From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/ARCMT/Common.h | 70 + clang/test/ARCMT/GC-check-warn-nsalloc.m | 12 + clang/test/ARCMT/GC-check.m | 20 + clang/test/ARCMT/GC-no-arc-runtime.m | 78 + clang/test/ARCMT/GC-no-arc-runtime.m.result | 73 + clang/test/ARCMT/GC-no-finalize-removal.m | 90 + clang/test/ARCMT/GC-no-finalize-removal.m.result | 98 + clang/test/ARCMT/GC.h | 6 + clang/test/ARCMT/GC.m | 95 + clang/test/ARCMT/GC.m.result | 90 + clang/test/ARCMT/Inputs/test.h | 15 + clang/test/ARCMT/Inputs/test.h.result | 13 + clang/test/ARCMT/Inputs/test1.m.in | 6 + clang/test/ARCMT/Inputs/test1.m.in.result | 5 + clang/test/ARCMT/Inputs/test2.m.in | 6 + clang/test/ARCMT/Inputs/test2.m.in.result | 5 + clang/test/ARCMT/api.m | 10 + clang/test/ARCMT/api.m.result | 10 + clang/test/ARCMT/assign-prop-no-arc-runtime.m | 15 + .../test/ARCMT/assign-prop-no-arc-runtime.m.result | 15 + clang/test/ARCMT/assign-prop-with-arc-runtime.m | 73 + .../ARCMT/assign-prop-with-arc-runtime.m.result | 73 + clang/test/ARCMT/atautorelease-2.m | 30 + clang/test/ARCMT/atautorelease-2.m.result | 29 + clang/test/ARCMT/atautorelease-3.m | 41 + clang/test/ARCMT/atautorelease-3.m.result | 32 + clang/test/ARCMT/atautorelease-check.m | 145 + clang/test/ARCMT/atautorelease.m | 62 + clang/test/ARCMT/atautorelease.m.result | 61 + clang/test/ARCMT/autoreleases.m | 49 + clang/test/ARCMT/autoreleases.m.result | 49 + clang/test/ARCMT/check-api.m | 43 + clang/test/ARCMT/check-with-serialized-diag.m | 55 + clang/test/ARCMT/checking.m | 327 ++ clang/test/ARCMT/cxx-checking.mm | 106 + clang/test/ARCMT/cxx-rewrite.mm | 34 + clang/test/ARCMT/cxx-rewrite.mm.result | 32 + clang/test/ARCMT/dealloc.m | 25 + clang/test/ARCMT/dealloc.m.result | 21 + clang/test/ARCMT/dispatch.m | 29 + clang/test/ARCMT/dispatch.m.result | 25 + clang/test/ARCMT/driver-migrate.m | 12 + clang/test/ARCMT/init.m | 40 + clang/test/ARCMT/init.m.result | 40 + clang/test/ARCMT/migrate-emit-errors.m | 12 + clang/test/ARCMT/migrate-plist-output.m | 52 + clang/test/ARCMT/migrate-space-in-path.m | 6 + clang/test/ARCMT/migrate.m | 6 + .../ARCMT/no-canceling-bridge-to-bridge-cast.m | 43 + clang/test/ARCMT/nonobjc-to-objc-cast-2.m | 35 + clang/test/ARCMT/nonobjc-to-objc-cast.m | 62 + clang/test/ARCMT/nonobjc-to-objc-cast.m.result | 62 + clang/test/ARCMT/objcmt-numeric-literals.m | 501 ++++ clang/test/ARCMT/objcmt-numeric-literals.m.result | 501 ++++ clang/test/ARCMT/objcmt-subscripting-literals.m | 137 + .../ARCMT/objcmt-subscripting-literals.m.result | 137 + clang/test/ARCMT/releases-driver.m | 68 + clang/test/ARCMT/releases-driver.m.result | 61 + clang/test/ARCMT/releases.m | 99 + clang/test/ARCMT/releases.m.result | 90 + clang/test/ARCMT/remove-dealloc-method.m | 26 + clang/test/ARCMT/remove-dealloc-method.m.result | 20 + clang/test/ARCMT/remove-dealloc-zerouts.m | 44 + clang/test/ARCMT/remove-dealloc-zerouts.m.result | 39 + clang/test/ARCMT/remove-statements.m | 45 + clang/test/ARCMT/remove-statements.m.result | 38 + clang/test/ARCMT/retains.m | 71 + clang/test/ARCMT/retains.m.result | 65 + clang/test/ARCMT/rewrite-block-var.m | 45 + clang/test/ARCMT/rewrite-block-var.m.result | 45 + clang/test/ARCMT/safe-arc-assign.m | 14 + clang/test/ARCMT/safe-arc-assign.m.result | 14 + clang/test/ARCMT/with space/test.h | 15 + clang/test/ARCMT/with space/test.h.result | 13 + clang/test/ARCMT/with space/test1.m.in | 6 + clang/test/ARCMT/with space/test1.m.in.result | 5 + clang/test/ARCMT/with space/test2.m.in | 6 + clang/test/ARCMT/with space/test2.m.in.result | 5 + clang/test/ARCMT/with-arc-mode-check.m | 9 + clang/test/ARCMT/with-arc-mode-migrate.m | 13 + clang/test/ARCMT/with-arc-mode-migrate.m.result | 12 + clang/test/ARCMT/with-arc-mode-modify.m | 13 + clang/test/ARCMT/with-arc-mode-modify.m.result | 12 + clang/test/ASTMerge/Inputs/category1.m | 48 + clang/test/ASTMerge/Inputs/category2.m | 49 + clang/test/ASTMerge/Inputs/class-template1.cpp | 34 + clang/test/ASTMerge/Inputs/class-template2.cpp | 35 + clang/test/ASTMerge/Inputs/class1.cpp | 15 + clang/test/ASTMerge/Inputs/class2.cpp | 9 + clang/test/ASTMerge/Inputs/enum1.c | 42 + clang/test/ASTMerge/Inputs/enum2.c | 42 + clang/test/ASTMerge/Inputs/exprs1.c | 10 + clang/test/ASTMerge/Inputs/exprs2.c | 10 + clang/test/ASTMerge/Inputs/function1.c | 6 + clang/test/ASTMerge/Inputs/function2.c | 7 + clang/test/ASTMerge/Inputs/interface1.m | 103 + clang/test/ASTMerge/Inputs/interface2.m | 100 + clang/test/ASTMerge/Inputs/lit.local.cfg | 1 + clang/test/ASTMerge/Inputs/namespace1.cpp | 17 + clang/test/ASTMerge/Inputs/namespace2.cpp | 17 + clang/test/ASTMerge/Inputs/property1.m | 31 + clang/test/ASTMerge/Inputs/property2.m | 33 + clang/test/ASTMerge/Inputs/struct1.c | 63 + clang/test/ASTMerge/Inputs/struct2.c | 60 + clang/test/ASTMerge/Inputs/typedef1.c | 4 + clang/test/ASTMerge/Inputs/typedef2.c | 4 + clang/test/ASTMerge/Inputs/var1.c | 7 + clang/test/ASTMerge/Inputs/var1.h | 1 + clang/test/ASTMerge/Inputs/var2.c | 7 + clang/test/ASTMerge/category.m | 11 + clang/test/ASTMerge/class-template.cpp | 24 + clang/test/ASTMerge/class.cpp | 9 + clang/test/ASTMerge/enum.c | 25 + clang/test/ASTMerge/exprs.c | 4 + clang/test/ASTMerge/function.c | 9 + clang/test/ASTMerge/interface.m | 22 + clang/test/ASTMerge/namespace.cpp | 6 + clang/test/ASTMerge/property.m | 13 + clang/test/ASTMerge/struct.c | 42 + clang/test/ASTMerge/typedef.c | 7 + clang/test/ASTMerge/var.c | 12 + clang/test/Analysis/CFContainers.mm | 204 ++ clang/test/Analysis/CFDateGC.m | 86 + clang/test/Analysis/CFNumber.c | 34 + .../Analysis/CFRetainRelease_NSAssertionHandler.m | 73 + clang/test/Analysis/CGColorSpace.c | 19 + clang/test/Analysis/CheckNSError.m | 57 + clang/test/Analysis/MissingDealloc.m | 117 + clang/test/Analysis/NSPanel.m | 88 + clang/test/Analysis/NSString.m | 408 +++ clang/test/Analysis/NSWindow.m | 87 + clang/test/Analysis/NoReturn.m | 78 + clang/test/Analysis/OSAtomic_mac.cpp | 19 + clang/test/Analysis/ObjCProperties.m | 21 + clang/test/Analysis/ObjCRetSigs.m | 25 + clang/test/Analysis/PR2599.m | 63 + clang/test/Analysis/PR2978.m | 62 + clang/test/Analysis/PR3991.m | 69 + clang/test/Analysis/PR7218.c | 6 + clang/test/Analysis/PR9741.cpp | 8 + .../Analysis/additive-folding-range-constraints.c | 99 + clang/test/Analysis/additive-folding.c | 203 ++ clang/test/Analysis/analyzeOneFunction.m | 56 + clang/test/Analysis/analyze_display_progress.c | 9 + clang/test/Analysis/analyzer-stats.c | 14 + clang/test/Analysis/array-struct-region.c | 47 + clang/test/Analysis/array-struct.c | 178 ++ clang/test/Analysis/auto-obj-dtors-cfg-output.cpp | 864 ++++++ clang/test/Analysis/base-init.cpp | 31 + clang/test/Analysis/blocks.m | 90 + clang/test/Analysis/bool-assignment.cpp | 87 + clang/test/Analysis/bool-assignment2.c | 35 + clang/test/Analysis/bstring.c | 430 +++ clang/test/Analysis/casts.c | 67 + clang/test/Analysis/casts.m | 42 + clang/test/Analysis/cfref_PR2519.c | 46 + clang/test/Analysis/cfref_rdar6080742.c | 56 + clang/test/Analysis/check-deserialization.cpp | 20 + clang/test/Analysis/chroot.c | 24 + clang/test/Analysis/complex.c | 18 + clang/test/Analysis/concrete-address.c | 6 + clang/test/Analysis/constant-folding.c | 72 + clang/test/Analysis/coverage.c | 94 + clang/test/Analysis/cstring-syntax-cxx.cpp | 16 + clang/test/Analysis/cstring-syntax.c | 13 + clang/test/Analysis/cxx-crashes.cpp | 56 + clang/test/Analysis/dead-stores.c | 550 ++++ clang/test/Analysis/dead-stores.cpp | 112 + clang/test/Analysis/dead-stores.m | 90 + clang/test/Analysis/debug-CallGraph.c | 21 + clang/test/Analysis/default-analyze.m | 63 + clang/test/Analysis/default-diagnostic-visitors.c | 13 + clang/test/Analysis/delegates.m | 113 + clang/test/Analysis/derived-to-base.cpp | 15 + clang/test/Analysis/div-zero.cpp | 13 + clang/test/Analysis/domtest.c | 165 ++ clang/test/Analysis/dtor.cpp | 13 + clang/test/Analysis/dtors-in-dtor-cfg-output.cpp | 56 + clang/test/Analysis/dynamic-cast.cpp | 230 ++ clang/test/Analysis/elementtype.c | 13 + clang/test/Analysis/exercise-ps.c | 23 + clang/test/Analysis/fields.c | 28 + clang/test/Analysis/free.c | 72 + clang/test/Analysis/func.c | 15 + clang/test/Analysis/global-region-invalidation.c | 75 + clang/test/Analysis/html-diags-multifile.c | 17 + clang/test/Analysis/html-diags-multifile.h | 4 + clang/test/Analysis/html-diags.c | 20 + .../Analysis/idempotent-operations-limited-loops.c | 21 + clang/test/Analysis/idempotent-operations.c | 236 ++ clang/test/Analysis/idempotent-operations.cpp | 34 + clang/test/Analysis/idempotent-operations.m | 54 + clang/test/Analysis/initializer.cpp | 14 + clang/test/Analysis/initializers-cfg-output.cpp | 98 + clang/test/Analysis/inline-not-supported.c | 29 + clang/test/Analysis/inline-plist.c | 369 +++ clang/test/Analysis/inline-unique-reports.c | 184 ++ clang/test/Analysis/inline.c | 92 + clang/test/Analysis/inline2.c | 14 + clang/test/Analysis/inline3.c | 14 + clang/test/Analysis/inline4.c | 14 + clang/test/Analysis/iterators.cpp | 105 + .../test/Analysis/keychainAPI-diagnostic-visitor.m | 35 + clang/test/Analysis/keychainAPI.m | 409 +++ clang/test/Analysis/lambdas.cpp | 20 + clang/test/Analysis/lvalue.cpp | 6 + clang/test/Analysis/malloc-annotations.c | 271 ++ clang/test/Analysis/malloc-interprocedural.c | 98 + clang/test/Analysis/malloc-overflow.c | 113 + clang/test/Analysis/malloc-overflow.cpp | 11 + clang/test/Analysis/malloc-plist.c | 2814 ++++++++++++++++++ clang/test/Analysis/malloc-sizeof.c | 27 + clang/test/Analysis/malloc.c | 809 +++++ clang/test/Analysis/malloc.cpp | 16 + clang/test/Analysis/malloc.m | 37 + clang/test/Analysis/malloc.mm | 156 + clang/test/Analysis/method-arg-decay.m | 97 + clang/test/Analysis/method-call-intra-p.cpp | 32 + clang/test/Analysis/method-call.cpp | 41 + clang/test/Analysis/misc-ps-64.m | 47 + clang/test/Analysis/misc-ps-cxx0x.cpp | 75 + clang/test/Analysis/misc-ps-eager-assume.m | 146 + clang/test/Analysis/misc-ps-ranges.m | 59 + clang/test/Analysis/misc-ps-region-store-i386.m | 14 + clang/test/Analysis/misc-ps-region-store-x86_64.m | 14 + clang/test/Analysis/misc-ps-region-store.cpp | 580 ++++ clang/test/Analysis/misc-ps-region-store.m | 1343 +++++++++ clang/test/Analysis/misc-ps-region-store.mm | 48 + clang/test/Analysis/misc-ps.c | 128 + clang/test/Analysis/misc-ps.m | 1347 +++++++++ clang/test/Analysis/new.cpp | 15 + ...iver-undefined-larger-than-voidptr-ret-region.m | 32 + ...il-receiver-undefined-larger-than-voidptr-ret.m | 95 + clang/test/Analysis/no-exit-cfg.c | 18 + clang/test/Analysis/no-outofbounds.c | 32 + clang/test/Analysis/null-deref-ps-region.c | 14 + clang/test/Analysis/null-deref-ps.c | 313 ++ clang/test/Analysis/nullptr.cpp | 83 + clang/test/Analysis/objc-arc.m | 220 ++ clang/test/Analysis/objc-bool.m | 22 + clang/test/Analysis/objc-method-coverage.m | 17 + clang/test/Analysis/operator-calls.cpp | 16 + clang/test/Analysis/out-of-bounds.c | 154 + clang/test/Analysis/outofbound-notwork.c | 32 + clang/test/Analysis/outofbound.c | 88 + clang/test/Analysis/override-werror.c | 14 + clang/test/Analysis/plist-output-alternate.m | 972 ++++++ clang/test/Analysis/plist-output.m | 1339 +++++++++ clang/test/Analysis/pr4209.m | 72 + clang/test/Analysis/pr_2542_rdar_6793404.m | 67 + clang/test/Analysis/pr_4164.c | 40 + clang/test/Analysis/properties.m | 168 ++ clang/test/Analysis/pthreadlock.c | 137 + clang/test/Analysis/ptr-arith.c | 288 ++ clang/test/Analysis/rdar-6442306-1.m | 33 + clang/test/Analysis/rdar-6540084.m | 37 + clang/test/Analysis/rdar-6541136-region.c | 27 + clang/test/Analysis/rdar-6562655.m | 64 + ...dar-6600344-nil-receiver-undefined-struct-ret.m | 25 + clang/test/Analysis/rdar-7168531.m | 18 + clang/test/Analysis/redefined_system.c | 17 + clang/test/Analysis/refcnt_naming.m | 84 + clang/test/Analysis/reference.cpp | 58 + clang/test/Analysis/region-1.m | 91 + clang/test/Analysis/retain-release-gc-only.m | 387 +++ clang/test/Analysis/retain-release-inline.m | 347 +++ clang/test/Analysis/retain-release-path-notes-gc.m | 73 + clang/test/Analysis/retain-release-path-notes.m | 132 + clang/test/Analysis/retain-release-region-store.m | 257 ++ clang/test/Analysis/retain-release.m | 1741 +++++++++++ clang/test/Analysis/retain-release.mm | 368 +++ .../test/Analysis/security-syntax-checks-no-emit.c | 33 + clang/test/Analysis/security-syntax-checks.m | 199 ++ clang/test/Analysis/self-init.m | 256 ++ clang/test/Analysis/sizeofpointer.c | 8 + clang/test/Analysis/stack-addr-ps.c | 92 + clang/test/Analysis/stack-addr-ps.cpp | 86 + clang/test/Analysis/stack-block-returned.cpp | 9 + clang/test/Analysis/stackaddrleak.c | 34 + clang/test/Analysis/stats.c | 8 + clang/test/Analysis/stream.c | 85 + clang/test/Analysis/string-fail.c | 113 + clang/test/Analysis/string.c | 1124 +++++++ clang/test/Analysis/system-header-simulator-objc.h | 114 + clang/test/Analysis/system-header-simulator.h | 38 + clang/test/Analysis/taint-generic.c | 185 ++ clang/test/Analysis/taint-tester.c | 204 ++ clang/test/Analysis/taint-tester.cpp | 26 + clang/test/Analysis/taint-tester.m | 20 + clang/test/Analysis/temp-obj-dtors-cfg-output.cpp | 767 +++++ clang/test/Analysis/undef-buffers.c | 43 + clang/test/Analysis/uninit-msg-expr.m | 56 + clang/test/Analysis/uninit-ps-rdar6145427.m | 39 + clang/test/Analysis/uninit-vals-ps-region.m | 78 + clang/test/Analysis/uninit-vals-ps.c | 124 + clang/test/Analysis/uninit-vals.m | 33 + clang/test/Analysis/unions-region.m | 41 + clang/test/Analysis/unix-fns.c | 138 + clang/test/Analysis/unreachable-code-path.c | 141 + clang/test/Analysis/unused-ivars.m | 110 + clang/test/Analysis/variadic-method-types.m | 100 + clang/test/Analysis/virtualcall.cpp | 53 + clang/test/CMakeLists.txt | 117 + clang/test/CXX/basic/basic.def.odr/p1-var.cpp | 21 + clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp | 36 + clang/test/CXX/basic/basic.link/p9.cpp | 10 + .../basic.lookup.argdep/p2-template-id.cpp | 27 + .../basic/basic.lookup/basic.lookup.argdep/p2.cpp | 110 + .../basic/basic.lookup/basic.lookup.argdep/p3.cpp | 20 + .../basic/basic.lookup/basic.lookup.argdep/p4.cpp | 64 + .../basic.lookup/basic.lookup.classref/p1.cpp | 89 + .../basic.lookup/basic.lookup.classref/p3.cpp | 30 + .../basic/basic.lookup/basic.lookup.elab/p2.cpp | 60 + .../basic.lookup/basic.lookup.elab/templateid.cpp | 18 + .../basic.lookup.qual/class.qual/p2.cpp | 27 + .../basic.lookup.qual/namespace.qual/p2.cpp | 65 + .../basic.lookup.qual/namespace.qual/p3.cpp | 41 + .../basic.lookup.qual/namespace.qual/p4.cpp | 25 + .../basic.lookup.qual/namespace.qual/p5.cpp | 35 + .../basic/basic.lookup/basic.lookup.qual/p6-0x.cpp | 26 + .../basic/basic.lookup/basic.lookup.qual/p6.cpp | 24 + .../basic/basic.lookup/basic.lookup.udir/p1.cpp | 35 + .../basic/basic.lookup/basic.lookup.unqual/p11.cpp | 12 + .../basic/basic.lookup/basic.lookup.unqual/p12.cpp | 13 + .../basic/basic.lookup/basic.lookup.unqual/p13.cpp | 8 + .../basic/basic.lookup/basic.lookup.unqual/p14.cpp | 18 + .../basic/basic.lookup/basic.lookup.unqual/p15.cpp | 17 + .../basic/basic.lookup/basic.lookup.unqual/p3.cpp | 24 + .../basic/basic.lookup/basic.lookup.unqual/p7.cpp | 37 + .../basic/basic.scope/basic.scope.hiding/p2.cpp | 24 + .../basic/basic.scope/basic.scope.local/p4-0x.cpp | 68 + .../CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp | 26 + .../CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp | 18 + .../CXX/basic/basic.start/basic.start.main/p2a.cpp | 8 + .../CXX/basic/basic.start/basic.start.main/p2b.cpp | 8 + .../CXX/basic/basic.start/basic.start.main/p2c.cpp | 4 + .../CXX/basic/basic.start/basic.start.main/p2d.cpp | 4 + .../CXX/basic/basic.start/basic.start.main/p2e.cpp | 4 + .../CXX/basic/basic.start/basic.start.main/p2f.cpp | 7 + .../CXX/basic/basic.start/basic.start.main/p2g.cpp | 4 + .../CXX/basic/basic.start/basic.start.main/p2h.cpp | 5 + .../CXX/basic/basic.start/basic.start.main/p2i.cpp | 6 + .../basic.stc.dynamic.allocation/p1.cpp | 44 + .../basic.stc.dynamic.deallocation/p1.cpp | 11 + .../basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp | 7 + .../basic.stc.dynamic/p2-noexceptions.cpp | 13 + .../CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp | 28 + clang/test/CXX/basic/basic.types/p10.cpp | 132 + .../test/CXX/class.access/class.access.base/p1.cpp | 155 + .../test/CXX/class.access/class.access.base/p5.cpp | 75 + .../test/CXX/class.access/class.access.dcl/p1.cpp | 199 ++ .../test/CXX/class.access/class.access.nest/p1.cpp | 33 + clang/test/CXX/class.access/class.friend/p1.cpp | 356 +++ clang/test/CXX/class.access/class.friend/p11.cpp | 19 + .../CXX/class.access/class.friend/p2-cxx03.cpp | 13 + .../CXX/class.access/class.friend/p3-cxx0x.cpp | 29 + clang/test/CXX/class.access/class.friend/p6.cpp | 20 + .../CXX/class.access/class.protected/p1-cxx11.cpp | 20 + clang/test/CXX/class.access/class.protected/p1.cpp | 519 ++++ clang/test/CXX/class.access/p4.cpp | 510 ++++ clang/test/CXX/class.access/p6.cpp | 192 ++ clang/test/CXX/class.derived/class.abstract/p4.cpp | 80 + clang/test/CXX/class.derived/class.abstract/p5.cpp | 23 + .../CXX/class.derived/class.member.lookup/p6.cpp | 40 + .../CXX/class.derived/class.member.lookup/p8.cpp | 63 + .../CXX/class.derived/class.member.lookup/p9.cpp | 28 + clang/test/CXX/class.derived/class.virtual/p12.cpp | 19 + clang/test/CXX/class.derived/class.virtual/p2.cpp | 37 + .../test/CXX/class.derived/class.virtual/p3-0x.cpp | 53 + clang/test/CXX/class.derived/p1.cpp | 40 + clang/test/CXX/class.derived/p2.cpp | 8 + .../CXX/class/class.base/class.base.init/p5-0x.cpp | 26 + clang/test/CXX/class/class.bit/p2.cpp | 22 + clang/test/CXX/class/class.friend/p1-ambiguous.cpp | 37 + clang/test/CXX/class/class.friend/p1-cxx11.cpp | 12 + clang/test/CXX/class/class.friend/p1.cpp | 77 + clang/test/CXX/class/class.friend/p2.cpp | 10 + clang/test/CXX/class/class.friend/p6.cpp | 10 + clang/test/CXX/class/class.local/p1-0x.cpp | 18 + clang/test/CXX/class/class.local/p1.cpp | 18 + clang/test/CXX/class/class.local/p2.cpp | 11 + clang/test/CXX/class/class.local/p3.cpp | 30 + clang/test/CXX/class/class.local/p4.cpp | 10 + clang/test/CXX/class/class.mem/p1.cpp | 91 + clang/test/CXX/class/class.mem/p13.cpp | 40 + clang/test/CXX/class/class.mem/p14.cpp | 19 + clang/test/CXX/class/class.mem/p1b.cpp | 46 + clang/test/CXX/class/class.mem/p2.cpp | 58 + clang/test/CXX/class/class.mem/p5-0x.cpp | 9 + clang/test/CXX/class/class.mem/p8-0x.cpp | 53 + .../class/class.mfct/class.mfct.non-static/p3.cpp | 98 + clang/test/CXX/class/class.nest/p1-cxx0x.cpp | 14 + clang/test/CXX/class/class.nest/p1.cpp | 14 + clang/test/CXX/class/class.nest/p3.cpp | 25 + clang/test/CXX/class/class.nested.type/p1.cpp | 13 + .../class/class.static/class.static.data/p3.cpp | 44 + .../class/class.static/class.static.data/p4.cpp | 25 + clang/test/CXX/class/class.union/p1.cpp | 125 + clang/test/CXX/class/class.union/p2-0x.cpp | 48 + clang/test/CXX/class/p1-0x.cpp | 6 + clang/test/CXX/class/p2-0x.cpp | 28 + clang/test/CXX/class/p6-0x.cpp | 30 + clang/test/CXX/conv/conv.mem/p4.cpp | 65 + clang/test/CXX/conv/conv.prom/p2.cpp | 16 + clang/test/CXX/conv/conv.prom/p4.cpp | 9 + clang/test/CXX/conv/conv.ptr/p2.cpp | 6 + clang/test/CXX/conv/conv.qual/pr6089.cpp | 18 + .../namespace.def/namespace.memdef/p3.cpp | 93 + .../namespace.def/namespace.unnamed/p1.cpp | 42 + .../dcl.dcl/basic.namespace/namespace.def/p1.cpp | 9 + .../dcl.dcl/basic.namespace/namespace.def/p2.cpp | 24 + .../dcl.dcl/basic.namespace/namespace.def/p7.cpp | 13 + .../dcl.dcl/basic.namespace/namespace.def/p8.cpp | 118 + .../dcl.dcl/basic.namespace/namespace.udecl/p1.cpp | 110 + .../basic.namespace/namespace.udecl/p10.cpp | 34 + .../basic.namespace/namespace.udecl/p11.cpp | 91 + .../basic.namespace/namespace.udecl/p12.cpp | 163 + .../basic.namespace/namespace.udecl/p13.cpp | 76 + .../basic.namespace/namespace.udecl/p3-cxx0x.cpp | 46 + .../dcl.dcl/basic.namespace/namespace.udecl/p4.cpp | 213 ++ .../basic.namespace/namespace.udecl/p5-cxx0x.cpp | 12 + .../basic.namespace/namespace.udecl/p6-cxx0x.cpp | 8 + .../basic.namespace/namespace.udecl/p8-cxx0x.cpp | 15 + .../dcl.dcl/basic.namespace/namespace.udecl/p8.cpp | 98 + .../dcl.dcl/basic.namespace/namespace.udir/p1.cpp | 141 + .../dcl.dcl/basic.namespace/namespace.udir/p6.cpp | 15 + .../CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp | 13 + clang/test/CXX/dcl.dcl/dcl.enum/p5.cpp | 56 + clang/test/CXX/dcl.dcl/dcl.link/p7.cpp | 30 + .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp | 123 + .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp | 26 + .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp | 139 + .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp | 249 ++ .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp | 112 + .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp | 68 + .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp | 38 + .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp | 37 + .../test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp | 13 + .../test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp | 7 + .../test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp | 16 + clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp | 32 + clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp | 14 + clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp | 26 + clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp | 11 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp | 49 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp | 51 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp | 43 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp | 68 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp | 104 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp | 32 + .../dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp | 19 + .../dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp | 61 + .../dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp | 27 + .../dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp | 108 + clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp | 43 + .../CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp | 160 + clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp | 8 + clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp | 15 + clang/test/CXX/dcl.dcl/p4-0x.cpp | 21 + .../dcl.fct.def/dcl.fct.def.default/p2.cpp | 56 + .../CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp | 78 + .../CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp | 18 + .../CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp | 17 + .../dcl.init/dcl.init.list/p7-0x-fixits.cpp | 33 + .../CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp | 209 ++ .../dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp | 210 ++ .../CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp | 19 + .../test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp | 14 + .../test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp | 3 + .../CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp | 194 ++ .../dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp | 77 + .../dcl.init.ref/p5-cxx0x-no-extra-copy.cpp | 64 + .../dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp | 53 + .../CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp | 135 + .../test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp | 40 + .../CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp | 19 + .../CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp | 2 + clang/test/CXX/dcl.decl/dcl.init/p14-0x.cpp | 44 + clang/test/CXX/dcl.decl/dcl.init/p5.cpp | 20 + clang/test/CXX/dcl.decl/dcl.init/p6.cpp | 28 + .../dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp | 7 + .../test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp | 54 + .../dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp | 16 + .../dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp | 9 + .../dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp | 13 + .../dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp | 55 + .../dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp | 19 + .../dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp | 33 + .../dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp | 7 + .../dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp | 4 + .../dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp | 62 + .../test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp | 48 + .../test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp | 31 + .../CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp | 7 + clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp | 3 + .../CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp | 53 + clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp | 20 + .../CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp | 6 + clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp | 10 + .../CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp | 3 + .../test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp | 26 + clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp | 145 + .../CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp | 26 + clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp | 24 + clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp | 37 + clang/test/CXX/dcl.decl/dcl.name/p1.cpp | 20 + clang/test/CXX/dcl.decl/p4-0x.cpp | 8 + clang/test/CXX/except/except.handle/p16.cpp | 40 + clang/test/CXX/except/except.spec/canonical.cpp | 53 + clang/test/CXX/except/except.spec/p1.cpp | 81 + clang/test/CXX/except/except.spec/p11.cpp | 12 + clang/test/CXX/except/except.spec/p14-ir.cpp | 79 + clang/test/CXX/except/except.spec/p14.cpp | 41 + clang/test/CXX/except/except.spec/p15.cpp | 24 + .../CXX/except/except.spec/p2-dynamic-types.cpp | 34 + clang/test/CXX/except/except.spec/p2-places.cpp | 63 + clang/test/CXX/except/except.spec/p3.cpp | 106 + clang/test/CXX/except/except.spec/p5-pointers.cpp | 85 + clang/test/CXX/except/except.spec/p5-virtual.cpp | 96 + clang/test/CXX/except/except.spec/p9-dynamic.cpp | 12 + clang/test/CXX/except/except.spec/p9-noexcept.cpp | 19 + clang/test/CXX/except/except.spec/template.cpp | 12 + clang/test/CXX/expr/expr.ass/p9-cxx11.cpp | 34 + clang/test/CXX/expr/expr.cast/p4-0x.cpp | 11 + clang/test/CXX/expr/expr.cast/p4.cpp | 23 + clang/test/CXX/expr/expr.const/p2-0x.cpp | 596 ++++ clang/test/CXX/expr/expr.const/p3-0x-nowarn.cpp | 8 + clang/test/CXX/expr/expr.const/p3-0x.cpp | 110 + clang/test/CXX/expr/expr.const/p5-0x.cpp | 85 + clang/test/CXX/expr/expr.mptr.oper/p5.cpp | 61 + clang/test/CXX/expr/expr.mptr.oper/p6-0x.cpp | 34 + clang/test/CXX/expr/expr.post/expr.call/p7-0x.cpp | 30 + .../CXX/expr/expr.post/expr.const.cast/p1-0x.cpp | 17 + .../CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp | 14 + clang/test/CXX/expr/expr.post/expr.ref/p3.cpp | 15 + .../expr/expr.post/expr.reinterpret.cast/p1-0x.cpp | 16 + .../CXX/expr/expr.post/expr.static.cast/p3-0x.cpp | 24 + .../CXX/expr/expr.post/expr.static.cast/p9-0x.cpp | 29 + .../CXX/expr/expr.post/expr.type.conv/p1-0x.cpp | 12 + .../expr/expr.prim/expr.prim.general/p12-0x.cpp | 38 + .../CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp | 101 + .../CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp | 20 + .../CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp | 78 + .../CXX/expr/expr.prim/expr.prim.lambda/blocks.mm | 88 + .../expr.prim.lambda/default-arguments.cpp | 50 + .../CXX/expr/expr.prim/expr.prim.lambda/p10.cpp | 40 + .../CXX/expr/expr.prim/expr.prim.lambda/p11.cpp | 16 + .../CXX/expr/expr.prim/expr.prim.lambda/p12.cpp | 77 + .../CXX/expr/expr.prim/expr.prim.lambda/p13.cpp | 16 + .../CXX/expr/expr.prim/expr.prim.lambda/p14.cpp | 75 + .../CXX/expr/expr.prim/expr.prim.lambda/p15.cpp | 12 + .../CXX/expr/expr.prim/expr.prim.lambda/p16.cpp | 40 + .../CXX/expr/expr.prim/expr.prim.lambda/p18.cpp | 45 + .../CXX/expr/expr.prim/expr.prim.lambda/p19.cpp | 28 + .../CXX/expr/expr.prim/expr.prim.lambda/p2.cpp | 42 + .../CXX/expr/expr.prim/expr.prim.lambda/p20.cpp | 12 + .../CXX/expr/expr.prim/expr.prim.lambda/p21.cpp | 9 + .../CXX/expr/expr.prim/expr.prim.lambda/p23.cpp | 58 + .../CXX/expr/expr.prim/expr.prim.lambda/p3.cpp | 6 + .../CXX/expr/expr.prim/expr.prim.lambda/p4.cpp | 51 + .../test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm | 8 + .../CXX/expr/expr.prim/expr.prim.lambda/p5.cpp | 64 + .../CXX/expr/expr.prim/expr.prim.lambda/p6.cpp | 22 + .../CXX/expr/expr.prim/expr.prim.lambda/p7.cpp | 56 + .../CXX/expr/expr.prim/expr.prim.lambda/p8.cpp | 29 + .../expr/expr.prim/expr.prim.lambda/templates.cpp | 149 + clang/test/CXX/expr/expr.unary/expr.delete/p5.cpp | 46 + .../CXX/expr/expr.unary/expr.new/p17-crash.cpp | 14 + clang/test/CXX/expr/expr.unary/expr.new/p17.cpp | 16 + clang/test/CXX/expr/expr.unary/expr.new/p19.cpp | 46 + .../test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp | 23 + clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp | 13 + clang/test/CXX/expr/expr.unary/expr.new/p20.cpp | 141 + .../test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp | 38 + .../CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp | 26 + .../expr/expr.unary/expr.unary.noexcept/sema.cpp | 189 ++ .../CXX/expr/expr.unary/expr.unary.noexcept/ser.h | 8 + .../test/CXX/expr/expr.unary/expr.unary.op/p3.cpp | 28 + .../test/CXX/expr/expr.unary/expr.unary.op/p4.cpp | 43 + .../test/CXX/expr/expr.unary/expr.unary.op/p6.cpp | 35 + clang/test/CXX/expr/p3.cpp | 15 + clang/test/CXX/expr/p8.cpp | 18 + clang/test/CXX/expr/p9.cpp | 50 + clang/test/CXX/lex/lex.charset/p2-cxx11.cpp | 42 + clang/test/CXX/lex/lex.charset/p2-cxx98.cpp | 55 + clang/test/CXX/lex/lex.literal/lex.ccon/p1.cpp | 16 + clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp | 7 + clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp | 14 + clang/test/CXX/lex/lex.literal/lex.ext/p2.cpp | 16 + clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp | 18 + clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp | 18 + clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp | 13 + clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp | 14 + clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp | 27 + clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp | 18 + clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp | 13 + clang/test/CXX/lex/lex.pptoken/p3-0x.cpp | 11 + clang/test/CXX/lex/lex.trigraph/p1.cpp | 19 + clang/test/CXX/lex/lex.trigraph/p2.cpp | 3 + clang/test/CXX/lex/lex.trigraph/p3.cpp | 8 + clang/test/CXX/over/over.built/p1.cpp | 16 + clang/test/CXX/over/over.built/p23.cpp | 25 + clang/test/CXX/over/over.built/p25.cpp | 15 + clang/test/CXX/over/over.load/p2-0x.cpp | 24 + .../over.best.ics/over.ics.list/p6.cpp | 15 + .../over.best.ics/over.ics.user/p3-0x.cpp | 14 + .../over.match.best/over.ics.rank/p3-0x.cpp | 59 + .../CXX/over/over.match/over.match.best/p1.cpp | 16 + .../over.match.funcs/over.match.copy/p1.cpp | 37 + .../CXX/over/over.match/over.match.funcs/p4-0x.cpp | 70 + clang/test/CXX/over/over.oper/over.literal/p2.cpp | 35 + clang/test/CXX/over/over.oper/over.literal/p3.cpp | 40 + clang/test/CXX/over/over.oper/over.literal/p5.cpp | 22 + clang/test/CXX/over/over.oper/over.literal/p6.cpp | 13 + clang/test/CXX/over/over.oper/over.literal/p7.cpp | 16 + clang/test/CXX/over/over.oper/over.literal/p8.cpp | 19 + clang/test/CXX/over/over.over/p1.cpp | 94 + .../over.over/p2-resolve-single-template-id.cpp | 191 ++ clang/test/CXX/over/over.over/p2.cpp | 9 + clang/test/CXX/over/over.over/p4.cpp | 20 + .../CXX/special/class.copy/implicit-move-def.cpp | 117 + .../test/CXX/special/class.copy/implicit-move.cpp | 236 ++ clang/test/CXX/special/class.copy/p11.0x.copy.cpp | 121 + clang/test/CXX/special/class.copy/p11.0x.move.cpp | 164 ++ clang/test/CXX/special/class.copy/p13-0x.cpp | 60 + clang/test/CXX/special/class.copy/p15-0x.cpp | 41 + clang/test/CXX/special/class.copy/p15-inclass.cpp | 42 + clang/test/CXX/special/class.copy/p20.cpp | 46 + clang/test/CXX/special/class.copy/p3.cpp | 27 + clang/test/CXX/special/class.copy/p33-0x.cpp | 57 + clang/test/CXX/special/class.copy/p8-cxx11.cpp | 48 + clang/test/CXX/special/class.copy/p9.cpp | 44 + clang/test/CXX/special/class.ctor/p1.cpp | 42 + clang/test/CXX/special/class.ctor/p4-0x.cpp | 7 + clang/test/CXX/special/class.ctor/p5-0x.cpp | 182 ++ clang/test/CXX/special/class.ctor/p6-0x.cpp | 57 + clang/test/CXX/special/class.dtor/p10-0x.cpp | 39 + clang/test/CXX/special/class.dtor/p2-0x.cpp | 10 + clang/test/CXX/special/class.dtor/p2.cpp | 7 + clang/test/CXX/special/class.dtor/p3-0x.cpp | 177 ++ clang/test/CXX/special/class.dtor/p5-0x.cpp | 104 + clang/test/CXX/special/class.dtor/p9.cpp | 85 + clang/test/CXX/special/class.free/p1.cpp | 11 + clang/test/CXX/special/class.free/p6.cpp | 11 + clang/test/CXX/special/class.inhctor/elsewhere.cpp | 57 + clang/test/CXX/special/class.inhctor/p3.cpp | 48 + clang/test/CXX/special/class.inhctor/p7.cpp | 29 + .../special/class.init/class.base.init/p8-0x.cpp | 62 + .../special/class.init/class.base.init/p9-0x.cpp | 36 + clang/test/CXX/special/class.temporary/p1.cpp | 57 + clang/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp | 40 + clang/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp | 55 + clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp | 47 + .../CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp | 209 ++ clang/test/CXX/stmt.stmt/stmt.label/p1.cpp | 25 + clang/test/CXX/stmt.stmt/stmt.select/p3.cpp | 19 + .../stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp | 39 + clang/test/CXX/temp/p3.cpp | 18 + .../CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp | 60 + .../test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp | 95 + .../test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp | 205 ++ .../CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp | 40 + .../CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp | 20 + clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp | 42 + clang/test/CXX/temp/temp.decls/p3.cpp | 7 + clang/test/CXX/temp/temp.decls/temp.alias/p1.cpp | 8 + clang/test/CXX/temp/temp.decls/temp.alias/p2.cpp | 45 + clang/test/CXX/temp/temp.decls/temp.alias/p3.cpp | 13 + .../CXX/temp/temp.decls/temp.class.spec/p6.cpp | 76 + .../CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp | 8 + .../CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp | 13 + .../CXX/temp/temp.decls/temp.class.spec/p9.cpp | 26 + .../temp.class.spec/temp.class.order/p2.cpp | 48 + .../temp.class.spec.mfunc/p1-neg.cpp | 25 + .../temp.class.spec/temp.class.spec.mfunc/p1.cpp | 25 + .../temp.decls/temp.class/temp.mem.class/p1.cpp | 27 + .../temp.decls/temp.class/temp.mem.enum/p1.cpp | 152 + .../temp.class/temp.mem.func/p1-retmem.cpp | 28 + .../temp.decls/temp.class/temp.mem.func/p1.cpp | 100 + .../temp.decls/temp.class/temp.mem.func/p1inst.cpp | 17 + .../temp.decls/temp.class/temp.mem.func/pr5056.cpp | 17 + .../temp.decls/temp.class/temp.static/p1-inst.cpp | 28 + .../temp/temp.decls/temp.class/temp.static/p1.cpp | 26 + .../temp.decls/temp.fct/temp.func.order/p3-0x.cpp | 17 + .../temp.decls/temp.fct/temp.func.order/p3.cpp | 16 + .../temp.decls/temp.fct/temp.func.order/p4.cpp | 23 + .../temp.decls/temp.fct/temp.func.order/p5.cpp | 12 + .../temp.decls/temp.fct/temp.over.link/p4-neg.cpp | 27 + .../temp/temp.decls/temp.fct/temp.over.link/p4.cpp | 13 + .../temp/temp.decls/temp.fct/temp.over.link/p6.cpp | 16 + clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp | 358 +++ clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp | 12 + clang/test/CXX/temp/temp.decls/temp.friend/p4.cpp | 28 + clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp | 103 + clang/test/CXX/temp/temp.decls/temp.friend/p8.cpp | 6 + clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp | 35 + clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp | 6 + clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp | 79 + .../temp/temp.decls/temp.variadic/deduction.cpp | 50 + .../temp/temp.decls/temp.variadic/example-bind.cpp | 352 +++ .../temp.decls/temp.variadic/example-function.cpp | 86 + .../temp.decls/temp.variadic/example-tuple.cpp | 260 ++ .../temp/temp.decls/temp.variadic/ext-blocks.cpp | 46 + .../temp.decls/temp.variadic/fixed-expansion.cpp | 127 + .../temp.variadic/injected-class-name.cpp | 75 + .../temp.decls/temp.variadic/metafunctions.cpp | 274 ++ .../temp.variadic/multi-level-substitution.cpp | 251 ++ .../test/CXX/temp/temp.decls/temp.variadic/p1.cpp | 9 + .../test/CXX/temp/temp.decls/temp.variadic/p2.cpp | 22 + .../test/CXX/temp/temp.decls/temp.variadic/p4.cpp | 193 ++ .../test/CXX/temp/temp.decls/temp.variadic/p5.cpp | 403 +++ .../temp.variadic/parameter-matching.cpp | 43 + .../temp.decls/temp.variadic/partial-ordering.cpp | 61 + .../temp/temp.fct.spec/temp.arg.explicit/p1.cpp | 12 + .../temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp | 27 + .../temp.arg.explicit/p3-nodeduct.cpp | 36 + .../temp/temp.fct.spec/temp.arg.explicit/p3.cpp | 65 + .../temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp | 68 + .../CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp | 41 + .../test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp | 26 + .../temp/temp.fct.spec/temp.deduct/sfinae-1.cpp | 42 + .../temp.deduct/temp.deduct.call/basic.cpp | 30 + .../temp.deduct/temp.deduct.call/p1-0x.cpp | 88 + .../temp.deduct/temp.deduct.call/p2.cpp | 31 + .../temp.deduct/temp.deduct.call/p3-0x.cpp | 46 + .../temp.deduct/temp.deduct.call/p3.cpp | 148 + .../temp.deduct/temp.deduct.call/p4.cpp | 20 + .../temp.deduct/temp.deduct.call/p6.cpp | 128 + .../temp.deduct/temp.deduct.conv/p2.cpp | 36 + .../temp.deduct/temp.deduct.conv/p3.cpp | 30 + .../temp.deduct/temp.deduct.conv/p4.cpp | 44 + .../temp.deduct/temp.deduct.funcaddr/p1.cpp | 22 + .../temp.deduct/temp.deduct.partial/p11.cpp | 47 + .../temp.deduct/temp.deduct.partial/p12.cpp | 27 + .../temp.deduct/temp.deduct.partial/p9-0x.cpp | 10 + .../temp.deduct/temp.deduct.type/p10-0x.cpp | 4 + .../temp.deduct/temp.deduct.type/p17.cpp | 31 + .../temp.deduct/temp.deduct.type/p2-0x.cpp | 23 + .../temp.deduct/temp.deduct.type/p21.cpp | 31 + .../temp.deduct/temp.deduct.type/p22.cpp | 14 + .../temp.deduct/temp.deduct.type/p5-0x.cpp | 22 + .../temp.deduct/temp.deduct.type/p8-0x.cpp | 47 + .../temp.deduct/temp.deduct.type/p9-0x.cpp | 55 + clang/test/CXX/temp/temp.names/p2.cpp | 13 + clang/test/CXX/temp/temp.names/p4.cpp | 15 + clang/test/CXX/temp/temp.param/p1.cpp | 12 + clang/test/CXX/temp/temp.param/p10-0x.cpp | 13 + clang/test/CXX/temp/temp.param/p10.cpp | 12 + clang/test/CXX/temp/temp.param/p11-0x.cpp | 81 + clang/test/CXX/temp/temp.param/p11.cpp | 15 + clang/test/CXX/temp/temp.param/p12.cpp | 39 + clang/test/CXX/temp/temp.param/p13.cpp | 14 + clang/test/CXX/temp/temp.param/p14.cpp | 5 + clang/test/CXX/temp/temp.param/p15-cxx0x.cpp | 24 + clang/test/CXX/temp/temp.param/p15.cpp | 12 + clang/test/CXX/temp/temp.param/p2.cpp | 22 + clang/test/CXX/temp/temp.param/p3.cpp | 40 + clang/test/CXX/temp/temp.param/p4.cpp | 21 + clang/test/CXX/temp/temp.param/p5.cpp | 13 + clang/test/CXX/temp/temp.param/p7.cpp | 15 + clang/test/CXX/temp/temp.param/p8.cpp | 6 + clang/test/CXX/temp/temp.param/p9-0x.cpp | 61 + clang/test/CXX/temp/temp.param/p9.cpp | 23 + .../temp/temp.res/temp.dep.res/temp.point/p1.cpp | 32 + clang/test/CXX/temp/temp.res/temp.dep/p3.cpp | 43 + .../temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp | 27 + .../temp.res/temp.dep/temp.dep.constexpr/p2.cpp | 21 + .../temp/temp.res/temp.dep/temp.dep.type/p1.cpp | 30 + clang/test/CXX/temp/temp.res/temp.local/p1.cpp | 32 + clang/test/CXX/temp/temp.res/temp.local/p3.cpp | 32 + clang/test/CXX/temp/temp.res/temp.local/p7.cpp | 10 + clang/test/CXX/temp/temp.res/temp.local/p8.cpp | 53 + clang/test/CXX/temp/temp.res/temp.local/p9.cpp | 15 + clang/test/CXX/temp/temp.spec/p5.cpp | 47 + .../CXX/temp/temp.spec/temp.expl.spec/examples.cpp | 334 +++ .../test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp | 99 + .../test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp | 7 + .../test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp | 8 + .../test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp | 6 + .../test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp | 42 + .../test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp | 33 + .../test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp | 38 + .../test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp | 34 + .../test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp | 20 + .../test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp | 30 + .../CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp | 302 ++ .../test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp | 252 ++ .../test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp | 14 + .../test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp | 30 + .../test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp | 13 + .../test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp | 58 + .../temp/temp.spec/temp.expl.spec/p5-example.cpp | 34 + .../test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp | 61 + .../test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp | 63 + .../test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp | 14 + .../CXX/temp/temp.spec/temp.explicit/p1-0x.cpp | 24 + .../CXX/temp/temp.spec/temp.explicit/p1-emit.cpp | 29 + clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp | 89 + .../test/CXX/temp/temp.spec/temp.explicit/p10.cpp | 33 + .../test/CXX/temp/temp.spec/temp.explicit/p11.cpp | 18 + .../test/CXX/temp/temp.spec/temp.explicit/p12.cpp | 6 + clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp | 43 + .../CXX/temp/temp.spec/temp.explicit/p3-0x.cpp | 65 + clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp | 81 + clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp | 48 + clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp | 17 + clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp | 35 + clang/test/CXX/temp/temp.spec/temp.explicit/p7.cpp | 36 + clang/test/CXX/temp/temp.spec/temp.explicit/p8.cpp | 40 + .../temp/temp.spec/temp.explicit/p9-linkage.cpp | 66 + clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp | 59 + clang/test/CXX/temp/temp.spec/temp.inst/p1.cpp | 104 + clang/test/CXX/temp/temp.spec/temp.inst/p11.cpp | 15 + clang/test/CXX/temp/temp.type/p1-0x.cpp | 23 + clang/test/CodeCompletion/Inputs/macros.h | 4 + clang/test/CodeCompletion/Inputs/reserved.h | 2 + clang/test/CodeCompletion/PR9728.cpp | 9 + clang/test/CodeCompletion/call.c | 15 + clang/test/CodeCompletion/call.cpp | 28 + .../CodeCompletion/enum-switch-case-qualified.cpp | 32 + clang/test/CodeCompletion/enum-switch-case.c | 45 + clang/test/CodeCompletion/enum-switch-case.cpp | 28 + clang/test/CodeCompletion/function-templates.cpp | 23 + clang/test/CodeCompletion/functions.cpp | 8 + clang/test/CodeCompletion/macros.c | 34 + clang/test/CodeCompletion/member-access.c | 12 + clang/test/CodeCompletion/member-access.cpp | 42 + clang/test/CodeCompletion/namespace-alias.cpp | 20 + clang/test/CodeCompletion/namespace.cpp | 14 + .../test/CodeCompletion/nested-name-specifier.cpp | 17 + clang/test/CodeCompletion/objc-message.m | 35 + clang/test/CodeCompletion/operator.cpp | 17 + clang/test/CodeCompletion/ordinary-name.c | 17 + clang/test/CodeCompletion/ordinary-name.cpp | 229 ++ clang/test/CodeCompletion/preamble.c | 7 + clang/test/CodeCompletion/some_struct.h | 1 + clang/test/CodeCompletion/stdin.c | 7 + clang/test/CodeCompletion/tag.c | 12 + clang/test/CodeCompletion/tag.cpp | 27 + clang/test/CodeCompletion/templates.cpp | 28 + clang/test/CodeCompletion/truncation.c | 15 + clang/test/CodeCompletion/truncation.c.h | 5 + clang/test/CodeCompletion/using-namespace.cpp | 20 + clang/test/CodeCompletion/using.cpp | 24 + .../CodeGen/2002-01-23-LoadQISIReloadFailure.c | 11 + clang/test/CodeGen/2002-01-24-ComplexSpaceInType.c | 11 + clang/test/CodeGen/2002-01-24-HandleCallInsnSEGV.c | 9 + clang/test/CodeGen/2002-02-13-ConditionalInCall.c | 11 + clang/test/CodeGen/2002-02-13-ReloadProblem.c | 18 + .../test/CodeGen/2002-02-13-TypeVarNameCollision.c | 16 + clang/test/CodeGen/2002-02-13-UnnamedLocal.c | 21 + clang/test/CodeGen/2002-02-14-EntryNodePreds.c | 37 + clang/test/CodeGen/2002-02-16-RenamingTest.c | 18 + clang/test/CodeGen/2002-02-17-ArgumentAddress.c | 39 + clang/test/CodeGen/2002-02-18-64bitConstant.c | 10 + clang/test/CodeGen/2002-02-18-StaticData.c | 13 + clang/test/CodeGen/2002-03-11-LargeCharInString.c | 10 + .../test/CodeGen/2002-03-12-ArrayInitialization.c | 19 + clang/test/CodeGen/2002-03-12-StructInitialize.c | 14 + clang/test/CodeGen/2002-03-12-StructInitializer.c | 18 + clang/test/CodeGen/2002-03-14-BrokenPHINode.c | 19 + clang/test/CodeGen/2002-03-14-BrokenSSA.c | 17 + clang/test/CodeGen/2002-03-14-QuotesInStrConst.c | 10 + clang/test/CodeGen/2002-04-07-SwitchStmt.c | 22 + clang/test/CodeGen/2002-04-08-LocalArray.c | 14 + clang/test/CodeGen/2002-04-09-StructRetVal.c | 12 + clang/test/CodeGen/2002-04-10-StructParameters.c | 25 + clang/test/CodeGen/2002-05-23-StaticValues.c | 15 + clang/test/CodeGen/2002-05-23-TypeNameCollision.c | 19 + clang/test/CodeGen/2002-05-24-Alloca.c | 11 + .../CodeGen/2002-06-25-FWriteInterfaceFailure.c | 9 + clang/test/CodeGen/2002-07-14-MiscListTests.c | 71 + clang/test/CodeGen/2002-07-14-MiscTests.c | 57 + clang/test/CodeGen/2002-07-14-MiscTests2.c | 13 + clang/test/CodeGen/2002-07-14-MiscTests3.c | 182 ++ clang/test/CodeGen/2002-07-16-HardStringInit.c | 8 + clang/test/CodeGen/2002-07-17-StringConstant.c | 4 + clang/test/CodeGen/2002-07-30-SubregSetAssertion.c | 12 + clang/test/CodeGen/2002-07-30-UnionTest.c | 22 + clang/test/CodeGen/2002-07-30-VarArgsCallFailure.c | 8 + clang/test/CodeGen/2002-07-31-BadAssert.c | 16 + clang/test/CodeGen/2002-07-31-SubregFailure.c | 14 + clang/test/CodeGen/2002-08-02-UnionTest.c | 19 + clang/test/CodeGen/2002-08-19-RecursiveLocals.c | 18 + clang/test/CodeGen/2002-09-08-PointerShifts.c | 6 + clang/test/CodeGen/2002-09-18-UnionProblem.c | 26 + clang/test/CodeGen/2002-09-19-StarInLabel.c | 9 + clang/test/CodeGen/2002-10-12-TooManyArguments.c | 8 + clang/test/CodeGen/2002-12-15-GlobalBoolTest.c | 5 + clang/test/CodeGen/2002-12-15-GlobalConstantTest.c | 8 + clang/test/CodeGen/2002-12-15-GlobalRedefinition.c | 5 + clang/test/CodeGen/2002-12-15-StructParameters.c | 18 + clang/test/CodeGen/2003-01-30-UnionInit.c | 8 + clang/test/CodeGen/2003-03-03-DeferredType.c | 12 + clang/test/CodeGen/2003-06-22-UnionCrash.c | 13 + .../2003-06-23-GCC-fold-infinite-recursion.c | 6 + clang/test/CodeGen/2003-06-26-CFECrash.c | 19 + .../2003-06-29-MultipleFunctionDefinition.c | 8 + .../CodeGen/2003-07-22-ArrayAccessTypeSafety.c | 7 + .../test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c | 14 + .../test/CodeGen/2003-08-17-DeadCodeShortCircuit.c | 6 + clang/test/CodeGen/2003-08-18-SigSetJmp.c | 10 + clang/test/CodeGen/2003-08-18-StructAsValue.c | 11 + clang/test/CodeGen/2003-08-20-BadBitfieldRef.c | 8 + clang/test/CodeGen/2003-08-20-PrototypeMismatch.c | 15 + clang/test/CodeGen/2003-08-20-vfork-bug.c | 6 + .../test/CodeGen/2003-08-21-BinOp-Type-Mismatch.c | 10 + clang/test/CodeGen/2003-08-21-StmtExpr.c | 12 + clang/test/CodeGen/2003-08-21-WideString.c | 16 + clang/test/CodeGen/2003-08-23-LocalUnionTest.c | 11 + clang/test/CodeGen/2003-08-29-BitFieldStruct.c | 13 + clang/test/CodeGen/2003-08-29-HugeCharConst.c | 5 + clang/test/CodeGen/2003-08-29-StructLayoutBug.c | 10 + .../test/CodeGen/2003-08-30-AggregateInitializer.c | 16 + .../2003-08-30-LargeIntegerBitfieldMember.c | 9 + clang/test/CodeGen/2003-09-18-BitfieldTests.c | 30 + clang/test/CodeGen/2003-09-30-StructLayout.c | 18 + clang/test/CodeGen/2003-10-02-UnionLValueError.c | 11 + clang/test/CodeGen/2003-10-06-NegateExprType.c | 8 + .../test/CodeGen/2003-10-09-UnionInitializerBug.c | 17 + clang/test/CodeGen/2003-10-28-ident.c | 4 + clang/test/CodeGen/2003-10-29-AsmRename.c | 22 + .../test/CodeGen/2003-11-01-C99-CompoundLiteral.c | 8 + clang/test/CodeGen/2003-11-01-EmptyStructCrash.c | 6 + clang/test/CodeGen/2003-11-01-GlobalUnionInit.c | 7 + clang/test/CodeGen/2003-11-03-AddrArrayElement.c | 11 + clang/test/CodeGen/2003-11-04-EmptyStruct.c | 6 + clang/test/CodeGen/2003-11-04-OutOfMemory.c | 9 + .../2003-11-08-PointerSubNotGetelementptr.c | 10 + clang/test/CodeGen/2003-11-12-VoidString.c | 4 + clang/test/CodeGen/2003-11-13-TypeSafety.c | 5 + clang/test/CodeGen/2003-11-16-StaticArrayInit.c | 8 + clang/test/CodeGen/2003-11-18-CondExprLValue.c | 9 + clang/test/CodeGen/2003-11-19-AddressOfRegister.c | 11 + clang/test/CodeGen/2003-11-19-BitFieldArray.c | 12 + clang/test/CodeGen/2003-11-20-Bitfields.c | 12 + clang/test/CodeGen/2003-11-20-ComplexDivision.c | 7 + clang/test/CodeGen/2003-11-20-UnionBitfield.c | 12 + clang/test/CodeGen/2003-11-26-PointerShift.c | 6 + clang/test/CodeGen/2003-11-27-ConstructorCast.c | 14 + .../CodeGen/2003-11-27-UnionCtorInitialization.c | 16 + .../test/CodeGen/2003-12-14-ExternInlineSupport.c | 3 + clang/test/CodeGen/2004-01-01-UnknownInitSize.c | 14 + .../test/CodeGen/2004-01-08-ExternInlineRedefine.c | 14 + clang/test/CodeGen/2004-02-12-LargeAggregateCopy.c | 8 + .../CodeGen/2004-02-13-BuiltinFrameReturnAddress.c | 10 + clang/test/CodeGen/2004-02-13-IllegalVararg.c | 9 + clang/test/CodeGen/2004-02-13-Memset.c | 12 + clang/test/CodeGen/2004-02-14-ZeroInitializer.c | 4 + clang/test/CodeGen/2004-02-20-Builtins.c | 5 + clang/test/CodeGen/2004-03-07-ComplexDivEquals.c | 6 + clang/test/CodeGen/2004-03-07-ExternalConstant.c | 7 + .../CodeGen/2004-03-09-LargeArrayInitializers.c | 32 + clang/test/CodeGen/2004-03-15-SimpleIndirectGoto.c | 23 + clang/test/CodeGen/2004-03-16-AsmRegisterCrash.c | 12 + clang/test/CodeGen/2004-05-07-VarArrays.c | 5 + clang/test/CodeGen/2004-05-21-IncompleteEnum.c | 5 + clang/test/CodeGen/2004-06-08-OpaqueStructArg.c | 7 + clang/test/CodeGen/2004-06-17-UnorderedBuiltins.c | 24 + clang/test/CodeGen/2004-06-17-UnorderedCompares.c | 19 + .../2004-06-18-VariableLengthArrayOfStructures.c | 10 + clang/test/CodeGen/2004-07-06-FunctionCast.c | 10 + clang/test/CodeGen/2004-08-06-LargeStructTest.c | 19 + .../CodeGen/2004-11-25-UnnamedBitfieldPadding.c | 8 + .../test/CodeGen/2004-11-27-InvalidConstantExpr.c | 10 + .../CodeGen/2004-11-27-StaticFunctionRedeclare.c | 15 + clang/test/CodeGen/2005-01-02-ConstantInits.c | 24 + clang/test/CodeGen/2005-01-02-PointerDifference.c | 4 + clang/test/CodeGen/2005-01-02-VAArgError-ICE.c | 9 + clang/test/CodeGen/2005-02-20-AggregateSAVEEXPR.c | 5 + clang/test/CodeGen/2005-02-27-MarkGlobalConstant.c | 12 + clang/test/CodeGen/2005-03-05-OffsetOfHack.c | 12 + .../test/CodeGen/2005-03-06-OffsetOfStructCrash.c | 14 + clang/test/CodeGen/2005-03-11-Prefetch.c | 7 + clang/test/CodeGen/2005-04-09-ComplexOps.c | 8 + clang/test/CodeGen/2005-05-10-GlobalUnionInit.c | 6 + .../CodeGen/2005-06-15-ExpandGotoInternalProblem.c | 14 + clang/test/CodeGen/2005-07-20-SqrtNoErrno.c | 10 + clang/test/CodeGen/2005-07-26-UnionInitCrash.c | 3 + .../test/CodeGen/2005-07-28-IncorrectWeakGlobal.c | 5 + clang/test/CodeGen/2005-09-20-ComplexConstants.c | 4 + clang/test/CodeGen/2005-09-24-AsmUserPrefix.c | 8 + clang/test/CodeGen/2005-09-24-BitFieldCrash.c | 33 + clang/test/CodeGen/2005-12-04-AttributeUsed.c | 7 + .../CodeGen/2005-12-04-DeclarationLineNumbers.c | 23 + clang/test/CodeGen/2006-01-13-Includes.c | 10 + clang/test/CodeGen/2006-01-13-StackSave.c | 11 + .../2006-01-16-BitCountIntrinsicsUnsigned.c | 12 + clang/test/CodeGen/2006-01-23-FileScopeAsm.c | 12 + clang/test/CodeGen/2006-03-03-MissingInitializer.c | 10 + clang/test/CodeGen/2006-03-16-VectorCtor.c | 10 + clang/test/CodeGen/2006-03-17-KnRMismatch.c | 8 + clang/test/CodeGen/2006-05-19-SingleEltReturn.c | 23 + clang/test/CodeGen/2006-07-31-PR854.c | 12 + clang/test/CodeGen/2006-09-11-BitfieldRefCrash.c | 12 + clang/test/CodeGen/2006-09-18-fwrite-cast-crash.c | 12 + .../CodeGen/2006-09-21-IncompleteElementType.c | 3 + clang/test/CodeGen/2006-09-25-DebugFilename.c | 4 + clang/test/CodeGen/2006-09-25-DebugFilename.h | 6 + clang/test/CodeGen/2006-09-28-SimpleAsm.c | 12 + clang/test/CodeGen/2006-10-30-ArrayCrash.c | 17 + clang/test/CodeGen/2006-12-14-ordered_expr.c | 6 + clang/test/CodeGen/2007-01-06-KNR-Proto.c | 10 + clang/test/CodeGen/2007-01-20-VectorICE.c | 11 + clang/test/CodeGen/2007-01-24-InlineAsmCModifier.c | 12 + clang/test/CodeGen/2007-02-04-AddrLValue-2.c | 13 + clang/test/CodeGen/2007-02-04-AddrLValue.c | 23 + clang/test/CodeGen/2007-02-04-EmptyStruct.c | 9 + clang/test/CodeGen/2007-02-07-AddrLabel.c | 10 + clang/test/CodeGen/2007-02-16-VoidPtrDiff.c | 5 + clang/test/CodeGen/2007-02-25-C-DotDotDot.c | 10 + clang/test/CodeGen/2007-03-01-VarSizeArrayIdx.c | 7 + clang/test/CodeGen/2007-03-05-DataLayout.c | 55 + .../CodeGen/2007-03-26-BitfieldAfterZeroWidth.c | 6 + clang/test/CodeGen/2007-03-26-ZeroWidthBitfield.c | 2 + clang/test/CodeGen/2007-03-27-VarLengthArray.c | 9 + clang/test/CodeGen/2007-04-05-PackedBitFields-2.c | 16 + clang/test/CodeGen/2007-04-05-PackedBitFields.c | 16 + clang/test/CodeGen/2007-04-05-PackedStruct.c | 18 + .../CodeGen/2007-04-05-PadBeforeZeroLengthField.c | 9 + clang/test/CodeGen/2007-04-05-UnPackedStruct.c | 16 + clang/test/CodeGen/2007-04-11-InlineAsmStruct.c | 8 + clang/test/CodeGen/2007-04-11-InlineAsmUnion.c | 7 + clang/test/CodeGen/2007-04-11-PR1321.c | 12 + clang/test/CodeGen/2007-04-13-InlineAsmStruct2.c | 9 + clang/test/CodeGen/2007-04-13-InlineAsmUnion2.c | 8 + clang/test/CodeGen/2007-04-14-FNoBuiltin.c | 7 + clang/test/CodeGen/2007-04-17-ZeroSizeBitFields.c | 4 + clang/test/CodeGen/2007-04-24-VolatileStructCopy.c | 11 + clang/test/CodeGen/2007-04-24-bit-not-expr.c | 7 + clang/test/CodeGen/2007-04-24-str-const.c | 17 + clang/test/CodeGen/2007-05-07-PaddingElements.c | 12 + clang/test/CodeGen/2007-05-08-PCH.c | 7 + clang/test/CodeGen/2007-05-11-str-const.c | 5 + clang/test/CodeGen/2007-05-15-PaddingElement.c | 23 + clang/test/CodeGen/2007-05-16-EmptyStruct.c | 5 + clang/test/CodeGen/2007-05-29-UnionCopy.c | 18 + clang/test/CodeGen/2007-06-05-NoInlineAttribute.c | 13 + clang/test/CodeGen/2007-06-15-AnnotateAttribute.c | 21 + clang/test/CodeGen/2007-06-18-SextAttrAggregate.c | 12 + clang/test/CodeGen/2007-07-29-RestrictPtrArg.c | 6 + clang/test/CodeGen/2007-08-01-LoadStoreAlign.c | 18 + clang/test/CodeGen/2007-08-21-ComplexCst.c | 3 + clang/test/CodeGen/2007-08-22-CTTZ.c | 8 + clang/test/CodeGen/2007-09-05-ConstCtor.c | 14 + clang/test/CodeGen/2007-09-12-PragmaPack.c | 32 + clang/test/CodeGen/2007-09-14-NegatePointer.c | 7 + clang/test/CodeGen/2007-09-17-WeakRef.c | 10 + clang/test/CodeGen/2007-09-26-Alignment.c | 8 + clang/test/CodeGen/2007-09-27-ComplexIntCompare.c | 15 + clang/test/CodeGen/2007-09-28-PackedUnionMember.c | 38 + clang/test/CodeGen/2007-10-02-VolatileArray.c | 7 + clang/test/CodeGen/2007-10-15-VoidPtr.c | 4 + clang/test/CodeGen/2007-10-30-Volatile.c | 6 + clang/test/CodeGen/2007-11-07-AlignedMemcpy.c | 4 + clang/test/CodeGen/2007-11-07-CopyAggregateAlign.c | 7 + clang/test/CodeGen/2007-11-07-ZeroAggregateAlign.c | 5 + clang/test/CodeGen/2007-11-28-GlobalInitializer.c | 8 + .../CodeGen/2007-11-29-ArraySizeFromInitializer.c | 4 + clang/test/CodeGen/2007-12-16-AsmNoUnwind.c | 3 + clang/test/CodeGen/2008-01-04-WideBitfield.c | 12 + clang/test/CodeGen/2008-01-07-UnusualIntSize.c | 15 + clang/test/CodeGen/2008-01-11-ChainConsistency.c | 3 + clang/test/CodeGen/2008-01-21-PackedBitFields.c | 7 + clang/test/CodeGen/2008-01-21-PackedStructField.c | 18 + .../CodeGen/2008-01-24-StructAlignAndBitFields.c | 4 + clang/test/CodeGen/2008-01-25-ByValReadNone.c | 16 + clang/test/CodeGen/2008-01-25-ZeroSizedAggregate.c | 39 + clang/test/CodeGen/2008-01-28-PragmaMark.c | 6 + clang/test/CodeGen/2008-01-28-UnionSize.c | 24 + clang/test/CodeGen/2008-02-07-bitfield-bug.c | 11 + clang/test/CodeGen/2008-02-08-bitfield-bug.c | 9 + clang/test/CodeGen/2008-02-26-inline-asm-bug.c | 6 + clang/test/CodeGen/2008-03-03-CtorAttrType.c | 6 + clang/test/CodeGen/2008-03-05-syncPtr.c | 40 + .../test/CodeGen/2008-03-24-BitField-And-Alloca.c | 89 + clang/test/CodeGen/2008-03-26-PackedBitFields.c | 7 + clang/test/CodeGen/2008-04-08-NoExceptions.c | 10 + clang/test/CodeGen/2008-05-06-CFECrash.c | 4 + clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c | 10 + clang/test/CodeGen/2008-05-19-AlwaysInline.c | 12 + clang/test/CodeGen/2008-07-17-no-emit-on-error.c | 15 + clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c | 8 + ...2008-07-22-bitfield-init-after-zero-len-array.c | 12 + .../CodeGen/2008-07-22-packed-bitfield-access.c | 10 + .../test/CodeGen/2008-07-29-override-alias-decl.c | 19 + .../CodeGen/2008-07-30-implicit-initialization.c | 28 + .../CodeGen/2008-07-30-redef-of-bitcasted-decl.c | 28 + clang/test/CodeGen/2008-07-31-asm-labels.c | 33 + ...7-31-promotion-of-compound-pointer-arithmetic.c | 25 + .../CodeGen/2008-08-04-void-pointer-arithmetic.c | 6 + clang/test/CodeGen/2008-08-07-AlignPadding1.c | 32 + clang/test/CodeGen/2008-08-07-AlignPadding2.c | 18 + clang/test/CodeGen/2008-08-07-GEPIntToPtr.c | 15 + clang/test/CodeGen/2008-08-19-cast-of-typedef.c | 10 + clang/test/CodeGen/2008-09-03-WeakAlias.c | 9 + clang/test/CodeGen/2008-09-22-bad-switch-type.c | 34 + clang/test/CodeGen/2008-10-13-FrontendCrash.c | 9 + clang/test/CodeGen/2008-10-30-ZeroPlacement.c | 9 + clang/test/CodeGen/2008-11-02-WeakAlias.c | 6 + clang/test/CodeGen/2008-11-08-InstCombineSelect.c | 17 + clang/test/CodeGen/2008-12-23-AsmIntPointerTie.c | 8 + clang/test/CodeGen/2009-01-05-BlockInlining.c | 29 + clang/test/CodeGen/2009-01-21-InvalidIterator.c | 74 + .../CodeGen/2009-02-13-zerosize-union-field-ppc.c | 13 + .../test/CodeGen/2009-02-13-zerosize-union-field.c | 16 + clang/test/CodeGen/2009-03-01-MallocNoAlias.c | 3 + clang/test/CodeGen/2009-03-08-ZeroEltStructCrash.c | 14 + clang/test/CodeGen/2009-03-13-dbg.c | 2 + clang/test/CodeGen/2009-03-22-increment-bitfield.c | 7 + clang/test/CodeGen/2009-04-23-dbg.c | 20 + clang/test/CodeGen/2009-04-28-UnionArrayCrash.c | 11 + clang/test/CodeGen/2009-05-04-EnumInreg.c | 17 + clang/test/CodeGen/2009-05-22-callingconv.c | 25 + clang/test/CodeGen/2009-05-28-const-typedef.c | 17 + clang/test/CodeGen/2009-06-01-addrofknr.c | 21 + clang/test/CodeGen/2009-06-14-HighlyAligned.c | 8 + .../test/CodeGen/2009-06-14-anonymous-union-init.c | 7 + .../CodeGen/2009-06-18-StaticInitTailPadPack.c | 26 + clang/test/CodeGen/2009-07-14-VoidPtr.c | 6 + clang/test/CodeGen/2009-07-15-pad-wchar_t-array.c | 17 + clang/test/CodeGen/2009-07-22-StructLayout.c | 34 + clang/test/CodeGen/2009-07-31-DbgDeclare.c | 5 + clang/test/CodeGen/2009-08-14-vararray-crash.c | 11 + clang/test/CodeGen/2009-09-24-SqrtErrno.c | 12 + clang/test/CodeGen/2009-10-20-GlobalDebug.c | 10 + clang/test/CodeGen/2009-12-07-BitFieldAlignment.c | 15 + clang/test/CodeGen/2010-01-13-MemBarrier.c | 11 + clang/test/CodeGen/2010-01-14-FnType-DebugInfo.c | 4 + clang/test/CodeGen/2010-01-18-Inlined-Debug.c | 12 + clang/test/CodeGen/2010-02-10-PointerName.c | 7 + clang/test/CodeGen/2010-02-15-DbgStaticVar.c | 13 + clang/test/CodeGen/2010-02-16-DbgScopes.c | 18 + clang/test/CodeGen/2010-02-18-Dbg-VectorType.c | 9 + clang/test/CodeGen/2010-03-09-DbgInfo.c | 2 + clang/test/CodeGen/2010-03-5-LexicalScope.c | 10 + clang/test/CodeGen/2010-05-26-AsmSideEffect.c | 9 + clang/test/CodeGen/2010-06-11-SaveExpr.c | 8 + clang/test/CodeGen/2010-06-17-asmcrash.c | 16 + clang/test/CodeGen/2010-07-08-DeclDebugLineNo.c | 10 + .../CodeGen/2010-07-14-overconservative-align.c | 14 + clang/test/CodeGen/2010-07-14-ref-off-end.c | 24 + clang/test/CodeGen/2010-08-10-DbgConstant.c | 5 + clang/test/CodeGen/2010-08-12-asm-aggr-arg.c | 16 + clang/test/CodeGen/2010-12-01-CommonGlobal.c | 7 + clang/test/CodeGen/2011-02-21-DATA-common.c | 5 + clang/test/CodeGen/2011-03-02-UnionInitializer.c | 2 + .../CodeGen/2011-03-08-ZeroFieldUnionInitializer.c | 7 + clang/test/CodeGen/2011-03-31-ArrayRefFolding.c | 15 + clang/test/CodeGen/3dnow-builtins.c | 156 + clang/test/CodeGen/Atomics.c | 203 ++ clang/test/CodeGen/BasicInstrs.c | 25 + clang/test/CodeGen/Inputs/stdio.h | 9 + clang/test/CodeGen/OpaqueStruct.c | 12 + clang/test/CodeGen/PR2001-bitfield-reload.c | 16 + .../test/CodeGen/PR2413-void-address-cast-error.c | 6 + clang/test/CodeGen/PR2643-null-store-to-bitfield.c | 10 + .../test/CodeGen/PR2743-reference-missing-static.c | 16 + clang/test/CodeGen/PR3130-cond-constant.c | 3 + clang/test/CodeGen/PR3589-freestanding-libcalls.c | 9 + clang/test/CodeGen/PR3613-static-decl.c | 16 + clang/test/CodeGen/PR3709-int-to-pointer-sign.c | 5 + clang/test/CodeGen/PR4611-bitfield-layout.c | 6 + clang/test/CodeGen/PR5060-align.c | 13 + clang/test/CodeGen/_Bool-conversion.c | 12 + clang/test/CodeGen/address-safety-attr.cpp | 35 + clang/test/CodeGen/address-space-cast.c | 4 + .../test/CodeGen/address-space-compound-literal.c | 5 + clang/test/CodeGen/address-space-field1.c | 38 + clang/test/CodeGen/address-space.c | 44 + clang/test/CodeGen/alias.c | 32 + clang/test/CodeGen/align-local.c | 8 + clang/test/CodeGen/align-param.c | 18 + clang/test/CodeGen/alignment.c | 59 + clang/test/CodeGen/alignof.c | 12 + clang/test/CodeGen/altivec.c | 40 + clang/test/CodeGen/always-inline.c | 12 + clang/test/CodeGen/always_inline.c | 20 + clang/test/CodeGen/annotations-builtin.c | 52 + clang/test/CodeGen/annotations-field.c | 27 + clang/test/CodeGen/annotations-global.c | 41 + clang/test/CodeGen/annotations-loc.c | 10 + clang/test/CodeGen/annotations-var.c | 48 + clang/test/CodeGen/arm-aapcs-vfp.c | 82 + clang/test/CodeGen/arm-aapcs-zerolength-bitfield.c | 236 ++ clang/test/CodeGen/arm-apcs-zerolength-bitfield.c | 240 ++ clang/test/CodeGen/arm-arguments.c | 167 ++ clang/test/CodeGen/arm-asm-variable.c | 31 + clang/test/CodeGen/arm-asm.c | 7 + clang/test/CodeGen/arm-cc.c | 18 + clang/test/CodeGen/arm-clear.c | 21 + clang/test/CodeGen/arm-homogenous.c | 160 + clang/test/CodeGen/arm-inline-asm.c | 6 + clang/test/CodeGen/arm-pcs.c | 12 + clang/test/CodeGen/arm-vaarg-align.c | 33 + clang/test/CodeGen/arm-vector-align.c | 29 + clang/test/CodeGen/arm-vector-arguments.c | 30 + clang/test/CodeGen/array.c | 14 + clang/test/CodeGen/arrayderef.c | 16 + clang/test/CodeGen/asm-errors.c | 11 + clang/test/CodeGen/asm-inout.c | 48 + clang/test/CodeGen/asm-label.c | 19 + clang/test/CodeGen/asm-reg-var-local.c | 24 + clang/test/CodeGen/asm-variable.c | 65 + clang/test/CodeGen/asm.c | 222 ++ clang/test/CodeGen/asm_arm.c | 54 + clang/test/CodeGen/assign.c | 32 + clang/test/CodeGen/atomic-ops.c | 314 ++ clang/test/CodeGen/atomic.c | 109 + clang/test/CodeGen/atomic_ops.c | 14 + clang/test/CodeGen/attr-availability.c | 31 + clang/test/CodeGen/attr-cleanup.c | 8 + clang/test/CodeGen/attr-naked.c | 16 + clang/test/CodeGen/attr-nodebug.c | 12 + clang/test/CodeGen/attr-noinline.c | 9 + clang/test/CodeGen/attr-used.c | 14 + clang/test/CodeGen/attr-weak-import.c | 26 + clang/test/CodeGen/attr-weakref.c | 62 + clang/test/CodeGen/attr-weakref2.c | 54 + clang/test/CodeGen/attribute-section-data-common.c | 5 + clang/test/CodeGen/attribute_constructor.c | 6 + clang/test/CodeGen/attributes.c | 83 + clang/test/CodeGen/available-externally-suppress.c | 27 + clang/test/CodeGen/avx-builtins.c | 25 + clang/test/CodeGen/avx-cmp-builtins.c | 46 + clang/test/CodeGen/avx-shuffle-builtins.c | 65 + clang/test/CodeGen/avx2-builtins.c | 782 +++++ clang/test/CodeGen/bitfield-2.c | 368 +++ clang/test/CodeGen/bitfield-assign.c | 44 + clang/test/CodeGen/bitfield-init.c | 14 + clang/test/CodeGen/bitfield-promote.c | 18 + clang/test/CodeGen/bitfield.c | 74 + clang/test/CodeGen/block-3.c | 8 + clang/test/CodeGen/block-byref-aggr.c | 17 + clang/test/CodeGen/block-copy.c | 20 + clang/test/CodeGen/blocks-1.c | 78 + clang/test/CodeGen/blocks-2.c | 18 + clang/test/CodeGen/blocks-aligned-byref-variable.c | 19 + clang/test/CodeGen/blocks-seq.c | 18 + clang/test/CodeGen/blocks.c | 42 + clang/test/CodeGen/blocksignature.c | 96 + clang/test/CodeGen/blockstret.c | 106 + clang/test/CodeGen/blockwithlocalstatic.c | 19 + clang/test/CodeGen/bmi-builtins.c | 79 + clang/test/CodeGen/bmi2-builtins.c | 36 + clang/test/CodeGen/bool-bitfield.c | 54 + clang/test/CodeGen/bool-convert.c | 10 + clang/test/CodeGen/bool-init.c | 4 + clang/test/CodeGen/bool_test.c | 5 + clang/test/CodeGen/boolassign.c | 7 + clang/test/CodeGen/builtin-attributes.c | 58 + clang/test/CodeGen/builtin-count-zeros.c | 8 + clang/test/CodeGen/builtin-expect.c | 47 + clang/test/CodeGen/builtin-memfns.c | 65 + clang/test/CodeGen/builtin-nanf.c | 15 + clang/test/CodeGen/builtin-recursive.cc | 10 + clang/test/CodeGen/builtin-rename.c | 8 + clang/test/CodeGen/builtin-stackaddress.c | 9 + clang/test/CodeGen/builtin-unwind-init.c | 5 + clang/test/CodeGen/builtins-arm.c | 12 + clang/test/CodeGen/builtins-ppc-altivec.c | 3115 ++++++++++++++++++++ clang/test/CodeGen/builtins-ptx.c | 99 + clang/test/CodeGen/builtins-x86.c | 496 ++++ clang/test/CodeGen/builtins.c | 205 ++ clang/test/CodeGen/builtinshufflevector.c | 6 + clang/test/CodeGen/builtinshufflevector2.c | 35 + clang/test/CodeGen/byval-memcpy-elim.c | 53 + clang/test/CodeGen/c-strings.c | 36 + clang/test/CodeGen/call.c | 39 + clang/test/CodeGen/capture-complex-expr-in-block.c | 20 + clang/test/CodeGen/cast-emit.c | 12 + clang/test/CodeGen/cast.c | 6 + clang/test/CodeGen/catch-undef-behavior.c | 7 + clang/test/CodeGen/cfstring.c | 23 + clang/test/CodeGen/cfstring2.c | 13 + clang/test/CodeGen/char-literal.c | 90 + clang/test/CodeGen/cleanup-stack.c | 25 + clang/test/CodeGen/complex-indirect.c | 12 + clang/test/CodeGen/complex-init-list.c | 18 + clang/test/CodeGen/complex.c | 99 + clang/test/CodeGen/compound-literal.c | 34 + clang/test/CodeGen/compound-type.c | 7 + clang/test/CodeGen/compound.c | 25 + clang/test/CodeGen/conditional-gnu-ext.c | 36 + clang/test/CodeGen/conditional.c | 74 + clang/test/CodeGen/const-arithmetic.c | 8 + clang/test/CodeGen/const-init.c | 146 + clang/test/CodeGen/const-label-addr.c | 4 + clang/test/CodeGen/const-unordered-compare.c | 7 + clang/test/CodeGen/constant-comparison.c | 12 + clang/test/CodeGen/constructor-attribute.c | 38 + clang/test/CodeGen/count-builtins.c | 33 + clang/test/CodeGen/cxx-condition.cpp | 9 + clang/test/CodeGen/cxx-default-arg.cpp | 25 + clang/test/CodeGen/cxx-value-init.cpp | 11 + clang/test/CodeGen/darwin-string-literals.c | 19 + clang/test/CodeGen/darwin-thread-specifier.c | 3 + clang/test/CodeGen/debug-dead-local-var.c | 14 + clang/test/CodeGen/debug-info-args.c | 9 + clang/test/CodeGen/debug-info-block.c | 11 + clang/test/CodeGen/debug-info-compilation-dir.c | 6 + clang/test/CodeGen/debug-info-crash.c | 31 + clang/test/CodeGen/debug-info-enum.c | 11 + clang/test/CodeGen/debug-info-iv.c | 36 + clang/test/CodeGen/debug-info-line.c | 23 + clang/test/CodeGen/debug-info-line2.c | 17 + clang/test/CodeGen/debug-info-line3.c | 16 + clang/test/CodeGen/debug-info-member.c | 3 + clang/test/CodeGen/debug-info-scope.c | 14 + clang/test/CodeGen/debug-info-static.c | 8 + clang/test/CodeGen/debug-info-var-location.c | 21 + clang/test/CodeGen/debug-info.c | 61 + clang/test/CodeGen/debug-line-1.c | 20 + clang/test/CodeGen/decl-in-prototype.c | 21 + clang/test/CodeGen/decl.c | 119 + clang/test/CodeGen/designated-initializers.c | 89 + clang/test/CodeGen/dllimport-dllexport.c | 12 + clang/test/CodeGen/dostmt.c | 70 + clang/test/CodeGen/emit-all-decls.c | 8 + clang/test/CodeGen/empty-union-init.c | 13 + clang/test/CodeGen/enum.c | 22 + clang/test/CodeGen/enum2.c | 8 + clang/test/CodeGen/exact-div-expr.c | 6 + clang/test/CodeGen/exceptions.c | 21 + clang/test/CodeGen/exprs.c | 176 ++ clang/test/CodeGen/ext-vector-member-alignment.c | 27 + clang/test/CodeGen/ext-vector.c | 288 ++ clang/test/CodeGen/extern-block-var.c | 6 + clang/test/CodeGen/extern-inline.c | 26 + clang/test/CodeGen/extern-weak.c | 12 + clang/test/CodeGen/flexible-array-init.c | 7 + clang/test/CodeGen/fma4-builtins.c | 166 ++ clang/test/CodeGen/fold-const-declref.c | 9 + clang/test/CodeGen/fp16-ops.c | 283 ++ clang/test/CodeGen/frame-pointer-elim.c | 40 + clang/test/CodeGen/func-aligned.c | 7 + clang/test/CodeGen/func-decl-cleanup.c | 12 + clang/test/CodeGen/func-in-block.c | 19 + clang/test/CodeGen/func-ptr-cast-decl.c | 6 + clang/test/CodeGen/func-return-member.c | 26 + clang/test/CodeGen/funccall.c | 17 + clang/test/CodeGen/function-attributes.c | 113 + clang/test/CodeGen/functions.c | 67 + clang/test/CodeGen/global-decls.c | 21 + clang/test/CodeGen/global-init.c | 52 + clang/test/CodeGen/global-with-initialiser.c | 25 + clang/test/CodeGen/globalinit.c | 51 + clang/test/CodeGen/hidden-visibility.c | 4 + clang/test/CodeGen/imaginary.c | 4 + clang/test/CodeGen/implicit-arg.c | 10 + clang/test/CodeGen/incomplete-function-type.c | 14 + clang/test/CodeGen/indirect-goto.c | 31 + clang/test/CodeGen/init-with-member-expr.c | 21 + clang/test/CodeGen/init.c | 132 + clang/test/CodeGen/inline-asm-mrv.c | 12 + clang/test/CodeGen/inline.c | 129 + clang/test/CodeGen/inline2.c | 62 + clang/test/CodeGen/instrument-functions.c | 18 + clang/test/CodeGen/int-to-pointer.c | 6 + clang/test/CodeGen/integer-overflow.c | 66 + clang/test/CodeGen/kr-func-promote.c | 5 + clang/test/CodeGen/kr-style-block.c | 10 + clang/test/CodeGen/libcalls-d.c | 16 + clang/test/CodeGen/libcalls-fno-builtin.c | 28 + clang/test/CodeGen/libcalls-ld.c | 19 + clang/test/CodeGen/libcalls.c | 75 + clang/test/CodeGen/lifetime.c | 23 + clang/test/CodeGen/lineno-dbginfo.c | 5 + clang/test/CodeGen/link-bitcode-file.c | 24 + clang/test/CodeGen/linkage-redecl.c | 11 + clang/test/CodeGen/long-double-x86.c | 4 + clang/test/CodeGen/lzcnt-builtins.c | 24 + clang/test/CodeGen/mandel.c | 65 + clang/test/CodeGen/mangle.c | 74 + clang/test/CodeGen/may-alias.c | 30 + clang/test/CodeGen/mcount.c | 4 + clang/test/CodeGen/merge-attrs.c | 13 + clang/test/CodeGen/merge-statics.c | 13 + clang/test/CodeGen/microsoft-call-conv.c | 50 + clang/test/CodeGen/mips-clobber-reg.c | 80 + clang/test/CodeGen/mips-constraint-regs.c | 44 + clang/test/CodeGen/mips64-class-return.cpp | 46 + clang/test/CodeGen/mips64-f128-literal.c | 9 + clang/test/CodeGen/mips64-nontrivial-return.cpp | 17 + clang/test/CodeGen/mips64-padding-arg.c | 43 + clang/test/CodeGen/misaligned-param.c | 13 + clang/test/CodeGen/mms-bitfields.c | 22 + clang/test/CodeGen/mmx-builtins.c | 453 +++ clang/test/CodeGen/mmx-inline-asm.c | 22 + clang/test/CodeGen/mmx-shift-with-immediate.c | 23 + clang/test/CodeGen/mrtd.c | 15 + clang/test/CodeGen/ms-anonymous-struct.c | 99 + clang/test/CodeGen/ms-declspecs.c | 16 + clang/test/CodeGen/ms_struct-bitfield-1.c | 91 + clang/test/CodeGen/ms_struct-bitfield-2.c | 135 + clang/test/CodeGen/ms_struct-bitfield-3.c | 49 + clang/test/CodeGen/ms_struct-bitfield-init.c | 68 + clang/test/CodeGen/ms_struct-bitfield.c | 131 + clang/test/CodeGen/ms_struct-pack.c | 125 + clang/test/CodeGen/ms_struct.c | 23 + clang/test/CodeGen/mult-alt-generic.c | 281 ++ clang/test/CodeGen/mult-alt-x86.c | 374 +++ clang/test/CodeGen/no-common.c | 15 + clang/test/CodeGen/noinline.c | 14 + clang/test/CodeGen/object-size.c | 136 + clang/test/CodeGen/offsetof.c | 12 + clang/test/CodeGen/opaque-pointer.c | 13 + clang/test/CodeGen/overloadable.c | 26 + clang/test/CodeGen/override-layout.c | 174 ++ clang/test/CodeGen/packed-arrays.c | 155 + clang/test/CodeGen/packed-nest-unpacked.c | 47 + clang/test/CodeGen/packed-structure.c | 101 + clang/test/CodeGen/packed-union.c | 15 + clang/test/CodeGen/palignr.c | 31 + clang/test/CodeGen/parameter-passing.c | 56 + clang/test/CodeGen/pascal-string.c | 8 + clang/test/CodeGen/pascal-wchar-string.c | 41 + clang/test/CodeGen/pointer-arithmetic.c | 25 + clang/test/CodeGen/pointer-cmp-type.c | 3 + clang/test/CodeGen/pointer-signext.c | 32 + clang/test/CodeGen/pointer-to-int.c | 13 + clang/test/CodeGen/popcnt-builtins.c | 16 + clang/test/CodeGen/powerpc_types.c | 10 + clang/test/CodeGen/pr12251.c | 11 + clang/test/CodeGen/pr2394.c | 7 + clang/test/CodeGen/pr3518.c | 29 + clang/test/CodeGen/pr4349.c | 38 + clang/test/CodeGen/pr5406.c | 17 + clang/test/CodeGen/pr9614.c | 29 + clang/test/CodeGen/pragma-pack-1.c | 7 + clang/test/CodeGen/pragma-pack-2.c | 23 + clang/test/CodeGen/pragma-pack-3.c | 17 + clang/test/CodeGen/pragma-visibility.c | 24 + clang/test/CodeGen/pragma-weak.c | 172 ++ clang/test/CodeGen/predefined-expr.c | 45 + clang/test/CodeGen/private-extern-redef.c | 39 + clang/test/CodeGen/private-extern.c | 10 + clang/test/CodeGen/ptx-cc.c | 9 + clang/test/CodeGen/redef-ext-inline.c | 6 + clang/test/CodeGen/redefine_extname.c | 15 + clang/test/CodeGen/regparm-flag.c | 20 + clang/test/CodeGen/regparm.c | 27 + clang/test/CodeGen/restrict.c | 26 + clang/test/CodeGen/shared-string-literals.c | 9 + clang/test/CodeGen/sizeof-vla.c | 13 + clang/test/CodeGen/sret.c | 15 + clang/test/CodeGen/sret2.c | 9 + clang/test/CodeGen/sse-builtins.c | 153 + clang/test/CodeGen/stack-protector.c | 14 + clang/test/CodeGen/statements.c | 40 + clang/test/CodeGen/static-forward-decl-fun.c | 6 + clang/test/CodeGen/static-forward-decl.c | 5 + clang/test/CodeGen/static-local-union.c | 4 + clang/test/CodeGen/static-order.c | 22 + clang/test/CodeGen/staticinit.c | 41 + clang/test/CodeGen/stdcall-fastcall.c | 50 + clang/test/CodeGen/string-literal-short-wstring.c | 32 + .../CodeGen/string-literal-unicode-conversion.c | 63 + clang/test/CodeGen/string-literal.c | 80 + clang/test/CodeGen/struct-comma.c | 4 + clang/test/CodeGen/struct-copy.c | 7 + clang/test/CodeGen/struct-init.c | 37 + clang/test/CodeGen/struct-matching-constraint.c | 13 + clang/test/CodeGen/struct-passing.c | 24 + clang/test/CodeGen/struct-x86-darwin.c | 25 + clang/test/CodeGen/struct.c | 196 ++ clang/test/CodeGen/switch-dce.c | 234 ++ clang/test/CodeGen/switch.c | 213 ++ clang/test/CodeGen/target-data.c | 6 + clang/test/CodeGen/tbaa-for-vptr.cpp | 19 + clang/test/CodeGen/tentative-decls.c | 38 + clang/test/CodeGen/thread-specifier.c | 15 + clang/test/CodeGen/transparent-union.c | 25 + clang/test/CodeGen/trapv.c | 49 + clang/test/CodeGen/typedef-func.c | 16 + clang/test/CodeGen/typedef.c | 8 + clang/test/CodeGen/types.c | 34 + clang/test/CodeGen/uint128_t.c | 18 + clang/test/CodeGen/unaligned-memcpy.c | 5 + clang/test/CodeGen/union-align.c | 17 + clang/test/CodeGen/union-init.c | 31 + clang/test/CodeGen/union-init2.c | 13 + clang/test/CodeGen/union.c | 46 + clang/test/CodeGen/unreachable.c | 37 + clang/test/CodeGen/unwind-attr.c | 24 + clang/test/CodeGen/utf16-cfstrings.c | 10 + clang/test/CodeGen/varargs.c | 11 + clang/test/CodeGen/variable-array.c | 19 + clang/test/CodeGen/vector.c | 57 + clang/test/CodeGen/vfprintf.c | 8 + clang/test/CodeGen/visibility.c | 69 + clang/test/CodeGen/vla-2.c | 10 + clang/test/CodeGen/vla-3.c | 11 + clang/test/CodeGen/vla-4.c | 24 + clang/test/CodeGen/vla.c | 144 + clang/test/CodeGen/vld_dup.c | 49 + clang/test/CodeGen/volatile-1.c | 315 ++ clang/test/CodeGen/volatile-2.c | 23 + clang/test/CodeGen/volatile.c | 100 + clang/test/CodeGen/wchar-const.c | 24 + clang/test/CodeGen/weak-global.c | 3 + clang/test/CodeGen/weak-incomplete.c | 5 + clang/test/CodeGen/weak_constant.c | 13 + clang/test/CodeGen/whilestmt.c | 62 + clang/test/CodeGen/writable-strings.c | 8 + clang/test/CodeGen/x86.c | 15 + clang/test/CodeGen/x86_32-arguments-darwin.c | 326 ++ clang/test/CodeGen/x86_32-arguments-linux.c | 51 + clang/test/CodeGen/x86_32-arguments-nommx.c | 11 + clang/test/CodeGen/x86_32-arguments-realign.c | 11 + clang/test/CodeGen/x86_32-arguments-win32.c | 48 + clang/test/CodeGen/x86_64-arguments-darwin.c | 17 + clang/test/CodeGen/x86_64-arguments.c | 356 +++ clang/test/CodeGenCUDA/device-stub.cu | 13 + clang/test/CodeGenCUDA/filter-decl.cu | 40 + clang/test/CodeGenCUDA/kernel-call.cu | 13 + clang/test/CodeGenCUDA/ptx-kernels.cu | 12 + clang/test/CodeGenCXX/2003-11-02-WeakLinkage.cpp | 13 + .../2003-11-18-PtrMemConstantInitializer.cpp | 13 + .../2003-11-27-MultipleInheritanceThunk.cpp | 28 + .../2003-11-29-DuplicatedCleanupTest.cpp | 41 + .../2003-12-08-ArrayOfPtrToMemberFunc.cpp | 12 + .../2004-01-11-DynamicInitializedConstant.cpp | 6 + .../CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp | 21 + .../2004-03-09-UnmangledBuiltinMethods.cpp | 8 + .../CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp | 14 + .../2004-06-08-LateTemplateInstantiation.cpp | 18 + .../CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp | 22 + .../2004-11-27-ExceptionCleanupAssertion.cpp | 14 + .../2004-11-27-FriendDefaultArgCrash.cpp | 9 + .../CodeGenCXX/2005-01-03-StaticInitializers.cpp | 8 + .../test/CodeGenCXX/2005-02-11-AnonymousUnion.cpp | 32 + .../test/CodeGenCXX/2005-02-13-BadDynamicInit.cpp | 9 + .../test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp | 12 + .../CodeGenCXX/2005-02-19-BitfieldStructCrash.cpp | 14 + .../2005-02-19-UnnamedVirtualThunkArgument.cpp | 22 + .../CodeGenCXX/2005-02-20-BrokenReferenceTest.cpp | 10 + clang/test/CodeGenCXX/2006-03-01-GimplifyCrash.cpp | 14 + .../test/CodeGenCXX/2006-03-06-C++RecurseCrash.cpp | 23 + .../CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp | 27 + clang/test/CodeGenCXX/2006-10-30-ClassBitfield.cpp | 16 + clang/test/CodeGenCXX/2006-11-20-GlobalSymbols.cpp | 11 + .../CodeGenCXX/2006-11-30-ConstantExprCrash.cpp | 21 + .../test/CodeGenCXX/2007-01-02-UnboundedArray.cpp | 14 + clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp | 75 + .../CodeGenCXX/2007-04-05-PackedBitFields-1.cpp | 22 + .../2007-04-05-PackedBitFieldsOverlap-2.cpp | 23 + .../2007-04-05-PackedBitFieldsOverlap.cpp | 23 + .../CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp | 27 + .../2007-04-05-StructPackedFieldUnpacked.cpp | 24 + clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp | 41 + clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp | 8 + clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp | 17 + .../test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp | 7 + .../test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp | 7 + .../2007-09-10-RecursiveTypeResolution.cpp | 87 + clang/test/CodeGenCXX/2007-10-01-StructResize.cpp | 13 + clang/test/CodeGenCXX/2008-01-12-VecInit.cpp | 5 + clang/test/CodeGenCXX/2008-05-07-CrazyOffsetOf.cpp | 8 + clang/test/CodeGenCXX/2009-03-17-dbg.cpp | 15 + clang/test/CodeGenCXX/2009-04-23-bool2.cpp | 15 + .../CodeGenCXX/2009-05-04-PureConstNounwind.cpp | 15 + .../test/CodeGenCXX/2009-06-16-DebugInfoCrash.cpp | 10 + clang/test/CodeGenCXX/2009-07-16-Using.cpp | 8 + clang/test/CodeGenCXX/2009-08-05-ZeroInitWidth.cpp | 11 + clang/test/CodeGenCXX/2009-08-11-VectorRetTy.cpp | 13 + clang/test/CodeGenCXX/2009-09-09-packed-layout.cpp | 18 + clang/test/CodeGenCXX/2009-10-27-crash.cpp | 43 + clang/test/CodeGenCXX/2009-12-23-MissingSext.cpp | 16 + clang/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp | 12 + clang/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp | 42 + .../2010-05-11-alwaysinlineinstantiation.cpp | 33 + .../test/CodeGenCXX/2010-05-12-PtrToMember-Dbg.cpp | 17 + clang/test/CodeGenCXX/2010-06-21-LocalVarDbg.cpp | 14 + clang/test/CodeGenCXX/2010-06-22-BitfieldInit.cpp | 20 + clang/test/CodeGenCXX/2010-06-22-ZeroBitfield.cpp | 5 + clang/test/CodeGenCXX/2010-07-23-DeclLoc.cpp | 86 + .../test/CodeGenCXX/2011-12-19-init-list-ctor.cpp | 26 + .../CodeGenCXX/2012-02-06-VecInitialization.cpp | 8 + clang/test/CodeGenCXX/2012-03-16-StoreAlign.cpp | 36 + clang/test/CodeGenCXX/DynArrayInit.cpp | 15 + clang/test/CodeGenCXX/PR4827-cast.cpp | 5 + .../CodeGenCXX/PR4983-constructor-conversion.cpp | 16 + .../CodeGenCXX/PR5050-constructor-conversion.cpp | 19 + .../CodeGenCXX/PR5093-static-member-function.cpp | 9 + .../CodeGenCXX/PR5834-constructor-conversion.cpp | 14 + clang/test/CodeGenCXX/PR5863-unreachable-block.cpp | 13 + clang/test/CodeGenCXX/PR6474.cpp | 31 + clang/test/CodeGenCXX/__null.cpp | 9 + .../test/CodeGenCXX/abstract-class-ctors-dtors.cpp | 16 + clang/test/CodeGenCXX/address-of-fntemplate.cpp | 27 + clang/test/CodeGenCXX/alloca-align.cpp | 28 + clang/test/CodeGenCXX/anonymous-namespaces.cpp | 68 + .../anonymous-union-member-initializer.cpp | 181 ++ .../test/CodeGenCXX/apple-kext-guard-variable.cpp | 9 + clang/test/CodeGenCXX/apple-kext-indirect-call-2.C | 77 + clang/test/CodeGenCXX/apple-kext-indirect-call.C | 14 + .../apple-kext-indirect-virtual-dtor-call.cpp | 19 + clang/test/CodeGenCXX/apple-kext-linkage.C | 33 + .../CodeGenCXX/apple-kext-no-staticinit-section.C | 20 + clang/test/CodeGenCXX/apple-kext.cpp | 22 + clang/test/CodeGenCXX/arm-cc.cpp | 20 + clang/test/CodeGenCXX/arm.cpp | 369 +++ clang/test/CodeGenCXX/array-construction.cpp | 37 + .../test/CodeGenCXX/array-operator-delete-call.cpp | 64 + clang/test/CodeGenCXX/array-pointer-decay.cpp | 7 + clang/test/CodeGenCXX/array-value-initialize.cpp | 52 + clang/test/CodeGenCXX/asm.cpp | 14 + clang/test/CodeGenCXX/assign-operator.cpp | 30 + clang/test/CodeGenCXX/atomic.cpp | 17 + clang/test/CodeGenCXX/atomicinit.cpp | 48 + clang/test/CodeGenCXX/attr-used.cpp | 9 + clang/test/CodeGenCXX/attr.cpp | 28 + clang/test/CodeGenCXX/bitfield-layout.cpp | 43 + clang/test/CodeGenCXX/block-byref-cxx-objc.cpp | 35 + clang/test/CodeGenCXX/block-destruct.cpp | 9 + clang/test/CodeGenCXX/block-in-ctor-dtor.cpp | 48 + clang/test/CodeGenCXX/block.cpp | 19 + clang/test/CodeGenCXX/blocks-cxx11.cpp | 84 + clang/test/CodeGenCXX/blocks.cpp | 228 ++ clang/test/CodeGenCXX/builtins.cpp | 21 + clang/test/CodeGenCXX/c-linkage.cpp | 13 + .../test/CodeGenCXX/c99-variable-length-array.cpp | 37 + clang/test/CodeGenCXX/call-arg-zero-temp.cpp | 23 + clang/test/CodeGenCXX/cast-conversion.cpp | 33 + clang/test/CodeGenCXX/casts.cpp | 20 + clang/test/CodeGenCXX/class-layout.cpp | 79 + clang/test/CodeGenCXX/compound-literals.cpp | 44 + clang/test/CodeGenCXX/condition.cpp | 317 ++ clang/test/CodeGenCXX/conditional-expr-lvalue.cpp | 20 + clang/test/CodeGenCXX/conditional-gnu-ext.cpp | 150 + clang/test/CodeGenCXX/conditional-temporaries.cpp | 55 + clang/test/CodeGenCXX/const-base-cast.cpp | 10 + clang/test/CodeGenCXX/const-global-linkage.cpp | 13 + clang/test/CodeGenCXX/const-init-cxx11.cpp | 428 +++ clang/test/CodeGenCXX/const-init.cpp | 78 + clang/test/CodeGenCXX/constructor-attr.cpp | 12 + clang/test/CodeGenCXX/constructor-conversion.cpp | 55 + clang/test/CodeGenCXX/constructor-convert.cpp | 20 + clang/test/CodeGenCXX/constructor-default-arg.cpp | 40 + clang/test/CodeGenCXX/constructor-direct-call.cpp | 60 + .../CodeGenCXX/constructor-for-array-members.cpp | 44 + .../test/CodeGenCXX/constructor-init-reference.cpp | 9 + clang/test/CodeGenCXX/constructor-init.cpp | 222 ++ clang/test/CodeGenCXX/constructor-template.cpp | 54 + clang/test/CodeGenCXX/constructors.cpp | 115 + clang/test/CodeGenCXX/conversion-function.cpp | 120 + clang/test/CodeGenCXX/conversion-operator-base.cpp | 7 + clang/test/CodeGenCXX/convert-to-fptr.cpp | 47 + clang/test/CodeGenCXX/copy-assign-synthesis-1.cpp | 109 + clang/test/CodeGenCXX/copy-assign-synthesis-2.cpp | 4 + clang/test/CodeGenCXX/copy-assign-synthesis-3.cpp | 24 + clang/test/CodeGenCXX/copy-assign-synthesis.cpp | 79 + .../CodeGenCXX/copy-assign-volatile-synthesis.cpp | 43 + clang/test/CodeGenCXX/copy-constructor-elim-2.cpp | 77 + clang/test/CodeGenCXX/copy-constructor-elim.cpp | 42 + .../CodeGenCXX/copy-constructor-synthesis-2.cpp | 7 + .../test/CodeGenCXX/copy-constructor-synthesis.cpp | 156 + clang/test/CodeGenCXX/copy-in-cplus-object.cpp | 28 + clang/test/CodeGenCXX/copy-initialization.cpp | 29 + clang/test/CodeGenCXX/cxx-apple-kext.cpp | 36 + clang/test/CodeGenCXX/cxx-block-objects.cpp | 33 + .../test/CodeGenCXX/cxx0x-defaulted-templates.cpp | 19 + clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp | 56 + clang/test/CodeGenCXX/cxx0x-initializer-array.cpp | 10 + .../CodeGenCXX/cxx0x-initializer-references.cpp | 69 + .../test/CodeGenCXX/cxx0x-initializer-scalars.cpp | 7 + ...xx0x-initializer-stdinitializerlist-pr12086.cpp | 37 + ...x0x-initializer-stdinitializerlist-startend.cpp | 85 + .../cxx0x-initializer-stdinitializerlist.cpp | 252 ++ clang/test/CodeGenCXX/cxx11-exception-spec.cpp | 120 + clang/test/CodeGenCXX/cxx11-unrestricted-union.cpp | 76 + .../test/CodeGenCXX/cxx11-user-defined-literal.cpp | 69 + .../test/CodeGenCXX/debug-info-artificial-arg.cpp | 30 + clang/test/CodeGenCXX/debug-info-byval.cpp | 31 + clang/test/CodeGenCXX/debug-info-char16.cpp | 6 + clang/test/CodeGenCXX/debug-info-class.cpp | 12 + clang/test/CodeGenCXX/debug-info-context.cpp | 17 + clang/test/CodeGenCXX/debug-info-ctor.cpp | 14 + clang/test/CodeGenCXX/debug-info-ctor2.cpp | 15 + clang/test/CodeGenCXX/debug-info-cxx0x.cpp | 8 + clang/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp | 24 + clang/test/CodeGenCXX/debug-info-enum.cpp | 8 + clang/test/CodeGenCXX/debug-info-fn-template.cpp | 15 + clang/test/CodeGenCXX/debug-info-friend.cpp | 11 + clang/test/CodeGenCXX/debug-info-fwd-ref.cpp | 26 + .../test/CodeGenCXX/debug-info-large-constant.cpp | 8 + clang/test/CodeGenCXX/debug-info-limit-type.cpp | 24 + clang/test/CodeGenCXX/debug-info-limit.cpp | 14 + clang/test/CodeGenCXX/debug-info-member.cpp | 6 + clang/test/CodeGenCXX/debug-info-method-spec.cpp | 10 + clang/test/CodeGenCXX/debug-info-method.cpp | 6 + clang/test/CodeGenCXX/debug-info-method2.cpp | 19 + clang/test/CodeGenCXX/debug-info-namespace.cpp | 12 + clang/test/CodeGenCXX/debug-info-nullptr.cpp | 7 + clang/test/CodeGenCXX/debug-info-pubtypes.cpp | 17 + clang/test/CodeGenCXX/debug-info-static-fns.cpp | 10 + .../test/CodeGenCXX/debug-info-template-limit.cpp | 15 + .../test/CodeGenCXX/debug-info-template-member.cpp | 21 + .../CodeGenCXX/debug-info-template-recursive.cpp | 13 + clang/test/CodeGenCXX/debug-info-template.cpp | 46 + clang/test/CodeGenCXX/debug-info-this.cpp | 15 + .../test/CodeGenCXX/debug-info-use-after-free.cpp | 312 ++ clang/test/CodeGenCXX/debug-info-wchar.cpp | 5 + clang/test/CodeGenCXX/debug-info.cpp | 69 + clang/test/CodeGenCXX/debug-lambda-expressions.cpp | 71 + clang/test/CodeGenCXX/decl-ref-init.cpp | 31 + clang/test/CodeGenCXX/default-arg-temps.cpp | 73 + clang/test/CodeGenCXX/default-arguments.cpp | 76 + .../default-constructor-default-argument.cpp | 8 + .../CodeGenCXX/default-constructor-for-members.cpp | 24 + .../default-constructor-template-member.cpp | 10 + .../test/CodeGenCXX/default-destructor-nested.cpp | 13 + .../CodeGenCXX/default-destructor-synthesis.cpp | 36 + clang/test/CodeGenCXX/deferred-global-init.cpp | 16 + clang/test/CodeGenCXX/delete-two-arg.cpp | 70 + clang/test/CodeGenCXX/delete.cpp | 135 + .../CodeGenCXX/dependent-type-member-pointer.cpp | 18 + clang/test/CodeGenCXX/derived-to-base-conv.cpp | 85 + clang/test/CodeGenCXX/derived-to-base.cpp | 47 + .../derived-to-virtual-base-class-calls-final.cpp | 16 + clang/test/CodeGenCXX/destructor-calls.cpp | 41 + clang/test/CodeGenCXX/destructor-debug-info.cpp | 21 + clang/test/CodeGenCXX/destructors.cpp | 403 +++ .../devirtualize-virtual-function-calls-final.cpp | 51 + .../devirtualize-virtual-function-calls.cpp | 55 + clang/test/CodeGenCXX/dynamic-cast-always-null.cpp | 19 + clang/test/CodeGenCXX/dynamic-cast.cpp | 18 + clang/test/CodeGenCXX/eh.cpp | 446 +++ clang/test/CodeGenCXX/elide-call-reference.cpp | 11 + clang/test/CodeGenCXX/empty-classes.cpp | 82 + clang/test/CodeGenCXX/empty-union.cpp | 7 + clang/test/CodeGenCXX/enum.cpp | 4 + clang/test/CodeGenCXX/eval-recursive-constant.cpp | 5 + clang/test/CodeGenCXX/exceptions-no-rtti.cpp | 51 + clang/test/CodeGenCXX/exceptions.cpp | 416 +++ clang/test/CodeGenCXX/explicit-instantiation.cpp | 45 + clang/test/CodeGenCXX/expr.cpp | 37 + clang/test/CodeGenCXX/extern-c.cpp | 16 + clang/test/CodeGenCXX/field-access-debug-info.cpp | 14 + clang/test/CodeGenCXX/for-range-temporaries.cpp | 146 + clang/test/CodeGenCXX/for-range.cpp | 128 + clang/test/CodeGenCXX/forward-enum.cpp | 11 + clang/test/CodeGenCXX/fp16-mangle.cpp | 12 + clang/test/CodeGenCXX/fp16-overload.cpp | 10 + clang/test/CodeGenCXX/friend-redecl.cpp | 18 + .../function-template-explicit-specialization.cpp | 13 + .../function-template-specialization.cpp | 26 + clang/test/CodeGenCXX/global-array-destruction.cpp | 34 + clang/test/CodeGenCXX/global-dtor-no-atexit.cpp | 44 + clang/test/CodeGenCXX/global-init-darwin.cpp | 23 + clang/test/CodeGenCXX/global-init.cpp | 122 + clang/test/CodeGenCXX/global-llvm-constant.cpp | 32 + clang/test/CodeGenCXX/goto.cpp | 43 + .../CodeGenCXX/implicit-copy-assign-operator.cpp | 56 + .../test/CodeGenCXX/implicit-copy-constructor.cpp | 82 + clang/test/CodeGenCXX/implicit-instantiation-1.cpp | 28 + .../incomplete-member-function-pointer.cpp | 10 + clang/test/CodeGenCXX/incomplete-types.cpp | 43 + clang/test/CodeGenCXX/inheriting-constructor.cpp | 11 + clang/test/CodeGenCXX/init-invariant.cpp | 60 + clang/test/CodeGenCXX/inline-functions.cpp | 55 + clang/test/CodeGenCXX/instantiate-blocks.cpp | 59 + clang/test/CodeGenCXX/instantiate-init-list.cpp | 13 + clang/test/CodeGenCXX/instantiate-temporaries.cpp | 37 + clang/test/CodeGenCXX/instrument-functions.cpp | 30 + clang/test/CodeGenCXX/internal-linkage.cpp | 64 + clang/test/CodeGenCXX/key-function-vtable.cpp | 52 + clang/test/CodeGenCXX/lambda-expressions.cpp | 78 + clang/test/CodeGenCXX/lvalue-bitcasts.cpp | 163 + clang/test/CodeGenCXX/m64-ptr.cpp | 18 + clang/test/CodeGenCXX/mangle-98.cpp | 12 + clang/test/CodeGenCXX/mangle-abi-examples.cpp | 27 + clang/test/CodeGenCXX/mangle-address-space.cpp | 12 + clang/test/CodeGenCXX/mangle-alias-template.cpp | 48 + clang/test/CodeGenCXX/mangle-exprs.cpp | 193 ++ clang/test/CodeGenCXX/mangle-extern-local.cpp | 45 + clang/test/CodeGenCXX/mangle-extreme.cpp | 47 + clang/test/CodeGenCXX/mangle-lambdas.cpp | 202 ++ clang/test/CodeGenCXX/mangle-local-class-names.cpp | 57 + .../test/CodeGenCXX/mangle-local-class-vtables.cpp | 61 + .../CodeGenCXX/mangle-local-classes-nested.cpp | 81 + clang/test/CodeGenCXX/mangle-ms.cpp | 105 + clang/test/CodeGenCXX/mangle-neon-vectors.cpp | 32 + clang/test/CodeGenCXX/mangle-nullptr-arg.cpp | 13 + clang/test/CodeGenCXX/mangle-ref-qualifiers.cpp | 16 + clang/test/CodeGenCXX/mangle-std-externc.cpp | 27 + clang/test/CodeGenCXX/mangle-subst-std.cpp | 112 + clang/test/CodeGenCXX/mangle-subst.cpp | 82 + clang/test/CodeGenCXX/mangle-system-header.cpp | 11 + clang/test/CodeGenCXX/mangle-template.cpp | 172 ++ clang/test/CodeGenCXX/mangle-this-cxx11.cpp | 20 + .../CodeGenCXX/mangle-unnameable-conversions.cpp | 14 + clang/test/CodeGenCXX/mangle-unnamed.cpp | 92 + .../test/CodeGenCXX/mangle-variadic-templates.cpp | 67 + clang/test/CodeGenCXX/mangle.cpp | 854 ++++++ clang/test/CodeGenCXX/member-alignment.cpp | 20 + clang/test/CodeGenCXX/member-call-parens.cpp | 12 + clang/test/CodeGenCXX/member-expressions.cpp | 86 + .../CodeGenCXX/member-function-pointer-calls.cpp | 23 + clang/test/CodeGenCXX/member-function-pointers.cpp | 274 ++ clang/test/CodeGenCXX/member-functions.cpp | 63 + clang/test/CodeGenCXX/member-init-anon-union.cpp | 35 + clang/test/CodeGenCXX/member-init-assignment.cpp | 17 + clang/test/CodeGenCXX/member-init-ctor.cpp | 14 + clang/test/CodeGenCXX/member-init-struct.cpp | 18 + clang/test/CodeGenCXX/member-init-union.cpp | 10 + clang/test/CodeGenCXX/member-initializers.cpp | 34 + .../CodeGenCXX/member-pointer-type-convert.cpp | 11 + clang/test/CodeGenCXX/member-templates.cpp | 31 + clang/test/CodeGenCXX/multi-dim-operator-new.cpp | 49 + clang/test/CodeGenCXX/namespace-aliases.cpp | 9 + .../test/CodeGenCXX/nested-base-member-access.cpp | 52 + .../test/CodeGenCXX/new-array-init-exceptions.cpp | 41 + clang/test/CodeGenCXX/new-array-init.cpp | 33 + clang/test/CodeGenCXX/new-operator-phi.cpp | 11 + clang/test/CodeGenCXX/new-overflow.cpp | 209 ++ clang/test/CodeGenCXX/new-with-default-arg.cpp | 33 + clang/test/CodeGenCXX/new.cpp | 252 ++ clang/test/CodeGenCXX/no-exceptions.cpp | 12 + clang/test/CodeGenCXX/noinline-template.cpp | 16 + clang/test/CodeGenCXX/nonconst-init.cpp | 5 + clang/test/CodeGenCXX/nrvo-noreturn.cc | 17 + clang/test/CodeGenCXX/nrvo.cpp | 161 + clang/test/CodeGenCXX/nullptr.cpp | 24 + clang/test/CodeGenCXX/operator-new.cpp | 29 + .../CodeGenCXX/overload-binop-implicitconvert.cpp | 22 + clang/test/CodeGenCXX/override-layout.cpp | 64 + clang/test/CodeGenCXX/partial-destruction.cpp | 172 ++ clang/test/CodeGenCXX/pointers-to-data-members.cpp | 242 ++ clang/test/CodeGenCXX/pr11676.cpp | 17 + clang/test/CodeGenCXX/pr11797.cpp | 8 + clang/test/CodeGenCXX/pr12104.cpp | 7 + clang/test/CodeGenCXX/pr12104.h | 9 + clang/test/CodeGenCXX/pr12251.cpp | 146 + clang/test/CodeGenCXX/pr9130.cpp | 14 + clang/test/CodeGenCXX/pr9965.cpp | 14 + clang/test/CodeGenCXX/pragma-pack-2.cpp | 17 + clang/test/CodeGenCXX/pragma-pack.cpp | 16 + clang/test/CodeGenCXX/pragma-visibility.cpp | 62 + clang/test/CodeGenCXX/predefined-expr-sizeof.cpp | 30 + clang/test/CodeGenCXX/predefined-expr.cpp | 517 ++++ clang/test/CodeGenCXX/ptr-to-datamember.cpp | 99 + clang/test/CodeGenCXX/ptr-to-member-function.cpp | 71 + .../CodeGenCXX/reference-bind-default-argument.cpp | 6 + clang/test/CodeGenCXX/reference-cast.cpp | 194 ++ clang/test/CodeGenCXX/reference-field.cpp | 6 + clang/test/CodeGenCXX/reference-in-block-args.cpp | 29 + clang/test/CodeGenCXX/reference-in-blocks.cpp | 43 + clang/test/CodeGenCXX/reference-init.cpp | 24 + clang/test/CodeGenCXX/references.cpp | 313 ++ clang/test/CodeGenCXX/regparm.cpp | 6 + clang/test/CodeGenCXX/reinterpret-cast.cpp | 17 + clang/test/CodeGenCXX/rtti-fundamental.cpp | 116 + clang/test/CodeGenCXX/rtti-layout.cpp | 205 ++ clang/test/CodeGenCXX/rtti-linkage.cpp | 140 + clang/test/CodeGenCXX/rtti-visibility.cpp | 35 + clang/test/CodeGenCXX/rvalue-references.cpp | 111 + clang/test/CodeGenCXX/scoped-enums.cpp | 9 + clang/test/CodeGenCXX/sel-address.mm | 14 + clang/test/CodeGenCXX/sizeof-unwind-exception.cpp | 28 + .../skip-vtable-pointer-initialization.cpp | 200 ++ .../specialized-static-data-mem-init.cpp | 29 + clang/test/CodeGenCXX/static-assert.cpp | 7 + clang/test/CodeGenCXX/static-data-member.cpp | 104 + clang/test/CodeGenCXX/static-init-1.cpp | 23 + clang/test/CodeGenCXX/static-init-2.cpp | 6 + clang/test/CodeGenCXX/static-init-3.cpp | 28 + clang/test/CodeGenCXX/static-init.cpp | 154 + .../CodeGenCXX/static-local-in-local-class.cpp | 33 + ...tic-member-variable-explicit-specialization.cpp | 11 + clang/test/CodeGenCXX/static-mutable.cpp | 12 + clang/test/CodeGenCXX/stmtexpr.cpp | 75 + clang/test/CodeGenCXX/switch-case-folding-1.cpp | 22 + clang/test/CodeGenCXX/switch-case-folding-2.cpp | 21 + clang/test/CodeGenCXX/switch-case-folding.cpp | 18 + clang/test/CodeGenCXX/temp-order.cpp | 226 ++ clang/test/CodeGenCXX/template-anonymous-types.cpp | 37 + ...template-anonymous-union-member-initializer.cpp | 11 + .../template-dependent-bind-temporary.cpp | 24 + .../template-inner-struct-visibility-hidden.cpp | 24 + clang/test/CodeGenCXX/template-instantiation.cpp | 190 ++ clang/test/CodeGenCXX/template-linkage.cpp | 44 + .../test/CodeGenCXX/template-static-var-defer.cpp | 12 + clang/test/CodeGenCXX/temporaries.cpp | 539 ++++ clang/test/CodeGenCXX/thiscall-struct-return.cpp | 41 + .../CodeGenCXX/threadsafe-statics-exceptions.cpp | 28 + clang/test/CodeGenCXX/threadsafe-statics.cpp | 23 + clang/test/CodeGenCXX/throw-expression-dtor.cpp | 13 + clang/test/CodeGenCXX/throw-expressions.cpp | 20 + clang/test/CodeGenCXX/thunk-linkonce-odr.cpp | 33 + clang/test/CodeGenCXX/thunk-use-after-free.cpp | 42 + .../CodeGenCXX/thunks-available-externally.cpp | 88 + clang/test/CodeGenCXX/thunks.cpp | 308 ++ clang/test/CodeGenCXX/trivial-constructor-init.cpp | 20 + clang/test/CodeGenCXX/try-catch.cpp | 13 + clang/test/CodeGenCXX/typeid-cxx11.cpp | 30 + clang/test/CodeGenCXX/typeid.cpp | 44 + clang/test/CodeGenCXX/typeinfo | 16 + clang/test/CodeGenCXX/unary-type-trait.cpp | 3 + clang/test/CodeGenCXX/uncode-string.cpp | 6 + clang/test/CodeGenCXX/union-dtor.cpp | 42 + clang/test/CodeGenCXX/unknown-anytype.cpp | 99 + clang/test/CodeGenCXX/value-init.cpp | 262 ++ clang/test/CodeGenCXX/vararg-conversion-ctor.cpp | 23 + clang/test/CodeGenCXX/vararg-non-pod.cpp | 16 + clang/test/CodeGenCXX/varargs.cpp | 43 + clang/test/CodeGenCXX/variadic-templates.cpp | 23 + clang/test/CodeGenCXX/virt-call-offsets.cpp | 8 + clang/test/CodeGenCXX/virt-canonical-decl.cpp | 19 + clang/test/CodeGenCXX/virt-dtor-gen.cpp | 10 + clang/test/CodeGenCXX/virt-dtor-key.cpp | 9 + clang/test/CodeGenCXX/virt-template-vtable.cpp | 22 + clang/test/CodeGenCXX/virt-thunk-reference.cpp | 7 + clang/test/CodeGenCXX/virtual-base-cast.cpp | 33 + clang/test/CodeGenCXX/virtual-base-ctor.cpp | 11 + .../CodeGenCXX/virtual-base-destructor-call.cpp | 51 + clang/test/CodeGenCXX/virtual-bases.cpp | 48 + clang/test/CodeGenCXX/virtual-destructor-calls.cpp | 48 + .../CodeGenCXX/virtual-destructor-synthesis.cpp | 16 + clang/test/CodeGenCXX/virtual-function-calls.cpp | 38 + .../virtual-functions-incomplete-types.cpp | 30 + .../virtual-implicit-copy-assignment.cpp | 11 + .../virtual-implicit-move-assignment.cpp | 12 + .../CodeGenCXX/virtual-inherited-destructor.cpp | 8 + clang/test/CodeGenCXX/virtual-operator-call.cpp | 10 + .../CodeGenCXX/virtual-pseudo-destructor-call.cpp | 14 + .../visibility-hidden-extern-templates.cpp | 26 + .../test/CodeGenCXX/visibility-inlines-hidden.cpp | 110 + clang/test/CodeGenCXX/visibility.cpp | 607 ++++ clang/test/CodeGenCXX/vla.cpp | 56 + clang/test/CodeGenCXX/volatile-1.cpp | 352 +++ clang/test/CodeGenCXX/volatile.cpp | 33 + .../CodeGenCXX/vtable-available-externally.cpp | 171 ++ clang/test/CodeGenCXX/vtable-cast-crash.cpp | 21 + clang/test/CodeGenCXX/vtable-debug-info.cpp | 319 ++ clang/test/CodeGenCXX/vtable-key-function.cpp | 33 + .../test/CodeGenCXX/vtable-layout-abi-examples.cpp | 322 ++ clang/test/CodeGenCXX/vtable-layout-extreme.cpp | 210 ++ clang/test/CodeGenCXX/vtable-layout.cpp | 1729 +++++++++++ clang/test/CodeGenCXX/vtable-linkage.cpp | 216 ++ .../CodeGenCXX/vtable-pointer-initialization.cpp | 57 + clang/test/CodeGenCXX/vtt-layout.cpp | 64 + clang/test/CodeGenCXX/warn-padded-packed.cpp | 76 + clang/test/CodeGenCXX/weak-extern-typeinfo.cpp | 47 + clang/test/CodeGenCXX/weak-external.cpp | 66 + clang/test/CodeGenCXX/x86_32-arguments.cpp | 116 + clang/test/CodeGenCXX/x86_64-arguments.cpp | 183 ++ clang/test/CodeGenObjC/2007-04-03-ObjcEH.m | 27 + clang/test/CodeGenObjC/2007-05-02-Strong.m | 23 + clang/test/CodeGenObjC/2007-10-18-ProDescriptor.m | 18 + .../test/CodeGenObjC/2007-10-23-GC-WriteBarrier.m | 9 + .../2008-08-25-incompatible-cond-expr.m | 10 + clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m | 7 + clang/test/CodeGenObjC/2008-10-3-EhValue.m | 50 + clang/test/CodeGenObjC/2008-11-12-Metadata.m | 14 + clang/test/CodeGenObjC/2008-11-24-ConstCFStrings.m | 13 + clang/test/CodeGenObjC/2008-11-25-Blocks.m | 17 + .../CodeGenObjC/2009-01-21-invalid-debug-info.m | 16 + clang/test/CodeGenObjC/2009-01-26-WriteBarrier-2.m | 19 + clang/test/CodeGenObjC/2009-02-05-VolatileProp.m | 10 + clang/test/CodeGenObjC/2009-08-05-utf16.m | 5 + .../test/CodeGenObjC/2010-02-01-utf16-with-null.m | 5 + clang/test/CodeGenObjC/2010-02-09-DbgSelf.m | 14 + .../test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m | 15 + clang/test/CodeGenObjC/2010-02-23-DbgInheritance.m | 10 + clang/test/CodeGenObjC/2010-03-17-StructRef.m | 43 + clang/test/CodeGenObjC/2011-03-08-IVarLookup.m | 30 + clang/test/CodeGenObjC/Inputs/literal-support.h | 35 + clang/test/CodeGenObjC/arc-arm.m | 20 + clang/test/CodeGenObjC/arc-block-copy-escape.m | 22 + clang/test/CodeGenObjC/arc-block-ivar-layout.m | 60 + clang/test/CodeGenObjC/arc-blocks.m | 523 ++++ clang/test/CodeGenObjC/arc-bridged-cast.m | 90 + clang/test/CodeGenObjC/arc-compound-stmt.m | 29 + clang/test/CodeGenObjC/arc-cond-stmt.m | 48 + clang/test/CodeGenObjC/arc-exceptions.m | 45 + clang/test/CodeGenObjC/arc-foreach.m | 173 ++ clang/test/CodeGenObjC/arc-ivar-layout.m | 55 + clang/test/CodeGenObjC/arc-literals.m | 121 + clang/test/CodeGenObjC/arc-no-arc-exceptions.m | 78 + clang/test/CodeGenObjC/arc-no-runtime.m | 9 + clang/test/CodeGenObjC/arc-property.m | 15 + clang/test/CodeGenObjC/arc-related-result-type.m | 30 + clang/test/CodeGenObjC/arc-unbridged-cast.m | 35 + clang/test/CodeGenObjC/arc-unopt.m | 69 + clang/test/CodeGenObjC/arc-weak-property.m | 55 + clang/test/CodeGenObjC/arc-with-atthrow.m | 17 + clang/test/CodeGenObjC/arc.m | 1539 ++++++++++ .../CodeGenObjC/arm-atomic-scalar-setter-getter.m | 13 + clang/test/CodeGenObjC/assign.m | 36 + clang/test/CodeGenObjC/atomic-aggregate-property.m | 42 + clang/test/CodeGenObjC/attr-availability.m | 24 + clang/test/CodeGenObjC/attr-strong.c | 9 + .../auto-property-synthesize-protocol.m | 37 + clang/test/CodeGenObjC/autorelease.m | 30 + clang/test/CodeGenObjC/bitfield-1.m | 81 + clang/test/CodeGenObjC/bitfield-access.m | 44 + clang/test/CodeGenObjC/bitfield-gnu.m | 5 + clang/test/CodeGenObjC/bitfield-ivar-metadata.m | 15 + clang/test/CodeGenObjC/bitfield-ivar-offsets.m | 25 + clang/test/CodeGenObjC/bitfield_encoding.m | 12 + clang/test/CodeGenObjC/block-6.m | 18 + clang/test/CodeGenObjC/block-var-layout.m | 166 ++ clang/test/CodeGenObjC/blocks-1.m | 43 + clang/test/CodeGenObjC/blocks-2.m | 38 + clang/test/CodeGenObjC/blocks-3.m | 21 + clang/test/CodeGenObjC/blocks-4.m | 21 + clang/test/CodeGenObjC/blocks-5.m | 37 + clang/test/CodeGenObjC/blocks-ivar-debug.m | 20 + clang/test/CodeGenObjC/blocks.m | 102 + clang/test/CodeGenObjC/builtins.m | 7 + clang/test/CodeGenObjC/catch-lexical-block.m | 16 + clang/test/CodeGenObjC/category-class.m | 17 + clang/test/CodeGenObjC/category-super-class-meth.m | 19 + clang/test/CodeGenObjC/class-getter-dotsyntax.m | 21 + clang/test/CodeGenObjC/class-type.m | 36 + clang/test/CodeGenObjC/compatibility-alias.m | 8 + clang/test/CodeGenObjC/complex-double-abi.m | 16 + clang/test/CodeGenObjC/complex-property.m | 32 + clang/test/CodeGenObjC/constant-string-class-1.m | 23 + clang/test/CodeGenObjC/constant-string-class.m | 35 + clang/test/CodeGenObjC/constant-strings.m | 16 + clang/test/CodeGenObjC/continuation-class.m | 35 + clang/test/CodeGenObjC/deadcode_strip_used_var.m | 9 + clang/test/CodeGenObjC/debug-info-block-helper.m | 30 + clang/test/CodeGenObjC/debug-info-blocks.m | 55 + .../test/CodeGenObjC/debug-info-class-extension.m | 15 + .../test/CodeGenObjC/debug-info-class-extension2.m | 14 + .../test/CodeGenObjC/debug-info-class-extension3.m | 12 + clang/test/CodeGenObjC/debug-info-crash-2.m | 15 + clang/test/CodeGenObjC/debug-info-crash.m | 41 + .../CodeGenObjC/debug-info-default-synth-ivar.m | 35 + clang/test/CodeGenObjC/debug-info-fwddecl.m | 5 + clang/test/CodeGenObjC/debug-info-getter-name.m | 54 + clang/test/CodeGenObjC/debug-info-impl.m | 16 + clang/test/CodeGenObjC/debug-info-linkagename.m | 18 + clang/test/CodeGenObjC/debug-info-property.m | 14 + clang/test/CodeGenObjC/debug-info-property2.m | 14 + clang/test/CodeGenObjC/debug-info-property3.m | 12 + clang/test/CodeGenObjC/debug-info-property4.m | 17 + clang/test/CodeGenObjC/debug-info-property5.m | 32 + clang/test/CodeGenObjC/debug-info-pubtypes.m | 14 + clang/test/CodeGenObjC/debug-info-selector.m | 15 + clang/test/CodeGenObjC/debug-info-self.m | 16 + clang/test/CodeGenObjC/debug-info-static-var.m | 23 + clang/test/CodeGenObjC/debug-info-synthesis.m | 34 + clang/test/CodeGenObjC/debug-property-synth.m | 20 + .../test/CodeGenObjC/default-property-synthesis.m | 38 + clang/test/CodeGenObjC/dot-syntax-1.m | 264 ++ clang/test/CodeGenObjC/dot-syntax-2.m | 27 + clang/test/CodeGenObjC/dot-syntax.m | 98 + clang/test/CodeGenObjC/encode-cstyle-method.m | 11 + clang/test/CodeGenObjC/encode-test-2.m | 30 + clang/test/CodeGenObjC/encode-test-3.m | 21 + clang/test/CodeGenObjC/encode-test-4.m | 10 + clang/test/CodeGenObjC/encode-test-5.m | 16 + clang/test/CodeGenObjC/encode-test.m | 167 ++ clang/test/CodeGenObjC/exceptions-nonfragile.m | 31 + clang/test/CodeGenObjC/exceptions.m | 183 ++ clang/test/CodeGenObjC/for-in.m | 50 + .../test/CodeGenObjC/forward-class-impl-metadata.m | 47 + clang/test/CodeGenObjC/forward-decl-param.m | 19 + clang/test/CodeGenObjC/fp2ret.m | 28 + clang/test/CodeGenObjC/fpret.m | 38 + clang/test/CodeGenObjC/function-decay.m | 10 + clang/test/CodeGenObjC/gc-weak-attribute.m | 28 + clang/test/CodeGenObjC/gc.m | 14 + clang/test/CodeGenObjC/gnu-exceptions.m | 29 + clang/test/CodeGenObjC/hidden-visibility.m | 25 + clang/test/CodeGenObjC/hidden.m | 19 + clang/test/CodeGenObjC/id-isa-codegen.m | 73 + clang/test/CodeGenObjC/illegal-UTF8.m | 6 + clang/test/CodeGenObjC/image-info.m | 17 + clang/test/CodeGenObjC/implicit-objc_msgSend.m | 7 + clang/test/CodeGenObjC/implicit-property.m | 16 + clang/test/CodeGenObjC/instance-method-metadata.m | 35 + clang/test/CodeGenObjC/interface-layout-64.m | 123 + clang/test/CodeGenObjC/interface.m | 34 + .../test/CodeGenObjC/ivar-base-as-invariant-load.m | 29 + clang/test/CodeGenObjC/ivar-layout-64-bitfields.m | 46 + clang/test/CodeGenObjC/ivar-layout-64.m | 94 + clang/test/CodeGenObjC/ivar-layout-array0-struct.m | 23 + clang/test/CodeGenObjC/ivar-layout-no-optimize.m | 20 + .../test/CodeGenObjC/ivar-layout-nonfragile-abi2.m | 51 + clang/test/CodeGenObjC/ivars.m | 29 + clang/test/CodeGenObjC/link-errors.m | 39 + clang/test/CodeGenObjC/local-static-block.m | 57 + clang/test/CodeGenObjC/message-arrays.m | 15 + clang/test/CodeGenObjC/messages-2.m | 175 ++ clang/test/CodeGenObjC/messages.m | 47 + clang/test/CodeGenObjC/metadata-symbols-32.m | 87 + clang/test/CodeGenObjC/metadata-symbols-64.m | 129 + clang/test/CodeGenObjC/metadata_symbols.m | 75 + clang/test/CodeGenObjC/misc-atomic-property.m | 80 + clang/test/CodeGenObjC/mrr-autorelease.m | 24 + clang/test/CodeGenObjC/nested-rethrow.m | 25 + .../CodeGenObjC/newproperty-nested-synthesis-1.m | 78 + clang/test/CodeGenObjC/next-objc-dispatch.m | 73 + clang/test/CodeGenObjC/no-category-class.m | 8 + clang/test/CodeGenObjC/no-vararg-messaging.m | 19 + clang/test/CodeGenObjC/non-lazy-classes.m | 32 + clang/test/CodeGenObjC/nonlazy-msgSend.m | 6 + clang/test/CodeGenObjC/ns-constant-strings.m | 39 + clang/test/CodeGenObjC/ns_consume_null_check.m | 32 + clang/test/CodeGenObjC/objc-align.m | 44 + .../CodeGenObjC/objc-arc-container-subscripting.m | 21 + clang/test/CodeGenObjC/objc-assign-ivar.m | 52 + .../CodeGenObjC/objc-container-subscripting-1.m | 56 + .../test/CodeGenObjC/objc-container-subscripting.m | 45 + clang/test/CodeGenObjC/objc-dictionary-literal.m | 25 + clang/test/CodeGenObjC/objc-gc-aggr-assign.m | 62 + .../test/CodeGenObjC/objc-literal-debugger-test.m | 16 + clang/test/CodeGenObjC/objc-literal-tests.m | 95 + clang/test/CodeGenObjC/objc-read-weak-byref.m | 26 + clang/test/CodeGenObjC/objc2-assign-global.m | 80 + clang/test/CodeGenObjC/objc2-ivar-assign.m | 40 + clang/test/CodeGenObjC/objc2-legacy-dispatch.m | 26 + .../test/CodeGenObjC/objc2-new-gc-api-strongcast.m | 27 + clang/test/CodeGenObjC/objc2-no-strong-cast.m | 22 + clang/test/CodeGenObjC/objc2-no-write-barrier.m | 20 + clang/test/CodeGenObjC/objc2-nonfragile-abi-impl.m | 15 + clang/test/CodeGenObjC/objc2-property-encode.m | 13 + clang/test/CodeGenObjC/objc2-protocol-enc.m | 43 + clang/test/CodeGenObjC/objc2-retain-codegen.m | 13 + clang/test/CodeGenObjC/objc2-strong-cast-1.m | 24 + .../CodeGenObjC/objc2-strong-cast-block-import.m | 25 + clang/test/CodeGenObjC/objc2-strong-cast.m | 18 + clang/test/CodeGenObjC/objc2-weak-assign.m | 28 + clang/test/CodeGenObjC/objc2-weak-block-call.m | 24 + clang/test/CodeGenObjC/objc2-weak-compare.m | 26 + .../test/CodeGenObjC/objc2-weak-import-attribute.m | 48 + clang/test/CodeGenObjC/objc2-weak-ivar-debug.m | 17 + clang/test/CodeGenObjC/objc2-weak-ivar.m | 11 + clang/test/CodeGenObjC/objc2-write-barrier-2.m | 83 + clang/test/CodeGenObjC/objc2-write-barrier-3.m | 49 + clang/test/CodeGenObjC/objc2-write-barrier-4.m | 30 + clang/test/CodeGenObjC/objc2-write-barrier-5.m | 46 + clang/test/CodeGenObjC/objc2-write-barrier.m | 116 + clang/test/CodeGenObjC/object-incr-decr-1.m | 19 + clang/test/CodeGenObjC/optimized-setter.m | 33 + clang/test/CodeGenObjC/overloadable.m | 10 + clang/test/CodeGenObjC/predefined-expr.m | 90 + clang/test/CodeGenObjC/property-aggregate.m | 31 + clang/test/CodeGenObjC/property-agrr-getter.m | 44 + clang/test/CodeGenObjC/property-category-impl.m | 20 + clang/test/CodeGenObjC/property-complex.m | 61 + clang/test/CodeGenObjC/property-dbg.m | 17 + .../test/CodeGenObjC/property-getter-dot-syntax.m | 11 + clang/test/CodeGenObjC/property-incr-decr-1.m | 29 + clang/test/CodeGenObjC/property-list-in-class.m | 32 + clang/test/CodeGenObjC/property-ref-cast-to-void.m | 18 + clang/test/CodeGenObjC/property-setter-attr.m | 10 + clang/test/CodeGenObjC/property-type-mismatch.m | 17 + clang/test/CodeGenObjC/property.m | 168 ++ .../test/CodeGenObjC/protocol-in-extended-class.m | 29 + clang/test/CodeGenObjC/protocol-property-synth.m | 33 + clang/test/CodeGenObjC/protocols-lazy.m | 47 + clang/test/CodeGenObjC/protocols.m | 57 + .../rdr-6732143-dangling-block-reference.m | 10 + clang/test/CodeGenObjC/related-result-type.m | 54 + clang/test/CodeGenObjC/return-objc-object.mm | 19 + clang/test/CodeGenObjC/runtime-fns.m | 33 + clang/test/CodeGenObjC/sel-as-builtin-type.m | 23 + clang/test/CodeGenObjC/selector-ref-invariance.m | 9 + clang/test/CodeGenObjC/simplify-exceptions.mm | 18 + .../test/CodeGenObjC/stand-alone-implementation.m | 16 + .../test/CodeGenObjC/super-classmethod-category.m | 13 + clang/test/CodeGenObjC/super-dotsyntax-property.m | 41 + .../CodeGenObjC/super-dotsyntax-struct-property.m | 47 + clang/test/CodeGenObjC/super-message-fragileabi.m | 32 + clang/test/CodeGenObjC/synchronized.m | 79 + .../test/CodeGenObjC/synthesize_ivar-cont-class.m | 18 + clang/test/CodeGenObjC/synthesize_ivar.m | 38 + clang/test/CodeGenObjC/terminate.m | 29 + clang/test/CodeGenObjC/try.m | 10 + clang/test/CodeGenObjC/undefined-protocol.m | 6 + clang/test/CodeGenObjC/unname-bf-metadata.m | 14 + clang/test/CodeGenObjC/variadic-sends.m | 41 + clang/test/CodeGenObjC/x86_64-struct-return-gc.m | 31 + .../CodeGenObjCXX/2007-10-03-MetadataPointers.mm | 7 + clang/test/CodeGenObjCXX/2010-08-04-Template.mm | 10 + clang/test/CodeGenObjCXX/2010-08-06-X.Y-syntax.mm | 16 + clang/test/CodeGenObjCXX/Inputs/literal-support.h | 35 + clang/test/CodeGenObjCXX/address-safety-attr.mm | 20 + clang/test/CodeGenObjCXX/arc-exceptions.mm | 85 + clang/test/CodeGenObjCXX/arc-globals.mm | 27 + clang/test/CodeGenObjCXX/arc-mangle.mm | 25 + clang/test/CodeGenObjCXX/arc-move.mm | 75 + clang/test/CodeGenObjCXX/arc-new-delete.mm | 95 + clang/test/CodeGenObjCXX/arc-pseudo-destructors.mm | 21 + clang/test/CodeGenObjCXX/arc-references.mm | 84 + .../arc-returns-inner-reference-ptr.mm | 22 + .../CodeGenObjCXX/arc-special-member-functions.mm | 165 ++ clang/test/CodeGenObjCXX/arc.mm | 254 ++ clang/test/CodeGenObjCXX/block-in-template-inst.mm | 71 + clang/test/CodeGenObjCXX/block-var-layout.mm | 157 + clang/test/CodeGenObjCXX/blocks.mm | 46 + clang/test/CodeGenObjCXX/catch-id-type.mm | 51 + clang/test/CodeGenObjCXX/copy.mm | 39 + .../test/CodeGenObjCXX/copyable-property-object.mm | 28 + clang/test/CodeGenObjCXX/debug-info.mm | 41 + clang/test/CodeGenObjCXX/encode.mm | 189 ++ clang/test/CodeGenObjCXX/exceptions.mm | 18 + clang/test/CodeGenObjCXX/foreach-statement.mm | 10 + clang/test/CodeGenObjCXX/gc.mm | 20 + .../CodeGenObjCXX/implicit-copy-assign-operator.mm | 57 + .../CodeGenObjCXX/implicit-copy-constructor.mm | 73 + clang/test/CodeGenObjCXX/ivar-objects.mm | 104 + clang/test/CodeGenObjCXX/lambda-expressions.mm | 39 + clang/test/CodeGenObjCXX/literals.mm | 111 + .../test/CodeGenObjCXX/lvalue-reference-getter.mm | 28 + clang/test/CodeGenObjCXX/mangle-blocks.mm | 50 + clang/test/CodeGenObjCXX/mangle.mm | 56 + clang/test/CodeGenObjCXX/message-reference.mm | 20 + .../CodeGenObjCXX/method-local-extern-mangle.mm | 14 + clang/test/CodeGenObjCXX/nrvo.mm | 32 + .../CodeGenObjCXX/objc-container-subscripting-1.mm | 50 + .../CodeGenObjCXX/objc-container-subscripting.mm | 57 + .../CodeGenObjCXX/property-derived-to-base-conv.mm | 25 + clang/test/CodeGenObjCXX/property-dot-copy.mm | 68 + clang/test/CodeGenObjCXX/property-dot-reference.mm | 62 + .../property-object-conditional-exp.mm | 44 + .../CodeGenObjCXX/property-object-reference-1.mm | 31 + .../CodeGenObjCXX/property-object-reference-2.mm | 56 + .../CodeGenObjCXX/property-object-reference.mm | 35 + clang/test/CodeGenObjCXX/property-objects.mm | 78 + clang/test/CodeGenObjCXX/property-reference.mm | 96 + .../CodeGenObjCXX/refence-assign-write-barrier.mm | 20 + clang/test/CodeGenObjCXX/references.mm | 45 + clang/test/CodeGenObjCXX/rtti.mm | 52 + clang/test/CodeGenObjCXX/selector-expr-lvalue.mm | 16 + .../CodeGenObjCXX/write-barrier-global-assign.mm | 29 + .../CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl | 11 + clang/test/CodeGenOpenCL/address-spaces.cl | 27 + clang/test/CodeGenOpenCL/ext-vector-shuffle.cl | 17 + clang/test/CodeGenOpenCL/fpmath.cl | 25 + clang/test/CodeGenOpenCL/kernel-metadata.cl | 10 + clang/test/CodeGenOpenCL/local.cl | 7 + clang/test/CodeGenOpenCL/ptx-calls.cl | 12 + clang/test/CodeGenOpenCL/ptx-kernels.cl | 10 + .../CodeGenOpenCL/single-precision-constant.cl | 7 + clang/test/CodeGenOpenCL/vector_literals_nested.cl | 23 + clang/test/CodeGenOpenCL/vector_literals_valid.cl | 22 + clang/test/CodeGenOpenCL/vector_logops.cl | 19 + clang/test/Coverage/ast-printing.c | 6 + clang/test/Coverage/ast-printing.cpp | 7 + clang/test/Coverage/ast-printing.m | 5 + clang/test/Coverage/c-language-features.inc | 198 ++ clang/test/Coverage/codegen-gnu.m | 3 + clang/test/Coverage/codegen-next.m | 4 + clang/test/Coverage/codegen.c | 7 + clang/test/Coverage/cxx-language-features.inc | 27 + clang/test/Coverage/html-diagnostics.c | 22 + clang/test/Coverage/html-print.c | 3 + clang/test/Coverage/objc-language-features.inc | 87 + clang/test/Coverage/targets.c | 20 + clang/test/Coverage/verbose.c | 1 + .../Driver/Inputs/basic_freebsd64_tree/lib/.keep | 0 .../Inputs/basic_freebsd64_tree/usr/lib/.keep | 0 .../Inputs/basic_freebsd64_tree/usr/lib/crt1.o | 0 .../Inputs/basic_freebsd64_tree/usr/lib32/.keep | 0 .../Driver/Inputs/basic_freebsd_tree/lib/.keep | 0 .../Driver/Inputs/basic_freebsd_tree/usr/lib/.keep | 0 .../Inputs/basic_freebsd_tree/usr/lib/crt1.o | 0 .../Inputs/basic_freebsd_tree/usr/lib32/.keep | 0 .../test/Driver/Inputs/basic_linux_tree/lib/.keep | 0 .../usr/i386-unknown-linux/lib/.keep | 0 .../Driver/Inputs/basic_linux_tree/usr/lib/.keep | 0 .../lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o | 0 .../lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o | 0 .../usr/x86_64-unknown-linux/lib/.keep | 0 .../Driver/Inputs/debian_multiarch_tree/lib/.keep | 0 .../debian_multiarch_tree/lib/i386-linux-gnu/.keep | 0 .../lib/powerpc-linux-gnu/.keep | 0 .../lib/powerpc64-linux-gnu/.keep | 0 .../lib/x86_64-linux-gnu/.keep | 0 .../Inputs/debian_multiarch_tree/usr/include/.keep | 0 .../usr/include/c++/4.5/.keep | 0 .../usr/include/c++/4.5/backward/.keep | 0 .../usr/include/c++/4.5/i686-linux-gnu/.keep | 0 .../usr/include/c++/4.5/powerpc-linux-gnu/.keep | 0 .../usr/include/c++/4.5/powerpc64-linux-gnu/.keep | 0 .../usr/include/c++/4.5/x86_64-linux-gnu/.keep | 0 .../usr/include/i386-linux-gnu/.keep | 0 .../usr/include/powerpc-linux-gnu/.keep | 0 .../usr/include/powerpc64-linux-gnu/.keep | 0 .../usr/include/x86_64-linux-gnu/.keep | 0 .../Inputs/debian_multiarch_tree/usr/lib/.keep | 0 .../usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o | 0 .../usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o | 0 .../usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o | 0 .../usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o | 0 .../usr/lib/i386-linux-gnu/.keep | 0 .../usr/lib/powerpc-linux-gnu/.keep | 0 .../usr/lib/powerpc64-linux-gnu/.keep | 0 .../usr/lib/x86_64-linux-gnu/.keep | 0 .../test/Driver/Inputs/fake_install_tree/bin/.keep | 0 .../lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o | 0 .../lib/gcc/x86_64-unknown-linux/4.5.0/crtbegin.o | 0 .../Driver/Inputs/gcc_version_parsing1/bin/.keep | 0 .../lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.6/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.7/crtbegin.o | 0 .../Driver/Inputs/gcc_version_parsing2/bin/.keep | 0 .../lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.6.x/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o | 0 .../Driver/Inputs/gcc_version_parsing3/bin/.keep | 0 .../lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o | 0 .../gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o | 0 .../Driver/Inputs/gcc_version_parsing4/bin/.keep | 0 .../lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o | 0 .../gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o | 0 .../Inputs/multiarch_freebsd64_tree/lib/.keep | 0 .../Inputs/multiarch_freebsd64_tree/usr/lib/.keep | 0 .../Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o | 0 .../multiarch_freebsd64_tree/usr/lib32/.keep | 0 .../multiarch_freebsd64_tree/usr/lib32/crt1.o | 0 .../Inputs/multilib_32bit_linux_tree/lib/.keep | 0 .../Inputs/multilib_32bit_linux_tree/lib32/.keep | 0 .../Inputs/multilib_32bit_linux_tree/lib64/.keep | 0 .../usr/i386-unknown-linux/lib/.keep | 0 .../usr/i386-unknown-linux/lib32/.keep | 0 .../usr/i386-unknown-linux/lib64/.keep | 0 .../Inputs/multilib_32bit_linux_tree/usr/lib/.keep | 0 .../lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o | 0 .../lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o | 0 .../multilib_32bit_linux_tree/usr/lib32/.keep | 0 .../multilib_32bit_linux_tree/usr/lib64/.keep | 0 .../Inputs/multilib_64bit_linux_tree/lib/.keep | 0 .../Inputs/multilib_64bit_linux_tree/lib32/.keep | 0 .../Inputs/multilib_64bit_linux_tree/lib64/.keep | 0 .../Inputs/multilib_64bit_linux_tree/usr/lib/.keep | 0 .../gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o | 0 .../lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o | 0 .../multilib_64bit_linux_tree/usr/lib32/.keep | 0 .../multilib_64bit_linux_tree/usr/lib64/.keep | 0 .../usr/x86_64-unknown-linux/lib/.keep | 0 .../usr/x86_64-unknown-linux/lib32/.keep | 0 .../usr/x86_64-unknown-linux/lib64/.keep | 0 .../Inputs/prefixed_tools_tree/x86_64--linux-as | 2 + .../Inputs/prefixed_tools_tree/x86_64--linux-ld | 2 + .../Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep | 0 .../Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep | 0 .../gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o | 0 .../lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o | 0 .../Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep | 0 .../Inputs/ubuntu_11.04_multiarch_tree/lib/.keep | 0 .../lib/i386-linux-gnu/.keep | 0 .../ubuntu_11.04_multiarch_tree/usr/include/.keep | 0 .../usr/include/c++/4.5/.keep | 0 .../usr/include/c++/4.5/backward/.keep | 0 .../usr/include/c++/4.5/i686-linux-gnu/.keep | 0 .../usr/include/i386-linux-gnu/.keep | 0 .../ubuntu_11.04_multiarch_tree/usr/lib/.keep | 0 .../usr/lib/i386-linux-gnu/.keep | 0 .../gcc/i686-linux-gnu/4.5/crtbegin.o | 0 clang/test/Driver/Wp-args.c | 13 + clang/test/Driver/Xarch.c | 9 + clang/test/Driver/Xlinker-args.c | 9 + clang/test/Driver/altivec.cpp | 14 + clang/test/Driver/analyze.c | 8 + clang/test/Driver/apple-kext-i386.cpp | 50 + clang/test/Driver/apple-kext-mkernel.c | 22 + clang/test/Driver/arc-exceptions.m | 5 + clang/test/Driver/arc.c | 17 + clang/test/Driver/arch.c | 3 + clang/test/Driver/arclite-link.c | 8 + clang/test/Driver/arm-darwin-builtin.c | 14 + clang/test/Driver/arm-mfpmath.c | 29 + clang/test/Driver/arm-mfpu.c | 48 + clang/test/Driver/asan.c | 8 + clang/test/Driver/ast.c | 26 + clang/test/Driver/at_file.c | 30 + clang/test/Driver/at_file.c.args | 11 + clang/test/Driver/bindings.c | 49 + clang/test/Driver/cc-log-diagnostics.c | 35 + clang/test/Driver/cc-print-options.c | 7 + clang/test/Driver/ccc-add-args.c | 5 + .../test/Driver/ccc-host-triple-no-integrated-as.c | 17 + clang/test/Driver/cfi.c | 9 + clang/test/Driver/clang-c-as-cxx.c | 6 + clang/test/Driver/clang-exception-flags.cpp | 23 + clang/test/Driver/clang-g-opts.c | 5 + clang/test/Driver/clang-translation.c | 46 + clang/test/Driver/clang_cpp.c | 4 + clang/test/Driver/clang_f_opts.c | 31 + clang/test/Driver/clang_wrapv_opts.c | 11 + clang/test/Driver/cpath.c | 22 + clang/test/Driver/cpp-precomp.c | 5 + clang/test/Driver/darwin-as.c | 17 + clang/test/Driver/darwin-cc.c | 4 + clang/test/Driver/darwin-debug-flags.c | 13 + clang/test/Driver/darwin-dsymutil.c | 45 + clang/test/Driver/darwin-iphone-defaults.m | 28 + clang/test/Driver/darwin-ld.c | 123 + clang/test/Driver/darwin-objc-defaults.m | 88 + clang/test/Driver/darwin-objc-gc.m | 19 + clang/test/Driver/darwin-objc-options.m | 21 + clang/test/Driver/darwin-verify-debug.c | 34 + clang/test/Driver/darwin-version.c | 31 + clang/test/Driver/darwin-xarch.c | 20 + clang/test/Driver/debug-options-as.c | 18 + clang/test/Driver/debug-options.c | 27 + clang/test/Driver/debug.c | 11 + clang/test/Driver/default-toolchain.c | 8 + clang/test/Driver/diagnostics.c | 9 + clang/test/Driver/dragonfly.c | 7 + clang/test/Driver/dwarf2-cfi-asm.c | 35 + clang/test/Driver/emit-llvm.c | 10 + clang/test/Driver/exceptions.m | 19 + clang/test/Driver/fast-math.c | 119 + clang/test/Driver/flags.c | 9 + clang/test/Driver/frame-pointer.c | 24 + clang/test/Driver/freebsd.c | 30 + clang/test/Driver/gcc-toolchain.cpp | 23 + clang/test/Driver/gcc_forward.c | 13 + clang/test/Driver/gnu-runtime.m | 5 + clang/test/Driver/gold-lto.c | 6 + clang/test/Driver/hello.c | 18 + clang/test/Driver/immediate-options.c | 4 + clang/test/Driver/index-header-map.c | 4 + clang/test/Driver/invalid-o-level.c | 4 + clang/test/Driver/ios-simulator-arcruntime.c | 6 + clang/test/Driver/le32-unknown-nacl.cpp | 146 + clang/test/Driver/linker-opts.c | 5 + clang/test/Driver/linux-as.c | 31 + clang/test/Driver/linux-header-search.cpp | 75 + clang/test/Driver/linux-ld.c | 270 ++ clang/test/Driver/lto.c | 23 + clang/test/Driver/m_and_mm.c | 3 + clang/test/Driver/mg.c | 5 + clang/test/Driver/mips-as.c | 31 + clang/test/Driver/mips-float.c | 42 + clang/test/Driver/mno-global-merge.c | 12 + clang/test/Driver/modules.m | 6 + clang/test/Driver/modules.mm | 6 + clang/test/Driver/no-objc-arr.m | 8 + .../Driver/no-objc-default-synthesize-properties.m | 10 + clang/test/Driver/no-sibling-calls.c | 8 + clang/test/Driver/noexecstack.c | 1 + clang/test/Driver/noinline.c | 10 + clang/test/Driver/nostdincxx.cpp | 4 + clang/test/Driver/nostdlib.c | 4 + clang/test/Driver/nostdlibinc.c | 10 + clang/test/Driver/objc++-cpp-output.mm | 8 + clang/test/Driver/objc-cpp-output.m | 7 + clang/test/Driver/openbsd.c | 5 + clang/test/Driver/option-aliases.c | 11 + clang/test/Driver/output-file-cleanup.c | 25 + clang/test/Driver/parsing.c | 22 + clang/test/Driver/phases.c | 78 + clang/test/Driver/pic.c | 81 + clang/test/Driver/prefixed-tools.c | 12 + clang/test/Driver/preprocessor.c | 6 + clang/test/Driver/pth.c | 12 + clang/test/Driver/qa_override.c | 6 + clang/test/Driver/redundant-args.c | 2 + clang/test/Driver/redzone.c | 6 + clang/test/Driver/rewrite-legacy-objc.m | 15 + clang/test/Driver/rewrite-objc.m | 15 + clang/test/Driver/stackrealign.c | 12 + clang/test/Driver/std.c | 8 + clang/test/Driver/std.cpp | 24 + clang/test/Driver/sysroot-flags.c | 28 + clang/test/Driver/sysroot.c | 18 + clang/test/Driver/target.c | 11 + clang/test/Driver/tsan.c | 8 + clang/test/Driver/unknown-arg.c | 4 + clang/test/Driver/unknown-gcc-arch.c | 8 + clang/test/Driver/working-directory.c | 4 + clang/test/Driver/x86_features.c | 3 + clang/test/FixIt/atomic-property.m | 29 + clang/test/FixIt/auto-fixit.m | 11 + clang/test/FixIt/dereference-addressof.c | 22 + clang/test/FixIt/fixit-c90.c | 17 + clang/test/FixIt/fixit-cxx0x.cpp | 110 + clang/test/FixIt/fixit-cxx11-compat.cpp | 11 + clang/test/FixIt/fixit-errors-1.c | 16 + clang/test/FixIt/fixit-errors.c | 23 + clang/test/FixIt/fixit-function-call.cpp | 118 + .../test/FixIt/fixit-missing-method-return-type.m | 24 + clang/test/FixIt/fixit-objc-message.m | 38 + clang/test/FixIt/fixit-objc.m | 69 + clang/test/FixIt/fixit-pmem.cpp | 26 + clang/test/FixIt/fixit-recompile.c | 6 + clang/test/FixIt/fixit-recursive-block.c | 12 + clang/test/FixIt/fixit-static-object-decl.m | 29 + clang/test/FixIt/fixit-suffix.c | 5 + clang/test/FixIt/fixit-unrecoverable.c | 8 + clang/test/FixIt/fixit-unrecoverable.cpp | 12 + clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp | 21 + clang/test/FixIt/fixit-vexing-parse.cpp | 89 + clang/test/FixIt/fixit.c | 102 + clang/test/FixIt/fixit.cpp | 206 ++ clang/test/FixIt/no-fixit.cpp | 7 + clang/test/FixIt/no-macro-fixit.c | 16 + clang/test/FixIt/no-typo.c | 6 + clang/test/FixIt/objc-literals.m | 44 + clang/test/FixIt/typo-crash.cpp | 29 + clang/test/FixIt/typo-crash.m | 6 + clang/test/FixIt/typo.c | 37 + clang/test/FixIt/typo.cpp | 88 + clang/test/FixIt/typo.m | 167 ++ .../Headers/TestFramework.h | 1 + clang/test/Frontend/Inputs/lit.local.cfg | 1 + clang/test/Frontend/Inputs/test.h | 1 + clang/test/Frontend/Inputs/test2.h | 1 + clang/test/Frontend/Inputs/test3.h | 1 + clang/test/Frontend/Weverything.c | 9 + clang/test/Frontend/Wno-everything.c | 7 + clang/test/Frontend/ast-codegen.c | 12 + clang/test/Frontend/ast-main.c | 8 + clang/test/Frontend/cpp-output.c | 14 + clang/test/Frontend/darwin-version.c | 25 + clang/test/Frontend/dependency-gen.c | 27 + clang/test/Frontend/dependency-generation-crash.c | 4 + clang/test/Frontend/diagnostics-option-names.c | 8 + clang/test/Frontend/iframework.c | 3 + clang/test/Frontend/ir-support-codegen.ll | 9 + clang/test/Frontend/ir-support-errors.ll | 8 + clang/test/Frontend/lit.local.cfg | 1 + clang/test/Frontend/macros.c | 4 + clang/test/Frontend/output-failures.c | 4 + .../preprocessed-output-macro-first-token.c | 5 + clang/test/Frontend/print-header-includes.c | 8 + clang/test/Frontend/rewrite-macros.c | 17 + clang/test/Frontend/stdin.c | 3 + clang/test/Frontend/undef.c | 4 + clang/test/Frontend/unknown-pragmas.c | 4 + clang/test/Frontend/warning-mapping-1.c | 6 + clang/test/Frontend/warning-mapping-2.c | 5 + clang/test/Frontend/warning-mapping-3.c | 10 + clang/test/Frontend/warning-mapping-4.c | 6 + clang/test/Frontend/warning-mapping-5.c | 9 + clang/test/Headers/arm-neon-header.c | 5 + clang/test/Headers/c89.c | 10 + clang/test/Headers/int64-type.c | 4 + clang/test/Headers/stdbool.cpp | 14 + clang/test/Headers/typedef_guards.c | 28 + clang/test/Headers/wchar_limits.cpp | 9 + clang/test/Headers/wmmintrin.c | 4 + clang/test/Headers/x86-intrinsics-headers.c | 15 + clang/test/Index/IBOutletCollection.m | 18 + .../Framework.framework/Headers/Framework.h | 2 + clang/test/Index/Inputs/Headers/a.h | 2 + clang/test/Index/Inputs/Headers/a_extensions.h | 1 + clang/test/Index/Inputs/Headers/crash.h | 6 + clang/test/Index/Inputs/Headers/module.map | 10 + clang/test/Index/Inputs/Headers/nested/module.map | 4 + clang/test/Index/Inputs/Headers/nested/nested.h | 1 + clang/test/Index/Inputs/a.h | 4 + clang/test/Index/Inputs/b.h | 1 + clang/test/Index/Inputs/c-index-pch.h | 7 + clang/test/Index/Inputs/cindex-from-source.h | 1 + clang/test/Index/Inputs/complete-pch.h | 10 + .../Inputs/crash-recovery-code-complete-remap.c | 12 + .../Index/Inputs/crash-recovery-reparse-remap.c | 11 + clang/test/Index/Inputs/foo.h | 8 + clang/test/Index/Inputs/get-cursor-includes-1.h | 6 + clang/test/Index/Inputs/get-cursor-includes-2.h | 2 + clang/test/Index/Inputs/guarded.h | 6 + clang/test/Index/Inputs/lit.local.cfg | 1 + clang/test/Index/Inputs/objc.h | 11 + clang/test/Index/Inputs/pragma-once.h | 3 + clang/test/Index/Inputs/pragma_disable_warning.h | 1 + clang/test/Index/Inputs/preamble-reparse-1.c | 2 + clang/test/Index/Inputs/preamble-reparse-2.c | 1 + clang/test/Index/Inputs/preamble.h | 6 + clang/test/Index/Inputs/preamble_macro_template.h | 6 + clang/test/Index/Inputs/prefix.h | 4 + clang/test/Index/Inputs/redeclarations.h | 21 + clang/test/Index/Inputs/remap-complete-to.c | 6 + clang/test/Index/Inputs/remap-load-to.c | 3 + clang/test/Index/Inputs/reparse-instantiate.h | 14 + clang/test/Index/Inputs/t1.c | 28 + clang/test/Index/Inputs/t1.m | 20 + clang/test/Index/Inputs/t2.c | 11 + clang/test/Index/Inputs/t2.m | 13 + clang/test/Index/TestClassDecl.m | 33 + clang/test/Index/TestClassForwardDecl.m | 41 + clang/test/Index/annotate-attribute.cpp | 33 + clang/test/Index/annotate-context-sensitive.cpp | 42 + clang/test/Index/annotate-literals.m | 72 + clang/test/Index/annotate-macro-args.h | 16 + clang/test/Index/annotate-macro-args.m | 23 + .../test/Index/annotate-nested-name-specifier.cpp | 466 +++ clang/test/Index/annotate-subscripting.m | 92 + clang/test/Index/annotate-tokens-cxx0x.cpp | 27 + clang/test/Index/annotate-tokens-include.c | 7 + clang/test/Index/annotate-tokens-include.h | 1 + clang/test/Index/annotate-tokens-pp.c | 198 ++ clang/test/Index/annotate-tokens-preamble.c | 20 + .../Index/annotate-tokens-with-default-args.cpp | 16 + .../test/Index/annotate-tokens-with-default-args.h | 3 + clang/test/Index/annotate-tokens.c | 136 + clang/test/Index/annotate-tokens.cpp | 122 + clang/test/Index/annotate-tokens.m | 576 ++++ .../Index/annotate-toplevel-in-objccontainer.m | 33 + .../Index/annotate-toplevel-in-objccontainer.m.h | 9 + clang/test/Index/arc-annotate.m | 38 + clang/test/Index/arc-complete.m | 16 + clang/test/Index/asm-attribute.c | 6 + clang/test/Index/blocks.c | 34 + clang/test/Index/c-index-api-loadTU-test.m | 163 + clang/test/Index/c-index-getCursor-pp.c | 39 + clang/test/Index/c-index-getCursor-test.m | 168 ++ clang/test/Index/c-index-pch.c | 9 + clang/test/Index/c-index-redecls.c | 107 + clang/test/Index/cindex-from-source.m | 12 + clang/test/Index/cindex-on-invalid-usrs.m | 7 + clang/test/Index/cindex-on-invalid.m | 21 + clang/test/Index/cindex-test-inclusions.c | 13 + clang/test/Index/code-completion.cpp | 90 + clang/test/Index/complete-access-checks.cpp | 89 + clang/test/Index/complete-at-directives.m | 54 + clang/test/Index/complete-at-exprstmt.m | 55 + clang/test/Index/complete-blocks.m | 64 + clang/test/Index/complete-categories.m | 39 + clang/test/Index/complete-ctor-inits.cpp | 40 + clang/test/Index/complete-cxx-inline-methods.cpp | 44 + clang/test/Index/complete-declarators.cpp | 43 + clang/test/Index/complete-declarators.m | 72 + clang/test/Index/complete-driver-errors.c | 24 + clang/test/Index/complete-enums.c | 22 + clang/test/Index/complete-enums.cpp | 25 + clang/test/Index/complete-exprs.c | 69 + clang/test/Index/complete-exprs.cpp | 84 + clang/test/Index/complete-exprs.m | 49 + clang/test/Index/complete-hiding.c | 32 + clang/test/Index/complete-in-invalid-method.m | 19 + clang/test/Index/complete-in-stringify.c | 17 + clang/test/Index/complete-interfaces.m | 47 + clang/test/Index/complete-ivar-access.m | 69 + clang/test/Index/complete-kvc.m | 105 + clang/test/Index/complete-lambdas.cpp | 43 + clang/test/Index/complete-macro-args.c | 22 + clang/test/Index/complete-macros.c | 43 + clang/test/Index/complete-member-access.m | 77 + clang/test/Index/complete-memfunc-cvquals.cpp | 86 + clang/test/Index/complete-method-decls.m | 184 ++ clang/test/Index/complete-modules.m | 14 + clang/test/Index/complete-natural.m | 57 + clang/test/Index/complete-objc-message-id.m | 74 + clang/test/Index/complete-objc-message.m | 336 +++ clang/test/Index/complete-pch.m | 26 + clang/test/Index/complete-preprocessor.m | 80 + clang/test/Index/complete-properties.m | 82 + clang/test/Index/complete-property-flags.m | 26 + clang/test/Index/complete-property-getset.m | 41 + clang/test/Index/complete-protocols.m | 27 + clang/test/Index/complete-qualified.cpp | 20 + clang/test/Index/complete-recovery.m | 38 + clang/test/Index/complete-stmt.c | 16 + clang/test/Index/complete-super.cpp | 42 + clang/test/Index/complete-super.m | 81 + clang/test/Index/complete-synthesized.m | 46 + clang/test/Index/complete-tabs.c | 9 + clang/test/Index/complete-templates.cpp | 19 + clang/test/Index/complete-type-factors.m | 137 + clang/test/Index/complete-unterminated.c | 30 + clang/test/Index/complete-with-annotations.cpp | 23 + clang/test/Index/crash-recovery-code-complete.c | 12 + clang/test/Index/crash-recovery-modules.m | 20 + clang/test/Index/crash-recovery-reparse.c | 12 + clang/test/Index/crash-recovery.c | 7 + clang/test/Index/cursor-ref-names.cpp | 47 + clang/test/Index/cxx-operator-overload.cpp | 28 + clang/test/Index/cxx11-lambdas.cpp | 33 + clang/test/Index/error-on-deserialized.c | 13 + clang/test/Index/file-macro-refs.c | 12 + clang/test/Index/file-refs-subscripting.m | 65 + clang/test/Index/file-refs.c | 57 + clang/test/Index/file-refs.cpp | 104 + clang/test/Index/file-refs.m | 91 + clang/test/Index/fix-its.c | 27 + clang/test/Index/get-cursor-includes.c | 7 + clang/test/Index/get-cursor-macro-args.h | 16 + clang/test/Index/get-cursor-macro-args.m | 19 + clang/test/Index/get-cursor.c | 14 + clang/test/Index/get-cursor.cpp | 95 + clang/test/Index/get-cursor.m | 104 + clang/test/Index/getcursor-pp-pch.c | 43 + clang/test/Index/getcursor-pp-pch.c.h | 5 + clang/test/Index/in-class-init.cpp | 6 + clang/test/Index/include_test.h | 1 + clang/test/Index/include_test_2.h | 0 clang/test/Index/index-attrs.m | 17 + clang/test/Index/index-decls.m | 30 + clang/test/Index/index-invalid-code.m | 8 + clang/test/Index/index-many-logical-ops.c | 2011 +++++++++++++ clang/test/Index/index-refs.cpp | 121 + clang/test/Index/index-subscripting-literals.m | 66 + clang/test/Index/index-suppress-refs.cpp | 12 + clang/test/Index/index-suppress-refs.h | 9 + clang/test/Index/index-suppress-refs.hpp | 3 + clang/test/Index/index-suppress-refs.m | 44 + clang/test/Index/index-templates.cpp | 207 ++ clang/test/Index/initializer-memory.cpp | 16 + clang/test/Index/invalid-code-rdar10451854.m | 15 + clang/test/Index/invalid-code-rdar_7833619.m | 4 + clang/test/Index/invalid-rdar-8236270.cpp | 11 + clang/test/Index/linkage.c | 30 + clang/test/Index/load-classes.cpp | 28 + clang/test/Index/load-decls.c | 15 + clang/test/Index/load-exprs.c | 81 + clang/test/Index/load-namespaces.cpp | 50 + clang/test/Index/load-stmts.cpp | 231 ++ clang/test/Index/local-symbols.m | 44 + clang/test/Index/ms-if-exists.cpp | 24 + clang/test/Index/nested-binaryoperators.cpp | 1983 +++++++++++++ clang/test/Index/overrides.cpp | 20 + clang/test/Index/overrides.m | 61 + clang/test/Index/pch-opaque-value.cpp | 16 + clang/test/Index/pch-with-errors.c | 42 + clang/test/Index/pch-with-errors.m | 28 + clang/test/Index/pragma-diag-reparse.c | 20 + clang/test/Index/preamble-reparse-chained.c | 10 + clang/test/Index/preamble-reparse-cmd-define.c | 9 + clang/test/Index/preamble-reparse-cmd-define.c.h | 1 + .../test/Index/preamble-reparse-cmd-define.c.remap | 8 + clang/test/Index/preamble-reparse-import.m | 12 + clang/test/Index/preamble-reparse-import.m-1.h | 5 + clang/test/Index/preamble-reparse-import.m-2.h | 5 + clang/test/Index/preamble-reparse-import.m-3.h | 1 + clang/test/Index/preamble-reparse.c | 2 + clang/test/Index/preamble.c | 24 + clang/test/Index/preamble_macro_template.cpp | 15 + clang/test/Index/print-display-names.cpp | 20 + clang/test/Index/print-typekind.c | 28 + clang/test/Index/print-typekind.m | 10 + clang/test/Index/print-usrs.c | 17 + clang/test/Index/properties-class-extensions.m | 99 + clang/test/Index/rdar-8288645-invalid-code.mm | 7 + clang/test/Index/recover-bad-code-rdar_7487294.c | 13 + clang/test/Index/recursive-cxx-member-calls.cpp | 2243 ++++++++++++++ clang/test/Index/recursive-member-access.c | 532 ++++ clang/test/Index/redeclarations.cpp | 21 + clang/test/Index/remap-complete.c | 4 + clang/test/Index/remap-cursor-at.c | 4 + clang/test/Index/remap-load.c | 10 + clang/test/Index/reparse-instantiate.cpp | 7 + clang/test/Index/retain-target-options.c | 8 + clang/test/Index/targeted-annotation.c | 99 + clang/test/Index/targeted-cursor.c | 65 + clang/test/Index/targeted-cursor.m | 6 + clang/test/Index/targeted-cursor.m.h | 7 + clang/test/Index/targeted-fields.h | 3 + clang/test/Index/targeted-file-refs.c | 59 + clang/test/Index/targeted-nested1.h | 2 + clang/test/Index/targeted-preamble.h | 2 + clang/test/Index/targeted-top.h | 24 + clang/test/Index/unmatched-braces.c | 9 + clang/test/Index/unmatched-braces.m | 11 + clang/test/Index/usrs-cxx0x.cpp | 8 + clang/test/Index/usrs.cpp | 146 + clang/test/Index/usrs.m | 284 ++ clang/test/Index/vector-types.c | 6 + clang/test/Index/warning-flags.c | 16 + clang/test/Index/werror.c | 12 + clang/test/Lexer/11-27-2007-FloatLiterals.c | 13 + clang/test/Lexer/badstring_in_if0.c | 8 + clang/test/Lexer/bcpl-escaped-newline.c | 12 + clang/test/Lexer/block_cmt_end.c | 34 + clang/test/Lexer/c90.c | 34 + clang/test/Lexer/char-escapes.c | 22 + clang/test/Lexer/char-literal-encoding-error.c | 15 + clang/test/Lexer/char-literal.cpp | 24 + clang/test/Lexer/clang-keywords.cpp | 3 + clang/test/Lexer/comment-escape.c | 6 + clang/test/Lexer/conflict-marker.c | 38 + clang/test/Lexer/constants.c | 69 + clang/test/Lexer/counter.c | 16 + clang/test/Lexer/cxx0x_keyword.cpp | 2 + clang/test/Lexer/cxx0x_keyword_as_cxx98.cpp | 36 + clang/test/Lexer/cxx0x_raw_string_delim_length.cpp | 7 + clang/test/Lexer/cxx0x_raw_string_unterminated.cpp | 4 + clang/test/Lexer/digraph.c | 15 + clang/test/Lexer/dollar-idents.c | 7 + clang/test/Lexer/escape_newline.c | 11 + clang/test/Lexer/gnu_keywords.c | 12 + clang/test/Lexer/has_extension.c | 44 + clang/test/Lexer/has_extension_cxx.cpp | 49 + clang/test/Lexer/has_feature_address_sanitizer.cpp | 11 + clang/test/Lexer/has_feature_c1x.c | 47 + clang/test/Lexer/has_feature_cxx0x.cpp | 274 ++ clang/test/Lexer/has_feature_exceptions.cpp | 11 + clang/test/Lexer/has_feature_modules.m | 25 + clang/test/Lexer/has_feature_objc_arc.m | 20 + clang/test/Lexer/has_feature_rtti.cpp | 11 + clang/test/Lexer/has_feature_type_traits.cpp | 111 + clang/test/Lexer/hexfloat.cpp | 7 + clang/test/Lexer/ms-extensions.c | 43 + clang/test/Lexer/ms-extensions.cpp | 6 + clang/test/Lexer/msdos-cpm-eof.c | 7 + clang/test/Lexer/multiple-include.c | 27 + clang/test/Lexer/newline-eof-c++11.cpp | 4 + clang/test/Lexer/newline-eof-c++98-compat.cpp | 4 + clang/test/Lexer/newline-eof.c | 5 + clang/test/Lexer/numeric-literal-trash.c | 13 + clang/test/Lexer/pragma-mark.c | 11 + clang/test/Lexer/pragma-message.c | 14 + clang/test/Lexer/pragma-operators.cpp | 20 + clang/test/Lexer/preamble.c | 36 + clang/test/Lexer/rdar-8914293.c | 7 + clang/test/Lexer/rdr-6096838-2.c | 5 + clang/test/Lexer/rdr-6096838.c | 6 + clang/test/Lexer/string-literal-encoding.c | 33 + clang/test/Lexer/string_concat.cpp | 33 + clang/test/Lexer/token-concat-2.c | 4 + clang/test/Lexer/token-concat.c | 4 + clang/test/Lexer/token-concat.cpp | 19 + clang/test/Lexer/unknown-char.c | 2 + clang/test/Lexer/utf-16.c | 6 + clang/test/Lexer/utf-16.c.txt | Bin 0 -> 48 bytes clang/test/Lexer/utf8-char-literal.cpp | 5 + clang/test/Lexer/wchar.c | 12 + clang/test/Makefile | 71 + clang/test/Misc/Inputs/include.h | 3 + clang/test/Misc/Inputs/remapped-file | 1 + clang/test/Misc/Inputs/remapped-file-2 | 3 + clang/test/Misc/Inputs/remapped-file-3 | 2 + clang/test/Misc/Inputs/working-directory.h | 1 + clang/test/Misc/ast-dump-templates.cpp | 39 + clang/test/Misc/caret-diags-macros.c | 120 + clang/test/Misc/caret-diags-scratch-buffer.c | 12 + clang/test/Misc/diag-aka-types.cpp | 68 + clang/test/Misc/diag-format.c | 34 + clang/test/Misc/diag-line-wrapping.cpp | 13 + clang/test/Misc/diag-macro-backtrace.c | 53 + clang/test/Misc/diag-mapping.c | 30 + clang/test/Misc/diag-mapping2.c | 22 + clang/test/Misc/diag-verify.cpp | 48 + clang/test/Misc/emit-html-insert.c | 4 + clang/test/Misc/emit-html.c | 18 + clang/test/Misc/error-limit-multiple-notes.cpp | 23 + clang/test/Misc/error-limit.c | 15 + clang/test/Misc/include-stack-for-note-flag.cpp | 28 + clang/test/Misc/integer-literal-printing.cpp | 13 + clang/test/Misc/macro-backtrace.c | 57 + clang/test/Misc/message-length.c | 41 + clang/test/Misc/predefines.c | 5 + clang/test/Misc/remap-file.c | 8 + clang/test/Misc/serialized-diags-no-category.c | 12 + clang/test/Misc/serialized-diags-no-issue.c | 10 + clang/test/Misc/serialized-diags-single-issue.c | 36 + clang/test/Misc/serialized-diags.c | 67 + clang/test/Misc/serialized-diags.h | 5 + clang/test/Misc/show-diag-options.c | 27 + clang/test/Misc/tabstop.c | 47 + clang/test/Misc/unprintable.c | 16 + clang/test/Misc/verify.c | 14 + clang/test/Misc/warn-in-system-header.c | 4 + clang/test/Misc/warn-in-system-header.h | 4 + clang/test/Misc/warning-flags.c | 273 ++ clang/test/Misc/wnull-character.cpp | Bin 0 -> 143 bytes clang/test/Misc/working-directory.c | 5 + clang/test/Misc/wrong-encoding.c | 16 + .../Headers/AlsoDependsOnModule.h | 2 + .../Inputs/CmdLine.framework/Headers/CmdLine.h | 6 + .../SubFramework.framework/Headers/Other.h | 1 + .../SubFramework.framework/Headers/SubFramework.h | 2 + .../Headers/DependsOnModule.h | 5 + .../DependsOnModule.framework/Headers/cxx_other.h | 5 + .../DependsOnModule.framework/Headers/other.h | 1 + .../PrivateHeaders/DependsOnModulePrivate.h | 2 + .../Inputs/DependsOnModule.framework/module.map | 19 + .../DependsOnModule.framework/module_private.map | 6 + clang/test/Modules/Inputs/MethodPoolA.h | 8 + clang/test/Modules/Inputs/MethodPoolB.h | 13 + .../SubFramework.framework/Headers/SubFramework.h | 5 + .../Module.framework/Headers/Buried/Treasure.h | 1 + .../Inputs/Module.framework/Headers/Module.h | 22 + .../Inputs/Module.framework/Headers/NotInModule.h | 1 + .../Modules/Inputs/Module.framework/Headers/Sub.h | 3 + .../Modules/Inputs/Module.framework/Headers/Sub2.h | 1 + .../PrivateHeaders/ModulePrivate.h | 1 + .../Headers/MutuallyRecursive1.h | 3 + .../Headers/MutuallyRecursive2.h | 6 + .../Inputs/NoUmbrella.framework/Headers/A.h | 8 + .../Inputs/NoUmbrella.framework/Headers/B.h | 1 + .../Inputs/NoUmbrella.framework/Headers/Boom.h | 1 + .../Inputs/NoUmbrella.framework/Headers/SubDir/C.h | 1 + .../PrivateHeaders/A_Private.h | 1 + .../PrivateHeaders/B_Private.h | 1 + .../Modules/Inputs/NoUmbrella.framework/module.map | 9 + .../Inputs/NoUmbrella.framework/module_private.map | 4 + .../Modules/Inputs/System/usr/include/module.map | 21 + .../Modules/Inputs/System/usr/include/stdbool.h | 1 + .../Modules/Inputs/System/usr/include/stdint.h | 1 + .../test/Modules/Inputs/System/usr/include/stdio.h | 3 + clang/test/Modules/Inputs/category_bottom.h | 11 + clang/test/Modules/Inputs/category_left.h | 15 + clang/test/Modules/Inputs/category_other.h | 6 + clang/test/Modules/Inputs/category_right.h | 12 + clang/test/Modules/Inputs/category_top.h | 14 + clang/test/Modules/Inputs/decl.h | 2 + clang/test/Modules/Inputs/decl2.h | 1 + clang/test/Modules/Inputs/def-include.h | 13 + clang/test/Modules/Inputs/def.h | 11 + clang/test/Modules/Inputs/diamond.h | 1 + clang/test/Modules/Inputs/diamond_bottom.h | 4 + clang/test/Modules/Inputs/diamond_left.h | 9 + clang/test/Modules/Inputs/diamond_right.h | 7 + clang/test/Modules/Inputs/diamond_top.h | 4 + clang/test/Modules/Inputs/irgen.h | 1 + clang/test/Modules/Inputs/load_failure.h | 1 + clang/test/Modules/Inputs/lookup_left.h | 3 + clang/test/Modules/Inputs/lookup_left.hpp | 5 + clang/test/Modules/Inputs/lookup_right.h | 5 + clang/test/Modules/Inputs/lookup_right.hpp | 1 + clang/test/Modules/Inputs/macros.h | 10 + clang/test/Modules/Inputs/module.map | 86 + clang/test/Modules/Inputs/module_private_left.h | 26 + clang/test/Modules/Inputs/module_private_right.h | 13 + clang/test/Modules/Inputs/namespaces-left.h | 53 + clang/test/Modules/Inputs/namespaces-right.h | 61 + clang/test/Modules/Inputs/namespaces-top.h | 14 + .../Inputs/normal-module-map/Umbrella/Umbrella.h | 4 + .../Inputs/normal-module-map/Umbrella/module.map | 3 + .../normal-module-map/Umbrella/umbrella_sub.h | 2 + .../Inputs/normal-module-map/Umbrella2/Umbrella2.h | 1 + .../Inputs/normal-module-map/Umbrella2/module.map | 3 + clang/test/Modules/Inputs/normal-module-map/a1.h | 1 + clang/test/Modules/Inputs/normal-module-map/a2.h | 1 + clang/test/Modules/Inputs/normal-module-map/b1.h | 2 + .../Modules/Inputs/normal-module-map/module.map | 13 + .../Inputs/normal-module-map/nested/module.map | 4 + .../Inputs/normal-module-map/nested/nested1.h | 1 + .../Inputs/normal-module-map/nested/nested2.h | 1 + .../Inputs/normal-module-map/nested_umbrella/a.h | 2 + .../Inputs/normal-module-map/nested_umbrella/b.h | 2 + clang/test/Modules/Inputs/point.h | 2 + clang/test/Modules/Inputs/redecl-merge-bottom.h | 28 + clang/test/Modules/Inputs/redecl-merge-left-left.h | 7 + clang/test/Modules/Inputs/redecl-merge-left.h | 90 + clang/test/Modules/Inputs/redecl-merge-right.h | 94 + .../Modules/Inputs/redecl-merge-top-explicit.h | 9 + clang/test/Modules/Inputs/redecl-merge-top.h | 20 + clang/test/Modules/Inputs/redecl_namespaces_left.h | 3 + .../test/Modules/Inputs/redecl_namespaces_right.h | 3 + clang/test/Modules/Inputs/redeclarations_left.h | 2 + clang/test/Modules/Inputs/redeclarations_right.h | 2 + clang/test/Modules/Inputs/subdir/module.map | 3 + clang/test/Modules/Inputs/subdir/subdir.h | 1 + clang/test/Modules/Inputs/submodules/hash_map.h | 4 + clang/test/Modules/Inputs/submodules/module.map | 5 + clang/test/Modules/Inputs/submodules/type_traits.h | 12 + clang/test/Modules/Inputs/submodules/vector.h | 3 + .../Inputs/wildcard-submodule-exports/A_one.h | 1 + .../Inputs/wildcard-submodule-exports/A_two.h | 1 + .../Inputs/wildcard-submodule-exports/B_one.h | 1 + .../Inputs/wildcard-submodule-exports/B_two.h | 1 + .../Inputs/wildcard-submodule-exports/C_one.h | 4 + .../Inputs/wildcard-submodule-exports/C_two.h | 4 + .../Inputs/wildcard-submodule-exports/module.map | 20 + clang/test/Modules/auto-module-import.m | 73 + clang/test/Modules/compiler_builtins.m | 10 + clang/test/Modules/cstd.m | 29 + clang/test/Modules/cycles.c | 12 + clang/test/Modules/decldef.mm | 28 + clang/test/Modules/diamond-pch.c | 28 + clang/test/Modules/diamond.c | 29 + clang/test/Modules/driver.c | 6 + clang/test/Modules/header-import.m | 7 + clang/test/Modules/inferred-submodules.m | 15 + clang/test/Modules/irgen.c | 13 + clang/test/Modules/load_failure.c | 21 + clang/test/Modules/lookup.cpp | 34 + clang/test/Modules/lookup.m | 20 + clang/test/Modules/macros.c | 30 + clang/test/Modules/method_pool.m | 30 + clang/test/Modules/module-private.cpp | 96 + clang/test/Modules/namespaces.cpp | 64 + clang/test/Modules/normal-module-map.cpp | 35 + clang/test/Modules/objc-categories.m | 40 + clang/test/Modules/on-demand-build-warnings.m | 5 + clang/test/Modules/on-demand-build.m | 27 + clang/test/Modules/on-demand-macros.m | 13 + clang/test/Modules/redecl-merge.m | 158 + clang/test/Modules/redecl-namespaces.mm | 13 + clang/test/Modules/redeclarations.m | 11 + clang/test/Modules/requires.m | 5 + clang/test/Modules/subframeworks.m | 22 + clang/test/Modules/submodules-preprocess.cpp | 61 + clang/test/Modules/submodules.cpp | 29 + clang/test/Modules/submodules.m | 11 + clang/test/Modules/wildcard-submodule-exports.cpp | 26 + clang/test/PCH/Inputs/arc.h | 26 + clang/test/PCH/Inputs/chain-decls1.h | 11 + clang/test/PCH/Inputs/chain-decls2.h | 12 + clang/test/PCH/Inputs/chain-ext_vector1.h | 3 + clang/test/PCH/Inputs/chain-ext_vector2.h | 3 + clang/test/PCH/Inputs/chain-external-defs1.h | 13 + clang/test/PCH/Inputs/chain-external-defs2.h | 11 + clang/test/PCH/Inputs/chain-macro-override1.h | 5 + clang/test/PCH/Inputs/chain-macro-override2.h | 5 + clang/test/PCH/Inputs/chain-macro1.h | 1 + clang/test/PCH/Inputs/chain-macro2.h | 1 + clang/test/PCH/Inputs/chain-remap-types1.h | 10 + clang/test/PCH/Inputs/chain-remap-types2.h | 8 + clang/test/PCH/Inputs/chain-selectors1.h | 16 + clang/test/PCH/Inputs/chain-selectors2.h | 15 + clang/test/PCH/Inputs/chain-trivial1.h | 0 clang/test/PCH/Inputs/chain-trivial2.h | 0 clang/test/PCH/Inputs/cxx-method.h | 6 + clang/test/PCH/Inputs/namespaces.h | 44 + clang/test/PCH/Inputs/preamble.h | 1 + clang/test/PCH/Inputs/typo.h | 6 + clang/test/PCH/Inputs/typo.hpp | 8 + clang/test/PCH/Inputs/va_arg.h | 2 + clang/test/PCH/Inputs/working-directory-1.h | 5 + clang/test/PCH/arc.m | 17 + clang/test/PCH/asm.c | 11 + clang/test/PCH/asm.h | 14 + clang/test/PCH/attrs-PR8406.c | 23 + clang/test/PCH/attrs.c | 17 + clang/test/PCH/blocks.c | 12 + clang/test/PCH/blocks.h | 14 + clang/test/PCH/builtins.c | 10 + clang/test/PCH/builtins.h | 2 + clang/test/PCH/chain-categories.m | 51 + clang/test/PCH/chain-categories2.m | 57 + clang/test/PCH/chain-class-extension.m | 42 + clang/test/PCH/chain-conversion-lookup.cpp | 26 + clang/test/PCH/chain-cxx.cpp | 142 + clang/test/PCH/chain-decls.c | 27 + clang/test/PCH/chain-empty-initial-namespace.cpp | 24 + clang/test/PCH/chain-ext_vector.c | 11 + clang/test/PCH/chain-external-defs.c | 54 + clang/test/PCH/chain-friend-instantiation.cpp | 61 + clang/test/PCH/chain-implicit-definition.cpp | 39 + clang/test/PCH/chain-late-anonymous-namespace.cpp | 61 + clang/test/PCH/chain-macro-override.c | 14 + clang/test/PCH/chain-macro.c | 9 + clang/test/PCH/chain-pending-instantiations.cpp | 33 + clang/test/PCH/chain-predecl.h | 3 + clang/test/PCH/chain-predecl.m | 16 + clang/test/PCH/chain-remap-types.m | 12 + clang/test/PCH/chain-selectors.m | 40 + clang/test/PCH/chain-trivial.c | 4 + clang/test/PCH/changed-files.c | 28 + clang/test/PCH/check-deserializations.cpp | 20 + clang/test/PCH/cmdline-include.c | 6 + clang/test/PCH/cmdline-include1.h | 1 + clang/test/PCH/cmdline-include2.h | 1 + clang/test/PCH/cocoa.m | 7 + clang/test/PCH/cuda-kernel-call.cu | 25 + clang/test/PCH/cxx-alias-decl.cpp | 20 + clang/test/PCH/cxx-alias-decl.h | 11 + clang/test/PCH/cxx-chain-function-template.cpp | 32 + clang/test/PCH/cxx-constexpr.cpp | 19 + clang/test/PCH/cxx-exprs.cpp | 27 + clang/test/PCH/cxx-for-range.cpp | 19 + clang/test/PCH/cxx-for-range.h | 35 + clang/test/PCH/cxx-friends.cpp | 13 + clang/test/PCH/cxx-friends.h | 6 + clang/test/PCH/cxx-functions.cpp | 10 + clang/test/PCH/cxx-functions.h | 1 + clang/test/PCH/cxx-implicit-moves.cpp | 23 + clang/test/PCH/cxx-member-init.cpp | 22 + clang/test/PCH/cxx-method.cpp | 8 + .../cxx-ms-function-specialization-class-scope.cpp | 13 + .../cxx-ms-function-specialization-class-scope.h | 29 + clang/test/PCH/cxx-namespaces.cpp | 10 + clang/test/PCH/cxx-namespaces.h | 7 + clang/test/PCH/cxx-offsetof-base.cpp | 2 + clang/test/PCH/cxx-offsetof-base.h | 5 + clang/test/PCH/cxx-reference.cpp | 6 + clang/test/PCH/cxx-reference.h | 13 + clang/test/PCH/cxx-required-decls.cpp | 10 + clang/test/PCH/cxx-required-decls.h | 12 + clang/test/PCH/cxx-static_assert.cpp | 20 + clang/test/PCH/cxx-templates.cpp | 70 + clang/test/PCH/cxx-templates.h | 217 ++ clang/test/PCH/cxx-trailing-return.cpp | 15 + clang/test/PCH/cxx-traits.cpp | 11 + clang/test/PCH/cxx-traits.h | 16 + clang/test/PCH/cxx-typeid.cpp | 9 + clang/test/PCH/cxx-typeid.h | 3 + clang/test/PCH/cxx-using.cpp | 15 + clang/test/PCH/cxx-using.h | 16 + clang/test/PCH/cxx-variadic-templates.cpp | 11 + clang/test/PCH/cxx-variadic-templates.h | 18 + clang/test/PCH/cxx0x-default-delete.cpp | 34 + clang/test/PCH/cxx0x-delegating-ctors.cpp | 20 + clang/test/PCH/cxx11-constexpr.cpp | 29 + clang/test/PCH/cxx11-enum-template.cpp | 26 + clang/test/PCH/cxx11-exception-spec.cpp | 17 + clang/test/PCH/cxx11-lambdas.mm | 48 + clang/test/PCH/cxx11-user-defined-literals.cpp | 21 + clang/test/PCH/cxx_exprs.cpp | 39 + clang/test/PCH/cxx_exprs.h | 83 + clang/test/PCH/designated-init.c | 7 + clang/test/PCH/designated-init.c.h | 42 + clang/test/PCH/enum.c | 15 + clang/test/PCH/enum.h | 16 + clang/test/PCH/exprs.c | 98 + clang/test/PCH/exprs.h | 107 + clang/test/PCH/ext_vector.c | 10 + clang/test/PCH/ext_vector.h | 4 + clang/test/PCH/external-defs.c | 19 + clang/test/PCH/external-defs.h | 13 + clang/test/PCH/functions.c | 25 + clang/test/PCH/functions.h | 11 + clang/test/PCH/fuzzy-pch.c | 19 + clang/test/PCH/fuzzy-pch.h | 2 + clang/test/PCH/headermap.h | 3 + clang/test/PCH/headermap.m | 15 + clang/test/PCH/headersearch.cpp | 44 + clang/test/PCH/libroot/usr/include/reloc.h | 15 + clang/test/PCH/libroot/usr/include/reloc2.h | 15 + clang/test/PCH/line-directive.c | 25 + clang/test/PCH/line-directive.h | 2 + clang/test/PCH/method-redecls.m | 18 + clang/test/PCH/method_pool.h | 36 + clang/test/PCH/method_pool.m | 21 + clang/test/PCH/missing-file.cpp | 31 + clang/test/PCH/modified-header-crash.c | 10 + clang/test/PCH/modified-header-crash.h | 1 + clang/test/PCH/modified-header-error.c | 12 + clang/test/PCH/ms-if-exists.cpp | 29 + clang/test/PCH/multiple_decls.c | 17 + clang/test/PCH/multiple_decls.h | 7 + clang/test/PCH/namespaces.cpp | 45 + clang/test/PCH/nonvisible-external-defs.c | 10 + clang/test/PCH/nonvisible-external-defs.h | 11 + clang/test/PCH/objc_container.h | 26 + clang/test/PCH/objc_container.m | 20 + clang/test/PCH/objc_exprs.h | 26 + clang/test/PCH/objc_exprs.m | 27 + clang/test/PCH/objc_import.h | 7 + clang/test/PCH/objc_import.m | 15 + clang/test/PCH/objc_literals.m | 66 + clang/test/PCH/objc_literals.mm | 65 + clang/test/PCH/objc_methods.h | 11 + clang/test/PCH/objc_methods.m | 16 + clang/test/PCH/objc_property.h | 12 + clang/test/PCH/objc_property.m | 11 + clang/test/PCH/objc_stmts.h | 22 + clang/test/PCH/objc_stmts.m | 12 + clang/test/PCH/objcxx-ivar-class.h | 16 + clang/test/PCH/objcxx-ivar-class.mm | 15 + clang/test/PCH/opencl-extensions.cl | 17 + clang/test/PCH/pchpch.c | 6 + clang/test/PCH/pchpch1.h | 0 clang/test/PCH/pchpch2.h | 0 clang/test/PCH/pending-ids.m | 33 + clang/test/PCH/pr4489.c | 48 + clang/test/PCH/pragma-diag-section.cpp | 29 + clang/test/PCH/pragma-diag.c | 20 + clang/test/PCH/pragma-weak.c | 10 + clang/test/PCH/pragma-weak.h | 10 + clang/test/PCH/preamble.c | 23 + clang/test/PCH/preprocess.c | 8 + clang/test/PCH/preprocess.h | 7 + clang/test/PCH/pth.c | 7 + clang/test/PCH/pth.h | 12 + clang/test/PCH/rdar10830559.cpp | 35 + clang/test/PCH/rdar8852495.c | 26 + clang/test/PCH/reinclude.cpp | 10 + clang/test/PCH/reinclude1.h | 7 + clang/test/PCH/reinclude2.h | 1 + clang/test/PCH/reloc.c | 14 + clang/test/PCH/replaced-decl.m | 22 + clang/test/PCH/selector-warning.h | 24 + clang/test/PCH/selector-warning.m | 19 + clang/test/PCH/single-token-macro.c | 24 + clang/test/PCH/source-manager-stack.c | 12 + clang/test/PCH/stmts.c | 14 + clang/test/PCH/stmts.h | 96 + clang/test/PCH/struct.c | 28 + clang/test/PCH/struct.h | 29 + clang/test/PCH/subscripting-literals.m | 47 + clang/test/PCH/tentative-defs.c | 9 + clang/test/PCH/tentative-defs.h | 9 + clang/test/PCH/types.c | 73 + clang/test/PCH/types.h | 50 + clang/test/PCH/typo.cpp | 17 + clang/test/PCH/typo.m | 6 + clang/test/PCH/typo2.cpp | 13 + clang/test/PCH/va_arg.c | 12 + clang/test/PCH/va_arg.cpp | 16 + clang/test/PCH/va_arg.h | 8 + clang/test/PCH/variables.c | 47 + clang/test/PCH/variables.h | 25 + clang/test/PCH/working-directory.cpp | 12 + clang/test/PCH/working-directory.h | 1 + clang/test/Parser/CompoundStmtScope.c | 8 + clang/test/Parser/DelayedTemplateParsing.cpp | 92 + clang/test/Parser/MicrosoftExtensions.c | 77 + clang/test/Parser/MicrosoftExtensions.cpp | 311 ++ clang/test/Parser/PR11000.cpp | 9 + clang/test/Parser/access-spec-attrs.cpp | 12 + clang/test/Parser/altivec.c | 121 + clang/test/Parser/argument_qualified.c | 5 + clang/test/Parser/argument_redef.c | 6 + clang/test/Parser/argument_scope.c | 6 + clang/test/Parser/asm-constraints-pr7869.c | 45 + clang/test/Parser/asm.c | 19 + clang/test/Parser/asm.cpp | 8 + clang/test/Parser/attr-availability.c | 28 + clang/test/Parser/attributes.c | 98 + clang/test/Parser/backtrack-crash.cpp | 4 + clang/test/Parser/bad-control.c | 9 + clang/test/Parser/block-block-storageclass.c | 17 + clang/test/Parser/block-pointer-decl.c | 28 + clang/test/Parser/bracket-crash.cpp | 6 + clang/test/Parser/builtin_classify_type.c | 21 + clang/test/Parser/builtin_types_compatible.c | 43 + clang/test/Parser/c-namespace.c | 6 + clang/test/Parser/c1x-alignas.c | 7 + clang/test/Parser/c1x-generic-selection.c | 10 + clang/test/Parser/char-literal-printing.c | 67 + clang/test/Parser/check-objc2-syntax-1.m | 10 + clang/test/Parser/check-syntax-1.m | 19 + clang/test/Parser/check_cast.c | 12 + clang/test/Parser/compound_literal.c | 5 + clang/test/Parser/control-scope.c | 8 + clang/test/Parser/cuda-kernel-call.cu | 9 + clang/test/Parser/cxx-altivec.cpp | 170 ++ clang/test/Parser/cxx-ambig-decl-expr-xfail.cpp | 16 + clang/test/Parser/cxx-ambig-decl-expr.cpp | 10 + clang/test/Parser/cxx-ambig-paren-expr.cpp | 66 + clang/test/Parser/cxx-attributes.cpp | 9 + clang/test/Parser/cxx-bool.cpp | 4 + clang/test/Parser/cxx-casting.cpp | 92 + clang/test/Parser/cxx-class.cpp | 89 + clang/test/Parser/cxx-condition.cpp | 15 + clang/test/Parser/cxx-decl.cpp | 129 + clang/test/Parser/cxx-default-args.cpp | 16 + clang/test/Parser/cxx-default-delete.cpp | 23 + clang/test/Parser/cxx-ext-delete-default.cpp | 11 + clang/test/Parser/cxx-extern-c-array.cpp | 7 + clang/test/Parser/cxx-friend.cpp | 40 + clang/test/Parser/cxx-in-c.c | 5 + clang/test/Parser/cxx-member-crash.cpp | 15 + .../Parser/cxx-member-init-missing-paren-crash.cpp | 12 + clang/test/Parser/cxx-member-initializers.cpp | 15 + clang/test/Parser/cxx-namespace-alias.cpp | 9 + clang/test/Parser/cxx-reference.cpp | 21 + clang/test/Parser/cxx-stmt.cpp | 60 + clang/test/Parser/cxx-template-argument.cpp | 12 + clang/test/Parser/cxx-template-decl.cpp | 115 + clang/test/Parser/cxx-throw.cpp | 15 + clang/test/Parser/cxx-typeid.cpp | 13 + clang/test/Parser/cxx-typeof.cpp | 13 + clang/test/Parser/cxx-undeclared-identifier.cpp | 9 + clang/test/Parser/cxx-using-declaration.cpp | 45 + clang/test/Parser/cxx-using-directive.cpp | 38 + clang/test/Parser/cxx-variadic-func.cpp | 5 + clang/test/Parser/cxx0x-ambig.cpp | 127 + clang/test/Parser/cxx0x-attributes.cpp | 83 + clang/test/Parser/cxx0x-condition.cpp | 37 + clang/test/Parser/cxx0x-decl.cpp | 18 + clang/test/Parser/cxx0x-for-range.cpp | 30 + clang/test/Parser/cxx0x-in-cxx98.cpp | 23 + clang/test/Parser/cxx0x-lambda-expressions.cpp | 43 + clang/test/Parser/cxx0x-literal-operators.cpp | 8 + clang/test/Parser/cxx0x-member-initializers.cpp | 29 + .../Parser/cxx0x-override-control-keywords.cpp | 25 + clang/test/Parser/cxx0x-rvalue-reference.cpp | 9 + clang/test/Parser/cxx11-stmt-attributes.cpp | 54 + clang/test/Parser/cxx11-type-specifier.cpp | 20 + clang/test/Parser/cxx11-user-defined-literals.cpp | 112 + clang/test/Parser/declarators.c | 102 + clang/test/Parser/designator.c | 17 + clang/test/Parser/encode.m | 8 + clang/test/Parser/enhanced-proto-1.m | 17 + clang/test/Parser/expressions.c | 59 + clang/test/Parser/expressions.m | 6 + clang/test/Parser/extension.c | 20 + clang/test/Parser/for.cpp | 20 + clang/test/Parser/function-decls.c | 10 + clang/test/Parser/goto.c | 30 + clang/test/Parser/if-scope-c90.c | 8 + clang/test/Parser/if-scope-c99.c | 8 + clang/test/Parser/implicit-casts.c | 21 + clang/test/Parser/knr_parameter_attributes.c | 11 + clang/test/Parser/method-def-in-class.m | 14 + clang/test/Parser/method-prototype-1.m | 43 + clang/test/Parser/missing-end-2.m | 19 + clang/test/Parser/missing-end-3.m | 10 + clang/test/Parser/missing-end-4.m | 51 + clang/test/Parser/missing-end.m | 7 + clang/test/Parser/ms-inline-asm.c | 25 + clang/test/Parser/namelookup-bug-1.c | 7 + clang/test/Parser/namelookup-bug-2.c | 14 + clang/test/Parser/namespace-alias-attr.cpp | 8 + clang/test/Parser/namespaces.cpp | 8 + clang/test/Parser/nested-namespaces-recovery.cpp | 24 + clang/test/Parser/objc-alias-printing.m | 18 + clang/test/Parser/objc-category-neg-1.m | 8 + clang/test/Parser/objc-forcollection-1.m | 43 + clang/test/Parser/objc-forcollection-neg-2.m | 38 + clang/test/Parser/objc-forcollection-neg.m | 38 + clang/test/Parser/objc-foreach-syntax.m | 25 + clang/test/Parser/objc-init.m | 60 + clang/test/Parser/objc-interfaces.m | 8 + clang/test/Parser/objc-messaging-1.m | 26 + clang/test/Parser/objc-messaging-neg-1.m | 13 + clang/test/Parser/objc-missing-impl.m | 2 + clang/test/Parser/objc-property-syntax.m | 17 + clang/test/Parser/objc-quirks.m | 32 + clang/test/Parser/objc-synthesized-recover.m | 15 + clang/test/Parser/objc-try-catch-1.m | 70 + clang/test/Parser/objc-type-printing.m | 19 + clang/test/Parser/objcxx-at.mm | 15 + clang/test/Parser/objcxx-lambda-expressions-neg.mm | 5 + clang/test/Parser/objcxx0x-lambda-expressions.mm | 23 + clang/test/Parser/objcxx11-attributes.mm | 57 + clang/test/Parser/objcxx11-user-defined-literal.mm | 3 + clang/test/Parser/offsetof.c | 7 + clang/test/Parser/opencl-astype.cl | 20 + clang/test/Parser/opencl-image-access.cl | 16 + clang/test/Parser/opencl-kernel.cl | 9 + clang/test/Parser/opencl-pragma.cl | 15 + clang/test/Parser/opencl-storage-class.cl | 15 + clang/test/Parser/parenthesis-balance.cpp | 15 + clang/test/Parser/parmvardecl_conversion.c | 4 + clang/test/Parser/parser_overflow.c | 7 + clang/test/Parser/placeholder-recovery.m | 12 + clang/test/Parser/pointer-arithmetic.c | 9 + clang/test/Parser/pointer_promotion.c | 17 + clang/test/Parser/pragma-options.c | 22 + clang/test/Parser/pragma-pack.c | 32 + clang/test/Parser/pragma-visibility.c | 9 + clang/test/Parser/pragma-visibility2.c | 19 + clang/test/Parser/pragma-weak.c | 17 + clang/test/Parser/prefix-attributes.m | 8 + clang/test/Parser/promote_types_in_proto.c | 9 + clang/test/Parser/recovery.c | 100 + clang/test/Parser/recovery.cpp | 42 + clang/test/Parser/recovery.m | 5 + clang/test/Parser/recursion-limits.cpp | 259 ++ clang/test/Parser/selector-1.m | 20 + clang/test/Parser/skip-function-bodies.mm | 45 + clang/test/Parser/statements.c | 64 + clang/test/Parser/struct-recursion.c | 11 + clang/test/Parser/switch-recovery.cpp | 172 ++ clang/test/Parser/top-level-semi-cxx0x.cpp | 15 + clang/test/Parser/traditional_arg_scope.c | 7 + clang/test/Parser/typeof.c | 26 + clang/test/Parser/types.c | 14 + clang/test/Parser/warn-dangling-else.cpp | 55 + .../TestFramework.framework/.system_framework | 0 .../Headers/AnotherTestFramework.h | 3 + .../Headers/TestFramework.h | 6 + clang/test/Preprocessor/_Pragma-dependency.c | 7 + clang/test/Preprocessor/_Pragma-dependency2.c | 5 + clang/test/Preprocessor/_Pragma-in-macro-arg.c | 35 + clang/test/Preprocessor/_Pragma-location.c | 4 + clang/test/Preprocessor/_Pragma-physloc.c | 6 + clang/test/Preprocessor/_Pragma.c | 10 + clang/test/Preprocessor/assembler-with-cpp.c | 79 + clang/test/Preprocessor/builtin_line.c | 13 + clang/test/Preprocessor/c90.c | 10 + clang/test/Preprocessor/c99-6_10_3_3_p4.c | 10 + clang/test/Preprocessor/c99-6_10_3_4_p5.c | 28 + clang/test/Preprocessor/c99-6_10_3_4_p6.c | 27 + clang/test/Preprocessor/c99-6_10_3_4_p7.c | 10 + clang/test/Preprocessor/c99-6_10_3_4_p9.c | 20 + clang/test/Preprocessor/clang_headers.c | 3 + clang/test/Preprocessor/comment_save.c | 8 + clang/test/Preprocessor/comment_save_if.c | 11 + clang/test/Preprocessor/comment_save_macro.c | 13 + clang/test/Preprocessor/cxx_and.cpp | 17 + clang/test/Preprocessor/cxx_bitand.cpp | 16 + clang/test/Preprocessor/cxx_bitor.cpp | 18 + clang/test/Preprocessor/cxx_compl.cpp | 16 + clang/test/Preprocessor/cxx_not.cpp | 15 + clang/test/Preprocessor/cxx_not_eq.cpp | 16 + clang/test/Preprocessor/cxx_oper_keyword.cpp | 7 + .../Preprocessor/cxx_oper_keyword_ms_compat.cpp | 179 ++ clang/test/Preprocessor/cxx_oper_spelling.cpp | 11 + clang/test/Preprocessor/cxx_or.cpp | 17 + clang/test/Preprocessor/cxx_true.cpp | 13 + clang/test/Preprocessor/cxx_xor.cpp | 18 + clang/test/Preprocessor/dependencies-and-pp.c | 31 + clang/test/Preprocessor/directive-invalid.c | 7 + clang/test/Preprocessor/disabled-cond-diags.c | 10 + clang/test/Preprocessor/dump-macros-spacing.c | 13 + clang/test/Preprocessor/dump-macros-undef.c | 8 + clang/test/Preprocessor/dump-options.c | 3 + clang/test/Preprocessor/dump_macros.c | 38 + clang/test/Preprocessor/dumptokens_phyloc.c | 5 + clang/test/Preprocessor/expr_comma.c | 10 + clang/test/Preprocessor/expr_define_expansion.c | 5 + clang/test/Preprocessor/expr_invalid_tok.c | 15 + clang/test/Preprocessor/expr_liveness.c | 52 + clang/test/Preprocessor/expr_multichar.c | 5 + clang/test/Preprocessor/expr_usual_conversions.c | 14 + clang/test/Preprocessor/extension-warning.c | 18 + clang/test/Preprocessor/feature_tests.c | 34 + clang/test/Preprocessor/file_to_include.h | 3 + clang/test/Preprocessor/function_macro_file.c | 5 + clang/test/Preprocessor/function_macro_file.h | 3 + clang/test/Preprocessor/has_attribute.c | 26 + clang/test/Preprocessor/has_include.c | 83 + clang/test/Preprocessor/hash_line.c | 8 + clang/test/Preprocessor/hash_space.c | 6 + clang/test/Preprocessor/header_lookup1.c | 2 + clang/test/Preprocessor/if_warning.c | 31 + clang/test/Preprocessor/ifdef-recover.c | 15 + clang/test/Preprocessor/import_self.c | 7 + clang/test/Preprocessor/include-directive1.c | 14 + clang/test/Preprocessor/include-directive2.c | 17 + clang/test/Preprocessor/include-directive3.c | 3 + clang/test/Preprocessor/include-macros.c | 4 + clang/test/Preprocessor/include-pth.c | 3 + clang/test/Preprocessor/indent_macro.c | 6 + clang/test/Preprocessor/init.c | 1764 +++++++++++ clang/test/Preprocessor/line-directive-output.c | 71 + clang/test/Preprocessor/line-directive.c | 92 + clang/test/Preprocessor/macro-multiline.c | 8 + clang/test/Preprocessor/macro_arg_directive.c | 20 + clang/test/Preprocessor/macro_arg_directive.h | 9 + clang/test/Preprocessor/macro_arg_keyword.c | 6 + clang/test/Preprocessor/macro_disable.c | 43 + clang/test/Preprocessor/macro_expand.c | 19 + clang/test/Preprocessor/macro_expandloc.c | 6 + clang/test/Preprocessor/macro_expandloc2.c | 6 + clang/test/Preprocessor/macro_fn.c | 46 + clang/test/Preprocessor/macro_fn_comma_swallow.c | 28 + clang/test/Preprocessor/macro_fn_disable_expand.c | 30 + clang/test/Preprocessor/macro_fn_lparen_scan.c | 27 + clang/test/Preprocessor/macro_fn_lparen_scan2.c | 7 + clang/test/Preprocessor/macro_fn_placemarker.c | 5 + clang/test/Preprocessor/macro_fn_preexpand.c | 12 + clang/test/Preprocessor/macro_fn_varargs_iso.c | 11 + clang/test/Preprocessor/macro_fn_varargs_named.c | 10 + clang/test/Preprocessor/macro_misc.c | 23 + clang/test/Preprocessor/macro_not_define.c | 9 + clang/test/Preprocessor/macro_paste_bad.c | 34 + clang/test/Preprocessor/macro_paste_bcpl_comment.c | 5 + .../Preprocessor/macro_paste_c_block_comment.c | 5 + clang/test/Preprocessor/macro_paste_commaext.c | 13 + clang/test/Preprocessor/macro_paste_empty.c | 13 + clang/test/Preprocessor/macro_paste_hard.c | 17 + clang/test/Preprocessor/macro_paste_hashhash.c | 11 + clang/test/Preprocessor/macro_paste_msextensions.c | 34 + clang/test/Preprocessor/macro_paste_none.c | 6 + clang/test/Preprocessor/macro_paste_simple.c | 14 + clang/test/Preprocessor/macro_paste_spacing.c | 7 + clang/test/Preprocessor/macro_paste_spacing2.c | 6 + clang/test/Preprocessor/macro_rescan.c | 9 + clang/test/Preprocessor/macro_rescan2.c | 15 + clang/test/Preprocessor/macro_rescan_varargs.c | 13 + clang/test/Preprocessor/macro_rparen_scan.c | 8 + clang/test/Preprocessor/macro_rparen_scan2.c | 10 + clang/test/Preprocessor/macro_space.c | 5 + clang/test/Preprocessor/macro_undef.c | 4 + clang/test/Preprocessor/mi_opt.c | 11 + clang/test/Preprocessor/mi_opt.h | 4 + clang/test/Preprocessor/mi_opt2.c | 15 + clang/test/Preprocessor/mi_opt2.h | 5 + clang/test/Preprocessor/microsoft-import.c | 17 + clang/test/Preprocessor/missing-system-header.c | 2 + clang/test/Preprocessor/missing-system-header.h | 2 + clang/test/Preprocessor/mmx.c | 13 + clang/test/Preprocessor/non_fragile_feature.m | 12 + clang/test/Preprocessor/non_fragile_feature1.m | 8 + clang/test/Preprocessor/objc-pp.m | 4 + clang/test/Preprocessor/optimize.c | 29 + clang/test/Preprocessor/output_paste_avoid.c | 33 + clang/test/Preprocessor/overflow.c | 25 + clang/test/Preprocessor/pic.c | 34 + clang/test/Preprocessor/pp-record.c | 12 + clang/test/Preprocessor/pp-record.h | 3 + clang/test/Preprocessor/pr2086.c | 11 + clang/test/Preprocessor/pr2086.h | 6 + clang/test/Preprocessor/pragma-pushpop-macro.c | 41 + clang/test/Preprocessor/pragma_diagnostic.c | 32 + clang/test/Preprocessor/pragma_diagnostic_output.c | 26 + .../Preprocessor/pragma_diagnostic_sections.cpp | 80 + clang/test/Preprocessor/pragma_microsoft.c | 83 + clang/test/Preprocessor/pragma_poison.c | 20 + clang/test/Preprocessor/pragma_sysheader.c | 12 + clang/test/Preprocessor/pragma_sysheader.h | 4 + clang/test/Preprocessor/pragma_unknown.c | 28 + clang/test/Preprocessor/predefined-arch-macros.c | 866 ++++++ clang/test/Preprocessor/predefined-exceptions.m | 15 + clang/test/Preprocessor/predefined-macros.c | 15 + clang/test/Preprocessor/print_line_count.c | 4 + clang/test/Preprocessor/print_line_empty_file.c | 12 + clang/test/Preprocessor/print_line_track.c | 17 + clang/test/Preprocessor/pushable-diagnostics.c | 17 + clang/test/Preprocessor/skipping_unclean.c | 9 + clang/test/Preprocessor/stdint.c | 959 ++++++ clang/test/Preprocessor/stringize_misc.c | 30 + clang/test/Preprocessor/stringize_space.c | 4 + clang/test/Preprocessor/stringize_space2.c | 6 + clang/test/Preprocessor/traditional-cpp.c | 12 + clang/test/Preprocessor/undef-error.c | 5 + clang/test/Preprocessor/unterminated.c | 5 + .../Preprocessor/user_defined_system_framework.c | 8 + .../Preprocessor/warn-disabled-macro-expansion.c | 27 + clang/test/Preprocessor/warn-macro-unused.c | 10 + clang/test/Preprocessor/warn-macro-unused.h | 1 + clang/test/Preprocessor/warning_tests.c | 19 + clang/test/Preprocessor/x86_target_features.c | 32 + clang/test/Rewriter/blockcast3.mm | 26 + clang/test/Rewriter/blockstruct.m | 17 + clang/test/Rewriter/crash.m | 25 + clang/test/Rewriter/dllimport-typedef.c | 17 + clang/test/Rewriter/finally.m | 42 + clang/test/Rewriter/func-in-impl.m | 30 + clang/test/Rewriter/id-test-3.m | 14 + clang/test/Rewriter/inner-block-helper-funcs.mm | 32 + clang/test/Rewriter/instancetype-test.mm | 77 + clang/test/Rewriter/ivar-encoding-1.m | 15 + clang/test/Rewriter/ivar-encoding-2.m | 12 + clang/test/Rewriter/metadata-test-1.m | 12 + clang/test/Rewriter/metadata-test-2.m | 15 + clang/test/Rewriter/method-encoding-1.m | 18 + clang/test/Rewriter/missing-dllimport.c | 19 + .../Rewriter/objc-bool-literal-check-modern.mm | 29 + clang/test/Rewriter/objc-bool-literal-modern-1.mm | 31 + clang/test/Rewriter/objc-bool-literal-modern.mm | 23 + clang/test/Rewriter/objc-encoding-bug-1.m | 19 + clang/test/Rewriter/objc-ivar-receiver-1.m | 24 + .../test/Rewriter/objc-modern-class-init-hooks.mm | 36 + clang/test/Rewriter/objc-modern-class-init.mm | 23 + .../Rewriter/objc-modern-container-subscript.mm | 48 + clang/test/Rewriter/objc-modern-implicit-cast.mm | 33 + clang/test/Rewriter/objc-modern-ivar-receiver-1.mm | 31 + clang/test/Rewriter/objc-modern-linkage-spec.mm | 21 + .../Rewriter/objc-modern-metadata-visibility.mm | 40 + clang/test/Rewriter/objc-modern-numeric-literal.mm | 69 + .../Rewriter/objc-modern-property-attributes.mm | 35 + clang/test/Rewriter/objc-string-concat-1.m | 14 + clang/test/Rewriter/objc-super-test.m | 18 + clang/test/Rewriter/objc-synchronized-1.m | 20 + clang/test/Rewriter/properties.m | 57 + clang/test/Rewriter/property-dot-syntax.mm | 46 + clang/test/Rewriter/protocol-rewrite-1.m | 48 + clang/test/Rewriter/protocol-rewrite-2.m | 7 + clang/test/Rewriter/rewrite-anonymous-union.m | 30 + clang/test/Rewriter/rewrite-api-bug.m | 11 + clang/test/Rewriter/rewrite-block-argument.m | 33 + clang/test/Rewriter/rewrite-block-consts.mm | 19 + clang/test/Rewriter/rewrite-block-ivar-call.mm | 12 + clang/test/Rewriter/rewrite-block-literal-1.mm | 35 + clang/test/Rewriter/rewrite-block-literal.mm | 76 + clang/test/Rewriter/rewrite-block-pointer.mm | 109 + clang/test/Rewriter/rewrite-block-property.m | 15 + .../Rewriter/rewrite-byref-in-nested-blocks.mm | 28 + clang/test/Rewriter/rewrite-byref-vars.mm | 57 + clang/test/Rewriter/rewrite-captured-nested-bvar.c | 35 + clang/test/Rewriter/rewrite-cast-ivar-access.mm | 53 + .../Rewriter/rewrite-cast-ivar-modern-access.mm | 46 + clang/test/Rewriter/rewrite-cast-to-bool.mm | 17 + clang/test/Rewriter/rewrite-category-property.mm | 15 + clang/test/Rewriter/rewrite-constructor-init.mm | 24 + clang/test/Rewriter/rewrite-eh.m | 20 + clang/test/Rewriter/rewrite-elaborated-type.mm | 40 + clang/test/Rewriter/rewrite-extern-c.mm | 8 + clang/test/Rewriter/rewrite-foreach-1.m | 37 + clang/test/Rewriter/rewrite-foreach-2.m | 34 + clang/test/Rewriter/rewrite-foreach-3.m | 29 + clang/test/Rewriter/rewrite-foreach-4.m | 32 + clang/test/Rewriter/rewrite-foreach-5.m | 51 + clang/test/Rewriter/rewrite-foreach-6.m | 17 + clang/test/Rewriter/rewrite-foreach-7.m | 7 + clang/test/Rewriter/rewrite-foreach-in-block.mm | 30 + clang/test/Rewriter/rewrite-foreach-protocol-id.m | 29 + clang/test/Rewriter/rewrite-forward-class.m | 35 + clang/test/Rewriter/rewrite-forward-class.mm | 44 + clang/test/Rewriter/rewrite-function-decl.mm | 31 + clang/test/Rewriter/rewrite-implementation.mm | 16 + clang/test/Rewriter/rewrite-ivar-use.m | 28 + .../Rewriter/rewrite-local-externs-in-block.mm | 23 + clang/test/Rewriter/rewrite-local-static-id.mm | 24 + clang/test/Rewriter/rewrite-message-expr.mm | 25 + .../test/Rewriter/rewrite-modern-array-literal.mm | 27 + .../Rewriter/rewrite-modern-block-ivar-call.mm | 17 + clang/test/Rewriter/rewrite-modern-block.mm | 23 + clang/test/Rewriter/rewrite-modern-catch.m | 31 + clang/test/Rewriter/rewrite-modern-class.mm | 70 + .../Rewriter/rewrite-modern-container-literal.mm | 55 + .../Rewriter/rewrite-modern-extern-c-func-decl.mm | 45 + clang/test/Rewriter/rewrite-modern-ivar-use.mm | 26 + clang/test/Rewriter/rewrite-modern-ivars-1.mm | 89 + clang/test/Rewriter/rewrite-modern-ivars-2.mm | 101 + clang/test/Rewriter/rewrite-modern-ivars.mm | 64 + clang/test/Rewriter/rewrite-modern-nested-ivar.mm | 33 + clang/test/Rewriter/rewrite-modern-protocol-1.mm | 14 + clang/test/Rewriter/rewrite-modern-protocol.mm | 31 + clang/test/Rewriter/rewrite-modern-struct-ivar.mm | 24 + clang/test/Rewriter/rewrite-modern-super.mm | 23 + clang/test/Rewriter/rewrite-modern-synchronized.m | 35 + clang/test/Rewriter/rewrite-modern-throw.m | 67 + .../Rewriter/rewrite-modern-try-catch-finally.m | 63 + clang/test/Rewriter/rewrite-modern-try-finally.m | 40 + clang/test/Rewriter/rewrite-modern-typeof.mm | 46 + clang/test/Rewriter/rewrite-nest.m | 27 + clang/test/Rewriter/rewrite-nested-blocks-1.mm | 49 + clang/test/Rewriter/rewrite-nested-blocks-2.mm | 21 + clang/test/Rewriter/rewrite-nested-blocks.mm | 58 + clang/test/Rewriter/rewrite-nested-ivar.mm | 33 + .../Rewriter/rewrite-nested-property-in-blocks.mm | 54 + clang/test/Rewriter/rewrite-no-nextline.mm | 10 + clang/test/Rewriter/rewrite-property-attributes.mm | 22 + .../test/Rewriter/rewrite-property-set-cfstring.mm | 21 + clang/test/Rewriter/rewrite-protocol-property.mm | 22 + clang/test/Rewriter/rewrite-protocol-qualified.mm | 50 + clang/test/Rewriter/rewrite-protocol-type-1.m | 27 + clang/test/Rewriter/rewrite-qualified-id.mm | 21 + .../test/Rewriter/rewrite-rewritten-initializer.mm | 28 + clang/test/Rewriter/rewrite-static-block.mm | 11 + clang/test/Rewriter/rewrite-super-message.mm | 51 + clang/test/Rewriter/rewrite-trivial-constructor.mm | 21 + clang/test/Rewriter/rewrite-try-catch.m | 27 + clang/test/Rewriter/rewrite-typeof.mm | 39 + clang/test/Rewriter/rewrite-unique-block-api.mm | 27 + .../Rewriter/rewrite-user-defined-accessors.mm | 30 + clang/test/Rewriter/rewrite-vararg.m | 27 + clang/test/Rewriter/rewrite-weak-attr.m | 13 + clang/test/Rewriter/static-type-protocol-1.m | 27 + clang/test/Rewriter/undecl-objc-h.m | 29 + clang/test/Rewriter/undeclared-method-1.m | 9 + clang/test/Rewriter/undef-field-reference-1.m | 15 + clang/test/Rewriter/unnamed-bf-modern-write.mm | 23 + clang/test/Rewriter/va-method.m | 17 + clang/test/Rewriter/weak_byref_objects.m | 15 + clang/test/Sema/128bitint.c | 13 + clang/test/Sema/2007-10-01-BuildArrayRef.c | 20 + clang/test/Sema/2009-03-09-WeakDeclarations-1.c | 16 + clang/test/Sema/2009-04-22-UnknownSize.c | 4 + clang/test/Sema/2009-07-17-VoidParameter.c | 4 + clang/test/Sema/2010-05-31-palignr.c | 22 + clang/test/Sema/Inputs/conversion.h | 4 + .../test/Sema/Inputs/pragma-arc-cf-code-audited.h | 16 + clang/test/Sema/Inputs/unused-expr-system-header.h | 23 + clang/test/Sema/MicrosoftCompatibility.c | 16 + clang/test/Sema/MicrosoftExtensions.c | 102 + clang/test/Sema/PR2727.c | 8 + clang/test/Sema/PR2728.c | 9 + .../Sema/PR2919-builtin-types-compat-strips-crv.c | 7 + clang/test/Sema/PR2923.c | 12 + clang/test/Sema/PR2963-enum-constant.c | 17 + clang/test/Sema/__try.c | 172 ++ clang/test/Sema/address-constant.c | 10 + clang/test/Sema/address_spaces.c | 50 + clang/test/Sema/align-arm-apcs.c | 4 + clang/test/Sema/align-x86-64.c | 25 + clang/test/Sema/align-x86.c | 48 + clang/test/Sema/alignas.c | 19 + clang/test/Sema/altivec-init.c | 47 + clang/test/Sema/annotate.c | 10 + clang/test/Sema/anonymous-struct-union-c11.c | 19 + clang/test/Sema/anonymous-struct-union.c | 110 + clang/test/Sema/arg-duplicate.c | 15 + clang/test/Sema/arg-scope-c99.c | 2 + clang/test/Sema/arg-scope.c | 5 + clang/test/Sema/arm-layout.c | 53 + clang/test/Sema/arm-neon-types.c | 35 + clang/test/Sema/array-bounds-ptr-arith.c | 21 + clang/test/Sema/array-constraint.c | 52 + clang/test/Sema/array-declared-as-incorrect-type.c | 16 + clang/test/Sema/array-init.c | 289 ++ clang/test/Sema/array-size-64.c | 7 + clang/test/Sema/array-size.c | 10 + clang/test/Sema/asm.c | 125 + clang/test/Sema/assign-null.c | 10 + clang/test/Sema/assign.c | 15 + clang/test/Sema/ast-print.c | 8 + clang/test/Sema/atomic-ops.c | 165 ++ clang/test/Sema/atomic-type.c | 22 + clang/test/Sema/attr-alias.c | 8 + clang/test/Sema/attr-aligned.c | 38 + clang/test/Sema/attr-args.c | 40 + clang/test/Sema/attr-availability-ios.c | 21 + clang/test/Sema/attr-availability-macosx.c | 31 + clang/test/Sema/attr-availability.c | 26 + clang/test/Sema/attr-cleanup.c | 40 + clang/test/Sema/attr-decl-after-definition.c | 19 + clang/test/Sema/attr-declspec-ignored.c | 12 + clang/test/Sema/attr-deprecated-message.c | 31 + clang/test/Sema/attr-deprecated.c | 115 + clang/test/Sema/attr-format.c | 80 + clang/test/Sema/attr-format_arg.c | 13 + clang/test/Sema/attr-malloc.c | 28 + clang/test/Sema/attr-mode.c | 59 + clang/test/Sema/attr-naked.c | 12 + clang/test/Sema/attr-nodebug.c | 8 + clang/test/Sema/attr-noinline.c | 8 + clang/test/Sema/attr-noreturn.c | 44 + clang/test/Sema/attr-regparm.c | 11 + clang/test/Sema/attr-returns-twice.c | 12 + clang/test/Sema/attr-section.c | 15 + clang/test/Sema/attr-sentinel.c | 59 + clang/test/Sema/attr-unavailable-message.c | 49 + clang/test/Sema/attr-unknown.c | 4 + clang/test/Sema/attr-unused.c | 43 + clang/test/Sema/attr-used.c | 20 + clang/test/Sema/attr-visibility.c | 9 + clang/test/Sema/attr-weak.c | 18 + clang/test/Sema/bitfield-layout.c | 42 + clang/test/Sema/bitfield-promote.c | 34 + clang/test/Sema/bitfield.c | 41 + clang/test/Sema/block-args.c | 47 + clang/test/Sema/block-call.c | 52 + clang/test/Sema/block-explicit-noreturn-type.c | 15 + clang/test/Sema/block-labels.c | 27 + clang/test/Sema/block-literal.c | 89 + clang/test/Sema/block-misc.c | 228 ++ clang/test/Sema/block-printf-attribute-1.c | 21 + clang/test/Sema/block-return-1.c | 6 + clang/test/Sema/block-return-2.c | 5 + clang/test/Sema/block-return-3.c | 5 + clang/test/Sema/block-return.c | 136 + clang/test/Sema/block-sentinel-attribute.c | 25 + clang/test/Sema/block-storageclass.c | 18 + clang/test/Sema/builtin-object-size.c | 28 + clang/test/Sema/builtin-prefetch.c | 14 + clang/test/Sema/builtin-stackaddress.c | 16 + clang/test/Sema/builtin-unary-fp.c | 16 + clang/test/Sema/builtin_objc_msgSend.c | 12 + clang/test/Sema/builtins-arm.c | 16 + clang/test/Sema/builtins-decl.c | 8 + clang/test/Sema/builtins.c | 164 ++ clang/test/Sema/c11-typedef-redef.c | 18 + clang/test/Sema/c89-2.c | 5 + clang/test/Sema/c89.c | 112 + clang/test/Sema/callingconv.c | 46 + clang/test/Sema/carbon.c | 5 + clang/test/Sema/cast-incomplete.c | 14 + clang/test/Sema/cast-to-union.c | 20 + clang/test/Sema/cast.c | 159 + clang/test/Sema/check-increment.c | 10 + clang/test/Sema/compare.c | 335 +++ clang/test/Sema/complex-imag.c | 29 + clang/test/Sema/complex-init-list.c | 48 + clang/test/Sema/complex-int.c | 67 + clang/test/Sema/complex-promotion.c | 15 + clang/test/Sema/compound-literal.c | 37 + clang/test/Sema/conditional-expr.c | 112 + clang/test/Sema/conditional.c | 14 + clang/test/Sema/const-eval-64.c | 7 + clang/test/Sema/const-eval.c | 133 + clang/test/Sema/const-ptr-int-ptr-cast.c | 5 + clang/test/Sema/constant-builtins-2.c | 56 + clang/test/Sema/constant-builtins.c | 24 + clang/test/Sema/constant-conversion.c | 82 + clang/test/Sema/constructor-attribute.c | 15 + clang/test/Sema/conversion-64-32.c | 19 + clang/test/Sema/conversion.c | 419 +++ clang/test/Sema/crash-invalid-array.c | 17 + clang/test/Sema/darwin-align-cast.c | 24 + clang/test/Sema/decl-in-prototype.c | 33 + clang/test/Sema/decl-invalid.c | 28 + clang/test/Sema/decl-type-merging.c | 16 + clang/test/Sema/declspec.c | 38 + clang/test/Sema/default.c | 8 + clang/test/Sema/default1.c | 2 + clang/test/Sema/deref.c | 44 + clang/test/Sema/designated-initializers.c | 279 ++ clang/test/Sema/dllimport-dllexport.c | 37 + clang/test/Sema/enum-packed.c | 16 + clang/test/Sema/enum.c | 121 + clang/test/Sema/expr-address-of.c | 120 + clang/test/Sema/expr-comma-c99.c | 17 + clang/test/Sema/expr-comma.c | 17 + clang/test/Sema/exprs.c | 240 ++ clang/test/Sema/ext_vector_casts.c | 52 + clang/test/Sema/ext_vector_comparisons.c | 30 + clang/test/Sema/ext_vector_components.c | 47 + clang/test/Sema/extern-redecl.c | 22 + clang/test/Sema/flexible-array-init.c | 91 + clang/test/Sema/floating-point-compare.c | 25 + clang/test/Sema/fn-ptr-as-fn-prototype.c | 15 + clang/test/Sema/for.c | 7 + clang/test/Sema/format-string-percentm.c | 7 + clang/test/Sema/format-strings-c90.c | 30 + clang/test/Sema/format-strings-fixit-ssize_t.c | 18 + clang/test/Sema/format-strings-fixit.c | 208 ++ clang/test/Sema/format-strings-int-typedefs.c | 37 + clang/test/Sema/format-strings-no-fixit.c | 65 + clang/test/Sema/format-strings-non-iso.c | 29 + clang/test/Sema/format-strings-scanf.c | 123 + clang/test/Sema/format-strings-size_t.c | 15 + clang/test/Sema/format-strings.c | 523 ++++ clang/test/Sema/fp16-sema.c | 30 + clang/test/Sema/fpack-struct.c | 9 + clang/test/Sema/freemain.c | 9 + clang/test/Sema/function-ptr.c | 11 + clang/test/Sema/function-redecl.c | 131 + clang/test/Sema/function.c | 94 + clang/test/Sema/generic-selection.c | 26 + clang/test/Sema/gnu89.c | 5 + clang/test/Sema/heinous-extensions-off.c | 10 + clang/test/Sema/heinous-extensions-on.c | 9 + clang/test/Sema/i-c-e.c | 75 + clang/test/Sema/illegal-types.c | 7 + clang/test/Sema/implicit-builtin-decl.c | 57 + clang/test/Sema/implicit-builtin-freestanding.c | 4 + clang/test/Sema/implicit-builtin-redecl.c | 26 + clang/test/Sema/implicit-cast.c | 8 + clang/test/Sema/implicit-decl.c | 32 + clang/test/Sema/implicit-def.c | 8 + clang/test/Sema/implicit-int.c | 28 + clang/test/Sema/incompatible-sign.c | 5 + clang/test/Sema/incomplete-call.c | 13 + clang/test/Sema/incomplete-decl.c | 31 + clang/test/Sema/indirect-goto.c | 11 + clang/test/Sema/init-struct-qualified.c | 12 + clang/test/Sema/init-vector.c | 17 + clang/test/Sema/init.c | 159 + clang/test/Sema/initialize-noreturn.c | 16 + clang/test/Sema/inline-redef.c | 24 + clang/test/Sema/inline.c | 6 + clang/test/Sema/int-arith-convert.c | 12 + clang/test/Sema/invalid-decl.c | 22 + clang/test/Sema/invalid-init-diag.c | 4 + clang/test/Sema/invalid-struct-init.c | 27 + clang/test/Sema/knr-def-call.c | 41 + clang/test/Sema/knr-variadic-def.c | 29 + clang/test/Sema/many-logical-ops.c | 2010 +++++++++++++ clang/test/Sema/many-parameters.c | 310 ++ clang/test/Sema/member-reference.c | 20 + clang/test/Sema/memset-invalid.c | 6 + clang/test/Sema/merge-decls.c | 39 + clang/test/Sema/missing-field-initializers.c | 52 + clang/test/Sema/ms_class_layout.cpp | 335 +++ clang/test/Sema/neon-vector-types.c | 33 + clang/test/Sema/nested-redef.c | 22 + clang/test/Sema/no-format-y2k-turnsoff-format.c | 9 + clang/test/Sema/nonnull.c | 21 + clang/test/Sema/offsetof.c | 71 + clang/test/Sema/overloadable-complex.c | 50 + clang/test/Sema/overloadable.c | 71 + .../test/Sema/overloaded-func-transparent-union.c | 28 + clang/test/Sema/parentheses.c | 73 + clang/test/Sema/parentheses.cpp | 47 + clang/test/Sema/pointer-addition.c | 21 + clang/test/Sema/pointer-conversion.c | 10 + clang/test/Sema/pointer-subtract-compat.c | 11 + clang/test/Sema/pragma-align-mac68k-unsupported.c | 4 + clang/test/Sema/pragma-align-mac68k.c | 98 + clang/test/Sema/pragma-align-packed.c | 30 + clang/test/Sema/pragma-arc-cf-code-audited.c | 18 + clang/test/Sema/pragma-ms_struct.c | 55 + clang/test/Sema/pragma-pack-2.c | 59 + clang/test/Sema/pragma-pack-3.c | 34 + clang/test/Sema/pragma-pack-4.c | 19 + clang/test/Sema/pragma-pack-5.c | 45 + clang/test/Sema/pragma-pack-and-options-align.c | 42 + clang/test/Sema/pragma-pack-apple.c | 10 + clang/test/Sema/pragma-pack.c | 27 + clang/test/Sema/pragma-unused.c | 65 + clang/test/Sema/predef.c | 19 + clang/test/Sema/predefined-function.c | 38 + clang/test/Sema/private-extern.c | 84 + .../Sema/rdr6094103-unordered-compare-promote.c | 6 + clang/test/Sema/recover-goto.c | 5 + clang/test/Sema/redefinition.c | 14 + clang/test/Sema/return-noreturn.c | 37 + clang/test/Sema/return-silent.c | 9 + clang/test/Sema/return.c | 266 ++ clang/test/Sema/scope-check.c | 234 ++ clang/test/Sema/self-comparison.c | 88 + clang/test/Sema/sentinel-attribute.c | 15 + clang/test/Sema/shift.c | 68 + clang/test/Sema/short-enums.c | 5 + clang/test/Sema/sign-conversion.c | 8 + clang/test/Sema/statements.c | 102 + clang/test/Sema/static-array.c | 31 + clang/test/Sema/static-assert.c | 11 + clang/test/Sema/static-init.c | 24 + clang/test/Sema/stdcall-fastcall.c | 21 + clang/test/Sema/struct-cast.c | 15 + clang/test/Sema/struct-compat.c | 17 + clang/test/Sema/struct-decl.c | 59 + clang/test/Sema/struct-packed-align.c | 134 + clang/test/Sema/surpress-deprecated.c | 7 + clang/test/Sema/switch.c | 322 ++ clang/test/Sema/tentative-decls.c | 65 + clang/test/Sema/text-diag.c | 4 + clang/test/Sema/thread-specifier.c | 21 + clang/test/Sema/transparent-union-pointer.c | 14 + clang/test/Sema/transparent-union.c | 73 + clang/test/Sema/type-spec-struct-union.c | 65 + clang/test/Sema/typecheck-binop.c | 27 + clang/test/Sema/typedef-prototype.c | 8 + clang/test/Sema/typedef-redef.c | 11 + clang/test/Sema/typedef-retain.c | 26 + clang/test/Sema/typedef-variable-type.c | 8 + clang/test/Sema/typeof-use-deprecated.c | 26 + clang/test/Sema/types.c | 66 + clang/test/Sema/ucn-cstring.c | 16 + clang/test/Sema/uninit-variables-vectors.c | 17 + clang/test/Sema/uninit-variables.c | 426 +++ clang/test/Sema/unnamed-bitfield-init.c | 6 + clang/test/Sema/unused-expr-system-header.c | 10 + clang/test/Sema/unused-expr.c | 123 + clang/test/Sema/usual-float.c | 12 + clang/test/Sema/va_arg_x86_32.c | 6 + clang/test/Sema/va_arg_x86_64.c | 15 + clang/test/Sema/var-redecl.c | 62 + clang/test/Sema/varargs-x86-64.c | 8 + clang/test/Sema/varargs.c | 78 + clang/test/Sema/variadic-block.c | 41 + clang/test/Sema/variadic-incomplete-arg-type.c | 13 + clang/test/Sema/vector-assign.c | 53 + clang/test/Sema/vector-cast.c | 38 + clang/test/Sema/vector-init.c | 44 + clang/test/Sema/vector-ops.c | 29 + clang/test/Sema/vfprintf-invalid-redecl.c | 6 + clang/test/Sema/vfprintf-valid-redecl.c | 6 + clang/test/Sema/vla-2.c | 17 + clang/test/Sema/vla.c | 67 + clang/test/Sema/void_arg.c | 26 + clang/test/Sema/warn-cast-align.c | 41 + clang/test/Sema/warn-char-subscripts.c | 64 + clang/test/Sema/warn-freestanding-complex.c | 4 + clang/test/Sema/warn-gnu-designators.c | 2 + clang/test/Sema/warn-missing-braces.c | 3 + clang/test/Sema/warn-missing-prototypes.c | 37 + clang/test/Sema/warn-shadow.c | 61 + clang/test/Sema/warn-sizeof-arrayarg.c | 30 + clang/test/Sema/warn-strlcpycat-size.c | 55 + clang/test/Sema/warn-strncat-size.c | 71 + clang/test/Sema/warn-unreachable.c | 134 + clang/test/Sema/warn-unused-function.c | 56 + clang/test/Sema/warn-unused-label.c | 11 + clang/test/Sema/warn-unused-parameters.c | 30 + clang/test/Sema/warn-unused-value.c | 90 + clang/test/Sema/warn-unused-variables.c | 32 + clang/test/Sema/warn-write-strings.c | 10 + clang/test/Sema/wchar.c | 22 + clang/test/Sema/weak-import-on-enum.c | 8 + clang/test/Sema/x86-attr-force-align-arg-pointer.c | 21 + clang/test/Sema/x86-builtin-palignr.c | 17 + clang/test/SemaCUDA/config-type.cu | 3 + clang/test/SemaCUDA/cuda.h | 19 + clang/test/SemaCUDA/function-target.cu | 44 + clang/test/SemaCUDA/kernel-call.cu | 26 + clang/test/SemaCUDA/qualifiers.cu | 8 + clang/test/SemaCXX/2008-01-11-BadWarning.cpp | 5 + .../SemaCXX/Inputs/array-bounds-system-header.h | 11 + clang/test/SemaCXX/Inputs/lit.local.cfg | 1 + clang/test/SemaCXX/Inputs/malloc.h | 3 + clang/test/SemaCXX/Inputs/warn-new-overaligned-3.h | 19 + .../test/SemaCXX/MicrosoftCompatibility-cxx98.cpp | 8 + clang/test/SemaCXX/MicrosoftCompatibility.cpp | 176 ++ clang/test/SemaCXX/MicrosoftExtensions.cpp | 205 ++ clang/test/SemaCXX/PR10177.cpp | 40 + clang/test/SemaCXX/PR10243.cpp | 23 + clang/test/SemaCXX/PR10447.cpp | 22 + clang/test/SemaCXX/PR10458.cpp | 7 + clang/test/SemaCXX/PR11358.cpp | 51 + clang/test/SemaCXX/PR12481.cpp | 17 + .../test/SemaCXX/PR5086-ambig-resolution-enum.cpp | 13 + clang/test/SemaCXX/PR6562.cpp | 10 + clang/test/SemaCXX/PR6618.cpp | 13 + clang/test/SemaCXX/PR7410.cpp | 13 + clang/test/SemaCXX/PR7944.cpp | 12 + clang/test/SemaCXX/PR8012.cpp | 3 + clang/test/SemaCXX/PR8385.cpp | 7 + clang/test/SemaCXX/PR8755.cpp | 16 + clang/test/SemaCXX/PR8884.cpp | 12 + clang/test/SemaCXX/PR9459.cpp | 7 + clang/test/SemaCXX/PR9460.cpp | 19 + clang/test/SemaCXX/PR9461.cpp | 32 + clang/test/SemaCXX/PR9572.cpp | 15 + clang/test/SemaCXX/PR9884.cpp | 17 + clang/test/SemaCXX/PR9902.cpp | 28 + clang/test/SemaCXX/PR9908.cpp | 32 + clang/test/SemaCXX/__null.cpp | 21 + clang/test/SemaCXX/__try.cpp | 58 + clang/test/SemaCXX/abstract.cpp | 261 ++ clang/test/SemaCXX/access-base-class.cpp | 91 + clang/test/SemaCXX/access-control-check.cpp | 15 + clang/test/SemaCXX/access-member-pointer.cpp | 11 + clang/test/SemaCXX/access.cpp | 34 + .../addr-of-overloaded-function-casting.cpp | 57 + clang/test/SemaCXX/addr-of-overloaded-function.cpp | 210 ++ clang/test/SemaCXX/address-of-temporary.cpp | 12 + clang/test/SemaCXX/address-of.cpp | 46 + clang/test/SemaCXX/address-space-conversion.cpp | 197 ++ clang/test/SemaCXX/address-space-newdelete.cpp | 24 + clang/test/SemaCXX/address-space-references.cpp | 19 + clang/test/SemaCXX/aggregate-initialization.cpp | 84 + clang/test/SemaCXX/alias-template.cpp | 147 + clang/test/SemaCXX/alignof-sizeof-reference.cpp | 22 + clang/test/SemaCXX/altivec.cpp | 78 + .../SemaCXX/ambig-user-defined-conversions.cpp | 67 + .../SemaCXX/ambiguous-builtin-unary-operator.cpp | 34 + clang/test/SemaCXX/anonymous-struct.cpp | 16 + clang/test/SemaCXX/anonymous-union.cpp | 199 ++ clang/test/SemaCXX/array-bound-merge.cpp | 9 + clang/test/SemaCXX/array-bounds-ptr-arith.cpp | 33 + clang/test/SemaCXX/array-bounds-system-header.cpp | 9 + clang/test/SemaCXX/array-bounds.cpp | 255 ++ clang/test/SemaCXX/arrow-operator.cpp | 38 + clang/test/SemaCXX/atomic-type.cxx | 35 + clang/test/SemaCXX/attr-after-definition.cpp | 9 + clang/test/SemaCXX/attr-cxx0x.cpp | 32 + clang/test/SemaCXX/attr-declspec-ignored.cpp | 19 + clang/test/SemaCXX/attr-deprecated.cpp | 235 ++ clang/test/SemaCXX/attr-format.cpp | 35 + clang/test/SemaCXX/attr-nonnull.cpp | 33 + clang/test/SemaCXX/attr-noreturn.cpp | 56 + clang/test/SemaCXX/attr-regparm.cpp | 15 + clang/test/SemaCXX/attr-sentinel.cpp | 23 + clang/test/SemaCXX/attr-unavailable.cpp | 39 + clang/test/SemaCXX/attr-weak.cpp | 29 + clang/test/SemaCXX/attr-weakref.cpp | 31 + clang/test/SemaCXX/auto-cxx0x.cpp | 5 + clang/test/SemaCXX/auto-cxx98.cpp | 8 + clang/test/SemaCXX/auto-subst-failure.cpp | 15 + clang/test/SemaCXX/bitfield-layout.cpp | 30 + clang/test/SemaCXX/block-call.cpp | 52 + clang/test/SemaCXX/blocks-1.cpp | 58 + clang/test/SemaCXX/blocks.cpp | 70 + clang/test/SemaCXX/bool.cpp | 33 + clang/test/SemaCXX/borland-extensions.cpp | 53 + clang/test/SemaCXX/builtin-exception-spec.cpp | 6 + clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp | 27 + .../SemaCXX/builtin-ptrtomember-overload-1.cpp | 46 + .../test/SemaCXX/builtin-ptrtomember-overload.cpp | 30 + clang/test/SemaCXX/builtin_objc_msgSend.cpp | 14 + clang/test/SemaCXX/builtins.cpp | 9 + clang/test/SemaCXX/c99-variable-length-array.cpp | 141 + clang/test/SemaCXX/c99.cpp | 9 + clang/test/SemaCXX/cast-conversion.cpp | 47 + clang/test/SemaCXX/cast-explicit-ctor.cpp | 6 + clang/test/SemaCXX/class-base-member-init.cpp | 92 + clang/test/SemaCXX/class-layout.cpp | 104 + clang/test/SemaCXX/class-names.cpp | 52 + clang/test/SemaCXX/class.cpp | 197 ++ clang/test/SemaCXX/comma.cpp | 8 + clang/test/SemaCXX/compare.cpp | 225 ++ clang/test/SemaCXX/complex-init-list.cpp | 14 + clang/test/SemaCXX/complex-overload.cpp | 50 + clang/test/SemaCXX/composite-pointer-type.cpp | 60 + clang/test/SemaCXX/compound-literal.cpp | 14 + clang/test/SemaCXX/condition.cpp | 60 + clang/test/SemaCXX/conditional-expr.cpp | 330 +++ clang/test/SemaCXX/const-cast.cpp | 64 + clang/test/SemaCXX/constant-expression-cxx11.cpp | 1250 ++++++++ clang/test/SemaCXX/constant-expression.cpp | 119 + clang/test/SemaCXX/constexpr-ackermann.cpp | 8 + clang/test/SemaCXX/constexpr-backtrace-limit.cpp | 34 + clang/test/SemaCXX/constexpr-depth.cpp | 8 + clang/test/SemaCXX/constexpr-factorial.cpp | 9 + clang/test/SemaCXX/constexpr-nqueens.cpp | 73 + clang/test/SemaCXX/constexpr-printing.cpp | 102 + clang/test/SemaCXX/constexpr-strlen.cpp | 15 + clang/test/SemaCXX/constexpr-turing.cpp | 55 + clang/test/SemaCXX/constexpr-value-init.cpp | 37 + clang/test/SemaCXX/constructor-initializer.cpp | 282 ++ clang/test/SemaCXX/constructor-recovery.cpp | 9 + clang/test/SemaCXX/constructor.cpp | 87 + clang/test/SemaCXX/conversion-delete-expr.cpp | 109 + clang/test/SemaCXX/conversion-function.cpp | 394 +++ clang/test/SemaCXX/conversion.cpp | 83 + clang/test/SemaCXX/convert-to-bool.cpp | 67 + clang/test/SemaCXX/converting-constructor.cpp | 47 + clang/test/SemaCXX/copy-assignment.cpp | 110 + clang/test/SemaCXX/copy-constructor-error.cpp | 25 + clang/test/SemaCXX/copy-initialization.cpp | 67 + clang/test/SemaCXX/crashes.cpp | 106 + clang/test/SemaCXX/cstyle-cast.cpp | 231 ++ clang/test/SemaCXX/cv-unqual-rvalues.cpp | 24 + clang/test/SemaCXX/cxx-member-pointer-op.cpp | 21 + clang/test/SemaCXX/cxx0x-class.cpp | 39 + clang/test/SemaCXX/cxx0x-compat.cpp | 39 + clang/test/SemaCXX/cxx0x-constexpr-const.cpp | 10 + .../test/SemaCXX/cxx0x-cursory-default-delete.cpp | 75 + clang/test/SemaCXX/cxx0x-defaulted-functions.cpp | 53 + clang/test/SemaCXX/cxx0x-delegating-ctors.cpp | 48 + clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp | 131 + .../test/SemaCXX/cxx0x-initializer-aggregates.cpp | 89 + .../test/SemaCXX/cxx0x-initializer-constructor.cpp | 283 ++ .../test/SemaCXX/cxx0x-initializer-references.cpp | 92 + clang/test/SemaCXX/cxx0x-initializer-scalars.cpp | 116 + .../cxx0x-initializer-stdinitializerlist.cpp | 177 ++ clang/test/SemaCXX/cxx0x-nontrivial-union.cpp | 124 + clang/test/SemaCXX/cxx0x-return-init-list.cpp | 16 + .../test/SemaCXX/cxx0x-type-convert-construct.cpp | 21 + clang/test/SemaCXX/cxx11-ast-print.cpp | 41 + clang/test/SemaCXX/cxx11-user-defined-literals.cpp | 137 + clang/test/SemaCXX/cxx98-compat-flags.cpp | 35 + clang/test/SemaCXX/cxx98-compat-pedantic.cpp | 34 + clang/test/SemaCXX/cxx98-compat.cpp | 305 ++ clang/test/SemaCXX/dcl_ambig_res.cpp | 76 + clang/test/SemaCXX/dcl_init_aggr.cpp | 123 + clang/test/SemaCXX/decl-expr-ambiguity.cpp | 72 + clang/test/SemaCXX/decl-init-ref.cpp | 29 + clang/test/SemaCXX/decltype-98.cpp | 3 + clang/test/SemaCXX/decltype-crash.cpp | 7 + .../test/SemaCXX/decltype-overloaded-functions.cpp | 15 + clang/test/SemaCXX/decltype-pr4444.cpp | 6 + clang/test/SemaCXX/decltype-pr4448.cpp | 8 + clang/test/SemaCXX/decltype-this.cpp | 16 + clang/test/SemaCXX/decltype.cpp | 30 + clang/test/SemaCXX/default-arg-special-member.cpp | 12 + .../test/SemaCXX/default-argument-temporaries.cpp | 11 + clang/test/SemaCXX/default-assignment-operator.cpp | 118 + .../SemaCXX/default-constructor-initializers.cpp | 68 + clang/test/SemaCXX/default1.cpp | 52 + clang/test/SemaCXX/default2.cpp | 124 + clang/test/SemaCXX/defaulted-ctor-loop.cpp | 14 + clang/test/SemaCXX/defaulted-private-dtor.cpp | 56 + clang/test/SemaCXX/delete.cpp | 9 + clang/test/SemaCXX/deleted-function.cpp | 57 + clang/test/SemaCXX/deleted-operator.cpp | 18 + clang/test/SemaCXX/dependent-auto.cpp | 59 + .../SemaCXX/dependent-noexcept-unevaluated.cpp | 40 + clang/test/SemaCXX/dependent-types.cpp | 13 + clang/test/SemaCXX/derived-to-base-ambig.cpp | 33 + clang/test/SemaCXX/destructor.cpp | 365 +++ clang/test/SemaCXX/direct-initializer.cpp | 50 + clang/test/SemaCXX/discrim-union.cpp | 118 + clang/test/SemaCXX/do-while-scope.cpp | 8 + clang/test/SemaCXX/dr1301.cpp | 67 + clang/test/SemaCXX/dynamic-cast.cpp | 74 + clang/test/SemaCXX/elaborated-type-specifier.cpp | 48 + clang/test/SemaCXX/empty-class-layout.cpp | 157 + clang/test/SemaCXX/enum-bitfield.cpp | 18 + clang/test/SemaCXX/enum-scoped.cpp | 247 ++ clang/test/SemaCXX/enum-unscoped-nonexistent.cpp | 39 + clang/test/SemaCXX/enum.cpp | 97 + .../test/SemaCXX/exception-spec-no-exceptions.cpp | 33 + clang/test/SemaCXX/exceptions.cpp | 122 + clang/test/SemaCXX/explicit.cpp | 175 ++ clang/test/SemaCXX/expression-traits.cpp | 620 ++++ clang/test/SemaCXX/expressions.cpp | 120 + clang/test/SemaCXX/flexible-array-test.cpp | 69 + clang/test/SemaCXX/fntype-decl.cpp | 20 + clang/test/SemaCXX/for-range-examples.cpp | 182 ++ clang/test/SemaCXX/for-range-no-std.cpp | 43 + clang/test/SemaCXX/for-range-unused.cpp | 21 + clang/test/SemaCXX/format-strings-0x.cpp | 15 + clang/test/SemaCXX/format-strings.cpp | 77 + clang/test/SemaCXX/friend-class-nodecl.cpp | 10 + clang/test/SemaCXX/friend-out-of-line.cpp | 12 + clang/test/SemaCXX/friend.cpp | 140 + clang/test/SemaCXX/function-extern-c.cpp | 38 + .../test/SemaCXX/function-overload-typo-crash.cpp | 28 + clang/test/SemaCXX/function-overloaded-redecl.cpp | 10 + clang/test/SemaCXX/function-redecl.cpp | 100 + clang/test/SemaCXX/function-type-qual.cpp | 28 + clang/test/SemaCXX/functional-cast.cpp | 320 ++ clang/test/SemaCXX/generic-selection.cpp | 46 + clang/test/SemaCXX/gnu-case-ranges.cpp | 24 + clang/test/SemaCXX/goto.cpp | 127 + clang/test/SemaCXX/goto2.cpp | 47 + clang/test/SemaCXX/i-c-e-cxx.cpp | 68 + .../test/SemaCXX/illegal-member-initialization.cpp | 31 + clang/test/SemaCXX/implicit-exception-spec.cpp | 89 + clang/test/SemaCXX/implicit-int.cpp | 5 + clang/test/SemaCXX/implicit-member-functions.cpp | 52 + .../SemaCXX/implicit-virtual-member-functions.cpp | 29 + clang/test/SemaCXX/incomplete-call.cpp | 49 + clang/test/SemaCXX/increment-decrement.cpp | 14 + clang/test/SemaCXX/indirect-goto.cpp | 7 + clang/test/SemaCXX/inherit.cpp | 32 + clang/test/SemaCXX/init-priority-attr.cpp | 36 + clang/test/SemaCXX/inline.cpp | 5 + clang/test/SemaCXX/instantiate-blocks.cpp | 32 + .../SemaCXX/invalid-instantiated-field-decl.cpp | 35 + clang/test/SemaCXX/invalid-member-expr.cpp | 39 + clang/test/SemaCXX/invalid-template-specifier.cpp | 12 + clang/test/SemaCXX/issue547.cpp | 66 + clang/test/SemaCXX/lambda-expressions.cpp | 150 + clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp | 33 + clang/test/SemaCXX/libstdcxx_map_base_hack.cpp | 25 + clang/test/SemaCXX/linkage-spec.cpp | 104 + clang/test/SemaCXX/linkage.cpp | 96 + clang/test/SemaCXX/literal-operators.cpp | 43 + clang/test/SemaCXX/literal-type.cpp | 77 + clang/test/SemaCXX/local-classes.cpp | 41 + clang/test/SemaCXX/lookup-member.cpp | 13 + clang/test/SemaCXX/member-class-11.cpp | 8 + clang/test/SemaCXX/member-expr-anonymous-union.cpp | 9 + clang/test/SemaCXX/member-expr-static.cpp | 19 + clang/test/SemaCXX/member-expr.cpp | 159 + clang/test/SemaCXX/member-init.cpp | 75 + clang/test/SemaCXX/member-location.cpp | 8 + clang/test/SemaCXX/member-name-lookup.cpp | 158 + clang/test/SemaCXX/member-operator-expr.cpp | 29 + clang/test/SemaCXX/member-pointer-ms.cpp | 14 + clang/test/SemaCXX/member-pointer-size.cpp | 15 + clang/test/SemaCXX/member-pointer.cpp | 314 ++ clang/test/SemaCXX/member-pointers-2.cpp | 51 + clang/test/SemaCXX/microsoft-cxx0x.cpp | 8 + clang/test/SemaCXX/missing-header.cpp | 9 + clang/test/SemaCXX/missing-members.cpp | 36 + ...issing-namespace-qualifier-typo-corrections.cpp | 121 + clang/test/SemaCXX/ms-exception-spec.cpp | 3 + clang/test/SemaCXX/namespace-alias.cpp | 127 + clang/test/SemaCXX/namespace.cpp | 92 + clang/test/SemaCXX/neon-vector-types.cpp | 27 + clang/test/SemaCXX/nested-name-spec-locations.cpp | 162 + clang/test/SemaCXX/nested-name-spec.cpp | 288 ++ clang/test/SemaCXX/new-array-size-conv.cpp | 27 + clang/test/SemaCXX/new-delete-0x.cpp | 32 + clang/test/SemaCXX/new-delete-cxx0x.cpp | 26 + .../test/SemaCXX/new-delete-predefined-decl-2.cpp | 13 + clang/test/SemaCXX/new-delete-predefined-decl.cpp | 19 + clang/test/SemaCXX/new-delete.cpp | 501 ++++ clang/test/SemaCXX/no-exceptions.cpp | 35 + clang/test/SemaCXX/no-implicit-builtin-decls.cpp | 7 + clang/test/SemaCXX/non-empty-class-size-zero.cpp | 18 + clang/test/SemaCXX/null_in_arithmetic_ops.cpp | 93 + clang/test/SemaCXX/nullptr-98.cpp | 3 + clang/test/SemaCXX/nullptr.cpp | 185 ++ clang/test/SemaCXX/nullptr_in_arithmetic_ops.cpp | 73 + clang/test/SemaCXX/offsetof.cpp | 75 + clang/test/SemaCXX/operator-arrow-temporary.cpp | 19 + clang/test/SemaCXX/out-of-line-def-mismatch.cpp | 24 + clang/test/SemaCXX/overload-0x.cpp | 11 + clang/test/SemaCXX/overload-call-copycon.cpp | 51 + clang/test/SemaCXX/overload-call.cpp | 570 ++++ clang/test/SemaCXX/overload-decl.cpp | 31 + clang/test/SemaCXX/overload-member-call.cpp | 98 + clang/test/SemaCXX/overload-value-dep-arg.cpp | 13 + .../SemaCXX/overloaded-builtin-operators-0x.cpp | 11 + .../test/SemaCXX/overloaded-builtin-operators.cpp | 239 ++ clang/test/SemaCXX/overloaded-name.cpp | 30 + clang/test/SemaCXX/overloaded-operator-decl.cpp | 50 + clang/test/SemaCXX/overloaded-operator.cpp | 417 +++ clang/test/SemaCXX/pascal-strings.cpp | 6 + clang/test/SemaCXX/pragma-pack.cpp | 34 + clang/test/SemaCXX/pragma-unused.cpp | 8 + clang/test/SemaCXX/pragma-visibility.cpp | 23 + clang/test/SemaCXX/prefetch-enum.cpp | 9 + clang/test/SemaCXX/primary-base.cpp | 11 + clang/test/SemaCXX/pseudo-destructors.cpp | 82 + .../SemaCXX/ptrtomember-overload-resolution.cpp | 44 + clang/test/SemaCXX/ptrtomember.cpp | 33 + clang/test/SemaCXX/qual-id-test.cpp | 149 + clang/test/SemaCXX/qualification-conversion.cpp | 34 + clang/test/SemaCXX/qualified-id-lookup.cpp | 153 + clang/test/SemaCXX/qualified-member-enum.cpp | 10 + clang/test/SemaCXX/qualified-names-diag.cpp | 33 + clang/test/SemaCXX/qualified-names-print.cpp | 15 + clang/test/SemaCXX/redeclared-alias-template.cpp | 23 + clang/test/SemaCXX/redeclared-auto.cpp | 26 + clang/test/SemaCXX/ref-init-ambiguous.cpp | 28 + clang/test/SemaCXX/references.cpp | 139 + clang/test/SemaCXX/reinterpret-cast.cpp | 292 ++ clang/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp | 9 + clang/test/SemaCXX/return-noreturn.cpp | 140 + clang/test/SemaCXX/return-stack-addr.cpp | 141 + clang/test/SemaCXX/return.cpp | 82 + clang/test/SemaCXX/runtimediag-ppe.cpp | 18 + clang/test/SemaCXX/rval-references-examples.cpp | 112 + clang/test/SemaCXX/rval-references.cpp | 94 + clang/test/SemaCXX/scope-check.cpp | 209 ++ clang/test/SemaCXX/shift.cpp | 14 + clang/test/SemaCXX/short-enums.cpp | 17 + clang/test/SemaCXX/short-wchar-sign.cpp | 6 + clang/test/SemaCXX/sourceranges.cpp | 27 + clang/test/SemaCXX/statements.cpp | 22 + clang/test/SemaCXX/static-array-member.cpp | 18 + clang/test/SemaCXX/static-assert.cpp | 36 + clang/test/SemaCXX/static-cast-complete-type.cpp | 13 + clang/test/SemaCXX/static-cast.cpp | 197 ++ clang/test/SemaCXX/static-initializers.cpp | 10 + clang/test/SemaCXX/storage-class.cpp | 7 + clang/test/SemaCXX/string-plus-int.cpp | 66 + clang/test/SemaCXX/struct-class-redecl.cpp | 164 ++ clang/test/SemaCXX/switch-0x.cpp | 11 + clang/test/SemaCXX/switch.cpp | 87 + clang/test/SemaCXX/tag-ambig.cpp | 28 + clang/test/SemaCXX/templated-friend-decl.cpp | 15 + clang/test/SemaCXX/this.cpp | 6 + clang/test/SemaCXX/trailing-return-0x.cpp | 71 + clang/test/SemaCXX/trivial-constructor.cpp | 38 + clang/test/SemaCXX/trivial-destructor.cpp | 38 + clang/test/SemaCXX/type-convert-construct.cpp | 17 + .../test/SemaCXX/type-definition-in-specifier.cpp | 25 + clang/test/SemaCXX/type-dependent-exprs.cpp | 35 + clang/test/SemaCXX/type-formatting.cpp | 10 + clang/test/SemaCXX/type-traits-incomplete.cpp | 8 + clang/test/SemaCXX/type-traits.cpp | 1818 ++++++++++++ clang/test/SemaCXX/typedef-redecl.cpp | 95 + clang/test/SemaCXX/typeid-ref.cpp | 12 + clang/test/SemaCXX/typeid.cpp | 23 + clang/test/SemaCXX/types_compatible_p.cpp | 5 + clang/test/SemaCXX/typo-correction.cpp | 192 ++ clang/test/SemaCXX/unary-real-imag.cpp | 6 + clang/test/SemaCXX/undefined-internal.cpp | 183 ++ clang/test/SemaCXX/underlying_type.cpp | 43 + .../test/SemaCXX/uninit-variables-conditional.cpp | 23 + clang/test/SemaCXX/uninit-variables.cpp | 143 + clang/test/SemaCXX/uninitialized.cpp | 169 ++ clang/test/SemaCXX/unknown-anytype-blocks.cpp | 11 + clang/test/SemaCXX/unknown-anytype.cpp | 47 + clang/test/SemaCXX/unknown-type-name.cpp | 29 + clang/test/SemaCXX/unreachable-catch-clauses.cpp | 14 + clang/test/SemaCXX/unreachable-code.cpp | 58 + clang/test/SemaCXX/unused-functions.cpp | 10 + clang/test/SemaCXX/unused-with-error.cpp | 8 + clang/test/SemaCXX/unused.cpp | 24 + clang/test/SemaCXX/user-defined-conversions.cpp | 99 + clang/test/SemaCXX/using-decl-1.cpp | 120 + clang/test/SemaCXX/using-decl-pr4441.cpp | 8 + clang/test/SemaCXX/using-decl-pr4450.cpp | 15 + clang/test/SemaCXX/using-decl-templates.cpp | 82 + clang/test/SemaCXX/using-directive.cpp | 135 + clang/test/SemaCXX/value-dependent-exprs.cpp | 47 + clang/test/SemaCXX/value-initialization.cpp | 10 + clang/test/SemaCXX/vararg-default-arg.cpp | 10 + clang/test/SemaCXX/vararg-non-pod.cpp | 125 + clang/test/SemaCXX/vector-casts.cpp | 40 + clang/test/SemaCXX/vector-no-lax.cpp | 9 + clang/test/SemaCXX/vector.cpp | 269 ++ clang/test/SemaCXX/virtual-base-used.cpp | 42 + .../virtual-member-functions-key-function.cpp | 29 + clang/test/SemaCXX/virtual-override.cpp | 290 ++ clang/test/SemaCXX/virtuals.cpp | 47 + clang/test/SemaCXX/vla.cpp | 5 + clang/test/SemaCXX/vtable-instantiation.cc | 68 + clang/test/SemaCXX/warn-assignment-condition.cpp | 146 + clang/test/SemaCXX/warn-bad-memaccess.cpp | 117 + clang/test/SemaCXX/warn-bool-conversion.cpp | 24 + clang/test/SemaCXX/warn-cast-align.cpp | 45 + clang/test/SemaCXX/warn-char-subscripts.cpp | 21 + clang/test/SemaCXX/warn-dangling-field.cpp | 37 + clang/test/SemaCXX/warn-deprecated-header.cpp | 6 + clang/test/SemaCXX/warn-empty-body.cpp | 271 ++ clang/test/SemaCXX/warn-enum-compare.cpp | 212 ++ clang/test/SemaCXX/warn-everthing.cpp | 13 + clang/test/SemaCXX/warn-exit-time-destructors.cpp | 27 + clang/test/SemaCXX/warn-func-as-bool.cpp | 40 + clang/test/SemaCXX/warn-global-constructors.cpp | 97 + clang/test/SemaCXX/warn-large-by-value-copy.cpp | 47 + clang/test/SemaCXX/warn-literal-conversion.cpp | 40 + clang/test/SemaCXX/warn-memset-bad-sizeof.cpp | 145 + clang/test/SemaCXX/warn-missing-noreturn.cpp | 125 + clang/test/SemaCXX/warn-missing-prototypes.cpp | 32 + clang/test/SemaCXX/warn-new-overaligned-2.cpp | 22 + clang/test/SemaCXX/warn-new-overaligned-3.cpp | 33 + clang/test/SemaCXX/warn-new-overaligned.cpp | 73 + clang/test/SemaCXX/warn-overloaded-virtual.cpp | 66 + .../warn-pure-virtual-call-from-ctor-dtor.cpp | 14 + .../SemaCXX/warn-reorder-ctor-initialization.cpp | 132 + clang/test/SemaCXX/warn-self-assign.cpp | 47 + clang/test/SemaCXX/warn-self-comparisons.cpp | 5 + clang/test/SemaCXX/warn-shadow.cpp | 83 + clang/test/SemaCXX/warn-sign-conversion.cpp | 80 + clang/test/SemaCXX/warn-string-conversion.cpp | 18 + clang/test/SemaCXX/warn-thread-safety-analysis.cpp | 2243 ++++++++++++++ clang/test/SemaCXX/warn-thread-safety-parsing.cpp | 1345 +++++++++ clang/test/SemaCXX/warn-unreachable.cpp | 109 + clang/test/SemaCXX/warn-unused-comparison.cpp | 94 + clang/test/SemaCXX/warn-unused-filescoped.cpp | 89 + clang/test/SemaCXX/warn-unused-parameters.cpp | 34 + clang/test/SemaCXX/warn-unused-result.cpp | 44 + clang/test/SemaCXX/warn-unused-value.cpp | 51 + clang/test/SemaCXX/warn-unused-variables.cpp | 124 + .../SemaCXX/warn-using-namespace-in-header.cpp | 54 + .../test/SemaCXX/warn-using-namespace-in-header.h | 50 + clang/test/SemaCXX/warn-weak-vtables.cpp | 78 + clang/test/SemaCXX/wchar_t.cpp | 32 + clang/test/SemaCXX/writable-strings-deprecated.cpp | 14 + clang/test/SemaCXX/zero-length-arrays.cpp | 26 + clang/test/SemaObjC/ClassPropertyNotObject.m | 15 + clang/test/SemaObjC/ContClassPropertyLookup.m | 38 + clang/test/SemaObjC/DoubleMethod.m | 19 + clang/test/SemaObjC/Inputs/arc-system-header.h | 52 + clang/test/SemaObjC/NSString-type.m | 10 + clang/test/SemaObjC/access-property-getter.m | 36 + clang/test/SemaObjC/alias-test-1.m | 31 + clang/test/SemaObjC/alias-test-2.m | 17 + clang/test/SemaObjC/arc-bridged-cast.m | 44 + clang/test/SemaObjC/arc-cf.m | 45 + clang/test/SemaObjC/arc-decls.m | 99 + clang/test/SemaObjC/arc-invalid.m | 18 + clang/test/SemaObjC/arc-jump-block.m | 97 + clang/test/SemaObjC/arc-no-runtime.m | 16 + clang/test/SemaObjC/arc-non-pod-memaccess.m | 63 + clang/test/SemaObjC/arc-nsconsumed-errors.m | 20 + clang/test/SemaObjC/arc-objc-lifetime.m | 42 + clang/test/SemaObjC/arc-peformselector.m | 38 + clang/test/SemaObjC/arc-property-decl-attrs.m | 81 + clang/test/SemaObjC/arc-property-lifetime.m | 170 ++ clang/test/SemaObjC/arc-property.m | 57 + clang/test/SemaObjC/arc-readonly-property-ivar-1.m | 29 + clang/test/SemaObjC/arc-readonly-property-ivar.m | 16 + clang/test/SemaObjC/arc-retain-block-property.m | 30 + clang/test/SemaObjC/arc-setter-property-match.m | 35 + clang/test/SemaObjC/arc-system-header.m | 50 + clang/test/SemaObjC/arc-type-conversion.m | 98 + clang/test/SemaObjC/arc-unavailable-for-weakref.m | 64 + .../SemaObjC/arc-unavailable-system-function.m | 13 + clang/test/SemaObjC/arc-unbridged-cast.m | 123 + clang/test/SemaObjC/arc-unsafe-assigns.m | 41 + clang/test/SemaObjC/arc-unsafe_unretained.m | 12 + clang/test/SemaObjC/arc.m | 698 +++++ clang/test/SemaObjC/argument-checking.m | 26 + clang/test/SemaObjC/assign-rvalue-message.m | 24 + clang/test/SemaObjC/at-defs.m | 29 + .../SemaObjC/atomoic-property-synnthesis-rules.m | 377 +++ clang/test/SemaObjC/attr-availability.m | 13 + clang/test/SemaObjC/attr-cleanup.m | 10 + clang/test/SemaObjC/attr-deprecated.m | 123 + clang/test/SemaObjC/attr-malloc.m | 16 + clang/test/SemaObjC/attr-ns-bridged.m | 15 + clang/test/SemaObjC/attr-objc-exception.m | 16 + clang/test/SemaObjC/attr-objc-gc.m | 30 + clang/test/SemaObjC/attr-root-class.m | 16 + clang/test/SemaObjC/autoreleasepool.m | 22 + clang/test/SemaObjC/bad-property-synthesis-crash.m | 23 + clang/test/SemaObjC/bad-receiver-1.m | 21 + clang/test/SemaObjC/block-as-object.m | 20 + clang/test/SemaObjC/block-attr.m | 12 + clang/test/SemaObjC/block-explicit-return-type.m | 77 + clang/test/SemaObjC/block-id-as-block-argtype.m | 27 + clang/test/SemaObjC/block-ivar.m | 19 + clang/test/SemaObjC/block-on-method-param.m | 12 + clang/test/SemaObjC/block-return.m | 13 + clang/test/SemaObjC/block-type-safety.m | 157 + clang/test/SemaObjC/blocks.m | 75 + clang/test/SemaObjC/builtin_objc_assign_ivar.m | 6 + clang/test/SemaObjC/builtin_objc_lib_functions.m | 29 + clang/test/SemaObjC/builtin_objc_msgSend.m | 3 + clang/test/SemaObjC/builtin_objc_nslog.m | 13 + clang/test/SemaObjC/call-super-2.m | 108 + clang/test/SemaObjC/catch-stmt.m | 13 + clang/test/SemaObjC/category-1.m | 101 + clang/test/SemaObjC/category-method-lookup-2.m | 23 + clang/test/SemaObjC/category-method-lookup.m | 31 + clang/test/SemaObjC/check-dup-decl-methods-1.m | 38 + clang/test/SemaObjC/check-dup-objc-decls-1.m | 44 + clang/test/SemaObjC/class-bitfield.m | 37 + clang/test/SemaObjC/class-conforming-protocol-1.m | 20 + clang/test/SemaObjC/class-conforming-protocol-2.m | 23 + clang/test/SemaObjC/class-def-test-1.m | 35 + .../class-extension-after-implementation.m | 11 + clang/test/SemaObjC/class-extension-dup-methods.m | 15 + clang/test/SemaObjC/class-getter-using-dotsyntax.m | 39 + clang/test/SemaObjC/class-impl-1.m | 40 + .../test/SemaObjC/class-message-protocol-lookup.m | 34 + clang/test/SemaObjC/class-method-lookup.m | 46 + clang/test/SemaObjC/class-method-self.m | 26 + clang/test/SemaObjC/class-property-access.m | 12 + clang/test/SemaObjC/class-proto-1.m | 36 + clang/test/SemaObjC/class-protocol-method-match.m | 48 + clang/test/SemaObjC/class-protocol.m | 6 + clang/test/SemaObjC/class-unavail-warning.m | 42 + clang/test/SemaObjC/cocoa-api-usage.m | 88 + clang/test/SemaObjC/cocoa-api-usage.m.fixed | 88 + clang/test/SemaObjC/cocoa.m | 5 + clang/test/SemaObjC/compare-qualified-class.m | 30 + clang/test/SemaObjC/compare-qualified-id.m | 34 + .../SemaObjC/compatible-protocol-qualified-types.m | 76 + clang/test/SemaObjC/compound-init.m | 7 + clang/test/SemaObjC/comptypes-1.m | 89 + clang/test/SemaObjC/comptypes-10.m | 52 + clang/test/SemaObjC/comptypes-2.m | 37 + clang/test/SemaObjC/comptypes-3.m | 64 + clang/test/SemaObjC/comptypes-4.m | 25 + clang/test/SemaObjC/comptypes-5.m | 44 + clang/test/SemaObjC/comptypes-6.m | 16 + clang/test/SemaObjC/comptypes-7.m | 75 + clang/test/SemaObjC/comptypes-8.m | 12 + clang/test/SemaObjC/comptypes-9.m | 86 + clang/test/SemaObjC/comptypes-a.m | 34 + clang/test/SemaObjC/comptypes-legal.m | 37 + clang/test/SemaObjC/conditional-expr-2.m | 29 + clang/test/SemaObjC/conditional-expr-3.m | 67 + clang/test/SemaObjC/conditional-expr-4.m | 80 + clang/test/SemaObjC/conditional-expr-5.m | 27 + clang/test/SemaObjC/conditional-expr-6.m | 51 + clang/test/SemaObjC/conditional-expr-7.m | 30 + clang/test/SemaObjC/conditional-expr-8.m | 25 + clang/test/SemaObjC/conditional-expr.m | 119 + clang/test/SemaObjC/conflict-atomic-property.m | 10 + clang/test/SemaObjC/conflict-nonfragile-abi2.m | 36 + clang/test/SemaObjC/conflicting-ivar-test-1.m | 86 + clang/test/SemaObjC/continuation-class-err.m | 51 + clang/test/SemaObjC/continuation-class-property.m | 63 + clang/test/SemaObjC/crash-label.m | 9 + clang/test/SemaObjC/custom-atomic-property.m | 20 + clang/test/SemaObjC/debugger-cast-result-to-id.m | 16 + clang/test/SemaObjC/debugger-support.m | 14 + clang/test/SemaObjC/default-synthesize-1.m | 116 + clang/test/SemaObjC/default-synthesize-2.m | 116 + clang/test/SemaObjC/default-synthesize-3.m | 41 + clang/test/SemaObjC/default-synthesize.m | 140 + clang/test/SemaObjC/deref-interface.m | 12 + .../test/SemaObjC/direct-synthesized-ivar-access.m | 15 + clang/test/SemaObjC/dist-object-modifiers.m | 21 + clang/test/SemaObjC/duplicate-ivar-check.m | 22 + .../SemaObjC/duplicate-ivar-in-class-extension.m | 32 + .../SemaObjC/duplicate-property-class-extension.m | 24 + clang/test/SemaObjC/duplicate-property.m | 8 + clang/test/SemaObjC/enhanced-proto-2.m | 21 + clang/test/SemaObjC/enum-fixed-type.m | 37 + .../SemaObjC/err-ivar-access-in-class-method.m | 26 + clang/test/SemaObjC/error-implicit-property.m | 30 + clang/test/SemaObjC/error-missing-getter.m | 19 + clang/test/SemaObjC/error-property-gc-attr.m | 28 + clang/test/SemaObjC/exprs.m | 44 + clang/test/SemaObjC/foreach.m | 57 + clang/test/SemaObjC/format-arg-attribute.m | 27 + clang/test/SemaObjC/format-strings-objc.m | 188 ++ clang/test/SemaObjC/forward-class-1.m | 58 + clang/test/SemaObjC/forward-class-receiver.m | 13 + clang/test/SemaObjC/forward-class-redeclare.m | 29 + clang/test/SemaObjC/gc-attributes.m | 22 + clang/test/SemaObjC/gcc-cast-ext.m | 24 + clang/test/SemaObjC/ibaction.m | 17 + clang/test/SemaObjC/iboutletcollection-attr.m | 43 + clang/test/SemaObjC/id-isa-ref.m | 35 + clang/test/SemaObjC/id.m | 21 + clang/test/SemaObjC/id_builtin.m | 10 + clang/test/SemaObjC/idiomatic-parentheses.m | 35 + .../SemaObjC/ignore-qualifier-on-qualified-id.m | 21 + clang/test/SemaObjC/ignore-weakimport-method.m | 6 + clang/test/SemaObjC/illegal-nonarc-bridged-cast.m | 44 + .../incompatible-protocol-qualified-types.m | 40 + clang/test/SemaObjC/incomplete-implementation.m | 40 + clang/test/SemaObjC/inst-method-lookup-in-root.m | 27 + clang/test/SemaObjC/instancetype.m | 190 ++ clang/test/SemaObjC/interface-1.m | 38 + clang/test/SemaObjC/interface-layout-2.m | 16 + clang/test/SemaObjC/interface-layout.m | 27 + clang/test/SemaObjC/interface-scope-2.m | 128 + clang/test/SemaObjC/interface-scope.m | 12 + clang/test/SemaObjC/interface-tu-variable.m | 26 + clang/test/SemaObjC/invalid-code.m | 54 + clang/test/SemaObjC/invalid-objc-decls-1.m | 42 + clang/test/SemaObjC/invalid-receiver.m | 9 + clang/test/SemaObjC/invalid-typename.m | 12 + clang/test/SemaObjC/ivar-access-package.m | 47 + clang/test/SemaObjC/ivar-access-tests.m | 122 + .../test/SemaObjC/ivar-in-class-extension-error.m | 15 + clang/test/SemaObjC/ivar-in-class-extension.m | 42 + clang/test/SemaObjC/ivar-in-implementations.m | 39 + .../test/SemaObjC/ivar-lookup-resolution-builtin.m | 40 + clang/test/SemaObjC/ivar-lookup.m | 82 + clang/test/SemaObjC/ivar-ref-misuse.m | 42 + clang/test/SemaObjC/ivar-sem-check-1.m | 19 + clang/test/SemaObjC/ivar-sem-check-2.m | 23 + clang/test/SemaObjC/legacy-implementation-1.m | 11 + clang/test/SemaObjC/message.m | 100 + clang/test/SemaObjC/method-arg-qualifier-warning.m | 20 + clang/test/SemaObjC/method-attributes.m | 57 + clang/test/SemaObjC/method-bad-param.m | 44 + clang/test/SemaObjC/method-conflict-1.m | 83 + clang/test/SemaObjC/method-conflict-2.m | 44 + clang/test/SemaObjC/method-conflict.m | 66 + clang/test/SemaObjC/method-def-1.m | 40 + clang/test/SemaObjC/method-def-2.m | 19 + clang/test/SemaObjC/method-encoding-2.m | 12 + .../test/SemaObjC/method-in-class-extension-impl.m | 20 + clang/test/SemaObjC/method-lookup-2.m | 63 + clang/test/SemaObjC/method-lookup-3.m | 73 + clang/test/SemaObjC/method-lookup-4.m | 62 + clang/test/SemaObjC/method-lookup-5.m | 10 + clang/test/SemaObjC/method-lookup.m | 35 + clang/test/SemaObjC/method-no-context.m | 4 + clang/test/SemaObjC/method-not-defined.m | 13 + clang/test/SemaObjC/method-prototype-scope.m | 38 + clang/test/SemaObjC/method-sentinel-attr.m | 49 + clang/test/SemaObjC/method-typecheck-1.m | 36 + clang/test/SemaObjC/method-typecheck-2.m | 25 + clang/test/SemaObjC/method-typecheck-3.m | 22 + clang/test/SemaObjC/method-undef-category-warn-1.m | 74 + .../test/SemaObjC/method-undef-extension-warn-1.m | 24 + clang/test/SemaObjC/method-undefined-warn-1.m | 56 + clang/test/SemaObjC/method-unused-attribute.m | 15 + clang/test/SemaObjC/method-warn-unused-attribute.m | 16 + clang/test/SemaObjC/missing-atend-metadata.m | 22 + clang/test/SemaObjC/missing-method-context.m | 4 + clang/test/SemaObjC/missing-method-return-type.m | 11 + .../SemaObjC/narrow-property-type-in-cont-class.m | 19 + clang/test/SemaObjC/nested-typedef-decl.m | 21 + clang/test/SemaObjC/newproperty-class-method-1.m | 62 + clang/test/SemaObjC/no-gc-weak-test.m | 28 + clang/test/SemaObjC/no-ivar-access-control.m | 70 + clang/test/SemaObjC/no-objc-exceptions.m | 13 + clang/test/SemaObjC/no-protocol-option-tests.m | 32 + clang/test/SemaObjC/no-warn-qual-mismatch.m | 16 + clang/test/SemaObjC/no-warn-synth-protocol-meth.m | 17 + clang/test/SemaObjC/no-warn-unimpl-method.m | 42 + clang/test/SemaObjC/no-warning-unavail-unimp.m | 12 + clang/test/SemaObjC/nonnull.h | 2 + clang/test/SemaObjC/nonnull.m | 96 + clang/test/SemaObjC/nsobject-attribute-1.m | 48 + clang/test/SemaObjC/nsobject-attribute.m | 54 + clang/test/SemaObjC/objc-array-literal.m | 41 + clang/test/SemaObjC/objc-buffered-methods.m | 25 + .../test/SemaObjC/objc-container-subscripting-1.m | 23 + .../test/SemaObjC/objc-container-subscripting-2.m | 30 + .../test/SemaObjC/objc-container-subscripting-3.m | 25 + clang/test/SemaObjC/objc-container-subscripting.m | 42 + clang/test/SemaObjC/objc-cstyle-args-in-methods.m | 20 + clang/test/SemaObjC/objc-dictionary-literal.m | 34 + clang/test/SemaObjC/objc-literal-nsnumber.m | 85 + clang/test/SemaObjC/objc-literal-sig.m | 40 + .../test/SemaObjC/objc-qualified-property-lookup.m | 21 + clang/test/SemaObjC/objc-string-constant.m | 39 + clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m | 29 + clang/test/SemaObjC/objc2-warn-weak-decl.m | 11 + clang/test/SemaObjC/pedantic-dynamic-test.m | 16 + clang/test/SemaObjC/pragma-pack.m | 16 + clang/test/SemaObjC/property-10.m | 48 + clang/test/SemaObjC/property-11.m | 36 + clang/test/SemaObjC/property-12.m | 32 + clang/test/SemaObjC/property-13.m | 78 + clang/test/SemaObjC/property-2.m | 63 + clang/test/SemaObjC/property-3.m | 14 + clang/test/SemaObjC/property-4.m | 29 + clang/test/SemaObjC/property-5.m | 34 + clang/test/SemaObjC/property-6.m | 69 + clang/test/SemaObjC/property-7.m | 34 + clang/test/SemaObjC/property-8.m | 74 + clang/test/SemaObjC/property-9-impl-method.m | 95 + clang/test/SemaObjC/property-9.m | 108 + clang/test/SemaObjC/property-and-class-extension.m | 36 + clang/test/SemaObjC/property-and-ivar-use.m | 36 + clang/test/SemaObjC/property-category-1.m | 53 + clang/test/SemaObjC/property-category-2.m | 20 + clang/test/SemaObjC/property-category-3.m | 31 + clang/test/SemaObjC/property-category-4.m | 18 + clang/test/SemaObjC/property-category-impl.m | 31 + clang/test/SemaObjC/property-dot-receiver.m | 22 + .../test/SemaObjC/property-error-readonly-assign.m | 44 + clang/test/SemaObjC/property-expression-error.m | 23 + clang/test/SemaObjC/property-impl-misuse.m | 36 + clang/test/SemaObjC/property-in-class-extension.m | 50 + clang/test/SemaObjC/property-inherited.m | 46 + clang/test/SemaObjC/property-ivar-mismatch.m | 14 + clang/test/SemaObjC/property-lookup-in-id.m | 33 + clang/test/SemaObjC/property-method-lookup-impl.m | 24 + clang/test/SemaObjC/property-missing.m | 34 + clang/test/SemaObjC/property-nonfragile-abi.m | 21 + clang/test/SemaObjC/property-noprotocol-warning.m | 36 + clang/test/SemaObjC/property-not-lvalue.m | 34 + .../property-ns-returns-not-retained-attr.m | 21 + .../SemaObjC/property-redundant-decl-accessor.m | 18 + clang/test/SemaObjC/property-typecheck-1.m | 101 + clang/test/SemaObjC/property-user-setter.m | 104 + clang/test/SemaObjC/property-weak.m | 5 + clang/test/SemaObjC/property.m | 83 + clang/test/SemaObjC/props-on-prots.m | 65 + clang/test/SemaObjC/protocol-archane.m | 42 + clang/test/SemaObjC/protocol-attribute.m | 49 + clang/test/SemaObjC/protocol-expr-1.m | 15 + clang/test/SemaObjC/protocol-expr-neg-1.m | 19 + clang/test/SemaObjC/protocol-id-test-1.m | 16 + clang/test/SemaObjC/protocol-id-test-2.m | 12 + clang/test/SemaObjC/protocol-id-test-3.m | 94 + .../SemaObjC/protocol-implementation-inherited.m | 56 + .../SemaObjC/protocol-implementing-class-methods.m | 41 + clang/test/SemaObjC/protocol-lookup-2.m | 33 + clang/test/SemaObjC/protocol-lookup.m | 51 + .../protocol-qualified-class-unsupported.m | 40 + clang/test/SemaObjC/protocol-typecheck.m | 25 + clang/test/SemaObjC/protocol-warn.m | 55 + clang/test/SemaObjC/protocols.m | 67 + clang/test/SemaObjC/provisional-ivar-lookup.m | 43 + .../SemaObjC/qualified-protocol-method-conflicts.m | 39 + clang/test/SemaObjC/rdar6248119.m | 27 + clang/test/SemaObjC/rdr-6211479-array-property.m | 8 + clang/test/SemaObjC/receiver-forward-class.m | 19 + .../test/SemaObjC/related-result-type-inference.m | 180 ++ clang/test/SemaObjC/restrict-id-type.m | 9 + clang/test/SemaObjC/return.m | 50 + clang/test/SemaObjC/scope-check.m | 103 + clang/test/SemaObjC/selector-1.m | 28 + clang/test/SemaObjC/selector-2.m | 14 + clang/test/SemaObjC/selector-3.m | 54 + clang/test/SemaObjC/selector-error.m | 20 + clang/test/SemaObjC/selector-overload.m | 47 + clang/test/SemaObjC/self-assign.m | 14 + clang/test/SemaObjC/self-declared-in-block.m | 52 + clang/test/SemaObjC/self-in-function.m | 26 + clang/test/SemaObjC/setter-dotsyntax.m | 19 + clang/test/SemaObjC/severe-syntax-error.m | 23 + clang/test/SemaObjC/sizeof-interface.m | 90 + clang/test/SemaObjC/special-dep-unavail-warning.m | 55 + clang/test/SemaObjC/stand-alone-implementation.m | 12 + clang/test/SemaObjC/static-ivar-ref-1.m | 30 + clang/test/SemaObjC/stmts.m | 18 + clang/test/SemaObjC/string.m | 15 + clang/test/SemaObjC/super-cat-prot.m | 50 + .../SemaObjC/super-class-protocol-conformance.m | 63 + clang/test/SemaObjC/super-property-message-expr.m | 21 + clang/test/SemaObjC/super-property-notation.m | 30 + clang/test/SemaObjC/super.m | 87 + clang/test/SemaObjC/synchronized.m | 23 + clang/test/SemaObjC/synth-provisional-ivars-1.m | 28 + clang/test/SemaObjC/synth-provisional-ivars.m | 50 + clang/test/SemaObjC/synthesize-setter-contclass.m | 24 + clang/test/SemaObjC/synthesized-ivar.m | 61 + clang/test/SemaObjC/transparent-union.m | 22 + clang/test/SemaObjC/try-catch.m | 47 + clang/test/SemaObjC/typedef-class.m | 78 + clang/test/SemaObjC/ucn-objc-string.m | 13 + clang/test/SemaObjC/undeclared-selector.m | 45 + clang/test/SemaObjC/undef-class-messagin-error.m | 13 + clang/test/SemaObjC/undef-protocol-methods-1.m | 37 + clang/test/SemaObjC/undef-superclass-1.m | 36 + clang/test/SemaObjC/undefined-protocol-type-1.m | 9 + clang/test/SemaObjC/unimplemented-protocol-prop.m | 39 + clang/test/SemaObjC/uninit-variables.m | 27 + clang/test/SemaObjC/unknown-anytype.m | 29 + .../SemaObjC/unqualified-to-qualified-class-warn.m | 72 + clang/test/SemaObjC/unused.m | 53 + clang/test/SemaObjC/va-method-1.m | 17 + .../test/SemaObjC/warn-assign-property-nscopying.m | 16 + .../SemaObjC/warn-deprecated-implementations.m | 46 + .../SemaObjC/warn-forward-class-attr-deprecated.m | 24 + .../test/SemaObjC/warn-implicit-atomic-property.m | 13 + .../SemaObjC/warn-incompatible-builtin-types.m | 42 + clang/test/SemaObjC/warn-missing-super.m | 58 + clang/test/SemaObjC/warn-retain-cycle.m | 125 + clang/test/SemaObjC/warn-selector-selection.m | 14 + clang/test/SemaObjC/warn-strict-selector-match.m | 75 + .../SemaObjC/warn-superclass-method-mismatch.m | 50 + clang/test/SemaObjC/warn-unreachable.m | 17 + clang/test/SemaObjC/warn-unused-exception-param.m | 4 + clang/test/SemaObjC/warn-weak-field.m | 25 + clang/test/SemaObjC/warn-write-strings.m | 4 + clang/test/SemaObjC/weak-attr-ivar.m | 84 + clang/test/SemaObjC/weak-property.m | 24 + clang/test/SemaObjC/weak-receiver-warn.m | 19 + .../SemaObjC/writable-property-in-superclass.m | 17 + clang/test/SemaObjCXX/Inputs/arc-system-header.h | 14 + clang/test/SemaObjCXX/NSString-type.mm | 10 + clang/test/SemaObjCXX/arc-0x.mm | 53 + clang/test/SemaObjCXX/arc-bool-conversion.mm | 7 + clang/test/SemaObjCXX/arc-bridged-cast.mm | 36 + clang/test/SemaObjCXX/arc-libstdcxx.mm | 10 + clang/test/SemaObjCXX/arc-memfunc.mm | 15 + clang/test/SemaObjCXX/arc-non-pod.mm | 116 + clang/test/SemaObjCXX/arc-nsconsumed-errors.mm | 20 + clang/test/SemaObjCXX/arc-object-init-destroy.mm | 52 + clang/test/SemaObjCXX/arc-overloading.mm | 202 ++ clang/test/SemaObjCXX/arc-ppe.mm | 16 + clang/test/SemaObjCXX/arc-system-header.mm | 10 + clang/test/SemaObjCXX/arc-templates.mm | 268 ++ clang/test/SemaObjCXX/arc-type-conversion.mm | 218 ++ clang/test/SemaObjCXX/arc-type-traits.mm | 90 + .../test/SemaObjCXX/arc-unavailable-for-weakref.mm | 50 + clang/test/SemaObjCXX/arc-unbridged-cast.mm | 110 + clang/test/SemaObjCXX/argument-dependent-lookup.mm | 19 + clang/test/SemaObjCXX/blocks.mm | 146 + clang/test/SemaObjCXX/category-lookup.mm | 10 + .../test/SemaObjCXX/composite-objc-pointertype.mm | 18 + clang/test/SemaObjCXX/conditional-expr.mm | 67 + clang/test/SemaObjCXX/const-cast.mm | 13 + clang/test/SemaObjCXX/conversion-ranking.mm | 89 + .../SemaObjCXX/conversion-to-objc-pointer-2.mm | 88 + .../test/SemaObjCXX/conversion-to-objc-pointer.mm | 50 + clang/test/SemaObjCXX/cstyle-block-pointer-cast.mm | 42 + clang/test/SemaObjCXX/cstyle-cast.mm | 40 + clang/test/SemaObjCXX/cxxoperator-selector.mm | 24 + .../test/SemaObjCXX/debugger-cast-result-to-id.mm | 17 + clang/test/SemaObjCXX/deduction.mm | 65 + clang/test/SemaObjCXX/exceptions-fragile.mm | 12 + clang/test/SemaObjCXX/expr-objcxx.mm | 4 + clang/test/SemaObjCXX/foreach-block.mm | 14 + clang/test/SemaObjCXX/fragile-abi-object-assign.m | 13 + .../test/SemaObjCXX/function-pointer-void-star.mm | 9 + clang/test/SemaObjCXX/gc-attributes.mm | 22 + clang/test/SemaObjCXX/goto.mm | 16 + clang/test/SemaObjCXX/instantiate-expr.mm | 75 + clang/test/SemaObjCXX/instantiate-message.mm | 50 + clang/test/SemaObjCXX/instantiate-method-return.mm | 26 + clang/test/SemaObjCXX/instantiate-stmt.mm | 78 + clang/test/SemaObjCXX/ivar-construct.mm | 37 + clang/test/SemaObjCXX/ivar-lookup.mm | 18 + clang/test/SemaObjCXX/ivar-reference-type.mm | 5 + clang/test/SemaObjCXX/ivar-struct.mm | 7 + clang/test/SemaObjCXX/linkage-spec.mm | 21 + clang/test/SemaObjCXX/literals.mm | 187 ++ clang/test/SemaObjCXX/message.mm | 127 + clang/test/SemaObjCXX/namespace-lookup.mm | 14 + clang/test/SemaObjCXX/null_objc_pointer.mm | 13 + clang/test/SemaObjCXX/nullptr.mm | 16 + .../test/SemaObjCXX/objc-container-subscripting.mm | 138 + .../test/SemaObjCXX/objc-decls-inside-namespace.mm | 32 + clang/test/SemaObjCXX/objc-extern-c.mm | 30 + clang/test/SemaObjCXX/objc-pointer-conv.mm | 48 + .../SemaObjCXX/objc2-merge-gc-attribue-decl.mm | 51 + clang/test/SemaObjCXX/overload-1.mm | 25 + clang/test/SemaObjCXX/overload-gc.mm | 24 + clang/test/SemaObjCXX/overload.mm | 179 ++ clang/test/SemaObjCXX/parameters.mm | 17 + .../SemaObjCXX/pointer-to-objc-pointer-conv.mm | 49 + clang/test/SemaObjCXX/propert-dot-error.mm | 69 + clang/test/SemaObjCXX/properties.mm | 108 + clang/test/SemaObjCXX/property-reference.mm | 59 + clang/test/SemaObjCXX/property-synthesis-error.mm | 74 + clang/test/SemaObjCXX/property-type-mismatch.mm | 19 + clang/test/SemaObjCXX/protocol-lookup.mm | 56 + clang/test/SemaObjCXX/references.mm | 62 + .../reinterpret-cast-objc-pointertype.mm | 23 + .../SemaObjCXX/related-result-type-inference.mm | 71 + clang/test/SemaObjCXX/reserved-keyword-methods.mm | 42 + .../test/SemaObjCXX/standard-conversion-to-bool.mm | 12 + clang/test/SemaObjCXX/static-cast.mm | 29 + clang/test/SemaObjCXX/unknown-anytype.mm | 9 + clang/test/SemaObjCXX/vararg-non-pod.mm | 32 + clang/test/SemaObjCXX/vla.mm | 12 + clang/test/SemaObjCXX/void_to_obj.mm | 26 + .../test/SemaObjCXX/warn-strict-selector-match.mm | 18 + clang/test/SemaOpenCL/address-spaces.cl | 13 + clang/test/SemaOpenCL/cond.cl | 5 + clang/test/SemaOpenCL/extension-fp64.cl | 19 + clang/test/SemaOpenCL/init.cl | 15 + clang/test/SemaOpenCL/vec_compare.cl | 11 + clang/test/SemaOpenCL/vec_step.cl | 32 + clang/test/SemaOpenCL/vector_conv_invalid.cl | 14 + clang/test/SemaOpenCL/vector_literals_const.cl | 26 + clang/test/SemaOpenCL/vector_literals_invalid.cl | 13 + clang/test/SemaTemplate/ackermann.cpp | 38 + clang/test/SemaTemplate/address-spaces.cpp | 86 + clang/test/SemaTemplate/alias-church-numerals.cpp | 34 + clang/test/SemaTemplate/alias-nested-nontag.cpp | 6 + .../SemaTemplate/alias-template-template-param.cpp | 7 + clang/test/SemaTemplate/alias-templates.cpp | 102 + clang/test/SemaTemplate/ambiguous-ovl-print.cpp | 9 + clang/test/SemaTemplate/anonymous-union.cpp | 40 + clang/test/SemaTemplate/array-to-pointer-decay.cpp | 25 + clang/test/SemaTemplate/atomics.cpp | 16 + clang/test/SemaTemplate/attributes.cpp | 34 + clang/test/SemaTemplate/canonical-expr-type-0x.cpp | 25 + clang/test/SemaTemplate/canonical-expr-type.cpp | 53 + .../class-template-ctor-initializer.cpp | 55 + clang/test/SemaTemplate/class-template-decl.cpp | 97 + clang/test/SemaTemplate/class-template-id-2.cpp | 24 + clang/test/SemaTemplate/class-template-id.cpp | 47 + clang/test/SemaTemplate/class-template-spec.cpp | 121 + clang/test/SemaTemplate/constexpr-instantiate.cpp | 77 + clang/test/SemaTemplate/constructor-template.cpp | 128 + clang/test/SemaTemplate/copy-ctor-assign.cpp | 52 + clang/test/SemaTemplate/crash-10438657.cpp | 15 + clang/test/SemaTemplate/crash-8204126.cpp | 6 + clang/test/SemaTemplate/current-instantiation.cpp | 237 ++ clang/test/SemaTemplate/deduction-crash.cpp | 89 + clang/test/SemaTemplate/deduction.cpp | 164 ++ .../test/SemaTemplate/default-arguments-cxx0x.cpp | 26 + clang/test/SemaTemplate/default-arguments.cpp | 138 + .../test/SemaTemplate/default-expr-arguments-2.cpp | 19 + clang/test/SemaTemplate/default-expr-arguments.cpp | 305 ++ .../test/SemaTemplate/delegating-constructors.cpp | 31 + clang/test/SemaTemplate/dependent-base-classes.cpp | 137 + .../SemaTemplate/dependent-base-member-init.cpp | 68 + .../dependent-class-member-operator.cpp | 11 + clang/test/SemaTemplate/dependent-expr.cpp | 73 + clang/test/SemaTemplate/dependent-names-no-std.cpp | 21 + clang/test/SemaTemplate/dependent-names.cpp | 326 ++ clang/test/SemaTemplate/dependent-sized_array.cpp | 17 + .../SemaTemplate/dependent-template-recover.cpp | 60 + .../test/SemaTemplate/dependent-type-identity.cpp | 100 + clang/test/SemaTemplate/destructor-template.cpp | 59 + .../SemaTemplate/elaborated-type-specifier.cpp | 40 + clang/test/SemaTemplate/enum-argument.cpp | 36 + clang/test/SemaTemplate/enum-forward.cpp | 8 + clang/test/SemaTemplate/example-dynarray.cpp | 177 ++ clang/test/SemaTemplate/example-typelist.cpp | 98 + clang/test/SemaTemplate/explicit-instantiation.cpp | 107 + .../explicit-specialization-member.cpp | 21 + clang/test/SemaTemplate/ext-vector-type.cpp | 94 + clang/test/SemaTemplate/extern-templates.cpp | 64 + clang/test/SemaTemplate/fibonacci.cpp | 66 + clang/test/SemaTemplate/friend-template.cpp | 245 ++ clang/test/SemaTemplate/friend.cpp | 33 + clang/test/SemaTemplate/fun-template-def.cpp | 48 + .../function-template-specialization.cpp | 48 + .../test/SemaTemplate/implicit-instantiation-1.cpp | 25 + .../SemaTemplate/inject-templated-friend-post.cpp | 72 + .../test/SemaTemplate/inject-templated-friend.cpp | 48 + clang/test/SemaTemplate/injected-class-name.cpp | 62 + .../SemaTemplate/instantiate-anonymous-union.cpp | 89 + clang/test/SemaTemplate/instantiate-array.cpp | 28 + clang/test/SemaTemplate/instantiate-attr.cpp | 26 + clang/test/SemaTemplate/instantiate-c99.cpp | 81 + clang/test/SemaTemplate/instantiate-call.cpp | 51 + clang/test/SemaTemplate/instantiate-case.cpp | 21 + clang/test/SemaTemplate/instantiate-cast.cpp | 117 + clang/test/SemaTemplate/instantiate-clang.cpp | 35 + clang/test/SemaTemplate/instantiate-complete.cpp | 146 + clang/test/SemaTemplate/instantiate-decl-dtor.cpp | 11 + clang/test/SemaTemplate/instantiate-decl-init.cpp | 46 + .../test/SemaTemplate/instantiate-declref-ice.cpp | 34 + clang/test/SemaTemplate/instantiate-declref.cpp | 117 + clang/test/SemaTemplate/instantiate-deeply.cpp | 36 + .../instantiate-default-assignment-operator.cpp | 17 + .../instantiate-dependent-nested-name.cpp | 7 + .../instantiate-elab-type-specifier.cpp | 13 + clang/test/SemaTemplate/instantiate-enum-2.cpp | 9 + clang/test/SemaTemplate/instantiate-enum.cpp | 27 + .../instantiate-exception-spec-cxx11.cpp | 133 + .../SemaTemplate/instantiate-exception-spec.cpp | 11 + clang/test/SemaTemplate/instantiate-expr-1.cpp | 192 ++ clang/test/SemaTemplate/instantiate-expr-2.cpp | 245 ++ clang/test/SemaTemplate/instantiate-expr-3.cpp | 119 + clang/test/SemaTemplate/instantiate-expr-4.cpp | 354 +++ clang/test/SemaTemplate/instantiate-expr-5.cpp | 38 + clang/test/SemaTemplate/instantiate-expr-basic.cpp | 17 + clang/test/SemaTemplate/instantiate-field.cpp | 104 + .../test/SemaTemplate/instantiate-friend-class.cpp | 9 + clang/test/SemaTemplate/instantiate-function-1.cpp | 249 ++ clang/test/SemaTemplate/instantiate-function-1.mm | 17 + clang/test/SemaTemplate/instantiate-function-2.cpp | 66 + .../SemaTemplate/instantiate-function-params.cpp | 90 + clang/test/SemaTemplate/instantiate-init.cpp | 109 + clang/test/SemaTemplate/instantiate-invalid.cpp | 52 + .../test/SemaTemplate/instantiate-local-class.cpp | 67 + .../test/SemaTemplate/instantiate-member-class.cpp | 142 + .../test/SemaTemplate/instantiate-member-expr.cpp | 68 + .../instantiate-member-initializers.cpp | 27 + .../SemaTemplate/instantiate-member-pointers.cpp | 67 + .../SemaTemplate/instantiate-member-template.cpp | 261 ++ clang/test/SemaTemplate/instantiate-method.cpp | 177 ++ .../instantiate-non-dependent-types.cpp | 14 + .../instantiate-non-type-template-parameter.cpp | 55 + clang/test/SemaTemplate/instantiate-objc-1.mm | 48 + .../instantiate-overload-candidates.cpp | 21 + .../SemaTemplate/instantiate-overloaded-arrow.cpp | 20 + clang/test/SemaTemplate/instantiate-self.cpp | 89 + clang/test/SemaTemplate/instantiate-sizeof.cpp | 10 + clang/test/SemaTemplate/instantiate-static-var.cpp | 116 + clang/test/SemaTemplate/instantiate-subscript.cpp | 41 + .../instantiate-template-template-parm.cpp | 97 + clang/test/SemaTemplate/instantiate-try-catch.cpp | 31 + clang/test/SemaTemplate/instantiate-type.cpp | 17 + clang/test/SemaTemplate/instantiate-typedef.cpp | 15 + clang/test/SemaTemplate/instantiate-typeof.cpp | 10 + clang/test/SemaTemplate/instantiate-using-decl.cpp | 82 + .../test/SemaTemplate/instantiation-backtrace.cpp | 32 + .../test/SemaTemplate/instantiation-default-1.cpp | 102 + .../test/SemaTemplate/instantiation-default-2.cpp | 18 + .../test/SemaTemplate/instantiation-default-3.cpp | 21 + clang/test/SemaTemplate/instantiation-depth.cpp | 13 + clang/test/SemaTemplate/instantiation-order.cpp | 15 + clang/test/SemaTemplate/issue150.cpp | 107 + clang/test/SemaTemplate/lookup-dependent-bases.cpp | 19 + clang/test/SemaTemplate/member-access-ambig.cpp | 45 + clang/test/SemaTemplate/member-access-expr.cpp | 149 + .../test/SemaTemplate/member-function-template.cpp | 103 + .../member-inclass-init-value-dependent.cpp | 18 + clang/test/SemaTemplate/member-initializers.cpp | 13 + .../SemaTemplate/member-template-access-expr.cpp | 144 + clang/test/SemaTemplate/metafun-apply.cpp | 40 + .../SemaTemplate/missing-class-keyword-crash.cpp | 7 + .../ms-function-specialization-class-scope.cpp | 71 + clang/test/SemaTemplate/ms-if-exists.cpp | 68 + .../ms-lookup-template-base-classes.cpp | 145 + .../test/SemaTemplate/nested-incomplete-class.cpp | 21 + clang/test/SemaTemplate/nested-linkage.cpp | 3 + .../SemaTemplate/nested-name-spec-template.cpp | 142 + clang/test/SemaTemplate/nested-template.cpp | 157 + .../SemaTemplate/operator-function-id-template.cpp | 28 + clang/test/SemaTemplate/operator-template.cpp | 18 + clang/test/SemaTemplate/overload-candidates.cpp | 40 + clang/test/SemaTemplate/overload-uneval.cpp | 42 + .../test/SemaTemplate/partial-spec-instantiate.cpp | 50 + clang/test/SemaTemplate/pragma-ms_struct.cpp | 10 + clang/test/SemaTemplate/qualified-id.cpp | 56 + clang/test/SemaTemplate/qualified-names-diag.cpp | 16 + clang/test/SemaTemplate/rdar9173693.cpp | 6 + clang/test/SemaTemplate/recovery-crash.cpp | 19 + .../recursive-template-instantiation.cpp | 10 + .../SemaTemplate/resolve-single-template-id.cpp | 82 + clang/test/SemaTemplate/self-comparison.cpp | 48 + clang/test/SemaTemplate/temp.cpp | 19 + clang/test/SemaTemplate/temp_arg.cpp | 20 + clang/test/SemaTemplate/temp_arg_nontype.cpp | 325 ++ clang/test/SemaTemplate/temp_arg_template.cpp | 62 + clang/test/SemaTemplate/temp_arg_type.cpp | 42 + clang/test/SemaTemplate/temp_class_order.cpp | 42 + clang/test/SemaTemplate/temp_class_spec.cpp | 363 +++ clang/test/SemaTemplate/temp_class_spec_blocks.cpp | 34 + clang/test/SemaTemplate/temp_class_spec_neg.cpp | 45 + clang/test/SemaTemplate/temp_explicit.cpp | 151 + clang/test/SemaTemplate/temp_explicit_cxx0x.cpp | 24 + clang/test/SemaTemplate/temp_func_order.cpp | 95 + clang/test/SemaTemplate/template-class-traits.cpp | 8 + clang/test/SemaTemplate/template-decl-fail.cpp | 10 + clang/test/SemaTemplate/template-id-expr.cpp | 98 + clang/test/SemaTemplate/template-id-printing.cpp | 141 + clang/test/SemaTemplate/typename-specifier-2.cpp | 30 + clang/test/SemaTemplate/typename-specifier-3.cpp | 19 + clang/test/SemaTemplate/typename-specifier-4.cpp | 164 ++ clang/test/SemaTemplate/typename-specifier.cpp | 117 + clang/test/SemaTemplate/typo-dependent-name.cpp | 17 + clang/test/SemaTemplate/unresolved-construct.cpp | 19 + clang/test/SemaTemplate/unused-variables.cpp | 21 + .../value-dependent-null-pointer-constant.cpp | 29 + .../test/SemaTemplate/virtual-member-functions.cpp | 86 + clang/test/TestRunner.sh | 13 + clang/test/Tooling/clang-check-args.cpp | 8 + clang/test/Tooling/clang-check-pwd.cpp | 13 + clang/test/Tooling/clang-check.cpp | 13 + clang/test/Unit/lit.cfg | 86 + clang/test/Unit/lit.site.cfg.in | 26 + clang/test/cxx-sections.data | 1943 ++++++++++++ clang/test/lit.cfg | 257 ++ clang/test/lit.site.cfg.in | 21 + clang/test/make_test_dirs.pl | 27 + 5009 files changed, 256953 insertions(+) create mode 100644 clang/test/ARCMT/Common.h create mode 100644 clang/test/ARCMT/GC-check-warn-nsalloc.m create mode 100644 clang/test/ARCMT/GC-check.m create mode 100644 clang/test/ARCMT/GC-no-arc-runtime.m create mode 100644 clang/test/ARCMT/GC-no-arc-runtime.m.result create mode 100644 clang/test/ARCMT/GC-no-finalize-removal.m create mode 100644 clang/test/ARCMT/GC-no-finalize-removal.m.result create mode 100644 clang/test/ARCMT/GC.h create mode 100644 clang/test/ARCMT/GC.m create mode 100644 clang/test/ARCMT/GC.m.result create mode 100644 clang/test/ARCMT/Inputs/test.h create mode 100644 clang/test/ARCMT/Inputs/test.h.result create mode 100644 clang/test/ARCMT/Inputs/test1.m.in create mode 100644 clang/test/ARCMT/Inputs/test1.m.in.result create mode 100644 clang/test/ARCMT/Inputs/test2.m.in create mode 100644 clang/test/ARCMT/Inputs/test2.m.in.result create mode 100644 clang/test/ARCMT/api.m create mode 100644 clang/test/ARCMT/api.m.result create mode 100644 clang/test/ARCMT/assign-prop-no-arc-runtime.m create mode 100644 clang/test/ARCMT/assign-prop-no-arc-runtime.m.result create mode 100644 clang/test/ARCMT/assign-prop-with-arc-runtime.m create mode 100644 clang/test/ARCMT/assign-prop-with-arc-runtime.m.result create mode 100644 clang/test/ARCMT/atautorelease-2.m create mode 100644 clang/test/ARCMT/atautorelease-2.m.result create mode 100644 clang/test/ARCMT/atautorelease-3.m create mode 100644 clang/test/ARCMT/atautorelease-3.m.result create mode 100644 clang/test/ARCMT/atautorelease-check.m create mode 100644 clang/test/ARCMT/atautorelease.m create mode 100644 clang/test/ARCMT/atautorelease.m.result create mode 100644 clang/test/ARCMT/autoreleases.m create mode 100644 clang/test/ARCMT/autoreleases.m.result create mode 100644 clang/test/ARCMT/check-api.m create mode 100644 clang/test/ARCMT/check-with-serialized-diag.m create mode 100644 clang/test/ARCMT/checking.m create mode 100644 clang/test/ARCMT/cxx-checking.mm create mode 100644 clang/test/ARCMT/cxx-rewrite.mm create mode 100644 clang/test/ARCMT/cxx-rewrite.mm.result create mode 100644 clang/test/ARCMT/dealloc.m create mode 100644 clang/test/ARCMT/dealloc.m.result create mode 100644 clang/test/ARCMT/dispatch.m create mode 100644 clang/test/ARCMT/dispatch.m.result create mode 100644 clang/test/ARCMT/driver-migrate.m create mode 100644 clang/test/ARCMT/init.m create mode 100644 clang/test/ARCMT/init.m.result create mode 100644 clang/test/ARCMT/migrate-emit-errors.m create mode 100644 clang/test/ARCMT/migrate-plist-output.m create mode 100644 clang/test/ARCMT/migrate-space-in-path.m create mode 100644 clang/test/ARCMT/migrate.m create mode 100644 clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m create mode 100644 clang/test/ARCMT/nonobjc-to-objc-cast-2.m create mode 100644 clang/test/ARCMT/nonobjc-to-objc-cast.m create mode 100644 clang/test/ARCMT/nonobjc-to-objc-cast.m.result create mode 100644 clang/test/ARCMT/objcmt-numeric-literals.m create mode 100644 clang/test/ARCMT/objcmt-numeric-literals.m.result create mode 100644 clang/test/ARCMT/objcmt-subscripting-literals.m create mode 100644 clang/test/ARCMT/objcmt-subscripting-literals.m.result create mode 100644 clang/test/ARCMT/releases-driver.m create mode 100644 clang/test/ARCMT/releases-driver.m.result create mode 100644 clang/test/ARCMT/releases.m create mode 100644 clang/test/ARCMT/releases.m.result create mode 100644 clang/test/ARCMT/remove-dealloc-method.m create mode 100644 clang/test/ARCMT/remove-dealloc-method.m.result create mode 100644 clang/test/ARCMT/remove-dealloc-zerouts.m create mode 100644 clang/test/ARCMT/remove-dealloc-zerouts.m.result create mode 100644 clang/test/ARCMT/remove-statements.m create mode 100644 clang/test/ARCMT/remove-statements.m.result create mode 100644 clang/test/ARCMT/retains.m create mode 100644 clang/test/ARCMT/retains.m.result create mode 100644 clang/test/ARCMT/rewrite-block-var.m create mode 100644 clang/test/ARCMT/rewrite-block-var.m.result create mode 100644 clang/test/ARCMT/safe-arc-assign.m create mode 100644 clang/test/ARCMT/safe-arc-assign.m.result create mode 100644 clang/test/ARCMT/with space/test.h create mode 100644 clang/test/ARCMT/with space/test.h.result create mode 100644 clang/test/ARCMT/with space/test1.m.in create mode 100644 clang/test/ARCMT/with space/test1.m.in.result create mode 100644 clang/test/ARCMT/with space/test2.m.in create mode 100644 clang/test/ARCMT/with space/test2.m.in.result create mode 100644 clang/test/ARCMT/with-arc-mode-check.m create mode 100644 clang/test/ARCMT/with-arc-mode-migrate.m create mode 100644 clang/test/ARCMT/with-arc-mode-migrate.m.result create mode 100644 clang/test/ARCMT/with-arc-mode-modify.m create mode 100644 clang/test/ARCMT/with-arc-mode-modify.m.result create mode 100644 clang/test/ASTMerge/Inputs/category1.m create mode 100644 clang/test/ASTMerge/Inputs/category2.m create mode 100644 clang/test/ASTMerge/Inputs/class-template1.cpp create mode 100644 clang/test/ASTMerge/Inputs/class-template2.cpp create mode 100644 clang/test/ASTMerge/Inputs/class1.cpp create mode 100644 clang/test/ASTMerge/Inputs/class2.cpp create mode 100644 clang/test/ASTMerge/Inputs/enum1.c create mode 100644 clang/test/ASTMerge/Inputs/enum2.c create mode 100644 clang/test/ASTMerge/Inputs/exprs1.c create mode 100644 clang/test/ASTMerge/Inputs/exprs2.c create mode 100644 clang/test/ASTMerge/Inputs/function1.c create mode 100644 clang/test/ASTMerge/Inputs/function2.c create mode 100644 clang/test/ASTMerge/Inputs/interface1.m create mode 100644 clang/test/ASTMerge/Inputs/interface2.m create mode 100644 clang/test/ASTMerge/Inputs/lit.local.cfg create mode 100644 clang/test/ASTMerge/Inputs/namespace1.cpp create mode 100644 clang/test/ASTMerge/Inputs/namespace2.cpp create mode 100644 clang/test/ASTMerge/Inputs/property1.m create mode 100644 clang/test/ASTMerge/Inputs/property2.m create mode 100644 clang/test/ASTMerge/Inputs/struct1.c create mode 100644 clang/test/ASTMerge/Inputs/struct2.c create mode 100644 clang/test/ASTMerge/Inputs/typedef1.c create mode 100644 clang/test/ASTMerge/Inputs/typedef2.c create mode 100644 clang/test/ASTMerge/Inputs/var1.c create mode 100644 clang/test/ASTMerge/Inputs/var1.h create mode 100644 clang/test/ASTMerge/Inputs/var2.c create mode 100644 clang/test/ASTMerge/category.m create mode 100644 clang/test/ASTMerge/class-template.cpp create mode 100644 clang/test/ASTMerge/class.cpp create mode 100644 clang/test/ASTMerge/enum.c create mode 100644 clang/test/ASTMerge/exprs.c create mode 100644 clang/test/ASTMerge/function.c create mode 100644 clang/test/ASTMerge/interface.m create mode 100644 clang/test/ASTMerge/namespace.cpp create mode 100644 clang/test/ASTMerge/property.m create mode 100644 clang/test/ASTMerge/struct.c create mode 100644 clang/test/ASTMerge/typedef.c create mode 100644 clang/test/ASTMerge/var.c create mode 100644 clang/test/Analysis/CFContainers.mm create mode 100644 clang/test/Analysis/CFDateGC.m create mode 100644 clang/test/Analysis/CFNumber.c create mode 100644 clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m create mode 100644 clang/test/Analysis/CGColorSpace.c create mode 100644 clang/test/Analysis/CheckNSError.m create mode 100644 clang/test/Analysis/MissingDealloc.m create mode 100644 clang/test/Analysis/NSPanel.m create mode 100644 clang/test/Analysis/NSString.m create mode 100644 clang/test/Analysis/NSWindow.m create mode 100644 clang/test/Analysis/NoReturn.m create mode 100644 clang/test/Analysis/OSAtomic_mac.cpp create mode 100644 clang/test/Analysis/ObjCProperties.m create mode 100644 clang/test/Analysis/ObjCRetSigs.m create mode 100644 clang/test/Analysis/PR2599.m create mode 100644 clang/test/Analysis/PR2978.m create mode 100644 clang/test/Analysis/PR3991.m create mode 100644 clang/test/Analysis/PR7218.c create mode 100644 clang/test/Analysis/PR9741.cpp create mode 100644 clang/test/Analysis/additive-folding-range-constraints.c create mode 100644 clang/test/Analysis/additive-folding.c create mode 100644 clang/test/Analysis/analyzeOneFunction.m create mode 100644 clang/test/Analysis/analyze_display_progress.c create mode 100644 clang/test/Analysis/analyzer-stats.c create mode 100644 clang/test/Analysis/array-struct-region.c create mode 100644 clang/test/Analysis/array-struct.c create mode 100644 clang/test/Analysis/auto-obj-dtors-cfg-output.cpp create mode 100644 clang/test/Analysis/base-init.cpp create mode 100644 clang/test/Analysis/blocks.m create mode 100644 clang/test/Analysis/bool-assignment.cpp create mode 100644 clang/test/Analysis/bool-assignment2.c create mode 100644 clang/test/Analysis/bstring.c create mode 100644 clang/test/Analysis/casts.c create mode 100644 clang/test/Analysis/casts.m create mode 100644 clang/test/Analysis/cfref_PR2519.c create mode 100644 clang/test/Analysis/cfref_rdar6080742.c create mode 100644 clang/test/Analysis/check-deserialization.cpp create mode 100644 clang/test/Analysis/chroot.c create mode 100644 clang/test/Analysis/complex.c create mode 100644 clang/test/Analysis/concrete-address.c create mode 100644 clang/test/Analysis/constant-folding.c create mode 100644 clang/test/Analysis/coverage.c create mode 100644 clang/test/Analysis/cstring-syntax-cxx.cpp create mode 100644 clang/test/Analysis/cstring-syntax.c create mode 100644 clang/test/Analysis/cxx-crashes.cpp create mode 100644 clang/test/Analysis/dead-stores.c create mode 100644 clang/test/Analysis/dead-stores.cpp create mode 100644 clang/test/Analysis/dead-stores.m create mode 100644 clang/test/Analysis/debug-CallGraph.c create mode 100644 clang/test/Analysis/default-analyze.m create mode 100644 clang/test/Analysis/default-diagnostic-visitors.c create mode 100644 clang/test/Analysis/delegates.m create mode 100644 clang/test/Analysis/derived-to-base.cpp create mode 100644 clang/test/Analysis/div-zero.cpp create mode 100644 clang/test/Analysis/domtest.c create mode 100644 clang/test/Analysis/dtor.cpp create mode 100644 clang/test/Analysis/dtors-in-dtor-cfg-output.cpp create mode 100644 clang/test/Analysis/dynamic-cast.cpp create mode 100644 clang/test/Analysis/elementtype.c create mode 100644 clang/test/Analysis/exercise-ps.c create mode 100644 clang/test/Analysis/fields.c create mode 100644 clang/test/Analysis/free.c create mode 100644 clang/test/Analysis/func.c create mode 100644 clang/test/Analysis/global-region-invalidation.c create mode 100644 clang/test/Analysis/html-diags-multifile.c create mode 100644 clang/test/Analysis/html-diags-multifile.h create mode 100644 clang/test/Analysis/html-diags.c create mode 100644 clang/test/Analysis/idempotent-operations-limited-loops.c create mode 100644 clang/test/Analysis/idempotent-operations.c create mode 100644 clang/test/Analysis/idempotent-operations.cpp create mode 100644 clang/test/Analysis/idempotent-operations.m create mode 100644 clang/test/Analysis/initializer.cpp create mode 100644 clang/test/Analysis/initializers-cfg-output.cpp create mode 100644 clang/test/Analysis/inline-not-supported.c create mode 100644 clang/test/Analysis/inline-plist.c create mode 100644 clang/test/Analysis/inline-unique-reports.c create mode 100644 clang/test/Analysis/inline.c create mode 100644 clang/test/Analysis/inline2.c create mode 100644 clang/test/Analysis/inline3.c create mode 100644 clang/test/Analysis/inline4.c create mode 100644 clang/test/Analysis/iterators.cpp create mode 100644 clang/test/Analysis/keychainAPI-diagnostic-visitor.m create mode 100644 clang/test/Analysis/keychainAPI.m create mode 100644 clang/test/Analysis/lambdas.cpp create mode 100644 clang/test/Analysis/lvalue.cpp create mode 100644 clang/test/Analysis/malloc-annotations.c create mode 100644 clang/test/Analysis/malloc-interprocedural.c create mode 100644 clang/test/Analysis/malloc-overflow.c create mode 100644 clang/test/Analysis/malloc-overflow.cpp create mode 100644 clang/test/Analysis/malloc-plist.c create mode 100644 clang/test/Analysis/malloc-sizeof.c create mode 100644 clang/test/Analysis/malloc.c create mode 100644 clang/test/Analysis/malloc.cpp create mode 100644 clang/test/Analysis/malloc.m create mode 100644 clang/test/Analysis/malloc.mm create mode 100644 clang/test/Analysis/method-arg-decay.m create mode 100644 clang/test/Analysis/method-call-intra-p.cpp create mode 100644 clang/test/Analysis/method-call.cpp create mode 100644 clang/test/Analysis/misc-ps-64.m create mode 100644 clang/test/Analysis/misc-ps-cxx0x.cpp create mode 100644 clang/test/Analysis/misc-ps-eager-assume.m create mode 100644 clang/test/Analysis/misc-ps-ranges.m create mode 100644 clang/test/Analysis/misc-ps-region-store-i386.m create mode 100644 clang/test/Analysis/misc-ps-region-store-x86_64.m create mode 100644 clang/test/Analysis/misc-ps-region-store.cpp create mode 100644 clang/test/Analysis/misc-ps-region-store.m create mode 100644 clang/test/Analysis/misc-ps-region-store.mm create mode 100644 clang/test/Analysis/misc-ps.c create mode 100644 clang/test/Analysis/misc-ps.m create mode 100644 clang/test/Analysis/new.cpp create mode 100644 clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m create mode 100644 clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m create mode 100644 clang/test/Analysis/no-exit-cfg.c create mode 100644 clang/test/Analysis/no-outofbounds.c create mode 100644 clang/test/Analysis/null-deref-ps-region.c create mode 100644 clang/test/Analysis/null-deref-ps.c create mode 100644 clang/test/Analysis/nullptr.cpp create mode 100644 clang/test/Analysis/objc-arc.m create mode 100644 clang/test/Analysis/objc-bool.m create mode 100644 clang/test/Analysis/objc-method-coverage.m create mode 100644 clang/test/Analysis/operator-calls.cpp create mode 100644 clang/test/Analysis/out-of-bounds.c create mode 100644 clang/test/Analysis/outofbound-notwork.c create mode 100644 clang/test/Analysis/outofbound.c create mode 100644 clang/test/Analysis/override-werror.c create mode 100644 clang/test/Analysis/plist-output-alternate.m create mode 100644 clang/test/Analysis/plist-output.m create mode 100644 clang/test/Analysis/pr4209.m create mode 100644 clang/test/Analysis/pr_2542_rdar_6793404.m create mode 100644 clang/test/Analysis/pr_4164.c create mode 100644 clang/test/Analysis/properties.m create mode 100644 clang/test/Analysis/pthreadlock.c create mode 100644 clang/test/Analysis/ptr-arith.c create mode 100644 clang/test/Analysis/rdar-6442306-1.m create mode 100644 clang/test/Analysis/rdar-6540084.m create mode 100644 clang/test/Analysis/rdar-6541136-region.c create mode 100644 clang/test/Analysis/rdar-6562655.m create mode 100644 clang/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m create mode 100644 clang/test/Analysis/rdar-7168531.m create mode 100644 clang/test/Analysis/redefined_system.c create mode 100644 clang/test/Analysis/refcnt_naming.m create mode 100644 clang/test/Analysis/reference.cpp create mode 100644 clang/test/Analysis/region-1.m create mode 100644 clang/test/Analysis/retain-release-gc-only.m create mode 100644 clang/test/Analysis/retain-release-inline.m create mode 100644 clang/test/Analysis/retain-release-path-notes-gc.m create mode 100644 clang/test/Analysis/retain-release-path-notes.m create mode 100644 clang/test/Analysis/retain-release-region-store.m create mode 100644 clang/test/Analysis/retain-release.m create mode 100644 clang/test/Analysis/retain-release.mm create mode 100644 clang/test/Analysis/security-syntax-checks-no-emit.c create mode 100644 clang/test/Analysis/security-syntax-checks.m create mode 100644 clang/test/Analysis/self-init.m create mode 100644 clang/test/Analysis/sizeofpointer.c create mode 100644 clang/test/Analysis/stack-addr-ps.c create mode 100644 clang/test/Analysis/stack-addr-ps.cpp create mode 100644 clang/test/Analysis/stack-block-returned.cpp create mode 100644 clang/test/Analysis/stackaddrleak.c create mode 100644 clang/test/Analysis/stats.c create mode 100644 clang/test/Analysis/stream.c create mode 100644 clang/test/Analysis/string-fail.c create mode 100644 clang/test/Analysis/string.c create mode 100644 clang/test/Analysis/system-header-simulator-objc.h create mode 100644 clang/test/Analysis/system-header-simulator.h create mode 100644 clang/test/Analysis/taint-generic.c create mode 100644 clang/test/Analysis/taint-tester.c create mode 100644 clang/test/Analysis/taint-tester.cpp create mode 100644 clang/test/Analysis/taint-tester.m create mode 100644 clang/test/Analysis/temp-obj-dtors-cfg-output.cpp create mode 100644 clang/test/Analysis/undef-buffers.c create mode 100644 clang/test/Analysis/uninit-msg-expr.m create mode 100644 clang/test/Analysis/uninit-ps-rdar6145427.m create mode 100644 clang/test/Analysis/uninit-vals-ps-region.m create mode 100644 clang/test/Analysis/uninit-vals-ps.c create mode 100644 clang/test/Analysis/uninit-vals.m create mode 100644 clang/test/Analysis/unions-region.m create mode 100644 clang/test/Analysis/unix-fns.c create mode 100644 clang/test/Analysis/unreachable-code-path.c create mode 100644 clang/test/Analysis/unused-ivars.m create mode 100644 clang/test/Analysis/variadic-method-types.m create mode 100644 clang/test/Analysis/virtualcall.cpp create mode 100644 clang/test/CMakeLists.txt create mode 100644 clang/test/CXX/basic/basic.def.odr/p1-var.cpp create mode 100644 clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp create mode 100644 clang/test/CXX/basic/basic.link/p9.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp create mode 100644 clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp create mode 100644 clang/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp create mode 100644 clang/test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp create mode 100644 clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp create mode 100644 clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2a.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2b.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2c.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2d.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2e.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2f.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2g.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2h.cpp create mode 100644 clang/test/CXX/basic/basic.start/basic.start.main/p2i.cpp create mode 100644 clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp create mode 100644 clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp create mode 100644 clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp create mode 100644 clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp create mode 100644 clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp create mode 100644 clang/test/CXX/basic/basic.types/p10.cpp create mode 100644 clang/test/CXX/class.access/class.access.base/p1.cpp create mode 100644 clang/test/CXX/class.access/class.access.base/p5.cpp create mode 100644 clang/test/CXX/class.access/class.access.dcl/p1.cpp create mode 100644 clang/test/CXX/class.access/class.access.nest/p1.cpp create mode 100644 clang/test/CXX/class.access/class.friend/p1.cpp create mode 100644 clang/test/CXX/class.access/class.friend/p11.cpp create mode 100644 clang/test/CXX/class.access/class.friend/p2-cxx03.cpp create mode 100644 clang/test/CXX/class.access/class.friend/p3-cxx0x.cpp create mode 100644 clang/test/CXX/class.access/class.friend/p6.cpp create mode 100644 clang/test/CXX/class.access/class.protected/p1-cxx11.cpp create mode 100644 clang/test/CXX/class.access/class.protected/p1.cpp create mode 100644 clang/test/CXX/class.access/p4.cpp create mode 100644 clang/test/CXX/class.access/p6.cpp create mode 100644 clang/test/CXX/class.derived/class.abstract/p4.cpp create mode 100644 clang/test/CXX/class.derived/class.abstract/p5.cpp create mode 100644 clang/test/CXX/class.derived/class.member.lookup/p6.cpp create mode 100644 clang/test/CXX/class.derived/class.member.lookup/p8.cpp create mode 100644 clang/test/CXX/class.derived/class.member.lookup/p9.cpp create mode 100644 clang/test/CXX/class.derived/class.virtual/p12.cpp create mode 100644 clang/test/CXX/class.derived/class.virtual/p2.cpp create mode 100644 clang/test/CXX/class.derived/class.virtual/p3-0x.cpp create mode 100644 clang/test/CXX/class.derived/p1.cpp create mode 100644 clang/test/CXX/class.derived/p2.cpp create mode 100644 clang/test/CXX/class/class.base/class.base.init/p5-0x.cpp create mode 100644 clang/test/CXX/class/class.bit/p2.cpp create mode 100644 clang/test/CXX/class/class.friend/p1-ambiguous.cpp create mode 100644 clang/test/CXX/class/class.friend/p1-cxx11.cpp create mode 100644 clang/test/CXX/class/class.friend/p1.cpp create mode 100644 clang/test/CXX/class/class.friend/p2.cpp create mode 100644 clang/test/CXX/class/class.friend/p6.cpp create mode 100644 clang/test/CXX/class/class.local/p1-0x.cpp create mode 100644 clang/test/CXX/class/class.local/p1.cpp create mode 100644 clang/test/CXX/class/class.local/p2.cpp create mode 100644 clang/test/CXX/class/class.local/p3.cpp create mode 100644 clang/test/CXX/class/class.local/p4.cpp create mode 100644 clang/test/CXX/class/class.mem/p1.cpp create mode 100644 clang/test/CXX/class/class.mem/p13.cpp create mode 100644 clang/test/CXX/class/class.mem/p14.cpp create mode 100644 clang/test/CXX/class/class.mem/p1b.cpp create mode 100644 clang/test/CXX/class/class.mem/p2.cpp create mode 100644 clang/test/CXX/class/class.mem/p5-0x.cpp create mode 100644 clang/test/CXX/class/class.mem/p8-0x.cpp create mode 100644 clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp create mode 100644 clang/test/CXX/class/class.nest/p1-cxx0x.cpp create mode 100644 clang/test/CXX/class/class.nest/p1.cpp create mode 100644 clang/test/CXX/class/class.nest/p3.cpp create mode 100644 clang/test/CXX/class/class.nested.type/p1.cpp create mode 100644 clang/test/CXX/class/class.static/class.static.data/p3.cpp create mode 100644 clang/test/CXX/class/class.static/class.static.data/p4.cpp create mode 100644 clang/test/CXX/class/class.union/p1.cpp create mode 100644 clang/test/CXX/class/class.union/p2-0x.cpp create mode 100644 clang/test/CXX/class/p1-0x.cpp create mode 100644 clang/test/CXX/class/p2-0x.cpp create mode 100644 clang/test/CXX/class/p6-0x.cpp create mode 100644 clang/test/CXX/conv/conv.mem/p4.cpp create mode 100644 clang/test/CXX/conv/conv.prom/p2.cpp create mode 100644 clang/test/CXX/conv/conv.prom/p4.cpp create mode 100644 clang/test/CXX/conv/conv.ptr/p2.cpp create mode 100644 clang/test/CXX/conv/conv.qual/pr6089.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p13.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp create mode 100644 clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.enum/p5.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.link/p7.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp create mode 100644 clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp create mode 100644 clang/test/CXX/dcl.dcl/p4-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/p14-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/p5.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.init/p6.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp create mode 100644 clang/test/CXX/dcl.decl/dcl.name/p1.cpp create mode 100644 clang/test/CXX/dcl.decl/p4-0x.cpp create mode 100644 clang/test/CXX/except/except.handle/p16.cpp create mode 100644 clang/test/CXX/except/except.spec/canonical.cpp create mode 100644 clang/test/CXX/except/except.spec/p1.cpp create mode 100644 clang/test/CXX/except/except.spec/p11.cpp create mode 100644 clang/test/CXX/except/except.spec/p14-ir.cpp create mode 100644 clang/test/CXX/except/except.spec/p14.cpp create mode 100644 clang/test/CXX/except/except.spec/p15.cpp create mode 100644 clang/test/CXX/except/except.spec/p2-dynamic-types.cpp create mode 100644 clang/test/CXX/except/except.spec/p2-places.cpp create mode 100644 clang/test/CXX/except/except.spec/p3.cpp create mode 100644 clang/test/CXX/except/except.spec/p5-pointers.cpp create mode 100644 clang/test/CXX/except/except.spec/p5-virtual.cpp create mode 100644 clang/test/CXX/except/except.spec/p9-dynamic.cpp create mode 100644 clang/test/CXX/except/except.spec/p9-noexcept.cpp create mode 100644 clang/test/CXX/except/except.spec/template.cpp create mode 100644 clang/test/CXX/expr/expr.ass/p9-cxx11.cpp create mode 100644 clang/test/CXX/expr/expr.cast/p4-0x.cpp create mode 100644 clang/test/CXX/expr/expr.cast/p4.cpp create mode 100644 clang/test/CXX/expr/expr.const/p2-0x.cpp create mode 100644 clang/test/CXX/expr/expr.const/p3-0x-nowarn.cpp create mode 100644 clang/test/CXX/expr/expr.const/p3-0x.cpp create mode 100644 clang/test/CXX/expr/expr.const/p5-0x.cpp create mode 100644 clang/test/CXX/expr/expr.mptr.oper/p5.cpp create mode 100644 clang/test/CXX/expr/expr.mptr.oper/p6-0x.cpp create mode 100644 clang/test/CXX/expr/expr.post/expr.call/p7-0x.cpp create mode 100644 clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp create mode 100644 clang/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp create mode 100644 clang/test/CXX/expr/expr.post/expr.ref/p3.cpp create mode 100644 clang/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp create mode 100644 clang/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp create mode 100644 clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp create mode 100644 clang/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp create mode 100644 clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.delete/p5.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.new/p17.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.new/p19.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.new/p20.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h create mode 100644 clang/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp create mode 100644 clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp create mode 100644 clang/test/CXX/expr/p3.cpp create mode 100644 clang/test/CXX/expr/p8.cpp create mode 100644 clang/test/CXX/expr/p9.cpp create mode 100644 clang/test/CXX/lex/lex.charset/p2-cxx11.cpp create mode 100644 clang/test/CXX/lex/lex.charset/p2-cxx98.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ccon/p1.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p2.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp create mode 100644 clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp create mode 100644 clang/test/CXX/lex/lex.pptoken/p3-0x.cpp create mode 100644 clang/test/CXX/lex/lex.trigraph/p1.cpp create mode 100644 clang/test/CXX/lex/lex.trigraph/p2.cpp create mode 100644 clang/test/CXX/lex/lex.trigraph/p3.cpp create mode 100644 clang/test/CXX/over/over.built/p1.cpp create mode 100644 clang/test/CXX/over/over.built/p23.cpp create mode 100644 clang/test/CXX/over/over.built/p25.cpp create mode 100644 clang/test/CXX/over/over.load/p2-0x.cpp create mode 100644 clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp create mode 100644 clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp create mode 100644 clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp create mode 100644 clang/test/CXX/over/over.match/over.match.best/p1.cpp create mode 100644 clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp create mode 100644 clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p2.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p3.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p5.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p6.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p7.cpp create mode 100644 clang/test/CXX/over/over.oper/over.literal/p8.cpp create mode 100644 clang/test/CXX/over/over.over/p1.cpp create mode 100644 clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp create mode 100644 clang/test/CXX/over/over.over/p2.cpp create mode 100644 clang/test/CXX/over/over.over/p4.cpp create mode 100644 clang/test/CXX/special/class.copy/implicit-move-def.cpp create mode 100644 clang/test/CXX/special/class.copy/implicit-move.cpp create mode 100644 clang/test/CXX/special/class.copy/p11.0x.copy.cpp create mode 100644 clang/test/CXX/special/class.copy/p11.0x.move.cpp create mode 100644 clang/test/CXX/special/class.copy/p13-0x.cpp create mode 100644 clang/test/CXX/special/class.copy/p15-0x.cpp create mode 100644 clang/test/CXX/special/class.copy/p15-inclass.cpp create mode 100644 clang/test/CXX/special/class.copy/p20.cpp create mode 100644 clang/test/CXX/special/class.copy/p3.cpp create mode 100644 clang/test/CXX/special/class.copy/p33-0x.cpp create mode 100644 clang/test/CXX/special/class.copy/p8-cxx11.cpp create mode 100644 clang/test/CXX/special/class.copy/p9.cpp create mode 100644 clang/test/CXX/special/class.ctor/p1.cpp create mode 100644 clang/test/CXX/special/class.ctor/p4-0x.cpp create mode 100644 clang/test/CXX/special/class.ctor/p5-0x.cpp create mode 100644 clang/test/CXX/special/class.ctor/p6-0x.cpp create mode 100644 clang/test/CXX/special/class.dtor/p10-0x.cpp create mode 100644 clang/test/CXX/special/class.dtor/p2-0x.cpp create mode 100644 clang/test/CXX/special/class.dtor/p2.cpp create mode 100644 clang/test/CXX/special/class.dtor/p3-0x.cpp create mode 100644 clang/test/CXX/special/class.dtor/p5-0x.cpp create mode 100644 clang/test/CXX/special/class.dtor/p9.cpp create mode 100644 clang/test/CXX/special/class.free/p1.cpp create mode 100644 clang/test/CXX/special/class.free/p6.cpp create mode 100644 clang/test/CXX/special/class.inhctor/elsewhere.cpp create mode 100644 clang/test/CXX/special/class.inhctor/p3.cpp create mode 100644 clang/test/CXX/special/class.inhctor/p7.cpp create mode 100644 clang/test/CXX/special/class.init/class.base.init/p8-0x.cpp create mode 100644 clang/test/CXX/special/class.init/class.base.init/p9-0x.cpp create mode 100644 clang/test/CXX/special/class.temporary/p1.cpp create mode 100644 clang/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp create mode 100644 clang/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp create mode 100644 clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp create mode 100644 clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp create mode 100644 clang/test/CXX/stmt.stmt/stmt.label/p1.cpp create mode 100644 clang/test/CXX/stmt.stmt/stmt.select/p3.cpp create mode 100644 clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp create mode 100644 clang/test/CXX/temp/p3.cpp create mode 100644 clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp create mode 100644 clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp create mode 100644 clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp create mode 100644 clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp create mode 100644 clang/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp create mode 100644 clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp create mode 100644 clang/test/CXX/temp/temp.decls/p3.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.alias/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.alias/p2.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.alias/p3.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.friend/p4.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.friend/p8.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/p2.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p2.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p3.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.funcaddr/p1.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p11.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp create mode 100644 clang/test/CXX/temp/temp.names/p2.cpp create mode 100644 clang/test/CXX/temp/temp.names/p4.cpp create mode 100644 clang/test/CXX/temp/temp.param/p1.cpp create mode 100644 clang/test/CXX/temp/temp.param/p10-0x.cpp create mode 100644 clang/test/CXX/temp/temp.param/p10.cpp create mode 100644 clang/test/CXX/temp/temp.param/p11-0x.cpp create mode 100644 clang/test/CXX/temp/temp.param/p11.cpp create mode 100644 clang/test/CXX/temp/temp.param/p12.cpp create mode 100644 clang/test/CXX/temp/temp.param/p13.cpp create mode 100644 clang/test/CXX/temp/temp.param/p14.cpp create mode 100644 clang/test/CXX/temp/temp.param/p15-cxx0x.cpp create mode 100644 clang/test/CXX/temp/temp.param/p15.cpp create mode 100644 clang/test/CXX/temp/temp.param/p2.cpp create mode 100644 clang/test/CXX/temp/temp.param/p3.cpp create mode 100644 clang/test/CXX/temp/temp.param/p4.cpp create mode 100644 clang/test/CXX/temp/temp.param/p5.cpp create mode 100644 clang/test/CXX/temp/temp.param/p7.cpp create mode 100644 clang/test/CXX/temp/temp.param/p8.cpp create mode 100644 clang/test/CXX/temp/temp.param/p9-0x.cpp create mode 100644 clang/test/CXX/temp/temp.param/p9.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.dep/p3.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.local/p1.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.local/p3.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.local/p7.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.local/p8.cpp create mode 100644 clang/test/CXX/temp/temp.res/temp.local/p9.cpp create mode 100644 clang/test/CXX/temp/temp.spec/p5.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p11.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p12.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p7.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p8.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.inst/p1.cpp create mode 100644 clang/test/CXX/temp/temp.spec/temp.inst/p11.cpp create mode 100644 clang/test/CXX/temp/temp.type/p1-0x.cpp create mode 100644 clang/test/CodeCompletion/Inputs/macros.h create mode 100644 clang/test/CodeCompletion/Inputs/reserved.h create mode 100644 clang/test/CodeCompletion/PR9728.cpp create mode 100644 clang/test/CodeCompletion/call.c create mode 100644 clang/test/CodeCompletion/call.cpp create mode 100644 clang/test/CodeCompletion/enum-switch-case-qualified.cpp create mode 100644 clang/test/CodeCompletion/enum-switch-case.c create mode 100644 clang/test/CodeCompletion/enum-switch-case.cpp create mode 100644 clang/test/CodeCompletion/function-templates.cpp create mode 100644 clang/test/CodeCompletion/functions.cpp create mode 100644 clang/test/CodeCompletion/macros.c create mode 100644 clang/test/CodeCompletion/member-access.c create mode 100644 clang/test/CodeCompletion/member-access.cpp create mode 100644 clang/test/CodeCompletion/namespace-alias.cpp create mode 100644 clang/test/CodeCompletion/namespace.cpp create mode 100644 clang/test/CodeCompletion/nested-name-specifier.cpp create mode 100644 clang/test/CodeCompletion/objc-message.m create mode 100644 clang/test/CodeCompletion/operator.cpp create mode 100644 clang/test/CodeCompletion/ordinary-name.c create mode 100644 clang/test/CodeCompletion/ordinary-name.cpp create mode 100644 clang/test/CodeCompletion/preamble.c create mode 100644 clang/test/CodeCompletion/some_struct.h create mode 100644 clang/test/CodeCompletion/stdin.c create mode 100644 clang/test/CodeCompletion/tag.c create mode 100644 clang/test/CodeCompletion/tag.cpp create mode 100644 clang/test/CodeCompletion/templates.cpp create mode 100644 clang/test/CodeCompletion/truncation.c create mode 100644 clang/test/CodeCompletion/truncation.c.h create mode 100644 clang/test/CodeCompletion/using-namespace.cpp create mode 100644 clang/test/CodeCompletion/using.cpp create mode 100644 clang/test/CodeGen/2002-01-23-LoadQISIReloadFailure.c create mode 100644 clang/test/CodeGen/2002-01-24-ComplexSpaceInType.c create mode 100644 clang/test/CodeGen/2002-01-24-HandleCallInsnSEGV.c create mode 100644 clang/test/CodeGen/2002-02-13-ConditionalInCall.c create mode 100644 clang/test/CodeGen/2002-02-13-ReloadProblem.c create mode 100644 clang/test/CodeGen/2002-02-13-TypeVarNameCollision.c create mode 100644 clang/test/CodeGen/2002-02-13-UnnamedLocal.c create mode 100644 clang/test/CodeGen/2002-02-14-EntryNodePreds.c create mode 100644 clang/test/CodeGen/2002-02-16-RenamingTest.c create mode 100644 clang/test/CodeGen/2002-02-17-ArgumentAddress.c create mode 100644 clang/test/CodeGen/2002-02-18-64bitConstant.c create mode 100644 clang/test/CodeGen/2002-02-18-StaticData.c create mode 100644 clang/test/CodeGen/2002-03-11-LargeCharInString.c create mode 100644 clang/test/CodeGen/2002-03-12-ArrayInitialization.c create mode 100644 clang/test/CodeGen/2002-03-12-StructInitialize.c create mode 100644 clang/test/CodeGen/2002-03-12-StructInitializer.c create mode 100644 clang/test/CodeGen/2002-03-14-BrokenPHINode.c create mode 100644 clang/test/CodeGen/2002-03-14-BrokenSSA.c create mode 100644 clang/test/CodeGen/2002-03-14-QuotesInStrConst.c create mode 100644 clang/test/CodeGen/2002-04-07-SwitchStmt.c create mode 100644 clang/test/CodeGen/2002-04-08-LocalArray.c create mode 100644 clang/test/CodeGen/2002-04-09-StructRetVal.c create mode 100644 clang/test/CodeGen/2002-04-10-StructParameters.c create mode 100644 clang/test/CodeGen/2002-05-23-StaticValues.c create mode 100644 clang/test/CodeGen/2002-05-23-TypeNameCollision.c create mode 100644 clang/test/CodeGen/2002-05-24-Alloca.c create mode 100644 clang/test/CodeGen/2002-06-25-FWriteInterfaceFailure.c create mode 100644 clang/test/CodeGen/2002-07-14-MiscListTests.c create mode 100644 clang/test/CodeGen/2002-07-14-MiscTests.c create mode 100644 clang/test/CodeGen/2002-07-14-MiscTests2.c create mode 100644 clang/test/CodeGen/2002-07-14-MiscTests3.c create mode 100644 clang/test/CodeGen/2002-07-16-HardStringInit.c create mode 100644 clang/test/CodeGen/2002-07-17-StringConstant.c create mode 100644 clang/test/CodeGen/2002-07-30-SubregSetAssertion.c create mode 100644 clang/test/CodeGen/2002-07-30-UnionTest.c create mode 100644 clang/test/CodeGen/2002-07-30-VarArgsCallFailure.c create mode 100644 clang/test/CodeGen/2002-07-31-BadAssert.c create mode 100644 clang/test/CodeGen/2002-07-31-SubregFailure.c create mode 100644 clang/test/CodeGen/2002-08-02-UnionTest.c create mode 100644 clang/test/CodeGen/2002-08-19-RecursiveLocals.c create mode 100644 clang/test/CodeGen/2002-09-08-PointerShifts.c create mode 100644 clang/test/CodeGen/2002-09-18-UnionProblem.c create mode 100644 clang/test/CodeGen/2002-09-19-StarInLabel.c create mode 100644 clang/test/CodeGen/2002-10-12-TooManyArguments.c create mode 100644 clang/test/CodeGen/2002-12-15-GlobalBoolTest.c create mode 100644 clang/test/CodeGen/2002-12-15-GlobalConstantTest.c create mode 100644 clang/test/CodeGen/2002-12-15-GlobalRedefinition.c create mode 100644 clang/test/CodeGen/2002-12-15-StructParameters.c create mode 100644 clang/test/CodeGen/2003-01-30-UnionInit.c create mode 100644 clang/test/CodeGen/2003-03-03-DeferredType.c create mode 100644 clang/test/CodeGen/2003-06-22-UnionCrash.c create mode 100644 clang/test/CodeGen/2003-06-23-GCC-fold-infinite-recursion.c create mode 100644 clang/test/CodeGen/2003-06-26-CFECrash.c create mode 100644 clang/test/CodeGen/2003-06-29-MultipleFunctionDefinition.c create mode 100644 clang/test/CodeGen/2003-07-22-ArrayAccessTypeSafety.c create mode 100644 clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c create mode 100644 clang/test/CodeGen/2003-08-17-DeadCodeShortCircuit.c create mode 100644 clang/test/CodeGen/2003-08-18-SigSetJmp.c create mode 100644 clang/test/CodeGen/2003-08-18-StructAsValue.c create mode 100644 clang/test/CodeGen/2003-08-20-BadBitfieldRef.c create mode 100644 clang/test/CodeGen/2003-08-20-PrototypeMismatch.c create mode 100644 clang/test/CodeGen/2003-08-20-vfork-bug.c create mode 100644 clang/test/CodeGen/2003-08-21-BinOp-Type-Mismatch.c create mode 100644 clang/test/CodeGen/2003-08-21-StmtExpr.c create mode 100644 clang/test/CodeGen/2003-08-21-WideString.c create mode 100644 clang/test/CodeGen/2003-08-23-LocalUnionTest.c create mode 100644 clang/test/CodeGen/2003-08-29-BitFieldStruct.c create mode 100644 clang/test/CodeGen/2003-08-29-HugeCharConst.c create mode 100644 clang/test/CodeGen/2003-08-29-StructLayoutBug.c create mode 100644 clang/test/CodeGen/2003-08-30-AggregateInitializer.c create mode 100644 clang/test/CodeGen/2003-08-30-LargeIntegerBitfieldMember.c create mode 100644 clang/test/CodeGen/2003-09-18-BitfieldTests.c create mode 100644 clang/test/CodeGen/2003-09-30-StructLayout.c create mode 100644 clang/test/CodeGen/2003-10-02-UnionLValueError.c create mode 100644 clang/test/CodeGen/2003-10-06-NegateExprType.c create mode 100644 clang/test/CodeGen/2003-10-09-UnionInitializerBug.c create mode 100644 clang/test/CodeGen/2003-10-28-ident.c create mode 100644 clang/test/CodeGen/2003-10-29-AsmRename.c create mode 100644 clang/test/CodeGen/2003-11-01-C99-CompoundLiteral.c create mode 100644 clang/test/CodeGen/2003-11-01-EmptyStructCrash.c create mode 100644 clang/test/CodeGen/2003-11-01-GlobalUnionInit.c create mode 100644 clang/test/CodeGen/2003-11-03-AddrArrayElement.c create mode 100644 clang/test/CodeGen/2003-11-04-EmptyStruct.c create mode 100644 clang/test/CodeGen/2003-11-04-OutOfMemory.c create mode 100644 clang/test/CodeGen/2003-11-08-PointerSubNotGetelementptr.c create mode 100644 clang/test/CodeGen/2003-11-12-VoidString.c create mode 100644 clang/test/CodeGen/2003-11-13-TypeSafety.c create mode 100644 clang/test/CodeGen/2003-11-16-StaticArrayInit.c create mode 100644 clang/test/CodeGen/2003-11-18-CondExprLValue.c create mode 100644 clang/test/CodeGen/2003-11-19-AddressOfRegister.c create mode 100644 clang/test/CodeGen/2003-11-19-BitFieldArray.c create mode 100644 clang/test/CodeGen/2003-11-20-Bitfields.c create mode 100644 clang/test/CodeGen/2003-11-20-ComplexDivision.c create mode 100644 clang/test/CodeGen/2003-11-20-UnionBitfield.c create mode 100644 clang/test/CodeGen/2003-11-26-PointerShift.c create mode 100644 clang/test/CodeGen/2003-11-27-ConstructorCast.c create mode 100644 clang/test/CodeGen/2003-11-27-UnionCtorInitialization.c create mode 100644 clang/test/CodeGen/2003-12-14-ExternInlineSupport.c create mode 100644 clang/test/CodeGen/2004-01-01-UnknownInitSize.c create mode 100644 clang/test/CodeGen/2004-01-08-ExternInlineRedefine.c create mode 100644 clang/test/CodeGen/2004-02-12-LargeAggregateCopy.c create mode 100644 clang/test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c create mode 100644 clang/test/CodeGen/2004-02-13-IllegalVararg.c create mode 100644 clang/test/CodeGen/2004-02-13-Memset.c create mode 100644 clang/test/CodeGen/2004-02-14-ZeroInitializer.c create mode 100644 clang/test/CodeGen/2004-02-20-Builtins.c create mode 100644 clang/test/CodeGen/2004-03-07-ComplexDivEquals.c create mode 100644 clang/test/CodeGen/2004-03-07-ExternalConstant.c create mode 100644 clang/test/CodeGen/2004-03-09-LargeArrayInitializers.c create mode 100644 clang/test/CodeGen/2004-03-15-SimpleIndirectGoto.c create mode 100644 clang/test/CodeGen/2004-03-16-AsmRegisterCrash.c create mode 100644 clang/test/CodeGen/2004-05-07-VarArrays.c create mode 100644 clang/test/CodeGen/2004-05-21-IncompleteEnum.c create mode 100644 clang/test/CodeGen/2004-06-08-OpaqueStructArg.c create mode 100644 clang/test/CodeGen/2004-06-17-UnorderedBuiltins.c create mode 100644 clang/test/CodeGen/2004-06-17-UnorderedCompares.c create mode 100644 clang/test/CodeGen/2004-06-18-VariableLengthArrayOfStructures.c create mode 100644 clang/test/CodeGen/2004-07-06-FunctionCast.c create mode 100644 clang/test/CodeGen/2004-08-06-LargeStructTest.c create mode 100644 clang/test/CodeGen/2004-11-25-UnnamedBitfieldPadding.c create mode 100644 clang/test/CodeGen/2004-11-27-InvalidConstantExpr.c create mode 100644 clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c create mode 100644 clang/test/CodeGen/2005-01-02-ConstantInits.c create mode 100644 clang/test/CodeGen/2005-01-02-PointerDifference.c create mode 100644 clang/test/CodeGen/2005-01-02-VAArgError-ICE.c create mode 100644 clang/test/CodeGen/2005-02-20-AggregateSAVEEXPR.c create mode 100644 clang/test/CodeGen/2005-02-27-MarkGlobalConstant.c create mode 100644 clang/test/CodeGen/2005-03-05-OffsetOfHack.c create mode 100644 clang/test/CodeGen/2005-03-06-OffsetOfStructCrash.c create mode 100644 clang/test/CodeGen/2005-03-11-Prefetch.c create mode 100644 clang/test/CodeGen/2005-04-09-ComplexOps.c create mode 100644 clang/test/CodeGen/2005-05-10-GlobalUnionInit.c create mode 100644 clang/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c create mode 100644 clang/test/CodeGen/2005-07-20-SqrtNoErrno.c create mode 100644 clang/test/CodeGen/2005-07-26-UnionInitCrash.c create mode 100644 clang/test/CodeGen/2005-07-28-IncorrectWeakGlobal.c create mode 100644 clang/test/CodeGen/2005-09-20-ComplexConstants.c create mode 100644 clang/test/CodeGen/2005-09-24-AsmUserPrefix.c create mode 100644 clang/test/CodeGen/2005-09-24-BitFieldCrash.c create mode 100644 clang/test/CodeGen/2005-12-04-AttributeUsed.c create mode 100644 clang/test/CodeGen/2005-12-04-DeclarationLineNumbers.c create mode 100644 clang/test/CodeGen/2006-01-13-Includes.c create mode 100644 clang/test/CodeGen/2006-01-13-StackSave.c create mode 100644 clang/test/CodeGen/2006-01-16-BitCountIntrinsicsUnsigned.c create mode 100644 clang/test/CodeGen/2006-01-23-FileScopeAsm.c create mode 100644 clang/test/CodeGen/2006-03-03-MissingInitializer.c create mode 100644 clang/test/CodeGen/2006-03-16-VectorCtor.c create mode 100644 clang/test/CodeGen/2006-03-17-KnRMismatch.c create mode 100644 clang/test/CodeGen/2006-05-19-SingleEltReturn.c create mode 100644 clang/test/CodeGen/2006-07-31-PR854.c create mode 100644 clang/test/CodeGen/2006-09-11-BitfieldRefCrash.c create mode 100644 clang/test/CodeGen/2006-09-18-fwrite-cast-crash.c create mode 100644 clang/test/CodeGen/2006-09-21-IncompleteElementType.c create mode 100644 clang/test/CodeGen/2006-09-25-DebugFilename.c create mode 100644 clang/test/CodeGen/2006-09-25-DebugFilename.h create mode 100644 clang/test/CodeGen/2006-09-28-SimpleAsm.c create mode 100644 clang/test/CodeGen/2006-10-30-ArrayCrash.c create mode 100644 clang/test/CodeGen/2006-12-14-ordered_expr.c create mode 100644 clang/test/CodeGen/2007-01-06-KNR-Proto.c create mode 100644 clang/test/CodeGen/2007-01-20-VectorICE.c create mode 100644 clang/test/CodeGen/2007-01-24-InlineAsmCModifier.c create mode 100644 clang/test/CodeGen/2007-02-04-AddrLValue-2.c create mode 100644 clang/test/CodeGen/2007-02-04-AddrLValue.c create mode 100644 clang/test/CodeGen/2007-02-04-EmptyStruct.c create mode 100644 clang/test/CodeGen/2007-02-07-AddrLabel.c create mode 100644 clang/test/CodeGen/2007-02-16-VoidPtrDiff.c create mode 100644 clang/test/CodeGen/2007-02-25-C-DotDotDot.c create mode 100644 clang/test/CodeGen/2007-03-01-VarSizeArrayIdx.c create mode 100644 clang/test/CodeGen/2007-03-05-DataLayout.c create mode 100644 clang/test/CodeGen/2007-03-26-BitfieldAfterZeroWidth.c create mode 100644 clang/test/CodeGen/2007-03-26-ZeroWidthBitfield.c create mode 100644 clang/test/CodeGen/2007-03-27-VarLengthArray.c create mode 100644 clang/test/CodeGen/2007-04-05-PackedBitFields-2.c create mode 100644 clang/test/CodeGen/2007-04-05-PackedBitFields.c create mode 100644 clang/test/CodeGen/2007-04-05-PackedStruct.c create mode 100644 clang/test/CodeGen/2007-04-05-PadBeforeZeroLengthField.c create mode 100644 clang/test/CodeGen/2007-04-05-UnPackedStruct.c create mode 100644 clang/test/CodeGen/2007-04-11-InlineAsmStruct.c create mode 100644 clang/test/CodeGen/2007-04-11-InlineAsmUnion.c create mode 100644 clang/test/CodeGen/2007-04-11-PR1321.c create mode 100644 clang/test/CodeGen/2007-04-13-InlineAsmStruct2.c create mode 100644 clang/test/CodeGen/2007-04-13-InlineAsmUnion2.c create mode 100644 clang/test/CodeGen/2007-04-14-FNoBuiltin.c create mode 100644 clang/test/CodeGen/2007-04-17-ZeroSizeBitFields.c create mode 100644 clang/test/CodeGen/2007-04-24-VolatileStructCopy.c create mode 100644 clang/test/CodeGen/2007-04-24-bit-not-expr.c create mode 100644 clang/test/CodeGen/2007-04-24-str-const.c create mode 100644 clang/test/CodeGen/2007-05-07-PaddingElements.c create mode 100644 clang/test/CodeGen/2007-05-08-PCH.c create mode 100644 clang/test/CodeGen/2007-05-11-str-const.c create mode 100644 clang/test/CodeGen/2007-05-15-PaddingElement.c create mode 100644 clang/test/CodeGen/2007-05-16-EmptyStruct.c create mode 100644 clang/test/CodeGen/2007-05-29-UnionCopy.c create mode 100644 clang/test/CodeGen/2007-06-05-NoInlineAttribute.c create mode 100644 clang/test/CodeGen/2007-06-15-AnnotateAttribute.c create mode 100644 clang/test/CodeGen/2007-06-18-SextAttrAggregate.c create mode 100644 clang/test/CodeGen/2007-07-29-RestrictPtrArg.c create mode 100644 clang/test/CodeGen/2007-08-01-LoadStoreAlign.c create mode 100644 clang/test/CodeGen/2007-08-21-ComplexCst.c create mode 100644 clang/test/CodeGen/2007-08-22-CTTZ.c create mode 100644 clang/test/CodeGen/2007-09-05-ConstCtor.c create mode 100644 clang/test/CodeGen/2007-09-12-PragmaPack.c create mode 100644 clang/test/CodeGen/2007-09-14-NegatePointer.c create mode 100644 clang/test/CodeGen/2007-09-17-WeakRef.c create mode 100644 clang/test/CodeGen/2007-09-26-Alignment.c create mode 100644 clang/test/CodeGen/2007-09-27-ComplexIntCompare.c create mode 100644 clang/test/CodeGen/2007-09-28-PackedUnionMember.c create mode 100644 clang/test/CodeGen/2007-10-02-VolatileArray.c create mode 100644 clang/test/CodeGen/2007-10-15-VoidPtr.c create mode 100644 clang/test/CodeGen/2007-10-30-Volatile.c create mode 100644 clang/test/CodeGen/2007-11-07-AlignedMemcpy.c create mode 100644 clang/test/CodeGen/2007-11-07-CopyAggregateAlign.c create mode 100644 clang/test/CodeGen/2007-11-07-ZeroAggregateAlign.c create mode 100644 clang/test/CodeGen/2007-11-28-GlobalInitializer.c create mode 100644 clang/test/CodeGen/2007-11-29-ArraySizeFromInitializer.c create mode 100644 clang/test/CodeGen/2007-12-16-AsmNoUnwind.c create mode 100644 clang/test/CodeGen/2008-01-04-WideBitfield.c create mode 100644 clang/test/CodeGen/2008-01-07-UnusualIntSize.c create mode 100644 clang/test/CodeGen/2008-01-11-ChainConsistency.c create mode 100644 clang/test/CodeGen/2008-01-21-PackedBitFields.c create mode 100644 clang/test/CodeGen/2008-01-21-PackedStructField.c create mode 100644 clang/test/CodeGen/2008-01-24-StructAlignAndBitFields.c create mode 100644 clang/test/CodeGen/2008-01-25-ByValReadNone.c create mode 100644 clang/test/CodeGen/2008-01-25-ZeroSizedAggregate.c create mode 100644 clang/test/CodeGen/2008-01-28-PragmaMark.c create mode 100644 clang/test/CodeGen/2008-01-28-UnionSize.c create mode 100644 clang/test/CodeGen/2008-02-07-bitfield-bug.c create mode 100644 clang/test/CodeGen/2008-02-08-bitfield-bug.c create mode 100644 clang/test/CodeGen/2008-02-26-inline-asm-bug.c create mode 100644 clang/test/CodeGen/2008-03-03-CtorAttrType.c create mode 100644 clang/test/CodeGen/2008-03-05-syncPtr.c create mode 100644 clang/test/CodeGen/2008-03-24-BitField-And-Alloca.c create mode 100644 clang/test/CodeGen/2008-03-26-PackedBitFields.c create mode 100644 clang/test/CodeGen/2008-04-08-NoExceptions.c create mode 100644 clang/test/CodeGen/2008-05-06-CFECrash.c create mode 100644 clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c create mode 100644 clang/test/CodeGen/2008-05-19-AlwaysInline.c create mode 100644 clang/test/CodeGen/2008-07-17-no-emit-on-error.c create mode 100644 clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c create mode 100644 clang/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c create mode 100644 clang/test/CodeGen/2008-07-22-packed-bitfield-access.c create mode 100644 clang/test/CodeGen/2008-07-29-override-alias-decl.c create mode 100644 clang/test/CodeGen/2008-07-30-implicit-initialization.c create mode 100644 clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c create mode 100644 clang/test/CodeGen/2008-07-31-asm-labels.c create mode 100644 clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c create mode 100644 clang/test/CodeGen/2008-08-04-void-pointer-arithmetic.c create mode 100644 clang/test/CodeGen/2008-08-07-AlignPadding1.c create mode 100644 clang/test/CodeGen/2008-08-07-AlignPadding2.c create mode 100644 clang/test/CodeGen/2008-08-07-GEPIntToPtr.c create mode 100644 clang/test/CodeGen/2008-08-19-cast-of-typedef.c create mode 100644 clang/test/CodeGen/2008-09-03-WeakAlias.c create mode 100644 clang/test/CodeGen/2008-09-22-bad-switch-type.c create mode 100644 clang/test/CodeGen/2008-10-13-FrontendCrash.c create mode 100644 clang/test/CodeGen/2008-10-30-ZeroPlacement.c create mode 100644 clang/test/CodeGen/2008-11-02-WeakAlias.c create mode 100644 clang/test/CodeGen/2008-11-08-InstCombineSelect.c create mode 100644 clang/test/CodeGen/2008-12-23-AsmIntPointerTie.c create mode 100644 clang/test/CodeGen/2009-01-05-BlockInlining.c create mode 100644 clang/test/CodeGen/2009-01-21-InvalidIterator.c create mode 100644 clang/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c create mode 100644 clang/test/CodeGen/2009-02-13-zerosize-union-field.c create mode 100644 clang/test/CodeGen/2009-03-01-MallocNoAlias.c create mode 100644 clang/test/CodeGen/2009-03-08-ZeroEltStructCrash.c create mode 100644 clang/test/CodeGen/2009-03-13-dbg.c create mode 100644 clang/test/CodeGen/2009-03-22-increment-bitfield.c create mode 100644 clang/test/CodeGen/2009-04-23-dbg.c create mode 100644 clang/test/CodeGen/2009-04-28-UnionArrayCrash.c create mode 100644 clang/test/CodeGen/2009-05-04-EnumInreg.c create mode 100644 clang/test/CodeGen/2009-05-22-callingconv.c create mode 100644 clang/test/CodeGen/2009-05-28-const-typedef.c create mode 100644 clang/test/CodeGen/2009-06-01-addrofknr.c create mode 100644 clang/test/CodeGen/2009-06-14-HighlyAligned.c create mode 100644 clang/test/CodeGen/2009-06-14-anonymous-union-init.c create mode 100644 clang/test/CodeGen/2009-06-18-StaticInitTailPadPack.c create mode 100644 clang/test/CodeGen/2009-07-14-VoidPtr.c create mode 100644 clang/test/CodeGen/2009-07-15-pad-wchar_t-array.c create mode 100644 clang/test/CodeGen/2009-07-22-StructLayout.c create mode 100644 clang/test/CodeGen/2009-07-31-DbgDeclare.c create mode 100644 clang/test/CodeGen/2009-08-14-vararray-crash.c create mode 100644 clang/test/CodeGen/2009-09-24-SqrtErrno.c create mode 100644 clang/test/CodeGen/2009-10-20-GlobalDebug.c create mode 100644 clang/test/CodeGen/2009-12-07-BitFieldAlignment.c create mode 100644 clang/test/CodeGen/2010-01-13-MemBarrier.c create mode 100644 clang/test/CodeGen/2010-01-14-FnType-DebugInfo.c create mode 100644 clang/test/CodeGen/2010-01-18-Inlined-Debug.c create mode 100644 clang/test/CodeGen/2010-02-10-PointerName.c create mode 100644 clang/test/CodeGen/2010-02-15-DbgStaticVar.c create mode 100644 clang/test/CodeGen/2010-02-16-DbgScopes.c create mode 100644 clang/test/CodeGen/2010-02-18-Dbg-VectorType.c create mode 100644 clang/test/CodeGen/2010-03-09-DbgInfo.c create mode 100644 clang/test/CodeGen/2010-03-5-LexicalScope.c create mode 100644 clang/test/CodeGen/2010-05-26-AsmSideEffect.c create mode 100644 clang/test/CodeGen/2010-06-11-SaveExpr.c create mode 100644 clang/test/CodeGen/2010-06-17-asmcrash.c create mode 100644 clang/test/CodeGen/2010-07-08-DeclDebugLineNo.c create mode 100644 clang/test/CodeGen/2010-07-14-overconservative-align.c create mode 100644 clang/test/CodeGen/2010-07-14-ref-off-end.c create mode 100644 clang/test/CodeGen/2010-08-10-DbgConstant.c create mode 100644 clang/test/CodeGen/2010-08-12-asm-aggr-arg.c create mode 100644 clang/test/CodeGen/2010-12-01-CommonGlobal.c create mode 100644 clang/test/CodeGen/2011-02-21-DATA-common.c create mode 100644 clang/test/CodeGen/2011-03-02-UnionInitializer.c create mode 100644 clang/test/CodeGen/2011-03-08-ZeroFieldUnionInitializer.c create mode 100644 clang/test/CodeGen/2011-03-31-ArrayRefFolding.c create mode 100644 clang/test/CodeGen/3dnow-builtins.c create mode 100644 clang/test/CodeGen/Atomics.c create mode 100644 clang/test/CodeGen/BasicInstrs.c create mode 100644 clang/test/CodeGen/Inputs/stdio.h create mode 100644 clang/test/CodeGen/OpaqueStruct.c create mode 100644 clang/test/CodeGen/PR2001-bitfield-reload.c create mode 100644 clang/test/CodeGen/PR2413-void-address-cast-error.c create mode 100644 clang/test/CodeGen/PR2643-null-store-to-bitfield.c create mode 100644 clang/test/CodeGen/PR2743-reference-missing-static.c create mode 100644 clang/test/CodeGen/PR3130-cond-constant.c create mode 100644 clang/test/CodeGen/PR3589-freestanding-libcalls.c create mode 100644 clang/test/CodeGen/PR3613-static-decl.c create mode 100644 clang/test/CodeGen/PR3709-int-to-pointer-sign.c create mode 100644 clang/test/CodeGen/PR4611-bitfield-layout.c create mode 100644 clang/test/CodeGen/PR5060-align.c create mode 100644 clang/test/CodeGen/_Bool-conversion.c create mode 100644 clang/test/CodeGen/address-safety-attr.cpp create mode 100644 clang/test/CodeGen/address-space-cast.c create mode 100644 clang/test/CodeGen/address-space-compound-literal.c create mode 100644 clang/test/CodeGen/address-space-field1.c create mode 100644 clang/test/CodeGen/address-space.c create mode 100644 clang/test/CodeGen/alias.c create mode 100644 clang/test/CodeGen/align-local.c create mode 100644 clang/test/CodeGen/align-param.c create mode 100644 clang/test/CodeGen/alignment.c create mode 100644 clang/test/CodeGen/alignof.c create mode 100644 clang/test/CodeGen/altivec.c create mode 100644 clang/test/CodeGen/always-inline.c create mode 100644 clang/test/CodeGen/always_inline.c create mode 100644 clang/test/CodeGen/annotations-builtin.c create mode 100644 clang/test/CodeGen/annotations-field.c create mode 100644 clang/test/CodeGen/annotations-global.c create mode 100644 clang/test/CodeGen/annotations-loc.c create mode 100644 clang/test/CodeGen/annotations-var.c create mode 100644 clang/test/CodeGen/arm-aapcs-vfp.c create mode 100644 clang/test/CodeGen/arm-aapcs-zerolength-bitfield.c create mode 100644 clang/test/CodeGen/arm-apcs-zerolength-bitfield.c create mode 100644 clang/test/CodeGen/arm-arguments.c create mode 100644 clang/test/CodeGen/arm-asm-variable.c create mode 100644 clang/test/CodeGen/arm-asm.c create mode 100644 clang/test/CodeGen/arm-cc.c create mode 100644 clang/test/CodeGen/arm-clear.c create mode 100644 clang/test/CodeGen/arm-homogenous.c create mode 100644 clang/test/CodeGen/arm-inline-asm.c create mode 100644 clang/test/CodeGen/arm-pcs.c create mode 100644 clang/test/CodeGen/arm-vaarg-align.c create mode 100644 clang/test/CodeGen/arm-vector-align.c create mode 100644 clang/test/CodeGen/arm-vector-arguments.c create mode 100644 clang/test/CodeGen/array.c create mode 100644 clang/test/CodeGen/arrayderef.c create mode 100644 clang/test/CodeGen/asm-errors.c create mode 100644 clang/test/CodeGen/asm-inout.c create mode 100644 clang/test/CodeGen/asm-label.c create mode 100644 clang/test/CodeGen/asm-reg-var-local.c create mode 100644 clang/test/CodeGen/asm-variable.c create mode 100644 clang/test/CodeGen/asm.c create mode 100644 clang/test/CodeGen/asm_arm.c create mode 100644 clang/test/CodeGen/assign.c create mode 100644 clang/test/CodeGen/atomic-ops.c create mode 100644 clang/test/CodeGen/atomic.c create mode 100644 clang/test/CodeGen/atomic_ops.c create mode 100644 clang/test/CodeGen/attr-availability.c create mode 100644 clang/test/CodeGen/attr-cleanup.c create mode 100644 clang/test/CodeGen/attr-naked.c create mode 100644 clang/test/CodeGen/attr-nodebug.c create mode 100644 clang/test/CodeGen/attr-noinline.c create mode 100644 clang/test/CodeGen/attr-used.c create mode 100644 clang/test/CodeGen/attr-weak-import.c create mode 100644 clang/test/CodeGen/attr-weakref.c create mode 100644 clang/test/CodeGen/attr-weakref2.c create mode 100644 clang/test/CodeGen/attribute-section-data-common.c create mode 100644 clang/test/CodeGen/attribute_constructor.c create mode 100644 clang/test/CodeGen/attributes.c create mode 100644 clang/test/CodeGen/available-externally-suppress.c create mode 100644 clang/test/CodeGen/avx-builtins.c create mode 100644 clang/test/CodeGen/avx-cmp-builtins.c create mode 100644 clang/test/CodeGen/avx-shuffle-builtins.c create mode 100644 clang/test/CodeGen/avx2-builtins.c create mode 100644 clang/test/CodeGen/bitfield-2.c create mode 100644 clang/test/CodeGen/bitfield-assign.c create mode 100644 clang/test/CodeGen/bitfield-init.c create mode 100644 clang/test/CodeGen/bitfield-promote.c create mode 100644 clang/test/CodeGen/bitfield.c create mode 100644 clang/test/CodeGen/block-3.c create mode 100644 clang/test/CodeGen/block-byref-aggr.c create mode 100644 clang/test/CodeGen/block-copy.c create mode 100644 clang/test/CodeGen/blocks-1.c create mode 100644 clang/test/CodeGen/blocks-2.c create mode 100644 clang/test/CodeGen/blocks-aligned-byref-variable.c create mode 100644 clang/test/CodeGen/blocks-seq.c create mode 100644 clang/test/CodeGen/blocks.c create mode 100644 clang/test/CodeGen/blocksignature.c create mode 100644 clang/test/CodeGen/blockstret.c create mode 100644 clang/test/CodeGen/blockwithlocalstatic.c create mode 100644 clang/test/CodeGen/bmi-builtins.c create mode 100644 clang/test/CodeGen/bmi2-builtins.c create mode 100644 clang/test/CodeGen/bool-bitfield.c create mode 100644 clang/test/CodeGen/bool-convert.c create mode 100644 clang/test/CodeGen/bool-init.c create mode 100644 clang/test/CodeGen/bool_test.c create mode 100644 clang/test/CodeGen/boolassign.c create mode 100644 clang/test/CodeGen/builtin-attributes.c create mode 100644 clang/test/CodeGen/builtin-count-zeros.c create mode 100644 clang/test/CodeGen/builtin-expect.c create mode 100644 clang/test/CodeGen/builtin-memfns.c create mode 100644 clang/test/CodeGen/builtin-nanf.c create mode 100644 clang/test/CodeGen/builtin-recursive.cc create mode 100644 clang/test/CodeGen/builtin-rename.c create mode 100644 clang/test/CodeGen/builtin-stackaddress.c create mode 100644 clang/test/CodeGen/builtin-unwind-init.c create mode 100644 clang/test/CodeGen/builtins-arm.c create mode 100644 clang/test/CodeGen/builtins-ppc-altivec.c create mode 100644 clang/test/CodeGen/builtins-ptx.c create mode 100644 clang/test/CodeGen/builtins-x86.c create mode 100644 clang/test/CodeGen/builtins.c create mode 100644 clang/test/CodeGen/builtinshufflevector.c create mode 100644 clang/test/CodeGen/builtinshufflevector2.c create mode 100644 clang/test/CodeGen/byval-memcpy-elim.c create mode 100644 clang/test/CodeGen/c-strings.c create mode 100644 clang/test/CodeGen/call.c create mode 100644 clang/test/CodeGen/capture-complex-expr-in-block.c create mode 100644 clang/test/CodeGen/cast-emit.c create mode 100644 clang/test/CodeGen/cast.c create mode 100644 clang/test/CodeGen/catch-undef-behavior.c create mode 100644 clang/test/CodeGen/cfstring.c create mode 100644 clang/test/CodeGen/cfstring2.c create mode 100644 clang/test/CodeGen/char-literal.c create mode 100644 clang/test/CodeGen/cleanup-stack.c create mode 100644 clang/test/CodeGen/complex-indirect.c create mode 100644 clang/test/CodeGen/complex-init-list.c create mode 100644 clang/test/CodeGen/complex.c create mode 100644 clang/test/CodeGen/compound-literal.c create mode 100644 clang/test/CodeGen/compound-type.c create mode 100644 clang/test/CodeGen/compound.c create mode 100644 clang/test/CodeGen/conditional-gnu-ext.c create mode 100644 clang/test/CodeGen/conditional.c create mode 100644 clang/test/CodeGen/const-arithmetic.c create mode 100644 clang/test/CodeGen/const-init.c create mode 100644 clang/test/CodeGen/const-label-addr.c create mode 100644 clang/test/CodeGen/const-unordered-compare.c create mode 100644 clang/test/CodeGen/constant-comparison.c create mode 100644 clang/test/CodeGen/constructor-attribute.c create mode 100644 clang/test/CodeGen/count-builtins.c create mode 100644 clang/test/CodeGen/cxx-condition.cpp create mode 100644 clang/test/CodeGen/cxx-default-arg.cpp create mode 100644 clang/test/CodeGen/cxx-value-init.cpp create mode 100644 clang/test/CodeGen/darwin-string-literals.c create mode 100644 clang/test/CodeGen/darwin-thread-specifier.c create mode 100644 clang/test/CodeGen/debug-dead-local-var.c create mode 100644 clang/test/CodeGen/debug-info-args.c create mode 100644 clang/test/CodeGen/debug-info-block.c create mode 100644 clang/test/CodeGen/debug-info-compilation-dir.c create mode 100644 clang/test/CodeGen/debug-info-crash.c create mode 100644 clang/test/CodeGen/debug-info-enum.c create mode 100644 clang/test/CodeGen/debug-info-iv.c create mode 100644 clang/test/CodeGen/debug-info-line.c create mode 100644 clang/test/CodeGen/debug-info-line2.c create mode 100644 clang/test/CodeGen/debug-info-line3.c create mode 100644 clang/test/CodeGen/debug-info-member.c create mode 100644 clang/test/CodeGen/debug-info-scope.c create mode 100644 clang/test/CodeGen/debug-info-static.c create mode 100644 clang/test/CodeGen/debug-info-var-location.c create mode 100644 clang/test/CodeGen/debug-info.c create mode 100644 clang/test/CodeGen/debug-line-1.c create mode 100644 clang/test/CodeGen/decl-in-prototype.c create mode 100644 clang/test/CodeGen/decl.c create mode 100644 clang/test/CodeGen/designated-initializers.c create mode 100644 clang/test/CodeGen/dllimport-dllexport.c create mode 100644 clang/test/CodeGen/dostmt.c create mode 100644 clang/test/CodeGen/emit-all-decls.c create mode 100644 clang/test/CodeGen/empty-union-init.c create mode 100644 clang/test/CodeGen/enum.c create mode 100644 clang/test/CodeGen/enum2.c create mode 100644 clang/test/CodeGen/exact-div-expr.c create mode 100644 clang/test/CodeGen/exceptions.c create mode 100644 clang/test/CodeGen/exprs.c create mode 100644 clang/test/CodeGen/ext-vector-member-alignment.c create mode 100644 clang/test/CodeGen/ext-vector.c create mode 100644 clang/test/CodeGen/extern-block-var.c create mode 100644 clang/test/CodeGen/extern-inline.c create mode 100644 clang/test/CodeGen/extern-weak.c create mode 100644 clang/test/CodeGen/flexible-array-init.c create mode 100644 clang/test/CodeGen/fma4-builtins.c create mode 100644 clang/test/CodeGen/fold-const-declref.c create mode 100644 clang/test/CodeGen/fp16-ops.c create mode 100644 clang/test/CodeGen/frame-pointer-elim.c create mode 100644 clang/test/CodeGen/func-aligned.c create mode 100644 clang/test/CodeGen/func-decl-cleanup.c create mode 100644 clang/test/CodeGen/func-in-block.c create mode 100644 clang/test/CodeGen/func-ptr-cast-decl.c create mode 100644 clang/test/CodeGen/func-return-member.c create mode 100644 clang/test/CodeGen/funccall.c create mode 100644 clang/test/CodeGen/function-attributes.c create mode 100644 clang/test/CodeGen/functions.c create mode 100644 clang/test/CodeGen/global-decls.c create mode 100644 clang/test/CodeGen/global-init.c create mode 100644 clang/test/CodeGen/global-with-initialiser.c create mode 100644 clang/test/CodeGen/globalinit.c create mode 100644 clang/test/CodeGen/hidden-visibility.c create mode 100644 clang/test/CodeGen/imaginary.c create mode 100644 clang/test/CodeGen/implicit-arg.c create mode 100644 clang/test/CodeGen/incomplete-function-type.c create mode 100644 clang/test/CodeGen/indirect-goto.c create mode 100644 clang/test/CodeGen/init-with-member-expr.c create mode 100644 clang/test/CodeGen/init.c create mode 100644 clang/test/CodeGen/inline-asm-mrv.c create mode 100644 clang/test/CodeGen/inline.c create mode 100644 clang/test/CodeGen/inline2.c create mode 100644 clang/test/CodeGen/instrument-functions.c create mode 100644 clang/test/CodeGen/int-to-pointer.c create mode 100644 clang/test/CodeGen/integer-overflow.c create mode 100644 clang/test/CodeGen/kr-func-promote.c create mode 100644 clang/test/CodeGen/kr-style-block.c create mode 100644 clang/test/CodeGen/libcalls-d.c create mode 100644 clang/test/CodeGen/libcalls-fno-builtin.c create mode 100644 clang/test/CodeGen/libcalls-ld.c create mode 100644 clang/test/CodeGen/libcalls.c create mode 100644 clang/test/CodeGen/lifetime.c create mode 100644 clang/test/CodeGen/lineno-dbginfo.c create mode 100644 clang/test/CodeGen/link-bitcode-file.c create mode 100644 clang/test/CodeGen/linkage-redecl.c create mode 100644 clang/test/CodeGen/long-double-x86.c create mode 100644 clang/test/CodeGen/lzcnt-builtins.c create mode 100644 clang/test/CodeGen/mandel.c create mode 100644 clang/test/CodeGen/mangle.c create mode 100644 clang/test/CodeGen/may-alias.c create mode 100644 clang/test/CodeGen/mcount.c create mode 100644 clang/test/CodeGen/merge-attrs.c create mode 100644 clang/test/CodeGen/merge-statics.c create mode 100644 clang/test/CodeGen/microsoft-call-conv.c create mode 100644 clang/test/CodeGen/mips-clobber-reg.c create mode 100644 clang/test/CodeGen/mips-constraint-regs.c create mode 100644 clang/test/CodeGen/mips64-class-return.cpp create mode 100644 clang/test/CodeGen/mips64-f128-literal.c create mode 100644 clang/test/CodeGen/mips64-nontrivial-return.cpp create mode 100644 clang/test/CodeGen/mips64-padding-arg.c create mode 100644 clang/test/CodeGen/misaligned-param.c create mode 100644 clang/test/CodeGen/mms-bitfields.c create mode 100644 clang/test/CodeGen/mmx-builtins.c create mode 100644 clang/test/CodeGen/mmx-inline-asm.c create mode 100644 clang/test/CodeGen/mmx-shift-with-immediate.c create mode 100644 clang/test/CodeGen/mrtd.c create mode 100644 clang/test/CodeGen/ms-anonymous-struct.c create mode 100644 clang/test/CodeGen/ms-declspecs.c create mode 100644 clang/test/CodeGen/ms_struct-bitfield-1.c create mode 100644 clang/test/CodeGen/ms_struct-bitfield-2.c create mode 100644 clang/test/CodeGen/ms_struct-bitfield-3.c create mode 100644 clang/test/CodeGen/ms_struct-bitfield-init.c create mode 100644 clang/test/CodeGen/ms_struct-bitfield.c create mode 100644 clang/test/CodeGen/ms_struct-pack.c create mode 100644 clang/test/CodeGen/ms_struct.c create mode 100644 clang/test/CodeGen/mult-alt-generic.c create mode 100644 clang/test/CodeGen/mult-alt-x86.c create mode 100644 clang/test/CodeGen/no-common.c create mode 100644 clang/test/CodeGen/noinline.c create mode 100644 clang/test/CodeGen/object-size.c create mode 100644 clang/test/CodeGen/offsetof.c create mode 100644 clang/test/CodeGen/opaque-pointer.c create mode 100644 clang/test/CodeGen/overloadable.c create mode 100644 clang/test/CodeGen/override-layout.c create mode 100644 clang/test/CodeGen/packed-arrays.c create mode 100644 clang/test/CodeGen/packed-nest-unpacked.c create mode 100644 clang/test/CodeGen/packed-structure.c create mode 100644 clang/test/CodeGen/packed-union.c create mode 100644 clang/test/CodeGen/palignr.c create mode 100644 clang/test/CodeGen/parameter-passing.c create mode 100644 clang/test/CodeGen/pascal-string.c create mode 100644 clang/test/CodeGen/pascal-wchar-string.c create mode 100644 clang/test/CodeGen/pointer-arithmetic.c create mode 100644 clang/test/CodeGen/pointer-cmp-type.c create mode 100644 clang/test/CodeGen/pointer-signext.c create mode 100644 clang/test/CodeGen/pointer-to-int.c create mode 100644 clang/test/CodeGen/popcnt-builtins.c create mode 100644 clang/test/CodeGen/powerpc_types.c create mode 100644 clang/test/CodeGen/pr12251.c create mode 100644 clang/test/CodeGen/pr2394.c create mode 100644 clang/test/CodeGen/pr3518.c create mode 100644 clang/test/CodeGen/pr4349.c create mode 100644 clang/test/CodeGen/pr5406.c create mode 100644 clang/test/CodeGen/pr9614.c create mode 100644 clang/test/CodeGen/pragma-pack-1.c create mode 100644 clang/test/CodeGen/pragma-pack-2.c create mode 100644 clang/test/CodeGen/pragma-pack-3.c create mode 100644 clang/test/CodeGen/pragma-visibility.c create mode 100644 clang/test/CodeGen/pragma-weak.c create mode 100644 clang/test/CodeGen/predefined-expr.c create mode 100644 clang/test/CodeGen/private-extern-redef.c create mode 100644 clang/test/CodeGen/private-extern.c create mode 100644 clang/test/CodeGen/ptx-cc.c create mode 100644 clang/test/CodeGen/redef-ext-inline.c create mode 100644 clang/test/CodeGen/redefine_extname.c create mode 100644 clang/test/CodeGen/regparm-flag.c create mode 100644 clang/test/CodeGen/regparm.c create mode 100644 clang/test/CodeGen/restrict.c create mode 100644 clang/test/CodeGen/shared-string-literals.c create mode 100644 clang/test/CodeGen/sizeof-vla.c create mode 100644 clang/test/CodeGen/sret.c create mode 100644 clang/test/CodeGen/sret2.c create mode 100644 clang/test/CodeGen/sse-builtins.c create mode 100644 clang/test/CodeGen/stack-protector.c create mode 100644 clang/test/CodeGen/statements.c create mode 100644 clang/test/CodeGen/static-forward-decl-fun.c create mode 100644 clang/test/CodeGen/static-forward-decl.c create mode 100644 clang/test/CodeGen/static-local-union.c create mode 100644 clang/test/CodeGen/static-order.c create mode 100644 clang/test/CodeGen/staticinit.c create mode 100644 clang/test/CodeGen/stdcall-fastcall.c create mode 100644 clang/test/CodeGen/string-literal-short-wstring.c create mode 100644 clang/test/CodeGen/string-literal-unicode-conversion.c create mode 100644 clang/test/CodeGen/string-literal.c create mode 100644 clang/test/CodeGen/struct-comma.c create mode 100644 clang/test/CodeGen/struct-copy.c create mode 100644 clang/test/CodeGen/struct-init.c create mode 100644 clang/test/CodeGen/struct-matching-constraint.c create mode 100644 clang/test/CodeGen/struct-passing.c create mode 100644 clang/test/CodeGen/struct-x86-darwin.c create mode 100644 clang/test/CodeGen/struct.c create mode 100644 clang/test/CodeGen/switch-dce.c create mode 100644 clang/test/CodeGen/switch.c create mode 100644 clang/test/CodeGen/target-data.c create mode 100644 clang/test/CodeGen/tbaa-for-vptr.cpp create mode 100644 clang/test/CodeGen/tentative-decls.c create mode 100644 clang/test/CodeGen/thread-specifier.c create mode 100644 clang/test/CodeGen/transparent-union.c create mode 100644 clang/test/CodeGen/trapv.c create mode 100644 clang/test/CodeGen/typedef-func.c create mode 100644 clang/test/CodeGen/typedef.c create mode 100644 clang/test/CodeGen/types.c create mode 100644 clang/test/CodeGen/uint128_t.c create mode 100644 clang/test/CodeGen/unaligned-memcpy.c create mode 100644 clang/test/CodeGen/union-align.c create mode 100644 clang/test/CodeGen/union-init.c create mode 100644 clang/test/CodeGen/union-init2.c create mode 100644 clang/test/CodeGen/union.c create mode 100644 clang/test/CodeGen/unreachable.c create mode 100644 clang/test/CodeGen/unwind-attr.c create mode 100644 clang/test/CodeGen/utf16-cfstrings.c create mode 100644 clang/test/CodeGen/varargs.c create mode 100644 clang/test/CodeGen/variable-array.c create mode 100644 clang/test/CodeGen/vector.c create mode 100644 clang/test/CodeGen/vfprintf.c create mode 100644 clang/test/CodeGen/visibility.c create mode 100644 clang/test/CodeGen/vla-2.c create mode 100644 clang/test/CodeGen/vla-3.c create mode 100644 clang/test/CodeGen/vla-4.c create mode 100644 clang/test/CodeGen/vla.c create mode 100644 clang/test/CodeGen/vld_dup.c create mode 100644 clang/test/CodeGen/volatile-1.c create mode 100644 clang/test/CodeGen/volatile-2.c create mode 100644 clang/test/CodeGen/volatile.c create mode 100644 clang/test/CodeGen/wchar-const.c create mode 100644 clang/test/CodeGen/weak-global.c create mode 100644 clang/test/CodeGen/weak-incomplete.c create mode 100644 clang/test/CodeGen/weak_constant.c create mode 100644 clang/test/CodeGen/whilestmt.c create mode 100644 clang/test/CodeGen/writable-strings.c create mode 100644 clang/test/CodeGen/x86.c create mode 100644 clang/test/CodeGen/x86_32-arguments-darwin.c create mode 100644 clang/test/CodeGen/x86_32-arguments-linux.c create mode 100644 clang/test/CodeGen/x86_32-arguments-nommx.c create mode 100644 clang/test/CodeGen/x86_32-arguments-realign.c create mode 100644 clang/test/CodeGen/x86_32-arguments-win32.c create mode 100644 clang/test/CodeGen/x86_64-arguments-darwin.c create mode 100644 clang/test/CodeGen/x86_64-arguments.c create mode 100644 clang/test/CodeGenCUDA/device-stub.cu create mode 100644 clang/test/CodeGenCUDA/filter-decl.cu create mode 100644 clang/test/CodeGenCUDA/kernel-call.cu create mode 100644 clang/test/CodeGenCUDA/ptx-kernels.cu create mode 100644 clang/test/CodeGenCXX/2003-11-02-WeakLinkage.cpp create mode 100644 clang/test/CodeGenCXX/2003-11-18-PtrMemConstantInitializer.cpp create mode 100644 clang/test/CodeGenCXX/2003-11-27-MultipleInheritanceThunk.cpp create mode 100644 clang/test/CodeGenCXX/2003-11-29-DuplicatedCleanupTest.cpp create mode 100644 clang/test/CodeGenCXX/2003-12-08-ArrayOfPtrToMemberFunc.cpp create mode 100644 clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp create mode 100644 clang/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp create mode 100644 clang/test/CodeGenCXX/2004-03-09-UnmangledBuiltinMethods.cpp create mode 100644 clang/test/CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp create mode 100644 clang/test/CodeGenCXX/2004-06-08-LateTemplateInstantiation.cpp create mode 100644 clang/test/CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp create mode 100644 clang/test/CodeGenCXX/2004-11-27-ExceptionCleanupAssertion.cpp create mode 100644 clang/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp create mode 100644 clang/test/CodeGenCXX/2005-01-03-StaticInitializers.cpp create mode 100644 clang/test/CodeGenCXX/2005-02-11-AnonymousUnion.cpp create mode 100644 clang/test/CodeGenCXX/2005-02-13-BadDynamicInit.cpp create mode 100644 clang/test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp create mode 100644 clang/test/CodeGenCXX/2005-02-19-BitfieldStructCrash.cpp create mode 100644 clang/test/CodeGenCXX/2005-02-19-UnnamedVirtualThunkArgument.cpp create mode 100644 clang/test/CodeGenCXX/2005-02-20-BrokenReferenceTest.cpp create mode 100644 clang/test/CodeGenCXX/2006-03-01-GimplifyCrash.cpp create mode 100644 clang/test/CodeGenCXX/2006-03-06-C++RecurseCrash.cpp create mode 100644 clang/test/CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp create mode 100644 clang/test/CodeGenCXX/2006-10-30-ClassBitfield.cpp create mode 100644 clang/test/CodeGenCXX/2006-11-20-GlobalSymbols.cpp create mode 100644 clang/test/CodeGenCXX/2006-11-30-ConstantExprCrash.cpp create mode 100644 clang/test/CodeGenCXX/2007-01-02-UnboundedArray.cpp create mode 100644 clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp create mode 100644 clang/test/CodeGenCXX/2007-04-05-PackedBitFields-1.cpp create mode 100644 clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap-2.cpp create mode 100644 clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap.cpp create mode 100644 clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp create mode 100644 clang/test/CodeGenCXX/2007-04-05-StructPackedFieldUnpacked.cpp create mode 100644 clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp create mode 100644 clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp create mode 100644 clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp create mode 100644 clang/test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp create mode 100644 clang/test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp create mode 100644 clang/test/CodeGenCXX/2007-09-10-RecursiveTypeResolution.cpp create mode 100644 clang/test/CodeGenCXX/2007-10-01-StructResize.cpp create mode 100644 clang/test/CodeGenCXX/2008-01-12-VecInit.cpp create mode 100644 clang/test/CodeGenCXX/2008-05-07-CrazyOffsetOf.cpp create mode 100644 clang/test/CodeGenCXX/2009-03-17-dbg.cpp create mode 100644 clang/test/CodeGenCXX/2009-04-23-bool2.cpp create mode 100644 clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp create mode 100644 clang/test/CodeGenCXX/2009-06-16-DebugInfoCrash.cpp create mode 100644 clang/test/CodeGenCXX/2009-07-16-Using.cpp create mode 100644 clang/test/CodeGenCXX/2009-08-05-ZeroInitWidth.cpp create mode 100644 clang/test/CodeGenCXX/2009-08-11-VectorRetTy.cpp create mode 100644 clang/test/CodeGenCXX/2009-09-09-packed-layout.cpp create mode 100644 clang/test/CodeGenCXX/2009-10-27-crash.cpp create mode 100644 clang/test/CodeGenCXX/2009-12-23-MissingSext.cpp create mode 100644 clang/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp create mode 100644 clang/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp create mode 100644 clang/test/CodeGenCXX/2010-05-11-alwaysinlineinstantiation.cpp create mode 100644 clang/test/CodeGenCXX/2010-05-12-PtrToMember-Dbg.cpp create mode 100644 clang/test/CodeGenCXX/2010-06-21-LocalVarDbg.cpp create mode 100644 clang/test/CodeGenCXX/2010-06-22-BitfieldInit.cpp create mode 100644 clang/test/CodeGenCXX/2010-06-22-ZeroBitfield.cpp create mode 100644 clang/test/CodeGenCXX/2010-07-23-DeclLoc.cpp create mode 100644 clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp create mode 100644 clang/test/CodeGenCXX/2012-02-06-VecInitialization.cpp create mode 100644 clang/test/CodeGenCXX/2012-03-16-StoreAlign.cpp create mode 100644 clang/test/CodeGenCXX/DynArrayInit.cpp create mode 100644 clang/test/CodeGenCXX/PR4827-cast.cpp create mode 100644 clang/test/CodeGenCXX/PR4983-constructor-conversion.cpp create mode 100644 clang/test/CodeGenCXX/PR5050-constructor-conversion.cpp create mode 100644 clang/test/CodeGenCXX/PR5093-static-member-function.cpp create mode 100644 clang/test/CodeGenCXX/PR5834-constructor-conversion.cpp create mode 100644 clang/test/CodeGenCXX/PR5863-unreachable-block.cpp create mode 100644 clang/test/CodeGenCXX/PR6474.cpp create mode 100644 clang/test/CodeGenCXX/__null.cpp create mode 100644 clang/test/CodeGenCXX/abstract-class-ctors-dtors.cpp create mode 100644 clang/test/CodeGenCXX/address-of-fntemplate.cpp create mode 100644 clang/test/CodeGenCXX/alloca-align.cpp create mode 100644 clang/test/CodeGenCXX/anonymous-namespaces.cpp create mode 100644 clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp create mode 100644 clang/test/CodeGenCXX/apple-kext-guard-variable.cpp create mode 100644 clang/test/CodeGenCXX/apple-kext-indirect-call-2.C create mode 100644 clang/test/CodeGenCXX/apple-kext-indirect-call.C create mode 100644 clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp create mode 100644 clang/test/CodeGenCXX/apple-kext-linkage.C create mode 100644 clang/test/CodeGenCXX/apple-kext-no-staticinit-section.C create mode 100644 clang/test/CodeGenCXX/apple-kext.cpp create mode 100644 clang/test/CodeGenCXX/arm-cc.cpp create mode 100644 clang/test/CodeGenCXX/arm.cpp create mode 100644 clang/test/CodeGenCXX/array-construction.cpp create mode 100644 clang/test/CodeGenCXX/array-operator-delete-call.cpp create mode 100644 clang/test/CodeGenCXX/array-pointer-decay.cpp create mode 100644 clang/test/CodeGenCXX/array-value-initialize.cpp create mode 100644 clang/test/CodeGenCXX/asm.cpp create mode 100644 clang/test/CodeGenCXX/assign-operator.cpp create mode 100644 clang/test/CodeGenCXX/atomic.cpp create mode 100644 clang/test/CodeGenCXX/atomicinit.cpp create mode 100644 clang/test/CodeGenCXX/attr-used.cpp create mode 100644 clang/test/CodeGenCXX/attr.cpp create mode 100644 clang/test/CodeGenCXX/bitfield-layout.cpp create mode 100644 clang/test/CodeGenCXX/block-byref-cxx-objc.cpp create mode 100644 clang/test/CodeGenCXX/block-destruct.cpp create mode 100644 clang/test/CodeGenCXX/block-in-ctor-dtor.cpp create mode 100644 clang/test/CodeGenCXX/block.cpp create mode 100644 clang/test/CodeGenCXX/blocks-cxx11.cpp create mode 100644 clang/test/CodeGenCXX/blocks.cpp create mode 100644 clang/test/CodeGenCXX/builtins.cpp create mode 100644 clang/test/CodeGenCXX/c-linkage.cpp create mode 100644 clang/test/CodeGenCXX/c99-variable-length-array.cpp create mode 100644 clang/test/CodeGenCXX/call-arg-zero-temp.cpp create mode 100644 clang/test/CodeGenCXX/cast-conversion.cpp create mode 100644 clang/test/CodeGenCXX/casts.cpp create mode 100644 clang/test/CodeGenCXX/class-layout.cpp create mode 100644 clang/test/CodeGenCXX/compound-literals.cpp create mode 100644 clang/test/CodeGenCXX/condition.cpp create mode 100644 clang/test/CodeGenCXX/conditional-expr-lvalue.cpp create mode 100644 clang/test/CodeGenCXX/conditional-gnu-ext.cpp create mode 100644 clang/test/CodeGenCXX/conditional-temporaries.cpp create mode 100644 clang/test/CodeGenCXX/const-base-cast.cpp create mode 100644 clang/test/CodeGenCXX/const-global-linkage.cpp create mode 100644 clang/test/CodeGenCXX/const-init-cxx11.cpp create mode 100644 clang/test/CodeGenCXX/const-init.cpp create mode 100644 clang/test/CodeGenCXX/constructor-attr.cpp create mode 100644 clang/test/CodeGenCXX/constructor-conversion.cpp create mode 100644 clang/test/CodeGenCXX/constructor-convert.cpp create mode 100644 clang/test/CodeGenCXX/constructor-default-arg.cpp create mode 100644 clang/test/CodeGenCXX/constructor-direct-call.cpp create mode 100644 clang/test/CodeGenCXX/constructor-for-array-members.cpp create mode 100644 clang/test/CodeGenCXX/constructor-init-reference.cpp create mode 100644 clang/test/CodeGenCXX/constructor-init.cpp create mode 100644 clang/test/CodeGenCXX/constructor-template.cpp create mode 100644 clang/test/CodeGenCXX/constructors.cpp create mode 100644 clang/test/CodeGenCXX/conversion-function.cpp create mode 100644 clang/test/CodeGenCXX/conversion-operator-base.cpp create mode 100644 clang/test/CodeGenCXX/convert-to-fptr.cpp create mode 100644 clang/test/CodeGenCXX/copy-assign-synthesis-1.cpp create mode 100644 clang/test/CodeGenCXX/copy-assign-synthesis-2.cpp create mode 100644 clang/test/CodeGenCXX/copy-assign-synthesis-3.cpp create mode 100644 clang/test/CodeGenCXX/copy-assign-synthesis.cpp create mode 100644 clang/test/CodeGenCXX/copy-assign-volatile-synthesis.cpp create mode 100644 clang/test/CodeGenCXX/copy-constructor-elim-2.cpp create mode 100644 clang/test/CodeGenCXX/copy-constructor-elim.cpp create mode 100644 clang/test/CodeGenCXX/copy-constructor-synthesis-2.cpp create mode 100644 clang/test/CodeGenCXX/copy-constructor-synthesis.cpp create mode 100644 clang/test/CodeGenCXX/copy-in-cplus-object.cpp create mode 100644 clang/test/CodeGenCXX/copy-initialization.cpp create mode 100644 clang/test/CodeGenCXX/cxx-apple-kext.cpp create mode 100644 clang/test/CodeGenCXX/cxx-block-objects.cpp create mode 100644 clang/test/CodeGenCXX/cxx0x-defaulted-templates.cpp create mode 100644 clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp create mode 100644 clang/test/CodeGenCXX/cxx0x-initializer-array.cpp create mode 100644 clang/test/CodeGenCXX/cxx0x-initializer-references.cpp create mode 100644 clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp create mode 100644 clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp create mode 100644 clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp create mode 100644 clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp create mode 100644 clang/test/CodeGenCXX/cxx11-exception-spec.cpp create mode 100644 clang/test/CodeGenCXX/cxx11-unrestricted-union.cpp create mode 100644 clang/test/CodeGenCXX/cxx11-user-defined-literal.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-artificial-arg.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-byval.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-char16.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-class.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-context.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-ctor.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-ctor2.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-cxx0x.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-enum.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-fn-template.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-friend.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-fwd-ref.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-large-constant.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-limit-type.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-limit.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-member.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-method-spec.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-method.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-method2.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-namespace.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-nullptr.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-pubtypes.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-static-fns.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-template-limit.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-template-member.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-template-recursive.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-template.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-this.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-use-after-free.cpp create mode 100644 clang/test/CodeGenCXX/debug-info-wchar.cpp create mode 100644 clang/test/CodeGenCXX/debug-info.cpp create mode 100644 clang/test/CodeGenCXX/debug-lambda-expressions.cpp create mode 100644 clang/test/CodeGenCXX/decl-ref-init.cpp create mode 100644 clang/test/CodeGenCXX/default-arg-temps.cpp create mode 100644 clang/test/CodeGenCXX/default-arguments.cpp create mode 100644 clang/test/CodeGenCXX/default-constructor-default-argument.cpp create mode 100644 clang/test/CodeGenCXX/default-constructor-for-members.cpp create mode 100644 clang/test/CodeGenCXX/default-constructor-template-member.cpp create mode 100644 clang/test/CodeGenCXX/default-destructor-nested.cpp create mode 100644 clang/test/CodeGenCXX/default-destructor-synthesis.cpp create mode 100644 clang/test/CodeGenCXX/deferred-global-init.cpp create mode 100644 clang/test/CodeGenCXX/delete-two-arg.cpp create mode 100644 clang/test/CodeGenCXX/delete.cpp create mode 100644 clang/test/CodeGenCXX/dependent-type-member-pointer.cpp create mode 100644 clang/test/CodeGenCXX/derived-to-base-conv.cpp create mode 100644 clang/test/CodeGenCXX/derived-to-base.cpp create mode 100644 clang/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp create mode 100644 clang/test/CodeGenCXX/destructor-calls.cpp create mode 100644 clang/test/CodeGenCXX/destructor-debug-info.cpp create mode 100644 clang/test/CodeGenCXX/destructors.cpp create mode 100644 clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp create mode 100644 clang/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp create mode 100644 clang/test/CodeGenCXX/dynamic-cast-always-null.cpp create mode 100644 clang/test/CodeGenCXX/dynamic-cast.cpp create mode 100644 clang/test/CodeGenCXX/eh.cpp create mode 100644 clang/test/CodeGenCXX/elide-call-reference.cpp create mode 100644 clang/test/CodeGenCXX/empty-classes.cpp create mode 100644 clang/test/CodeGenCXX/empty-union.cpp create mode 100644 clang/test/CodeGenCXX/enum.cpp create mode 100644 clang/test/CodeGenCXX/eval-recursive-constant.cpp create mode 100644 clang/test/CodeGenCXX/exceptions-no-rtti.cpp create mode 100644 clang/test/CodeGenCXX/exceptions.cpp create mode 100644 clang/test/CodeGenCXX/explicit-instantiation.cpp create mode 100644 clang/test/CodeGenCXX/expr.cpp create mode 100644 clang/test/CodeGenCXX/extern-c.cpp create mode 100644 clang/test/CodeGenCXX/field-access-debug-info.cpp create mode 100644 clang/test/CodeGenCXX/for-range-temporaries.cpp create mode 100644 clang/test/CodeGenCXX/for-range.cpp create mode 100644 clang/test/CodeGenCXX/forward-enum.cpp create mode 100644 clang/test/CodeGenCXX/fp16-mangle.cpp create mode 100644 clang/test/CodeGenCXX/fp16-overload.cpp create mode 100644 clang/test/CodeGenCXX/friend-redecl.cpp create mode 100644 clang/test/CodeGenCXX/function-template-explicit-specialization.cpp create mode 100644 clang/test/CodeGenCXX/function-template-specialization.cpp create mode 100644 clang/test/CodeGenCXX/global-array-destruction.cpp create mode 100644 clang/test/CodeGenCXX/global-dtor-no-atexit.cpp create mode 100644 clang/test/CodeGenCXX/global-init-darwin.cpp create mode 100644 clang/test/CodeGenCXX/global-init.cpp create mode 100644 clang/test/CodeGenCXX/global-llvm-constant.cpp create mode 100644 clang/test/CodeGenCXX/goto.cpp create mode 100644 clang/test/CodeGenCXX/implicit-copy-assign-operator.cpp create mode 100644 clang/test/CodeGenCXX/implicit-copy-constructor.cpp create mode 100644 clang/test/CodeGenCXX/implicit-instantiation-1.cpp create mode 100644 clang/test/CodeGenCXX/incomplete-member-function-pointer.cpp create mode 100644 clang/test/CodeGenCXX/incomplete-types.cpp create mode 100644 clang/test/CodeGenCXX/inheriting-constructor.cpp create mode 100644 clang/test/CodeGenCXX/init-invariant.cpp create mode 100644 clang/test/CodeGenCXX/inline-functions.cpp create mode 100644 clang/test/CodeGenCXX/instantiate-blocks.cpp create mode 100644 clang/test/CodeGenCXX/instantiate-init-list.cpp create mode 100644 clang/test/CodeGenCXX/instantiate-temporaries.cpp create mode 100644 clang/test/CodeGenCXX/instrument-functions.cpp create mode 100644 clang/test/CodeGenCXX/internal-linkage.cpp create mode 100644 clang/test/CodeGenCXX/key-function-vtable.cpp create mode 100644 clang/test/CodeGenCXX/lambda-expressions.cpp create mode 100644 clang/test/CodeGenCXX/lvalue-bitcasts.cpp create mode 100644 clang/test/CodeGenCXX/m64-ptr.cpp create mode 100644 clang/test/CodeGenCXX/mangle-98.cpp create mode 100644 clang/test/CodeGenCXX/mangle-abi-examples.cpp create mode 100644 clang/test/CodeGenCXX/mangle-address-space.cpp create mode 100644 clang/test/CodeGenCXX/mangle-alias-template.cpp create mode 100644 clang/test/CodeGenCXX/mangle-exprs.cpp create mode 100644 clang/test/CodeGenCXX/mangle-extern-local.cpp create mode 100644 clang/test/CodeGenCXX/mangle-extreme.cpp create mode 100644 clang/test/CodeGenCXX/mangle-lambdas.cpp create mode 100644 clang/test/CodeGenCXX/mangle-local-class-names.cpp create mode 100644 clang/test/CodeGenCXX/mangle-local-class-vtables.cpp create mode 100644 clang/test/CodeGenCXX/mangle-local-classes-nested.cpp create mode 100644 clang/test/CodeGenCXX/mangle-ms.cpp create mode 100644 clang/test/CodeGenCXX/mangle-neon-vectors.cpp create mode 100644 clang/test/CodeGenCXX/mangle-nullptr-arg.cpp create mode 100644 clang/test/CodeGenCXX/mangle-ref-qualifiers.cpp create mode 100644 clang/test/CodeGenCXX/mangle-std-externc.cpp create mode 100644 clang/test/CodeGenCXX/mangle-subst-std.cpp create mode 100644 clang/test/CodeGenCXX/mangle-subst.cpp create mode 100644 clang/test/CodeGenCXX/mangle-system-header.cpp create mode 100644 clang/test/CodeGenCXX/mangle-template.cpp create mode 100644 clang/test/CodeGenCXX/mangle-this-cxx11.cpp create mode 100644 clang/test/CodeGenCXX/mangle-unnameable-conversions.cpp create mode 100644 clang/test/CodeGenCXX/mangle-unnamed.cpp create mode 100644 clang/test/CodeGenCXX/mangle-variadic-templates.cpp create mode 100644 clang/test/CodeGenCXX/mangle.cpp create mode 100644 clang/test/CodeGenCXX/member-alignment.cpp create mode 100644 clang/test/CodeGenCXX/member-call-parens.cpp create mode 100644 clang/test/CodeGenCXX/member-expressions.cpp create mode 100644 clang/test/CodeGenCXX/member-function-pointer-calls.cpp create mode 100644 clang/test/CodeGenCXX/member-function-pointers.cpp create mode 100644 clang/test/CodeGenCXX/member-functions.cpp create mode 100644 clang/test/CodeGenCXX/member-init-anon-union.cpp create mode 100644 clang/test/CodeGenCXX/member-init-assignment.cpp create mode 100644 clang/test/CodeGenCXX/member-init-ctor.cpp create mode 100644 clang/test/CodeGenCXX/member-init-struct.cpp create mode 100644 clang/test/CodeGenCXX/member-init-union.cpp create mode 100644 clang/test/CodeGenCXX/member-initializers.cpp create mode 100644 clang/test/CodeGenCXX/member-pointer-type-convert.cpp create mode 100644 clang/test/CodeGenCXX/member-templates.cpp create mode 100644 clang/test/CodeGenCXX/multi-dim-operator-new.cpp create mode 100644 clang/test/CodeGenCXX/namespace-aliases.cpp create mode 100644 clang/test/CodeGenCXX/nested-base-member-access.cpp create mode 100644 clang/test/CodeGenCXX/new-array-init-exceptions.cpp create mode 100644 clang/test/CodeGenCXX/new-array-init.cpp create mode 100644 clang/test/CodeGenCXX/new-operator-phi.cpp create mode 100644 clang/test/CodeGenCXX/new-overflow.cpp create mode 100644 clang/test/CodeGenCXX/new-with-default-arg.cpp create mode 100644 clang/test/CodeGenCXX/new.cpp create mode 100644 clang/test/CodeGenCXX/no-exceptions.cpp create mode 100644 clang/test/CodeGenCXX/noinline-template.cpp create mode 100644 clang/test/CodeGenCXX/nonconst-init.cpp create mode 100644 clang/test/CodeGenCXX/nrvo-noreturn.cc create mode 100644 clang/test/CodeGenCXX/nrvo.cpp create mode 100644 clang/test/CodeGenCXX/nullptr.cpp create mode 100644 clang/test/CodeGenCXX/operator-new.cpp create mode 100644 clang/test/CodeGenCXX/overload-binop-implicitconvert.cpp create mode 100644 clang/test/CodeGenCXX/override-layout.cpp create mode 100644 clang/test/CodeGenCXX/partial-destruction.cpp create mode 100644 clang/test/CodeGenCXX/pointers-to-data-members.cpp create mode 100644 clang/test/CodeGenCXX/pr11676.cpp create mode 100644 clang/test/CodeGenCXX/pr11797.cpp create mode 100644 clang/test/CodeGenCXX/pr12104.cpp create mode 100644 clang/test/CodeGenCXX/pr12104.h create mode 100644 clang/test/CodeGenCXX/pr12251.cpp create mode 100644 clang/test/CodeGenCXX/pr9130.cpp create mode 100644 clang/test/CodeGenCXX/pr9965.cpp create mode 100644 clang/test/CodeGenCXX/pragma-pack-2.cpp create mode 100644 clang/test/CodeGenCXX/pragma-pack.cpp create mode 100644 clang/test/CodeGenCXX/pragma-visibility.cpp create mode 100644 clang/test/CodeGenCXX/predefined-expr-sizeof.cpp create mode 100644 clang/test/CodeGenCXX/predefined-expr.cpp create mode 100644 clang/test/CodeGenCXX/ptr-to-datamember.cpp create mode 100644 clang/test/CodeGenCXX/ptr-to-member-function.cpp create mode 100644 clang/test/CodeGenCXX/reference-bind-default-argument.cpp create mode 100644 clang/test/CodeGenCXX/reference-cast.cpp create mode 100644 clang/test/CodeGenCXX/reference-field.cpp create mode 100644 clang/test/CodeGenCXX/reference-in-block-args.cpp create mode 100644 clang/test/CodeGenCXX/reference-in-blocks.cpp create mode 100644 clang/test/CodeGenCXX/reference-init.cpp create mode 100644 clang/test/CodeGenCXX/references.cpp create mode 100644 clang/test/CodeGenCXX/regparm.cpp create mode 100644 clang/test/CodeGenCXX/reinterpret-cast.cpp create mode 100644 clang/test/CodeGenCXX/rtti-fundamental.cpp create mode 100644 clang/test/CodeGenCXX/rtti-layout.cpp create mode 100644 clang/test/CodeGenCXX/rtti-linkage.cpp create mode 100644 clang/test/CodeGenCXX/rtti-visibility.cpp create mode 100644 clang/test/CodeGenCXX/rvalue-references.cpp create mode 100644 clang/test/CodeGenCXX/scoped-enums.cpp create mode 100644 clang/test/CodeGenCXX/sel-address.mm create mode 100644 clang/test/CodeGenCXX/sizeof-unwind-exception.cpp create mode 100644 clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp create mode 100644 clang/test/CodeGenCXX/specialized-static-data-mem-init.cpp create mode 100644 clang/test/CodeGenCXX/static-assert.cpp create mode 100644 clang/test/CodeGenCXX/static-data-member.cpp create mode 100644 clang/test/CodeGenCXX/static-init-1.cpp create mode 100644 clang/test/CodeGenCXX/static-init-2.cpp create mode 100644 clang/test/CodeGenCXX/static-init-3.cpp create mode 100644 clang/test/CodeGenCXX/static-init.cpp create mode 100644 clang/test/CodeGenCXX/static-local-in-local-class.cpp create mode 100644 clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp create mode 100644 clang/test/CodeGenCXX/static-mutable.cpp create mode 100644 clang/test/CodeGenCXX/stmtexpr.cpp create mode 100644 clang/test/CodeGenCXX/switch-case-folding-1.cpp create mode 100644 clang/test/CodeGenCXX/switch-case-folding-2.cpp create mode 100644 clang/test/CodeGenCXX/switch-case-folding.cpp create mode 100644 clang/test/CodeGenCXX/temp-order.cpp create mode 100644 clang/test/CodeGenCXX/template-anonymous-types.cpp create mode 100644 clang/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp create mode 100644 clang/test/CodeGenCXX/template-dependent-bind-temporary.cpp create mode 100644 clang/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp create mode 100644 clang/test/CodeGenCXX/template-instantiation.cpp create mode 100644 clang/test/CodeGenCXX/template-linkage.cpp create mode 100644 clang/test/CodeGenCXX/template-static-var-defer.cpp create mode 100644 clang/test/CodeGenCXX/temporaries.cpp create mode 100644 clang/test/CodeGenCXX/thiscall-struct-return.cpp create mode 100644 clang/test/CodeGenCXX/threadsafe-statics-exceptions.cpp create mode 100644 clang/test/CodeGenCXX/threadsafe-statics.cpp create mode 100644 clang/test/CodeGenCXX/throw-expression-dtor.cpp create mode 100644 clang/test/CodeGenCXX/throw-expressions.cpp create mode 100644 clang/test/CodeGenCXX/thunk-linkonce-odr.cpp create mode 100644 clang/test/CodeGenCXX/thunk-use-after-free.cpp create mode 100644 clang/test/CodeGenCXX/thunks-available-externally.cpp create mode 100644 clang/test/CodeGenCXX/thunks.cpp create mode 100644 clang/test/CodeGenCXX/trivial-constructor-init.cpp create mode 100644 clang/test/CodeGenCXX/try-catch.cpp create mode 100644 clang/test/CodeGenCXX/typeid-cxx11.cpp create mode 100644 clang/test/CodeGenCXX/typeid.cpp create mode 100644 clang/test/CodeGenCXX/typeinfo create mode 100644 clang/test/CodeGenCXX/unary-type-trait.cpp create mode 100644 clang/test/CodeGenCXX/uncode-string.cpp create mode 100644 clang/test/CodeGenCXX/union-dtor.cpp create mode 100644 clang/test/CodeGenCXX/unknown-anytype.cpp create mode 100644 clang/test/CodeGenCXX/value-init.cpp create mode 100644 clang/test/CodeGenCXX/vararg-conversion-ctor.cpp create mode 100644 clang/test/CodeGenCXX/vararg-non-pod.cpp create mode 100644 clang/test/CodeGenCXX/varargs.cpp create mode 100644 clang/test/CodeGenCXX/variadic-templates.cpp create mode 100644 clang/test/CodeGenCXX/virt-call-offsets.cpp create mode 100644 clang/test/CodeGenCXX/virt-canonical-decl.cpp create mode 100644 clang/test/CodeGenCXX/virt-dtor-gen.cpp create mode 100644 clang/test/CodeGenCXX/virt-dtor-key.cpp create mode 100644 clang/test/CodeGenCXX/virt-template-vtable.cpp create mode 100644 clang/test/CodeGenCXX/virt-thunk-reference.cpp create mode 100644 clang/test/CodeGenCXX/virtual-base-cast.cpp create mode 100644 clang/test/CodeGenCXX/virtual-base-ctor.cpp create mode 100644 clang/test/CodeGenCXX/virtual-base-destructor-call.cpp create mode 100644 clang/test/CodeGenCXX/virtual-bases.cpp create mode 100644 clang/test/CodeGenCXX/virtual-destructor-calls.cpp create mode 100644 clang/test/CodeGenCXX/virtual-destructor-synthesis.cpp create mode 100644 clang/test/CodeGenCXX/virtual-function-calls.cpp create mode 100644 clang/test/CodeGenCXX/virtual-functions-incomplete-types.cpp create mode 100644 clang/test/CodeGenCXX/virtual-implicit-copy-assignment.cpp create mode 100644 clang/test/CodeGenCXX/virtual-implicit-move-assignment.cpp create mode 100644 clang/test/CodeGenCXX/virtual-inherited-destructor.cpp create mode 100644 clang/test/CodeGenCXX/virtual-operator-call.cpp create mode 100644 clang/test/CodeGenCXX/virtual-pseudo-destructor-call.cpp create mode 100644 clang/test/CodeGenCXX/visibility-hidden-extern-templates.cpp create mode 100644 clang/test/CodeGenCXX/visibility-inlines-hidden.cpp create mode 100644 clang/test/CodeGenCXX/visibility.cpp create mode 100644 clang/test/CodeGenCXX/vla.cpp create mode 100644 clang/test/CodeGenCXX/volatile-1.cpp create mode 100644 clang/test/CodeGenCXX/volatile.cpp create mode 100644 clang/test/CodeGenCXX/vtable-available-externally.cpp create mode 100644 clang/test/CodeGenCXX/vtable-cast-crash.cpp create mode 100644 clang/test/CodeGenCXX/vtable-debug-info.cpp create mode 100644 clang/test/CodeGenCXX/vtable-key-function.cpp create mode 100644 clang/test/CodeGenCXX/vtable-layout-abi-examples.cpp create mode 100644 clang/test/CodeGenCXX/vtable-layout-extreme.cpp create mode 100644 clang/test/CodeGenCXX/vtable-layout.cpp create mode 100644 clang/test/CodeGenCXX/vtable-linkage.cpp create mode 100644 clang/test/CodeGenCXX/vtable-pointer-initialization.cpp create mode 100644 clang/test/CodeGenCXX/vtt-layout.cpp create mode 100644 clang/test/CodeGenCXX/warn-padded-packed.cpp create mode 100644 clang/test/CodeGenCXX/weak-extern-typeinfo.cpp create mode 100644 clang/test/CodeGenCXX/weak-external.cpp create mode 100644 clang/test/CodeGenCXX/x86_32-arguments.cpp create mode 100644 clang/test/CodeGenCXX/x86_64-arguments.cpp create mode 100644 clang/test/CodeGenObjC/2007-04-03-ObjcEH.m create mode 100644 clang/test/CodeGenObjC/2007-05-02-Strong.m create mode 100644 clang/test/CodeGenObjC/2007-10-18-ProDescriptor.m create mode 100644 clang/test/CodeGenObjC/2007-10-23-GC-WriteBarrier.m create mode 100644 clang/test/CodeGenObjC/2008-08-25-incompatible-cond-expr.m create mode 100644 clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m create mode 100644 clang/test/CodeGenObjC/2008-10-3-EhValue.m create mode 100644 clang/test/CodeGenObjC/2008-11-12-Metadata.m create mode 100644 clang/test/CodeGenObjC/2008-11-24-ConstCFStrings.m create mode 100644 clang/test/CodeGenObjC/2008-11-25-Blocks.m create mode 100644 clang/test/CodeGenObjC/2009-01-21-invalid-debug-info.m create mode 100644 clang/test/CodeGenObjC/2009-01-26-WriteBarrier-2.m create mode 100644 clang/test/CodeGenObjC/2009-02-05-VolatileProp.m create mode 100644 clang/test/CodeGenObjC/2009-08-05-utf16.m create mode 100644 clang/test/CodeGenObjC/2010-02-01-utf16-with-null.m create mode 100644 clang/test/CodeGenObjC/2010-02-09-DbgSelf.m create mode 100644 clang/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m create mode 100644 clang/test/CodeGenObjC/2010-02-23-DbgInheritance.m create mode 100644 clang/test/CodeGenObjC/2010-03-17-StructRef.m create mode 100644 clang/test/CodeGenObjC/2011-03-08-IVarLookup.m create mode 100644 clang/test/CodeGenObjC/Inputs/literal-support.h create mode 100644 clang/test/CodeGenObjC/arc-arm.m create mode 100644 clang/test/CodeGenObjC/arc-block-copy-escape.m create mode 100644 clang/test/CodeGenObjC/arc-block-ivar-layout.m create mode 100644 clang/test/CodeGenObjC/arc-blocks.m create mode 100644 clang/test/CodeGenObjC/arc-bridged-cast.m create mode 100644 clang/test/CodeGenObjC/arc-compound-stmt.m create mode 100644 clang/test/CodeGenObjC/arc-cond-stmt.m create mode 100644 clang/test/CodeGenObjC/arc-exceptions.m create mode 100644 clang/test/CodeGenObjC/arc-foreach.m create mode 100644 clang/test/CodeGenObjC/arc-ivar-layout.m create mode 100644 clang/test/CodeGenObjC/arc-literals.m create mode 100644 clang/test/CodeGenObjC/arc-no-arc-exceptions.m create mode 100644 clang/test/CodeGenObjC/arc-no-runtime.m create mode 100644 clang/test/CodeGenObjC/arc-property.m create mode 100644 clang/test/CodeGenObjC/arc-related-result-type.m create mode 100644 clang/test/CodeGenObjC/arc-unbridged-cast.m create mode 100644 clang/test/CodeGenObjC/arc-unopt.m create mode 100644 clang/test/CodeGenObjC/arc-weak-property.m create mode 100644 clang/test/CodeGenObjC/arc-with-atthrow.m create mode 100644 clang/test/CodeGenObjC/arc.m create mode 100644 clang/test/CodeGenObjC/arm-atomic-scalar-setter-getter.m create mode 100644 clang/test/CodeGenObjC/assign.m create mode 100644 clang/test/CodeGenObjC/atomic-aggregate-property.m create mode 100644 clang/test/CodeGenObjC/attr-availability.m create mode 100644 clang/test/CodeGenObjC/attr-strong.c create mode 100644 clang/test/CodeGenObjC/auto-property-synthesize-protocol.m create mode 100644 clang/test/CodeGenObjC/autorelease.m create mode 100644 clang/test/CodeGenObjC/bitfield-1.m create mode 100644 clang/test/CodeGenObjC/bitfield-access.m create mode 100644 clang/test/CodeGenObjC/bitfield-gnu.m create mode 100644 clang/test/CodeGenObjC/bitfield-ivar-metadata.m create mode 100644 clang/test/CodeGenObjC/bitfield-ivar-offsets.m create mode 100644 clang/test/CodeGenObjC/bitfield_encoding.m create mode 100644 clang/test/CodeGenObjC/block-6.m create mode 100644 clang/test/CodeGenObjC/block-var-layout.m create mode 100644 clang/test/CodeGenObjC/blocks-1.m create mode 100644 clang/test/CodeGenObjC/blocks-2.m create mode 100644 clang/test/CodeGenObjC/blocks-3.m create mode 100644 clang/test/CodeGenObjC/blocks-4.m create mode 100644 clang/test/CodeGenObjC/blocks-5.m create mode 100644 clang/test/CodeGenObjC/blocks-ivar-debug.m create mode 100644 clang/test/CodeGenObjC/blocks.m create mode 100644 clang/test/CodeGenObjC/builtins.m create mode 100644 clang/test/CodeGenObjC/catch-lexical-block.m create mode 100644 clang/test/CodeGenObjC/category-class.m create mode 100644 clang/test/CodeGenObjC/category-super-class-meth.m create mode 100644 clang/test/CodeGenObjC/class-getter-dotsyntax.m create mode 100644 clang/test/CodeGenObjC/class-type.m create mode 100644 clang/test/CodeGenObjC/compatibility-alias.m create mode 100644 clang/test/CodeGenObjC/complex-double-abi.m create mode 100644 clang/test/CodeGenObjC/complex-property.m create mode 100644 clang/test/CodeGenObjC/constant-string-class-1.m create mode 100644 clang/test/CodeGenObjC/constant-string-class.m create mode 100644 clang/test/CodeGenObjC/constant-strings.m create mode 100644 clang/test/CodeGenObjC/continuation-class.m create mode 100644 clang/test/CodeGenObjC/deadcode_strip_used_var.m create mode 100644 clang/test/CodeGenObjC/debug-info-block-helper.m create mode 100644 clang/test/CodeGenObjC/debug-info-blocks.m create mode 100644 clang/test/CodeGenObjC/debug-info-class-extension.m create mode 100644 clang/test/CodeGenObjC/debug-info-class-extension2.m create mode 100644 clang/test/CodeGenObjC/debug-info-class-extension3.m create mode 100644 clang/test/CodeGenObjC/debug-info-crash-2.m create mode 100644 clang/test/CodeGenObjC/debug-info-crash.m create mode 100644 clang/test/CodeGenObjC/debug-info-default-synth-ivar.m create mode 100644 clang/test/CodeGenObjC/debug-info-fwddecl.m create mode 100644 clang/test/CodeGenObjC/debug-info-getter-name.m create mode 100644 clang/test/CodeGenObjC/debug-info-impl.m create mode 100644 clang/test/CodeGenObjC/debug-info-linkagename.m create mode 100644 clang/test/CodeGenObjC/debug-info-property.m create mode 100644 clang/test/CodeGenObjC/debug-info-property2.m create mode 100644 clang/test/CodeGenObjC/debug-info-property3.m create mode 100644 clang/test/CodeGenObjC/debug-info-property4.m create mode 100644 clang/test/CodeGenObjC/debug-info-property5.m create mode 100644 clang/test/CodeGenObjC/debug-info-pubtypes.m create mode 100644 clang/test/CodeGenObjC/debug-info-selector.m create mode 100644 clang/test/CodeGenObjC/debug-info-self.m create mode 100644 clang/test/CodeGenObjC/debug-info-static-var.m create mode 100644 clang/test/CodeGenObjC/debug-info-synthesis.m create mode 100644 clang/test/CodeGenObjC/debug-property-synth.m create mode 100644 clang/test/CodeGenObjC/default-property-synthesis.m create mode 100644 clang/test/CodeGenObjC/dot-syntax-1.m create mode 100644 clang/test/CodeGenObjC/dot-syntax-2.m create mode 100644 clang/test/CodeGenObjC/dot-syntax.m create mode 100644 clang/test/CodeGenObjC/encode-cstyle-method.m create mode 100644 clang/test/CodeGenObjC/encode-test-2.m create mode 100644 clang/test/CodeGenObjC/encode-test-3.m create mode 100644 clang/test/CodeGenObjC/encode-test-4.m create mode 100644 clang/test/CodeGenObjC/encode-test-5.m create mode 100644 clang/test/CodeGenObjC/encode-test.m create mode 100644 clang/test/CodeGenObjC/exceptions-nonfragile.m create mode 100644 clang/test/CodeGenObjC/exceptions.m create mode 100644 clang/test/CodeGenObjC/for-in.m create mode 100644 clang/test/CodeGenObjC/forward-class-impl-metadata.m create mode 100644 clang/test/CodeGenObjC/forward-decl-param.m create mode 100644 clang/test/CodeGenObjC/fp2ret.m create mode 100644 clang/test/CodeGenObjC/fpret.m create mode 100644 clang/test/CodeGenObjC/function-decay.m create mode 100644 clang/test/CodeGenObjC/gc-weak-attribute.m create mode 100644 clang/test/CodeGenObjC/gc.m create mode 100644 clang/test/CodeGenObjC/gnu-exceptions.m create mode 100644 clang/test/CodeGenObjC/hidden-visibility.m create mode 100644 clang/test/CodeGenObjC/hidden.m create mode 100644 clang/test/CodeGenObjC/id-isa-codegen.m create mode 100644 clang/test/CodeGenObjC/illegal-UTF8.m create mode 100644 clang/test/CodeGenObjC/image-info.m create mode 100644 clang/test/CodeGenObjC/implicit-objc_msgSend.m create mode 100644 clang/test/CodeGenObjC/implicit-property.m create mode 100644 clang/test/CodeGenObjC/instance-method-metadata.m create mode 100644 clang/test/CodeGenObjC/interface-layout-64.m create mode 100644 clang/test/CodeGenObjC/interface.m create mode 100644 clang/test/CodeGenObjC/ivar-base-as-invariant-load.m create mode 100644 clang/test/CodeGenObjC/ivar-layout-64-bitfields.m create mode 100644 clang/test/CodeGenObjC/ivar-layout-64.m create mode 100644 clang/test/CodeGenObjC/ivar-layout-array0-struct.m create mode 100644 clang/test/CodeGenObjC/ivar-layout-no-optimize.m create mode 100644 clang/test/CodeGenObjC/ivar-layout-nonfragile-abi2.m create mode 100644 clang/test/CodeGenObjC/ivars.m create mode 100644 clang/test/CodeGenObjC/link-errors.m create mode 100644 clang/test/CodeGenObjC/local-static-block.m create mode 100644 clang/test/CodeGenObjC/message-arrays.m create mode 100644 clang/test/CodeGenObjC/messages-2.m create mode 100644 clang/test/CodeGenObjC/messages.m create mode 100644 clang/test/CodeGenObjC/metadata-symbols-32.m create mode 100644 clang/test/CodeGenObjC/metadata-symbols-64.m create mode 100644 clang/test/CodeGenObjC/metadata_symbols.m create mode 100644 clang/test/CodeGenObjC/misc-atomic-property.m create mode 100644 clang/test/CodeGenObjC/mrr-autorelease.m create mode 100644 clang/test/CodeGenObjC/nested-rethrow.m create mode 100644 clang/test/CodeGenObjC/newproperty-nested-synthesis-1.m create mode 100644 clang/test/CodeGenObjC/next-objc-dispatch.m create mode 100644 clang/test/CodeGenObjC/no-category-class.m create mode 100644 clang/test/CodeGenObjC/no-vararg-messaging.m create mode 100644 clang/test/CodeGenObjC/non-lazy-classes.m create mode 100644 clang/test/CodeGenObjC/nonlazy-msgSend.m create mode 100644 clang/test/CodeGenObjC/ns-constant-strings.m create mode 100644 clang/test/CodeGenObjC/ns_consume_null_check.m create mode 100644 clang/test/CodeGenObjC/objc-align.m create mode 100644 clang/test/CodeGenObjC/objc-arc-container-subscripting.m create mode 100644 clang/test/CodeGenObjC/objc-assign-ivar.m create mode 100644 clang/test/CodeGenObjC/objc-container-subscripting-1.m create mode 100644 clang/test/CodeGenObjC/objc-container-subscripting.m create mode 100644 clang/test/CodeGenObjC/objc-dictionary-literal.m create mode 100644 clang/test/CodeGenObjC/objc-gc-aggr-assign.m create mode 100644 clang/test/CodeGenObjC/objc-literal-debugger-test.m create mode 100644 clang/test/CodeGenObjC/objc-literal-tests.m create mode 100644 clang/test/CodeGenObjC/objc-read-weak-byref.m create mode 100644 clang/test/CodeGenObjC/objc2-assign-global.m create mode 100644 clang/test/CodeGenObjC/objc2-ivar-assign.m create mode 100644 clang/test/CodeGenObjC/objc2-legacy-dispatch.m create mode 100644 clang/test/CodeGenObjC/objc2-new-gc-api-strongcast.m create mode 100644 clang/test/CodeGenObjC/objc2-no-strong-cast.m create mode 100644 clang/test/CodeGenObjC/objc2-no-write-barrier.m create mode 100644 clang/test/CodeGenObjC/objc2-nonfragile-abi-impl.m create mode 100644 clang/test/CodeGenObjC/objc2-property-encode.m create mode 100644 clang/test/CodeGenObjC/objc2-protocol-enc.m create mode 100644 clang/test/CodeGenObjC/objc2-retain-codegen.m create mode 100644 clang/test/CodeGenObjC/objc2-strong-cast-1.m create mode 100644 clang/test/CodeGenObjC/objc2-strong-cast-block-import.m create mode 100644 clang/test/CodeGenObjC/objc2-strong-cast.m create mode 100644 clang/test/CodeGenObjC/objc2-weak-assign.m create mode 100644 clang/test/CodeGenObjC/objc2-weak-block-call.m create mode 100644 clang/test/CodeGenObjC/objc2-weak-compare.m create mode 100644 clang/test/CodeGenObjC/objc2-weak-import-attribute.m create mode 100644 clang/test/CodeGenObjC/objc2-weak-ivar-debug.m create mode 100644 clang/test/CodeGenObjC/objc2-weak-ivar.m create mode 100644 clang/test/CodeGenObjC/objc2-write-barrier-2.m create mode 100644 clang/test/CodeGenObjC/objc2-write-barrier-3.m create mode 100644 clang/test/CodeGenObjC/objc2-write-barrier-4.m create mode 100644 clang/test/CodeGenObjC/objc2-write-barrier-5.m create mode 100644 clang/test/CodeGenObjC/objc2-write-barrier.m create mode 100644 clang/test/CodeGenObjC/object-incr-decr-1.m create mode 100644 clang/test/CodeGenObjC/optimized-setter.m create mode 100644 clang/test/CodeGenObjC/overloadable.m create mode 100644 clang/test/CodeGenObjC/predefined-expr.m create mode 100644 clang/test/CodeGenObjC/property-aggregate.m create mode 100644 clang/test/CodeGenObjC/property-agrr-getter.m create mode 100644 clang/test/CodeGenObjC/property-category-impl.m create mode 100644 clang/test/CodeGenObjC/property-complex.m create mode 100644 clang/test/CodeGenObjC/property-dbg.m create mode 100644 clang/test/CodeGenObjC/property-getter-dot-syntax.m create mode 100644 clang/test/CodeGenObjC/property-incr-decr-1.m create mode 100644 clang/test/CodeGenObjC/property-list-in-class.m create mode 100644 clang/test/CodeGenObjC/property-ref-cast-to-void.m create mode 100644 clang/test/CodeGenObjC/property-setter-attr.m create mode 100644 clang/test/CodeGenObjC/property-type-mismatch.m create mode 100644 clang/test/CodeGenObjC/property.m create mode 100644 clang/test/CodeGenObjC/protocol-in-extended-class.m create mode 100644 clang/test/CodeGenObjC/protocol-property-synth.m create mode 100644 clang/test/CodeGenObjC/protocols-lazy.m create mode 100644 clang/test/CodeGenObjC/protocols.m create mode 100644 clang/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m create mode 100644 clang/test/CodeGenObjC/related-result-type.m create mode 100644 clang/test/CodeGenObjC/return-objc-object.mm create mode 100644 clang/test/CodeGenObjC/runtime-fns.m create mode 100644 clang/test/CodeGenObjC/sel-as-builtin-type.m create mode 100644 clang/test/CodeGenObjC/selector-ref-invariance.m create mode 100644 clang/test/CodeGenObjC/simplify-exceptions.mm create mode 100644 clang/test/CodeGenObjC/stand-alone-implementation.m create mode 100644 clang/test/CodeGenObjC/super-classmethod-category.m create mode 100644 clang/test/CodeGenObjC/super-dotsyntax-property.m create mode 100644 clang/test/CodeGenObjC/super-dotsyntax-struct-property.m create mode 100644 clang/test/CodeGenObjC/super-message-fragileabi.m create mode 100644 clang/test/CodeGenObjC/synchronized.m create mode 100644 clang/test/CodeGenObjC/synthesize_ivar-cont-class.m create mode 100644 clang/test/CodeGenObjC/synthesize_ivar.m create mode 100644 clang/test/CodeGenObjC/terminate.m create mode 100644 clang/test/CodeGenObjC/try.m create mode 100644 clang/test/CodeGenObjC/undefined-protocol.m create mode 100644 clang/test/CodeGenObjC/unname-bf-metadata.m create mode 100644 clang/test/CodeGenObjC/variadic-sends.m create mode 100644 clang/test/CodeGenObjC/x86_64-struct-return-gc.m create mode 100644 clang/test/CodeGenObjCXX/2007-10-03-MetadataPointers.mm create mode 100644 clang/test/CodeGenObjCXX/2010-08-04-Template.mm create mode 100644 clang/test/CodeGenObjCXX/2010-08-06-X.Y-syntax.mm create mode 100644 clang/test/CodeGenObjCXX/Inputs/literal-support.h create mode 100644 clang/test/CodeGenObjCXX/address-safety-attr.mm create mode 100644 clang/test/CodeGenObjCXX/arc-exceptions.mm create mode 100644 clang/test/CodeGenObjCXX/arc-globals.mm create mode 100644 clang/test/CodeGenObjCXX/arc-mangle.mm create mode 100644 clang/test/CodeGenObjCXX/arc-move.mm create mode 100644 clang/test/CodeGenObjCXX/arc-new-delete.mm create mode 100644 clang/test/CodeGenObjCXX/arc-pseudo-destructors.mm create mode 100644 clang/test/CodeGenObjCXX/arc-references.mm create mode 100644 clang/test/CodeGenObjCXX/arc-returns-inner-reference-ptr.mm create mode 100644 clang/test/CodeGenObjCXX/arc-special-member-functions.mm create mode 100644 clang/test/CodeGenObjCXX/arc.mm create mode 100644 clang/test/CodeGenObjCXX/block-in-template-inst.mm create mode 100644 clang/test/CodeGenObjCXX/block-var-layout.mm create mode 100644 clang/test/CodeGenObjCXX/blocks.mm create mode 100644 clang/test/CodeGenObjCXX/catch-id-type.mm create mode 100644 clang/test/CodeGenObjCXX/copy.mm create mode 100644 clang/test/CodeGenObjCXX/copyable-property-object.mm create mode 100644 clang/test/CodeGenObjCXX/debug-info.mm create mode 100644 clang/test/CodeGenObjCXX/encode.mm create mode 100644 clang/test/CodeGenObjCXX/exceptions.mm create mode 100644 clang/test/CodeGenObjCXX/foreach-statement.mm create mode 100644 clang/test/CodeGenObjCXX/gc.mm create mode 100644 clang/test/CodeGenObjCXX/implicit-copy-assign-operator.mm create mode 100644 clang/test/CodeGenObjCXX/implicit-copy-constructor.mm create mode 100644 clang/test/CodeGenObjCXX/ivar-objects.mm create mode 100644 clang/test/CodeGenObjCXX/lambda-expressions.mm create mode 100644 clang/test/CodeGenObjCXX/literals.mm create mode 100644 clang/test/CodeGenObjCXX/lvalue-reference-getter.mm create mode 100644 clang/test/CodeGenObjCXX/mangle-blocks.mm create mode 100644 clang/test/CodeGenObjCXX/mangle.mm create mode 100644 clang/test/CodeGenObjCXX/message-reference.mm create mode 100644 clang/test/CodeGenObjCXX/method-local-extern-mangle.mm create mode 100644 clang/test/CodeGenObjCXX/nrvo.mm create mode 100644 clang/test/CodeGenObjCXX/objc-container-subscripting-1.mm create mode 100644 clang/test/CodeGenObjCXX/objc-container-subscripting.mm create mode 100644 clang/test/CodeGenObjCXX/property-derived-to-base-conv.mm create mode 100644 clang/test/CodeGenObjCXX/property-dot-copy.mm create mode 100644 clang/test/CodeGenObjCXX/property-dot-reference.mm create mode 100644 clang/test/CodeGenObjCXX/property-object-conditional-exp.mm create mode 100644 clang/test/CodeGenObjCXX/property-object-reference-1.mm create mode 100644 clang/test/CodeGenObjCXX/property-object-reference-2.mm create mode 100644 clang/test/CodeGenObjCXX/property-object-reference.mm create mode 100644 clang/test/CodeGenObjCXX/property-objects.mm create mode 100644 clang/test/CodeGenObjCXX/property-reference.mm create mode 100644 clang/test/CodeGenObjCXX/refence-assign-write-barrier.mm create mode 100644 clang/test/CodeGenObjCXX/references.mm create mode 100644 clang/test/CodeGenObjCXX/rtti.mm create mode 100644 clang/test/CodeGenObjCXX/selector-expr-lvalue.mm create mode 100644 clang/test/CodeGenObjCXX/write-barrier-global-assign.mm create mode 100644 clang/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl create mode 100644 clang/test/CodeGenOpenCL/address-spaces.cl create mode 100644 clang/test/CodeGenOpenCL/ext-vector-shuffle.cl create mode 100644 clang/test/CodeGenOpenCL/fpmath.cl create mode 100644 clang/test/CodeGenOpenCL/kernel-metadata.cl create mode 100644 clang/test/CodeGenOpenCL/local.cl create mode 100644 clang/test/CodeGenOpenCL/ptx-calls.cl create mode 100644 clang/test/CodeGenOpenCL/ptx-kernels.cl create mode 100644 clang/test/CodeGenOpenCL/single-precision-constant.cl create mode 100644 clang/test/CodeGenOpenCL/vector_literals_nested.cl create mode 100644 clang/test/CodeGenOpenCL/vector_literals_valid.cl create mode 100644 clang/test/CodeGenOpenCL/vector_logops.cl create mode 100644 clang/test/Coverage/ast-printing.c create mode 100644 clang/test/Coverage/ast-printing.cpp create mode 100644 clang/test/Coverage/ast-printing.m create mode 100644 clang/test/Coverage/c-language-features.inc create mode 100644 clang/test/Coverage/codegen-gnu.m create mode 100644 clang/test/Coverage/codegen-next.m create mode 100644 clang/test/Coverage/codegen.c create mode 100644 clang/test/Coverage/cxx-language-features.inc create mode 100644 clang/test/Coverage/html-diagnostics.c create mode 100644 clang/test/Coverage/html-print.c create mode 100644 clang/test/Coverage/objc-language-features.inc create mode 100644 clang/test/Coverage/targets.c create mode 100644 clang/test/Coverage/verbose.c create mode 100644 clang/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep create mode 100644 clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o create mode 100644 clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep create mode 100644 clang/test/Driver/Inputs/basic_freebsd_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep create mode 100644 clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o create mode 100644 clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep create mode 100644 clang/test/Driver/Inputs/basic_linux_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/basic_linux_tree/usr/i386-unknown-linux/lib/.keep create mode 100644 clang/test/Driver/Inputs/basic_linux_tree/usr/lib/.keep create mode 100644 clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o create mode 100644 clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o create mode 100644 clang/test/Driver/Inputs/basic_linux_tree/usr/x86_64-unknown-linux/lib/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/fake_install_tree/bin/.keep create mode 100644 clang/test/Driver/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o create mode 100644 clang/test/Driver/Inputs/fake_install_tree/lib/gcc/x86_64-unknown-linux/4.5.0/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing1/bin/.keep create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing2/bin/.keep create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.x/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing3/bin/.keep create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing4/bin/.keep create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o create mode 100644 clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o create mode 100644 clang/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep create mode 100644 clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o create mode 100644 clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep create mode 100644 clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib32/.keep create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib64/.keep create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib/.keep create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib32/.keep create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib64/.keep create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/.keep create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib32/.keep create mode 100644 clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib64/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib32/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib64/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib32/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib64/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib32/.keep create mode 100644 clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib64/.keep create mode 100755 clang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as create mode 100755 clang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld create mode 100644 clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep create mode 100644 clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o create mode 100644 clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o create mode 100644 clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep create mode 100644 clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o create mode 100644 clang/test/Driver/Wp-args.c create mode 100644 clang/test/Driver/Xarch.c create mode 100644 clang/test/Driver/Xlinker-args.c create mode 100644 clang/test/Driver/altivec.cpp create mode 100644 clang/test/Driver/analyze.c create mode 100644 clang/test/Driver/apple-kext-i386.cpp create mode 100644 clang/test/Driver/apple-kext-mkernel.c create mode 100644 clang/test/Driver/arc-exceptions.m create mode 100644 clang/test/Driver/arc.c create mode 100644 clang/test/Driver/arch.c create mode 100644 clang/test/Driver/arclite-link.c create mode 100644 clang/test/Driver/arm-darwin-builtin.c create mode 100644 clang/test/Driver/arm-mfpmath.c create mode 100644 clang/test/Driver/arm-mfpu.c create mode 100644 clang/test/Driver/asan.c create mode 100644 clang/test/Driver/ast.c create mode 100644 clang/test/Driver/at_file.c create mode 100644 clang/test/Driver/at_file.c.args create mode 100644 clang/test/Driver/bindings.c create mode 100644 clang/test/Driver/cc-log-diagnostics.c create mode 100644 clang/test/Driver/cc-print-options.c create mode 100644 clang/test/Driver/ccc-add-args.c create mode 100644 clang/test/Driver/ccc-host-triple-no-integrated-as.c create mode 100644 clang/test/Driver/cfi.c create mode 100644 clang/test/Driver/clang-c-as-cxx.c create mode 100644 clang/test/Driver/clang-exception-flags.cpp create mode 100644 clang/test/Driver/clang-g-opts.c create mode 100644 clang/test/Driver/clang-translation.c create mode 100644 clang/test/Driver/clang_cpp.c create mode 100644 clang/test/Driver/clang_f_opts.c create mode 100644 clang/test/Driver/clang_wrapv_opts.c create mode 100644 clang/test/Driver/cpath.c create mode 100644 clang/test/Driver/cpp-precomp.c create mode 100644 clang/test/Driver/darwin-as.c create mode 100644 clang/test/Driver/darwin-cc.c create mode 100644 clang/test/Driver/darwin-debug-flags.c create mode 100644 clang/test/Driver/darwin-dsymutil.c create mode 100644 clang/test/Driver/darwin-iphone-defaults.m create mode 100644 clang/test/Driver/darwin-ld.c create mode 100644 clang/test/Driver/darwin-objc-defaults.m create mode 100644 clang/test/Driver/darwin-objc-gc.m create mode 100644 clang/test/Driver/darwin-objc-options.m create mode 100644 clang/test/Driver/darwin-verify-debug.c create mode 100644 clang/test/Driver/darwin-version.c create mode 100644 clang/test/Driver/darwin-xarch.c create mode 100644 clang/test/Driver/debug-options-as.c create mode 100644 clang/test/Driver/debug-options.c create mode 100644 clang/test/Driver/debug.c create mode 100644 clang/test/Driver/default-toolchain.c create mode 100644 clang/test/Driver/diagnostics.c create mode 100644 clang/test/Driver/dragonfly.c create mode 100644 clang/test/Driver/dwarf2-cfi-asm.c create mode 100644 clang/test/Driver/emit-llvm.c create mode 100644 clang/test/Driver/exceptions.m create mode 100644 clang/test/Driver/fast-math.c create mode 100644 clang/test/Driver/flags.c create mode 100644 clang/test/Driver/frame-pointer.c create mode 100644 clang/test/Driver/freebsd.c create mode 100644 clang/test/Driver/gcc-toolchain.cpp create mode 100644 clang/test/Driver/gcc_forward.c create mode 100644 clang/test/Driver/gnu-runtime.m create mode 100644 clang/test/Driver/gold-lto.c create mode 100644 clang/test/Driver/hello.c create mode 100644 clang/test/Driver/immediate-options.c create mode 100644 clang/test/Driver/index-header-map.c create mode 100644 clang/test/Driver/invalid-o-level.c create mode 100644 clang/test/Driver/ios-simulator-arcruntime.c create mode 100644 clang/test/Driver/le32-unknown-nacl.cpp create mode 100644 clang/test/Driver/linker-opts.c create mode 100644 clang/test/Driver/linux-as.c create mode 100644 clang/test/Driver/linux-header-search.cpp create mode 100644 clang/test/Driver/linux-ld.c create mode 100644 clang/test/Driver/lto.c create mode 100644 clang/test/Driver/m_and_mm.c create mode 100644 clang/test/Driver/mg.c create mode 100644 clang/test/Driver/mips-as.c create mode 100644 clang/test/Driver/mips-float.c create mode 100644 clang/test/Driver/mno-global-merge.c create mode 100644 clang/test/Driver/modules.m create mode 100644 clang/test/Driver/modules.mm create mode 100644 clang/test/Driver/no-objc-arr.m create mode 100644 clang/test/Driver/no-objc-default-synthesize-properties.m create mode 100644 clang/test/Driver/no-sibling-calls.c create mode 100644 clang/test/Driver/noexecstack.c create mode 100644 clang/test/Driver/noinline.c create mode 100644 clang/test/Driver/nostdincxx.cpp create mode 100644 clang/test/Driver/nostdlib.c create mode 100644 clang/test/Driver/nostdlibinc.c create mode 100644 clang/test/Driver/objc++-cpp-output.mm create mode 100644 clang/test/Driver/objc-cpp-output.m create mode 100644 clang/test/Driver/openbsd.c create mode 100644 clang/test/Driver/option-aliases.c create mode 100644 clang/test/Driver/output-file-cleanup.c create mode 100644 clang/test/Driver/parsing.c create mode 100644 clang/test/Driver/phases.c create mode 100644 clang/test/Driver/pic.c create mode 100644 clang/test/Driver/prefixed-tools.c create mode 100644 clang/test/Driver/preprocessor.c create mode 100644 clang/test/Driver/pth.c create mode 100644 clang/test/Driver/qa_override.c create mode 100644 clang/test/Driver/redundant-args.c create mode 100644 clang/test/Driver/redzone.c create mode 100644 clang/test/Driver/rewrite-legacy-objc.m create mode 100644 clang/test/Driver/rewrite-objc.m create mode 100644 clang/test/Driver/stackrealign.c create mode 100644 clang/test/Driver/std.c create mode 100644 clang/test/Driver/std.cpp create mode 100644 clang/test/Driver/sysroot-flags.c create mode 100644 clang/test/Driver/sysroot.c create mode 100644 clang/test/Driver/target.c create mode 100644 clang/test/Driver/tsan.c create mode 100644 clang/test/Driver/unknown-arg.c create mode 100644 clang/test/Driver/unknown-gcc-arch.c create mode 100644 clang/test/Driver/working-directory.c create mode 100644 clang/test/Driver/x86_features.c create mode 100644 clang/test/FixIt/atomic-property.m create mode 100644 clang/test/FixIt/auto-fixit.m create mode 100644 clang/test/FixIt/dereference-addressof.c create mode 100644 clang/test/FixIt/fixit-c90.c create mode 100644 clang/test/FixIt/fixit-cxx0x.cpp create mode 100644 clang/test/FixIt/fixit-cxx11-compat.cpp create mode 100644 clang/test/FixIt/fixit-errors-1.c create mode 100644 clang/test/FixIt/fixit-errors.c create mode 100644 clang/test/FixIt/fixit-function-call.cpp create mode 100644 clang/test/FixIt/fixit-missing-method-return-type.m create mode 100644 clang/test/FixIt/fixit-objc-message.m create mode 100644 clang/test/FixIt/fixit-objc.m create mode 100644 clang/test/FixIt/fixit-pmem.cpp create mode 100644 clang/test/FixIt/fixit-recompile.c create mode 100644 clang/test/FixIt/fixit-recursive-block.c create mode 100644 clang/test/FixIt/fixit-static-object-decl.m create mode 100644 clang/test/FixIt/fixit-suffix.c create mode 100644 clang/test/FixIt/fixit-unrecoverable.c create mode 100644 clang/test/FixIt/fixit-unrecoverable.cpp create mode 100644 clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp create mode 100644 clang/test/FixIt/fixit-vexing-parse.cpp create mode 100644 clang/test/FixIt/fixit.c create mode 100644 clang/test/FixIt/fixit.cpp create mode 100644 clang/test/FixIt/no-fixit.cpp create mode 100644 clang/test/FixIt/no-macro-fixit.c create mode 100644 clang/test/FixIt/no-typo.c create mode 100644 clang/test/FixIt/objc-literals.m create mode 100644 clang/test/FixIt/typo-crash.cpp create mode 100644 clang/test/FixIt/typo-crash.m create mode 100644 clang/test/FixIt/typo.c create mode 100644 clang/test/FixIt/typo.cpp create mode 100644 clang/test/FixIt/typo.m create mode 100644 clang/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h create mode 100644 clang/test/Frontend/Inputs/lit.local.cfg create mode 100644 clang/test/Frontend/Inputs/test.h create mode 100644 clang/test/Frontend/Inputs/test2.h create mode 100644 clang/test/Frontend/Inputs/test3.h create mode 100644 clang/test/Frontend/Weverything.c create mode 100644 clang/test/Frontend/Wno-everything.c create mode 100644 clang/test/Frontend/ast-codegen.c create mode 100644 clang/test/Frontend/ast-main.c create mode 100644 clang/test/Frontend/cpp-output.c create mode 100644 clang/test/Frontend/darwin-version.c create mode 100644 clang/test/Frontend/dependency-gen.c create mode 100644 clang/test/Frontend/dependency-generation-crash.c create mode 100644 clang/test/Frontend/diagnostics-option-names.c create mode 100644 clang/test/Frontend/iframework.c create mode 100644 clang/test/Frontend/ir-support-codegen.ll create mode 100644 clang/test/Frontend/ir-support-errors.ll create mode 100644 clang/test/Frontend/lit.local.cfg create mode 100644 clang/test/Frontend/macros.c create mode 100644 clang/test/Frontend/output-failures.c create mode 100644 clang/test/Frontend/preprocessed-output-macro-first-token.c create mode 100644 clang/test/Frontend/print-header-includes.c create mode 100644 clang/test/Frontend/rewrite-macros.c create mode 100644 clang/test/Frontend/stdin.c create mode 100644 clang/test/Frontend/undef.c create mode 100644 clang/test/Frontend/unknown-pragmas.c create mode 100644 clang/test/Frontend/warning-mapping-1.c create mode 100644 clang/test/Frontend/warning-mapping-2.c create mode 100644 clang/test/Frontend/warning-mapping-3.c create mode 100644 clang/test/Frontend/warning-mapping-4.c create mode 100644 clang/test/Frontend/warning-mapping-5.c create mode 100644 clang/test/Headers/arm-neon-header.c create mode 100644 clang/test/Headers/c89.c create mode 100644 clang/test/Headers/int64-type.c create mode 100644 clang/test/Headers/stdbool.cpp create mode 100644 clang/test/Headers/typedef_guards.c create mode 100644 clang/test/Headers/wchar_limits.cpp create mode 100644 clang/test/Headers/wmmintrin.c create mode 100644 clang/test/Headers/x86-intrinsics-headers.c create mode 100644 clang/test/Index/IBOutletCollection.m create mode 100644 clang/test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h create mode 100644 clang/test/Index/Inputs/Headers/a.h create mode 100644 clang/test/Index/Inputs/Headers/a_extensions.h create mode 100644 clang/test/Index/Inputs/Headers/crash.h create mode 100644 clang/test/Index/Inputs/Headers/module.map create mode 100644 clang/test/Index/Inputs/Headers/nested/module.map create mode 100644 clang/test/Index/Inputs/Headers/nested/nested.h create mode 100644 clang/test/Index/Inputs/a.h create mode 100644 clang/test/Index/Inputs/b.h create mode 100644 clang/test/Index/Inputs/c-index-pch.h create mode 100644 clang/test/Index/Inputs/cindex-from-source.h create mode 100644 clang/test/Index/Inputs/complete-pch.h create mode 100644 clang/test/Index/Inputs/crash-recovery-code-complete-remap.c create mode 100644 clang/test/Index/Inputs/crash-recovery-reparse-remap.c create mode 100644 clang/test/Index/Inputs/foo.h create mode 100644 clang/test/Index/Inputs/get-cursor-includes-1.h create mode 100644 clang/test/Index/Inputs/get-cursor-includes-2.h create mode 100644 clang/test/Index/Inputs/guarded.h create mode 100644 clang/test/Index/Inputs/lit.local.cfg create mode 100644 clang/test/Index/Inputs/objc.h create mode 100644 clang/test/Index/Inputs/pragma-once.h create mode 100644 clang/test/Index/Inputs/pragma_disable_warning.h create mode 100644 clang/test/Index/Inputs/preamble-reparse-1.c create mode 100644 clang/test/Index/Inputs/preamble-reparse-2.c create mode 100644 clang/test/Index/Inputs/preamble.h create mode 100644 clang/test/Index/Inputs/preamble_macro_template.h create mode 100644 clang/test/Index/Inputs/prefix.h create mode 100644 clang/test/Index/Inputs/redeclarations.h create mode 100644 clang/test/Index/Inputs/remap-complete-to.c create mode 100644 clang/test/Index/Inputs/remap-load-to.c create mode 100644 clang/test/Index/Inputs/reparse-instantiate.h create mode 100644 clang/test/Index/Inputs/t1.c create mode 100644 clang/test/Index/Inputs/t1.m create mode 100644 clang/test/Index/Inputs/t2.c create mode 100644 clang/test/Index/Inputs/t2.m create mode 100644 clang/test/Index/TestClassDecl.m create mode 100644 clang/test/Index/TestClassForwardDecl.m create mode 100644 clang/test/Index/annotate-attribute.cpp create mode 100644 clang/test/Index/annotate-context-sensitive.cpp create mode 100644 clang/test/Index/annotate-literals.m create mode 100644 clang/test/Index/annotate-macro-args.h create mode 100644 clang/test/Index/annotate-macro-args.m create mode 100644 clang/test/Index/annotate-nested-name-specifier.cpp create mode 100644 clang/test/Index/annotate-subscripting.m create mode 100644 clang/test/Index/annotate-tokens-cxx0x.cpp create mode 100644 clang/test/Index/annotate-tokens-include.c create mode 100644 clang/test/Index/annotate-tokens-include.h create mode 100644 clang/test/Index/annotate-tokens-pp.c create mode 100644 clang/test/Index/annotate-tokens-preamble.c create mode 100644 clang/test/Index/annotate-tokens-with-default-args.cpp create mode 100644 clang/test/Index/annotate-tokens-with-default-args.h create mode 100644 clang/test/Index/annotate-tokens.c create mode 100644 clang/test/Index/annotate-tokens.cpp create mode 100644 clang/test/Index/annotate-tokens.m create mode 100644 clang/test/Index/annotate-toplevel-in-objccontainer.m create mode 100644 clang/test/Index/annotate-toplevel-in-objccontainer.m.h create mode 100644 clang/test/Index/arc-annotate.m create mode 100644 clang/test/Index/arc-complete.m create mode 100644 clang/test/Index/asm-attribute.c create mode 100644 clang/test/Index/blocks.c create mode 100644 clang/test/Index/c-index-api-loadTU-test.m create mode 100644 clang/test/Index/c-index-getCursor-pp.c create mode 100644 clang/test/Index/c-index-getCursor-test.m create mode 100644 clang/test/Index/c-index-pch.c create mode 100644 clang/test/Index/c-index-redecls.c create mode 100644 clang/test/Index/cindex-from-source.m create mode 100644 clang/test/Index/cindex-on-invalid-usrs.m create mode 100644 clang/test/Index/cindex-on-invalid.m create mode 100644 clang/test/Index/cindex-test-inclusions.c create mode 100644 clang/test/Index/code-completion.cpp create mode 100644 clang/test/Index/complete-access-checks.cpp create mode 100644 clang/test/Index/complete-at-directives.m create mode 100644 clang/test/Index/complete-at-exprstmt.m create mode 100644 clang/test/Index/complete-blocks.m create mode 100644 clang/test/Index/complete-categories.m create mode 100644 clang/test/Index/complete-ctor-inits.cpp create mode 100644 clang/test/Index/complete-cxx-inline-methods.cpp create mode 100644 clang/test/Index/complete-declarators.cpp create mode 100644 clang/test/Index/complete-declarators.m create mode 100644 clang/test/Index/complete-driver-errors.c create mode 100644 clang/test/Index/complete-enums.c create mode 100644 clang/test/Index/complete-enums.cpp create mode 100644 clang/test/Index/complete-exprs.c create mode 100644 clang/test/Index/complete-exprs.cpp create mode 100644 clang/test/Index/complete-exprs.m create mode 100644 clang/test/Index/complete-hiding.c create mode 100644 clang/test/Index/complete-in-invalid-method.m create mode 100644 clang/test/Index/complete-in-stringify.c create mode 100644 clang/test/Index/complete-interfaces.m create mode 100644 clang/test/Index/complete-ivar-access.m create mode 100644 clang/test/Index/complete-kvc.m create mode 100644 clang/test/Index/complete-lambdas.cpp create mode 100644 clang/test/Index/complete-macro-args.c create mode 100644 clang/test/Index/complete-macros.c create mode 100644 clang/test/Index/complete-member-access.m create mode 100644 clang/test/Index/complete-memfunc-cvquals.cpp create mode 100644 clang/test/Index/complete-method-decls.m create mode 100644 clang/test/Index/complete-modules.m create mode 100644 clang/test/Index/complete-natural.m create mode 100644 clang/test/Index/complete-objc-message-id.m create mode 100644 clang/test/Index/complete-objc-message.m create mode 100644 clang/test/Index/complete-pch.m create mode 100644 clang/test/Index/complete-preprocessor.m create mode 100644 clang/test/Index/complete-properties.m create mode 100644 clang/test/Index/complete-property-flags.m create mode 100644 clang/test/Index/complete-property-getset.m create mode 100644 clang/test/Index/complete-protocols.m create mode 100644 clang/test/Index/complete-qualified.cpp create mode 100644 clang/test/Index/complete-recovery.m create mode 100644 clang/test/Index/complete-stmt.c create mode 100644 clang/test/Index/complete-super.cpp create mode 100644 clang/test/Index/complete-super.m create mode 100644 clang/test/Index/complete-synthesized.m create mode 100644 clang/test/Index/complete-tabs.c create mode 100644 clang/test/Index/complete-templates.cpp create mode 100644 clang/test/Index/complete-type-factors.m create mode 100644 clang/test/Index/complete-unterminated.c create mode 100644 clang/test/Index/complete-with-annotations.cpp create mode 100644 clang/test/Index/crash-recovery-code-complete.c create mode 100644 clang/test/Index/crash-recovery-modules.m create mode 100644 clang/test/Index/crash-recovery-reparse.c create mode 100644 clang/test/Index/crash-recovery.c create mode 100644 clang/test/Index/cursor-ref-names.cpp create mode 100644 clang/test/Index/cxx-operator-overload.cpp create mode 100644 clang/test/Index/cxx11-lambdas.cpp create mode 100644 clang/test/Index/error-on-deserialized.c create mode 100644 clang/test/Index/file-macro-refs.c create mode 100644 clang/test/Index/file-refs-subscripting.m create mode 100644 clang/test/Index/file-refs.c create mode 100644 clang/test/Index/file-refs.cpp create mode 100644 clang/test/Index/file-refs.m create mode 100644 clang/test/Index/fix-its.c create mode 100644 clang/test/Index/get-cursor-includes.c create mode 100644 clang/test/Index/get-cursor-macro-args.h create mode 100644 clang/test/Index/get-cursor-macro-args.m create mode 100644 clang/test/Index/get-cursor.c create mode 100644 clang/test/Index/get-cursor.cpp create mode 100644 clang/test/Index/get-cursor.m create mode 100644 clang/test/Index/getcursor-pp-pch.c create mode 100644 clang/test/Index/getcursor-pp-pch.c.h create mode 100644 clang/test/Index/in-class-init.cpp create mode 100644 clang/test/Index/include_test.h create mode 100644 clang/test/Index/include_test_2.h create mode 100644 clang/test/Index/index-attrs.m create mode 100644 clang/test/Index/index-decls.m create mode 100644 clang/test/Index/index-invalid-code.m create mode 100644 clang/test/Index/index-many-logical-ops.c create mode 100644 clang/test/Index/index-refs.cpp create mode 100644 clang/test/Index/index-subscripting-literals.m create mode 100644 clang/test/Index/index-suppress-refs.cpp create mode 100644 clang/test/Index/index-suppress-refs.h create mode 100644 clang/test/Index/index-suppress-refs.hpp create mode 100644 clang/test/Index/index-suppress-refs.m create mode 100644 clang/test/Index/index-templates.cpp create mode 100644 clang/test/Index/initializer-memory.cpp create mode 100644 clang/test/Index/invalid-code-rdar10451854.m create mode 100644 clang/test/Index/invalid-code-rdar_7833619.m create mode 100644 clang/test/Index/invalid-rdar-8236270.cpp create mode 100644 clang/test/Index/linkage.c create mode 100644 clang/test/Index/load-classes.cpp create mode 100644 clang/test/Index/load-decls.c create mode 100644 clang/test/Index/load-exprs.c create mode 100644 clang/test/Index/load-namespaces.cpp create mode 100644 clang/test/Index/load-stmts.cpp create mode 100644 clang/test/Index/local-symbols.m create mode 100644 clang/test/Index/ms-if-exists.cpp create mode 100644 clang/test/Index/nested-binaryoperators.cpp create mode 100644 clang/test/Index/overrides.cpp create mode 100644 clang/test/Index/overrides.m create mode 100644 clang/test/Index/pch-opaque-value.cpp create mode 100644 clang/test/Index/pch-with-errors.c create mode 100644 clang/test/Index/pch-with-errors.m create mode 100644 clang/test/Index/pragma-diag-reparse.c create mode 100644 clang/test/Index/preamble-reparse-chained.c create mode 100644 clang/test/Index/preamble-reparse-cmd-define.c create mode 100644 clang/test/Index/preamble-reparse-cmd-define.c.h create mode 100644 clang/test/Index/preamble-reparse-cmd-define.c.remap create mode 100644 clang/test/Index/preamble-reparse-import.m create mode 100644 clang/test/Index/preamble-reparse-import.m-1.h create mode 100644 clang/test/Index/preamble-reparse-import.m-2.h create mode 100644 clang/test/Index/preamble-reparse-import.m-3.h create mode 100644 clang/test/Index/preamble-reparse.c create mode 100644 clang/test/Index/preamble.c create mode 100644 clang/test/Index/preamble_macro_template.cpp create mode 100644 clang/test/Index/print-display-names.cpp create mode 100644 clang/test/Index/print-typekind.c create mode 100644 clang/test/Index/print-typekind.m create mode 100644 clang/test/Index/print-usrs.c create mode 100644 clang/test/Index/properties-class-extensions.m create mode 100644 clang/test/Index/rdar-8288645-invalid-code.mm create mode 100644 clang/test/Index/recover-bad-code-rdar_7487294.c create mode 100644 clang/test/Index/recursive-cxx-member-calls.cpp create mode 100644 clang/test/Index/recursive-member-access.c create mode 100644 clang/test/Index/redeclarations.cpp create mode 100644 clang/test/Index/remap-complete.c create mode 100644 clang/test/Index/remap-cursor-at.c create mode 100644 clang/test/Index/remap-load.c create mode 100644 clang/test/Index/reparse-instantiate.cpp create mode 100644 clang/test/Index/retain-target-options.c create mode 100644 clang/test/Index/targeted-annotation.c create mode 100644 clang/test/Index/targeted-cursor.c create mode 100644 clang/test/Index/targeted-cursor.m create mode 100644 clang/test/Index/targeted-cursor.m.h create mode 100644 clang/test/Index/targeted-fields.h create mode 100644 clang/test/Index/targeted-file-refs.c create mode 100644 clang/test/Index/targeted-nested1.h create mode 100644 clang/test/Index/targeted-preamble.h create mode 100644 clang/test/Index/targeted-top.h create mode 100644 clang/test/Index/unmatched-braces.c create mode 100644 clang/test/Index/unmatched-braces.m create mode 100644 clang/test/Index/usrs-cxx0x.cpp create mode 100644 clang/test/Index/usrs.cpp create mode 100644 clang/test/Index/usrs.m create mode 100644 clang/test/Index/vector-types.c create mode 100644 clang/test/Index/warning-flags.c create mode 100644 clang/test/Index/werror.c create mode 100644 clang/test/Lexer/11-27-2007-FloatLiterals.c create mode 100644 clang/test/Lexer/badstring_in_if0.c create mode 100644 clang/test/Lexer/bcpl-escaped-newline.c create mode 100644 clang/test/Lexer/block_cmt_end.c create mode 100644 clang/test/Lexer/c90.c create mode 100644 clang/test/Lexer/char-escapes.c create mode 100644 clang/test/Lexer/char-literal-encoding-error.c create mode 100644 clang/test/Lexer/char-literal.cpp create mode 100644 clang/test/Lexer/clang-keywords.cpp create mode 100644 clang/test/Lexer/comment-escape.c create mode 100644 clang/test/Lexer/conflict-marker.c create mode 100644 clang/test/Lexer/constants.c create mode 100644 clang/test/Lexer/counter.c create mode 100644 clang/test/Lexer/cxx0x_keyword.cpp create mode 100644 clang/test/Lexer/cxx0x_keyword_as_cxx98.cpp create mode 100644 clang/test/Lexer/cxx0x_raw_string_delim_length.cpp create mode 100644 clang/test/Lexer/cxx0x_raw_string_unterminated.cpp create mode 100644 clang/test/Lexer/digraph.c create mode 100644 clang/test/Lexer/dollar-idents.c create mode 100644 clang/test/Lexer/escape_newline.c create mode 100644 clang/test/Lexer/gnu_keywords.c create mode 100644 clang/test/Lexer/has_extension.c create mode 100644 clang/test/Lexer/has_extension_cxx.cpp create mode 100644 clang/test/Lexer/has_feature_address_sanitizer.cpp create mode 100644 clang/test/Lexer/has_feature_c1x.c create mode 100644 clang/test/Lexer/has_feature_cxx0x.cpp create mode 100644 clang/test/Lexer/has_feature_exceptions.cpp create mode 100644 clang/test/Lexer/has_feature_modules.m create mode 100644 clang/test/Lexer/has_feature_objc_arc.m create mode 100644 clang/test/Lexer/has_feature_rtti.cpp create mode 100644 clang/test/Lexer/has_feature_type_traits.cpp create mode 100644 clang/test/Lexer/hexfloat.cpp create mode 100644 clang/test/Lexer/ms-extensions.c create mode 100644 clang/test/Lexer/ms-extensions.cpp create mode 100644 clang/test/Lexer/msdos-cpm-eof.c create mode 100644 clang/test/Lexer/multiple-include.c create mode 100644 clang/test/Lexer/newline-eof-c++11.cpp create mode 100644 clang/test/Lexer/newline-eof-c++98-compat.cpp create mode 100644 clang/test/Lexer/newline-eof.c create mode 100644 clang/test/Lexer/numeric-literal-trash.c create mode 100644 clang/test/Lexer/pragma-mark.c create mode 100644 clang/test/Lexer/pragma-message.c create mode 100644 clang/test/Lexer/pragma-operators.cpp create mode 100644 clang/test/Lexer/preamble.c create mode 100644 clang/test/Lexer/rdar-8914293.c create mode 100644 clang/test/Lexer/rdr-6096838-2.c create mode 100644 clang/test/Lexer/rdr-6096838.c create mode 100644 clang/test/Lexer/string-literal-encoding.c create mode 100644 clang/test/Lexer/string_concat.cpp create mode 100644 clang/test/Lexer/token-concat-2.c create mode 100644 clang/test/Lexer/token-concat.c create mode 100644 clang/test/Lexer/token-concat.cpp create mode 100644 clang/test/Lexer/unknown-char.c create mode 100644 clang/test/Lexer/utf-16.c create mode 100644 clang/test/Lexer/utf-16.c.txt create mode 100644 clang/test/Lexer/utf8-char-literal.cpp create mode 100644 clang/test/Lexer/wchar.c create mode 100644 clang/test/Makefile create mode 100644 clang/test/Misc/Inputs/include.h create mode 100644 clang/test/Misc/Inputs/remapped-file create mode 100644 clang/test/Misc/Inputs/remapped-file-2 create mode 100644 clang/test/Misc/Inputs/remapped-file-3 create mode 100644 clang/test/Misc/Inputs/working-directory.h create mode 100644 clang/test/Misc/ast-dump-templates.cpp create mode 100644 clang/test/Misc/caret-diags-macros.c create mode 100644 clang/test/Misc/caret-diags-scratch-buffer.c create mode 100644 clang/test/Misc/diag-aka-types.cpp create mode 100644 clang/test/Misc/diag-format.c create mode 100644 clang/test/Misc/diag-line-wrapping.cpp create mode 100644 clang/test/Misc/diag-macro-backtrace.c create mode 100644 clang/test/Misc/diag-mapping.c create mode 100644 clang/test/Misc/diag-mapping2.c create mode 100644 clang/test/Misc/diag-verify.cpp create mode 100644 clang/test/Misc/emit-html-insert.c create mode 100644 clang/test/Misc/emit-html.c create mode 100644 clang/test/Misc/error-limit-multiple-notes.cpp create mode 100644 clang/test/Misc/error-limit.c create mode 100644 clang/test/Misc/include-stack-for-note-flag.cpp create mode 100644 clang/test/Misc/integer-literal-printing.cpp create mode 100644 clang/test/Misc/macro-backtrace.c create mode 100644 clang/test/Misc/message-length.c create mode 100644 clang/test/Misc/predefines.c create mode 100644 clang/test/Misc/remap-file.c create mode 100644 clang/test/Misc/serialized-diags-no-category.c create mode 100644 clang/test/Misc/serialized-diags-no-issue.c create mode 100644 clang/test/Misc/serialized-diags-single-issue.c create mode 100644 clang/test/Misc/serialized-diags.c create mode 100644 clang/test/Misc/serialized-diags.h create mode 100644 clang/test/Misc/show-diag-options.c create mode 100644 clang/test/Misc/tabstop.c create mode 100644 clang/test/Misc/unprintable.c create mode 100644 clang/test/Misc/verify.c create mode 100644 clang/test/Misc/warn-in-system-header.c create mode 100644 clang/test/Misc/warn-in-system-header.h create mode 100644 clang/test/Misc/warning-flags.c create mode 100644 clang/test/Misc/wnull-character.cpp create mode 100644 clang/test/Misc/working-directory.c create mode 100644 clang/test/Misc/wrong-encoding.c create mode 100644 clang/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h create mode 100644 clang/test/Modules/Inputs/CmdLine.framework/Headers/CmdLine.h create mode 100644 clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h create mode 100644 clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h create mode 100644 clang/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h create mode 100644 clang/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h create mode 100644 clang/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h create mode 100644 clang/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h create mode 100644 clang/test/Modules/Inputs/DependsOnModule.framework/module.map create mode 100644 clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map create mode 100644 clang/test/Modules/Inputs/MethodPoolA.h create mode 100644 clang/test/Modules/Inputs/MethodPoolB.h create mode 100644 clang/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h create mode 100644 clang/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h create mode 100644 clang/test/Modules/Inputs/Module.framework/Headers/Module.h create mode 100644 clang/test/Modules/Inputs/Module.framework/Headers/NotInModule.h create mode 100644 clang/test/Modules/Inputs/Module.framework/Headers/Sub.h create mode 100644 clang/test/Modules/Inputs/Module.framework/Headers/Sub2.h create mode 100644 clang/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h create mode 100644 clang/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h create mode 100644 clang/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h create mode 100644 clang/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h create mode 100644 clang/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h create mode 100644 clang/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h create mode 100644 clang/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h create mode 100644 clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h create mode 100644 clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h create mode 100644 clang/test/Modules/Inputs/NoUmbrella.framework/module.map create mode 100644 clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map create mode 100644 clang/test/Modules/Inputs/System/usr/include/module.map create mode 100644 clang/test/Modules/Inputs/System/usr/include/stdbool.h create mode 100644 clang/test/Modules/Inputs/System/usr/include/stdint.h create mode 100644 clang/test/Modules/Inputs/System/usr/include/stdio.h create mode 100644 clang/test/Modules/Inputs/category_bottom.h create mode 100644 clang/test/Modules/Inputs/category_left.h create mode 100644 clang/test/Modules/Inputs/category_other.h create mode 100644 clang/test/Modules/Inputs/category_right.h create mode 100644 clang/test/Modules/Inputs/category_top.h create mode 100644 clang/test/Modules/Inputs/decl.h create mode 100644 clang/test/Modules/Inputs/decl2.h create mode 100644 clang/test/Modules/Inputs/def-include.h create mode 100644 clang/test/Modules/Inputs/def.h create mode 100644 clang/test/Modules/Inputs/diamond.h create mode 100644 clang/test/Modules/Inputs/diamond_bottom.h create mode 100644 clang/test/Modules/Inputs/diamond_left.h create mode 100644 clang/test/Modules/Inputs/diamond_right.h create mode 100644 clang/test/Modules/Inputs/diamond_top.h create mode 100644 clang/test/Modules/Inputs/irgen.h create mode 100644 clang/test/Modules/Inputs/load_failure.h create mode 100644 clang/test/Modules/Inputs/lookup_left.h create mode 100644 clang/test/Modules/Inputs/lookup_left.hpp create mode 100644 clang/test/Modules/Inputs/lookup_right.h create mode 100644 clang/test/Modules/Inputs/lookup_right.hpp create mode 100644 clang/test/Modules/Inputs/macros.h create mode 100644 clang/test/Modules/Inputs/module.map create mode 100644 clang/test/Modules/Inputs/module_private_left.h create mode 100644 clang/test/Modules/Inputs/module_private_right.h create mode 100644 clang/test/Modules/Inputs/namespaces-left.h create mode 100644 clang/test/Modules/Inputs/namespaces-right.h create mode 100644 clang/test/Modules/Inputs/namespaces-top.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/Umbrella/module.map create mode 100644 clang/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/Umbrella2/module.map create mode 100644 clang/test/Modules/Inputs/normal-module-map/a1.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/a2.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/b1.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/module.map create mode 100644 clang/test/Modules/Inputs/normal-module-map/nested/module.map create mode 100644 clang/test/Modules/Inputs/normal-module-map/nested/nested1.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/nested/nested2.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h create mode 100644 clang/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h create mode 100644 clang/test/Modules/Inputs/point.h create mode 100644 clang/test/Modules/Inputs/redecl-merge-bottom.h create mode 100644 clang/test/Modules/Inputs/redecl-merge-left-left.h create mode 100644 clang/test/Modules/Inputs/redecl-merge-left.h create mode 100644 clang/test/Modules/Inputs/redecl-merge-right.h create mode 100644 clang/test/Modules/Inputs/redecl-merge-top-explicit.h create mode 100644 clang/test/Modules/Inputs/redecl-merge-top.h create mode 100644 clang/test/Modules/Inputs/redecl_namespaces_left.h create mode 100644 clang/test/Modules/Inputs/redecl_namespaces_right.h create mode 100644 clang/test/Modules/Inputs/redeclarations_left.h create mode 100644 clang/test/Modules/Inputs/redeclarations_right.h create mode 100644 clang/test/Modules/Inputs/subdir/module.map create mode 100644 clang/test/Modules/Inputs/subdir/subdir.h create mode 100644 clang/test/Modules/Inputs/submodules/hash_map.h create mode 100644 clang/test/Modules/Inputs/submodules/module.map create mode 100644 clang/test/Modules/Inputs/submodules/type_traits.h create mode 100644 clang/test/Modules/Inputs/submodules/vector.h create mode 100644 clang/test/Modules/Inputs/wildcard-submodule-exports/A_one.h create mode 100644 clang/test/Modules/Inputs/wildcard-submodule-exports/A_two.h create mode 100644 clang/test/Modules/Inputs/wildcard-submodule-exports/B_one.h create mode 100644 clang/test/Modules/Inputs/wildcard-submodule-exports/B_two.h create mode 100644 clang/test/Modules/Inputs/wildcard-submodule-exports/C_one.h create mode 100644 clang/test/Modules/Inputs/wildcard-submodule-exports/C_two.h create mode 100644 clang/test/Modules/Inputs/wildcard-submodule-exports/module.map create mode 100644 clang/test/Modules/auto-module-import.m create mode 100644 clang/test/Modules/compiler_builtins.m create mode 100644 clang/test/Modules/cstd.m create mode 100644 clang/test/Modules/cycles.c create mode 100644 clang/test/Modules/decldef.mm create mode 100644 clang/test/Modules/diamond-pch.c create mode 100644 clang/test/Modules/diamond.c create mode 100644 clang/test/Modules/driver.c create mode 100644 clang/test/Modules/header-import.m create mode 100644 clang/test/Modules/inferred-submodules.m create mode 100644 clang/test/Modules/irgen.c create mode 100644 clang/test/Modules/load_failure.c create mode 100644 clang/test/Modules/lookup.cpp create mode 100644 clang/test/Modules/lookup.m create mode 100644 clang/test/Modules/macros.c create mode 100644 clang/test/Modules/method_pool.m create mode 100644 clang/test/Modules/module-private.cpp create mode 100644 clang/test/Modules/namespaces.cpp create mode 100644 clang/test/Modules/normal-module-map.cpp create mode 100644 clang/test/Modules/objc-categories.m create mode 100644 clang/test/Modules/on-demand-build-warnings.m create mode 100644 clang/test/Modules/on-demand-build.m create mode 100644 clang/test/Modules/on-demand-macros.m create mode 100644 clang/test/Modules/redecl-merge.m create mode 100644 clang/test/Modules/redecl-namespaces.mm create mode 100644 clang/test/Modules/redeclarations.m create mode 100644 clang/test/Modules/requires.m create mode 100644 clang/test/Modules/subframeworks.m create mode 100644 clang/test/Modules/submodules-preprocess.cpp create mode 100644 clang/test/Modules/submodules.cpp create mode 100644 clang/test/Modules/submodules.m create mode 100644 clang/test/Modules/wildcard-submodule-exports.cpp create mode 100644 clang/test/PCH/Inputs/arc.h create mode 100644 clang/test/PCH/Inputs/chain-decls1.h create mode 100644 clang/test/PCH/Inputs/chain-decls2.h create mode 100644 clang/test/PCH/Inputs/chain-ext_vector1.h create mode 100644 clang/test/PCH/Inputs/chain-ext_vector2.h create mode 100644 clang/test/PCH/Inputs/chain-external-defs1.h create mode 100644 clang/test/PCH/Inputs/chain-external-defs2.h create mode 100644 clang/test/PCH/Inputs/chain-macro-override1.h create mode 100644 clang/test/PCH/Inputs/chain-macro-override2.h create mode 100644 clang/test/PCH/Inputs/chain-macro1.h create mode 100644 clang/test/PCH/Inputs/chain-macro2.h create mode 100644 clang/test/PCH/Inputs/chain-remap-types1.h create mode 100644 clang/test/PCH/Inputs/chain-remap-types2.h create mode 100644 clang/test/PCH/Inputs/chain-selectors1.h create mode 100644 clang/test/PCH/Inputs/chain-selectors2.h create mode 100644 clang/test/PCH/Inputs/chain-trivial1.h create mode 100644 clang/test/PCH/Inputs/chain-trivial2.h create mode 100644 clang/test/PCH/Inputs/cxx-method.h create mode 100644 clang/test/PCH/Inputs/namespaces.h create mode 100644 clang/test/PCH/Inputs/preamble.h create mode 100644 clang/test/PCH/Inputs/typo.h create mode 100644 clang/test/PCH/Inputs/typo.hpp create mode 100644 clang/test/PCH/Inputs/va_arg.h create mode 100644 clang/test/PCH/Inputs/working-directory-1.h create mode 100644 clang/test/PCH/arc.m create mode 100644 clang/test/PCH/asm.c create mode 100644 clang/test/PCH/asm.h create mode 100644 clang/test/PCH/attrs-PR8406.c create mode 100644 clang/test/PCH/attrs.c create mode 100644 clang/test/PCH/blocks.c create mode 100644 clang/test/PCH/blocks.h create mode 100644 clang/test/PCH/builtins.c create mode 100644 clang/test/PCH/builtins.h create mode 100644 clang/test/PCH/chain-categories.m create mode 100644 clang/test/PCH/chain-categories2.m create mode 100644 clang/test/PCH/chain-class-extension.m create mode 100644 clang/test/PCH/chain-conversion-lookup.cpp create mode 100644 clang/test/PCH/chain-cxx.cpp create mode 100644 clang/test/PCH/chain-decls.c create mode 100644 clang/test/PCH/chain-empty-initial-namespace.cpp create mode 100644 clang/test/PCH/chain-ext_vector.c create mode 100644 clang/test/PCH/chain-external-defs.c create mode 100644 clang/test/PCH/chain-friend-instantiation.cpp create mode 100644 clang/test/PCH/chain-implicit-definition.cpp create mode 100644 clang/test/PCH/chain-late-anonymous-namespace.cpp create mode 100644 clang/test/PCH/chain-macro-override.c create mode 100644 clang/test/PCH/chain-macro.c create mode 100644 clang/test/PCH/chain-pending-instantiations.cpp create mode 100644 clang/test/PCH/chain-predecl.h create mode 100644 clang/test/PCH/chain-predecl.m create mode 100644 clang/test/PCH/chain-remap-types.m create mode 100644 clang/test/PCH/chain-selectors.m create mode 100644 clang/test/PCH/chain-trivial.c create mode 100644 clang/test/PCH/changed-files.c create mode 100644 clang/test/PCH/check-deserializations.cpp create mode 100644 clang/test/PCH/cmdline-include.c create mode 100644 clang/test/PCH/cmdline-include1.h create mode 100644 clang/test/PCH/cmdline-include2.h create mode 100644 clang/test/PCH/cocoa.m create mode 100644 clang/test/PCH/cuda-kernel-call.cu create mode 100644 clang/test/PCH/cxx-alias-decl.cpp create mode 100644 clang/test/PCH/cxx-alias-decl.h create mode 100644 clang/test/PCH/cxx-chain-function-template.cpp create mode 100644 clang/test/PCH/cxx-constexpr.cpp create mode 100644 clang/test/PCH/cxx-exprs.cpp create mode 100644 clang/test/PCH/cxx-for-range.cpp create mode 100644 clang/test/PCH/cxx-for-range.h create mode 100644 clang/test/PCH/cxx-friends.cpp create mode 100644 clang/test/PCH/cxx-friends.h create mode 100644 clang/test/PCH/cxx-functions.cpp create mode 100644 clang/test/PCH/cxx-functions.h create mode 100644 clang/test/PCH/cxx-implicit-moves.cpp create mode 100644 clang/test/PCH/cxx-member-init.cpp create mode 100644 clang/test/PCH/cxx-method.cpp create mode 100644 clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp create mode 100644 clang/test/PCH/cxx-ms-function-specialization-class-scope.h create mode 100644 clang/test/PCH/cxx-namespaces.cpp create mode 100644 clang/test/PCH/cxx-namespaces.h create mode 100644 clang/test/PCH/cxx-offsetof-base.cpp create mode 100644 clang/test/PCH/cxx-offsetof-base.h create mode 100644 clang/test/PCH/cxx-reference.cpp create mode 100644 clang/test/PCH/cxx-reference.h create mode 100644 clang/test/PCH/cxx-required-decls.cpp create mode 100644 clang/test/PCH/cxx-required-decls.h create mode 100644 clang/test/PCH/cxx-static_assert.cpp create mode 100644 clang/test/PCH/cxx-templates.cpp create mode 100644 clang/test/PCH/cxx-templates.h create mode 100644 clang/test/PCH/cxx-trailing-return.cpp create mode 100644 clang/test/PCH/cxx-traits.cpp create mode 100644 clang/test/PCH/cxx-traits.h create mode 100644 clang/test/PCH/cxx-typeid.cpp create mode 100644 clang/test/PCH/cxx-typeid.h create mode 100644 clang/test/PCH/cxx-using.cpp create mode 100644 clang/test/PCH/cxx-using.h create mode 100644 clang/test/PCH/cxx-variadic-templates.cpp create mode 100644 clang/test/PCH/cxx-variadic-templates.h create mode 100644 clang/test/PCH/cxx0x-default-delete.cpp create mode 100644 clang/test/PCH/cxx0x-delegating-ctors.cpp create mode 100644 clang/test/PCH/cxx11-constexpr.cpp create mode 100644 clang/test/PCH/cxx11-enum-template.cpp create mode 100644 clang/test/PCH/cxx11-exception-spec.cpp create mode 100644 clang/test/PCH/cxx11-lambdas.mm create mode 100644 clang/test/PCH/cxx11-user-defined-literals.cpp create mode 100644 clang/test/PCH/cxx_exprs.cpp create mode 100644 clang/test/PCH/cxx_exprs.h create mode 100644 clang/test/PCH/designated-init.c create mode 100644 clang/test/PCH/designated-init.c.h create mode 100644 clang/test/PCH/enum.c create mode 100644 clang/test/PCH/enum.h create mode 100644 clang/test/PCH/exprs.c create mode 100644 clang/test/PCH/exprs.h create mode 100644 clang/test/PCH/ext_vector.c create mode 100644 clang/test/PCH/ext_vector.h create mode 100644 clang/test/PCH/external-defs.c create mode 100644 clang/test/PCH/external-defs.h create mode 100644 clang/test/PCH/functions.c create mode 100644 clang/test/PCH/functions.h create mode 100644 clang/test/PCH/fuzzy-pch.c create mode 100644 clang/test/PCH/fuzzy-pch.h create mode 100644 clang/test/PCH/headermap.h create mode 100644 clang/test/PCH/headermap.m create mode 100644 clang/test/PCH/headersearch.cpp create mode 100644 clang/test/PCH/libroot/usr/include/reloc.h create mode 100644 clang/test/PCH/libroot/usr/include/reloc2.h create mode 100644 clang/test/PCH/line-directive.c create mode 100644 clang/test/PCH/line-directive.h create mode 100644 clang/test/PCH/method-redecls.m create mode 100644 clang/test/PCH/method_pool.h create mode 100644 clang/test/PCH/method_pool.m create mode 100644 clang/test/PCH/missing-file.cpp create mode 100644 clang/test/PCH/modified-header-crash.c create mode 100644 clang/test/PCH/modified-header-crash.h create mode 100644 clang/test/PCH/modified-header-error.c create mode 100644 clang/test/PCH/ms-if-exists.cpp create mode 100644 clang/test/PCH/multiple_decls.c create mode 100644 clang/test/PCH/multiple_decls.h create mode 100644 clang/test/PCH/namespaces.cpp create mode 100644 clang/test/PCH/nonvisible-external-defs.c create mode 100644 clang/test/PCH/nonvisible-external-defs.h create mode 100644 clang/test/PCH/objc_container.h create mode 100644 clang/test/PCH/objc_container.m create mode 100644 clang/test/PCH/objc_exprs.h create mode 100644 clang/test/PCH/objc_exprs.m create mode 100644 clang/test/PCH/objc_import.h create mode 100644 clang/test/PCH/objc_import.m create mode 100644 clang/test/PCH/objc_literals.m create mode 100644 clang/test/PCH/objc_literals.mm create mode 100644 clang/test/PCH/objc_methods.h create mode 100644 clang/test/PCH/objc_methods.m create mode 100644 clang/test/PCH/objc_property.h create mode 100644 clang/test/PCH/objc_property.m create mode 100644 clang/test/PCH/objc_stmts.h create mode 100644 clang/test/PCH/objc_stmts.m create mode 100644 clang/test/PCH/objcxx-ivar-class.h create mode 100644 clang/test/PCH/objcxx-ivar-class.mm create mode 100644 clang/test/PCH/opencl-extensions.cl create mode 100644 clang/test/PCH/pchpch.c create mode 100644 clang/test/PCH/pchpch1.h create mode 100644 clang/test/PCH/pchpch2.h create mode 100644 clang/test/PCH/pending-ids.m create mode 100644 clang/test/PCH/pr4489.c create mode 100644 clang/test/PCH/pragma-diag-section.cpp create mode 100644 clang/test/PCH/pragma-diag.c create mode 100644 clang/test/PCH/pragma-weak.c create mode 100644 clang/test/PCH/pragma-weak.h create mode 100644 clang/test/PCH/preamble.c create mode 100644 clang/test/PCH/preprocess.c create mode 100644 clang/test/PCH/preprocess.h create mode 100644 clang/test/PCH/pth.c create mode 100644 clang/test/PCH/pth.h create mode 100644 clang/test/PCH/rdar10830559.cpp create mode 100644 clang/test/PCH/rdar8852495.c create mode 100644 clang/test/PCH/reinclude.cpp create mode 100644 clang/test/PCH/reinclude1.h create mode 100644 clang/test/PCH/reinclude2.h create mode 100644 clang/test/PCH/reloc.c create mode 100644 clang/test/PCH/replaced-decl.m create mode 100644 clang/test/PCH/selector-warning.h create mode 100644 clang/test/PCH/selector-warning.m create mode 100644 clang/test/PCH/single-token-macro.c create mode 100644 clang/test/PCH/source-manager-stack.c create mode 100644 clang/test/PCH/stmts.c create mode 100644 clang/test/PCH/stmts.h create mode 100644 clang/test/PCH/struct.c create mode 100644 clang/test/PCH/struct.h create mode 100644 clang/test/PCH/subscripting-literals.m create mode 100644 clang/test/PCH/tentative-defs.c create mode 100644 clang/test/PCH/tentative-defs.h create mode 100644 clang/test/PCH/types.c create mode 100644 clang/test/PCH/types.h create mode 100644 clang/test/PCH/typo.cpp create mode 100644 clang/test/PCH/typo.m create mode 100644 clang/test/PCH/typo2.cpp create mode 100644 clang/test/PCH/va_arg.c create mode 100644 clang/test/PCH/va_arg.cpp create mode 100644 clang/test/PCH/va_arg.h create mode 100644 clang/test/PCH/variables.c create mode 100644 clang/test/PCH/variables.h create mode 100644 clang/test/PCH/working-directory.cpp create mode 100644 clang/test/PCH/working-directory.h create mode 100644 clang/test/Parser/CompoundStmtScope.c create mode 100644 clang/test/Parser/DelayedTemplateParsing.cpp create mode 100644 clang/test/Parser/MicrosoftExtensions.c create mode 100644 clang/test/Parser/MicrosoftExtensions.cpp create mode 100644 clang/test/Parser/PR11000.cpp create mode 100644 clang/test/Parser/access-spec-attrs.cpp create mode 100644 clang/test/Parser/altivec.c create mode 100644 clang/test/Parser/argument_qualified.c create mode 100644 clang/test/Parser/argument_redef.c create mode 100644 clang/test/Parser/argument_scope.c create mode 100644 clang/test/Parser/asm-constraints-pr7869.c create mode 100644 clang/test/Parser/asm.c create mode 100644 clang/test/Parser/asm.cpp create mode 100644 clang/test/Parser/attr-availability.c create mode 100644 clang/test/Parser/attributes.c create mode 100644 clang/test/Parser/backtrack-crash.cpp create mode 100644 clang/test/Parser/bad-control.c create mode 100644 clang/test/Parser/block-block-storageclass.c create mode 100644 clang/test/Parser/block-pointer-decl.c create mode 100644 clang/test/Parser/bracket-crash.cpp create mode 100644 clang/test/Parser/builtin_classify_type.c create mode 100644 clang/test/Parser/builtin_types_compatible.c create mode 100644 clang/test/Parser/c-namespace.c create mode 100644 clang/test/Parser/c1x-alignas.c create mode 100644 clang/test/Parser/c1x-generic-selection.c create mode 100644 clang/test/Parser/char-literal-printing.c create mode 100644 clang/test/Parser/check-objc2-syntax-1.m create mode 100644 clang/test/Parser/check-syntax-1.m create mode 100644 clang/test/Parser/check_cast.c create mode 100644 clang/test/Parser/compound_literal.c create mode 100644 clang/test/Parser/control-scope.c create mode 100644 clang/test/Parser/cuda-kernel-call.cu create mode 100644 clang/test/Parser/cxx-altivec.cpp create mode 100644 clang/test/Parser/cxx-ambig-decl-expr-xfail.cpp create mode 100644 clang/test/Parser/cxx-ambig-decl-expr.cpp create mode 100644 clang/test/Parser/cxx-ambig-paren-expr.cpp create mode 100644 clang/test/Parser/cxx-attributes.cpp create mode 100644 clang/test/Parser/cxx-bool.cpp create mode 100644 clang/test/Parser/cxx-casting.cpp create mode 100644 clang/test/Parser/cxx-class.cpp create mode 100644 clang/test/Parser/cxx-condition.cpp create mode 100644 clang/test/Parser/cxx-decl.cpp create mode 100644 clang/test/Parser/cxx-default-args.cpp create mode 100644 clang/test/Parser/cxx-default-delete.cpp create mode 100644 clang/test/Parser/cxx-ext-delete-default.cpp create mode 100644 clang/test/Parser/cxx-extern-c-array.cpp create mode 100644 clang/test/Parser/cxx-friend.cpp create mode 100644 clang/test/Parser/cxx-in-c.c create mode 100644 clang/test/Parser/cxx-member-crash.cpp create mode 100644 clang/test/Parser/cxx-member-init-missing-paren-crash.cpp create mode 100644 clang/test/Parser/cxx-member-initializers.cpp create mode 100644 clang/test/Parser/cxx-namespace-alias.cpp create mode 100644 clang/test/Parser/cxx-reference.cpp create mode 100644 clang/test/Parser/cxx-stmt.cpp create mode 100644 clang/test/Parser/cxx-template-argument.cpp create mode 100644 clang/test/Parser/cxx-template-decl.cpp create mode 100644 clang/test/Parser/cxx-throw.cpp create mode 100644 clang/test/Parser/cxx-typeid.cpp create mode 100644 clang/test/Parser/cxx-typeof.cpp create mode 100644 clang/test/Parser/cxx-undeclared-identifier.cpp create mode 100644 clang/test/Parser/cxx-using-declaration.cpp create mode 100644 clang/test/Parser/cxx-using-directive.cpp create mode 100644 clang/test/Parser/cxx-variadic-func.cpp create mode 100644 clang/test/Parser/cxx0x-ambig.cpp create mode 100644 clang/test/Parser/cxx0x-attributes.cpp create mode 100644 clang/test/Parser/cxx0x-condition.cpp create mode 100644 clang/test/Parser/cxx0x-decl.cpp create mode 100644 clang/test/Parser/cxx0x-for-range.cpp create mode 100644 clang/test/Parser/cxx0x-in-cxx98.cpp create mode 100644 clang/test/Parser/cxx0x-lambda-expressions.cpp create mode 100644 clang/test/Parser/cxx0x-literal-operators.cpp create mode 100644 clang/test/Parser/cxx0x-member-initializers.cpp create mode 100644 clang/test/Parser/cxx0x-override-control-keywords.cpp create mode 100644 clang/test/Parser/cxx0x-rvalue-reference.cpp create mode 100644 clang/test/Parser/cxx11-stmt-attributes.cpp create mode 100644 clang/test/Parser/cxx11-type-specifier.cpp create mode 100644 clang/test/Parser/cxx11-user-defined-literals.cpp create mode 100644 clang/test/Parser/declarators.c create mode 100644 clang/test/Parser/designator.c create mode 100644 clang/test/Parser/encode.m create mode 100644 clang/test/Parser/enhanced-proto-1.m create mode 100644 clang/test/Parser/expressions.c create mode 100644 clang/test/Parser/expressions.m create mode 100644 clang/test/Parser/extension.c create mode 100644 clang/test/Parser/for.cpp create mode 100644 clang/test/Parser/function-decls.c create mode 100644 clang/test/Parser/goto.c create mode 100644 clang/test/Parser/if-scope-c90.c create mode 100644 clang/test/Parser/if-scope-c99.c create mode 100644 clang/test/Parser/implicit-casts.c create mode 100644 clang/test/Parser/knr_parameter_attributes.c create mode 100644 clang/test/Parser/method-def-in-class.m create mode 100644 clang/test/Parser/method-prototype-1.m create mode 100644 clang/test/Parser/missing-end-2.m create mode 100644 clang/test/Parser/missing-end-3.m create mode 100644 clang/test/Parser/missing-end-4.m create mode 100644 clang/test/Parser/missing-end.m create mode 100644 clang/test/Parser/ms-inline-asm.c create mode 100644 clang/test/Parser/namelookup-bug-1.c create mode 100644 clang/test/Parser/namelookup-bug-2.c create mode 100644 clang/test/Parser/namespace-alias-attr.cpp create mode 100644 clang/test/Parser/namespaces.cpp create mode 100644 clang/test/Parser/nested-namespaces-recovery.cpp create mode 100644 clang/test/Parser/objc-alias-printing.m create mode 100644 clang/test/Parser/objc-category-neg-1.m create mode 100644 clang/test/Parser/objc-forcollection-1.m create mode 100644 clang/test/Parser/objc-forcollection-neg-2.m create mode 100644 clang/test/Parser/objc-forcollection-neg.m create mode 100644 clang/test/Parser/objc-foreach-syntax.m create mode 100644 clang/test/Parser/objc-init.m create mode 100644 clang/test/Parser/objc-interfaces.m create mode 100644 clang/test/Parser/objc-messaging-1.m create mode 100644 clang/test/Parser/objc-messaging-neg-1.m create mode 100644 clang/test/Parser/objc-missing-impl.m create mode 100644 clang/test/Parser/objc-property-syntax.m create mode 100644 clang/test/Parser/objc-quirks.m create mode 100644 clang/test/Parser/objc-synthesized-recover.m create mode 100644 clang/test/Parser/objc-try-catch-1.m create mode 100644 clang/test/Parser/objc-type-printing.m create mode 100644 clang/test/Parser/objcxx-at.mm create mode 100644 clang/test/Parser/objcxx-lambda-expressions-neg.mm create mode 100644 clang/test/Parser/objcxx0x-lambda-expressions.mm create mode 100644 clang/test/Parser/objcxx11-attributes.mm create mode 100644 clang/test/Parser/objcxx11-user-defined-literal.mm create mode 100644 clang/test/Parser/offsetof.c create mode 100644 clang/test/Parser/opencl-astype.cl create mode 100644 clang/test/Parser/opencl-image-access.cl create mode 100644 clang/test/Parser/opencl-kernel.cl create mode 100644 clang/test/Parser/opencl-pragma.cl create mode 100644 clang/test/Parser/opencl-storage-class.cl create mode 100644 clang/test/Parser/parenthesis-balance.cpp create mode 100644 clang/test/Parser/parmvardecl_conversion.c create mode 100644 clang/test/Parser/parser_overflow.c create mode 100644 clang/test/Parser/placeholder-recovery.m create mode 100644 clang/test/Parser/pointer-arithmetic.c create mode 100644 clang/test/Parser/pointer_promotion.c create mode 100644 clang/test/Parser/pragma-options.c create mode 100644 clang/test/Parser/pragma-pack.c create mode 100644 clang/test/Parser/pragma-visibility.c create mode 100644 clang/test/Parser/pragma-visibility2.c create mode 100644 clang/test/Parser/pragma-weak.c create mode 100644 clang/test/Parser/prefix-attributes.m create mode 100644 clang/test/Parser/promote_types_in_proto.c create mode 100644 clang/test/Parser/recovery.c create mode 100644 clang/test/Parser/recovery.cpp create mode 100644 clang/test/Parser/recovery.m create mode 100644 clang/test/Parser/recursion-limits.cpp create mode 100644 clang/test/Parser/selector-1.m create mode 100644 clang/test/Parser/skip-function-bodies.mm create mode 100644 clang/test/Parser/statements.c create mode 100644 clang/test/Parser/struct-recursion.c create mode 100644 clang/test/Parser/switch-recovery.cpp create mode 100644 clang/test/Parser/top-level-semi-cxx0x.cpp create mode 100644 clang/test/Parser/traditional_arg_scope.c create mode 100644 clang/test/Parser/typeof.c create mode 100644 clang/test/Parser/types.c create mode 100644 clang/test/Parser/warn-dangling-else.cpp create mode 100644 clang/test/Preprocessor/Inputs/TestFramework.framework/.system_framework create mode 100644 clang/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h create mode 100644 clang/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h create mode 100644 clang/test/Preprocessor/_Pragma-dependency.c create mode 100644 clang/test/Preprocessor/_Pragma-dependency2.c create mode 100644 clang/test/Preprocessor/_Pragma-in-macro-arg.c create mode 100644 clang/test/Preprocessor/_Pragma-location.c create mode 100644 clang/test/Preprocessor/_Pragma-physloc.c create mode 100644 clang/test/Preprocessor/_Pragma.c create mode 100644 clang/test/Preprocessor/assembler-with-cpp.c create mode 100644 clang/test/Preprocessor/builtin_line.c create mode 100644 clang/test/Preprocessor/c90.c create mode 100644 clang/test/Preprocessor/c99-6_10_3_3_p4.c create mode 100644 clang/test/Preprocessor/c99-6_10_3_4_p5.c create mode 100644 clang/test/Preprocessor/c99-6_10_3_4_p6.c create mode 100644 clang/test/Preprocessor/c99-6_10_3_4_p7.c create mode 100644 clang/test/Preprocessor/c99-6_10_3_4_p9.c create mode 100644 clang/test/Preprocessor/clang_headers.c create mode 100644 clang/test/Preprocessor/comment_save.c create mode 100644 clang/test/Preprocessor/comment_save_if.c create mode 100644 clang/test/Preprocessor/comment_save_macro.c create mode 100644 clang/test/Preprocessor/cxx_and.cpp create mode 100644 clang/test/Preprocessor/cxx_bitand.cpp create mode 100644 clang/test/Preprocessor/cxx_bitor.cpp create mode 100644 clang/test/Preprocessor/cxx_compl.cpp create mode 100644 clang/test/Preprocessor/cxx_not.cpp create mode 100644 clang/test/Preprocessor/cxx_not_eq.cpp create mode 100644 clang/test/Preprocessor/cxx_oper_keyword.cpp create mode 100644 clang/test/Preprocessor/cxx_oper_keyword_ms_compat.cpp create mode 100644 clang/test/Preprocessor/cxx_oper_spelling.cpp create mode 100644 clang/test/Preprocessor/cxx_or.cpp create mode 100644 clang/test/Preprocessor/cxx_true.cpp create mode 100644 clang/test/Preprocessor/cxx_xor.cpp create mode 100644 clang/test/Preprocessor/dependencies-and-pp.c create mode 100644 clang/test/Preprocessor/directive-invalid.c create mode 100644 clang/test/Preprocessor/disabled-cond-diags.c create mode 100644 clang/test/Preprocessor/dump-macros-spacing.c create mode 100644 clang/test/Preprocessor/dump-macros-undef.c create mode 100644 clang/test/Preprocessor/dump-options.c create mode 100644 clang/test/Preprocessor/dump_macros.c create mode 100644 clang/test/Preprocessor/dumptokens_phyloc.c create mode 100644 clang/test/Preprocessor/expr_comma.c create mode 100644 clang/test/Preprocessor/expr_define_expansion.c create mode 100644 clang/test/Preprocessor/expr_invalid_tok.c create mode 100644 clang/test/Preprocessor/expr_liveness.c create mode 100644 clang/test/Preprocessor/expr_multichar.c create mode 100644 clang/test/Preprocessor/expr_usual_conversions.c create mode 100644 clang/test/Preprocessor/extension-warning.c create mode 100644 clang/test/Preprocessor/feature_tests.c create mode 100644 clang/test/Preprocessor/file_to_include.h create mode 100644 clang/test/Preprocessor/function_macro_file.c create mode 100644 clang/test/Preprocessor/function_macro_file.h create mode 100644 clang/test/Preprocessor/has_attribute.c create mode 100644 clang/test/Preprocessor/has_include.c create mode 100644 clang/test/Preprocessor/hash_line.c create mode 100644 clang/test/Preprocessor/hash_space.c create mode 100644 clang/test/Preprocessor/header_lookup1.c create mode 100644 clang/test/Preprocessor/if_warning.c create mode 100644 clang/test/Preprocessor/ifdef-recover.c create mode 100644 clang/test/Preprocessor/import_self.c create mode 100644 clang/test/Preprocessor/include-directive1.c create mode 100644 clang/test/Preprocessor/include-directive2.c create mode 100644 clang/test/Preprocessor/include-directive3.c create mode 100644 clang/test/Preprocessor/include-macros.c create mode 100644 clang/test/Preprocessor/include-pth.c create mode 100644 clang/test/Preprocessor/indent_macro.c create mode 100644 clang/test/Preprocessor/init.c create mode 100644 clang/test/Preprocessor/line-directive-output.c create mode 100644 clang/test/Preprocessor/line-directive.c create mode 100644 clang/test/Preprocessor/macro-multiline.c create mode 100644 clang/test/Preprocessor/macro_arg_directive.c create mode 100644 clang/test/Preprocessor/macro_arg_directive.h create mode 100644 clang/test/Preprocessor/macro_arg_keyword.c create mode 100644 clang/test/Preprocessor/macro_disable.c create mode 100644 clang/test/Preprocessor/macro_expand.c create mode 100644 clang/test/Preprocessor/macro_expandloc.c create mode 100644 clang/test/Preprocessor/macro_expandloc2.c create mode 100644 clang/test/Preprocessor/macro_fn.c create mode 100644 clang/test/Preprocessor/macro_fn_comma_swallow.c create mode 100644 clang/test/Preprocessor/macro_fn_disable_expand.c create mode 100644 clang/test/Preprocessor/macro_fn_lparen_scan.c create mode 100644 clang/test/Preprocessor/macro_fn_lparen_scan2.c create mode 100644 clang/test/Preprocessor/macro_fn_placemarker.c create mode 100644 clang/test/Preprocessor/macro_fn_preexpand.c create mode 100644 clang/test/Preprocessor/macro_fn_varargs_iso.c create mode 100644 clang/test/Preprocessor/macro_fn_varargs_named.c create mode 100644 clang/test/Preprocessor/macro_misc.c create mode 100644 clang/test/Preprocessor/macro_not_define.c create mode 100644 clang/test/Preprocessor/macro_paste_bad.c create mode 100644 clang/test/Preprocessor/macro_paste_bcpl_comment.c create mode 100644 clang/test/Preprocessor/macro_paste_c_block_comment.c create mode 100644 clang/test/Preprocessor/macro_paste_commaext.c create mode 100644 clang/test/Preprocessor/macro_paste_empty.c create mode 100644 clang/test/Preprocessor/macro_paste_hard.c create mode 100644 clang/test/Preprocessor/macro_paste_hashhash.c create mode 100644 clang/test/Preprocessor/macro_paste_msextensions.c create mode 100644 clang/test/Preprocessor/macro_paste_none.c create mode 100644 clang/test/Preprocessor/macro_paste_simple.c create mode 100644 clang/test/Preprocessor/macro_paste_spacing.c create mode 100644 clang/test/Preprocessor/macro_paste_spacing2.c create mode 100644 clang/test/Preprocessor/macro_rescan.c create mode 100644 clang/test/Preprocessor/macro_rescan2.c create mode 100644 clang/test/Preprocessor/macro_rescan_varargs.c create mode 100644 clang/test/Preprocessor/macro_rparen_scan.c create mode 100644 clang/test/Preprocessor/macro_rparen_scan2.c create mode 100644 clang/test/Preprocessor/macro_space.c create mode 100644 clang/test/Preprocessor/macro_undef.c create mode 100644 clang/test/Preprocessor/mi_opt.c create mode 100644 clang/test/Preprocessor/mi_opt.h create mode 100644 clang/test/Preprocessor/mi_opt2.c create mode 100644 clang/test/Preprocessor/mi_opt2.h create mode 100644 clang/test/Preprocessor/microsoft-import.c create mode 100644 clang/test/Preprocessor/missing-system-header.c create mode 100644 clang/test/Preprocessor/missing-system-header.h create mode 100644 clang/test/Preprocessor/mmx.c create mode 100644 clang/test/Preprocessor/non_fragile_feature.m create mode 100644 clang/test/Preprocessor/non_fragile_feature1.m create mode 100644 clang/test/Preprocessor/objc-pp.m create mode 100644 clang/test/Preprocessor/optimize.c create mode 100644 clang/test/Preprocessor/output_paste_avoid.c create mode 100644 clang/test/Preprocessor/overflow.c create mode 100644 clang/test/Preprocessor/pic.c create mode 100644 clang/test/Preprocessor/pp-record.c create mode 100644 clang/test/Preprocessor/pp-record.h create mode 100644 clang/test/Preprocessor/pr2086.c create mode 100644 clang/test/Preprocessor/pr2086.h create mode 100644 clang/test/Preprocessor/pragma-pushpop-macro.c create mode 100644 clang/test/Preprocessor/pragma_diagnostic.c create mode 100644 clang/test/Preprocessor/pragma_diagnostic_output.c create mode 100644 clang/test/Preprocessor/pragma_diagnostic_sections.cpp create mode 100644 clang/test/Preprocessor/pragma_microsoft.c create mode 100644 clang/test/Preprocessor/pragma_poison.c create mode 100644 clang/test/Preprocessor/pragma_sysheader.c create mode 100644 clang/test/Preprocessor/pragma_sysheader.h create mode 100644 clang/test/Preprocessor/pragma_unknown.c create mode 100644 clang/test/Preprocessor/predefined-arch-macros.c create mode 100644 clang/test/Preprocessor/predefined-exceptions.m create mode 100644 clang/test/Preprocessor/predefined-macros.c create mode 100644 clang/test/Preprocessor/print_line_count.c create mode 100644 clang/test/Preprocessor/print_line_empty_file.c create mode 100644 clang/test/Preprocessor/print_line_track.c create mode 100644 clang/test/Preprocessor/pushable-diagnostics.c create mode 100644 clang/test/Preprocessor/skipping_unclean.c create mode 100644 clang/test/Preprocessor/stdint.c create mode 100644 clang/test/Preprocessor/stringize_misc.c create mode 100644 clang/test/Preprocessor/stringize_space.c create mode 100644 clang/test/Preprocessor/stringize_space2.c create mode 100644 clang/test/Preprocessor/traditional-cpp.c create mode 100644 clang/test/Preprocessor/undef-error.c create mode 100644 clang/test/Preprocessor/unterminated.c create mode 100644 clang/test/Preprocessor/user_defined_system_framework.c create mode 100644 clang/test/Preprocessor/warn-disabled-macro-expansion.c create mode 100644 clang/test/Preprocessor/warn-macro-unused.c create mode 100644 clang/test/Preprocessor/warn-macro-unused.h create mode 100644 clang/test/Preprocessor/warning_tests.c create mode 100644 clang/test/Preprocessor/x86_target_features.c create mode 100644 clang/test/Rewriter/blockcast3.mm create mode 100644 clang/test/Rewriter/blockstruct.m create mode 100644 clang/test/Rewriter/crash.m create mode 100644 clang/test/Rewriter/dllimport-typedef.c create mode 100644 clang/test/Rewriter/finally.m create mode 100644 clang/test/Rewriter/func-in-impl.m create mode 100644 clang/test/Rewriter/id-test-3.m create mode 100644 clang/test/Rewriter/inner-block-helper-funcs.mm create mode 100644 clang/test/Rewriter/instancetype-test.mm create mode 100644 clang/test/Rewriter/ivar-encoding-1.m create mode 100644 clang/test/Rewriter/ivar-encoding-2.m create mode 100644 clang/test/Rewriter/metadata-test-1.m create mode 100644 clang/test/Rewriter/metadata-test-2.m create mode 100644 clang/test/Rewriter/method-encoding-1.m create mode 100644 clang/test/Rewriter/missing-dllimport.c create mode 100644 clang/test/Rewriter/objc-bool-literal-check-modern.mm create mode 100644 clang/test/Rewriter/objc-bool-literal-modern-1.mm create mode 100644 clang/test/Rewriter/objc-bool-literal-modern.mm create mode 100644 clang/test/Rewriter/objc-encoding-bug-1.m create mode 100644 clang/test/Rewriter/objc-ivar-receiver-1.m create mode 100644 clang/test/Rewriter/objc-modern-class-init-hooks.mm create mode 100644 clang/test/Rewriter/objc-modern-class-init.mm create mode 100644 clang/test/Rewriter/objc-modern-container-subscript.mm create mode 100644 clang/test/Rewriter/objc-modern-implicit-cast.mm create mode 100644 clang/test/Rewriter/objc-modern-ivar-receiver-1.mm create mode 100644 clang/test/Rewriter/objc-modern-linkage-spec.mm create mode 100644 clang/test/Rewriter/objc-modern-metadata-visibility.mm create mode 100644 clang/test/Rewriter/objc-modern-numeric-literal.mm create mode 100644 clang/test/Rewriter/objc-modern-property-attributes.mm create mode 100644 clang/test/Rewriter/objc-string-concat-1.m create mode 100644 clang/test/Rewriter/objc-super-test.m create mode 100644 clang/test/Rewriter/objc-synchronized-1.m create mode 100644 clang/test/Rewriter/properties.m create mode 100644 clang/test/Rewriter/property-dot-syntax.mm create mode 100644 clang/test/Rewriter/protocol-rewrite-1.m create mode 100644 clang/test/Rewriter/protocol-rewrite-2.m create mode 100644 clang/test/Rewriter/rewrite-anonymous-union.m create mode 100644 clang/test/Rewriter/rewrite-api-bug.m create mode 100644 clang/test/Rewriter/rewrite-block-argument.m create mode 100644 clang/test/Rewriter/rewrite-block-consts.mm create mode 100644 clang/test/Rewriter/rewrite-block-ivar-call.mm create mode 100644 clang/test/Rewriter/rewrite-block-literal-1.mm create mode 100644 clang/test/Rewriter/rewrite-block-literal.mm create mode 100644 clang/test/Rewriter/rewrite-block-pointer.mm create mode 100644 clang/test/Rewriter/rewrite-block-property.m create mode 100644 clang/test/Rewriter/rewrite-byref-in-nested-blocks.mm create mode 100644 clang/test/Rewriter/rewrite-byref-vars.mm create mode 100644 clang/test/Rewriter/rewrite-captured-nested-bvar.c create mode 100644 clang/test/Rewriter/rewrite-cast-ivar-access.mm create mode 100644 clang/test/Rewriter/rewrite-cast-ivar-modern-access.mm create mode 100644 clang/test/Rewriter/rewrite-cast-to-bool.mm create mode 100644 clang/test/Rewriter/rewrite-category-property.mm create mode 100644 clang/test/Rewriter/rewrite-constructor-init.mm create mode 100644 clang/test/Rewriter/rewrite-eh.m create mode 100644 clang/test/Rewriter/rewrite-elaborated-type.mm create mode 100644 clang/test/Rewriter/rewrite-extern-c.mm create mode 100644 clang/test/Rewriter/rewrite-foreach-1.m create mode 100644 clang/test/Rewriter/rewrite-foreach-2.m create mode 100644 clang/test/Rewriter/rewrite-foreach-3.m create mode 100644 clang/test/Rewriter/rewrite-foreach-4.m create mode 100644 clang/test/Rewriter/rewrite-foreach-5.m create mode 100644 clang/test/Rewriter/rewrite-foreach-6.m create mode 100644 clang/test/Rewriter/rewrite-foreach-7.m create mode 100644 clang/test/Rewriter/rewrite-foreach-in-block.mm create mode 100644 clang/test/Rewriter/rewrite-foreach-protocol-id.m create mode 100644 clang/test/Rewriter/rewrite-forward-class.m create mode 100644 clang/test/Rewriter/rewrite-forward-class.mm create mode 100644 clang/test/Rewriter/rewrite-function-decl.mm create mode 100644 clang/test/Rewriter/rewrite-implementation.mm create mode 100644 clang/test/Rewriter/rewrite-ivar-use.m create mode 100644 clang/test/Rewriter/rewrite-local-externs-in-block.mm create mode 100644 clang/test/Rewriter/rewrite-local-static-id.mm create mode 100644 clang/test/Rewriter/rewrite-message-expr.mm create mode 100644 clang/test/Rewriter/rewrite-modern-array-literal.mm create mode 100644 clang/test/Rewriter/rewrite-modern-block-ivar-call.mm create mode 100644 clang/test/Rewriter/rewrite-modern-block.mm create mode 100644 clang/test/Rewriter/rewrite-modern-catch.m create mode 100644 clang/test/Rewriter/rewrite-modern-class.mm create mode 100644 clang/test/Rewriter/rewrite-modern-container-literal.mm create mode 100644 clang/test/Rewriter/rewrite-modern-extern-c-func-decl.mm create mode 100644 clang/test/Rewriter/rewrite-modern-ivar-use.mm create mode 100644 clang/test/Rewriter/rewrite-modern-ivars-1.mm create mode 100644 clang/test/Rewriter/rewrite-modern-ivars-2.mm create mode 100644 clang/test/Rewriter/rewrite-modern-ivars.mm create mode 100644 clang/test/Rewriter/rewrite-modern-nested-ivar.mm create mode 100644 clang/test/Rewriter/rewrite-modern-protocol-1.mm create mode 100644 clang/test/Rewriter/rewrite-modern-protocol.mm create mode 100644 clang/test/Rewriter/rewrite-modern-struct-ivar.mm create mode 100644 clang/test/Rewriter/rewrite-modern-super.mm create mode 100644 clang/test/Rewriter/rewrite-modern-synchronized.m create mode 100644 clang/test/Rewriter/rewrite-modern-throw.m create mode 100644 clang/test/Rewriter/rewrite-modern-try-catch-finally.m create mode 100644 clang/test/Rewriter/rewrite-modern-try-finally.m create mode 100644 clang/test/Rewriter/rewrite-modern-typeof.mm create mode 100644 clang/test/Rewriter/rewrite-nest.m create mode 100644 clang/test/Rewriter/rewrite-nested-blocks-1.mm create mode 100644 clang/test/Rewriter/rewrite-nested-blocks-2.mm create mode 100644 clang/test/Rewriter/rewrite-nested-blocks.mm create mode 100644 clang/test/Rewriter/rewrite-nested-ivar.mm create mode 100755 clang/test/Rewriter/rewrite-nested-property-in-blocks.mm create mode 100644 clang/test/Rewriter/rewrite-no-nextline.mm create mode 100644 clang/test/Rewriter/rewrite-property-attributes.mm create mode 100644 clang/test/Rewriter/rewrite-property-set-cfstring.mm create mode 100644 clang/test/Rewriter/rewrite-protocol-property.mm create mode 100644 clang/test/Rewriter/rewrite-protocol-qualified.mm create mode 100644 clang/test/Rewriter/rewrite-protocol-type-1.m create mode 100644 clang/test/Rewriter/rewrite-qualified-id.mm create mode 100644 clang/test/Rewriter/rewrite-rewritten-initializer.mm create mode 100644 clang/test/Rewriter/rewrite-static-block.mm create mode 100644 clang/test/Rewriter/rewrite-super-message.mm create mode 100644 clang/test/Rewriter/rewrite-trivial-constructor.mm create mode 100644 clang/test/Rewriter/rewrite-try-catch.m create mode 100644 clang/test/Rewriter/rewrite-typeof.mm create mode 100644 clang/test/Rewriter/rewrite-unique-block-api.mm create mode 100644 clang/test/Rewriter/rewrite-user-defined-accessors.mm create mode 100644 clang/test/Rewriter/rewrite-vararg.m create mode 100644 clang/test/Rewriter/rewrite-weak-attr.m create mode 100644 clang/test/Rewriter/static-type-protocol-1.m create mode 100644 clang/test/Rewriter/undecl-objc-h.m create mode 100644 clang/test/Rewriter/undeclared-method-1.m create mode 100644 clang/test/Rewriter/undef-field-reference-1.m create mode 100644 clang/test/Rewriter/unnamed-bf-modern-write.mm create mode 100644 clang/test/Rewriter/va-method.m create mode 100644 clang/test/Rewriter/weak_byref_objects.m create mode 100644 clang/test/Sema/128bitint.c create mode 100644 clang/test/Sema/2007-10-01-BuildArrayRef.c create mode 100644 clang/test/Sema/2009-03-09-WeakDeclarations-1.c create mode 100644 clang/test/Sema/2009-04-22-UnknownSize.c create mode 100644 clang/test/Sema/2009-07-17-VoidParameter.c create mode 100644 clang/test/Sema/2010-05-31-palignr.c create mode 100644 clang/test/Sema/Inputs/conversion.h create mode 100644 clang/test/Sema/Inputs/pragma-arc-cf-code-audited.h create mode 100644 clang/test/Sema/Inputs/unused-expr-system-header.h create mode 100644 clang/test/Sema/MicrosoftCompatibility.c create mode 100644 clang/test/Sema/MicrosoftExtensions.c create mode 100644 clang/test/Sema/PR2727.c create mode 100644 clang/test/Sema/PR2728.c create mode 100644 clang/test/Sema/PR2919-builtin-types-compat-strips-crv.c create mode 100644 clang/test/Sema/PR2923.c create mode 100644 clang/test/Sema/PR2963-enum-constant.c create mode 100644 clang/test/Sema/__try.c create mode 100644 clang/test/Sema/address-constant.c create mode 100644 clang/test/Sema/address_spaces.c create mode 100644 clang/test/Sema/align-arm-apcs.c create mode 100644 clang/test/Sema/align-x86-64.c create mode 100644 clang/test/Sema/align-x86.c create mode 100644 clang/test/Sema/alignas.c create mode 100644 clang/test/Sema/altivec-init.c create mode 100644 clang/test/Sema/annotate.c create mode 100644 clang/test/Sema/anonymous-struct-union-c11.c create mode 100644 clang/test/Sema/anonymous-struct-union.c create mode 100644 clang/test/Sema/arg-duplicate.c create mode 100644 clang/test/Sema/arg-scope-c99.c create mode 100644 clang/test/Sema/arg-scope.c create mode 100644 clang/test/Sema/arm-layout.c create mode 100644 clang/test/Sema/arm-neon-types.c create mode 100644 clang/test/Sema/array-bounds-ptr-arith.c create mode 100644 clang/test/Sema/array-constraint.c create mode 100644 clang/test/Sema/array-declared-as-incorrect-type.c create mode 100644 clang/test/Sema/array-init.c create mode 100644 clang/test/Sema/array-size-64.c create mode 100644 clang/test/Sema/array-size.c create mode 100644 clang/test/Sema/asm.c create mode 100644 clang/test/Sema/assign-null.c create mode 100644 clang/test/Sema/assign.c create mode 100644 clang/test/Sema/ast-print.c create mode 100644 clang/test/Sema/atomic-ops.c create mode 100644 clang/test/Sema/atomic-type.c create mode 100644 clang/test/Sema/attr-alias.c create mode 100644 clang/test/Sema/attr-aligned.c create mode 100644 clang/test/Sema/attr-args.c create mode 100644 clang/test/Sema/attr-availability-ios.c create mode 100644 clang/test/Sema/attr-availability-macosx.c create mode 100644 clang/test/Sema/attr-availability.c create mode 100644 clang/test/Sema/attr-cleanup.c create mode 100644 clang/test/Sema/attr-decl-after-definition.c create mode 100644 clang/test/Sema/attr-declspec-ignored.c create mode 100644 clang/test/Sema/attr-deprecated-message.c create mode 100644 clang/test/Sema/attr-deprecated.c create mode 100644 clang/test/Sema/attr-format.c create mode 100644 clang/test/Sema/attr-format_arg.c create mode 100644 clang/test/Sema/attr-malloc.c create mode 100644 clang/test/Sema/attr-mode.c create mode 100644 clang/test/Sema/attr-naked.c create mode 100644 clang/test/Sema/attr-nodebug.c create mode 100644 clang/test/Sema/attr-noinline.c create mode 100644 clang/test/Sema/attr-noreturn.c create mode 100644 clang/test/Sema/attr-regparm.c create mode 100644 clang/test/Sema/attr-returns-twice.c create mode 100644 clang/test/Sema/attr-section.c create mode 100644 clang/test/Sema/attr-sentinel.c create mode 100644 clang/test/Sema/attr-unavailable-message.c create mode 100644 clang/test/Sema/attr-unknown.c create mode 100644 clang/test/Sema/attr-unused.c create mode 100644 clang/test/Sema/attr-used.c create mode 100644 clang/test/Sema/attr-visibility.c create mode 100644 clang/test/Sema/attr-weak.c create mode 100644 clang/test/Sema/bitfield-layout.c create mode 100644 clang/test/Sema/bitfield-promote.c create mode 100644 clang/test/Sema/bitfield.c create mode 100644 clang/test/Sema/block-args.c create mode 100644 clang/test/Sema/block-call.c create mode 100644 clang/test/Sema/block-explicit-noreturn-type.c create mode 100644 clang/test/Sema/block-labels.c create mode 100644 clang/test/Sema/block-literal.c create mode 100644 clang/test/Sema/block-misc.c create mode 100644 clang/test/Sema/block-printf-attribute-1.c create mode 100644 clang/test/Sema/block-return-1.c create mode 100644 clang/test/Sema/block-return-2.c create mode 100644 clang/test/Sema/block-return-3.c create mode 100644 clang/test/Sema/block-return.c create mode 100644 clang/test/Sema/block-sentinel-attribute.c create mode 100644 clang/test/Sema/block-storageclass.c create mode 100644 clang/test/Sema/builtin-object-size.c create mode 100644 clang/test/Sema/builtin-prefetch.c create mode 100644 clang/test/Sema/builtin-stackaddress.c create mode 100644 clang/test/Sema/builtin-unary-fp.c create mode 100644 clang/test/Sema/builtin_objc_msgSend.c create mode 100644 clang/test/Sema/builtins-arm.c create mode 100644 clang/test/Sema/builtins-decl.c create mode 100644 clang/test/Sema/builtins.c create mode 100644 clang/test/Sema/c11-typedef-redef.c create mode 100644 clang/test/Sema/c89-2.c create mode 100644 clang/test/Sema/c89.c create mode 100644 clang/test/Sema/callingconv.c create mode 100644 clang/test/Sema/carbon.c create mode 100644 clang/test/Sema/cast-incomplete.c create mode 100644 clang/test/Sema/cast-to-union.c create mode 100644 clang/test/Sema/cast.c create mode 100644 clang/test/Sema/check-increment.c create mode 100644 clang/test/Sema/compare.c create mode 100644 clang/test/Sema/complex-imag.c create mode 100644 clang/test/Sema/complex-init-list.c create mode 100644 clang/test/Sema/complex-int.c create mode 100644 clang/test/Sema/complex-promotion.c create mode 100644 clang/test/Sema/compound-literal.c create mode 100644 clang/test/Sema/conditional-expr.c create mode 100644 clang/test/Sema/conditional.c create mode 100644 clang/test/Sema/const-eval-64.c create mode 100644 clang/test/Sema/const-eval.c create mode 100644 clang/test/Sema/const-ptr-int-ptr-cast.c create mode 100644 clang/test/Sema/constant-builtins-2.c create mode 100644 clang/test/Sema/constant-builtins.c create mode 100644 clang/test/Sema/constant-conversion.c create mode 100644 clang/test/Sema/constructor-attribute.c create mode 100644 clang/test/Sema/conversion-64-32.c create mode 100644 clang/test/Sema/conversion.c create mode 100644 clang/test/Sema/crash-invalid-array.c create mode 100644 clang/test/Sema/darwin-align-cast.c create mode 100644 clang/test/Sema/decl-in-prototype.c create mode 100644 clang/test/Sema/decl-invalid.c create mode 100644 clang/test/Sema/decl-type-merging.c create mode 100644 clang/test/Sema/declspec.c create mode 100644 clang/test/Sema/default.c create mode 100644 clang/test/Sema/default1.c create mode 100644 clang/test/Sema/deref.c create mode 100644 clang/test/Sema/designated-initializers.c create mode 100644 clang/test/Sema/dllimport-dllexport.c create mode 100644 clang/test/Sema/enum-packed.c create mode 100644 clang/test/Sema/enum.c create mode 100644 clang/test/Sema/expr-address-of.c create mode 100644 clang/test/Sema/expr-comma-c99.c create mode 100644 clang/test/Sema/expr-comma.c create mode 100644 clang/test/Sema/exprs.c create mode 100644 clang/test/Sema/ext_vector_casts.c create mode 100644 clang/test/Sema/ext_vector_comparisons.c create mode 100644 clang/test/Sema/ext_vector_components.c create mode 100644 clang/test/Sema/extern-redecl.c create mode 100644 clang/test/Sema/flexible-array-init.c create mode 100644 clang/test/Sema/floating-point-compare.c create mode 100644 clang/test/Sema/fn-ptr-as-fn-prototype.c create mode 100644 clang/test/Sema/for.c create mode 100644 clang/test/Sema/format-string-percentm.c create mode 100644 clang/test/Sema/format-strings-c90.c create mode 100644 clang/test/Sema/format-strings-fixit-ssize_t.c create mode 100644 clang/test/Sema/format-strings-fixit.c create mode 100644 clang/test/Sema/format-strings-int-typedefs.c create mode 100644 clang/test/Sema/format-strings-no-fixit.c create mode 100644 clang/test/Sema/format-strings-non-iso.c create mode 100644 clang/test/Sema/format-strings-scanf.c create mode 100644 clang/test/Sema/format-strings-size_t.c create mode 100644 clang/test/Sema/format-strings.c create mode 100644 clang/test/Sema/fp16-sema.c create mode 100644 clang/test/Sema/fpack-struct.c create mode 100644 clang/test/Sema/freemain.c create mode 100644 clang/test/Sema/function-ptr.c create mode 100644 clang/test/Sema/function-redecl.c create mode 100644 clang/test/Sema/function.c create mode 100644 clang/test/Sema/generic-selection.c create mode 100644 clang/test/Sema/gnu89.c create mode 100644 clang/test/Sema/heinous-extensions-off.c create mode 100644 clang/test/Sema/heinous-extensions-on.c create mode 100644 clang/test/Sema/i-c-e.c create mode 100644 clang/test/Sema/illegal-types.c create mode 100644 clang/test/Sema/implicit-builtin-decl.c create mode 100644 clang/test/Sema/implicit-builtin-freestanding.c create mode 100644 clang/test/Sema/implicit-builtin-redecl.c create mode 100644 clang/test/Sema/implicit-cast.c create mode 100644 clang/test/Sema/implicit-decl.c create mode 100644 clang/test/Sema/implicit-def.c create mode 100644 clang/test/Sema/implicit-int.c create mode 100644 clang/test/Sema/incompatible-sign.c create mode 100644 clang/test/Sema/incomplete-call.c create mode 100644 clang/test/Sema/incomplete-decl.c create mode 100644 clang/test/Sema/indirect-goto.c create mode 100644 clang/test/Sema/init-struct-qualified.c create mode 100644 clang/test/Sema/init-vector.c create mode 100644 clang/test/Sema/init.c create mode 100644 clang/test/Sema/initialize-noreturn.c create mode 100644 clang/test/Sema/inline-redef.c create mode 100644 clang/test/Sema/inline.c create mode 100644 clang/test/Sema/int-arith-convert.c create mode 100644 clang/test/Sema/invalid-decl.c create mode 100644 clang/test/Sema/invalid-init-diag.c create mode 100644 clang/test/Sema/invalid-struct-init.c create mode 100644 clang/test/Sema/knr-def-call.c create mode 100644 clang/test/Sema/knr-variadic-def.c create mode 100644 clang/test/Sema/many-logical-ops.c create mode 100644 clang/test/Sema/many-parameters.c create mode 100644 clang/test/Sema/member-reference.c create mode 100644 clang/test/Sema/memset-invalid.c create mode 100644 clang/test/Sema/merge-decls.c create mode 100644 clang/test/Sema/missing-field-initializers.c create mode 100644 clang/test/Sema/ms_class_layout.cpp create mode 100644 clang/test/Sema/neon-vector-types.c create mode 100644 clang/test/Sema/nested-redef.c create mode 100644 clang/test/Sema/no-format-y2k-turnsoff-format.c create mode 100644 clang/test/Sema/nonnull.c create mode 100644 clang/test/Sema/offsetof.c create mode 100644 clang/test/Sema/overloadable-complex.c create mode 100644 clang/test/Sema/overloadable.c create mode 100644 clang/test/Sema/overloaded-func-transparent-union.c create mode 100644 clang/test/Sema/parentheses.c create mode 100644 clang/test/Sema/parentheses.cpp create mode 100644 clang/test/Sema/pointer-addition.c create mode 100644 clang/test/Sema/pointer-conversion.c create mode 100644 clang/test/Sema/pointer-subtract-compat.c create mode 100644 clang/test/Sema/pragma-align-mac68k-unsupported.c create mode 100644 clang/test/Sema/pragma-align-mac68k.c create mode 100644 clang/test/Sema/pragma-align-packed.c create mode 100644 clang/test/Sema/pragma-arc-cf-code-audited.c create mode 100644 clang/test/Sema/pragma-ms_struct.c create mode 100644 clang/test/Sema/pragma-pack-2.c create mode 100644 clang/test/Sema/pragma-pack-3.c create mode 100644 clang/test/Sema/pragma-pack-4.c create mode 100644 clang/test/Sema/pragma-pack-5.c create mode 100644 clang/test/Sema/pragma-pack-and-options-align.c create mode 100644 clang/test/Sema/pragma-pack-apple.c create mode 100644 clang/test/Sema/pragma-pack.c create mode 100644 clang/test/Sema/pragma-unused.c create mode 100644 clang/test/Sema/predef.c create mode 100644 clang/test/Sema/predefined-function.c create mode 100644 clang/test/Sema/private-extern.c create mode 100644 clang/test/Sema/rdr6094103-unordered-compare-promote.c create mode 100644 clang/test/Sema/recover-goto.c create mode 100644 clang/test/Sema/redefinition.c create mode 100644 clang/test/Sema/return-noreturn.c create mode 100644 clang/test/Sema/return-silent.c create mode 100644 clang/test/Sema/return.c create mode 100644 clang/test/Sema/scope-check.c create mode 100644 clang/test/Sema/self-comparison.c create mode 100644 clang/test/Sema/sentinel-attribute.c create mode 100644 clang/test/Sema/shift.c create mode 100644 clang/test/Sema/short-enums.c create mode 100644 clang/test/Sema/sign-conversion.c create mode 100644 clang/test/Sema/statements.c create mode 100644 clang/test/Sema/static-array.c create mode 100644 clang/test/Sema/static-assert.c create mode 100644 clang/test/Sema/static-init.c create mode 100644 clang/test/Sema/stdcall-fastcall.c create mode 100644 clang/test/Sema/struct-cast.c create mode 100644 clang/test/Sema/struct-compat.c create mode 100644 clang/test/Sema/struct-decl.c create mode 100644 clang/test/Sema/struct-packed-align.c create mode 100644 clang/test/Sema/surpress-deprecated.c create mode 100644 clang/test/Sema/switch.c create mode 100644 clang/test/Sema/tentative-decls.c create mode 100644 clang/test/Sema/text-diag.c create mode 100644 clang/test/Sema/thread-specifier.c create mode 100644 clang/test/Sema/transparent-union-pointer.c create mode 100644 clang/test/Sema/transparent-union.c create mode 100644 clang/test/Sema/type-spec-struct-union.c create mode 100644 clang/test/Sema/typecheck-binop.c create mode 100644 clang/test/Sema/typedef-prototype.c create mode 100644 clang/test/Sema/typedef-redef.c create mode 100644 clang/test/Sema/typedef-retain.c create mode 100644 clang/test/Sema/typedef-variable-type.c create mode 100644 clang/test/Sema/typeof-use-deprecated.c create mode 100644 clang/test/Sema/types.c create mode 100644 clang/test/Sema/ucn-cstring.c create mode 100644 clang/test/Sema/uninit-variables-vectors.c create mode 100644 clang/test/Sema/uninit-variables.c create mode 100644 clang/test/Sema/unnamed-bitfield-init.c create mode 100644 clang/test/Sema/unused-expr-system-header.c create mode 100644 clang/test/Sema/unused-expr.c create mode 100644 clang/test/Sema/usual-float.c create mode 100644 clang/test/Sema/va_arg_x86_32.c create mode 100644 clang/test/Sema/va_arg_x86_64.c create mode 100644 clang/test/Sema/var-redecl.c create mode 100644 clang/test/Sema/varargs-x86-64.c create mode 100644 clang/test/Sema/varargs.c create mode 100644 clang/test/Sema/variadic-block.c create mode 100644 clang/test/Sema/variadic-incomplete-arg-type.c create mode 100644 clang/test/Sema/vector-assign.c create mode 100644 clang/test/Sema/vector-cast.c create mode 100644 clang/test/Sema/vector-init.c create mode 100644 clang/test/Sema/vector-ops.c create mode 100644 clang/test/Sema/vfprintf-invalid-redecl.c create mode 100644 clang/test/Sema/vfprintf-valid-redecl.c create mode 100644 clang/test/Sema/vla-2.c create mode 100644 clang/test/Sema/vla.c create mode 100644 clang/test/Sema/void_arg.c create mode 100644 clang/test/Sema/warn-cast-align.c create mode 100644 clang/test/Sema/warn-char-subscripts.c create mode 100644 clang/test/Sema/warn-freestanding-complex.c create mode 100644 clang/test/Sema/warn-gnu-designators.c create mode 100644 clang/test/Sema/warn-missing-braces.c create mode 100644 clang/test/Sema/warn-missing-prototypes.c create mode 100644 clang/test/Sema/warn-shadow.c create mode 100644 clang/test/Sema/warn-sizeof-arrayarg.c create mode 100644 clang/test/Sema/warn-strlcpycat-size.c create mode 100644 clang/test/Sema/warn-strncat-size.c create mode 100644 clang/test/Sema/warn-unreachable.c create mode 100644 clang/test/Sema/warn-unused-function.c create mode 100644 clang/test/Sema/warn-unused-label.c create mode 100644 clang/test/Sema/warn-unused-parameters.c create mode 100644 clang/test/Sema/warn-unused-value.c create mode 100644 clang/test/Sema/warn-unused-variables.c create mode 100644 clang/test/Sema/warn-write-strings.c create mode 100644 clang/test/Sema/wchar.c create mode 100644 clang/test/Sema/weak-import-on-enum.c create mode 100644 clang/test/Sema/x86-attr-force-align-arg-pointer.c create mode 100644 clang/test/Sema/x86-builtin-palignr.c create mode 100644 clang/test/SemaCUDA/config-type.cu create mode 100644 clang/test/SemaCUDA/cuda.h create mode 100644 clang/test/SemaCUDA/function-target.cu create mode 100644 clang/test/SemaCUDA/kernel-call.cu create mode 100644 clang/test/SemaCUDA/qualifiers.cu create mode 100644 clang/test/SemaCXX/2008-01-11-BadWarning.cpp create mode 100644 clang/test/SemaCXX/Inputs/array-bounds-system-header.h create mode 100644 clang/test/SemaCXX/Inputs/lit.local.cfg create mode 100644 clang/test/SemaCXX/Inputs/malloc.h create mode 100644 clang/test/SemaCXX/Inputs/warn-new-overaligned-3.h create mode 100644 clang/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp create mode 100644 clang/test/SemaCXX/MicrosoftCompatibility.cpp create mode 100644 clang/test/SemaCXX/MicrosoftExtensions.cpp create mode 100644 clang/test/SemaCXX/PR10177.cpp create mode 100644 clang/test/SemaCXX/PR10243.cpp create mode 100644 clang/test/SemaCXX/PR10447.cpp create mode 100644 clang/test/SemaCXX/PR10458.cpp create mode 100644 clang/test/SemaCXX/PR11358.cpp create mode 100644 clang/test/SemaCXX/PR12481.cpp create mode 100644 clang/test/SemaCXX/PR5086-ambig-resolution-enum.cpp create mode 100644 clang/test/SemaCXX/PR6562.cpp create mode 100644 clang/test/SemaCXX/PR6618.cpp create mode 100644 clang/test/SemaCXX/PR7410.cpp create mode 100644 clang/test/SemaCXX/PR7944.cpp create mode 100644 clang/test/SemaCXX/PR8012.cpp create mode 100644 clang/test/SemaCXX/PR8385.cpp create mode 100644 clang/test/SemaCXX/PR8755.cpp create mode 100644 clang/test/SemaCXX/PR8884.cpp create mode 100644 clang/test/SemaCXX/PR9459.cpp create mode 100644 clang/test/SemaCXX/PR9460.cpp create mode 100644 clang/test/SemaCXX/PR9461.cpp create mode 100644 clang/test/SemaCXX/PR9572.cpp create mode 100644 clang/test/SemaCXX/PR9884.cpp create mode 100644 clang/test/SemaCXX/PR9902.cpp create mode 100644 clang/test/SemaCXX/PR9908.cpp create mode 100644 clang/test/SemaCXX/__null.cpp create mode 100644 clang/test/SemaCXX/__try.cpp create mode 100644 clang/test/SemaCXX/abstract.cpp create mode 100644 clang/test/SemaCXX/access-base-class.cpp create mode 100644 clang/test/SemaCXX/access-control-check.cpp create mode 100644 clang/test/SemaCXX/access-member-pointer.cpp create mode 100644 clang/test/SemaCXX/access.cpp create mode 100644 clang/test/SemaCXX/addr-of-overloaded-function-casting.cpp create mode 100644 clang/test/SemaCXX/addr-of-overloaded-function.cpp create mode 100644 clang/test/SemaCXX/address-of-temporary.cpp create mode 100644 clang/test/SemaCXX/address-of.cpp create mode 100644 clang/test/SemaCXX/address-space-conversion.cpp create mode 100644 clang/test/SemaCXX/address-space-newdelete.cpp create mode 100644 clang/test/SemaCXX/address-space-references.cpp create mode 100644 clang/test/SemaCXX/aggregate-initialization.cpp create mode 100644 clang/test/SemaCXX/alias-template.cpp create mode 100644 clang/test/SemaCXX/alignof-sizeof-reference.cpp create mode 100644 clang/test/SemaCXX/altivec.cpp create mode 100644 clang/test/SemaCXX/ambig-user-defined-conversions.cpp create mode 100644 clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp create mode 100644 clang/test/SemaCXX/anonymous-struct.cpp create mode 100644 clang/test/SemaCXX/anonymous-union.cpp create mode 100644 clang/test/SemaCXX/array-bound-merge.cpp create mode 100644 clang/test/SemaCXX/array-bounds-ptr-arith.cpp create mode 100644 clang/test/SemaCXX/array-bounds-system-header.cpp create mode 100644 clang/test/SemaCXX/array-bounds.cpp create mode 100644 clang/test/SemaCXX/arrow-operator.cpp create mode 100644 clang/test/SemaCXX/atomic-type.cxx create mode 100644 clang/test/SemaCXX/attr-after-definition.cpp create mode 100644 clang/test/SemaCXX/attr-cxx0x.cpp create mode 100644 clang/test/SemaCXX/attr-declspec-ignored.cpp create mode 100644 clang/test/SemaCXX/attr-deprecated.cpp create mode 100644 clang/test/SemaCXX/attr-format.cpp create mode 100644 clang/test/SemaCXX/attr-nonnull.cpp create mode 100644 clang/test/SemaCXX/attr-noreturn.cpp create mode 100644 clang/test/SemaCXX/attr-regparm.cpp create mode 100644 clang/test/SemaCXX/attr-sentinel.cpp create mode 100644 clang/test/SemaCXX/attr-unavailable.cpp create mode 100644 clang/test/SemaCXX/attr-weak.cpp create mode 100644 clang/test/SemaCXX/attr-weakref.cpp create mode 100644 clang/test/SemaCXX/auto-cxx0x.cpp create mode 100644 clang/test/SemaCXX/auto-cxx98.cpp create mode 100644 clang/test/SemaCXX/auto-subst-failure.cpp create mode 100644 clang/test/SemaCXX/bitfield-layout.cpp create mode 100644 clang/test/SemaCXX/block-call.cpp create mode 100644 clang/test/SemaCXX/blocks-1.cpp create mode 100644 clang/test/SemaCXX/blocks.cpp create mode 100644 clang/test/SemaCXX/bool.cpp create mode 100644 clang/test/SemaCXX/borland-extensions.cpp create mode 100644 clang/test/SemaCXX/builtin-exception-spec.cpp create mode 100644 clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp create mode 100644 clang/test/SemaCXX/builtin-ptrtomember-overload-1.cpp create mode 100644 clang/test/SemaCXX/builtin-ptrtomember-overload.cpp create mode 100644 clang/test/SemaCXX/builtin_objc_msgSend.cpp create mode 100644 clang/test/SemaCXX/builtins.cpp create mode 100644 clang/test/SemaCXX/c99-variable-length-array.cpp create mode 100644 clang/test/SemaCXX/c99.cpp create mode 100644 clang/test/SemaCXX/cast-conversion.cpp create mode 100644 clang/test/SemaCXX/cast-explicit-ctor.cpp create mode 100644 clang/test/SemaCXX/class-base-member-init.cpp create mode 100644 clang/test/SemaCXX/class-layout.cpp create mode 100644 clang/test/SemaCXX/class-names.cpp create mode 100644 clang/test/SemaCXX/class.cpp create mode 100644 clang/test/SemaCXX/comma.cpp create mode 100644 clang/test/SemaCXX/compare.cpp create mode 100644 clang/test/SemaCXX/complex-init-list.cpp create mode 100644 clang/test/SemaCXX/complex-overload.cpp create mode 100644 clang/test/SemaCXX/composite-pointer-type.cpp create mode 100644 clang/test/SemaCXX/compound-literal.cpp create mode 100644 clang/test/SemaCXX/condition.cpp create mode 100644 clang/test/SemaCXX/conditional-expr.cpp create mode 100644 clang/test/SemaCXX/const-cast.cpp create mode 100644 clang/test/SemaCXX/constant-expression-cxx11.cpp create mode 100644 clang/test/SemaCXX/constant-expression.cpp create mode 100644 clang/test/SemaCXX/constexpr-ackermann.cpp create mode 100644 clang/test/SemaCXX/constexpr-backtrace-limit.cpp create mode 100644 clang/test/SemaCXX/constexpr-depth.cpp create mode 100644 clang/test/SemaCXX/constexpr-factorial.cpp create mode 100644 clang/test/SemaCXX/constexpr-nqueens.cpp create mode 100644 clang/test/SemaCXX/constexpr-printing.cpp create mode 100644 clang/test/SemaCXX/constexpr-strlen.cpp create mode 100644 clang/test/SemaCXX/constexpr-turing.cpp create mode 100644 clang/test/SemaCXX/constexpr-value-init.cpp create mode 100644 clang/test/SemaCXX/constructor-initializer.cpp create mode 100644 clang/test/SemaCXX/constructor-recovery.cpp create mode 100644 clang/test/SemaCXX/constructor.cpp create mode 100644 clang/test/SemaCXX/conversion-delete-expr.cpp create mode 100644 clang/test/SemaCXX/conversion-function.cpp create mode 100644 clang/test/SemaCXX/conversion.cpp create mode 100644 clang/test/SemaCXX/convert-to-bool.cpp create mode 100644 clang/test/SemaCXX/converting-constructor.cpp create mode 100644 clang/test/SemaCXX/copy-assignment.cpp create mode 100644 clang/test/SemaCXX/copy-constructor-error.cpp create mode 100644 clang/test/SemaCXX/copy-initialization.cpp create mode 100644 clang/test/SemaCXX/crashes.cpp create mode 100644 clang/test/SemaCXX/cstyle-cast.cpp create mode 100644 clang/test/SemaCXX/cv-unqual-rvalues.cpp create mode 100644 clang/test/SemaCXX/cxx-member-pointer-op.cpp create mode 100644 clang/test/SemaCXX/cxx0x-class.cpp create mode 100644 clang/test/SemaCXX/cxx0x-compat.cpp create mode 100644 clang/test/SemaCXX/cxx0x-constexpr-const.cpp create mode 100644 clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp create mode 100644 clang/test/SemaCXX/cxx0x-defaulted-functions.cpp create mode 100644 clang/test/SemaCXX/cxx0x-delegating-ctors.cpp create mode 100644 clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp create mode 100644 clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp create mode 100644 clang/test/SemaCXX/cxx0x-initializer-constructor.cpp create mode 100644 clang/test/SemaCXX/cxx0x-initializer-references.cpp create mode 100644 clang/test/SemaCXX/cxx0x-initializer-scalars.cpp create mode 100644 clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp create mode 100644 clang/test/SemaCXX/cxx0x-nontrivial-union.cpp create mode 100644 clang/test/SemaCXX/cxx0x-return-init-list.cpp create mode 100644 clang/test/SemaCXX/cxx0x-type-convert-construct.cpp create mode 100644 clang/test/SemaCXX/cxx11-ast-print.cpp create mode 100644 clang/test/SemaCXX/cxx11-user-defined-literals.cpp create mode 100644 clang/test/SemaCXX/cxx98-compat-flags.cpp create mode 100644 clang/test/SemaCXX/cxx98-compat-pedantic.cpp create mode 100644 clang/test/SemaCXX/cxx98-compat.cpp create mode 100644 clang/test/SemaCXX/dcl_ambig_res.cpp create mode 100644 clang/test/SemaCXX/dcl_init_aggr.cpp create mode 100644 clang/test/SemaCXX/decl-expr-ambiguity.cpp create mode 100644 clang/test/SemaCXX/decl-init-ref.cpp create mode 100644 clang/test/SemaCXX/decltype-98.cpp create mode 100644 clang/test/SemaCXX/decltype-crash.cpp create mode 100644 clang/test/SemaCXX/decltype-overloaded-functions.cpp create mode 100644 clang/test/SemaCXX/decltype-pr4444.cpp create mode 100644 clang/test/SemaCXX/decltype-pr4448.cpp create mode 100644 clang/test/SemaCXX/decltype-this.cpp create mode 100644 clang/test/SemaCXX/decltype.cpp create mode 100644 clang/test/SemaCXX/default-arg-special-member.cpp create mode 100644 clang/test/SemaCXX/default-argument-temporaries.cpp create mode 100644 clang/test/SemaCXX/default-assignment-operator.cpp create mode 100644 clang/test/SemaCXX/default-constructor-initializers.cpp create mode 100644 clang/test/SemaCXX/default1.cpp create mode 100644 clang/test/SemaCXX/default2.cpp create mode 100644 clang/test/SemaCXX/defaulted-ctor-loop.cpp create mode 100644 clang/test/SemaCXX/defaulted-private-dtor.cpp create mode 100644 clang/test/SemaCXX/delete.cpp create mode 100644 clang/test/SemaCXX/deleted-function.cpp create mode 100644 clang/test/SemaCXX/deleted-operator.cpp create mode 100644 clang/test/SemaCXX/dependent-auto.cpp create mode 100644 clang/test/SemaCXX/dependent-noexcept-unevaluated.cpp create mode 100644 clang/test/SemaCXX/dependent-types.cpp create mode 100644 clang/test/SemaCXX/derived-to-base-ambig.cpp create mode 100644 clang/test/SemaCXX/destructor.cpp create mode 100644 clang/test/SemaCXX/direct-initializer.cpp create mode 100644 clang/test/SemaCXX/discrim-union.cpp create mode 100644 clang/test/SemaCXX/do-while-scope.cpp create mode 100644 clang/test/SemaCXX/dr1301.cpp create mode 100644 clang/test/SemaCXX/dynamic-cast.cpp create mode 100644 clang/test/SemaCXX/elaborated-type-specifier.cpp create mode 100644 clang/test/SemaCXX/empty-class-layout.cpp create mode 100644 clang/test/SemaCXX/enum-bitfield.cpp create mode 100644 clang/test/SemaCXX/enum-scoped.cpp create mode 100644 clang/test/SemaCXX/enum-unscoped-nonexistent.cpp create mode 100644 clang/test/SemaCXX/enum.cpp create mode 100644 clang/test/SemaCXX/exception-spec-no-exceptions.cpp create mode 100644 clang/test/SemaCXX/exceptions.cpp create mode 100644 clang/test/SemaCXX/explicit.cpp create mode 100644 clang/test/SemaCXX/expression-traits.cpp create mode 100644 clang/test/SemaCXX/expressions.cpp create mode 100644 clang/test/SemaCXX/flexible-array-test.cpp create mode 100644 clang/test/SemaCXX/fntype-decl.cpp create mode 100644 clang/test/SemaCXX/for-range-examples.cpp create mode 100644 clang/test/SemaCXX/for-range-no-std.cpp create mode 100644 clang/test/SemaCXX/for-range-unused.cpp create mode 100644 clang/test/SemaCXX/format-strings-0x.cpp create mode 100644 clang/test/SemaCXX/format-strings.cpp create mode 100644 clang/test/SemaCXX/friend-class-nodecl.cpp create mode 100644 clang/test/SemaCXX/friend-out-of-line.cpp create mode 100644 clang/test/SemaCXX/friend.cpp create mode 100644 clang/test/SemaCXX/function-extern-c.cpp create mode 100644 clang/test/SemaCXX/function-overload-typo-crash.cpp create mode 100644 clang/test/SemaCXX/function-overloaded-redecl.cpp create mode 100644 clang/test/SemaCXX/function-redecl.cpp create mode 100644 clang/test/SemaCXX/function-type-qual.cpp create mode 100644 clang/test/SemaCXX/functional-cast.cpp create mode 100644 clang/test/SemaCXX/generic-selection.cpp create mode 100644 clang/test/SemaCXX/gnu-case-ranges.cpp create mode 100644 clang/test/SemaCXX/goto.cpp create mode 100644 clang/test/SemaCXX/goto2.cpp create mode 100644 clang/test/SemaCXX/i-c-e-cxx.cpp create mode 100644 clang/test/SemaCXX/illegal-member-initialization.cpp create mode 100644 clang/test/SemaCXX/implicit-exception-spec.cpp create mode 100644 clang/test/SemaCXX/implicit-int.cpp create mode 100644 clang/test/SemaCXX/implicit-member-functions.cpp create mode 100644 clang/test/SemaCXX/implicit-virtual-member-functions.cpp create mode 100644 clang/test/SemaCXX/incomplete-call.cpp create mode 100644 clang/test/SemaCXX/increment-decrement.cpp create mode 100644 clang/test/SemaCXX/indirect-goto.cpp create mode 100644 clang/test/SemaCXX/inherit.cpp create mode 100644 clang/test/SemaCXX/init-priority-attr.cpp create mode 100644 clang/test/SemaCXX/inline.cpp create mode 100644 clang/test/SemaCXX/instantiate-blocks.cpp create mode 100644 clang/test/SemaCXX/invalid-instantiated-field-decl.cpp create mode 100644 clang/test/SemaCXX/invalid-member-expr.cpp create mode 100644 clang/test/SemaCXX/invalid-template-specifier.cpp create mode 100644 clang/test/SemaCXX/issue547.cpp create mode 100644 clang/test/SemaCXX/lambda-expressions.cpp create mode 100644 clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp create mode 100644 clang/test/SemaCXX/libstdcxx_map_base_hack.cpp create mode 100644 clang/test/SemaCXX/linkage-spec.cpp create mode 100644 clang/test/SemaCXX/linkage.cpp create mode 100644 clang/test/SemaCXX/literal-operators.cpp create mode 100644 clang/test/SemaCXX/literal-type.cpp create mode 100644 clang/test/SemaCXX/local-classes.cpp create mode 100644 clang/test/SemaCXX/lookup-member.cpp create mode 100644 clang/test/SemaCXX/member-class-11.cpp create mode 100644 clang/test/SemaCXX/member-expr-anonymous-union.cpp create mode 100644 clang/test/SemaCXX/member-expr-static.cpp create mode 100644 clang/test/SemaCXX/member-expr.cpp create mode 100644 clang/test/SemaCXX/member-init.cpp create mode 100644 clang/test/SemaCXX/member-location.cpp create mode 100644 clang/test/SemaCXX/member-name-lookup.cpp create mode 100644 clang/test/SemaCXX/member-operator-expr.cpp create mode 100644 clang/test/SemaCXX/member-pointer-ms.cpp create mode 100644 clang/test/SemaCXX/member-pointer-size.cpp create mode 100644 clang/test/SemaCXX/member-pointer.cpp create mode 100644 clang/test/SemaCXX/member-pointers-2.cpp create mode 100644 clang/test/SemaCXX/microsoft-cxx0x.cpp create mode 100644 clang/test/SemaCXX/missing-header.cpp create mode 100644 clang/test/SemaCXX/missing-members.cpp create mode 100644 clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp create mode 100644 clang/test/SemaCXX/ms-exception-spec.cpp create mode 100644 clang/test/SemaCXX/namespace-alias.cpp create mode 100644 clang/test/SemaCXX/namespace.cpp create mode 100644 clang/test/SemaCXX/neon-vector-types.cpp create mode 100644 clang/test/SemaCXX/nested-name-spec-locations.cpp create mode 100644 clang/test/SemaCXX/nested-name-spec.cpp create mode 100644 clang/test/SemaCXX/new-array-size-conv.cpp create mode 100644 clang/test/SemaCXX/new-delete-0x.cpp create mode 100644 clang/test/SemaCXX/new-delete-cxx0x.cpp create mode 100644 clang/test/SemaCXX/new-delete-predefined-decl-2.cpp create mode 100644 clang/test/SemaCXX/new-delete-predefined-decl.cpp create mode 100644 clang/test/SemaCXX/new-delete.cpp create mode 100644 clang/test/SemaCXX/no-exceptions.cpp create mode 100644 clang/test/SemaCXX/no-implicit-builtin-decls.cpp create mode 100644 clang/test/SemaCXX/non-empty-class-size-zero.cpp create mode 100644 clang/test/SemaCXX/null_in_arithmetic_ops.cpp create mode 100644 clang/test/SemaCXX/nullptr-98.cpp create mode 100644 clang/test/SemaCXX/nullptr.cpp create mode 100644 clang/test/SemaCXX/nullptr_in_arithmetic_ops.cpp create mode 100644 clang/test/SemaCXX/offsetof.cpp create mode 100644 clang/test/SemaCXX/operator-arrow-temporary.cpp create mode 100644 clang/test/SemaCXX/out-of-line-def-mismatch.cpp create mode 100644 clang/test/SemaCXX/overload-0x.cpp create mode 100644 clang/test/SemaCXX/overload-call-copycon.cpp create mode 100644 clang/test/SemaCXX/overload-call.cpp create mode 100644 clang/test/SemaCXX/overload-decl.cpp create mode 100644 clang/test/SemaCXX/overload-member-call.cpp create mode 100644 clang/test/SemaCXX/overload-value-dep-arg.cpp create mode 100644 clang/test/SemaCXX/overloaded-builtin-operators-0x.cpp create mode 100644 clang/test/SemaCXX/overloaded-builtin-operators.cpp create mode 100644 clang/test/SemaCXX/overloaded-name.cpp create mode 100644 clang/test/SemaCXX/overloaded-operator-decl.cpp create mode 100644 clang/test/SemaCXX/overloaded-operator.cpp create mode 100644 clang/test/SemaCXX/pascal-strings.cpp create mode 100644 clang/test/SemaCXX/pragma-pack.cpp create mode 100644 clang/test/SemaCXX/pragma-unused.cpp create mode 100644 clang/test/SemaCXX/pragma-visibility.cpp create mode 100644 clang/test/SemaCXX/prefetch-enum.cpp create mode 100644 clang/test/SemaCXX/primary-base.cpp create mode 100644 clang/test/SemaCXX/pseudo-destructors.cpp create mode 100644 clang/test/SemaCXX/ptrtomember-overload-resolution.cpp create mode 100644 clang/test/SemaCXX/ptrtomember.cpp create mode 100644 clang/test/SemaCXX/qual-id-test.cpp create mode 100644 clang/test/SemaCXX/qualification-conversion.cpp create mode 100644 clang/test/SemaCXX/qualified-id-lookup.cpp create mode 100644 clang/test/SemaCXX/qualified-member-enum.cpp create mode 100644 clang/test/SemaCXX/qualified-names-diag.cpp create mode 100644 clang/test/SemaCXX/qualified-names-print.cpp create mode 100644 clang/test/SemaCXX/redeclared-alias-template.cpp create mode 100644 clang/test/SemaCXX/redeclared-auto.cpp create mode 100644 clang/test/SemaCXX/ref-init-ambiguous.cpp create mode 100644 clang/test/SemaCXX/references.cpp create mode 100644 clang/test/SemaCXX/reinterpret-cast.cpp create mode 100644 clang/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp create mode 100644 clang/test/SemaCXX/return-noreturn.cpp create mode 100644 clang/test/SemaCXX/return-stack-addr.cpp create mode 100644 clang/test/SemaCXX/return.cpp create mode 100644 clang/test/SemaCXX/runtimediag-ppe.cpp create mode 100644 clang/test/SemaCXX/rval-references-examples.cpp create mode 100644 clang/test/SemaCXX/rval-references.cpp create mode 100644 clang/test/SemaCXX/scope-check.cpp create mode 100644 clang/test/SemaCXX/shift.cpp create mode 100644 clang/test/SemaCXX/short-enums.cpp create mode 100644 clang/test/SemaCXX/short-wchar-sign.cpp create mode 100644 clang/test/SemaCXX/sourceranges.cpp create mode 100644 clang/test/SemaCXX/statements.cpp create mode 100644 clang/test/SemaCXX/static-array-member.cpp create mode 100644 clang/test/SemaCXX/static-assert.cpp create mode 100644 clang/test/SemaCXX/static-cast-complete-type.cpp create mode 100644 clang/test/SemaCXX/static-cast.cpp create mode 100644 clang/test/SemaCXX/static-initializers.cpp create mode 100644 clang/test/SemaCXX/storage-class.cpp create mode 100644 clang/test/SemaCXX/string-plus-int.cpp create mode 100644 clang/test/SemaCXX/struct-class-redecl.cpp create mode 100644 clang/test/SemaCXX/switch-0x.cpp create mode 100644 clang/test/SemaCXX/switch.cpp create mode 100644 clang/test/SemaCXX/tag-ambig.cpp create mode 100644 clang/test/SemaCXX/templated-friend-decl.cpp create mode 100644 clang/test/SemaCXX/this.cpp create mode 100644 clang/test/SemaCXX/trailing-return-0x.cpp create mode 100644 clang/test/SemaCXX/trivial-constructor.cpp create mode 100644 clang/test/SemaCXX/trivial-destructor.cpp create mode 100644 clang/test/SemaCXX/type-convert-construct.cpp create mode 100644 clang/test/SemaCXX/type-definition-in-specifier.cpp create mode 100644 clang/test/SemaCXX/type-dependent-exprs.cpp create mode 100644 clang/test/SemaCXX/type-formatting.cpp create mode 100644 clang/test/SemaCXX/type-traits-incomplete.cpp create mode 100644 clang/test/SemaCXX/type-traits.cpp create mode 100644 clang/test/SemaCXX/typedef-redecl.cpp create mode 100644 clang/test/SemaCXX/typeid-ref.cpp create mode 100644 clang/test/SemaCXX/typeid.cpp create mode 100644 clang/test/SemaCXX/types_compatible_p.cpp create mode 100644 clang/test/SemaCXX/typo-correction.cpp create mode 100644 clang/test/SemaCXX/unary-real-imag.cpp create mode 100644 clang/test/SemaCXX/undefined-internal.cpp create mode 100644 clang/test/SemaCXX/underlying_type.cpp create mode 100644 clang/test/SemaCXX/uninit-variables-conditional.cpp create mode 100644 clang/test/SemaCXX/uninit-variables.cpp create mode 100644 clang/test/SemaCXX/uninitialized.cpp create mode 100644 clang/test/SemaCXX/unknown-anytype-blocks.cpp create mode 100644 clang/test/SemaCXX/unknown-anytype.cpp create mode 100644 clang/test/SemaCXX/unknown-type-name.cpp create mode 100644 clang/test/SemaCXX/unreachable-catch-clauses.cpp create mode 100644 clang/test/SemaCXX/unreachable-code.cpp create mode 100644 clang/test/SemaCXX/unused-functions.cpp create mode 100644 clang/test/SemaCXX/unused-with-error.cpp create mode 100644 clang/test/SemaCXX/unused.cpp create mode 100644 clang/test/SemaCXX/user-defined-conversions.cpp create mode 100644 clang/test/SemaCXX/using-decl-1.cpp create mode 100644 clang/test/SemaCXX/using-decl-pr4441.cpp create mode 100644 clang/test/SemaCXX/using-decl-pr4450.cpp create mode 100644 clang/test/SemaCXX/using-decl-templates.cpp create mode 100644 clang/test/SemaCXX/using-directive.cpp create mode 100644 clang/test/SemaCXX/value-dependent-exprs.cpp create mode 100644 clang/test/SemaCXX/value-initialization.cpp create mode 100644 clang/test/SemaCXX/vararg-default-arg.cpp create mode 100644 clang/test/SemaCXX/vararg-non-pod.cpp create mode 100644 clang/test/SemaCXX/vector-casts.cpp create mode 100644 clang/test/SemaCXX/vector-no-lax.cpp create mode 100644 clang/test/SemaCXX/vector.cpp create mode 100644 clang/test/SemaCXX/virtual-base-used.cpp create mode 100644 clang/test/SemaCXX/virtual-member-functions-key-function.cpp create mode 100644 clang/test/SemaCXX/virtual-override.cpp create mode 100644 clang/test/SemaCXX/virtuals.cpp create mode 100644 clang/test/SemaCXX/vla.cpp create mode 100644 clang/test/SemaCXX/vtable-instantiation.cc create mode 100644 clang/test/SemaCXX/warn-assignment-condition.cpp create mode 100644 clang/test/SemaCXX/warn-bad-memaccess.cpp create mode 100644 clang/test/SemaCXX/warn-bool-conversion.cpp create mode 100644 clang/test/SemaCXX/warn-cast-align.cpp create mode 100644 clang/test/SemaCXX/warn-char-subscripts.cpp create mode 100644 clang/test/SemaCXX/warn-dangling-field.cpp create mode 100644 clang/test/SemaCXX/warn-deprecated-header.cpp create mode 100644 clang/test/SemaCXX/warn-empty-body.cpp create mode 100644 clang/test/SemaCXX/warn-enum-compare.cpp create mode 100644 clang/test/SemaCXX/warn-everthing.cpp create mode 100644 clang/test/SemaCXX/warn-exit-time-destructors.cpp create mode 100644 clang/test/SemaCXX/warn-func-as-bool.cpp create mode 100644 clang/test/SemaCXX/warn-global-constructors.cpp create mode 100644 clang/test/SemaCXX/warn-large-by-value-copy.cpp create mode 100644 clang/test/SemaCXX/warn-literal-conversion.cpp create mode 100644 clang/test/SemaCXX/warn-memset-bad-sizeof.cpp create mode 100644 clang/test/SemaCXX/warn-missing-noreturn.cpp create mode 100644 clang/test/SemaCXX/warn-missing-prototypes.cpp create mode 100644 clang/test/SemaCXX/warn-new-overaligned-2.cpp create mode 100644 clang/test/SemaCXX/warn-new-overaligned-3.cpp create mode 100644 clang/test/SemaCXX/warn-new-overaligned.cpp create mode 100644 clang/test/SemaCXX/warn-overloaded-virtual.cpp create mode 100644 clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp create mode 100644 clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp create mode 100644 clang/test/SemaCXX/warn-self-assign.cpp create mode 100644 clang/test/SemaCXX/warn-self-comparisons.cpp create mode 100644 clang/test/SemaCXX/warn-shadow.cpp create mode 100644 clang/test/SemaCXX/warn-sign-conversion.cpp create mode 100644 clang/test/SemaCXX/warn-string-conversion.cpp create mode 100644 clang/test/SemaCXX/warn-thread-safety-analysis.cpp create mode 100644 clang/test/SemaCXX/warn-thread-safety-parsing.cpp create mode 100644 clang/test/SemaCXX/warn-unreachable.cpp create mode 100644 clang/test/SemaCXX/warn-unused-comparison.cpp create mode 100644 clang/test/SemaCXX/warn-unused-filescoped.cpp create mode 100644 clang/test/SemaCXX/warn-unused-parameters.cpp create mode 100644 clang/test/SemaCXX/warn-unused-result.cpp create mode 100644 clang/test/SemaCXX/warn-unused-value.cpp create mode 100644 clang/test/SemaCXX/warn-unused-variables.cpp create mode 100644 clang/test/SemaCXX/warn-using-namespace-in-header.cpp create mode 100644 clang/test/SemaCXX/warn-using-namespace-in-header.h create mode 100644 clang/test/SemaCXX/warn-weak-vtables.cpp create mode 100644 clang/test/SemaCXX/wchar_t.cpp create mode 100644 clang/test/SemaCXX/writable-strings-deprecated.cpp create mode 100644 clang/test/SemaCXX/zero-length-arrays.cpp create mode 100644 clang/test/SemaObjC/ClassPropertyNotObject.m create mode 100644 clang/test/SemaObjC/ContClassPropertyLookup.m create mode 100644 clang/test/SemaObjC/DoubleMethod.m create mode 100644 clang/test/SemaObjC/Inputs/arc-system-header.h create mode 100644 clang/test/SemaObjC/NSString-type.m create mode 100644 clang/test/SemaObjC/access-property-getter.m create mode 100644 clang/test/SemaObjC/alias-test-1.m create mode 100644 clang/test/SemaObjC/alias-test-2.m create mode 100644 clang/test/SemaObjC/arc-bridged-cast.m create mode 100644 clang/test/SemaObjC/arc-cf.m create mode 100644 clang/test/SemaObjC/arc-decls.m create mode 100644 clang/test/SemaObjC/arc-invalid.m create mode 100644 clang/test/SemaObjC/arc-jump-block.m create mode 100644 clang/test/SemaObjC/arc-no-runtime.m create mode 100644 clang/test/SemaObjC/arc-non-pod-memaccess.m create mode 100644 clang/test/SemaObjC/arc-nsconsumed-errors.m create mode 100644 clang/test/SemaObjC/arc-objc-lifetime.m create mode 100644 clang/test/SemaObjC/arc-peformselector.m create mode 100644 clang/test/SemaObjC/arc-property-decl-attrs.m create mode 100644 clang/test/SemaObjC/arc-property-lifetime.m create mode 100644 clang/test/SemaObjC/arc-property.m create mode 100644 clang/test/SemaObjC/arc-readonly-property-ivar-1.m create mode 100644 clang/test/SemaObjC/arc-readonly-property-ivar.m create mode 100644 clang/test/SemaObjC/arc-retain-block-property.m create mode 100644 clang/test/SemaObjC/arc-setter-property-match.m create mode 100644 clang/test/SemaObjC/arc-system-header.m create mode 100644 clang/test/SemaObjC/arc-type-conversion.m create mode 100644 clang/test/SemaObjC/arc-unavailable-for-weakref.m create mode 100644 clang/test/SemaObjC/arc-unavailable-system-function.m create mode 100644 clang/test/SemaObjC/arc-unbridged-cast.m create mode 100644 clang/test/SemaObjC/arc-unsafe-assigns.m create mode 100644 clang/test/SemaObjC/arc-unsafe_unretained.m create mode 100644 clang/test/SemaObjC/arc.m create mode 100644 clang/test/SemaObjC/argument-checking.m create mode 100644 clang/test/SemaObjC/assign-rvalue-message.m create mode 100644 clang/test/SemaObjC/at-defs.m create mode 100644 clang/test/SemaObjC/atomoic-property-synnthesis-rules.m create mode 100644 clang/test/SemaObjC/attr-availability.m create mode 100644 clang/test/SemaObjC/attr-cleanup.m create mode 100644 clang/test/SemaObjC/attr-deprecated.m create mode 100644 clang/test/SemaObjC/attr-malloc.m create mode 100644 clang/test/SemaObjC/attr-ns-bridged.m create mode 100644 clang/test/SemaObjC/attr-objc-exception.m create mode 100644 clang/test/SemaObjC/attr-objc-gc.m create mode 100644 clang/test/SemaObjC/attr-root-class.m create mode 100644 clang/test/SemaObjC/autoreleasepool.m create mode 100644 clang/test/SemaObjC/bad-property-synthesis-crash.m create mode 100644 clang/test/SemaObjC/bad-receiver-1.m create mode 100644 clang/test/SemaObjC/block-as-object.m create mode 100644 clang/test/SemaObjC/block-attr.m create mode 100644 clang/test/SemaObjC/block-explicit-return-type.m create mode 100644 clang/test/SemaObjC/block-id-as-block-argtype.m create mode 100644 clang/test/SemaObjC/block-ivar.m create mode 100644 clang/test/SemaObjC/block-on-method-param.m create mode 100644 clang/test/SemaObjC/block-return.m create mode 100644 clang/test/SemaObjC/block-type-safety.m create mode 100644 clang/test/SemaObjC/blocks.m create mode 100644 clang/test/SemaObjC/builtin_objc_assign_ivar.m create mode 100644 clang/test/SemaObjC/builtin_objc_lib_functions.m create mode 100644 clang/test/SemaObjC/builtin_objc_msgSend.m create mode 100644 clang/test/SemaObjC/builtin_objc_nslog.m create mode 100644 clang/test/SemaObjC/call-super-2.m create mode 100644 clang/test/SemaObjC/catch-stmt.m create mode 100644 clang/test/SemaObjC/category-1.m create mode 100644 clang/test/SemaObjC/category-method-lookup-2.m create mode 100644 clang/test/SemaObjC/category-method-lookup.m create mode 100644 clang/test/SemaObjC/check-dup-decl-methods-1.m create mode 100644 clang/test/SemaObjC/check-dup-objc-decls-1.m create mode 100644 clang/test/SemaObjC/class-bitfield.m create mode 100644 clang/test/SemaObjC/class-conforming-protocol-1.m create mode 100644 clang/test/SemaObjC/class-conforming-protocol-2.m create mode 100644 clang/test/SemaObjC/class-def-test-1.m create mode 100644 clang/test/SemaObjC/class-extension-after-implementation.m create mode 100644 clang/test/SemaObjC/class-extension-dup-methods.m create mode 100644 clang/test/SemaObjC/class-getter-using-dotsyntax.m create mode 100644 clang/test/SemaObjC/class-impl-1.m create mode 100644 clang/test/SemaObjC/class-message-protocol-lookup.m create mode 100644 clang/test/SemaObjC/class-method-lookup.m create mode 100644 clang/test/SemaObjC/class-method-self.m create mode 100644 clang/test/SemaObjC/class-property-access.m create mode 100644 clang/test/SemaObjC/class-proto-1.m create mode 100644 clang/test/SemaObjC/class-protocol-method-match.m create mode 100644 clang/test/SemaObjC/class-protocol.m create mode 100644 clang/test/SemaObjC/class-unavail-warning.m create mode 100644 clang/test/SemaObjC/cocoa-api-usage.m create mode 100644 clang/test/SemaObjC/cocoa-api-usage.m.fixed create mode 100644 clang/test/SemaObjC/cocoa.m create mode 100644 clang/test/SemaObjC/compare-qualified-class.m create mode 100644 clang/test/SemaObjC/compare-qualified-id.m create mode 100644 clang/test/SemaObjC/compatible-protocol-qualified-types.m create mode 100644 clang/test/SemaObjC/compound-init.m create mode 100644 clang/test/SemaObjC/comptypes-1.m create mode 100644 clang/test/SemaObjC/comptypes-10.m create mode 100644 clang/test/SemaObjC/comptypes-2.m create mode 100644 clang/test/SemaObjC/comptypes-3.m create mode 100644 clang/test/SemaObjC/comptypes-4.m create mode 100644 clang/test/SemaObjC/comptypes-5.m create mode 100644 clang/test/SemaObjC/comptypes-6.m create mode 100644 clang/test/SemaObjC/comptypes-7.m create mode 100644 clang/test/SemaObjC/comptypes-8.m create mode 100644 clang/test/SemaObjC/comptypes-9.m create mode 100644 clang/test/SemaObjC/comptypes-a.m create mode 100644 clang/test/SemaObjC/comptypes-legal.m create mode 100644 clang/test/SemaObjC/conditional-expr-2.m create mode 100644 clang/test/SemaObjC/conditional-expr-3.m create mode 100644 clang/test/SemaObjC/conditional-expr-4.m create mode 100644 clang/test/SemaObjC/conditional-expr-5.m create mode 100644 clang/test/SemaObjC/conditional-expr-6.m create mode 100644 clang/test/SemaObjC/conditional-expr-7.m create mode 100644 clang/test/SemaObjC/conditional-expr-8.m create mode 100644 clang/test/SemaObjC/conditional-expr.m create mode 100644 clang/test/SemaObjC/conflict-atomic-property.m create mode 100644 clang/test/SemaObjC/conflict-nonfragile-abi2.m create mode 100644 clang/test/SemaObjC/conflicting-ivar-test-1.m create mode 100644 clang/test/SemaObjC/continuation-class-err.m create mode 100644 clang/test/SemaObjC/continuation-class-property.m create mode 100644 clang/test/SemaObjC/crash-label.m create mode 100644 clang/test/SemaObjC/custom-atomic-property.m create mode 100644 clang/test/SemaObjC/debugger-cast-result-to-id.m create mode 100644 clang/test/SemaObjC/debugger-support.m create mode 100644 clang/test/SemaObjC/default-synthesize-1.m create mode 100644 clang/test/SemaObjC/default-synthesize-2.m create mode 100644 clang/test/SemaObjC/default-synthesize-3.m create mode 100644 clang/test/SemaObjC/default-synthesize.m create mode 100644 clang/test/SemaObjC/deref-interface.m create mode 100644 clang/test/SemaObjC/direct-synthesized-ivar-access.m create mode 100644 clang/test/SemaObjC/dist-object-modifiers.m create mode 100644 clang/test/SemaObjC/duplicate-ivar-check.m create mode 100644 clang/test/SemaObjC/duplicate-ivar-in-class-extension.m create mode 100644 clang/test/SemaObjC/duplicate-property-class-extension.m create mode 100644 clang/test/SemaObjC/duplicate-property.m create mode 100644 clang/test/SemaObjC/enhanced-proto-2.m create mode 100644 clang/test/SemaObjC/enum-fixed-type.m create mode 100644 clang/test/SemaObjC/err-ivar-access-in-class-method.m create mode 100644 clang/test/SemaObjC/error-implicit-property.m create mode 100644 clang/test/SemaObjC/error-missing-getter.m create mode 100644 clang/test/SemaObjC/error-property-gc-attr.m create mode 100644 clang/test/SemaObjC/exprs.m create mode 100644 clang/test/SemaObjC/foreach.m create mode 100644 clang/test/SemaObjC/format-arg-attribute.m create mode 100644 clang/test/SemaObjC/format-strings-objc.m create mode 100644 clang/test/SemaObjC/forward-class-1.m create mode 100644 clang/test/SemaObjC/forward-class-receiver.m create mode 100644 clang/test/SemaObjC/forward-class-redeclare.m create mode 100644 clang/test/SemaObjC/gc-attributes.m create mode 100644 clang/test/SemaObjC/gcc-cast-ext.m create mode 100644 clang/test/SemaObjC/ibaction.m create mode 100644 clang/test/SemaObjC/iboutletcollection-attr.m create mode 100644 clang/test/SemaObjC/id-isa-ref.m create mode 100644 clang/test/SemaObjC/id.m create mode 100644 clang/test/SemaObjC/id_builtin.m create mode 100644 clang/test/SemaObjC/idiomatic-parentheses.m create mode 100644 clang/test/SemaObjC/ignore-qualifier-on-qualified-id.m create mode 100644 clang/test/SemaObjC/ignore-weakimport-method.m create mode 100644 clang/test/SemaObjC/illegal-nonarc-bridged-cast.m create mode 100644 clang/test/SemaObjC/incompatible-protocol-qualified-types.m create mode 100644 clang/test/SemaObjC/incomplete-implementation.m create mode 100644 clang/test/SemaObjC/inst-method-lookup-in-root.m create mode 100644 clang/test/SemaObjC/instancetype.m create mode 100644 clang/test/SemaObjC/interface-1.m create mode 100644 clang/test/SemaObjC/interface-layout-2.m create mode 100644 clang/test/SemaObjC/interface-layout.m create mode 100644 clang/test/SemaObjC/interface-scope-2.m create mode 100644 clang/test/SemaObjC/interface-scope.m create mode 100644 clang/test/SemaObjC/interface-tu-variable.m create mode 100644 clang/test/SemaObjC/invalid-code.m create mode 100644 clang/test/SemaObjC/invalid-objc-decls-1.m create mode 100644 clang/test/SemaObjC/invalid-receiver.m create mode 100644 clang/test/SemaObjC/invalid-typename.m create mode 100644 clang/test/SemaObjC/ivar-access-package.m create mode 100644 clang/test/SemaObjC/ivar-access-tests.m create mode 100644 clang/test/SemaObjC/ivar-in-class-extension-error.m create mode 100644 clang/test/SemaObjC/ivar-in-class-extension.m create mode 100644 clang/test/SemaObjC/ivar-in-implementations.m create mode 100644 clang/test/SemaObjC/ivar-lookup-resolution-builtin.m create mode 100644 clang/test/SemaObjC/ivar-lookup.m create mode 100644 clang/test/SemaObjC/ivar-ref-misuse.m create mode 100644 clang/test/SemaObjC/ivar-sem-check-1.m create mode 100644 clang/test/SemaObjC/ivar-sem-check-2.m create mode 100644 clang/test/SemaObjC/legacy-implementation-1.m create mode 100644 clang/test/SemaObjC/message.m create mode 100644 clang/test/SemaObjC/method-arg-qualifier-warning.m create mode 100644 clang/test/SemaObjC/method-attributes.m create mode 100644 clang/test/SemaObjC/method-bad-param.m create mode 100644 clang/test/SemaObjC/method-conflict-1.m create mode 100644 clang/test/SemaObjC/method-conflict-2.m create mode 100644 clang/test/SemaObjC/method-conflict.m create mode 100644 clang/test/SemaObjC/method-def-1.m create mode 100644 clang/test/SemaObjC/method-def-2.m create mode 100644 clang/test/SemaObjC/method-encoding-2.m create mode 100644 clang/test/SemaObjC/method-in-class-extension-impl.m create mode 100644 clang/test/SemaObjC/method-lookup-2.m create mode 100644 clang/test/SemaObjC/method-lookup-3.m create mode 100644 clang/test/SemaObjC/method-lookup-4.m create mode 100644 clang/test/SemaObjC/method-lookup-5.m create mode 100644 clang/test/SemaObjC/method-lookup.m create mode 100644 clang/test/SemaObjC/method-no-context.m create mode 100644 clang/test/SemaObjC/method-not-defined.m create mode 100644 clang/test/SemaObjC/method-prototype-scope.m create mode 100644 clang/test/SemaObjC/method-sentinel-attr.m create mode 100644 clang/test/SemaObjC/method-typecheck-1.m create mode 100644 clang/test/SemaObjC/method-typecheck-2.m create mode 100644 clang/test/SemaObjC/method-typecheck-3.m create mode 100644 clang/test/SemaObjC/method-undef-category-warn-1.m create mode 100644 clang/test/SemaObjC/method-undef-extension-warn-1.m create mode 100644 clang/test/SemaObjC/method-undefined-warn-1.m create mode 100644 clang/test/SemaObjC/method-unused-attribute.m create mode 100644 clang/test/SemaObjC/method-warn-unused-attribute.m create mode 100644 clang/test/SemaObjC/missing-atend-metadata.m create mode 100644 clang/test/SemaObjC/missing-method-context.m create mode 100644 clang/test/SemaObjC/missing-method-return-type.m create mode 100644 clang/test/SemaObjC/narrow-property-type-in-cont-class.m create mode 100644 clang/test/SemaObjC/nested-typedef-decl.m create mode 100644 clang/test/SemaObjC/newproperty-class-method-1.m create mode 100644 clang/test/SemaObjC/no-gc-weak-test.m create mode 100644 clang/test/SemaObjC/no-ivar-access-control.m create mode 100644 clang/test/SemaObjC/no-objc-exceptions.m create mode 100644 clang/test/SemaObjC/no-protocol-option-tests.m create mode 100644 clang/test/SemaObjC/no-warn-qual-mismatch.m create mode 100644 clang/test/SemaObjC/no-warn-synth-protocol-meth.m create mode 100644 clang/test/SemaObjC/no-warn-unimpl-method.m create mode 100644 clang/test/SemaObjC/no-warning-unavail-unimp.m create mode 100644 clang/test/SemaObjC/nonnull.h create mode 100644 clang/test/SemaObjC/nonnull.m create mode 100644 clang/test/SemaObjC/nsobject-attribute-1.m create mode 100644 clang/test/SemaObjC/nsobject-attribute.m create mode 100644 clang/test/SemaObjC/objc-array-literal.m create mode 100644 clang/test/SemaObjC/objc-buffered-methods.m create mode 100644 clang/test/SemaObjC/objc-container-subscripting-1.m create mode 100644 clang/test/SemaObjC/objc-container-subscripting-2.m create mode 100644 clang/test/SemaObjC/objc-container-subscripting-3.m create mode 100644 clang/test/SemaObjC/objc-container-subscripting.m create mode 100644 clang/test/SemaObjC/objc-cstyle-args-in-methods.m create mode 100644 clang/test/SemaObjC/objc-dictionary-literal.m create mode 100644 clang/test/SemaObjC/objc-literal-nsnumber.m create mode 100644 clang/test/SemaObjC/objc-literal-sig.m create mode 100644 clang/test/SemaObjC/objc-qualified-property-lookup.m create mode 100644 clang/test/SemaObjC/objc-string-constant.m create mode 100644 clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m create mode 100644 clang/test/SemaObjC/objc2-warn-weak-decl.m create mode 100644 clang/test/SemaObjC/pedantic-dynamic-test.m create mode 100644 clang/test/SemaObjC/pragma-pack.m create mode 100644 clang/test/SemaObjC/property-10.m create mode 100644 clang/test/SemaObjC/property-11.m create mode 100644 clang/test/SemaObjC/property-12.m create mode 100644 clang/test/SemaObjC/property-13.m create mode 100644 clang/test/SemaObjC/property-2.m create mode 100644 clang/test/SemaObjC/property-3.m create mode 100644 clang/test/SemaObjC/property-4.m create mode 100644 clang/test/SemaObjC/property-5.m create mode 100644 clang/test/SemaObjC/property-6.m create mode 100644 clang/test/SemaObjC/property-7.m create mode 100644 clang/test/SemaObjC/property-8.m create mode 100644 clang/test/SemaObjC/property-9-impl-method.m create mode 100644 clang/test/SemaObjC/property-9.m create mode 100644 clang/test/SemaObjC/property-and-class-extension.m create mode 100644 clang/test/SemaObjC/property-and-ivar-use.m create mode 100644 clang/test/SemaObjC/property-category-1.m create mode 100644 clang/test/SemaObjC/property-category-2.m create mode 100644 clang/test/SemaObjC/property-category-3.m create mode 100644 clang/test/SemaObjC/property-category-4.m create mode 100644 clang/test/SemaObjC/property-category-impl.m create mode 100644 clang/test/SemaObjC/property-dot-receiver.m create mode 100644 clang/test/SemaObjC/property-error-readonly-assign.m create mode 100644 clang/test/SemaObjC/property-expression-error.m create mode 100644 clang/test/SemaObjC/property-impl-misuse.m create mode 100644 clang/test/SemaObjC/property-in-class-extension.m create mode 100644 clang/test/SemaObjC/property-inherited.m create mode 100644 clang/test/SemaObjC/property-ivar-mismatch.m create mode 100644 clang/test/SemaObjC/property-lookup-in-id.m create mode 100644 clang/test/SemaObjC/property-method-lookup-impl.m create mode 100644 clang/test/SemaObjC/property-missing.m create mode 100644 clang/test/SemaObjC/property-nonfragile-abi.m create mode 100644 clang/test/SemaObjC/property-noprotocol-warning.m create mode 100644 clang/test/SemaObjC/property-not-lvalue.m create mode 100644 clang/test/SemaObjC/property-ns-returns-not-retained-attr.m create mode 100644 clang/test/SemaObjC/property-redundant-decl-accessor.m create mode 100644 clang/test/SemaObjC/property-typecheck-1.m create mode 100644 clang/test/SemaObjC/property-user-setter.m create mode 100644 clang/test/SemaObjC/property-weak.m create mode 100644 clang/test/SemaObjC/property.m create mode 100644 clang/test/SemaObjC/props-on-prots.m create mode 100644 clang/test/SemaObjC/protocol-archane.m create mode 100644 clang/test/SemaObjC/protocol-attribute.m create mode 100644 clang/test/SemaObjC/protocol-expr-1.m create mode 100644 clang/test/SemaObjC/protocol-expr-neg-1.m create mode 100644 clang/test/SemaObjC/protocol-id-test-1.m create mode 100644 clang/test/SemaObjC/protocol-id-test-2.m create mode 100644 clang/test/SemaObjC/protocol-id-test-3.m create mode 100644 clang/test/SemaObjC/protocol-implementation-inherited.m create mode 100644 clang/test/SemaObjC/protocol-implementing-class-methods.m create mode 100644 clang/test/SemaObjC/protocol-lookup-2.m create mode 100644 clang/test/SemaObjC/protocol-lookup.m create mode 100644 clang/test/SemaObjC/protocol-qualified-class-unsupported.m create mode 100644 clang/test/SemaObjC/protocol-typecheck.m create mode 100644 clang/test/SemaObjC/protocol-warn.m create mode 100644 clang/test/SemaObjC/protocols.m create mode 100644 clang/test/SemaObjC/provisional-ivar-lookup.m create mode 100644 clang/test/SemaObjC/qualified-protocol-method-conflicts.m create mode 100644 clang/test/SemaObjC/rdar6248119.m create mode 100644 clang/test/SemaObjC/rdr-6211479-array-property.m create mode 100644 clang/test/SemaObjC/receiver-forward-class.m create mode 100644 clang/test/SemaObjC/related-result-type-inference.m create mode 100644 clang/test/SemaObjC/restrict-id-type.m create mode 100644 clang/test/SemaObjC/return.m create mode 100644 clang/test/SemaObjC/scope-check.m create mode 100644 clang/test/SemaObjC/selector-1.m create mode 100644 clang/test/SemaObjC/selector-2.m create mode 100644 clang/test/SemaObjC/selector-3.m create mode 100644 clang/test/SemaObjC/selector-error.m create mode 100644 clang/test/SemaObjC/selector-overload.m create mode 100644 clang/test/SemaObjC/self-assign.m create mode 100644 clang/test/SemaObjC/self-declared-in-block.m create mode 100644 clang/test/SemaObjC/self-in-function.m create mode 100644 clang/test/SemaObjC/setter-dotsyntax.m create mode 100644 clang/test/SemaObjC/severe-syntax-error.m create mode 100644 clang/test/SemaObjC/sizeof-interface.m create mode 100644 clang/test/SemaObjC/special-dep-unavail-warning.m create mode 100644 clang/test/SemaObjC/stand-alone-implementation.m create mode 100644 clang/test/SemaObjC/static-ivar-ref-1.m create mode 100644 clang/test/SemaObjC/stmts.m create mode 100644 clang/test/SemaObjC/string.m create mode 100644 clang/test/SemaObjC/super-cat-prot.m create mode 100644 clang/test/SemaObjC/super-class-protocol-conformance.m create mode 100644 clang/test/SemaObjC/super-property-message-expr.m create mode 100644 clang/test/SemaObjC/super-property-notation.m create mode 100644 clang/test/SemaObjC/super.m create mode 100644 clang/test/SemaObjC/synchronized.m create mode 100644 clang/test/SemaObjC/synth-provisional-ivars-1.m create mode 100644 clang/test/SemaObjC/synth-provisional-ivars.m create mode 100644 clang/test/SemaObjC/synthesize-setter-contclass.m create mode 100644 clang/test/SemaObjC/synthesized-ivar.m create mode 100644 clang/test/SemaObjC/transparent-union.m create mode 100644 clang/test/SemaObjC/try-catch.m create mode 100644 clang/test/SemaObjC/typedef-class.m create mode 100644 clang/test/SemaObjC/ucn-objc-string.m create mode 100644 clang/test/SemaObjC/undeclared-selector.m create mode 100644 clang/test/SemaObjC/undef-class-messagin-error.m create mode 100644 clang/test/SemaObjC/undef-protocol-methods-1.m create mode 100644 clang/test/SemaObjC/undef-superclass-1.m create mode 100644 clang/test/SemaObjC/undefined-protocol-type-1.m create mode 100644 clang/test/SemaObjC/unimplemented-protocol-prop.m create mode 100644 clang/test/SemaObjC/uninit-variables.m create mode 100644 clang/test/SemaObjC/unknown-anytype.m create mode 100644 clang/test/SemaObjC/unqualified-to-qualified-class-warn.m create mode 100644 clang/test/SemaObjC/unused.m create mode 100644 clang/test/SemaObjC/va-method-1.m create mode 100644 clang/test/SemaObjC/warn-assign-property-nscopying.m create mode 100644 clang/test/SemaObjC/warn-deprecated-implementations.m create mode 100644 clang/test/SemaObjC/warn-forward-class-attr-deprecated.m create mode 100644 clang/test/SemaObjC/warn-implicit-atomic-property.m create mode 100644 clang/test/SemaObjC/warn-incompatible-builtin-types.m create mode 100644 clang/test/SemaObjC/warn-missing-super.m create mode 100644 clang/test/SemaObjC/warn-retain-cycle.m create mode 100644 clang/test/SemaObjC/warn-selector-selection.m create mode 100644 clang/test/SemaObjC/warn-strict-selector-match.m create mode 100644 clang/test/SemaObjC/warn-superclass-method-mismatch.m create mode 100644 clang/test/SemaObjC/warn-unreachable.m create mode 100644 clang/test/SemaObjC/warn-unused-exception-param.m create mode 100644 clang/test/SemaObjC/warn-weak-field.m create mode 100644 clang/test/SemaObjC/warn-write-strings.m create mode 100644 clang/test/SemaObjC/weak-attr-ivar.m create mode 100644 clang/test/SemaObjC/weak-property.m create mode 100644 clang/test/SemaObjC/weak-receiver-warn.m create mode 100644 clang/test/SemaObjC/writable-property-in-superclass.m create mode 100644 clang/test/SemaObjCXX/Inputs/arc-system-header.h create mode 100644 clang/test/SemaObjCXX/NSString-type.mm create mode 100644 clang/test/SemaObjCXX/arc-0x.mm create mode 100644 clang/test/SemaObjCXX/arc-bool-conversion.mm create mode 100644 clang/test/SemaObjCXX/arc-bridged-cast.mm create mode 100644 clang/test/SemaObjCXX/arc-libstdcxx.mm create mode 100644 clang/test/SemaObjCXX/arc-memfunc.mm create mode 100644 clang/test/SemaObjCXX/arc-non-pod.mm create mode 100644 clang/test/SemaObjCXX/arc-nsconsumed-errors.mm create mode 100644 clang/test/SemaObjCXX/arc-object-init-destroy.mm create mode 100644 clang/test/SemaObjCXX/arc-overloading.mm create mode 100644 clang/test/SemaObjCXX/arc-ppe.mm create mode 100644 clang/test/SemaObjCXX/arc-system-header.mm create mode 100644 clang/test/SemaObjCXX/arc-templates.mm create mode 100644 clang/test/SemaObjCXX/arc-type-conversion.mm create mode 100644 clang/test/SemaObjCXX/arc-type-traits.mm create mode 100644 clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm create mode 100644 clang/test/SemaObjCXX/arc-unbridged-cast.mm create mode 100644 clang/test/SemaObjCXX/argument-dependent-lookup.mm create mode 100644 clang/test/SemaObjCXX/blocks.mm create mode 100644 clang/test/SemaObjCXX/category-lookup.mm create mode 100644 clang/test/SemaObjCXX/composite-objc-pointertype.mm create mode 100644 clang/test/SemaObjCXX/conditional-expr.mm create mode 100644 clang/test/SemaObjCXX/const-cast.mm create mode 100644 clang/test/SemaObjCXX/conversion-ranking.mm create mode 100644 clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm create mode 100644 clang/test/SemaObjCXX/conversion-to-objc-pointer.mm create mode 100644 clang/test/SemaObjCXX/cstyle-block-pointer-cast.mm create mode 100644 clang/test/SemaObjCXX/cstyle-cast.mm create mode 100644 clang/test/SemaObjCXX/cxxoperator-selector.mm create mode 100644 clang/test/SemaObjCXX/debugger-cast-result-to-id.mm create mode 100644 clang/test/SemaObjCXX/deduction.mm create mode 100644 clang/test/SemaObjCXX/exceptions-fragile.mm create mode 100644 clang/test/SemaObjCXX/expr-objcxx.mm create mode 100644 clang/test/SemaObjCXX/foreach-block.mm create mode 100644 clang/test/SemaObjCXX/fragile-abi-object-assign.m create mode 100644 clang/test/SemaObjCXX/function-pointer-void-star.mm create mode 100644 clang/test/SemaObjCXX/gc-attributes.mm create mode 100644 clang/test/SemaObjCXX/goto.mm create mode 100644 clang/test/SemaObjCXX/instantiate-expr.mm create mode 100644 clang/test/SemaObjCXX/instantiate-message.mm create mode 100644 clang/test/SemaObjCXX/instantiate-method-return.mm create mode 100644 clang/test/SemaObjCXX/instantiate-stmt.mm create mode 100644 clang/test/SemaObjCXX/ivar-construct.mm create mode 100644 clang/test/SemaObjCXX/ivar-lookup.mm create mode 100644 clang/test/SemaObjCXX/ivar-reference-type.mm create mode 100644 clang/test/SemaObjCXX/ivar-struct.mm create mode 100644 clang/test/SemaObjCXX/linkage-spec.mm create mode 100644 clang/test/SemaObjCXX/literals.mm create mode 100644 clang/test/SemaObjCXX/message.mm create mode 100644 clang/test/SemaObjCXX/namespace-lookup.mm create mode 100644 clang/test/SemaObjCXX/null_objc_pointer.mm create mode 100644 clang/test/SemaObjCXX/nullptr.mm create mode 100644 clang/test/SemaObjCXX/objc-container-subscripting.mm create mode 100644 clang/test/SemaObjCXX/objc-decls-inside-namespace.mm create mode 100644 clang/test/SemaObjCXX/objc-extern-c.mm create mode 100644 clang/test/SemaObjCXX/objc-pointer-conv.mm create mode 100644 clang/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm create mode 100644 clang/test/SemaObjCXX/overload-1.mm create mode 100644 clang/test/SemaObjCXX/overload-gc.mm create mode 100644 clang/test/SemaObjCXX/overload.mm create mode 100644 clang/test/SemaObjCXX/parameters.mm create mode 100644 clang/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm create mode 100644 clang/test/SemaObjCXX/propert-dot-error.mm create mode 100644 clang/test/SemaObjCXX/properties.mm create mode 100644 clang/test/SemaObjCXX/property-reference.mm create mode 100644 clang/test/SemaObjCXX/property-synthesis-error.mm create mode 100644 clang/test/SemaObjCXX/property-type-mismatch.mm create mode 100644 clang/test/SemaObjCXX/protocol-lookup.mm create mode 100644 clang/test/SemaObjCXX/references.mm create mode 100644 clang/test/SemaObjCXX/reinterpret-cast-objc-pointertype.mm create mode 100644 clang/test/SemaObjCXX/related-result-type-inference.mm create mode 100644 clang/test/SemaObjCXX/reserved-keyword-methods.mm create mode 100644 clang/test/SemaObjCXX/standard-conversion-to-bool.mm create mode 100644 clang/test/SemaObjCXX/static-cast.mm create mode 100644 clang/test/SemaObjCXX/unknown-anytype.mm create mode 100644 clang/test/SemaObjCXX/vararg-non-pod.mm create mode 100644 clang/test/SemaObjCXX/vla.mm create mode 100644 clang/test/SemaObjCXX/void_to_obj.mm create mode 100644 clang/test/SemaObjCXX/warn-strict-selector-match.mm create mode 100644 clang/test/SemaOpenCL/address-spaces.cl create mode 100644 clang/test/SemaOpenCL/cond.cl create mode 100644 clang/test/SemaOpenCL/extension-fp64.cl create mode 100644 clang/test/SemaOpenCL/init.cl create mode 100644 clang/test/SemaOpenCL/vec_compare.cl create mode 100644 clang/test/SemaOpenCL/vec_step.cl create mode 100644 clang/test/SemaOpenCL/vector_conv_invalid.cl create mode 100644 clang/test/SemaOpenCL/vector_literals_const.cl create mode 100644 clang/test/SemaOpenCL/vector_literals_invalid.cl create mode 100644 clang/test/SemaTemplate/ackermann.cpp create mode 100644 clang/test/SemaTemplate/address-spaces.cpp create mode 100644 clang/test/SemaTemplate/alias-church-numerals.cpp create mode 100644 clang/test/SemaTemplate/alias-nested-nontag.cpp create mode 100644 clang/test/SemaTemplate/alias-template-template-param.cpp create mode 100644 clang/test/SemaTemplate/alias-templates.cpp create mode 100644 clang/test/SemaTemplate/ambiguous-ovl-print.cpp create mode 100644 clang/test/SemaTemplate/anonymous-union.cpp create mode 100644 clang/test/SemaTemplate/array-to-pointer-decay.cpp create mode 100644 clang/test/SemaTemplate/atomics.cpp create mode 100644 clang/test/SemaTemplate/attributes.cpp create mode 100644 clang/test/SemaTemplate/canonical-expr-type-0x.cpp create mode 100644 clang/test/SemaTemplate/canonical-expr-type.cpp create mode 100644 clang/test/SemaTemplate/class-template-ctor-initializer.cpp create mode 100644 clang/test/SemaTemplate/class-template-decl.cpp create mode 100644 clang/test/SemaTemplate/class-template-id-2.cpp create mode 100644 clang/test/SemaTemplate/class-template-id.cpp create mode 100644 clang/test/SemaTemplate/class-template-spec.cpp create mode 100644 clang/test/SemaTemplate/constexpr-instantiate.cpp create mode 100644 clang/test/SemaTemplate/constructor-template.cpp create mode 100644 clang/test/SemaTemplate/copy-ctor-assign.cpp create mode 100644 clang/test/SemaTemplate/crash-10438657.cpp create mode 100644 clang/test/SemaTemplate/crash-8204126.cpp create mode 100644 clang/test/SemaTemplate/current-instantiation.cpp create mode 100644 clang/test/SemaTemplate/deduction-crash.cpp create mode 100644 clang/test/SemaTemplate/deduction.cpp create mode 100644 clang/test/SemaTemplate/default-arguments-cxx0x.cpp create mode 100644 clang/test/SemaTemplate/default-arguments.cpp create mode 100644 clang/test/SemaTemplate/default-expr-arguments-2.cpp create mode 100644 clang/test/SemaTemplate/default-expr-arguments.cpp create mode 100644 clang/test/SemaTemplate/delegating-constructors.cpp create mode 100644 clang/test/SemaTemplate/dependent-base-classes.cpp create mode 100644 clang/test/SemaTemplate/dependent-base-member-init.cpp create mode 100644 clang/test/SemaTemplate/dependent-class-member-operator.cpp create mode 100644 clang/test/SemaTemplate/dependent-expr.cpp create mode 100644 clang/test/SemaTemplate/dependent-names-no-std.cpp create mode 100644 clang/test/SemaTemplate/dependent-names.cpp create mode 100644 clang/test/SemaTemplate/dependent-sized_array.cpp create mode 100644 clang/test/SemaTemplate/dependent-template-recover.cpp create mode 100644 clang/test/SemaTemplate/dependent-type-identity.cpp create mode 100644 clang/test/SemaTemplate/destructor-template.cpp create mode 100644 clang/test/SemaTemplate/elaborated-type-specifier.cpp create mode 100644 clang/test/SemaTemplate/enum-argument.cpp create mode 100644 clang/test/SemaTemplate/enum-forward.cpp create mode 100644 clang/test/SemaTemplate/example-dynarray.cpp create mode 100644 clang/test/SemaTemplate/example-typelist.cpp create mode 100644 clang/test/SemaTemplate/explicit-instantiation.cpp create mode 100644 clang/test/SemaTemplate/explicit-specialization-member.cpp create mode 100644 clang/test/SemaTemplate/ext-vector-type.cpp create mode 100644 clang/test/SemaTemplate/extern-templates.cpp create mode 100644 clang/test/SemaTemplate/fibonacci.cpp create mode 100644 clang/test/SemaTemplate/friend-template.cpp create mode 100644 clang/test/SemaTemplate/friend.cpp create mode 100644 clang/test/SemaTemplate/fun-template-def.cpp create mode 100644 clang/test/SemaTemplate/function-template-specialization.cpp create mode 100644 clang/test/SemaTemplate/implicit-instantiation-1.cpp create mode 100644 clang/test/SemaTemplate/inject-templated-friend-post.cpp create mode 100644 clang/test/SemaTemplate/inject-templated-friend.cpp create mode 100644 clang/test/SemaTemplate/injected-class-name.cpp create mode 100644 clang/test/SemaTemplate/instantiate-anonymous-union.cpp create mode 100644 clang/test/SemaTemplate/instantiate-array.cpp create mode 100644 clang/test/SemaTemplate/instantiate-attr.cpp create mode 100644 clang/test/SemaTemplate/instantiate-c99.cpp create mode 100644 clang/test/SemaTemplate/instantiate-call.cpp create mode 100644 clang/test/SemaTemplate/instantiate-case.cpp create mode 100644 clang/test/SemaTemplate/instantiate-cast.cpp create mode 100644 clang/test/SemaTemplate/instantiate-clang.cpp create mode 100644 clang/test/SemaTemplate/instantiate-complete.cpp create mode 100644 clang/test/SemaTemplate/instantiate-decl-dtor.cpp create mode 100644 clang/test/SemaTemplate/instantiate-decl-init.cpp create mode 100644 clang/test/SemaTemplate/instantiate-declref-ice.cpp create mode 100644 clang/test/SemaTemplate/instantiate-declref.cpp create mode 100644 clang/test/SemaTemplate/instantiate-deeply.cpp create mode 100644 clang/test/SemaTemplate/instantiate-default-assignment-operator.cpp create mode 100644 clang/test/SemaTemplate/instantiate-dependent-nested-name.cpp create mode 100644 clang/test/SemaTemplate/instantiate-elab-type-specifier.cpp create mode 100644 clang/test/SemaTemplate/instantiate-enum-2.cpp create mode 100644 clang/test/SemaTemplate/instantiate-enum.cpp create mode 100644 clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp create mode 100644 clang/test/SemaTemplate/instantiate-exception-spec.cpp create mode 100644 clang/test/SemaTemplate/instantiate-expr-1.cpp create mode 100644 clang/test/SemaTemplate/instantiate-expr-2.cpp create mode 100644 clang/test/SemaTemplate/instantiate-expr-3.cpp create mode 100644 clang/test/SemaTemplate/instantiate-expr-4.cpp create mode 100644 clang/test/SemaTemplate/instantiate-expr-5.cpp create mode 100644 clang/test/SemaTemplate/instantiate-expr-basic.cpp create mode 100644 clang/test/SemaTemplate/instantiate-field.cpp create mode 100644 clang/test/SemaTemplate/instantiate-friend-class.cpp create mode 100644 clang/test/SemaTemplate/instantiate-function-1.cpp create mode 100644 clang/test/SemaTemplate/instantiate-function-1.mm create mode 100644 clang/test/SemaTemplate/instantiate-function-2.cpp create mode 100644 clang/test/SemaTemplate/instantiate-function-params.cpp create mode 100644 clang/test/SemaTemplate/instantiate-init.cpp create mode 100644 clang/test/SemaTemplate/instantiate-invalid.cpp create mode 100644 clang/test/SemaTemplate/instantiate-local-class.cpp create mode 100644 clang/test/SemaTemplate/instantiate-member-class.cpp create mode 100644 clang/test/SemaTemplate/instantiate-member-expr.cpp create mode 100644 clang/test/SemaTemplate/instantiate-member-initializers.cpp create mode 100644 clang/test/SemaTemplate/instantiate-member-pointers.cpp create mode 100644 clang/test/SemaTemplate/instantiate-member-template.cpp create mode 100644 clang/test/SemaTemplate/instantiate-method.cpp create mode 100644 clang/test/SemaTemplate/instantiate-non-dependent-types.cpp create mode 100644 clang/test/SemaTemplate/instantiate-non-type-template-parameter.cpp create mode 100644 clang/test/SemaTemplate/instantiate-objc-1.mm create mode 100644 clang/test/SemaTemplate/instantiate-overload-candidates.cpp create mode 100644 clang/test/SemaTemplate/instantiate-overloaded-arrow.cpp create mode 100644 clang/test/SemaTemplate/instantiate-self.cpp create mode 100644 clang/test/SemaTemplate/instantiate-sizeof.cpp create mode 100644 clang/test/SemaTemplate/instantiate-static-var.cpp create mode 100644 clang/test/SemaTemplate/instantiate-subscript.cpp create mode 100644 clang/test/SemaTemplate/instantiate-template-template-parm.cpp create mode 100644 clang/test/SemaTemplate/instantiate-try-catch.cpp create mode 100644 clang/test/SemaTemplate/instantiate-type.cpp create mode 100644 clang/test/SemaTemplate/instantiate-typedef.cpp create mode 100644 clang/test/SemaTemplate/instantiate-typeof.cpp create mode 100644 clang/test/SemaTemplate/instantiate-using-decl.cpp create mode 100644 clang/test/SemaTemplate/instantiation-backtrace.cpp create mode 100644 clang/test/SemaTemplate/instantiation-default-1.cpp create mode 100644 clang/test/SemaTemplate/instantiation-default-2.cpp create mode 100644 clang/test/SemaTemplate/instantiation-default-3.cpp create mode 100644 clang/test/SemaTemplate/instantiation-depth.cpp create mode 100644 clang/test/SemaTemplate/instantiation-order.cpp create mode 100644 clang/test/SemaTemplate/issue150.cpp create mode 100644 clang/test/SemaTemplate/lookup-dependent-bases.cpp create mode 100644 clang/test/SemaTemplate/member-access-ambig.cpp create mode 100644 clang/test/SemaTemplate/member-access-expr.cpp create mode 100644 clang/test/SemaTemplate/member-function-template.cpp create mode 100644 clang/test/SemaTemplate/member-inclass-init-value-dependent.cpp create mode 100644 clang/test/SemaTemplate/member-initializers.cpp create mode 100644 clang/test/SemaTemplate/member-template-access-expr.cpp create mode 100644 clang/test/SemaTemplate/metafun-apply.cpp create mode 100644 clang/test/SemaTemplate/missing-class-keyword-crash.cpp create mode 100644 clang/test/SemaTemplate/ms-function-specialization-class-scope.cpp create mode 100644 clang/test/SemaTemplate/ms-if-exists.cpp create mode 100644 clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp create mode 100644 clang/test/SemaTemplate/nested-incomplete-class.cpp create mode 100644 clang/test/SemaTemplate/nested-linkage.cpp create mode 100644 clang/test/SemaTemplate/nested-name-spec-template.cpp create mode 100644 clang/test/SemaTemplate/nested-template.cpp create mode 100644 clang/test/SemaTemplate/operator-function-id-template.cpp create mode 100644 clang/test/SemaTemplate/operator-template.cpp create mode 100644 clang/test/SemaTemplate/overload-candidates.cpp create mode 100644 clang/test/SemaTemplate/overload-uneval.cpp create mode 100644 clang/test/SemaTemplate/partial-spec-instantiate.cpp create mode 100644 clang/test/SemaTemplate/pragma-ms_struct.cpp create mode 100644 clang/test/SemaTemplate/qualified-id.cpp create mode 100644 clang/test/SemaTemplate/qualified-names-diag.cpp create mode 100644 clang/test/SemaTemplate/rdar9173693.cpp create mode 100644 clang/test/SemaTemplate/recovery-crash.cpp create mode 100644 clang/test/SemaTemplate/recursive-template-instantiation.cpp create mode 100644 clang/test/SemaTemplate/resolve-single-template-id.cpp create mode 100644 clang/test/SemaTemplate/self-comparison.cpp create mode 100644 clang/test/SemaTemplate/temp.cpp create mode 100644 clang/test/SemaTemplate/temp_arg.cpp create mode 100644 clang/test/SemaTemplate/temp_arg_nontype.cpp create mode 100644 clang/test/SemaTemplate/temp_arg_template.cpp create mode 100644 clang/test/SemaTemplate/temp_arg_type.cpp create mode 100644 clang/test/SemaTemplate/temp_class_order.cpp create mode 100644 clang/test/SemaTemplate/temp_class_spec.cpp create mode 100644 clang/test/SemaTemplate/temp_class_spec_blocks.cpp create mode 100644 clang/test/SemaTemplate/temp_class_spec_neg.cpp create mode 100644 clang/test/SemaTemplate/temp_explicit.cpp create mode 100644 clang/test/SemaTemplate/temp_explicit_cxx0x.cpp create mode 100644 clang/test/SemaTemplate/temp_func_order.cpp create mode 100644 clang/test/SemaTemplate/template-class-traits.cpp create mode 100644 clang/test/SemaTemplate/template-decl-fail.cpp create mode 100644 clang/test/SemaTemplate/template-id-expr.cpp create mode 100644 clang/test/SemaTemplate/template-id-printing.cpp create mode 100644 clang/test/SemaTemplate/typename-specifier-2.cpp create mode 100644 clang/test/SemaTemplate/typename-specifier-3.cpp create mode 100644 clang/test/SemaTemplate/typename-specifier-4.cpp create mode 100644 clang/test/SemaTemplate/typename-specifier.cpp create mode 100644 clang/test/SemaTemplate/typo-dependent-name.cpp create mode 100644 clang/test/SemaTemplate/unresolved-construct.cpp create mode 100644 clang/test/SemaTemplate/unused-variables.cpp create mode 100644 clang/test/SemaTemplate/value-dependent-null-pointer-constant.cpp create mode 100644 clang/test/SemaTemplate/virtual-member-functions.cpp create mode 100755 clang/test/TestRunner.sh create mode 100644 clang/test/Tooling/clang-check-args.cpp create mode 100644 clang/test/Tooling/clang-check-pwd.cpp create mode 100644 clang/test/Tooling/clang-check.cpp create mode 100644 clang/test/Unit/lit.cfg create mode 100644 clang/test/Unit/lit.site.cfg.in create mode 100644 clang/test/cxx-sections.data create mode 100644 clang/test/lit.cfg create mode 100644 clang/test/lit.site.cfg.in create mode 100755 clang/test/make_test_dirs.pl (limited to 'clang/test') 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 {} +- (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 {} +- (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 {} +- (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 {} +- (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: +// CHECK: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: descriptionARC forbids explicit message send of 'release' +// CHECK: categoryARC Restrictions +// CHECK: typeerror +// CHECK: location +// CHECK: +// CHECK: line10 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: + +// 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 {} +@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 _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 {} +@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 _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 {} +@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 _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 {} +@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 _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 +struct X0; + +template +struct X1; + +template +struct X2; + +template +struct X3; + +template class> +struct X4; + +template class> +struct X5; + +template +struct X6; + +extern X0 *x0i; +extern X0 *x0l; +extern X0 *x0r; + +template<> +struct X0 { + int member; +}; + +template<> +struct X0 { + 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 +struct X0; + +template +struct X1; + +template +struct X2; + +template +struct X3; + +template class> +struct X4; + +template class> +struct X5; + +template class> +struct X6; + +typedef int Integer; +extern X0 *x0i; +extern X0 *x0f; +extern X0 *x0r; + +template<> +struct X0 { + int member; +}; + +template<> +struct X0 { + 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 ++ (int)foo; +- (int)bar:(float)x; +@end + +// Protocol with protocol +@protocol P2 +- (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 ++ (int)foo; +- (int)bar:(float)x; +@end + +// Protocol with protocol +@protocol P2 +- (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 *' vs. 'X0 *') +// CHECK: class-template1.cpp:24:19: note: declared here with type 'X0 *' + +// CHECK: class-template1.cpp:32:8: warning: type 'X0' 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 {} - (id)init; @end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSString : NSObject +- (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 {} @end +@class NSDictionary; +@interface NSError : NSObject {} ++ (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 {} +- (void)dealloc; +- (id)init; +@end + +typedef struct objc_selector *SEL; + +// : '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 + +//===------------------------------------------------------------------------=== +// +// 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 {} ++ (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 +- (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 {} @end +@protocol NSAnimatablePropertyContainer +- (id)animator; +@end +@protocol NSValidatedUserInterfaceItem +- (SEL)action; +@end +@protocol NSUserInterfaceValidations +- (BOOL)validateUserInterfaceItem:(id )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 {} +- (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 {} +- (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 +- (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 - (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 . +// 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 () +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 {} + + (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 {} +@end +@protocol NSAnimatablePropertyContainer +- (id)animator; +@end +extern NSString *NSAnimationTriggerOrderIn ; +@class CIFilter, CALayer, NSDictionary, NSScreen, NSShadow, NSTrackingArea; +@interface NSView : NSResponder {} @end +@protocol NSValidatedUserInterfaceItem - (SEL)action; @end +@protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id )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 { + 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 + +//===----------------------------------------------------------------------===// +// 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 {} @end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSString : NSObject +- (NSUInteger)length; ++ (id)stringWithFormat:(NSString *)format, ...; +@end +@interface NSSimpleCString : NSString {} @end +@interface NSConstantString : NSSimpleCString @end +extern void *_NSConstantStringClassReference; +typedef double NSTimeInterval; +@interface NSDate : NSObject - (NSTimeInterval)timeIntervalSinceReferenceDate; @end +@class NSString, NSDictionary, NSArray; +@interface NSException : NSObject {} ++ (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 (). +// 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 {} +- (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 +- (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 { +} +@end extern id NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone); +@interface NSArray : NSObject - (unsigned)count; +@end @class NSTimer, NSPort, NSArray; +@class NSURLHandle, NSMutableArray, NSMutableData, NSData, NSURL; +@interface NSResponder : NSObject { +} +@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 *)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 {} ++(id)alloc; +-(id)init; +-(id)autorelease; +-(id)copy; +-(id)retain; +@end +@interface NSString : NSObject +- (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 {} ++ (id)alloc; +@end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSString : NSObject - (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)(); +} + +// +// A cast from int onjective C property reference to int. +typedef signed char BOOL; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface 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 . +// 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 + +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>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 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(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(*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 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 +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; +} + +// +// 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}} + } +} + +// 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 + class pencil { + public: + ~pencil() throw() {} + }; + template struct _Row_base { + _Row_base(const pencil<_Tp>& x) {} + }; + template > + 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 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 {} @end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSValue : NSObject - (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 {} @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; +} + +// 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 {} +- (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 +- (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 - (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. +//===----------------------------------------------------------------------===// + +// +// 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(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(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(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(pbb); + BB *s = dynamic_cast(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(pbb); + return b->m; // no warning +} + +int testLHS() { + B aa; + A *a = &aa; + return (dynamic_cast(a))->m; +} + +int testLHS2() { + B aa; + A *a = &aa; + return (*dynamic_cast(a)).m; +} + +int testDynCastUnknown2(class A *a) { + B *b = dynamic_cast(a); + return b->m; // no warning +} + +int testDynCastUnknown(class A *a) { + B *b = dynamic_cast(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(pa); + return b->m; // expected-warning {{dereference of a null pointer}} +} + +int testLHSFail() { + C c; + A *a = &c; + return (*dynamic_cast(a)).m; // expected-warning {{Dereference of null pointer}} +} + +int testBaseToDerivedFail() { + A a; + B *b = dynamic_cast(&a); + return b->m; // expected-warning {{dereference of a null pointer}} +} + +int testConstZeroFail() { + B *b = dynamic_cast((A *)0); + return b->m; // expected-warning {{dereference of a null pointer}} +} + +int testConstZeroFail2() { + A *a = 0; + B *b = dynamic_cast(a); + return b->m; // expected-warning {{dereference of a null pointer}} +} + +int testUpcast() { + B b; + A *a = dynamic_cast(&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(&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(rb); + int *x = 0; + return *x; // expected-warning {{Dereference of null pointer}} +} + +int testReferenceFailedCast() { + A a; + B &b = dynamic_cast(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(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(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(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 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> 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; +} + +// - 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 + +// - 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; +} + +// : 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 + +// +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: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line12 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col14 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Assuming 'x' is equal to 0 +// CHECK: message +// CHECK: Assuming 'x' is equal to 0 +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line14 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col14 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Division by zero +// CHECK: message +// CHECK: Division by zero +// CHECK: +// CHECK: +// CHECK: descriptionDivision by zero +// CHECK: categoryLogic error +// CHECK: typeDivision by zero +// CHECK: issue_context_kindfunction +// CHECK: issue_contextfoo +// CHECK: location +// CHECK: +// CHECK: line14 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line23 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'has_bug' +// CHECK: message +// CHECK: Calling 'has_bug' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'test_has_bug' +// CHECK: message +// CHECK: Entered call from 'test_has_bug' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexthas_bug +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: 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: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'bug' +// CHECK: message +// CHECK: Calling 'bug' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line4 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'test_bug_1' +// CHECK: message +// CHECK: Entered call from 'test_bug_1' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contextbug +// CHECK: location +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: 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 + +void fum(std::vector::iterator t); + +void foo1() +{ + // iterators that are defined but not initialized + std::vector::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 v, vv; + std::vector::iterator it = v.begin(); + fum(it); // no-warning + *it; // no-warning + // a valid iterator plus an integer is still valid + std::vector::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::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 v; + vector::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 v; + std::vector::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 v, vv; + std::vector::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: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line11 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is allocated +// CHECK: message +// CHECK: Memory is allocated +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line14 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line14 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'p' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'p' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'p' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextdiagnosticTest +// CHECK: location +// CHECK: +// CHECK: line14 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col30 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col30 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is allocated +// CHECK: message +// CHECK: Memory is allocated +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col30 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line21 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line21 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line21 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'A' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'A' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'A' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextmyArrayAllocation +// CHECK: location +// CHECK: +// CHECK: line21 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line24 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is allocated +// CHECK: message +// CHECK: Memory is allocated +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line26 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Attempt to reallocate memory +// CHECK: message +// CHECK: Attempt to reallocate memory +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line27 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Assuming 'tmp' is null +// CHECK: message +// CHECK: Assuming 'tmp' is null +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line27 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reallocation failed +// CHECK: message +// CHECK: Reallocation failed +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col14 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line28 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col14 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'buf' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'buf' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'buf' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextreallocDiagnostics +// CHECK: location +// CHECK: +// CHECK: line28 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line43 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'wrapper' +// CHECK: message +// CHECK: Calling 'wrapper' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line34 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'test_wrapper' +// CHECK: message +// CHECK: Entered call from 'test_wrapper' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line34 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line34 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col13 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line35 +// CHECK: col13 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col13 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is allocated +// CHECK: message +// CHECK: Memory is allocated +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col13 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Assuming 'x' is non-null +// CHECK: message +// CHECK: Assuming 'x' is non-null +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line38 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line38 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line43 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Returned allocated memory +// CHECK: message +// CHECK: Returned allocated memory +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line45 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'buf' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'buf' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'buf' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_wrapper +// CHECK: location +// CHECK: +// CHECK: line45 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line60 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'my_malloc_and_free' +// CHECK: message +// CHECK: Calling 'my_malloc_and_free' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line52 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'test_double_action_call' +// CHECK: message +// CHECK: Entered call from 'test_double_action_call' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line53 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is allocated +// CHECK: message +// CHECK: Memory is allocated +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Calling 'my_free' +// CHECK: message +// CHECK: Calling 'my_free' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line49 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth2 +// CHECK: extended_message +// CHECK: Entered call from 'my_malloc_and_free' +// CHECK: message +// CHECK: Entered call from 'my_malloc_and_free' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line50 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth2 +// CHECK: extended_message +// CHECK: Memory is released +// CHECK: message +// CHECK: Memory is released +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth2 +// CHECK: extended_message +// CHECK: Returned released memory via 1st parameter +// CHECK: message +// CHECK: Returned released memory via 1st parameter +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line60 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Returned released memory via 1st parameter +// CHECK: message +// CHECK: Returned released memory via 1st parameter +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line61 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line61 +// CHECK: col14 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line61 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line61 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line61 +// CHECK: col14 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Use of memory after it is freed +// CHECK: message +// CHECK: Use of memory after it is freed +// CHECK: +// CHECK: +// CHECK: descriptionUse of memory after it is freed +// CHECK: categoryMemory Error +// CHECK: typeUse-after-free +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_double_action_call +// CHECK: location +// CHECK: +// CHECK: line61 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line74 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line74 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line74 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line74 +// CHECK: col35 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line74 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line74 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line74 +// CHECK: col35 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is allocated +// CHECK: message +// CHECK: Memory is allocated +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line74 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line74 +// CHECK: col35 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line75 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'my_realloc' +// CHECK: message +// CHECK: Calling 'my_realloc' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line65 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'reallocIntra' +// CHECK: message +// CHECK: Entered call from 'reallocIntra' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line67 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Attempt to reallocate memory +// CHECK: message +// CHECK: Attempt to reallocate memory +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line67 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line68 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Assuming 'tmp' is null +// CHECK: message +// CHECK: Assuming 'tmp' is null +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line68 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Reallocation failed +// CHECK: message +// CHECK: Reallocation failed +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line68 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line75 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Reallocation of 1st parameter failed +// CHECK: message +// CHECK: Reallocation of 1st parameter failed +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col13 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line76 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col13 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'buf' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'buf' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'buf' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextreallocIntra +// CHECK: location +// CHECK: +// CHECK: line76 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line84 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line84 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line85 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line85 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line85 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line85 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line85 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'malloc_wrapper_ret' +// CHECK: message +// CHECK: Calling 'malloc_wrapper_ret' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line80 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'use_ret' +// CHECK: message +// CHECK: Entered call from 'use_ret' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line80 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line80 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line81 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is allocated +// CHECK: message +// CHECK: Memory is allocated +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line85 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line85 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line85 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Returned allocated memory +// CHECK: message +// CHECK: Returned allocated memory +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line85 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line85 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line86 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line86 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line86 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'v' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'v' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'v' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextuse_ret +// CHECK: location +// CHECK: +// CHECK: line86 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line90 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line90 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col24 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line92 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col24 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is allocated +// CHECK: message +// CHECK: Memory is allocated +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line92 +// CHECK: col24 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line97 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line97 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line97 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line97 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line97 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'm' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'm' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'm' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextLeakedSymbol +// CHECK: location +// CHECK: +// CHECK: line97 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: + 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 + +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}} +} + +// . +// 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 +@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 { +} +@end extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSValue : NSObject - (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 - (NSUInteger)length; +@end @class NSArray, NSDictionary, NSString, NSError; +@interface NSSet : NSObject - (NSUInteger)count; +@end extern NSString *NSAccessibilityRoleDescription(NSString *role, NSString *subrole) ; +@interface NSResponder : NSObject { +} +@end @protocol NSAnimatablePropertyContainer - (id)animator; +@end extern NSString *NSAnimationTriggerOrderIn ; +@interface NSView : NSResponder { +} +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView; +@interface NSWindowController : NSResponder { +} +@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 - (BOOL)findText:(NSString *)string ignoreCase:(BOOL)ignoreCase matchStyle:(PBXFindMatchStyle)matchStyle backwards:(BOOL)backwards wrap:(BOOL)wrap; +@end @class PBXProjectDocument, PBXProject, PBXAttributedStatusView; +@interface PBXProjectModule : PBXModule { +} +@end @class PBXBookmark; +@protocol PBXSelectionTarget - (NSObject *) 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 { +} +@end @class PBXProjectDocument, PBXFileReference, PBXModule, XCWindowTool; +@interface XCPerspectiveModule : PBXProjectModule { // 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 + +// - 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); +} + +// - 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 {} ++ (id)alloc; +- (id)init; +@end typedef struct {} +NSFastEnumerationState; +@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; +@end @interface NSArray : NSObject - (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 +// +// 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 +} + + +//===---------------------------------------------------------------------===// +// +// 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 + +// +// 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 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}} +} + +// - 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 Foo { + ~Foo(); + struct Bar; + Bar* bar_; +}; + +template Foo::~Foo() { + Use(bar_); + T::DoSomething(); + bar_->Work(); +} + +// PR8427 -- this used to crash. + +class Dummy {}; + +bool operator==(Dummy, int); + +template +class Foo2 { + bool Bar(); +}; + +template +bool Foo2::Bar() { + return 0 == T(); +} + +// PR8433 -- this used to crash. + +template +class Foo3 { + public: + void Bar(); + void Baz(); + T value_; +}; + +template +void Foo3::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(*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 {} - (id)init; @end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSString : NSObject +- (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 . +// 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 + } +} + +//===----------------------------------------------------------------------===// +// +// 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 +} + +//===----------------------------------------------------------------------===// +// [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}} +} + +//===----------------------------------------------------------------------===// +// - 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 +} + +//===----------------------------------------------------------------------===// +// - 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 +} + +//===----------------------------------------------------------------------===// +// - 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 +} + +//===----------------------------------------------------------------------===// +// [RegionStore] crash when +// handling load: '*((unsigned int *)"????")' +//===----------------------------------------------------------------------===// + +int rdar_7261075(void) { + unsigned int var = 0; + if (var == *((unsigned int *)"????")) + return 1; + return 0; +} + +//===----------------------------------------------------------------------===// +// 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 + } +} + +//===----------------------------------------------------------------------===// +// +// +// 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 + } + } +} + +//===----------------------------------------------------------------------===// +// - 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}} +} + +//===----------------------------------------------------------------------===// +// : 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; +} + +//===----------------------------------------------------------------------===// +// - 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. +// () +//===----------------------------------------------------------------------===// + +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 () +//===----------------------------------------------------------------------===// + +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 +} + +//===----------------------------------------------------------------------===// +// - 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 + +//===----------------------------------------------------------------------===// +// - 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 +} + +//===----------------------------------------------------------------------===// +// +// 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; +} + +//===----------------------------------------------------------------------===// +// 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))) { + } + } +} + +//===----------------------------------------------------------------------===// +// - 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 +} + +//===----------------------------------------------------------------------===// +// - 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 +} + +//===----------------------------------------------------------------------===// +// +//===----------------------------------------------------------------------===// + +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 +} + +// - 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}} +} + +// - ?-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; +} + +// 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); +} + +// - 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}} +} + +// +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; })) { + } +} + +// - 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]; +} + +// - 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}} +} + +// - 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. +// +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 {} +- (id)init; ++ (id)allocWithZone:(NSZone *)zone; +@end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSString : NSObject +- (NSUInteger)length; ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end extern NSString * const NSBundleDidLoadNotification; +@interface NSValue : NSObject +- (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 +@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 +// + +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) { + ({}); +} + +// +// 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]; } + +// - 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; +} + +// - 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. +// +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 . 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 +// "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: +// 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; + } +} + +// - '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}} +} + +// "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 + +// - 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. +} + +// [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}} +} + +// - 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]; +} + +//===----------------------------------------------------------------------===// +// 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) { + } +} + +//===----------------------------------------------------------------------===// +// - 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}} +} + +// - __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 +} + +// - 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); +} + +// 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}} +} + +// 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 + } +} + +// 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 +// +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. +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 + +// - 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 +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 {} ++ (id)alloc; +- (id)init; +- (NSString *)description; +@end +@interface NSArray : NSObject +- (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}} + } +} + +// - 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; +} + +// 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: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line6 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line6 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line6 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line6 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line6 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_init +// CHECK: location +// CHECK: +// CHECK: line6 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_assign +// CHECK: location +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line16 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line16 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'q') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'q') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'q') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_assign_transitive +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line23 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Assuming 'p' is null +// CHECK: message +// CHECK: Assuming 'p' is null +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_cond +// CHECK: location +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line30 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line30 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line30 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line30 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line31 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line31 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line31 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line31 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line31 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_cond_transitive +// CHECK: location +// CHECK: +// CHECK: line31 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line38 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line38 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line38 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line38 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line38 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from field 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from field 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from field 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_field +// CHECK: location +// CHECK: +// CHECK: line38 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col82 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line54 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col82 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count +// CHECK: message +// CHECK: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col82 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line58 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'value' is not referenced later in this execution path and has a retain count of +1 +// CHECK: message +// CHECK: Object leaked: object allocated and stored into 'value' is not referenced later in this execution path and has a retain count of +1 +// CHECK: +// CHECK: +// CHECK: descriptionPotential leak of an object stored into 'value' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextrdar8331641 +// CHECK: location +// CHECK: +// CHECK: line58 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: 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. +// +@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: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line6 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line6 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line6 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line6 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line6 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_init +// CHECK: location +// CHECK: +// CHECK: line6 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_assign +// CHECK: location +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line16 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line16 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'q') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'q') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'q') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_assign_transitive +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line23 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Assuming 'p' is null +// CHECK: message +// CHECK: Assuming 'p' is null +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_cond +// CHECK: location +// CHECK: +// CHECK: line24 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line31 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line31 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line31 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line31 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line32 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line32 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line32 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line32 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line32 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_cond_transitive +// CHECK: location +// CHECK: +// CHECK: line32 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line39 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line39 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line39 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line39 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line39 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from field 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from field 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from field 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_null_field +// CHECK: location +// CHECK: +// CHECK: line39 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line44 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line44 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line44 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line44 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line44 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line44 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line51 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_assumptions +// CHECK: location +// CHECK: +// CHECK: line51 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line57 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Assuming 'p' is null +// CHECK: message +// CHECK: Assuming 'p' is null +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line59 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_cond_assign +// CHECK: location +// CHECK: +// CHECK: line59 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line77 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line77 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line77 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line77 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line78 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line78 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line78 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line78 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line78 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindObjective-C method +// CHECK: issue_contexttest +// CHECK: location +// CHECK: +// CHECK: line78 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: + 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 { +} +@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 - (NSUInteger)count; +@end @interface NSMutableArray : NSArray - (void)addObject:(id)anObject; +@end typedef unsigned short unichar; +@interface NSString : NSObject - (NSUInteger)length; +- (int)intValue; +@end @interface NSSimpleCString : NSString { +} +@end @interface NSConstantString : NSSimpleCString @end extern void *_NSConstantStringClassReference; +@interface NSDictionary : NSObject - (NSUInteger)count; +@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; +@end typedef struct { +} +CMProfileLocation; +@interface NSResponder : NSObject { +} +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView; +@interface NSCell : NSObject { +} +@end extern NSString *NSControlTintDidChangeNotification; +@interface NSActionCell : NSCell { +} +@end @class NSArray, NSDocument, NSWindow; +@interface NSWindowController : NSResponder { +} +@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 { +} +- (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 {} +- (id)init; ++ (id)alloc; +@end +typedef double NSTimeInterval; +enum { NSAnimationEaseInOut, NSAnimationEaseIn, NSAnimationEaseOut, NSAnimationLinear }; +typedef NSUInteger NSAnimationCurve; +@interface NSAnimation : NSObject {} +- (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 {} ++(id)alloc; +-(id)init; +-(id)autorelease; +-(id)copy; +-(id)retain; +@end +@interface NSString : NSObject +- (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 + +// 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=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=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=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 {} @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 {} +@end extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSResponder : NSObject {} +@end @protocol NSAnimatablePropertyContainer - (id)animator; +@end extern NSString *NSAnimationTriggerOrderIn ; +@interface NSView : NSResponder { +} +@end enum { +NSNullCellType = 0, NSTextCellType = 1, NSImageCellType = 2 }; +typedef struct __CFlags { + unsigned int botnet:3; +} + _CFlags; +@interface Bar : NSObject { + _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 {} @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 { +} +@end @class NSArray; +@interface NSResponder : NSObject { +} +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView; +@class JabasectItem; +@protocol EcoClassifier; +@protocol EcoClassInterfaceCommons @end @protocol EcoImplementation; +@protocol EcoBehavioredClassifier - (NSArray *) implementations; +@end enum { +CK_UNRESTRICTED= 0, CK_READ_ONLY, CK_ADD_ONLY, CK_REMOVE_ONLY }; +@protocol EcoClass - (NSArray *) ownedAttributes; +@end @protocol EcoNamespace; +@protocol EcoType; +@protocol EcoClassifier - (NSArray *) features; +@end @protocol EcoComment; +@protocol EcoElement - (NSArray *) ownedElements; +@end @protocol EcoDirectedRelationship; +@protocol EcoNamedElement - (NSString *) name; +@end extern NSString *const JabaPathSeparator; +@protocol EcoNamespace - (NSArray *) Legs; +@end enum { +PDK_IN=0, PDK_INOUT, PDK_OUT, PDK_RETURN }; +@interface EcoElementImp : NSObject { +} +@end @class EcoNamespace; +@interface EcoNamedElementImp : EcoElementImp { +} +@end @interface EcoNamespaceImp : EcoNamedElementImp { +} +@end @class JabaSCDocController, JabaSCDisplaySpecification; +@interface JabaSCSharedDiagramViewController : NSObject { +} +@end extern NSString *const JabaSCsectGraphicNamesectIdentifier; +@interface EcoClassifierImp : EcoNamespaceImp { +} +@end @class EcoOperationImp; +@interface EcoClassImp : EcoClassifierImp { +} +@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 - (JabaSourceLanguage)language; +@end @interface JabaSCClass : EcoClassImp { +} +@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 selectedElement = [sectItem representedObject]; + id 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 {} ++ (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 - (void)getValue:(void *)value; +@end @interface NSNumber : NSValue - (char)charValue; +- (id)initWithInt:(int)value; +@end @class NSString; +@interface NSArray : NSObject - (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 - (NSTimeInterval)timeIntervalSinceReferenceDate; +@end typedef unsigned short unichar; +@interface NSString : NSObject - (NSUInteger)length; +- ( const char *)UTF8String; +- (id)initWithUTF8String:(const char *)nullTerminatedCString; ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end @class NSString, NSURL, NSError; +@interface NSData : NSObject - (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 - (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 { +} +@end @protocol NSAnimatablePropertyContainer - (id)animator; +@end extern NSString *NSAnimationTriggerOrderIn ; +@interface NSView : NSResponder { +} +@end @protocol NSValidatedUserInterfaceItem - (SEL)action; +@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id )anItem; +@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; +@interface NSApplication : NSResponder { +} +@end enum { +NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; +typedef NSUInteger NSApplicationTerminateReply; +@protocol NSApplicationDelegate @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; +@interface NSCell : NSObject { +} +@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; +typedef struct { +} +CVTimeStamp; +@interface CIImage : NSObject { +} +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 { +} +- (id) createSnapshotImageOfType:(NSString*)type; +@end extern NSString* const QCViewDidStartRenderingNotification; +@interface QCView : NSView { +} +- (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 @required - (void)didRemoveDevice:(ICDevice*)device; +@end extern NSString *const ICScannerStatusWarmingUp; +@class ICScannerDevice; +@protocol ICScannerDeviceDelegate @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 + +//===----------------------------------------------------------------------===// +// 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 + +//===----------------------------------------------------------------------===// +// '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}} +} + +//===----------------------------------------------------------------------===// +// 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}} +} + + +//===----------------------------------------------------------------------===// +// 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 +// #include +// #include +// #include +// #include +// #include +// +// 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 {} ++ (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 - (void)getValue:(void *)value; +@end @interface NSNumber : NSValue - (char)charValue; +- (id)initWithInt:(int)value; +@end @class NSString; +@interface NSArray : NSObject - (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 - (NSTimeInterval)timeIntervalSinceReferenceDate; +@end typedef unsigned short unichar; +@interface NSString : NSObject +- (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 - (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 - (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 { +} +@end @protocol NSAnimatablePropertyContainer - (id)animator; +@end extern NSString *NSAnimationTriggerOrderIn ; +@interface NSView : NSResponder { +} +@end @protocol NSValidatedUserInterfaceItem - (SEL)action; +@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id )anItem; +@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; +@interface NSApplication : NSResponder { +} +@end enum { +NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; +typedef NSUInteger NSApplicationTerminateReply; +@protocol NSApplicationDelegate @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; +@interface NSCell : NSObject { +} +@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; +typedef struct { +} +CVTimeStamp; +@interface CIImage : NSObject { +} +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 { +} +- (id) createSnapshotImageOfType:(NSString*)type; +@end extern NSString* const QCViewDidStartRenderingNotification; +@interface QCView : NSView { +} +- (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 @required - (void)didRemoveDevice:(ICDevice*)device; +@end extern NSString *const ICScannerStatusWarmingUp; +@class ICScannerDevice; +@protocol ICScannerDeviceDelegate @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 {} +- (id)init; ++ (id)allocWithZone:(NSZone *)zone; ++ (id)alloc; +- (void)dealloc; +@end +typedef float CGFloat; +typedef double NSTimeInterval; +@interface NSDate : NSObject - (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 + +//===------------------------------------------------------------------------------------------===// +// (also ) - 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 + } +} + +// 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 +// #include +// #include +// #include +// #include +// #include +// +// 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 {} ++ (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 - (void)getValue:(void *)value; +@end @interface NSNumber : NSValue - (char)charValue; +- (id)initWithInt:(int)value; +@end @class NSString; +@interface NSArray : NSObject +- (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 - (NSTimeInterval)timeIntervalSinceReferenceDate; +@end typedef unsigned short unichar; +@interface NSString : NSObject +- (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 - (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 +- (NSUInteger)count; ++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])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 { +} +@end @protocol NSAnimatablePropertyContainer - (id)animator; +@end extern NSString *NSAnimationTriggerOrderIn ; +@interface NSView : NSResponder { +} +@end @protocol NSValidatedUserInterfaceItem - (SEL)action; +@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id )anItem; +@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; +@interface NSApplication : NSResponder { +} +@end enum { +NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; +typedef NSUInteger NSApplicationTerminateReply; +@protocol NSApplicationDelegate @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; +@interface NSCell : NSObject { +} +@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; +typedef struct { +} +CVTimeStamp; +@interface CIImage : NSObject { +} +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 { +} +- (id) createSnapshotImageOfType:(NSString*)type; +@end extern NSString* const QCViewDidStartRenderingNotification; +@interface QCView : NSView { +} +- (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 @required - (void)didRemoveDevice:(ICDevice*)device; +@end extern NSString *const ICScannerStatusWarmingUp; +@class ICScannerDevice; +@protocol ICScannerDeviceDelegate @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 + +// +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 . The problem here is that 'length' binds to +// '($0 - 1)' after '--length', but SimpleConstraintManager doesn't know how to +// reason about '($0 - 1) > constant'. As a temporary hack, we drop the value +// of '($0 - 1)' and conjure a new symbol. +void rdar6704930(unsigned char *s, unsigned int length) { + NSString* name = 0; + if (s != 0) { + if (length > 0) { + while (length > 0) { + if (*s == ':') { + ++s; + --length; + name = [[NSString alloc] init]; // no-warning + break; + } + ++s; + --length; + } + if ((length == 0) && (name != 0)) { + [name release]; + name = 0; + } + if (length == 0) { // no ':' found -> use it all as name + name = [[NSString alloc] init]; // no-warning + } + } + } + + if (name != 0) { + [name release]; + } +} + +//===----------------------------------------------------------------------===// +// +// One build of the analyzer accidentally stopped tracking the allocated +// object after the 'retain'. +//===----------------------------------------------------------------------===// + +@interface rdar_6833332 : NSObject { + 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 + +//===----------------------------------------------------------------------===// +// 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; +} + +//===----------------------------------------------------------------------===// +// Analyzer is confused about NSAutoreleasePool -allocWithZone:. +//===----------------------------------------------------------------------===// + +void rdar_10640253_autorelease_allocWithZone() { + NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init]; + (void) pool; +} + +//===----------------------------------------------------------------------===// +// 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]; +} + + +//===----------------------------------------------------------------------===// +// 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 + +//===----------------------------------------------------------------------===// +// 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; +} + +//===----------------------------------------------------------------------===// +// -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 + +//===----------------------------------------------------------------------===// +// [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 + +//===----------------------------------------------------------------------===// +// 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 + +//===----------------------------------------------------------------------===// +// clang: false positives w/QC and CoreImage methods +//===----------------------------------------------------------------------===// + +void rdar6902710(QCView *view, QCRenderer *renderer, CIContext *context, + NSString *str, CIImage *img, CGRect rect, + CIFormat form, CGColorSpaceRef cs) { + [view createSnapshotImageOfType:str]; // expected-warning{{leak}} + [renderer createSnapshotImageOfType:str]; // expected-warning{{leak}} + [context createCGImage:img fromRect:rect]; // expected-warning{{leak}} + [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}} +} + +//===----------------------------------------------------------------------===// +// -[CIContext createCGLayerWithSize:info:] +// misinterpreted by clang scan-build +//===----------------------------------------------------------------------===// + +void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) { + [context createCGLayerWithSize:size info:d]; // expected-warning{{leak}} +} + +//===----------------------------------------------------------------------===// +// add knowledge of IOKit functions to retain/release +// checker +//===----------------------------------------------------------------------===// + +void IOBSDNameMatching_wrapper(mach_port_t 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 *); + +// +void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) { + CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + CFDictionaryAddValue(y, key, x); + CFRelease(x); // the dictionary keeps a reference, so the object isn't deallocated yet + signed z = 1; + CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); + if (value) { + CFDictionaryAddValue(x, val_key, (void*)value); // no-warning + CFRelease(value); + CFDictionaryAddValue(y, val_key, (void*)value); // no-warning + } +} + +// +// Same issue, except with "AppendValue" functions. +void rdar_6560661(CFMutableArrayRef x) { + signed z = 1; + CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); + // CFArrayAppendValue keeps a reference to value. + CFArrayAppendValue(x, value); + CFRelease(value); + CFRetain(value); + CFRelease(value); // no-warning +} + +// +// Same issue, excwept with "CFAttributeStringSetAttribute". +void rdar_7152619(CFStringRef str) { + CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, str, 0); + CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 100, string); + CFRelease(string); + NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} + CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 1), str, number); + [number release]; + [number retain]; + CFRelease(attrString); +} + +//===----------------------------------------------------------------------===// +// Test of handling CGGradientXXX functions. +//===----------------------------------------------------------------------===// + +void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, + CGPoint myEndPoint) { + size_t num_locations = 6; + CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; + CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, + x, // Start color + 207.0/255.0, 39.0/255.0, 39.0/255.0, x, + 147.0/255.0, 21.0/255.0, 22.0/255.0, x, + 175.0/255.0, 175.0/255.0, 175.0/255.0, x, + 255.0/255.0,255.0/255.0, 255.0/255.0, x, + 255.0/255.0,255.0/255.0, 255.0/255.0, x + }; // End color + + CGGradientRef myGradient = + CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), // expected-warning{{leak}} + components, locations, num_locations); + + CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, + 0); + CGGradientRelease(myGradient); +} + +void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, + CGPoint myEndPoint) { + size_t num_locations = 6; + CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; + CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, + x, // Start color + 207.0/255.0, 39.0/255.0, 39.0/255.0, x, + 147.0/255.0, 21.0/255.0, 22.0/255.0, x, + 175.0/255.0, 175.0/255.0, 175.0/255.0, x, + 255.0/255.0,255.0/255.0, 255.0/255.0, x, + 255.0/255.0,255.0/255.0, 255.0/255.0, x + }; // End color + + CGGradientRef myGradient = + CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations); // expected-warning 2 {{leak}} + + CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, + 0); +} + +//===----------------------------------------------------------------------===// +// clang false positive: retained instance passed to +// thread in pthread_create marked as leak +// +// Until we have full IPA, the analyzer should stop tracking the reference +// count of objects passed to pthread_create. +// +//===----------------------------------------------------------------------===// + +struct _opaque_pthread_t {}; +struct _opaque_pthread_attr_t {}; +typedef struct _opaque_pthread_t *__darwin_pthread_t; +typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; +typedef __darwin_pthread_t pthread_t; +typedef __darwin_pthread_attr_t pthread_attr_t; + +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}} +} + +//===----------------------------------------------------------------------===// +// False leak associated with call to +// CVPixelBufferCreateWithBytes () +// +// According to the Core Video Reference (ADC), CVPixelBufferCreateWithBytes and +// CVPixelBufferCreateWithPlanarBytes can release (via a callback) the +// pixel buffer object. These test cases show how the analyzer stops tracking +// the reference count for the objects passed for this argument. This +// could be made smarter. +//===----------------------------------------------------------------------===// + +typedef int int32_t; +typedef UInt32 FourCharCode; +typedef FourCharCode OSType; +typedef uint64_t CVOptionFlags; +typedef int32_t CVReturn; +typedef struct __CVBuffer *CVBufferRef; +typedef CVBufferRef CVImageBufferRef; +typedef CVImageBufferRef CVPixelBufferRef; +typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress ); + +extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, + size_t width, + size_t height, + OSType pixelFormatType, + void *baseAddress, + size_t bytesPerRow, + CVPixelBufferReleaseBytesCallback releaseCallback, + void *releaseRefCon, + CFDictionaryRef pixelBufferAttributes, + CVPixelBufferRef *pixelBufferOut) ; + +typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] ); + +extern CVReturn CVPixelBufferCreateWithPlanarBytes(CFAllocatorRef allocator, + size_t width, + size_t height, + OSType pixelFormatType, + void *dataPtr, + size_t dataSize, + size_t numberOfPlanes, + void *planeBaseAddress[], + size_t planeWidth[], + size_t planeHeight[], + size_t planeBytesPerRow[], + CVPixelBufferReleasePlanarBytesCallback releaseCallback, + void *releaseRefCon, + CFDictionaryRef pixelBufferAttributes, + CVPixelBufferRef *pixelBufferOut) ; + +extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, + size_t width, + size_t height, + OSType pixelFormatType, + void *baseAddress, + size_t bytesPerRow, + CVPixelBufferReleaseBytesCallback releaseCallback, + void *releaseRefCon, + CFDictionaryRef pixelBufferAttributes, + CVPixelBufferRef *pixelBufferOut) ; + +CVReturn rdar_7283567(CFAllocatorRef allocator, size_t width, size_t height, + OSType pixelFormatType, void *baseAddress, + size_t bytesPerRow, + CVPixelBufferReleaseBytesCallback releaseCallback, + CFDictionaryRef pixelBufferAttributes, + CVPixelBufferRef *pixelBufferOut) { + + // For the allocated object, it doesn't really matter what type it is + // for the purpose of this test. All we want to show is that + // this is freed later by the callback. + NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning + + return CVPixelBufferCreateWithBytes(allocator, width, height, pixelFormatType, + baseAddress, bytesPerRow, releaseCallback, + number, // potentially released by callback + pixelBufferAttributes, pixelBufferOut) ; +} + +CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height, + OSType pixelFormatType, void *dataPtr, size_t dataSize, + size_t numberOfPlanes, void *planeBaseAddress[], + size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[], + CVPixelBufferReleasePlanarBytesCallback releaseCallback, + CFDictionaryRef pixelBufferAttributes, + CVPixelBufferRef *pixelBufferOut) { + + // For the allocated object, it doesn't really matter what type it is + // for the purpose of this test. All we want to show is that + // this is freed later by the callback. + NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning + + return CVPixelBufferCreateWithPlanarBytes(allocator, + width, height, pixelFormatType, dataPtr, dataSize, + numberOfPlanes, planeBaseAddress, planeWidth, + planeHeight, planeBytesPerRow, releaseCallback, + number, // potentially released by callback + pixelBufferAttributes, pixelBufferOut) ; +} + +//===----------------------------------------------------------------------===// +// False leak associated with +// CGBitmapContextCreateWithData +//===----------------------------------------------------------------------===// +typedef uint32_t CGBitmapInfo; +typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data); + +CGContextRef CGBitmapContextCreateWithData(void *data, + size_t width, size_t height, size_t bitsPerComponent, + size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, + CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo); + +void rdar_7358899(void *data, + size_t width, size_t height, size_t bitsPerComponent, + size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, + CGBitmapContextReleaseDataCallback releaseCallback) { + + // For the allocated object, it doesn't really matter what type it is + // for the purpose of this test. All we want to show is that + // this is freed later by the callback. + NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning + + CGBitmapContextCreateWithData(data, width, height, bitsPerComponent, // expected-warning{{leak}} + bytesPerRow, space, bitmapInfo, releaseCallback, number); +} + +//===----------------------------------------------------------------------===// +// allow 'new', 'copy', 'alloc', 'init' prefix to +// start before '_' when determining Cocoa fundamental rule +// +// Previously the retain/release checker just skipped prefixes before the +// first '_' entirely. Now the checker honors the prefix if it results in a +// recognizable naming convention (e.g., 'new', 'init'). +//===----------------------------------------------------------------------===// + +@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]; +} + +//===----------------------------------------------------------------------===// +// 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}} +} + +//===----------------------------------------------------------------------===// +// 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. +// +// 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 , 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 + +// - Correcly handle Class<...> in Cocoa Conventions +// detector. + +@protocol Prot_R8272168 @end +Class GetAClassThatImplementsProt_R8272168(); +void r8272168() { + GetAClassThatImplementsProt_R8272168(); +} + +// Test case for , 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 + +// - This test case previously crashed because +// of a bug in BugReporter. +extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); +typedef struct __CFError * CFErrorRef; +extern const CFStringRef kCFErrorUnderlyingErrorKey; +extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err); +static void rdar_8724287(CFErrorRef error) +{ + CFErrorRef error_to_dump; + + error_to_dump = error; + while (error_to_dump != ((void*)0)) { + CFDictionaryRef info; + + info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}} + + if (info != ((void*)0)) { + } + + error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey); + } +} + +// - Make sure the model applies cf_consumed +// correctly in argument positions besides the first. +extern void *CFStringCreate(void); +extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value); +void rdar_9234108() { + rdar_9234108_helper(0, CFStringCreate()); +} + +// - Make sure that objc_method_family works +// to override naming conventions. +struct TwoDoubles { + double one; + double two; +}; +typedef struct TwoDoubles TwoDoubles; + +@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]; +} + +// +// 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 @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 +} + +// - 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. +// +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 +// #include +// #include +// #include +// #include +// #include +// +// 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 {} ++ (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 - (void)getValue:(void *)value; +@end @interface NSNumber : NSValue - (char)charValue; +- (id)initWithInt:(int)value; +@end @class NSString; +@interface NSArray : NSObject - (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 - (NSTimeInterval)timeIntervalSinceReferenceDate; +@end typedef unsigned short unichar; +@interface NSString : NSObject - (NSUInteger)length; +- ( const char *)UTF8String; +- (id)initWithUTF8String:(const char *)nullTerminatedCString; ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end @class NSString, NSURL, NSError; +@interface NSData : NSObject - (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 - (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 { +} +@end @protocol NSAnimatablePropertyContainer - (id)animator; +@end extern NSString *NSAnimationTriggerOrderIn ; +@interface NSView : NSResponder { +} +@end @protocol NSValidatedUserInterfaceItem - (SEL)action; +@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id )anItem; +@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; +@interface NSApplication : NSResponder { +} +@end enum { +NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; +typedef NSUInteger NSApplicationTerminateReply; +@protocol NSApplicationDelegate @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; +@interface NSCell : NSObject { +} +@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; +typedef struct { +} +CVTimeStamp; +@interface CIImage : NSObject { +} +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 { +} +- (id) createSnapshotImageOfType:(NSString*)type; +@end extern NSString* const QCViewDidStartRenderingNotification; +@interface QCView : NSView { +} +- (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 @required - (void)didRemoveDevice:(ICDevice*)device; +@end extern NSString *const ICScannerStatusWarmingUp; +@class ICScannerDevice; +@protocol ICScannerDeviceDelegate @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 T static_objc_cast(U* value) +{ + // ...debugging code omitted... + return static_cast(value); +} + +int rdar10553686(void) +{ + NSObject* bar = static_objc_cast([[NSObject alloc] init]); + [bar release]; + return 0; +} +int rdar10553686_positive(void) +{ + NSObject* bar = static_objc_cast([[NSObject alloc] init]); + [bar release]; + [bar retain]; // expected-warning {{used after it is released}} + return 0; +} + +@interface NSMapTable : NSObject +@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; + + +// 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'}} +} + +// 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().}} +} + +// 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}} +} + +// 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 {} ++ (id)allocWithZone:(NSZone *)zone; ++ (id)alloc; +- (void)dealloc; +-(id)class; +-(id)init; +-(id)release; +@end +@interface NSProxy {} +@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 +- (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 +- (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 +} + +// +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'. +// +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 +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 {} ++ (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 - (void)getValue:(void *)value; +@end @interface NSNumber : NSValue - (char)charValue; +- (id)initWithInt:(int)value; +@end @class NSString; +@interface NSArray : NSObject - (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 - (NSTimeInterval)timeIntervalSinceReferenceDate; +@end + +@interface NSString : NSObject +- (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 - (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 + +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 + +@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 {} @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 +- (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 {} ++ (id)alloc; +- (id)init; +@end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSValue : NSObject - (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: + +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 . 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}} +} + +// +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 {} +- (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. () +@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 + +//===----------------------------------------------------------------------===// +// 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 + +//===----------------------------------------------------------------------===// +// - 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 + +//===----------------------------------------------------------------------===// +// - consult attribute((unused)) to silence warnings +// about unused instance variables +//===----------------------------------------------------------------------===// + +@interface RDar7353683 { +@private + id x __attribute__((unused)); +} +@end + +@implementation RDar7353683 +@end +//===----------------------------------------------------------------------===// +// 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 {} +- (id)init; ++ (id)alloc; +@end +typedef struct {} NSFastEnumerationState; +@protocol NSFastEnumeration +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; +@end +@interface NSArray : NSObject +@end +@interface NSArray (NSArrayCreation) ++ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); +- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); +@end +@interface NSDictionary : NSObject +@end +@interface NSDictionary (NSDictionaryCreation) ++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1))); +- (id)initWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1))); +@end +@interface NSSet : NSObject +@end +@interface NSSet (NSSetCreation) ++ (id)setWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); +- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); +@end +@interface NSOrderedSet : NSObject +@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

b, C* c, C

*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 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 , but we don't have that yet. +namespace std { + class type_info; +} + +struct Poly { + virtual ~Poly(); +}; + +struct NonPoly { }; + +template +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 xp, X xpr, X xnp, X 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 struct Y { }; +} + +namespace N3 { + void test() { + int &ir = f((N2::Y*)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 A { + template friend void foo(A &, U); // expected-note {{not viable: 1st argument ('const A') would lose const qualifier}} + + public: + A(); + }; + + void test() { + const A 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 +struct set{}; // expected-note{{lookup from the current scope refers here}} +struct Value { + template + void set(T value) {} // expected-note{{lookup in the object type 'Value' refers here}} + + void resolves_to_same() { + Value v; + v.set(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(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(3.2); + } +} + +namespace rdar9915664 { + struct A { + template void a(); + }; + + struct B : A { }; + + struct C : A { }; + + struct D : B, C { + A &getA() { return static_cast(*this); } + + void test_a() { + getA().a(); + } + }; +} + +namespace PR11856 { + template T end(T); + + template + void Foo() { + T it1; + if (it1->end < it1->end) { + } + } + + template T *end(T*); + + class X { }; + template + 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 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 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 class Ident {}; // expected-note {{previous use is here}} + +namespace A { + template void Ident(); + + class Ident AIdent; // expected-error {{refers to a function template}} + class ::Ident AnotherIdent; +} + +class Ident GlobalIdent; +union Ident 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 +struct X1 { + X1(int); + (X1)(float); + X1 f2(); + X1 f2(int); + X1 f2(float); +}; + +// Error recovery: out-of-line constructors whose names have template arguments. +template X1::X1(int) { } // expected-error{{out-of-line constructor for 'X1' cannot have template arguments}} +template (X1::X1)(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 X1::X1 X1::f2() { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}} +template X1::X1 (X1::f2)(int) { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}} +template struct X1::X1 (X1::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 +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 struct bar {}; + template struct foo : bar {}; // 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 struct X0 { }; +template<> struct X0 { static const bool value = true; }; +int array0[X0<>::value? 1 : -1]; + +// Non-type template parameters. +const int N = 17; +template struct X1 { }; +template<> struct X1<17> { static const bool value = true; }; +int array1[X1<>::value? 1 : -1]; + +// Template template parameters. +template class X0 = X0> struct X2 { }; +template<> struct X2 { 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 +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 + +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 void *operator new(size_t, int); +}; + +struct G { + template T operator new(size_t, int); // expected-error {{'operator new' cannot have a dependent return type; use 'void *' instead}} +}; + +struct H { + template void *operator new(T, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}} +}; + +struct I { + template 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 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 classtemplate = {}; +constexpr ClassTemp 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 +struct DerivedFromNonTrivDtor : T { // expected-note {{'DerivedFromNonTrivDtor' is not literal because it has base class 'NonTrivDtorBase' of non-literal type}} + constexpr DerivedFromNonTrivDtor(); +}; +constexpr int f(DerivedFromNonTrivDtor) { return 0; } // expected-error {{constexpr function's 1st parameter type 'DerivedFromNonTrivDtor' 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 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 +struct CtorArg { + constexpr CtorArg(T); +}; +constexpr int f(CtorArg) { return 0; } // ok +constexpr int f(CtorArg) { 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 struct DerivedFromVBase : T { // expected-note {{struct with virtual base class is not a literal type}} + constexpr DerivedFromVBase(); +}; +constexpr int f(DerivedFromVBase) {} // expected-error {{constexpr function's 1st parameter type 'DerivedFromVBase' is not a literal type}} +template constexpr DerivedFromVBase::DerivedFromVBase() : T() {} +constexpr int nVBase = (DerivedFromVBase(), 0); // expected-error {{constant expression}} expected-note {{cannot construct object of type 'DerivedFromVBase' 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 +struct MemberType { + T t; // expected-note {{'MemberType' is not literal because it has data member 't' of non-literal type 'NonLiteral'}} + constexpr MemberType(); +}; +constexpr int f(MemberType) { return 0; } +constexpr int f(MemberType) { 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 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 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 struct B : A { + A::type; // expected-error {{dependent using declaration resolved to type without 'typename'}} // 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-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::hiding local; + struct hiding _ = local(); + } + + void test2() { + typedef struct A::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; // 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 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 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 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 struct X { + X(); + ~X(); + void foo(); + void bar(); + }; + + class A { + friend void X::foo(); + friend X::X(); + friend X::X(const X&); + + private: + A(); // expected-note 2 {{declared private here}} + }; + + template<> void X::foo() { + A a; + } + + template<> void X::bar() { + A a; // expected-error {{calling a private constructor}} + } + + template<> X::X() { + A a; + } + + template<> X::~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 friend I g(I i); + }; + + const A::I A::x; + A::I f(A::I i = A::x) {} + template A::I g(A::I i) { + T t; + } + template A::I g(A::I i); + + A::I f2(A::I i = A::x) {} // expected-error 3 {{is a private member of}} + template A::I g2(A::I i) { // expected-error 2 {{is a private member of}} + T t; + } + template A::I g2(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(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 +class X0 { + friend T; // expected-warning{{non-class friend type 'T' is a C++11 extension}} +}; + +class X1 { }; +enum E1 { }; +X0 x0a; +X0 x0b; +X0 x0c; +X0 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 +class X0 { + friend T; +}; + +class Y1 { }; +enum E1 { }; +X0 x0a; +X0 x0b; +X0 x0c; +X0 x0d; + +template +class X1 { + friend typename T::type; // expected-error{{no type named 'type' in 'Y1'}} +}; + +struct Y2 { + struct type { }; +}; + +struct Y3 { + typedef int type; +}; + +X1 x1a; +X1 x1b; +X1 x1c; // expected-note{{in instantiation of template class 'X1' 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 class A { + protected: + int foo(); + int foo() const; + + ~A() { foo(); } + }; + + template class A; +} + +// 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 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 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 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 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 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'}} + static int protected_sfoo; // expected-note 3 {{declared protected here}} + + int test1(A &a) { + return a.private_foo; // expected-error {{private member}} + } + + int test2(A &a) { + return a.private_sfoo; // expected-error {{private member}} + } + + int test3(A &a) { + return a.protected_foo; // expected-error {{protected member}} + } + + int test4(A &a) { + return a.protected_sfoo; // expected-error {{protected member}} + } + }; + + template class A; + template class A; // expected-note 4 {{in instantiation}} + + template class B : public A { + // TODO: These first two accesses can be detected as ill-formed at + // definition time because they're member accesses and A can't + // be a subclass of B for any T. + + int test1(A &a) { + return a.protected_foo; // expected-error 2 {{protected member}} + } + + int test2(A &a) { + return a.protected_sfoo; // expected-error {{protected member}} + } + + int test3(B &b) { + return b.protected_foo; // expected-error {{protected member}} + } + + int test4(B &b) { + return b.protected_sfoo; // expected-error {{protected member}} + } + }; + + template class B; // expected-note {{in instantiation}} + template class B; // 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 class Inner { }; // expected-note {{declared private here}} + }; + + A::Inner s; // expected-error {{'Inner' is a private member of 'test17::A'}} +} + +namespace test18 { + template class A {}; + class B : A { + A 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 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 A { + void foo(); + void bar(); + class Inner; // expected-note {{implicitly declared private here}} + public: + void baz(); + }; + template class A::Inner {}; + class B { + template class A::Inner; // expected-error{{non-friend class member 'Inner' cannot have a qualified name}} + }; + + void test() { + A::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 class A { + A(); + static A instance; + }; + + template A A::instance; + template class A; +} 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 static void set(T &t, typename T::type v) { + t.value = v; + } + template 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 A { + }; + }; + + template class Outer::A { + public: + static void foo(); + }; + + class B { + private: typedef Green nature; + friend class Outer; + }; + + void test() { + Outer::A::foo(); + Outer::A::foo(); // expected-error {{no member named 'foo'}} + } +} + +namespace test4 { + template class A { + private: typedef int type; + template friend void foo(U &, typename U::type); + }; + + template void foo(U &, typename U::type) {} + + void test() { + A a; + foo(a, 0); + } +} + +// PR7644 +namespace test5 { + class A { + enum Enum { E0, E1, E2 }; // expected-note 4 {{declared private here}} + template void foo(); + template class bar; + }; + + template void A::foo() {} + template class A::bar {}; + + template void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}} + template class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} + + class B { + template void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}} + template 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 + 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 +struct BaseT { + void Foo(); // expected-note{{found by ambiguous name lookup}} + int Member; +}; + +template struct Derived1T : BaseT { }; +template struct Derived2T : BaseT { }; + +template +struct DerivedT : public Derived1T, public Derived2T { + void Inner(); +}; + +template +void DerivedT::Inner() { + Derived1T::Foo(); + Derived2T::Member = 42; + this->Derived1T::Foo(); + this->Derived2T::Member = 42; + this->Foo(); // expected-error{{non-static member 'Foo' found in multiple base-class subobjects of type 'BaseT'}} +} + +template +void Test(DerivedT d) { + d.template Derived1T::Foo(); + d.template Derived2T::Member = 17; + d.Inner(); // expected-note{{in instantiation}} +} + +template void Test(DerivedT); 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 +struct B : A { + virtual void f(T) override; +}; + +} + +namespace Test3 { + +struct A { + virtual void f(int, char, int); +}; + +template +struct B : A { + virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}} +}; + +template struct B; +template struct B; // expected-note {{in instantiation of template class 'Test3::B' 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 + struct Derived3 : decltype(T().foo()) { }; + struct Foo { Base foo(); }; + Derived3 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 + 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(b2)); + b = b; + b = static_cast(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 Inner { + public: + void foo(bool bar = true); + int bam; + }; + + Inner _foo; + }; + + void f() { + X::Inner c2i; + X::Inner 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 struct A { + A x; // expected-error {{implicit instantiation of template 'test1::A' within its own definition}} + }; +} + +namespace test2 { + template struct A; + template <> struct A {}; + template struct A { + A x; + }; +} + +namespace test3 { + struct A { + struct B { + void f() throw(A); + void g() throw(B); + }; + + void f() throw(A); + void g() throw(B); + }; + + template + struct A2 { + struct B { + void f1() throw(A2); + void f2() throw(A2); + void g() throw(B); + }; + + void f1() throw(A2); + void f2() throw(A2); + void g() throw(B); + }; + + template struct A2; +} 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 struct B; + template struct C; + + template struct A { + void foo(); + + void test0() { + Unrelated::foo(); // expected-error {{call to non-static member function without an object argument}} + } + + void test1() { + B::foo(); + } + + static void test2() { + B::foo(); // expected-error {{call to non-static member function without an object argument}} + } + + void test3() { + C::foo(); // expected-error {{no member named 'foo'}} + } + }; + + template struct B : A { + }; + + template struct C { + }; + + int test() { + A 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 +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 constexpr T U::d = T(); // expected-error {{non-literal type 'const NonLit'}} + +U u1; +U u2; // expected-note {{here}} + +static_assert(U::a == 0, ""); + +constexpr int outofline = (U::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 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:: 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 virt(0); // expected-note {{in instantiation of template}} + Either vbase(0); // expected-note {{in instantiation of template}} + Either ctor(0); // expected-note {{in instantiation of template}} + Either copyctor(0); // expected-note {{in instantiation of template}} + Either copyassign(0); // expected-note {{in instantiation of template}} + Either dtor(0); // expected-note {{in instantiation of template}} + Either 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 +union U2 { + static const int k1; + static double k2; + T t; +}; +template constexpr int U2::k1 = sizeof(U2); +template double U2::k2 = 5.3; + +static_assert(U2::k1 == sizeof(int), ""); +static_assert(U2::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 struct A final { }; // expected-note 2 {{'A' declared here}} +struct B : A { }; // expected-error {{base 'A' is marked 'final'}} + +template struct C : A { }; // expected-error {{base 'A' is marked 'final'}} +struct D : C { }; // expected-note {{in instantiation of template class 'Test2::C' requested here}} + +} + +namespace Test3 { + +template struct A { }; +template<> struct A final { }; // expected-note {{'A' declared here}} + +struct B : A { }; +struct C : A { }; // 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 + +// 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 struct X0 { }; +struct X1 { }; + +struct Y { + template union X0; + template friend union X0; + + union X1; + friend union X1; +}; + +namespace N { + namespace M { + template class X; + } +} + +namespace N3 { + class Y { + template 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 void f(T); + namespace ns { + class A { + friend void f(int); + static void foo(); // expected-note 2 {{declared private here}} + }; + + // Note that this happens without instantiation. + template void f(T) { + A::foo(); // expected-error {{'foo' is a private member of 'test5::ns::A'}} + } + } + + template void f(T) { + ns::A::foo(); // expected-error {{'foo' is a private member of 'test5::ns::A'}} + } + + template void f(int); + template void f(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 class C {}; + } + + // Specialize and partially specialize somewhere else. + template <> class C {}; + template class C {}; +} + +// 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 {}; +template class C {}; + +template class C; + + +// 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 allocator; + + template <> + class allocator + { + public: + typedef const void* const_pointer; + }; + + template + class allocator + { + public: + typedef Tp& reference; + + void allocate(allocator::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 void f(T) { } + template struct X2 { }; + int i = 71; + enum E { e }; + } + + void f(int) { } + struct X1 { }; + template void f(T) { } + template 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 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 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 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 class Test0 { + void test() { + int foo(T); + using ns::foo; + } + }; + + template class Test1 { + void test() { + using ns::foo; + int foo(T); + } + }; + + template class Test0; + template class Test1; +} 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 struct Opaque {}; +template void expect(Opaque _) {} + +// PR5727 +// This just shouldn't crash. +namespace test0 { + template struct RefPtr { }; + template struct PtrHash { + static void f() { } + }; + template struct PtrHash > : PtrHash { + using PtrHash::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 struct Derived1 : Base { + using Base::foo; + void foo(T); + + void testUnresolved(int i) { foo(i); } + }; + + void test0(int i) { + Derived1 d1; + d1.foo(i); + d1.testUnresolved(i); + } + + // Same thing, except with the order of members reversed. + template struct Derived2 : Base { + void foo(T); + using Base::foo; + + void testUnresolved(int i) { foo(i); } + }; + + void test1(int i) { + Derived2 d2; + d2.foo(i); + d2.testUnresolved(i); + } +} + +// Hiding of member templates. +namespace test3 { + struct Base { + template Opaque<0> foo() { return Opaque<0>(); } + template Opaque<1> foo() { return Opaque<1>(); } + }; + + struct Derived1 : Base { + using Base::foo; + template Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}} + }; + + struct Derived2 : Base { + template 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 Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}} + }; + + struct Derived4 : Base { + template 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()); + expect<1>(Base().foo<0>()); + expect<0>(Derived1().foo()); // expected-error {{no matching member function for call to 'foo'}} + expect<2>(Derived1().foo<0>()); + expect<0>(Derived2().foo()); // expected-error {{no matching member function for call to 'foo'}} + expect<2>(Derived2().foo<0>()); + expect<3>(Derived3().foo()); + expect<1>(Derived3().foo<0>()); // expected-error {{no matching member function for call to 'foo'}} + expect<3>(Derived4().foo()); + 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 void foo(T); + template void bar(T); // expected-note {{declared protected here}} + }; + + struct Derived : Base { + using Base::foo; + }; + + void test() { + Derived d; + d.foo(3); + d.bar(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 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 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 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 struct B : A { + using A::type; // expected-error {{dependent using declaration resolved to type without 'typename'}} + using A::hiding; + using A::union_member; + using A::enumerator; + using A::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::hiding local; + struct hiding _ = local(); + } + + void test2() { + typedef struct A::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; // expected-note {{in instantiation}} + + template struct C : A { + using typename A::type; + using typename A::hiding; // expected-note {{declared here}} \ + // expected-error {{'typename' keyword used on a non-type}} + using typename A::union_member; // expected-error {{'typename' keyword used on a non-type}} + using typename A::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; // 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 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 void f(T); + template struct X { }; +}; + +struct B : A { + using A::f; // expected-error{{using declaration can not refer to a template specialization}} + using A::X; // 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 struct Base { + typedef Base type; + void foo(); + }; + + template struct Derived : Base { + // These are invalid redeclarations, detectable only after + // instantiation. + using Base::foo; // expected-note {{previous using decl}} + using Base::type::foo; //expected-error {{redeclaration of using decl}} + }; + + template struct Derived; // 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 + +// +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 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 constexpr class TC1 {}; // expected-error {{class cannot be marked constexpr}} +template constexpr struct TS1 {}; // expected-error {{struct cannot be marked constexpr}} +template 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 constexpr T f5(T); +template constexpr T f5(T); // expected-note {{previous}} +template T f5(T); // expected-error {{non-constexpr declaration of 'f5' follows constexpr declaration}} +template T f6(T); // expected-note {{here}} +template 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 constexpr T ft(T t) { return t; } +template T gt(T t) { return t; } +struct S { + template constexpr T f(); + template 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' 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' 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 using Int = int; +template +struct TemplateInit { + T a; + int b; // desired-note {{not initialized}} + Int c; // desired-note {{not initialized}} + struct { + T d; + int e; // desired-note {{not initialized}} + Int 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 struct TemplateInit2 { + Literal l; + constexpr TemplateInit2() {} // ok +}; + +template struct weak_ptr { + constexpr weak_ptr() : p(0) {} + T *p; +}; +template struct enable_shared_from_this { + weak_ptr weak_this; + constexpr enable_shared_from_this() {} // ok +}; +constexpr int f(enable_shared_from_this); + +// - 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 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 +struct Y { + constexpr Y() {} + constexpr int get() { return T(); } +}; +struct Z { operator int(); }; + +int y1 = Y().get(); // ok +int y2 = Y().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 struct ImplicitVirtualFromDependentBase : T { + constexpr int ImplicitlyVirtual() { return 0; } +}; + +constexpr int a = ImplicitVirtualFromDependentBase().ImplicitlyVirtual(); // expected-error {{constant expression}} expected-note {{cannot evaluate virtual function call}} +constexpr int b = ImplicitVirtualFromDependentBase().ImplicitlyVirtual(); // ok +constexpr int c = ImplicitVirtualFromDependentBase().ImplicitVirtualFromDependentBase::ImplicitlyVirtual(); + +template struct ConstexprMember { + constexpr R F() { return 0; } +}; +constexpr int d = ConstexprMember().F(); // ok +constexpr int e = ConstexprMember().F(); // expected-error {{constant expression}} + +template struct ConstexprCtor { + constexpr ConstexprCtor(P...) {} +}; +constexpr ConstexprCtor<> f1() { return {}; } // ok +constexpr ConstexprCtor f2() { return 0; } // ok +constexpr ConstexprCtor f3() { return { 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}} +constexpr ConstexprCtor 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 struct T1 : virtual Literal { // expected-note {{here}} + constexpr T1() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}} + }; + + template 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 g2() { return {}; } + + template class T3 : public T { // expected-note {{class with virtual base class is not a literal type}} + public: + constexpr T3() {} + }; + constexpr T3 g3() { return {}; } // ok + constexpr T3 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 void f(T) {} +template static void g(T) {} + + +template<> static void f(int); // expected-error{{explicit specialization has extraneous, inconsistent storage class 'static'}} +template static void f(float); // expected-error{{explicit instantiation cannot have a storage class}} + +template<> void f(double); +template void f(long); + +template<> static void g(int); // expected-warning{{explicit specialization cannot have a storage class}} +template static void g(float); // expected-error{{explicit instantiation cannot have a storage class}} + +template<> void g(double); +template void g(long); + +template +struct X { + static int value; +}; + +template +int X::value = 17; + +template static int X::value; // expected-error{{explicit instantiation cannot have a storage class}} + +template<> static int X::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 struct U {}; + +void j() { + (void)typeid(auto(*)()->void); + (void)sizeof(auto(*)()->void); + (void)__alignof(auto(*)()->void); + + Uvoid> v; + + int n; + (void)static_castvoid>(&j); + auto p = reinterpret_castint>(&j); + (void)const_castint>(&p); + (void)(auto(*)()->void)(&j); +} + +template void = &j> class C { }; +struct F : auto(*)()->int {}; // expected-error{{expected class name}} +templateint> 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 struct same; +template struct same {}; + +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 +struct only { + only(T); + template 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 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 v; // expected-error{{'auto' not allowed in template argument}} + + int n; + (void)dynamic_cast(n); // expected-error{{'auto' not allowed here}} + (void)static_cast(&n); // expected-error{{'auto' not allowed here}} + (void)reinterpret_cast(&n); // expected-error{{'auto' not allowed here}} + (void)const_cast(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 class C { }; // expected-error{{'auto' not allowed in template parameter}} +int ints[] = {1, 2, 3}; +template 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 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 +struct only { + only(T); + template only(U) = delete; +}; + +namespace N +{ + auto a = "const char [16]", *p = &a; + + only testA = a; + only testP = p; +} + +void h() { + auto b = 42ULL; + only testB = b; + + for (auto c = 0; c < 100; ++c) { + only testC = c; + } +} + +void p3example() { + auto x = 5; + const auto *v = &x, u = 6; + static auto y = 0.0; + + only testX = x; + only testV = v; + only testU = u; + only testY = y; +} + +void f() { + if (auto a = true) { + only testA = a; + } + + switch (auto a = 0) { + case 0: + only testA = a; + } + + while (auto a = false) { + only testA = a; + } + + for (; auto a = "test"; ) { + only 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 ''}} + auto S::*p5 = &S::g; // expected-error {{incompatible initializer of type ''}} + auto (S::*p6)(int) = &S::g; + auto p7 = &S::m; + auto S::*p8 = &S::m; + + only test1 = p1; + only test2 = p2; + only test3 = p3; + only test6 = p6; + only test7 = p7; + only test8 = p8; + } +}; + +namespace PR10939 { + struct X { + int method(int); + int method(float); + }; + + template 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 (*funcptr2)(int) = funcptr; + } +} + +// if the initializer is a braced-init-list, deduce auto as std::initializer_list: +// 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 using X = A; // expected-note {{declared here}} +struct X* p2; // expected-error {{elaborated type refers to a type alias template}} + + +template using Id = T; // expected-note {{declared here}} +template class F> +struct Y { + struct F i; // expected-error {{elaborated type refers to a type alias template}} + typename F::type j; // ok + + // FIXME: don't produce the diagnostic both for the definition and the instantiation. + template using U = F; // expected-note 2{{declared here}} + struct Y::template U k; // expected-error 2{{elaborated type refers to a type alias template}} + typename Y::template U l; // ok +}; +template struct Y; // 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 struct B { // expected-note {{previous use is here}} + class Member {}; // expected-note 2 {{previous use is here}} +}; + +template <> class B { + // no type Member +}; + +template <> struct B { + union Member { // expected-note 4 {{previous use is here}} + void* a; + }; +}; + +void b1(struct B); +void b2(class B); +void b3(union B); // expected-error {{use of 'B' with tag type that does not match previous declaration}} +//void b4(enum B); // this just doesn't parse; you can't template an enum directly + +void c1(struct B::Member); +void c2(class B::Member); +void c3(union B::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} +void c4(enum B::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} + +void d1(struct B::Member); // expected-error {{no struct named 'Member' in 'B'}} +void d2(class B::Member); // expected-error {{no class named 'Member' in 'B'}} +void d3(union B::Member); // expected-error {{no union named 'Member' in 'B'}} +void d4(enum B::Member); // expected-error {{no enum named 'Member' in 'B'}} + +void e1(struct B::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} +void e2(class B::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} +void e3(union B::Member); +void e4(enum B::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} + +template struct C { + void foo(class B::Member); // expected-error{{no class named 'Member' in 'B'}} \ + // expected-error{{use of 'Member' with tag type that does not match previous declaration}} +}; + +C f1; +C f2; // expected-note {{in instantiation of template class}} +C 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 +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +const int&& foo(); +int i; +struct A { double x; }; +const A* a = new A(); + +static_assert(is_same::value, ""); +static_assert(is_same::value, ""); +static_assert(is_samex), double>::value, ""); +static_assert(is_samex)), const double&>::value, ""); +static_assert(is_same(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 struct A { ~A() = delete; }; // expected-note {{deleted here}} +template auto h() -> A; +template auto i(T) -> T; +template auto f(T) -> decltype(i(h())); // #1 +template auto f(T) -> void; // #2 +auto g() -> void { + f(42); // ok, calls #2, since #1 is not viable. +} +template auto q(T) -> decltype((h())); +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 struct is_same { static const bool value = false; }; + template struct is_same { static const bool value = true; }; + + template T declval(); + + void swap(int &a, int &b); + nat swap(any, any); + + template struct swappable { + typedef decltype(swap(declval(), declval())) type; + static const bool value = !is_same::value; + constexpr operator bool() { return value; } + }; + + static_assert(swappable(), ""); + static_assert(!swappable(), ""); +} + +namespace RequireCompleteType { + template struct S { + static_assert(OK, "boom!"); // expected-error 2{{boom!}} + }; + + template T make(); + template S 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())>()) *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 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((K*)0); // expected-error {{'W' can not be defined in a type specifier}} + (void)static_cast(0); // expected-error {{'X' can not be defined in a type specifier}} + (void)reinterpret_cast(0); // expected-error {{'Y' can not be defined in a type specifier}} + (void)const_cast((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 void f0() { + using U = T*; // expected-error {{declaration type contains unexpanded parameter pack 'T'}} + U u; + } + template void f0(); + + void f1() { + using T = int; + } + void f2() { + using T = int[-1]; // expected-error {{array size is negative}} + } + + template 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 class C3 { + using f = T; // expected-error {{declaration type contains unexpanded parameter pack 'T'}} + }; + template 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 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; // 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 +struct MaybeAggr5a : BaseList... {}; // expected-note {{default constructor of 'MaybeAggr5a' is implicitly deleted because base class 'Aggr' has a deleted default constructor}} +MaybeAggr5a<> ma5a0 = {}; // ok +MaybeAggr5a ma5a1 = {}; // expected-error {{call to implicitly-deleted default constructor of 'MaybeAggr5a'}} + +// 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 +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 + 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(int); // expected-note{{in instantiation of function template specialization 'PR12453::f' 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(" + // CHECK: fix-it:{{.*}}:27}:")" + struct {int16_t i;} i16 = {70000}; + // CHECK: warning:{{.*}} cannot be narrowed + // CHECK: fix-it:{{.*}}:30}:"static_cast(" + // CHECK: fix-it:{{.*}}:35}:")" +} + +template +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. + // CHECK: fix-it:{{.*}}"static_cast(" + // 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 +struct Agg { + T t; +}; + +template +struct Convert { + constexpr Convert(T v) : v(v) {} + constexpr operator T() const { return v; } + T v; +}; +template Convert 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 a1 = {1.0F}; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}} + Agg a2 = {1.0}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg 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 a4 = {f}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg a5 = {d}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg a6 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + + Agg ce1 = { Convert(1.0) }; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}} + Agg ce2 = { ConvertVar() }; // 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 f1 = {f}; // OK (no-op) + Agg f2 = {d}; // expected-error {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{override}} + Agg f3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + // Exact constants. + Agg f4 = {1.0}; // OK (double constant represented exactly) + Agg f5 = {1.0L}; // OK (long double constant represented exactly) + // Inexact but in-range constants. + Agg f6 = {0.1}; // OK (double constant in range but rounded) + Agg f7 = {0.1L}; // OK (long double constant in range but rounded) + // Out of range constants. + Agg f8 = {1E50}; // expected-error {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{override}} + Agg f9 = {1E50L}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + // More complex constant expression. + constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L; + Agg f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK + + // Variables. + Agg d1 = {f}; // OK (widening) + Agg d2 = {d}; // OK (no-op) + Agg d3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + // Exact constant. + Agg d4 = {1.0L}; // OK (long double constant represented exactly) + // Inexact but in-range constant. + Agg d5 = {0.1L}; // OK (long double constant in range but rounded) + // Out of range constant. + Agg d6 = {1E315L}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + // More complex constant expression. + constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L; + Agg d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK + + Agg ce1 = { Convert(1e300) }; // expected-error {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{override}} + Agg ce2 = { ConvertVar() }; // 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 f1 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg f2 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg f3 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + + // Constants. + Agg f4 = {12345678}; // OK (exactly fits in a float) + Agg f5 = {123456789}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + + Agg ce1 = { Convert(123456789) }; // expected-error {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{override}} + Agg ce2 = { ConvertVar() }; // 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 c1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg s1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg 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) i1 = {l1}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + long long ll = 1; + Agg l2 = {ll}; // OK + + // Constants. + Agg c2 = {127}; // OK + Agg c3 = {300}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}} + + Agg i2 = {0x7FFFFFFFU}; // OK + Agg i3 = {0x80000000U}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg 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 b1 = {0}; // OK + Agg b2 = {1}; // OK + Agg b3 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + + // Conversions from pointers to booleans aren't narrowing conversions. + Agg b = {&b1}; // OK + + Agg ce1 = { Convert(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 ce2 = { ConvertVar() }; // 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 +void maybe_shrink_int(T t) { + Agg s1 = {t}; // expected-error {{ cannot be narrowed }} expected-note {{override}} + Agg s2 = {I}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}} + Agg 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 c2 = {j}; // expected-error {{from type 'int' to 'const unsigned char' in}} expected-note {{override}} +} + +// Test SFINAE checks. +template struct Value { }; + +template +int &check_narrowed(Value); + +template +float &check_narrowed(...); + +void test_narrowed(Value vi, Value vd) { + int &ir = check_narrowed(vd); + float &fr = check_narrowed(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 +struct Agg { + T t; +}; + +template +struct Convert { + constexpr Convert(T v) : v(v) {} + constexpr operator T() const { return v; } + T v; +}; +template Convert 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 a1 = {1.0F}; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}} + Agg a2 = {1.0}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg 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 a4 = {f}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg a5 = {d}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg a6 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + + Agg ce1 = { Convert(1.0) }; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}} + Agg ce2 = { ConvertVar() }; // 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 f1 = {f}; // OK (no-op) + Agg f2 = {d}; // expected-warning {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{override}} + Agg f3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + // Exact constants. + Agg f4 = {1.0}; // OK (double constant represented exactly) + Agg f5 = {1.0L}; // OK (long double constant represented exactly) + // Inexact but in-range constants. + Agg f6 = {0.1}; // OK (double constant in range but rounded) + Agg f7 = {0.1L}; // OK (long double constant in range but rounded) + // Out of range constants. + Agg f8 = {1E50}; // expected-warning {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{override}} + Agg f9 = {1E50L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + // More complex constant expression. + constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L; + Agg f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK + + // Variables. + Agg d1 = {f}; // OK (widening) + Agg d2 = {d}; // OK (no-op) + Agg d3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + // Exact constant. + Agg d4 = {1.0L}; // OK (long double constant represented exactly) + // Inexact but in-range constant. + Agg d5 = {0.1L}; // OK (long double constant in range but rounded) + // Out of range constant. + Agg d6 = {1E315L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + // More complex constant expression. + constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L; + Agg d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK + + Agg ce1 = { Convert(1e300) }; // expected-warning {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{override}} + Agg ce2 = { ConvertVar() }; // 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 f1 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg f2 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg f3 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + + // Constants. + Agg f4 = {12345678}; // OK (exactly fits in a float) + Agg f5 = {123456789}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + + Agg ce1 = { Convert(123456789) }; // expected-warning {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{override}} + Agg ce2 = { ConvertVar() }; // 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 c1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg s1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg 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) i1 = {l1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + long long ll = 1; + Agg l2 = {ll}; // OK + + // Constants. + Agg c2 = {127}; // OK + Agg c3 = {300}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}} + + Agg i2 = {0x7FFFFFFFU}; // OK + Agg i3 = {0x80000000U}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg 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 b1 = {0}; // OK + Agg b2 = {1}; // OK + Agg b3 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + + // Conversions from pointers to booleans aren't narrowing conversions. + Agg b = {&b1}; // OK + + Agg ce1 = { Convert(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 ce2 = { ConvertVar() }; // 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 +void maybe_shrink_int(T t) { + Agg s1 = {t}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + Agg s2 = {I}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}} + Agg 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 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 struct Value { }; + +template +int &check_narrowed(Value); + +template +float &check_narrowed(...); + +void test_narrowed(Value vi, Value vd) { + int &ir = check_narrowed(vd); + float &fr = check_narrowed(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 +class E { + public: + E& Foo(const C&); + E& Bar() { return Foo(C()); } +}; + +void Test() { + E 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 T prvalue(); +template T&& xvalue(); +template T& lvalue(); + +struct Base { }; +struct Derived : Base { }; + +struct HasArray { + int array[5]; +}; + +int f(int); + +template +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&& base1 = xvalue(); + int&& int0 = xvalue(); + + // class prvalue case + Base&& base2 = prvalue(); + Base&& base3 = prvalue(); + + // 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&& base5 = ConvertsTo(); + int && int1 = ConvertsTo(); + + // class prvalue + Base&& base6 = ConvertsTo(); + Base&& base7 = ConvertsTo(); + + // function lvalue + int (&&function1)(int) = ConvertsTo(); + + // 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(); // expected-error{{no viable conversion from 'ConvertsTo' to 'int'}} + int &&int3 = ConvertsTo(); // expected-error{{no viable conversion from 'ConvertsTo' 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 &&nc1 = prvalue(); + NonCopyable &&nc2 = xvalue(); + NonCopyable &&nc3 = xvalue(); + const NonCopyable &nc4 = prvalue(); + const NonCopyable &nc5 = prvalue(); + const NonCopyable &nc6 = xvalue(); + const NonCopyable &nc7 = xvalue(); + NonCopyable &&nc8 = ConvertsTo(); + NonCopyable &&nc9 = ConvertsTo(); + const NonCopyable &nc10 = ConvertsTo(); + const NonCopyable &nc11 = ConvertsTo(); +} + +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(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' to 'int &&' for 1st argument}} \ + // expected-note{{candidate function not viable: no known conversion from 'ConvertsTo' to 'int &&' for 1st argument}} + + void array_rvalue_ref(int (&&)[5]); + void function_rvalue_ref(int (&&)(int)); + + void test() { + base_rvalue_ref(xvalue()); + base_rvalue_ref(xvalue()); + int_rvalue_ref(xvalue()); + + base_rvalue_ref(prvalue()); + base_rvalue_ref(prvalue()); + + array_rvalue_ref(HasArray().array); + + function_rvalue_ref(f); + + base_rvalue_ref(ConvertsTo()); + base_rvalue_ref(ConvertsTo()); + int_rvalue_ref(ConvertsTo()); + + base_rvalue_ref(ConvertsTo()); + base_rvalue_ref(ConvertsTo()); + + function_rvalue_ref(ConvertsTo()); + + int_rvalue_ref(ConvertsTo()); // expected-error{{no matching function for call to 'int_rvalue_ref'}} + int_rvalue_ref(ConvertsTo()); // 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 +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 +struct X4 { + X4(); + X4(const X4&, T = get_value_badly()); // 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&); +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()); + g5(X5()); // Generates a warning in the default argument. +} + +// Check that unavailable copy constructors still cause SFINAE failures. +template struct int_c { }; + +template T f(const T&); + +// Would be ambiguous with the next g(), except the instantiation failure in +// sizeof() prevents that. +template +int &g(int_c * = 0); + +template float &g(); + +void h() { + float &fp2 = g(); // 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 +T get_value_badly() { + double *dp = 0; + T *tp = dp; + return T(); +} + +template +struct X4 { + X4(); + X4(const X4&, T = get_value_badly()); +}; + +void g1(const X1&); +void g2(const X2&); +void g3(const X3&); +void g4(const X4&); + +void test() { + g1(X1()); + g2(X2()); + g3(X3()); + g4(X4()); +} + +// Check that unavailable copy constructors do not cause SFINAE failures. +template struct int_c { }; + +template T f(const T&); + +template +int &g(int_c * = 0); // expected-note{{candidate function [with T = X3]}} + +template float &g(); // expected-note{{candidate function [with T = X3]}} + +void h() { + float &fp = g(); // 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 + const double &rcd = d; +} + +struct A { }; +struct B : A { } b; + +// CHECK: example1 +void example1() { + // CHECK: A &ra = + // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue + A &ra = b; + // CHECK: const A &rca = + // CHECK: ImplicitCastExpr{{.*}}'const struct A' lvalue + // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue + 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' + // CHECK: ImplicitCastExpr{{.*}}'struct A' + // CHECK: CallExpr{{.*}}B + const A &rca = f(); + // CHECK: const A &r = + // CHECK: ImplicitCastExpr{{.*}}'const struct A' + // CHECK: ImplicitCastExpr{{.*}}'struct A' + // CHECK: CXXMemberCallExpr{{.*}}'struct B' + const A& r = x; +} + +// CHECK: example3 +void example3() { + // CHECK: const double &rcd2 = + // CHECK: ImplicitCastExpr{{.*}} + 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 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(); + const Base &br2 = create(); + const Derived &dr1 = create(); // expected-error{{no viable conversion}} + + const Base &br3 = create(); + const Base &br4 = create(); + + const Base &br5 = create(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Base' drops qualifiers}} + const Base &br6 = create(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Derived' drops qualifiers}} + + const int &ir = create(); +} + +// 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 +struct s2 { + static const s0 foo; +}; + +template<> const struct s0 s2::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 struct S { + typename T::type x; // expected-error {{has no members}} +}; +S 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 void f1(T); // expected-note{{previous}} + +template +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 +struct X0 { + void f(int); + + struct Inner { + void g(int); + }; +}; + +// DR217 +template +void X0::f(int = 17) { } // expected-error{{cannot be added}} + +// DR217 + DR205 (reading tea leaves) +template +void X0::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 +void f0(Types ...args); + +template +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 +struct X0 { }; + +template +struct X1 { + template 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 +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 +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 struct identity; +template struct tuple; + +template struct is_same { + static const bool value = false; +}; + +template struct is_same { + 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 +struct X0 { + typedef identity function_pack_1; + typedef identity variadic_function_pack_1; + typedef identity variadic_1; + typedef tuple 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 struct wrap { + typedef T val; + typedef T *ptr; + typedef T &ref; +}; + +using func_type_lvalue = wrap<>::val; +using func_type_lvalue = wrap::val; +using func_type_rvalue = wrap::val; + +using func_type_lvalue_ptr = wrap<>::ptr; +using func_type_lvalue_ptr = wrap::ptr; +using func_type_rvalue_ptr = wrap::ptr; + +using func_type_lvalue_ref = wrap<>::ref; +using func_type_lvalue_ref = wrap::ref; +using func_type_rvalue_ref = wrap::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 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' 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 RefMem { // expected-warning{{class 'RefMem' 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' requested here}} +}; + + +template 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 ArrMem { + T + member + [ // expected-error {{declared as array of references}} + 10 + ]; +}; +template 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 +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + 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::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 +class tfoo { + static int i; + void func(); +}; + +template +int decltype(tfoo())::i; // expected-error{{nested name specifier 'decltype(tfoo())::' for declaration does not refer into a class, class template or class template partial specialization}} +template +void decltype(tfoo())::func() { // expected-error{{nested name specifier 'decltype(tfoo())::' 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 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 + struct PR8019::x2 { }; // expected-error{{non-friend class member 'x2' cannot have a qualified name}} + + template + struct inner_template; + + template + struct y::inner_template { }; // expected-warning{{extra qualification on member 'inner_template'}} + }; + +} + +namespace NS { + void foo(); + extern int bar; + struct X; + template struct Y; + template 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 struct NS::Y; // expected-warning{{extra qualification on member 'Y'}} + template 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 +class X { + T* ptr; + +public: + X(const X &) { + 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) { // expected-note{{instantiation}} + // copy constructor + } catch (X 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 _Tp&& declval() noexcept; + +template +struct __is_nothrow_constructible +{ + static const bool value = noexcept(_Tp(declval<_Args>()...)); +}; + +template +class basic_string +{ +public: + typedef typename _Traits::char_type value_type; + typedef _Allocator allocator_type; + + basic_string() + noexcept(__is_nothrow_constructible::value); +}; + +template +struct __map_value_compare +{ +public: + __map_value_compare() + noexcept(__is_nothrow_constructible<_Compare>::value); +}; + +struct less +{ +}; + +struct map +{ + typedef __map_value_compare __vc; + __vc vc_; +}; + + +template +basic_string::basic_string() noexcept(__is_nothrow_constructible::value) {} + +template +__map_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 bool f(T) { + T* x = 1; + } + + template + void g(T x) noexcept((sizeof(T) == sizeof(int)) || noexcept(f(x))) { } + + void h() { + g(1); + } +} + +namespace PR11084 { + template 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 struct TEx; // expected-note {{template is declared here}} + +void tf() throw(TEx); // 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 void f1() throw(int); +template 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 struct complex { + complex(T = T(), T = T()); + void operator+=(complex); + T a, b; +}; + +void std_example() { + complex 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(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(vi)) {} + constexpr S(const S &s) : i(2), v(const_cast(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(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(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(&a); + int c = 10; // expected-note 2 {{here}} + int &d = c; + constexpr int e = 42; + int &f = const_cast(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(&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(&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 pq, 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 +class bitWidthHolding { +public: + static const + unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1); +}; + +static const int width=bitWidthHolding<255>::width; + +template +struct always_false { + static const bool value = false; +}; + +template +struct and_or { + static const bool and_value = b && and_or::value>::and_value; + static const bool or_value = !b || and_or::value>::or_value; +}; + +static const bool and_value = and_or::and_value; +static const bool or_value = and_or::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 + +// +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 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 struct T {}; +T 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 using A = int; +using Int = A; +using Int = A; // 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 struct Val { static constexpr T value = v; }; +static_assert(Val::value == 1, ""); // ok +static_assert(Val::value == 0, ""); // ok +static_assert(Val::value == 1, ""); // ok +static_assert(Val::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 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::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 struct X { }; +constexpr A a = 42; +X 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 T& lvalue(); +template T&& xvalue(); +template 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().*pmf)(17); + (xvalue().*pmf)(17); + (prvalue().*pmf)(17); + (xp->*pmf)(17); + + // Lvalue ref-qualifier. + (lvalue().*l_pmf)(17); + (xvalue().*l_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &' can only be called on an lvalue}} + (prvalue().*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().*r_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &&' can only be called on an rvalue}} + (xvalue().*r_pmf)(17); + (prvalue().*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(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 T& lvalue(); +template T&& xvalue(); +template T prvalue(); + +void test_classification(const int *ptr) { + int *ptr0 = const_cast(ptr); + int *ptr1 = const_cast(xvalue()); + int *ptr2 = const_cast(prvalue()); +} 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(x); + Y &&yr1 = dynamic_cast(static_cast(x)); + Y &&yr2 = dynamic_cast(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 struct Node { + int lhs; + void splay( ) + { + Node n[1]; + (void)n->lhs; + } +}; + +void f() { + Node 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 T&& xvalue(); +void test_classification(char *ptr) { + int (&fr0)(int) = reinterpret_cast(f); + int &&ir0 = reinterpret_cast(*ptr); + int &&ir1 = reinterpret_cast(0); + int &&ir2 = reinterpret_cast('a'); + int &&ir3 = reinterpret_cast(xvalue()); +} 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 T& lvalue(); +template T&& xvalue(); + +void test(A &a, B &b) { + A &&ar0 = static_cast(a); + A &&ar1 = static_cast(b); + A &&ar2 = static_cast(lvalue()); + A &&ar3 = static_cast(lvalue()); + A &&ar4 = static_cast(xvalue()); + A &&ar5 = static_cast(xvalue()); + const A &&ar6 = static_cast(a); + const A &&ar7 = static_cast(b); + const A &&ar8 = static_cast(lvalue()); + const A &&ar9 = static_cast(lvalue()); + const A &&ar10 = static_cast(xvalue()); + const A &&ar11 = static_cast(xvalue()); +} 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(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); +} + +namespace PR9107 { + enum E {}; + template 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 auto f(T t) -> decltype(t + g()) + { return t + g(); } +}; + +template auto B::f(int t) -> decltype(t + g()); + +template +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 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 + void + iter_swap(I x, I y) noexcept; + + template + class A + { + T t_; + public: + void swap(A& a) noexcept(noexcept(iter_swap(&t_, &a.t_))); + }; + + void test() { + A 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 + struct X2 { + int m; + + T f(T*); + static T f(int); + + auto g(T x) -> decltype(f(x)) { return 0; } + }; + + void test_X2() { + X2().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 + 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; // expected-note{{in instantiation of template class 'PR10127::templ' requested here}} + template class templ; + + 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 +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 boom, + ConstCopyConstructorBoom 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 +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 +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()' required here}} +} + +template void defargs_in_template_used(); +template void defargs_in_template_used(); // 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 T g(T = [] () -> T { T n; return ++n; } ()); + int k = f() + g(); +} 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 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 +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + 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::value, + "should be const float&"); + static_assert(is_same::value, "should be float"); + static_assert(is_same::value, + "should be const float&"); + static_assert(is_same::value, "should be float&"); + static_assert(is_same::value, "should be int&"); + static_assert(is_same::value, "should be int&"); + static_assert(is_same::value, + "should be const int&"); + static_assert(is_same::value, + "should be const int&"); + }(); + + [=] { + [=] () mutable { + static_assert(is_same::value, "should be float"); + static_assert(is_same::value, + "should be float&"); + }(); + }(); + + [&i] { + static_assert(is_same::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 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 '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 +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 boom_int, Boom boom_float, + Boom boom_double) { + const std::type_info &ti1 + = typeid([=,&p]() -> P& { boom_int.tickle(); return p; }()); // expected-note{{in instantiation of member function 'Boom::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::Boom' requested here}} + + auto foo = [=]() -> int { boom_double.tickle(); return 0; }; // expected-note{{in instantiation of member function 'Boom::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 +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 +void print(T first, Ts... rest) { + (void)first; + print(rest...); +} + +template +void unsupported(Ts ...values) { + auto unsup = [values] {}; // expected-error{{unexpanded function parameter pack capture is unsupported}} +} + +template +void implicit_capture(Ts ...values) { + auto implicit = [&] { print(values...); }; + implicit(); +} + +template +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 +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 +void std_example(Args... args) { + auto lm = [&, args...] { return g(args...); }; +}; + +template void std_example(int*, float*, double*); + +template +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 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(); + 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 +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 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 +void test_attributes() { + auto nrl = []() [[noreturn]] {}; // expected-error{{lambda declared 'noreturn' should not return}} +} + +template void test_attributes(); // expected-note{{in instantiation of function}} + +template +void call_with_zero() { + [](T *ptr) -> T& { return *ptr; }(0); +} + +template void call_with_zero(); + +template +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 +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' requested here}} + +// Make sure that lambda's operator() can be used from templates. +template +void accept_lambda(F f) { + f(1); +} + +template +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 + 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 + void odr_used(R &r, Boom 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); // expected-note{{in instantiation of function template specialization}} + + template + void odr_used2(R &r, Boom 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); +} + +namespace p5 { + struct NonConstCopy { + NonConstCopy(const NonConstCopy&) = delete; + NonConstCopy(NonConstCopy&); + }; + + template + void double_capture(T &nc) { + [=] () mutable { + [=] () mutable { + T nc2(nc); + }(); + }(); + } + + template void double_capture(NonConstCopy&); +} + +namespace NonLocalLambdaInstantation { + template + struct X { + static int value; + }; + + template + int X::value = []{ return T(); }(); // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'int *'}} + + template int X::value; + template int X::value; + template int X::value; // expected-note{{in instantiation of static data member }} + + template + 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(); + defaults(); + defaults(); // expected-note{{in instantiation of default function argument expression for 'defaults' required here}} + } + + template + struct X2 { + int x = []{ return T(); }(); // expected-error{{cannot initialize a member subobject of type 'int' with an rvalue of type 'int *'}} + }; + + X2 x2i; + X2 x2f; + X2 x2ip; // expected-note{{in instantiation of template class 'NonLocalLambdaInstantation::X2' 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 +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 x; } // expected-note {{in instantiation of member function}} + +// This case depends on when we check T2_C::f0. +class T2_A; +template +struct T2_B { void f0(T *a) { delete a; } }; +struct T2_C { T2_B 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 +struct T3_B { + void f0(T *a) { + delete a; // expected-error{{calling a private destructor of class 'T3_A'}} + } +}; + +struct T3_C { + T3_B x; + void f0(T3_A *a) { + x.f0(a); // expected-note{{in instantiation of member function 'T3_B::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'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[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 +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 +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 +struct only { + only(T); + template only(U) = delete; +}; + +void f() { + only p = new const auto (0); + only 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 r = new auto(1); + auto x = new auto('a'); + + only 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 +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 +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 +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 + 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 +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 +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 +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 +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 struct count_types { + static const unsigned value = sizeof...(Types); +}; + +template struct count_ints { + static const unsigned value = sizeof...(Values); +}; + +// Test instantiation +int check_types[count_types::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 any(T); +}; + +template +void init_me(Inits ...inits) { + any array[sizeof...(inits)] = { inits... }; +} + +template void init_me(int, float, double*); + +// Test parser and semantic recovery. +template struct count_ints_2 { + static const unsigned value = sizeof...(Value); // expected-error{{'Value' does not refer to the name of a parameter pack}} +}; + +template // 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(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(s)); + P(static_cast(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(*pd)); + P(dynamic_cast(pd)); + N(dynamic_cast(*pv)); + P(dynamic_cast(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 void f(T&&) noexcept; +template +void late() { + B(b, typeid(*(T*)0)); + B(b, T(1)); + B(b, static_cast(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 T&& f2() noexcept; +template +void late2() { + P(dynamic_cast(f2())); +} +void operator +(const S1&, float) throw(); +void operator +(const S1&, const S3&); +void tlate() { + late(); + late(); + late2(); +} 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 void g(T); + + void test() { + foo(&g); // 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 struct selector; +template<> struct selector { typedef long type; }; +template<> struct selector {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 +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 &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 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 &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 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 struct same_type; +template struct same_type {}; + +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 test1; + same_type test2; + same_type 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 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 operator T(); +}; + +Variant getValue(); + +void testVariant() { + bool ret1 = getValue() || getValue(); + bool ret2 = getValue() && getValue(); + bool ret3 = !getValue(); +} + +struct ExplicitVariant { + template 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 void f(T*) &; + template void f(T*) &&; + + template void g(T*) &; // expected-note{{previous declaration}} + template 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 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::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 struct identity + { typedef T type; }; + + struct D { + template + operator typename identity::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 +struct remove_reference { + typedef T type; +}; + +template +struct remove_reference { + typedef T type; +}; + +template +struct remove_reference { + typedef T type; +}; + +namespace FunctionReferencesOverloading { + template int &f(typename remove_reference::type&); + template float &f(typename remove_reference::type&&); + + void test_f(int (&func_ref)(int)) { + int &ir = f(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 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(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 T &lvalue(); +template T &&xvalue(); +template T prvalue(); + +struct X0 { + int &f() &; + float &f() &&; + + template int &ft(T) &; + template 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 int &operator+(const T&) &; + template 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().f(); + float &fr1 = xvalue().f(); + float &fr2 = prvalue().f(); + int &ir2 = lvalue().ft(1); + float &fr3 = xvalue().ft(2); + float &fr4 = prvalue().ft(3); +} + +void test_ref_qualifier_binding_with_surrogates() { + int &ir1 = lvalue()(); + float &fr1 = xvalue()(); + float &fr2 = prvalue()(); +} + +void test_ref_qualifier_binding_operators() { + int &ir1 = lvalue() + prvalue(); + float &fr1 = xvalue() + prvalue(); + float &fr2 = prvalue() + prvalue(); + int &ir2 = lvalue() + 1; + float &fr3 = xvalue() + 2; + float &fr4 = prvalue() + 3; +} + +void test_ref_qualifier_overloading() { + int &ir1 = lvalue().h(); + float &fr1 = xvalue().h(); + float &fr2 = prvalue().h(); + int &ir2 = lvalue().h2(); + float &fr3 = xvalue().h2(); + float &fr4 = prvalue().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 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 struct S {}; + +template void operator "" _a(); +template S operator "" _a(); + +template 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 struct V { + friend void operator "" _b(); // expected-error {{parameter}} +}; + +template void operator "" _b(); // expected-error {{parameter}} +template void operator "" _b(int N = 0); // expected-error {{parameter}} +template void operator "" _b(); // expected-error {{parameter}} +template T operator "" _b(const char *); // expected-error {{parameter}} +template 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 void operator "" _b(); // expected-error {{must have C++ linkage}} + +extern "C" { + void operator "" _c(const char *); // expected-error {{must have C++ linkage}} + template void operator "" _d(); // expected-error {{must have C++ linkage}} + namespace N { + void operator "" _e(const char *); // expected-error {{must have C++ linkage}} + template 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 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 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 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 struct Y0 { }; +template struct Y1 { }; +template struct Y2 { }; +template struct Y3 { }; + +Y0 y0; +Y0<&f0> y0a; +Y1 y1; +Y1<&f0> y1a; +Y2 y2; +Y3 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 T* f(int); // #1 + template T& f(U); // #2 + + void g() { + int *ip = f(1); // calls #1 + } + + template + T* f2(int); + template + T& f2(U); + + void g2() { + int*ip = (f2)(1); // ok + } + +} // End namespace + +namespace DontAllowUnresolvedOverloadedExpressionInAnUnusedExpression +{ + void one() { } + template void oneT() { } + + void two() { } // expected-note 2 {{possible target for call}} + void two(int) { } // expected-note 2 {{possible target for call}} + template void twoT() { } // expected-note 2 {{possible target for call}} + template 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; // expected-warning {{expression result unused}} + twoT; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} + } + + // check the template function case + template 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; // expected-warning {{expression result unused}} + twoT; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} + + } + +} + + template + void twoT() { } + template + void twoT(T) { } + + + void two() { }; //expected-note 5{{candidate}} + void two(int) { }; //expected-note 5{{candidate}} + + + + void one() { } + template + void oneT() { } + + template + void cant_resolve() { } //expected-note 3{{candidate}} + + template void cant_resolve(T) { }//expected-note 3{{candidate}} + + +int main() +{ + + { static_cast(one); } + { (void)(one); } + { static_cast(oneT); } + { (void)(oneT); } + + { static_cast(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(twoT); } + { (void)(twoT); } + + + { ptrdiff_t x = reinterpret_cast(oneT); } + { (void) reinterpret_cast(oneT); } + { (void) reinterpret_cast(one); } + { (void) reinterpret_cast(one); } + + { ptrdiff_t x = reinterpret_cast(twoT); } + { (void) reinterpret_cast(twoT); } + { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} + { (void) static_cast(two); } //ok + + { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} + { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} + + { bool b = (twoT); } + { bool b = (twoT); } + + { bool b = &twoT; //&foo; } + b = &(twoT); } + + { ptrdiff_t x = (ptrdiff_t) &twoT; + x = (ptrdiff_t) &twoT; } + + { ptrdiff_t x = (ptrdiff_t) twoT; + x = (ptrdiff_t) twoT; } + + + { ptrdiff_t x = (ptrdiff_t) &twoT; + x = (ptrdiff_t) &twoT; } + + { oneT; &oneT; } //expected-warning 2{{expression result unused}} + { static_cast(cant_resolve); } // expected-error {{address of overload}} + { bool b = cant_resolve; } // expected-error {{address of overload}} + { (void) cant_resolve; } // expected-error {{address of overload}} + +} + +namespace member_pointers { + struct S { + template bool f(T) { return false; } + template static bool g(T) { return false; } + + template bool h(T) { return false; } // expected-note 3 {{possible target for call}} + template static bool h(int) { return false; } // expected-note 3 {{possible target for call}} + }; + + void test(S s) { + if (S::f) return; // expected-error {{call to non-static member function without an object argument}} + if (S::f) return; // expected-error {{call to non-static member function without an object argument}} + if (&S::f) return; + if (&S::f) return; + if (s.f) return; // expected-error {{reference to non-static member function must be called}} + if (s.f) return; // expected-error {{reference to non-static member function must be called}} + if (&s.f) return; // expected-error {{cannot create a non-constant pointer to member function}} + if (&s.f) return; // expected-error {{cannot create a non-constant pointer to member function}} + + if (S::g) return; + if (S::g) return; + if (&S::g) return; + if (&S::g) return; + if (s.g) return; + if (s.g) return; + if (&s.g) return; + if (&s.g) return; + + if (S::h<42>) return; + if (S::h) 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) return; + if (s.h<42>) return; + if (s.h) 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) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} + + { bool b = S::f; } // expected-error {{call to non-static member function without an object argument}} + { bool b = S::f; } // expected-error {{call to non-static member function without an object argument}} + { bool b = &S::f; } + { bool b = &S::f; } + // These next two errors are terrible. + { bool b = s.f; } // expected-error {{reference to non-static member function must be called}} + { bool b = s.f; } // expected-error {{reference to non-static member function must be called}} + { bool b = &s.f; } // expected-error {{cannot create a non-constant pointer to member function}} + { bool b = &s.f; } // expected-error {{cannot create a non-constant pointer to member function}} + + { bool b = S::g; } + { bool b = S::g; } + { bool b = &S::g; } + { bool b = &S::g; } + { bool b = s.g; } + { bool b = s.g; } + { bool b = &s.g; } + { bool b = &s.g; } + + { bool b = S::h<42>; } + { bool b = S::h; } // expected-error {{can't form member pointer of type 'bool' without '&' and class name}} + { bool b = &S::h<42>; } + { bool b = &S::h; } + { bool b = s.h<42>; } + { bool b = s.h; } // expected-error {{can't form member pointer of type 'bool' without '&' and class name}} + { bool b = &s.h<42>; } + { bool b = &s.h; } // 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 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 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(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(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 = b; + b = static_cast(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(const_cast(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 + T may_throw() { + return T(); + } + + template T &&declval() noexcept; + + struct NonPOD { + NonPOD(); + NonPOD(const NonPOD &) noexcept; + NonPOD(NonPOD &&) noexcept; + }; + + struct X { + NonPOD np = may_throw(); + }; + + static_assert(noexcept(declval()), "noexcept isn't working at all"); + static_assert(noexcept(X(declval())), "copy constructor can't throw"); + static_assert(noexcept(X(declval())), "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)); + } + + // 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 +struct X { + X(); + template X(X); + X(const X&); +}; + +void f(X) { } + +struct Y : X { }; +struct Z : X { }; + +// 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 + 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(int); // expected-note{{in instantiation of function template specialization 'PR10142::f2' 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 +struct X1 { + struct type { }; + + X1(); + X1(int); + (X1)(float); + X1(float, float); + (X1)(double); + X1 (f0)(int); + X1 (f0)(type); + X1 (f1)(int); + X1 (f1)(type); + + template X1(U); + X1 f2(); + X1 f2(int); +}; + +template X1::X1() { } +template (X1::X1)(double) { } +template X1 X1::f1(int) { return 0; } +template X1 (X1::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 class Trivial4 { Trivial4() = default; }; +static_assert(__has_trivial_constructor(Trivial4), "Trivial4 is trivial"); + +template class Trivial5 { Trivial5() = delete; }; +static_assert(__has_trivial_constructor(Trivial5), "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 +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' requested here}} +template void b(const A*,const A*); // expected-note{{in instantiation of function template specialization 'b' 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 +struct TA { + ~TA(); +}; + +template +struct TB { + ~TB() throw(int); +}; + +template +struct TC { + TB b; + ~TC() {} +}; + +template +struct TD { + ~TD() noexcept(false); +}; + +template +struct TE { + TD d; + ~TE() {} +}; + +void tfoo() { + TA a; + TC c; + TE e; + // CHECK: invoke {{.*}} @_ZN2TEIiED1Ev + // CHECK: invoke {{.*}} @_ZN2TCIiED1Ev + // CHECK: call {{.*}} @_ZN2TAIiED1Ev +} + +template +struct TF { + TD d; + ~TF(); +}; +template +TF::~TF() noexcept(false) {} + +template +struct TG { + TD d; + ~TG(); +}; +template +TG::~TG() {} + +template +struct TH { + TB b; + ~TH(); +}; +template +TH::~TH() {} + +void tinst() { + TF f; + TG g; + TH h; +} +// CHECK: define linkonce_odr {{.*}} @_ZN2THIiED1Ev +// CHECK: _ZTIi +// CHECK: __cxa_call_unexpected + +struct VX +{ virtual ~VX() {} }; + +struct VY : VX +{ virtual ~VY() {} }; + +template +struct TVY : VX +{ virtual ~TVY() {} }; + + +struct VA { + B b; + virtual ~VA() {} +}; + +struct VB : VA +{ virtual ~VB() {} }; + +template +struct TVB : VA +{ virtual ~TVB() {} }; + +void tinst2() { + TVY tvy; + TVB tvb; +} + +template +struct Sw { + T t; + ~Sw() {} +}; + +void tsw() { + Sw swi; + Sw 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 +struct TVC : VX +{ virtual ~TVC(); }; +template +TVC::~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 + +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 + +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 struct A {}; + +template struct B : A, A { + using A::A; // expected-error {{'A::', which is not a base class of 'B'}} expected-error {{not supported}} +}; +B bb; +B bc; +B bd; // expected-note {{here}} + +template struct C : A { + using A::A; // expected-error {{'A::', which is not a base class of 'C'}} expected-error {{not supported}} +}; +C cb; +C cc; // expected-note {{here}} + +template struct D : A {}; +template struct E : D { + using A::A; // expected-error {{'A' is not a direct base of 'E', can not inherit}} expected-error {{not supported}} +}; +E eb; // expected-note {{here}} + +template struct F : D { + using A::A; // expected-error {{'A' is not a direct base of 'F'}} expected-error {{not supported}} +}; +F 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 struct T1 : B1 { + using B1::B1; // expected-error {{not supported}} +}; +template struct T2 : T1 { + using T1::T1; // expected-error {{not supported}} +}; +template struct T3 : T1 { + using T1::T1; // expected-error {{not supported}} +}; +struct U { + friend T1::T1(int); + friend T1::T1(int, int); + friend T2::T2(int); + friend T2::T2(int, int); + friend T3::T3(int); + friend T3::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 struct B3 { + B3(T); // expected-note {{previous constructor}} +}; +template struct B4 : B3, B1 { + B4(); + using B3::B3; // expected-note {{inherited here}} expected-error {{not supported}} + using B1::B1; // expected-error {{already inherited}} expected-error {{not supported}} +}; +B4 b4c; +B4 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 +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 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 +void func(A, B, C, D, E); + +void func(int a, int c) { + T(a)->m = 7; + T(a)++; + T(a,5)<m = 7; + decltype(T())(a)++; + decltype(T())(a,5)< 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 + auto begin(T &&t) -> decltype(t.begin()) { return t.begin(); } // expected-note 4{{ignored: substitution failure}} + template + auto end(T &&t) -> decltype(t.end()) { return t.end(); } // expected-note {{candidate template ignored: substitution failure [with T = }} + + template + 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 + 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 '' 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 +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); +template void h(A(&)[4]); +template void h(A(&)[13]); +template void h(A(&)[13]); // expected-note {{requested here}} + +template +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*); // expected-note {{requested here}} +template void i(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 struct S { + static int a, b; +}; + +template int S::a, S::b; // expected-error {{can only declare a single entity}} + +template struct A { static A a; } A::a; // expected-error {{expected ';' after struct}} \ + expected-error {{use of undeclared identifier 'T'}} \ + expected-warning{{extra qualification}} + +template struct B { } f(); // expected-error {{expected ';' after struct}} \ + expected-error {{requires a type specifier}} + +template struct C { } // expected-error {{expected ';' after struct}} + +A 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 struct IP { // expected-note 4 {{template parameter is declared here}} + 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 ip2; +IP ip3; +IP<(int*)0> ip4; +IP ip5; +IP 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 struct PM { // expected-note 2 {{template parameter is declared here}} + 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 pm2; +PM pm3; +PM<(int X::*)0> pm4; +PM pm5; + +template struct PMF { // expected-note 2 {{template parameter is declared here}} + 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 pmf2; +PMF pmf3; +PMF<(int (X::*)(int))0> pmf4; +PMF pmf5; + + +template struct NP { // expected-note 2{{template parameter is declared here}} + NP *np2; +}; + +NP np1; +NP np2; +NP 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 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 struct X0 { X0(); }; + template X0::X0() { } + template struct X1 { X1(); }; + template X1::X1() { } + template struct X3 { X3(); }; + template X3::X3() { } + template struct X4 { X4(); }; + template X4::X4() { } + template struct X5 { X5(); }; + template X5::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 struct X0 { }; // expected-note 4{{here}} + template struct X1 { }; + template struct X2 { }; // expected-note 4{{here}} + template struct X2k { }; // expected-note {{here}} + template 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 T f_tmpl(T t); + + void test() { + X0 x0a; // expected-error {{must have its address taken}} + X0<&i> x0a_addr; + X0 x0b; + X0<&iarr> x0b_addr; // expected-error {{cannot be converted to a value of type 'int *'}} + X0 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 x1a; + X1<&f> x1a_addr; + X1 x1b; + X1<&f_tmpl> x1b_addr; + X1 > x1c; + X1<&f_tmpl > x1c_addr; + X1 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 x2a; + X2<&i> x2a_addr; // expected-error {{address taken}} + X2 x2b; // expected-error {{cannot bind to template argument of type 'int [10]'}} + X2<&iarr> x2b_addr; // expected-error {{address taken}} + X2 x2c; // expected-error {{ignores qualifiers}} expected-warning {{internal linkage is a C++11 extension}} + X2k 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 x2d_addr; // expected-error {{refers to thread-local object}} + X3 x3a; + X3<&f> x3a_addr; // expected-error {{address taken}} + X3 x3b; + X3<&f_tmpl> x3b_addr; // expected-error {{address taken}} + X3 > x3c; + X3<&f_tmpl > x3c_addr; // expected-error {{address taken}} + X3 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 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 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 struct X0 { }; + X0<17> x0i; + X0<'a'> x0c; + template 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 + struct A { + Str get() { return s; } + }; + + char hello[6] = "Hello"; + extern const char world[6]; + const char world[6] = "world"; + void test() { + (void)A().get(); + (void)A().get(); + } + + class X { + public: + X(); + X(int, int); + operator int() const; + }; + + template struct A2; // expected-note{{template parameter is declared here}} + + X *X_ptr; + X an_X; + X array_of_Xs[10]; + A2 *a12; // expected-error{{must have its address taken}} + A2 *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 struct X2 { }; + template struct X3 : X2 { }; + struct X4 : X3<&X1v> { }; + + // PR6563 + int *bar; + template struct zed {}; // expected-note 2{{template parameter is declared here}} + void g(zed*); // expected-error{{must have its address taken}} + + int baz; + void g2(zed*); // 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 struct S0 { }; // expected-note 3 {{template parameter is declared here}} + template struct S1 { }; // expected-note 2 {{template parameter is declared here}} + template struct S2 { }; // expected-note 2 {{template parameter is declared here}} + template struct S3 { }; + int i; + extern const int ci; + volatile int vi; + extern const volatile int cvi; + void test() { + S0 s0; + S0 s0c; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const int' ignores qualifiers}} + S0 s0v; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'volatile int' ignores qualifiers}} + S0 s0cv; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const volatile int' ignores qualifiers}} + + S1 s1; + S1 s1c; + S1 s1v; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'volatile int' ignores qualifiers}} + S1 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 s2; + S2 s2c; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const int' ignores qualifiers}} + S2 s2v; + S2 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 s3; + S3 s3c; + S3 s3v; + S3 s3cv; + } + + namespace PR6250 { + template void inc() { + ref++; // expected-error{{read-only variable is not assignable}} + } + + template void bind() { + T &ref2 = ref; // expected-error{{drops qualifiers}} + } + + int counter; + void test() { + inc(); // expected-note{{instantiation of}} + bind(); // expected-note{{instantiation of}} + } + } + + namespace PR6749 { + template struct foo {}; // expected-note{{template parameter is declared here}} + int x, &y = x; + foo 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 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); + void x0b(X0<&f>); + void x0c(X0); // 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); // 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 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); + void x0b(X0<&f>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}} + void x0c(X0); // 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); // 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 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 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 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 struct eval; // expected-note 3{{template is declared here}} + +template