From 56d91b49b13fe55c918afbda19f6165b5fbff87a Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 15 Aug 2012 20:02:54 +0000 Subject: Vendor import of clang trunk r161861: http://llvm.org/svn/llvm-project/cfe/trunk@161861 --- test/ARCMT/Common.h | 36 +- test/ARCMT/autoreleases.m | 47 +- test/ARCMT/autoreleases.m.result | 43 +- test/ARCMT/checking.m | 33 +- test/ARCMT/cxx-rewrite.mm.result | 2 +- test/ARCMT/dispatch.m | 11 - test/ARCMT/dispatch.m.result | 11 - test/ARCMT/nonobjc-to-objc-cast-2.m | 31 +- test/ARCMT/nonobjc-to-objc-cast.m | 27 +- test/ARCMT/nonobjc-to-objc-cast.m.result | 57 +- test/ARCMT/objcmt-boxing.m | 102 + test/ARCMT/objcmt-boxing.m.result | 102 + test/ARCMT/objcmt-numeric-literals.m | 1 + test/ARCMT/objcmt-numeric-literals.m.result | 5 +- test/ARCMT/objcmt-subscripting-literals-in-arc.m | 106 + .../objcmt-subscripting-literals-in-arc.m.result | 106 + test/ARCMT/objcmt-subscripting-literals.m | 102 +- test/ARCMT/objcmt-subscripting-literals.m.result | 102 +- test/ARCMT/objcmt-subscripting-unavailable.m | 79 + .../ARCMT/objcmt-subscripting-unavailable.m.result | 79 + test/ARCMT/releases-driver.m | 3 +- test/ARCMT/releases-driver.m.result | 3 - test/ARCMT/releases.m | 3 +- test/ARCMT/releases.m.result | 3 - test/ARCMT/verify.m | 13 + test/ASTMerge/function.c | 6 + test/Analysis/MissingDealloc.m | 6 +- test/Analysis/NoReturn.m | 12 + test/Analysis/PR12905.c | 8 + test/Analysis/additive-folding-range-constraints.c | 191 +- test/Analysis/additive-folding.c | 203 - test/Analysis/additive-folding.cpp | 196 + test/Analysis/array-struct-region.c | 171 +- test/Analysis/auto-obj-dtors-cfg-output.cpp | 295 +- test/Analysis/base-init.cpp | 9 +- test/Analysis/blocks-no-inline.c | 13 + test/Analysis/blocks.m | 4 +- test/Analysis/bstring.c | 89 +- test/Analysis/casts.c | 8 + test/Analysis/comparison-implicit-casts.cpp | 98 + test/Analysis/constant-folding.c | 90 +- test/Analysis/coverage.c | 8 + test/Analysis/cstring-syntax.c | 2 +- test/Analysis/ctor-inlining.mm | 41 + test/Analysis/cxx-crashes.cpp | 23 +- test/Analysis/cxx-for-range-cfg.cpp | 16 + test/Analysis/cxx-method-names.cpp | 21 + test/Analysis/cxx11-crashes.cpp | 66 + test/Analysis/dead-stores.m | 20 + test/Analysis/delegates.m | 25 +- test/Analysis/derived-to-base.cpp | 124 +- test/Analysis/diagnostics/undef-value-callee.h | 4 + test/Analysis/diagnostics/undef-value-caller.c | 238 ++ test/Analysis/domtest.c | 45 +- test/Analysis/dtor.cpp | 164 +- test/Analysis/dynamic-cast.cpp | 25 +- test/Analysis/engine/replay-without-inlining.c | 57 + test/Analysis/global-region-invalidation.c | 13 +- test/Analysis/html-diags.c | 2 +- test/Analysis/initializer.cpp | 74 +- test/Analysis/initializers-cfg-output.cpp | 2 +- test/Analysis/inline-plist.c | 834 +++- test/Analysis/inline-unique-reports.c | 26 +- test/Analysis/inline.c | 22 +- test/Analysis/inline.cpp | 168 + test/Analysis/inlining/DynDispatchBifurcate.m | 181 + test/Analysis/inlining/InlineObjCClassMethod.m | 181 + test/Analysis/inlining/InlineObjCInstanceMethod.h | 46 + test/Analysis/inlining/InlineObjCInstanceMethod.m | 86 + test/Analysis/inlining/ObjCDynTypePopagation.m | 84 + .../ObjCImproperDynamictallyDetectableCast.m | 37 + test/Analysis/inlining/RetainCountExamples.m | 33 + test/Analysis/inlining/path-notes.c | 1291 ++++++ test/Analysis/iterators.cpp | 105 - test/Analysis/ivars.m | 132 + test/Analysis/malloc-annotations.c | 8 +- test/Analysis/malloc-plist.c | 1896 ++++++++- test/Analysis/malloc-sizeof.c | 27 +- test/Analysis/malloc.c | 278 +- test/Analysis/malloc.cpp | 21 + test/Analysis/malloc.m | 2 +- test/Analysis/malloc.mm | 80 +- test/Analysis/method-call-path-notes.cpp | 664 +++ test/Analysis/method-call.cpp | 28 +- test/Analysis/misc-ps-arm.m | 18 + test/Analysis/misc-ps-cxx0x.cpp | 14 + test/Analysis/misc-ps-region-store.cpp | 50 +- test/Analysis/misc-ps-region-store.m | 22 +- test/Analysis/misc-ps.c | 7 + test/Analysis/misc-ps.m | 36 +- test/Analysis/new.cpp | 99 +- test/Analysis/nonnull.m | 23 + test/Analysis/nullptr.cpp | 2 +- test/Analysis/objc-boxing.m | 44 + test/Analysis/objc-for.m | 58 + test/Analysis/objc-subscript.m | 89 + test/Analysis/operator-calls.cpp | 18 +- test/Analysis/out-of-bounds.c | 6 +- test/Analysis/outofbound-notwork.c | 2 +- test/Analysis/outofbound.c | 36 + test/Analysis/plist-output-alternate.m | 49 +- test/Analysis/plist-output.m | 647 ++- test/Analysis/ptr-arith.c | 217 +- test/Analysis/rdar-7168531.m | 2 +- test/Analysis/refcnt_naming.m | 2 +- test/Analysis/reference.cpp | 79 +- test/Analysis/region-store.c | 23 + test/Analysis/retain-release-path-notes-gc.m | 1339 +++++- test/Analysis/retain-release-path-notes.m | 4489 +++++++++++++++++++- test/Analysis/retain-release.m | 130 +- test/Analysis/self-init.m | 31 +- test/Analysis/stack-addr-ps.cpp | 6 + test/Analysis/string-fail.c | 40 +- test/Analysis/string.c | 397 +- test/Analysis/svalbuilder-logic.c | 7 + test/Analysis/system-header-simulator-objc.h | 16 + test/Analysis/system-header-simulator.h | 24 + test/Analysis/taint-generic.c | 29 + test/Analysis/taint-tester.c | 2 +- test/Analysis/temp-obj-dtors-cfg-output.cpp | 205 +- test/Analysis/templates.cpp | 44 + test/Analysis/test-variably-modified-types.c | 13 + test/Analysis/traversal-algorithm.mm | 213 + test/Analysis/uninit-sometimes.cpp | 387 ++ test/Analysis/unused-ivars.m | 21 + test/CMakeLists.txt | 172 +- .../basic.lookup.classref/p1-cxx11.cpp | 69 + .../basic.lookup.classref/p4-cxx11.cpp | 21 + test/CXX/basic/basic.types/p10.cpp | 6 +- test/CXX/class.access/class.friend/p1.cpp | 2 + test/CXX/class.access/class.friend/p9-cxx0x.cpp | 117 + test/CXX/class.derived/class.virtual/p3-0x.cpp | 49 + test/CXX/class/class.mem/p14.cpp | 5 +- test/CXX/class/class.union/p1.cpp | 5 +- test/CXX/class/p6-0x.cpp | 2 +- test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp | 48 +- .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp | 37 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp | 3 +- .../dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp | 12 +- test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp | 4 +- .../dcl.fct.def/dcl.fct.def.default/p2.cpp | 76 +- .../dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp | 8 + test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp | 2 +- test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp | 113 + test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp | 14 + .../dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp | 2 +- .../dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp | 16 + .../dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp | 27 +- test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp | 6 +- test/CXX/except/except.spec/p14.cpp | 24 + test/CXX/except/except.spec/p5-pointers.cpp | 6 +- test/CXX/expr/expr.const/p2-0x.cpp | 6 +- .../expr/expr.post/expr.reinterpret.cast/p1-0x.cpp | 7 +- .../expr.prim/expr.prim.lambda/blocks-irgen.mm | 29 + test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm | 38 + test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp | 4 +- test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp | 8 +- test/CXX/expr/expr.unary/expr.unary.op/p6.cpp | 2 +- test/CXX/expr/p10-0x.cpp | 46 + test/CXX/special/class.conv/class.conv.ctor/p1.cpp | 21 + test/CXX/special/class.copy/implicit-move.cpp | 7 + test/CXX/special/class.copy/p11.0x.copy.cpp | 16 +- test/CXX/special/class.copy/p13-0x.cpp | 56 + test/CXX/special/class.copy/p15-inclass.cpp | 2 +- test/CXX/special/class.copy/p23-cxx11.cpp | 148 + test/CXX/special/class.copy/p8-cxx11.cpp | 2 +- test/CXX/special/class.ctor/p5-0x.cpp | 6 +- test/CXX/special/class.ctor/p6-0x.cpp | 39 + test/CXX/special/class.dtor/p5-0x.cpp | 8 +- test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp | 9 + test/CXX/temp/temp.decls/temp.friend/p1.cpp | 3 + .../temp.variadic/multi-level-substitution.cpp | 43 + test/CXX/temp/temp.names/p3-0x.cpp | 12 + test/CXX/temp/temp.spec/p5.cpp | 2 +- test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp | 2 +- test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp | 8 +- test/CXX/temp/temp.spec/temp.explicit/p12.cpp | 49 +- .../temp/temp.spec/temp.explicit/p9-linkage.cpp | 2 +- test/CodeCompletion/auto.cpp | 2 + test/CodeCompletion/documentation.cpp | 33 + test/CodeCompletion/objc-expr.m | 17 + test/CodeGen/2002-05-24-Alloca.c | 11 - test/CodeGen/2005-07-20-SqrtNoErrno.c | 2 +- test/CodeGen/2007-02-25-C-DotDotDot.c | 2 +- test/CodeGen/2008-01-25-ByValReadNone.c | 2 +- test/CodeGen/2008-03-05-syncPtr.c | 2 +- test/CodeGen/2008-04-08-NoExceptions.c | 2 +- test/CodeGen/2009-02-13-zerosize-union-field-ppc.c | 1 + test/CodeGen/2009-09-24-SqrtErrno.c | 2 +- test/CodeGen/2009-10-20-GlobalDebug.c | 4 +- test/CodeGen/2010-02-10-PointerName.c | 2 +- test/CodeGen/2010-05-26-AsmSideEffect.c | 1 + test/CodeGen/Atomics.c | 2 +- test/CodeGen/address-safety-attr.cpp | 6 + test/CodeGen/address-space.c | 6 +- test/CodeGen/alloca.c | 11 + test/CodeGen/altivec.c | 1 + test/CodeGen/annotations-builtin.c | 14 +- test/CodeGen/arm-aapcs-vfp.c | 12 + test/CodeGen/arm-aapcs-zerolength-bitfield.c | 1 + test/CodeGen/arm-apcs-zerolength-bitfield.c | 1 + test/CodeGen/arm-arguments.c | 13 + test/CodeGen/arm-asm-variable.c | 1 + test/CodeGen/arm-asm.c | 1 + test/CodeGen/arm-cc.c | 1 + test/CodeGen/arm-clear.c | 1 + test/CodeGen/arm-homogenous.c | 3 +- test/CodeGen/arm-inline-asm.c | 1 + test/CodeGen/arm-pcs.c | 1 + test/CodeGen/arm-vaarg-align.c | 1 + test/CodeGen/arm-vector-align.c | 1 + test/CodeGen/arm-vector-arguments.c | 1 + test/CodeGen/asm.c | 10 + test/CodeGen/asm_arm.c | 1 + test/CodeGen/atomic_ops.c | 15 +- test/CodeGen/attr-coldhot.c | 9 + test/CodeGen/attributes.c | 8 + test/CodeGen/avx-builtins.c | 70 + test/CodeGen/avx2-builtins.c | 156 + test/CodeGen/block-3.c | 12 + test/CodeGen/block-byref-aggr.c | 71 +- test/CodeGen/blocks.c | 28 +- test/CodeGen/blocksignature.c | 2 +- test/CodeGen/blockwithlocalstatic.c | 6 +- test/CodeGen/bmi-builtins.c | 12 +- test/CodeGen/bool_test.c | 1 + test/CodeGen/bounds-checking.c | 26 + test/CodeGen/branch-target-layout.c | 40 + test/CodeGen/builtin-attributes.c | 1 + test/CodeGen/builtins-arm.c | 1 + test/CodeGen/builtins-mips-args.c | 14 + test/CodeGen/builtins-mips.c | 324 ++ test/CodeGen/builtins-nvptx.c | 98 + test/CodeGen/builtins-ppc-altivec.c | 1 + test/CodeGen/builtins-ptx.c | 99 - test/CodeGen/builtins-x86.c | 1 - test/CodeGen/builtins.c | 6 + test/CodeGen/capture-complex-expr-in-block.c | 2 +- test/CodeGen/catch-undef-behavior.c | 12 +- test/CodeGen/compound-literal.c | 2 +- test/CodeGen/debug-info-gline-tables-only.c | 33 + test/CodeGen/debug-info-gline-tables-only2.c | 13 + test/CodeGen/debug-info-line2.c | 5 +- test/CodeGen/debug-info-line3.c | 4 +- test/CodeGen/debug-info-vla.c | 12 + test/CodeGen/debug-line-1.c | 2 +- test/CodeGen/fma-builtins.c | 166 + test/CodeGen/fma4-builtins.c | 64 +- test/CodeGen/forceinline.c | 14 + test/CodeGen/fp-contract.c | 9 + test/CodeGen/fp16-ops.c | 1 + test/CodeGen/func-aligned.c | 2 +- test/CodeGen/func-in-block.c | 4 +- test/CodeGen/func-return-member.c | 2 +- test/CodeGen/incomplete-function-type.c | 2 +- test/CodeGen/integer-overflow.c | 8 +- test/CodeGen/libcalls.c | 45 + test/CodeGen/mips-byval-arg.c | 15 + test/CodeGen/mips-vector-arg.c | 28 + test/CodeGen/mips-vector-return.c | 31 + test/CodeGen/mips64-class-return.cpp | 2 +- test/CodeGen/ms-declspecs.c | 8 + test/CodeGen/ms-inline-asm.c | 40 + test/CodeGen/no-common.c | 2 +- test/CodeGen/nobuiltin.c | 8 + test/CodeGen/nvptx-cc.c | 9 + test/CodeGen/nvptx-inlineasm.c | 15 + test/CodeGen/object-size.c | 16 +- test/CodeGen/packed-nest-unpacked.c | 18 + test/CodeGen/pclmul-builtins.c | 11 + test/CodeGen/powerpc_types.c | 1 + test/CodeGen/pr12251.c | 2 +- test/CodeGen/pr13168.c | 7 + test/CodeGen/pr5406.c | 1 + test/CodeGen/pragma-visibility.c | 2 +- test/CodeGen/ptx-cc.c | 9 - test/CodeGen/rdrand-builtins.c | 27 + test/CodeGen/regparm-flag.c | 3 +- test/CodeGen/regparm-struct.c | 177 + test/CodeGen/sse-builtins.c | 6 + test/CodeGen/sse4a-builtins.c | 39 + test/CodeGen/struct-init.c | 1 + test/CodeGen/struct-matching-constraint.c | 1 + test/CodeGen/tbaa-for-vptr.cpp | 12 +- test/CodeGen/thread-specifier.c | 15 + test/CodeGen/tls-model.c | 28 + test/CodeGen/varargs.c | 8 +- test/CodeGen/vector-alignment.c | 38 + test/CodeGen/vla.c | 49 + test/CodeGen/vld_dup.c | 1 + test/CodeGen/x86_32-arguments-darwin.c | 13 + test/CodeGen/xop-builtins.c | 326 ++ test/CodeGenCUDA/address-spaces.cu | 24 + test/CodeGenCUDA/ptx-kernels.cu | 2 +- .../anonymous-union-member-initializer.cpp | 10 + test/CodeGenCXX/block-in-ctor-dtor.cpp | 10 +- test/CodeGenCXX/blocks.cpp | 6 +- test/CodeGenCXX/class-layout.cpp | 14 + test/CodeGenCXX/const-init-cxx11.cpp | 32 + test/CodeGenCXX/constructor-init.cpp | 20 + test/CodeGenCXX/cxx0x-delegating-ctors.cpp | 11 + test/CodeGenCXX/cxx0x-initializer-constructors.cpp | 37 + test/CodeGenCXX/cxx0x-initializer-references.cpp | 4 + test/CodeGenCXX/cxx11-initializer-aggregate.cpp | 25 + test/CodeGenCXX/cxx11-vtable-key-function.cpp | 38 + test/CodeGenCXX/debug-info-artificial-arg.cpp | 10 +- test/CodeGenCXX/debug-info-cxx0x.cpp | 10 + test/CodeGenCXX/debug-info-determinism.cpp | 16 + test/CodeGenCXX/debug-info-enum-class.cpp | 15 + test/CodeGenCXX/debug-info-flex-member.cpp | 9 + test/CodeGenCXX/debug-info-fwd-ref.cpp | 6 +- test/CodeGenCXX/debug-info-gline-tables-only.cpp | 21 + test/CodeGenCXX/debug-info-globalinit.cpp | 30 + test/CodeGenCXX/debug-info-nullptr.cpp | 2 +- test/CodeGenCXX/debug-info-rvalue-ref.cpp | 11 + test/CodeGenCXX/debug-info-static-fns.cpp | 2 +- test/CodeGenCXX/debug-info-template-array.cpp | 14 + test/CodeGenCXX/debug-info-template-limit.cpp | 5 +- test/CodeGenCXX/debug-info-template-member.cpp | 2 +- test/CodeGenCXX/debug-info-template-quals.cpp | 23 + test/CodeGenCXX/debug-info-union.cpp | 16 + test/CodeGenCXX/debug-info-user-def.cpp | 14 + test/CodeGenCXX/debug-lambda-expressions.cpp | 50 +- test/CodeGenCXX/derived-to-base-conv.cpp | 111 +- test/CodeGenCXX/destructor-debug-info.cpp | 7 +- test/CodeGenCXX/destructor-exception-spec.cpp | 12 + test/CodeGenCXX/destructors.cpp | 16 + .../devirtualize-virtual-function-calls-final.cpp | 139 +- .../devirtualize-virtual-function-calls.cpp | 30 + test/CodeGenCXX/dynamic-cast-always-null.cpp | 5 + test/CodeGenCXX/exceptions.cpp | 36 + test/CodeGenCXX/global-array-destruction.cpp | 33 +- test/CodeGenCXX/global-block-literal-helpers.cpp | 27 + test/CodeGenCXX/global-init.cpp | 107 +- test/CodeGenCXX/inline-functions.cpp | 14 + test/CodeGenCXX/lambda-expressions.cpp | 8 +- test/CodeGenCXX/mangle-lambdas.cpp | 35 +- test/CodeGenCXX/mangle-ms-abi-examples.cpp | 28 + .../mangle-ms-back-references-pr13207.cpp | 165 + test/CodeGenCXX/mangle-ms-back-references.cpp | 63 + test/CodeGenCXX/mangle-ms-cxx11.cpp | 11 + test/CodeGenCXX/mangle-ms-return-qualifiers.cpp | 173 + test/CodeGenCXX/mangle-ms-templates.cpp | 68 + test/CodeGenCXX/mangle-ms.cpp | 73 +- test/CodeGenCXX/mangle-ref-qualifiers.cpp | 8 +- test/CodeGenCXX/member-data-pointers.cpp | 13 + test/CodeGenCXX/member-function-pointers.cpp | 119 +- test/CodeGenCXX/member-init-anon-union.cpp | 6 +- test/CodeGenCXX/member-init-ctor.cpp | 14 - test/CodeGenCXX/member-pointer-type-convert.cpp | 11 - test/CodeGenCXX/microsoft-abi-array-cookies.cpp | 59 + test/CodeGenCXX/microsoft-abi-constructors.cpp | 21 + test/CodeGenCXX/microsoft-abi-methods.cpp | 89 + .../microsoft-abi-static-initializers.cpp | 52 + test/CodeGenCXX/ms_wide_predefined_expr.cpp | 20 + test/CodeGenCXX/pointers-to-data-members.cpp | 14 + test/CodeGenCXX/pr13396.cpp | 26 + test/CodeGenCXX/pragma-visibility.cpp | 28 +- test/CodeGenCXX/rvalue-references.cpp | 2 +- test/CodeGenCXX/template-instantiation.cpp | 4 +- test/CodeGenCXX/throw-expression-cleanup.cpp | 22 + test/CodeGenCXX/virt-call-offsets.cpp | 8 - test/CodeGenCXX/virt-template-vtable.cpp | 10 + test/CodeGenCXX/virtual-destructor-calls.cpp | 11 + test/CodeGenCXX/visibility-inlines-hidden.cpp | 18 + test/CodeGenCXX/visibility.cpp | 511 ++- test/CodeGenObjC/2008-11-12-Metadata.m | 2 +- test/CodeGenObjC/2008-11-24-ConstCFStrings.m | 2 +- test/CodeGenObjC/2010-03-17-StructRef.m | 2 +- test/CodeGenObjC/arc-blocks.m | 17 +- test/CodeGenObjC/arc.m | 3 + test/CodeGenObjC/assign.m | 2 +- test/CodeGenObjC/autorelease.m | 4 +- test/CodeGenObjC/bitfield-1.m | 6 +- test/CodeGenObjC/bitfield-access.m | 4 +- test/CodeGenObjC/bitfield-gnu.m | 2 +- test/CodeGenObjC/bitfield_encoding.m | 4 +- test/CodeGenObjC/block-6.m | 2 +- test/CodeGenObjC/block-var-layout.m | 2 +- test/CodeGenObjC/blocks-1.m | 4 +- test/CodeGenObjC/blocks-2.m | 6 +- test/CodeGenObjC/blocks-3.m | 2 +- test/CodeGenObjC/blocks-4.m | 2 +- test/CodeGenObjC/blocks-5.m | 2 +- test/CodeGenObjC/blocks.m | 6 +- test/CodeGenObjC/boxing.m | 95 + test/CodeGenObjC/builtins.m | 2 +- test/CodeGenObjC/category-class.m | 2 +- test/CodeGenObjC/class-type.m | 6 +- test/CodeGenObjC/constant-string-class.m | 2 +- test/CodeGenObjC/constant-strings.m | 4 +- test/CodeGenObjC/deadcode_strip_used_var.m | 4 +- test/CodeGenObjC/debug-info-block-helper.m | 4 +- test/CodeGenObjC/debug-info-crash.m | 2 +- test/CodeGenObjC/debug-info-static-var.m | 2 +- test/CodeGenObjC/debug-info-synthesis.m | 2 +- test/CodeGenObjC/encode-cstyle-method.m | 2 +- test/CodeGenObjC/encode-test-6.m | 19 + test/CodeGenObjC/encode-test.m | 2 +- test/CodeGenObjC/exceptions.m | 2 +- test/CodeGenObjC/fp2ret.m | 6 +- test/CodeGenObjC/fpret.m | 6 +- test/CodeGenObjC/getter-property-mismatch.m | 20 + test/CodeGenObjC/getter-property-type-mismatch.m | 35 + test/CodeGenObjC/gnu-exceptions.m | 2 +- test/CodeGenObjC/id-isa-codegen.m | 4 +- test/CodeGenObjC/image-info.m | 2 +- test/CodeGenObjC/implicit-objc_msgSend.m | 2 +- test/CodeGenObjC/interface-layout-64.m | 47 +- test/CodeGenObjC/interface.m | 2 +- test/CodeGenObjC/ivar-layout-64-bitfields.m | 4 +- test/CodeGenObjC/ivar-layout-array0-struct.m | 2 +- test/CodeGenObjC/ivar-layout-no-optimize.m | 4 +- test/CodeGenObjC/ivars.m | 4 +- test/CodeGenObjC/layout-bitfield-crash.m | 35 + test/CodeGenObjC/link-errors.m | 4 +- test/CodeGenObjC/local-static-block.m | 2 +- test/CodeGenObjC/messages-2.m | 2 +- test/CodeGenObjC/messages.m | 6 +- test/CodeGenObjC/metadata-symbols-32.m | 2 +- test/CodeGenObjC/misc-atomic-property.m | 2 +- test/CodeGenObjC/mrr-autorelease.m | 2 +- test/CodeGenObjC/nested-rethrow.m | 2 +- test/CodeGenObjC/next-objc-dispatch.m | 2 +- test/CodeGenObjC/no-category-class.m | 2 +- test/CodeGenObjC/nonlazy-msgSend.m | 2 +- test/CodeGenObjC/ns-constant-strings.m | 2 +- test/CodeGenObjC/objc-align.m | 2 +- test/CodeGenObjC/objc-assign-ivar.m | 2 +- test/CodeGenObjC/objc-gc-aggr-assign.m | 4 +- test/CodeGenObjC/objc-literal-debugger-test.m | 39 +- test/CodeGenObjC/objc-read-weak-byref.m | 4 +- test/CodeGenObjC/objc2-assign-global.m | 2 +- test/CodeGenObjC/objc2-new-gc-api-strongcast.m | 4 +- test/CodeGenObjC/objc2-no-write-barrier.m | 4 +- test/CodeGenObjC/objc2-retain-codegen.m | 4 +- test/CodeGenObjC/objc2-strong-cast-1.m | 4 +- test/CodeGenObjC/objc2-weak-assign.m | 4 +- test/CodeGenObjC/objc2-weak-block-call.m | 4 +- test/CodeGenObjC/objc2-weak-compare.m | 4 +- test/CodeGenObjC/objc2-weak-ivar-debug.m | 8 +- test/CodeGenObjC/objc2-weak-ivar.m | 4 +- test/CodeGenObjC/objc2-write-barrier-2.m | 4 +- test/CodeGenObjC/objc2-write-barrier-4.m | 4 +- test/CodeGenObjC/objc2-write-barrier-5.m | 4 +- test/CodeGenObjC/objc2-write-barrier.m | 4 +- test/CodeGenObjC/object-incr-decr-1.m | 2 +- test/CodeGenObjC/objfw.m | 15 + test/CodeGenObjC/predefined-expr.m | 2 +- test/CodeGenObjC/property-complex.m | 4 +- test/CodeGenObjC/property-ref-cast-to-void.m | 4 +- test/CodeGenObjC/protocol-in-extended-class.m | 2 +- test/CodeGenObjC/protocols-lazy.m | 2 +- .../rdr-6732143-dangling-block-reference.m | 2 +- test/CodeGenObjC/super-message-fragileabi.m | 2 +- test/CodeGenObjC/synchronized.m | 2 +- test/CodeGenObjC/terminate.m | 4 +- test/CodeGenObjC/undefined-protocol.m | 2 +- test/CodeGenObjC/variadic-sends.m | 4 +- test/CodeGenObjC/x86_64-struct-return-gc.m | 2 +- test/CodeGenObjCXX/arc.mm | 16 + test/CodeGenObjCXX/block-in-template-inst.mm | 2 +- test/CodeGenObjCXX/block-var-layout.mm | 2 +- test/CodeGenObjCXX/blocks.mm | 21 +- test/CodeGenObjCXX/catch-id-type.mm | 2 +- test/CodeGenObjCXX/copy.mm | 2 +- test/CodeGenObjCXX/copyable-property-object.mm | 2 +- test/CodeGenObjCXX/encode.mm | 58 +- test/CodeGenObjCXX/gc.mm | 2 +- .../CodeGenObjCXX/implicit-copy-assign-operator.mm | 2 +- test/CodeGenObjCXX/implicit-copy-constructor.mm | 2 +- test/CodeGenObjCXX/lambda-expressions.mm | 10 +- test/CodeGenObjCXX/mangle-blocks.mm | 18 +- test/CodeGenObjCXX/message-reference.mm | 2 +- test/CodeGenObjCXX/nrvo.mm | 4 +- .../CodeGenObjCXX/property-derived-to-base-conv.mm | 2 +- .../property-object-conditional-exp.mm | 2 +- test/CodeGenObjCXX/property-object-reference-2.mm | 2 +- test/CodeGenObjCXX/property-object-reference.mm | 2 +- test/CodeGenObjCXX/property-reference.mm | 2 +- test/CodeGenObjCXX/refence-assign-write-barrier.mm | 2 +- test/CodeGenObjCXX/selector-expr-lvalue.mm | 2 +- test/CodeGenObjCXX/write-barrier-global-assign.mm | 2 +- test/CodeGenOpenCL/kernel-arg-info.cl | 7 + test/CodeGenOpenCL/kernel-attributes.cl | 12 + test/CodeGenOpenCL/ptx-calls.cl | 2 +- test/CodeGenOpenCL/ptx-kernels.cl | 2 +- test/Coverage/codegen-gnu.m | 2 +- .../basic_android_tree/usr/lib/crtbegin_dynamic.o | 0 .../basic_android_tree/usr/lib/crtbegin_so.o | 0 .../basic_android_tree/usr/lib/crtbegin_static.o | 0 .../basic_android_tree/usr/lib/crtend_android.o | 0 .../Inputs/basic_android_tree/usr/lib/crtend_so.o | 0 .../debian_multiarch_tree/lib/mips-linux-gnu/.keep | 0 .../lib/mipsel-linux-gnu/.keep | 0 .../usr/include/c++/4.5/mips-linux-gnu/.keep | 0 .../usr/include/c++/4.5/mipsel-linux-gnu/.keep | 0 .../usr/include/mips-linux-gnu/.keep | 0 .../usr/include/mipsel-linux-gnu/.keep | 0 .../usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o | 0 .../usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o | 0 .../usr/lib/gcc/mips-linux-gnu/4.5/n32/crtbegin.o | 0 .../usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o | 0 .../usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o | 0 .../lib/gcc/mipsel-linux-gnu/4.5/n32/crtbegin.o | 0 .../usr/lib/mips-linux-gnu/.keep | 0 .../usr/lib/mipsel-linux-gnu/.keep | 0 .../lib/gcc/i686-montavista-linux/4.2.0/crtbegin.o | 1 + .../lib/gcc/i686-montavista-linux/4.2.0/libgcc.a | 1 + .../ubuntu_12.04_LTS_multiarch_tree/lib/.keep | 0 .../lib/arm-linux-gnueabi/.keep | 0 .../lib/arm-linux-gnueabihf/.keep | 0 .../usr/include/.keep | 0 .../usr/include/arm-linux-gnueabi/.keep | 0 .../usr/include/arm-linux-gnueabihf/.keep | 0 .../ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep | 0 .../usr/lib/arm-linux-gnueabi/crt1.o | 0 .../usr/lib/arm-linux-gnueabi/crti.o | 0 .../usr/lib/arm-linux-gnueabi/crtn.o | 0 .../usr/lib/arm-linux-gnueabihf/crt1.o | 0 .../usr/lib/arm-linux-gnueabihf/crti.o | 0 .../usr/lib/arm-linux-gnueabihf/crtn.o | 0 .../usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o | 0 .../usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o | 0 .../lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o | 0 .../usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o | 0 test/Driver/altivec.cpp | 3 +- test/Driver/apple-kext-i386.cpp | 5 + test/Driver/arc.c | 4 +- test/Driver/arclite-link.c | 11 +- test/Driver/asan-ld.c | 31 + test/Driver/bounds-checking.c | 7 + test/Driver/ccc-as-cpp.c | 6 + test/Driver/clang-translation.c | 30 + test/Driver/clang_f_opts.c | 9 + test/Driver/clang_f_opts.h | 2 + test/Driver/constructors.c | 14 + test/Driver/crash-report.c | 27 + test/Driver/darwin-ld.c | 5 + test/Driver/darwin-objc-defaults.m | 18 +- test/Driver/darwin-objc-options.m | 15 +- test/Driver/debug-options-as.c | 6 +- test/Driver/debug-options.c | 49 +- test/Driver/debug-unsupported.c | 13 + test/Driver/fast-math.c | 24 +- test/Driver/flags.c | 2 + test/Driver/fpack-struct.c | 10 + test/Driver/freebsd.c | 16 + test/Driver/gnu-runtime.m | 5 +- test/Driver/ios-simulator-arcruntime.c | 8 +- test/Driver/linker-opts.c | 2 +- test/Driver/linux-as.c | 37 +- test/Driver/linux-ld.c | 130 + test/Driver/mips-as.c | 19 +- test/Driver/mips-features.c | 39 + test/Driver/mips-float.c | 1 + test/Driver/montavista-gcc-toolchain.c | 9 + test/Driver/msvc_forward.c | 5 + test/Driver/nodefaultlib.c | 8 + test/Driver/rewrite-legacy-objc.m | 2 +- test/Driver/rewrite-objc.m | 2 +- test/Driver/target-triple-deployment.c | 33 + test/Driver/warning-options.cpp | 10 + test/Driver/warning-options_pedantic.cpp | 7 + test/FixIt/fixit-autoreleasepool.m | 9 + test/FixIt/fixit-cxx0x.cpp | 14 + test/FixIt/fixit-include.c | 13 + test/FixIt/fixit-include.h | 1 + test/FixIt/fixit-interface-as-param.m | 11 + test/FixIt/fixit-objc-message-comma-separator.m | 17 + test/FixIt/fixit-unicode.c | 33 + test/FixIt/fixit-vexing-parse.cpp | 51 +- test/FixIt/fixit.c | 8 + test/FixIt/fixit.cpp | 90 +- test/FixIt/format-no-fixit.m | 30 + test/FixIt/format.m | 95 + test/FixIt/messages.cpp | 13 + test/FixIt/objc-literals.m | 16 +- .../Inputs/SystemHeaderPrefix/libs/boost/all.h | 1 + .../Inputs/SystemHeaderPrefix/libs/boost/warn.h | 2 + .../Inputs/SystemHeaderPrefix/libs/mylib/all.h | 1 + .../Inputs/SystemHeaderPrefix/libs/mylib/warn.h | 2 + test/Frontend/Inputs/SystemHeaderPrefix/src/all.h | 6 + test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h | 2 + test/Frontend/Inputs/rewrite-includes1.h | 3 + test/Frontend/Inputs/rewrite-includes2.h | 1 + test/Frontend/Inputs/rewrite-includes3.h | 1 + test/Frontend/Inputs/rewrite-includes4.h | 1 + test/Frontend/Inputs/rewrite-includes5.h | 1 + test/Frontend/Inputs/rewrite-includes6.h | 2 + test/Frontend/Inputs/rewrite-includes7.h | 4 + test/Frontend/rewrite-includes-missing.c | 7 + test/Frontend/rewrite-includes.c | 145 + test/Frontend/system-header-prefix.c | 11 + test/Frontend/verify-directive.h | 2 + test/Frontend/verify-fatal.c | 12 + test/Frontend/verify.c | 125 + test/Frontend/verify2.c | 19 + test/Frontend/verify2.h | 5 + test/Headers/ms-null-ms-header-vs-stddef.cpp | 16 + .../Inputs/CommentXML/invalid-function-01.xml | 7 + .../Inputs/CommentXML/invalid-function-02.xml | 9 + .../Inputs/CommentXML/invalid-function-03.xml | 11 + .../Inputs/CommentXML/invalid-function-04.xml | 11 + .../Inputs/CommentXML/invalid-function-05.xml | 10 + .../Inputs/CommentXML/invalid-function-06.xml | 5 + .../Inputs/CommentXML/invalid-function-07.xml | 13 + .../Inputs/CommentXML/invalid-function-08.xml | 13 + .../Inputs/CommentXML/invalid-function-09.xml | 13 + .../Inputs/CommentXML/invalid-function-10.xml | 11 + .../Inputs/CommentXML/invalid-function-11.xml | 13 + .../Inputs/CommentXML/invalid-function-12.xml | 6 + test/Index/Inputs/CommentXML/valid-class-01.xml | 5 + test/Index/Inputs/CommentXML/valid-class-02.xml | 5 + test/Index/Inputs/CommentXML/valid-class-03.xml | 5 + test/Index/Inputs/CommentXML/valid-class-04.xml | 5 + test/Index/Inputs/CommentXML/valid-enum-01.xml | 6 + test/Index/Inputs/CommentXML/valid-function-01.xml | 5 + test/Index/Inputs/CommentXML/valid-function-02.xml | 5 + test/Index/Inputs/CommentXML/valid-function-03.xml | 12 + test/Index/Inputs/CommentXML/valid-function-04.xml | 13 + test/Index/Inputs/CommentXML/valid-function-05.xml | 8 + test/Index/Inputs/CommentXML/valid-function-06.xml | 6 + test/Index/Inputs/CommentXML/valid-function-07.xml | 30 + test/Index/Inputs/CommentXML/valid-function-08.xml | 17 + test/Index/Inputs/CommentXML/valid-function-09.xml | 6 + test/Index/Inputs/CommentXML/valid-function-10.xml | 6 + .../Index/Inputs/CommentXML/valid-namespace-01.xml | 6 + test/Index/Inputs/CommentXML/valid-other-01.xml | 5 + test/Index/Inputs/CommentXML/valid-typedef-01.xml | 6 + test/Index/Inputs/CommentXML/valid-typedef-02.xml | 25 + test/Index/Inputs/CommentXML/valid-variable-01.xml | 6 + test/Index/Inputs/annotate-comments-preprocessor.h | 2 + test/Index/annotate-comments-preprocessor.c | 45 + test/Index/annotate-comments-unterminated.c | 13 + test/Index/annotate-comments.cpp | 926 ++++ test/Index/availability.c | 10 + test/Index/boxed-exprs.h | 10 + test/Index/boxed-exprs.m | 19 + test/Index/c-index-api-loadTU-test.m | 2 +- test/Index/comment-xml-schema.c | 43 + test/Index/compile_commands.json | 27 + test/Index/complete-documentation.cpp | 51 + test/Index/complete-exprs.m | 10 +- test/Index/complete-lambdas.mm | 51 + test/Index/complete-method-decls.m | 2 +- test/Index/complete-properties.m | 14 + test/Index/create-tu-fail.c | 10 + test/Index/cursor-dynamic-call.mm | 59 + test/Index/get-cursor.c | 6 + test/Index/get-cursor.cpp | 10 + test/Index/get-cursor.m | 33 + test/Index/index-decls.m | 17 +- test/Index/index-kernel-invocation.cpp | 4 + test/Index/index-many-call-ops.cpp | 47 + test/Index/index-refs.m | 18 + test/Index/overrides.m | 58 + test/Index/pch-with-errors.c | 4 +- test/Index/print-typekind.m | 6 +- test/Index/recursive-cxx-member-calls.cpp | 5 +- test/Lexer/bcpl-escaped-newline.c | 3 +- test/Lexer/c90.c | 7 + test/Lexer/char-literal.cpp | 3 + test/Lexer/hexfloat.cpp | 8 + test/Lexer/newline-eof.c | 4 + test/Lexer/pragma-operators.cpp | 1 - test/Lexer/wchar-signedness.c | 8 + test/Misc/ast-dump-wchar.cpp | 13 + test/Misc/diag-aka-types.cpp | 23 +- test/Misc/diag-template-diffing-color.cpp | 19 + test/Misc/diag-template-diffing.cpp | 433 ++ test/Misc/diag-trailing-null-bytes.cpp | 10 + test/Misc/emit-html.c | 8 + test/Misc/integer-literal-printing.cpp | 4 +- test/Misc/serialized-diags-frontend.c | 8 + test/Misc/show-diag-options.c | 2 +- test/Misc/tabstop.c | 9 + test/Misc/warning-flags-enabled.c | 27 + test/Misc/warning-flags-tree.c | 56 + test/Misc/warning-flags.c | 103 +- test/Misc/wnull-character.cpp | Bin 143 -> 0 bytes .../Inputs/Module.framework/Headers/Module.h | 6 +- test/Modules/Inputs/category_right.h | 2 +- test/Modules/Inputs/import-decl.h | 1 + test/Modules/Inputs/module.map | 3 + test/Modules/cstd.m | 2 +- test/Modules/import-decl.cpp | 10 + test/Modules/lookup.cpp | 2 + test/Modules/objc-categories.m | 1 + test/Modules/on-demand-build.m | 5 +- test/PCH/Inputs/__va_list_tag.h | 5 + test/PCH/__va_list_tag.c | 12 + test/PCH/attrs.c | 3 +- test/PCH/badpch-dir.h.gch/.keep | 0 test/PCH/badpch-empty.h.gch | 0 test/PCH/badpch.c | 13 + test/PCH/chain-staticvar-instantiation.cpp | 45 + test/PCH/chain-trivial.c | 2 - test/PCH/cxx-friends.cpp | 8 + test/PCH/cxx-friends.h | 12 + test/PCH/cxx-member-init.cpp | 4 + test/PCH/cxx-static_assert.cpp | 3 +- test/PCH/cxx-trailing-return.cpp | 6 +- test/PCH/cxx0x-default-delete.cpp | 12 +- test/PCH/cxx0x-delegating-ctors.cpp | 12 +- test/PCH/cxx11-constexpr.cpp | 6 +- test/PCH/cxx11-enum-template.cpp | 4 +- test/PCH/cxx11-user-defined-literals.cpp | 3 +- test/PCH/empty-with-headers.c | 27 + test/PCH/exprs.h | 2 +- test/PCH/format-strings.c | 18 + test/PCH/ms-if-exists.cpp | 3 +- test/PCH/objc_methods.h | 30 + test/PCH/objc_methods.m | 2 +- test/PCH/objc_stmts.m | 4 +- test/PCH/pch__VA_ARGS__.c | 6 + test/PCH/pch__VA_ARGS__.h | 2 + test/PCH/remap-file-from-pch.cpp | 10 + test/PCH/remap-file-from-pch.cpp.h | 2 + test/PCH/remap-file-from-pch.cpp.remap.h | 4 + test/PCH/replaced-decl.m | 3 +- test/PCH/typo2.cpp | 3 +- test/PCH/variables.c | 12 +- test/Parser/DelayedTemplateParsing.cpp | 13 +- test/Parser/MicrosoftExtensions.c | 43 +- test/Parser/MicrosoftExtensions.cpp | 60 +- test/Parser/altivec.c | 10 + test/Parser/c1x-alignas.c | 8 +- test/Parser/completely-empty-header-file.h | 0 test/Parser/cuda-kernel-call.cu | 7 + test/Parser/cxx-class.cpp | 8 +- test/Parser/cxx-decl.cpp | 6 +- test/Parser/cxx-extra-semi.cpp | 41 + test/Parser/cxx-template-argument.cpp | 15 + test/Parser/cxx-throw.cpp | 2 + test/Parser/cxx-undeclared-identifier.cpp | 12 + test/Parser/cxx-using-declaration.cpp | 16 + test/Parser/cxx-using-directive.cpp | 5 +- test/Parser/cxx0x-ambig.cpp | 6 +- test/Parser/cxx0x-attributes.cpp | 135 +- test/Parser/cxx0x-decl.cpp | 16 +- test/Parser/cxx0x-lambda-expressions.cpp | 7 + test/Parser/cxx11-type-specifier.cpp | 4 + test/Parser/declarators.c | 12 + test/Parser/empty-translation-unit.c | 10 + test/Parser/missing-selector-name.mm | 52 + test/Parser/ms-inline-asm.c | 33 +- test/Parser/objc-boxing.m | 26 + test/Parser/objc-diag-width.mm | 8 + test/Parser/objc-forcollection-neg.m | 4 +- test/Parser/objc-init.m | 4 +- test/Parser/objc-recover.mm | 64 + test/Parser/objcxx11-attributes.mm | 3 +- test/Parser/opencl-pragma.cl | 2 +- test/Parser/recovery.c | 5 +- test/Parser/recovery.cpp | 12 +- test/Preprocessor/_Pragma-location.c | 49 +- test/Preprocessor/comment_save.c | 14 + test/Preprocessor/disabled-cond-diags2.c | 27 + test/Preprocessor/has_attribute.c | 10 + test/Preprocessor/has_include.c | 48 +- test/Preprocessor/init.c | 440 +- test/Preprocessor/line-directive.c | 14 +- test/Preprocessor/macro_fn.c | 18 +- test/Preprocessor/macro_paste_c_block_comment.c | 4 + test/Preprocessor/macro_paste_identifier_error.c | 7 + test/Preprocessor/mmx.c | 3 + test/Preprocessor/non_fragile_feature1.m | 2 +- test/Preprocessor/pp-record.c | 11 + test/Preprocessor/predefined-arch-macros.c | 205 +- test/Preprocessor/predefined-macros.c | 13 + test/Preprocessor/undef-error.c | 2 +- test/Preprocessor/warning_tests.c | 8 +- test/Rewriter/blockcast3.mm | 2 +- test/Rewriter/blockstruct.m | 2 +- test/Rewriter/crash.m | 2 +- test/Rewriter/finally.m | 2 +- test/Rewriter/func-in-impl.m | 2 +- test/Rewriter/id-test-3.m | 2 +- test/Rewriter/inner-block-helper-funcs.mm | 2 +- test/Rewriter/instancetype-test.mm | 2 +- test/Rewriter/ivar-encoding-1.m | 2 +- test/Rewriter/ivar-encoding-2.m | 2 +- test/Rewriter/metadata-test-1.m | 2 +- test/Rewriter/metadata-test-2.m | 2 +- test/Rewriter/method-encoding-1.m | 2 +- test/Rewriter/objc-bool-literal-modern-1.mm | 3 + test/Rewriter/objc-encoding-bug-1.m | 2 +- test/Rewriter/objc-ivar-receiver-1.m | 4 +- test/Rewriter/objc-modern-StretAPI.mm | 45 + test/Rewriter/objc-modern-boxing.mm | 72 + test/Rewriter/objc-modern-container-subscript.mm | 3 +- test/Rewriter/objc-modern-getclass-proto.mm | 10 + test/Rewriter/objc-modern-property-attributes.mm | 10 + test/Rewriter/objc-string-concat-1.m | 2 +- test/Rewriter/objc-super-test.m | 2 +- test/Rewriter/objc-synchronized-1.m | 2 +- test/Rewriter/properties.m | 2 +- test/Rewriter/property-dot-syntax.mm | 2 +- test/Rewriter/protocol-rewrite-1.m | 2 +- test/Rewriter/protocol-rewrite-2.m | 2 +- test/Rewriter/rewrite-anonymous-union.m | 2 +- test/Rewriter/rewrite-api-bug.m | 2 +- test/Rewriter/rewrite-block-argument.m | 2 +- test/Rewriter/rewrite-block-consts.mm | 2 +- test/Rewriter/rewrite-block-ivar-call.mm | 2 +- test/Rewriter/rewrite-block-literal-1.mm | 5 +- test/Rewriter/rewrite-block-literal.mm | 5 +- test/Rewriter/rewrite-block-pointer.mm | 5 +- test/Rewriter/rewrite-block-property.m | 2 +- test/Rewriter/rewrite-byref-in-nested-blocks.mm | 9 +- test/Rewriter/rewrite-byref-vars.mm | 4 +- test/Rewriter/rewrite-cast-ivar-access.mm | 2 +- test/Rewriter/rewrite-cast-to-bool.mm | 2 +- test/Rewriter/rewrite-category-property.mm | 2 +- test/Rewriter/rewrite-constructor-init.mm | 2 +- test/Rewriter/rewrite-eh.m | 2 +- test/Rewriter/rewrite-elaborated-type.mm | 2 +- test/Rewriter/rewrite-extern-c.mm | 2 +- test/Rewriter/rewrite-foreach-1.m | 2 +- test/Rewriter/rewrite-foreach-2.m | 2 +- test/Rewriter/rewrite-foreach-3.m | 2 +- test/Rewriter/rewrite-foreach-4.m | 2 +- test/Rewriter/rewrite-foreach-5.m | 2 +- test/Rewriter/rewrite-foreach-6.m | 2 +- test/Rewriter/rewrite-foreach-7.m | 2 +- test/Rewriter/rewrite-foreach-in-block.mm | 4 +- test/Rewriter/rewrite-foreach-protocol-id.m | 2 +- test/Rewriter/rewrite-forward-class.m | 2 +- test/Rewriter/rewrite-forward-class.mm | 2 +- test/Rewriter/rewrite-function-decl.mm | 2 +- test/Rewriter/rewrite-implementation.mm | 2 +- test/Rewriter/rewrite-ivar-use.m | 2 +- test/Rewriter/rewrite-local-externs-in-block.mm | 2 +- test/Rewriter/rewrite-local-static-id.mm | 2 +- test/Rewriter/rewrite-message-expr.mm | 2 +- test/Rewriter/rewrite-modern-atautoreleasepool.mm | 32 + test/Rewriter/rewrite-modern-block-consts.mm | 22 + test/Rewriter/rewrite-modern-block.mm | 44 +- .../rewrite-modern-captured-nested-bvar.mm | 35 + .../rewrite-modern-default-property-synthesis.mm | 80 + test/Rewriter/rewrite-modern-extern-c-func-decl.mm | 49 + test/Rewriter/rewrite-modern-ivar-access.mm | 98 + test/Rewriter/rewrite-modern-ivars-1.mm | 37 +- test/Rewriter/rewrite-modern-private-ivars.mm | 53 + test/Rewriter/rewrite-modern-struct-ivar-1.mm | 48 + test/Rewriter/rewrite-modern-struct-ivar.mm | 32 +- test/Rewriter/rewrite-modern-typeof.mm | 1 + test/Rewriter/rewrite-nest.m | 2 +- test/Rewriter/rewrite-nested-blocks-1.mm | 3 +- test/Rewriter/rewrite-nested-blocks-2.mm | 3 +- test/Rewriter/rewrite-nested-blocks.mm | 3 +- test/Rewriter/rewrite-nested-ivar.mm | 2 +- test/Rewriter/rewrite-nested-property-in-blocks.mm | 3 +- test/Rewriter/rewrite-no-nextline.mm | 2 +- test/Rewriter/rewrite-property-attributes.mm | 2 +- test/Rewriter/rewrite-property-set-cfstring.mm | 2 +- test/Rewriter/rewrite-protocol-property.mm | 2 +- test/Rewriter/rewrite-protocol-qualified.mm | 2 +- test/Rewriter/rewrite-protocol-type-1.m | 2 +- test/Rewriter/rewrite-qualified-id.mm | 2 +- test/Rewriter/rewrite-rewritten-initializer.mm | 7 +- test/Rewriter/rewrite-static-block.mm | 2 +- test/Rewriter/rewrite-super-message.mm | 2 +- test/Rewriter/rewrite-trivial-constructor.mm | 2 +- test/Rewriter/rewrite-try-catch.m | 2 +- test/Rewriter/rewrite-typeof.mm | 2 +- test/Rewriter/rewrite-unique-block-api.mm | 3 +- test/Rewriter/rewrite-user-defined-accessors.mm | 2 +- test/Rewriter/rewrite-vararg.m | 2 +- test/Rewriter/rewrite-weak-attr.m | 2 +- test/Rewriter/static-type-protocol-1.m | 2 +- test/Rewriter/undecl-objc-h.m | 2 +- test/Rewriter/undeclared-method-1.m | 2 +- test/Rewriter/undef-field-reference-1.m | 2 +- test/Rewriter/va-method.m | 2 +- test/Rewriter/weak_byref_objects.m | 2 +- test/Sema/128bitint.c | 9 +- test/Sema/Inputs/format-unused-system-args.h | 8 + test/Sema/MicrosoftCompatibility.c | 7 +- test/Sema/MicrosoftExtensions.c | 8 +- test/Sema/alignas.c | 13 +- test/Sema/alloc_size.c | 26 + test/Sema/annotate.c | 5 +- test/Sema/array-bounds-ptr-arith.c | 18 + test/Sema/array-init.c | 2 +- test/Sema/attr-aligned.c | 2 +- test/Sema/attr-availability-ios.c | 8 +- test/Sema/attr-availability-macosx.c | 2 +- test/Sema/attr-availability.c | 21 +- test/Sema/attr-coldhot.c | 10 + test/Sema/attr-decl-after-definition.c | 22 +- test/Sema/attr-deprecated-message.c | 8 +- test/Sema/attr-deprecated.c | 29 +- test/Sema/attr-nodebug.c | 7 +- test/Sema/attr-section.c | 4 + test/Sema/attr-tls_model.c | 14 + test/Sema/attr-unavailable-message.c | 4 +- test/Sema/attr-visibility.c | 15 + test/Sema/c89-2.c | 2 +- test/Sema/compare.c | 7 + test/Sema/conditional-expr.c | 2 +- test/Sema/const-eval.c | 3 + test/Sema/dllimport-dllexport.c | 6 + test/Sema/exprs.c | 15 +- test/Sema/format-strings-enum-fixed-type.cpp | 92 + test/Sema/format-strings-enum.c | 36 + test/Sema/format-strings-fixit.c | 34 + test/Sema/format-strings-scanf.c | 55 + test/Sema/format-strings-size_t.c | 13 + test/Sema/format-strings.c | 117 +- test/Sema/fpack-struct.c | 4 +- test/Sema/implicit-builtin-decl.c | 2 + test/Sema/inline.c | 72 + test/Sema/invalid-decl.c | 9 + test/Sema/knr-def-call.c | 4 +- test/Sema/ms_class_layout.cpp | 173 + test/Sema/ms_wide_predefined_expr.cpp | 25 + test/Sema/pragma-pack-6.c | 16 + test/Sema/switch.c | 31 +- test/Sema/thread-specifier.c | 12 +- test/Sema/tls.c | 20 + test/Sema/typeof-use-deprecated.c | 12 +- test/Sema/uninit-variables.c | 104 +- test/Sema/unused-expr.c | 3 +- test/Sema/vector-ops.c | 2 +- test/Sema/warn-documentation-almost-trailing.c | 14 + test/Sema/warn-documentation-fixits.cpp | 27 + test/Sema/warn-documentation.cpp | 670 +++ test/Sema/warn-documentation.m | 93 + test/Sema/warn-outof-range-assign-enum.c | 32 + test/Sema/warn-self-assign-field.mm | 66 + test/Sema/warn-strncat-size.c | 7 +- test/SemaCXX/MicrosoftCompatibility.cpp | 4 + .../SemaCXX/MicrosoftCompatibilityNoExceptions.cpp | 8 + test/SemaCXX/PR10243.cpp | 4 +- test/SemaCXX/abstract.cpp | 14 + test/SemaCXX/address-of-temporary.cpp | 40 +- test/SemaCXX/alias-template.cpp | 27 + test/SemaCXX/altivec.cpp | 7 +- test/SemaCXX/anonymous-union-cxx11.cpp | 13 + test/SemaCXX/array-bound-merge.cpp | 2 + test/SemaCXX/arrow-operator.cpp | 28 + test/SemaCXX/attr-deprecated.cpp | 42 +- test/SemaCXX/attr-visibility.cpp | 20 + test/SemaCXX/bool.cpp | 2 +- test/SemaCXX/condition.cpp | 2 +- test/SemaCXX/conditional-expr.cpp | 26 +- test/SemaCXX/constant-expression-cxx11.cpp | 130 +- test/SemaCXX/constant-expression.cpp | 9 +- test/SemaCXX/constexpr-many-arguments.cpp | 42 + test/SemaCXX/constructor-initializer.cpp | 13 +- test/SemaCXX/conversion-function.cpp | 11 + test/SemaCXX/conversion.cpp | 60 +- test/SemaCXX/crashes.cpp | 32 + test/SemaCXX/cxx0x-cursory-default-delete.cpp | 21 +- test/SemaCXX/cxx0x-defaulted-functions.cpp | 110 +- test/SemaCXX/cxx0x-initializer-aggregates.cpp | 29 + test/SemaCXX/cxx0x-initializer-constructor.cpp | 23 + .../cxx0x-initializer-stdinitializerlist.cpp | 12 + test/SemaCXX/cxx98-compat-pedantic.cpp | 2 +- test/SemaCXX/cxx98-compat.cpp | 61 +- test/SemaCXX/dcl_ambig_res.cpp | 6 +- test/SemaCXX/dcl_init_aggr.cpp | 2 +- test/SemaCXX/decl-expr-ambiguity.cpp | 33 +- test/SemaCXX/default1.cpp | 9 +- test/SemaCXX/deleted-function.cpp | 10 + test/SemaCXX/deleted-operator.cpp | 4 +- test/SemaCXX/elaborated-type-specifier.cpp | 7 +- test/SemaCXX/enum-scoped.cpp | 7 + test/SemaCXX/expressions.cpp | 2 +- test/SemaCXX/format-strings-0x.cpp | 12 + test/SemaCXX/function-extern-c.cpp | 2 + test/SemaCXX/function-redecl.cpp | 28 +- test/SemaCXX/implicit-exception-spec.cpp | 17 +- test/SemaCXX/invalid-member-expr.cpp | 31 + test/SemaCXX/lambda-expressions.cpp | 141 +- test/SemaCXX/literal-operators.cpp | 1 + test/SemaCXX/long-virtual-inheritance-chain.cpp | 53 + test/SemaCXX/member-expr.cpp | 10 + test/SemaCXX/member-init.cpp | 4 +- test/SemaCXX/member-operator-expr.cpp | 5 + test/SemaCXX/microsoft-cxx0x.cpp | 14 + test/SemaCXX/neon-vector-types.cpp | 19 +- test/SemaCXX/nested-name-spec.cpp | 14 +- test/SemaCXX/no-rtti.cpp | 10 + test/SemaCXX/nullptr.cpp | 4 +- test/SemaCXX/offsetof-0x.cpp | 20 + test/SemaCXX/overload-call.cpp | 34 +- test/SemaCXX/overload-member-call.cpp | 13 +- test/SemaCXX/overloaded-builtin-operators.cpp | 33 +- test/SemaCXX/pr13353.cpp | 13 + test/SemaCXX/pr13394-crash-on-invalid.cpp | 16 + test/SemaCXX/printf-block.cpp | 18 + test/SemaCXX/printf-cstr.cpp | 53 + test/SemaCXX/qualified-id-lookup.cpp | 5 +- test/SemaCXX/reinterpret-cast.cpp | 2 +- test/SemaCXX/static-assert.cpp | 14 + test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp | 119 + .../switch-implicit-fallthrough-per-method.cpp | 51 + test/SemaCXX/switch-implicit-fallthrough.cpp | 197 + test/SemaCXX/type-traits.cpp | 35 +- test/SemaCXX/typo-correction.cpp | 44 + test/SemaCXX/uninit-variables.cpp | 6 + test/SemaCXX/uninitialized.cpp | 165 +- test/SemaCXX/unknown-type-name.cpp | 56 + test/SemaCXX/unused.cpp | 48 +- test/SemaCXX/user-defined-conversions.cpp | 2 +- test/SemaCXX/virtuals.cpp | 2 +- test/SemaCXX/warn-deprecated-header.cpp | 3 +- test/SemaCXX/warn-literal-conversion.cpp | 28 +- test/SemaCXX/warn-loop-analysis.cpp | 154 + test/SemaCXX/warn-memset-bad-sizeof.cpp | 24 +- test/SemaCXX/warn-static-function-inheader.cpp | 12 + test/SemaCXX/warn-static-function-inheader.h | 3 + test/SemaCXX/warn-thread-safety-analysis.cpp | 1008 ++++- test/SemaCXX/warn-thread-safety-parsing.cpp | 857 ++-- test/SemaCXX/warn-unique-enum.cpp | 27 + test/SemaCXX/warn-unused-private-field.cpp | 246 ++ test/SemaCXX/warn-unused-value.cpp | 2 +- test/SemaObjC/arc-bridged-cast.m | 26 +- test/SemaObjC/arc-cf.m | 10 +- test/SemaObjC/arc-dict-bridged-cast.m | 46 + test/SemaObjC/arc-no-runtime.m | 2 +- test/SemaObjC/arc-property-lifetime.m | 5 + test/SemaObjC/arc-property.m | 10 +- test/SemaObjC/arc-retain-block-property.m | 30 - test/SemaObjC/arc-unbridged-cast.m | 8 +- test/SemaObjC/arc.m | 23 +- test/SemaObjC/assign-rvalue-message.m | 2 +- test/SemaObjC/at-defs.m | 2 +- test/SemaObjC/attr-availability.m | 16 +- test/SemaObjC/attr-deprecated.m | 27 +- test/SemaObjC/blocks.m | 121 + test/SemaObjC/boxing-illegal-types.m | 58 + test/SemaObjC/category-1.m | 9 + test/SemaObjC/class-bitfield.m | 2 +- test/SemaObjC/cocoa-api-usage.m | 8 +- test/SemaObjC/cocoa-api-usage.m.fixed | 8 +- test/SemaObjC/conflicting-ivar-test-1.m | 2 +- test/SemaObjC/continuation-class-err.m | 10 +- test/SemaObjC/continuation-class-property.m | 4 +- test/SemaObjC/dealloc.m | 25 + test/SemaObjC/default-synthesize-1.m | 30 +- test/SemaObjC/default-synthesize-2.m | 19 +- test/SemaObjC/delay-parsing-cfunctions.m | 43 + test/SemaObjC/direct-synthesized-ivar-access.m | 2 +- test/SemaObjC/duplicate-property-class-extension.m | 2 +- test/SemaObjC/error-implicit-property.m | 2 +- test/SemaObjC/format-strings-objc.m | 57 +- test/SemaObjC/format-strings-system.h | 10 + .../getter-setter-defined-in-category-of-parent.m | 26 + test/SemaObjC/iboutlet.m | 23 + test/SemaObjC/id-isa-ref.m | 35 - test/SemaObjC/id.m | 12 +- test/SemaObjC/interface-1.m | 2 +- test/SemaObjC/interface-layout.m | 2 +- test/SemaObjC/ivar-in-class-extension-error.m | 2 +- test/SemaObjC/method-bad-param.m | 2 +- test/SemaObjC/method-prototype-scope.m | 4 +- test/SemaObjC/mismatched-undefined-method.m | 13 + test/SemaObjC/narrow-property-type-in-cont-class.m | 2 +- test/SemaObjC/no-ivar-in-interface-block.m | 32 + test/SemaObjC/nowarn-superclass-method-mismatch.m | 20 + test/SemaObjC/nsobject-attribute.m | 12 +- test/SemaObjC/objc-container-subscripting-2.m | 4 +- test/SemaObjC/objc-container-subscripting-3.m | 2 +- test/SemaObjC/objc-container-subscripting.m | 8 +- test/SemaObjC/objc-cstyle-args-in-methods.m | 2 +- test/SemaObjC/objc-dictionary-literal.m | 2 +- test/SemaObjC/objc-literal-comparison.m | 96 + test/SemaObjC/objc-literal-nsnumber.m | 4 + test/SemaObjC/objc-literal-sig.m | 17 +- test/SemaObjC/property-10.m | 2 +- test/SemaObjC/property-12.m | 37 +- test/SemaObjC/property-impl-misuse.m | 17 +- test/SemaObjC/property-ivar-mismatch.m | 12 + test/SemaObjC/property-typecheck-1.m | 8 +- test/SemaObjC/property-user-setter.m | 52 + test/SemaObjC/property.m | 4 +- test/SemaObjC/protocol-attribute.m | 2 +- test/SemaObjC/protocols.m | 2 +- test/SemaObjC/provisional-ivar-lookup.m | 2 +- test/SemaObjC/related-result-type-inference.m | 8 +- test/SemaObjC/sizeof-interface.m | 18 +- test/SemaObjC/special-dep-unavail-warning.m | 2 +- test/SemaObjC/tentative-property-decl.m | 47 + test/SemaObjC/unused.m | 2 + test/SemaObjC/warn-deprecated-implementations.m | 2 +- test/SemaObjC/warn-direct-ivar-access.m | 56 + test/SemaObjC/warn-isa-ref.m | 83 + test/SemaObjC/warn-protocol-method-deprecated.m | 32 + test/SemaObjC/warn-retain-block-property.m | 32 + test/SemaObjC/weak-receiver-warn.m | 65 +- test/SemaObjCXX/arc-0x.mm | 32 +- test/SemaObjCXX/arc-templates.mm | 17 + test/SemaObjCXX/arc-type-traits.mm | 126 +- test/SemaObjCXX/arc-unbridged-cast.mm | 8 +- test/SemaObjCXX/boxing-illegal-types.mm | 58 + test/SemaObjCXX/crash.mm | 23 + test/SemaObjCXX/delay-parsing-cfunctions.mm | 48 + test/SemaObjCXX/delay-parsing-cplusfuncs.mm | 52 + test/SemaObjCXX/delay-parsing-func-tryblock.mm | 66 + test/SemaObjCXX/exceptions-fragile.mm | 2 +- test/SemaObjCXX/foreach.mm | 61 + test/SemaObjCXX/fragile-abi-object-assign.m | 2 +- test/SemaObjCXX/instantiate-stmt.mm | 8 +- test/SemaObjCXX/message.mm | 2 +- test/SemaObjCXX/objc-container-subscripting.mm | 4 +- test/SemaObjCXX/property-synthesis-error.mm | 13 +- test/SemaObjCXX/protocol-lookup.mm | 2 +- test/SemaObjCXX/warn-missing-super.mm | 19 + test/SemaOpenCL/storageclass.cl | 12 + test/SemaOpenCL/warn-missing-prototypes.cl | 6 + test/SemaTemplate/alias-templates.cpp | 76 +- test/SemaTemplate/class-template-decl.cpp | 42 + test/SemaTemplate/delegating-constructors.cpp | 18 + test/SemaTemplate/dependent-base-classes.cpp | 3 +- test/SemaTemplate/explicit-instantiation.cpp | 4 +- test/SemaTemplate/friend-template.cpp | 59 + .../instantiate-exception-spec-cxx11.cpp | 14 + test/SemaTemplate/instantiate-expr-1.cpp | 2 +- test/SemaTemplate/instantiate-init.cpp | 15 +- test/SemaTemplate/instantiate-member-class.cpp | 7 +- test/SemaTemplate/instantiate-method.cpp | 7 + test/SemaTemplate/instantiate-objc-1.mm | 21 + test/SemaTemplate/instantiation-backtrace.cpp | 19 + test/SemaTemplate/instantiation-depth-defarg.cpp | 36 + test/SemaTemplate/instantiation-depth-subst-2.cpp | 9 + test/SemaTemplate/instantiation-depth-subst.cpp | 9 + test/SemaTemplate/instantiation-depth.cpp | 20 +- test/SemaTemplate/member-template-access-expr.cpp | 2 +- .../ms-function-specialization-class-scope.cpp | 21 + .../ms-lookup-template-base-classes.cpp | 29 + test/SemaTemplate/overload-candidates.cpp | 26 +- test/SemaTemplate/recovery-crash.cpp | 3 +- test/SemaTemplate/typename-specifier.cpp | 41 +- test/Tooling/Inputs/lit.local.cfg | 1 + test/Tooling/Inputs/pch-fail.h | 0 test/Tooling/Inputs/pch.cpp | 0 test/Tooling/Inputs/pch.h | 0 .../auto-detect-from-source-parent-of-cwd.cpp | 10 + test/Tooling/auto-detect-from-source-parent.cpp | 10 + test/Tooling/auto-detect-from-source.cpp | 10 + test/Tooling/clang-check-args.cpp | 7 +- test/Tooling/clang-check-ast-dump.cpp | 35 + test/Tooling/clang-check-autodetect-dir.cpp | 11 + test/Tooling/clang-check-builtin-headers.cpp | 15 + test/Tooling/clang-check-chdir.cpp | 17 + test/Tooling/clang-check-pwd.cpp | 8 +- test/Tooling/clang-check.cpp | 9 +- test/Tooling/multi-jobs.cpp | 7 + test/Tooling/pch.cpp | 17 + test/lit.cfg | 8 + 1154 files changed, 37834 insertions(+), 4132 deletions(-) create mode 100644 test/ARCMT/objcmt-boxing.m create mode 100644 test/ARCMT/objcmt-boxing.m.result create mode 100644 test/ARCMT/objcmt-subscripting-literals-in-arc.m create mode 100644 test/ARCMT/objcmt-subscripting-literals-in-arc.m.result create mode 100644 test/ARCMT/objcmt-subscripting-unavailable.m create mode 100644 test/ARCMT/objcmt-subscripting-unavailable.m.result create mode 100644 test/ARCMT/verify.m create mode 100644 test/Analysis/PR12905.c delete mode 100644 test/Analysis/additive-folding.c create mode 100644 test/Analysis/additive-folding.cpp create mode 100644 test/Analysis/blocks-no-inline.c create mode 100644 test/Analysis/comparison-implicit-casts.cpp create mode 100644 test/Analysis/ctor-inlining.mm create mode 100644 test/Analysis/cxx-for-range-cfg.cpp create mode 100644 test/Analysis/cxx-method-names.cpp create mode 100644 test/Analysis/cxx11-crashes.cpp create mode 100644 test/Analysis/diagnostics/undef-value-callee.h create mode 100644 test/Analysis/diagnostics/undef-value-caller.c create mode 100644 test/Analysis/engine/replay-without-inlining.c create mode 100644 test/Analysis/inline.cpp create mode 100644 test/Analysis/inlining/DynDispatchBifurcate.m create mode 100644 test/Analysis/inlining/InlineObjCClassMethod.m create mode 100644 test/Analysis/inlining/InlineObjCInstanceMethod.h create mode 100644 test/Analysis/inlining/InlineObjCInstanceMethod.m create mode 100644 test/Analysis/inlining/ObjCDynTypePopagation.m create mode 100644 test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m create mode 100644 test/Analysis/inlining/RetainCountExamples.m create mode 100644 test/Analysis/inlining/path-notes.c delete mode 100644 test/Analysis/iterators.cpp create mode 100644 test/Analysis/ivars.m create mode 100644 test/Analysis/method-call-path-notes.cpp create mode 100644 test/Analysis/misc-ps-arm.m create mode 100644 test/Analysis/nonnull.m create mode 100644 test/Analysis/objc-boxing.m create mode 100644 test/Analysis/objc-for.m create mode 100644 test/Analysis/objc-subscript.m create mode 100644 test/Analysis/region-store.c create mode 100644 test/Analysis/svalbuilder-logic.c create mode 100644 test/Analysis/templates.cpp create mode 100644 test/Analysis/test-variably-modified-types.c create mode 100644 test/Analysis/traversal-algorithm.mm create mode 100644 test/Analysis/uninit-sometimes.cpp create mode 100644 test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp create mode 100644 test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp create mode 100644 test/CXX/class.access/class.friend/p9-cxx0x.cpp create mode 100644 test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp create mode 100644 test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp create mode 100644 test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp create mode 100644 test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm create mode 100644 test/CXX/expr/p10-0x.cpp create mode 100644 test/CXX/special/class.conv/class.conv.ctor/p1.cpp create mode 100644 test/CXX/special/class.copy/p23-cxx11.cpp create mode 100644 test/CXX/temp/temp.names/p3-0x.cpp create mode 100644 test/CodeCompletion/auto.cpp create mode 100644 test/CodeCompletion/documentation.cpp create mode 100644 test/CodeCompletion/objc-expr.m delete mode 100644 test/CodeGen/2002-05-24-Alloca.c create mode 100644 test/CodeGen/alloca.c create mode 100644 test/CodeGen/attr-coldhot.c create mode 100644 test/CodeGen/bounds-checking.c create mode 100644 test/CodeGen/branch-target-layout.c create mode 100644 test/CodeGen/builtins-mips-args.c create mode 100644 test/CodeGen/builtins-mips.c create mode 100644 test/CodeGen/builtins-nvptx.c delete mode 100644 test/CodeGen/builtins-ptx.c create mode 100644 test/CodeGen/debug-info-gline-tables-only.c create mode 100644 test/CodeGen/debug-info-gline-tables-only2.c create mode 100644 test/CodeGen/debug-info-vla.c create mode 100644 test/CodeGen/fma-builtins.c create mode 100644 test/CodeGen/forceinline.c create mode 100644 test/CodeGen/fp-contract.c create mode 100644 test/CodeGen/mips-byval-arg.c create mode 100644 test/CodeGen/mips-vector-arg.c create mode 100644 test/CodeGen/mips-vector-return.c create mode 100644 test/CodeGen/ms-inline-asm.c create mode 100644 test/CodeGen/nobuiltin.c create mode 100644 test/CodeGen/nvptx-cc.c create mode 100644 test/CodeGen/nvptx-inlineasm.c create mode 100644 test/CodeGen/pclmul-builtins.c create mode 100644 test/CodeGen/pr13168.c delete mode 100644 test/CodeGen/ptx-cc.c create mode 100644 test/CodeGen/rdrand-builtins.c create mode 100644 test/CodeGen/regparm-struct.c create mode 100644 test/CodeGen/sse4a-builtins.c create mode 100644 test/CodeGen/tls-model.c create mode 100644 test/CodeGen/vector-alignment.c create mode 100644 test/CodeGen/xop-builtins.c create mode 100644 test/CodeGenCUDA/address-spaces.cu create mode 100644 test/CodeGenCXX/cxx0x-initializer-constructors.cpp create mode 100644 test/CodeGenCXX/cxx11-initializer-aggregate.cpp create mode 100644 test/CodeGenCXX/cxx11-vtable-key-function.cpp create mode 100644 test/CodeGenCXX/debug-info-determinism.cpp create mode 100644 test/CodeGenCXX/debug-info-enum-class.cpp create mode 100644 test/CodeGenCXX/debug-info-flex-member.cpp create mode 100644 test/CodeGenCXX/debug-info-gline-tables-only.cpp create mode 100644 test/CodeGenCXX/debug-info-globalinit.cpp create mode 100644 test/CodeGenCXX/debug-info-rvalue-ref.cpp create mode 100644 test/CodeGenCXX/debug-info-template-array.cpp create mode 100644 test/CodeGenCXX/debug-info-template-quals.cpp create mode 100644 test/CodeGenCXX/debug-info-union.cpp create mode 100644 test/CodeGenCXX/debug-info-user-def.cpp create mode 100644 test/CodeGenCXX/destructor-exception-spec.cpp create mode 100644 test/CodeGenCXX/global-block-literal-helpers.cpp create mode 100644 test/CodeGenCXX/mangle-ms-abi-examples.cpp create mode 100644 test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp create mode 100644 test/CodeGenCXX/mangle-ms-back-references.cpp create mode 100644 test/CodeGenCXX/mangle-ms-cxx11.cpp create mode 100644 test/CodeGenCXX/mangle-ms-return-qualifiers.cpp create mode 100644 test/CodeGenCXX/mangle-ms-templates.cpp create mode 100644 test/CodeGenCXX/member-data-pointers.cpp delete mode 100644 test/CodeGenCXX/member-init-ctor.cpp delete mode 100644 test/CodeGenCXX/member-pointer-type-convert.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-array-cookies.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-constructors.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-methods.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-static-initializers.cpp create mode 100644 test/CodeGenCXX/ms_wide_predefined_expr.cpp create mode 100644 test/CodeGenCXX/pr13396.cpp create mode 100644 test/CodeGenCXX/throw-expression-cleanup.cpp delete mode 100644 test/CodeGenCXX/virt-call-offsets.cpp create mode 100644 test/CodeGenObjC/boxing.m create mode 100644 test/CodeGenObjC/encode-test-6.m create mode 100644 test/CodeGenObjC/getter-property-mismatch.m create mode 100644 test/CodeGenObjC/getter-property-type-mismatch.m create mode 100644 test/CodeGenObjC/layout-bitfield-crash.m create mode 100644 test/CodeGenObjC/objfw.m create mode 100644 test/CodeGenOpenCL/kernel-arg-info.cl create mode 100644 test/CodeGenOpenCL/kernel-attributes.cl create mode 100644 test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_dynamic.o create mode 100644 test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_so.o create mode 100644 test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_static.o create mode 100644 test/Driver/Inputs/basic_android_tree/usr/lib/crtend_android.o create mode 100644 test/Driver/Inputs/basic_android_tree/usr/lib/crtend_so.o create mode 100644 test/Driver/Inputs/debian_multiarch_tree/lib/mips-linux-gnu/.keep create mode 100644 test/Driver/Inputs/debian_multiarch_tree/lib/mipsel-linux-gnu/.keep create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mips-linux-gnu/.keep create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mipsel-linux-gnu/.keep create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/include/mips-linux-gnu/.keep create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/include/mipsel-linux-gnu/.keep create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/n32/crtbegin.o create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/n32/crtbegin.o create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/lib/mips-linux-gnu/.keep create mode 100644 test/Driver/Inputs/debian_multiarch_tree/usr/lib/mipsel-linux-gnu/.keep create mode 100644 test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/crtbegin.o create mode 100644 test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabi/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabihf/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabi/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabihf/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o create mode 100644 test/Driver/asan-ld.c create mode 100644 test/Driver/bounds-checking.c create mode 100644 test/Driver/ccc-as-cpp.c create mode 100644 test/Driver/clang_f_opts.h create mode 100644 test/Driver/constructors.c create mode 100644 test/Driver/crash-report.c create mode 100644 test/Driver/debug-unsupported.c create mode 100644 test/Driver/fpack-struct.c create mode 100644 test/Driver/mips-features.c create mode 100644 test/Driver/montavista-gcc-toolchain.c create mode 100644 test/Driver/msvc_forward.c create mode 100644 test/Driver/nodefaultlib.c create mode 100644 test/Driver/target-triple-deployment.c create mode 100644 test/Driver/warning-options.cpp create mode 100644 test/Driver/warning-options_pedantic.cpp create mode 100644 test/FixIt/fixit-autoreleasepool.m create mode 100644 test/FixIt/fixit-include.c create mode 100644 test/FixIt/fixit-include.h create mode 100644 test/FixIt/fixit-interface-as-param.m create mode 100644 test/FixIt/fixit-objc-message-comma-separator.m create mode 100644 test/FixIt/fixit-unicode.c create mode 100644 test/FixIt/format-no-fixit.m create mode 100644 test/FixIt/format.m create mode 100644 test/FixIt/messages.cpp create mode 100644 test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h create mode 100644 test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h create mode 100644 test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h create mode 100644 test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h create mode 100644 test/Frontend/Inputs/SystemHeaderPrefix/src/all.h create mode 100644 test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h create mode 100644 test/Frontend/Inputs/rewrite-includes1.h create mode 100644 test/Frontend/Inputs/rewrite-includes2.h create mode 100644 test/Frontend/Inputs/rewrite-includes3.h create mode 100644 test/Frontend/Inputs/rewrite-includes4.h create mode 100644 test/Frontend/Inputs/rewrite-includes5.h create mode 100644 test/Frontend/Inputs/rewrite-includes6.h create mode 100644 test/Frontend/Inputs/rewrite-includes7.h create mode 100644 test/Frontend/rewrite-includes-missing.c create mode 100644 test/Frontend/rewrite-includes.c create mode 100644 test/Frontend/system-header-prefix.c create mode 100644 test/Frontend/verify-directive.h create mode 100644 test/Frontend/verify-fatal.c create mode 100644 test/Frontend/verify.c create mode 100644 test/Frontend/verify2.c create mode 100644 test/Frontend/verify2.h create mode 100644 test/Headers/ms-null-ms-header-vs-stddef.cpp create mode 100644 test/Index/Inputs/CommentXML/invalid-function-01.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-02.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-03.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-04.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-05.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-06.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-07.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-08.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-09.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-10.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-11.xml create mode 100644 test/Index/Inputs/CommentXML/invalid-function-12.xml create mode 100644 test/Index/Inputs/CommentXML/valid-class-01.xml create mode 100644 test/Index/Inputs/CommentXML/valid-class-02.xml create mode 100644 test/Index/Inputs/CommentXML/valid-class-03.xml create mode 100644 test/Index/Inputs/CommentXML/valid-class-04.xml create mode 100644 test/Index/Inputs/CommentXML/valid-enum-01.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-01.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-02.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-03.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-04.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-05.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-06.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-07.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-08.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-09.xml create mode 100644 test/Index/Inputs/CommentXML/valid-function-10.xml create mode 100644 test/Index/Inputs/CommentXML/valid-namespace-01.xml create mode 100644 test/Index/Inputs/CommentXML/valid-other-01.xml create mode 100644 test/Index/Inputs/CommentXML/valid-typedef-01.xml create mode 100644 test/Index/Inputs/CommentXML/valid-typedef-02.xml create mode 100644 test/Index/Inputs/CommentXML/valid-variable-01.xml create mode 100644 test/Index/Inputs/annotate-comments-preprocessor.h create mode 100644 test/Index/annotate-comments-preprocessor.c create mode 100644 test/Index/annotate-comments-unterminated.c create mode 100644 test/Index/annotate-comments.cpp create mode 100644 test/Index/availability.c create mode 100644 test/Index/boxed-exprs.h create mode 100644 test/Index/boxed-exprs.m create mode 100644 test/Index/comment-xml-schema.c create mode 100644 test/Index/compile_commands.json create mode 100644 test/Index/complete-documentation.cpp create mode 100644 test/Index/complete-lambdas.mm create mode 100644 test/Index/create-tu-fail.c create mode 100644 test/Index/cursor-dynamic-call.mm create mode 100644 test/Index/index-kernel-invocation.cpp create mode 100644 test/Index/index-many-call-ops.cpp create mode 100644 test/Index/index-refs.m create mode 100644 test/Lexer/wchar-signedness.c create mode 100644 test/Misc/ast-dump-wchar.cpp create mode 100644 test/Misc/diag-template-diffing-color.cpp create mode 100644 test/Misc/diag-template-diffing.cpp create mode 100644 test/Misc/diag-trailing-null-bytes.cpp create mode 100644 test/Misc/serialized-diags-frontend.c create mode 100644 test/Misc/warning-flags-enabled.c create mode 100644 test/Misc/warning-flags-tree.c delete mode 100644 test/Misc/wnull-character.cpp create mode 100644 test/Modules/Inputs/import-decl.h create mode 100644 test/Modules/import-decl.cpp create mode 100644 test/PCH/Inputs/__va_list_tag.h create mode 100644 test/PCH/__va_list_tag.c create mode 100644 test/PCH/badpch-dir.h.gch/.keep create mode 100644 test/PCH/badpch-empty.h.gch create mode 100644 test/PCH/badpch.c create mode 100644 test/PCH/chain-staticvar-instantiation.cpp create mode 100644 test/PCH/empty-with-headers.c create mode 100644 test/PCH/format-strings.c create mode 100644 test/PCH/pch__VA_ARGS__.c create mode 100644 test/PCH/pch__VA_ARGS__.h create mode 100644 test/PCH/remap-file-from-pch.cpp create mode 100644 test/PCH/remap-file-from-pch.cpp.h create mode 100644 test/PCH/remap-file-from-pch.cpp.remap.h create mode 100644 test/Parser/completely-empty-header-file.h create mode 100644 test/Parser/cxx-extra-semi.cpp create mode 100644 test/Parser/empty-translation-unit.c create mode 100644 test/Parser/missing-selector-name.mm create mode 100644 test/Parser/objc-boxing.m create mode 100644 test/Parser/objc-diag-width.mm create mode 100644 test/Parser/objc-recover.mm create mode 100644 test/Preprocessor/disabled-cond-diags2.c create mode 100644 test/Preprocessor/macro_paste_identifier_error.c create mode 100644 test/Rewriter/objc-modern-StretAPI.mm create mode 100644 test/Rewriter/objc-modern-boxing.mm create mode 100644 test/Rewriter/objc-modern-getclass-proto.mm create mode 100644 test/Rewriter/rewrite-modern-atautoreleasepool.mm create mode 100644 test/Rewriter/rewrite-modern-block-consts.mm create mode 100644 test/Rewriter/rewrite-modern-captured-nested-bvar.mm create mode 100644 test/Rewriter/rewrite-modern-default-property-synthesis.mm create mode 100644 test/Rewriter/rewrite-modern-ivar-access.mm create mode 100644 test/Rewriter/rewrite-modern-private-ivars.mm create mode 100644 test/Rewriter/rewrite-modern-struct-ivar-1.mm create mode 100644 test/Sema/Inputs/format-unused-system-args.h create mode 100644 test/Sema/alloc_size.c create mode 100644 test/Sema/attr-coldhot.c create mode 100644 test/Sema/attr-tls_model.c create mode 100644 test/Sema/format-strings-enum-fixed-type.cpp create mode 100644 test/Sema/format-strings-enum.c create mode 100644 test/Sema/ms_wide_predefined_expr.cpp create mode 100644 test/Sema/pragma-pack-6.c create mode 100644 test/Sema/tls.c create mode 100644 test/Sema/warn-documentation-almost-trailing.c create mode 100644 test/Sema/warn-documentation-fixits.cpp create mode 100644 test/Sema/warn-documentation.cpp create mode 100644 test/Sema/warn-documentation.m create mode 100644 test/Sema/warn-outof-range-assign-enum.c create mode 100644 test/Sema/warn-self-assign-field.mm create mode 100644 test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp create mode 100644 test/SemaCXX/anonymous-union-cxx11.cpp create mode 100644 test/SemaCXX/attr-visibility.cpp create mode 100644 test/SemaCXX/constexpr-many-arguments.cpp create mode 100644 test/SemaCXX/long-virtual-inheritance-chain.cpp create mode 100644 test/SemaCXX/no-rtti.cpp create mode 100644 test/SemaCXX/offsetof-0x.cpp create mode 100644 test/SemaCXX/pr13353.cpp create mode 100644 test/SemaCXX/pr13394-crash-on-invalid.cpp create mode 100644 test/SemaCXX/printf-block.cpp create mode 100644 test/SemaCXX/printf-cstr.cpp create mode 100644 test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp create mode 100644 test/SemaCXX/switch-implicit-fallthrough-per-method.cpp create mode 100644 test/SemaCXX/switch-implicit-fallthrough.cpp create mode 100644 test/SemaCXX/warn-loop-analysis.cpp create mode 100644 test/SemaCXX/warn-static-function-inheader.cpp create mode 100644 test/SemaCXX/warn-static-function-inheader.h create mode 100644 test/SemaCXX/warn-unique-enum.cpp create mode 100644 test/SemaCXX/warn-unused-private-field.cpp create mode 100644 test/SemaObjC/arc-dict-bridged-cast.m delete mode 100644 test/SemaObjC/arc-retain-block-property.m create mode 100644 test/SemaObjC/boxing-illegal-types.m create mode 100644 test/SemaObjC/dealloc.m create mode 100644 test/SemaObjC/delay-parsing-cfunctions.m create mode 100644 test/SemaObjC/format-strings-system.h create mode 100644 test/SemaObjC/getter-setter-defined-in-category-of-parent.m create mode 100644 test/SemaObjC/iboutlet.m delete mode 100644 test/SemaObjC/id-isa-ref.m create mode 100644 test/SemaObjC/mismatched-undefined-method.m create mode 100644 test/SemaObjC/no-ivar-in-interface-block.m create mode 100644 test/SemaObjC/nowarn-superclass-method-mismatch.m create mode 100644 test/SemaObjC/objc-literal-comparison.m create mode 100644 test/SemaObjC/tentative-property-decl.m create mode 100644 test/SemaObjC/warn-direct-ivar-access.m create mode 100644 test/SemaObjC/warn-isa-ref.m create mode 100644 test/SemaObjC/warn-protocol-method-deprecated.m create mode 100644 test/SemaObjC/warn-retain-block-property.m create mode 100644 test/SemaObjCXX/boxing-illegal-types.mm create mode 100644 test/SemaObjCXX/crash.mm create mode 100644 test/SemaObjCXX/delay-parsing-cfunctions.mm create mode 100644 test/SemaObjCXX/delay-parsing-cplusfuncs.mm create mode 100644 test/SemaObjCXX/delay-parsing-func-tryblock.mm create mode 100644 test/SemaObjCXX/foreach.mm create mode 100644 test/SemaObjCXX/warn-missing-super.mm create mode 100644 test/SemaOpenCL/storageclass.cl create mode 100644 test/SemaOpenCL/warn-missing-prototypes.cl create mode 100644 test/SemaTemplate/instantiation-depth-defarg.cpp create mode 100644 test/SemaTemplate/instantiation-depth-subst-2.cpp create mode 100644 test/SemaTemplate/instantiation-depth-subst.cpp create mode 100644 test/Tooling/Inputs/lit.local.cfg create mode 100644 test/Tooling/Inputs/pch-fail.h create mode 100644 test/Tooling/Inputs/pch.cpp create mode 100644 test/Tooling/Inputs/pch.h create mode 100644 test/Tooling/auto-detect-from-source-parent-of-cwd.cpp create mode 100644 test/Tooling/auto-detect-from-source-parent.cpp create mode 100644 test/Tooling/auto-detect-from-source.cpp create mode 100644 test/Tooling/clang-check-ast-dump.cpp create mode 100644 test/Tooling/clang-check-autodetect-dir.cpp create mode 100644 test/Tooling/clang-check-builtin-headers.cpp create mode 100644 test/Tooling/clang-check-chdir.cpp create mode 100644 test/Tooling/multi-jobs.cpp create mode 100644 test/Tooling/pch.cpp (limited to 'test') diff --git a/test/ARCMT/Common.h b/test/ARCMT/Common.h index 16856ed1b444..ed4894970247 100644 --- a/test/ARCMT/Common.h +++ b/test/ARCMT/Common.h @@ -6,6 +6,7 @@ #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) #define CF_CONSUMED __attribute__((cf_consumed)) +#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) #define NS_INLINE static __inline__ __attribute__((always_inline)) #define nil ((void*) 0) @@ -21,7 +22,7 @@ typedef struct _NSZone NSZone; typedef const void * CFTypeRef; CFTypeRef CFRetain(CFTypeRef cf); -id CFBridgingRelease(CFTypeRef CF_CONSUMED X); +CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; @@ -68,3 +69,36 @@ typedef const void* objc_objectptr_t; extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer); extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer); extern objc_objectptr_t objc_unretainedPointer(id object); + +#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; }) +#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; }) +#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; }) +#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; }) + +typedef id dispatch_object_t; +typedef id xpc_object_t; + +void _dispatch_object_validate(dispatch_object_t object); +void _xpc_object_validate(xpc_object_t object); + +#if __has_feature(objc_arc) + +NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { + return (__bridge_retained CFTypeRef)X; +} + +NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { + return (__bridge_transfer id)X; +} + +#else + +NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { + return X ? CFRetain((CFTypeRef)X) : NULL; +} + +NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { + return [(id)CFMakeCollectable(X) autorelease]; +} + +#endif diff --git a/test/ARCMT/autoreleases.m b/test/ARCMT/autoreleases.m index 3acddb71e7c8..a131bc53391d 100644 --- a/test/ARCMT/autoreleases.m +++ b/test/ARCMT/autoreleases.m @@ -3,29 +3,21 @@ // RUN: diff %t %s.result // DISABLE: mingw32 -typedef unsigned char BOOL; +#include "Common.h" -@interface NSObject { - id isa; -} -+new; -+alloc; --init; --autorelease; -@end - -@interface NSAutoreleasePool : NSObject -- drain; -@end - @interface A : NSObject { @package id object; } @end -@interface B : NSObject +@interface B : NSObject { + id _prop; + xpc_object_t _xpc_prop; +} - (BOOL)containsSelf:(A*)a; +@property (retain) id prop; +@property (retain) xpc_object_t xpc_prop; @end @implementation A @@ -35,6 +27,26 @@ typedef unsigned char BOOL; - (BOOL)containsSelf:(A*)a { return a->object == self; } + +-(id) prop { + return _prop; +} +-(void) setProp:(id) newVal { + [_prop autorelease]; + _prop = [newVal retain]; +} +-(void) setProp2:(CFTypeRef) newVal { + [_prop autorelease]; + _prop = (id)CFRetain(newVal); +} + +-(id) xpc_prop { + return _xpc_prop; +} +-(void) setXpc_prop:(xpc_object_t) newVal { + [_xpc_prop autorelease]; + _xpc_prop = xpc_retain(newVal); +} @end void NSLog(id, ...); @@ -47,3 +59,8 @@ int main (int argc, const char * argv[]) { [pool drain]; return 0; } + +void test(A *prevVal, A *newVal) { + [prevVal autorelease]; + prevVal = [newVal retain]; +} diff --git a/test/ARCMT/autoreleases.m.result b/test/ARCMT/autoreleases.m.result index 49bc32141ec5..6593fc9199a0 100644 --- a/test/ARCMT/autoreleases.m.result +++ b/test/ARCMT/autoreleases.m.result @@ -3,29 +3,21 @@ // RUN: diff %t %s.result // DISABLE: mingw32 -typedef unsigned char BOOL; +#include "Common.h" -@interface NSObject { - id isa; -} -+new; -+alloc; --init; --autorelease; -@end - -@interface NSAutoreleasePool : NSObject -- drain; -@end - @interface A : NSObject { @package id object; } @end -@interface B : NSObject +@interface B : NSObject { + id _prop; + xpc_object_t _xpc_prop; +} - (BOOL)containsSelf:(A*)a; +@property (strong) id prop; +@property (strong) xpc_object_t xpc_prop; @end @implementation A @@ -35,6 +27,23 @@ typedef unsigned char BOOL; - (BOOL)containsSelf:(A*)a { return a->object == self; } + +-(id) prop { + return _prop; +} +-(void) setProp:(id) newVal { + _prop = newVal; +} +-(void) setProp2:(CFTypeRef) newVal { + _prop = (id)CFBridgingRelease(CFRetain(newVal)); +} + +-(id) xpc_prop { + return _xpc_prop; +} +-(void) setXpc_prop:(xpc_object_t) newVal { + _xpc_prop = newVal; +} @end void NSLog(id, ...); @@ -47,3 +56,7 @@ int main (int argc, const char * argv[]) { } return 0; } + +void test(A *prevVal, A *newVal) { + prevVal = newVal; +} diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m index cf7161187fb1..3ad911e10a8f 100644 --- a/test/ARCMT/checking.m +++ b/test/ARCMT/checking.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s +// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s // DISABLE: mingw32 #if __has_feature(objc_arc) @@ -45,9 +45,9 @@ struct UnsafeS { }; @interface A : NSObject -- (id)retain; -- (id)retainCount; -- (id)autorelease; +- (id)retain; // expected-note {{declaration has been explicitly marked unavailable here}} +- (id)retainCount; // expected-note {{declaration has been explicitly marked unavailable here}} +- (id)autorelease; // expected-note 2 {{declaration has been explicitly marked unavailable here}} - (id)init; - (oneway void)release; - (void)dealloc; @@ -79,7 +79,8 @@ 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}} [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \ - // expected-error {{ARC forbids explicit message send}} + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'retain' is unavailable}} id foo = [unsafeS->unsafeObj retain]; // no warning. [global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \ // expected-error {{ARC forbids explicit message send}} @@ -87,10 +88,16 @@ void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { // expected-error {{ARC forbids explicit message send}} [a dealloc]; [a retain]; - [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} + [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} \ + // expected-error {{'retainCount' is unavailable}} [a release]; [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ - // expected-error {{ARC forbids explicit message send}} + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'autorelease' is unavailable}} + [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'autorelease' is unavailable}} + a = 0; CFStringRef cfstr; NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ @@ -135,7 +142,7 @@ void rdar8861761() { - (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'}} + for (__strong id x in collection) { // expected-error {{use of undeclared identifier 'collection'}} x = 0; } } @@ -325,3 +332,13 @@ void rdar9504750(id p) { self->x = [NSObject new]; // expected-error {{assigning retained object}} } @end + +@interface Test10 : NSObject +@property (retain) id prop; +-(void)foo; +@end + +void test(Test10 *x) { + x.prop = ^{ [x foo]; }; // expected-warning {{likely to lead to a retain cycle}} \ + // expected-note {{retained by the captured object}} +} diff --git a/test/ARCMT/cxx-rewrite.mm.result b/test/ARCMT/cxx-rewrite.mm.result index a2dc9a51f006..7c944d5f240a 100644 --- a/test/ARCMT/cxx-rewrite.mm.result +++ b/test/ARCMT/cxx-rewrite.mm.result @@ -16,7 +16,7 @@ struct foo { [NSString string]; } } - ~foo(){ s; } + ~foo(){ } private: foo(foo const &); foo &operator=(foo const &); diff --git a/test/ARCMT/dispatch.m b/test/ARCMT/dispatch.m index 75c4a83459c7..58c7769638cb 100644 --- a/test/ARCMT/dispatch.m +++ b/test/ARCMT/dispatch.m @@ -4,17 +4,6 @@ #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) { diff --git a/test/ARCMT/dispatch.m.result b/test/ARCMT/dispatch.m.result index e897672a264b..55b65585e4f6 100644 --- a/test/ARCMT/dispatch.m.result +++ b/test/ARCMT/dispatch.m.result @@ -4,17 +4,6 @@ #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) { diff --git a/test/ARCMT/nonobjc-to-objc-cast-2.m b/test/ARCMT/nonobjc-to-objc-cast-2.m index 1ec0089f08e8..80d694e58680 100644 --- a/test/ARCMT/nonobjc-to-objc-cast-2.m +++ b/test/ARCMT/nonobjc-to-objc-cast-2.m @@ -3,16 +3,37 @@ #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); +struct StrS { + CFStringRef sref_member; +}; + +@interface NSString : NSObject { + CFStringRef sref; + struct StrS *strS; +} +-(id)string; +-(id)newString; +@end + +@implementation NSString +-(id)string { + if (0) + return sref; + else + return strS->sref_member; +} +-(id)newString { + return sref; // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'id' requires a bridged cast}} \ + // expected-note{{use __bridge to convert directly (no change in ownership)}} \ + // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} +} +@end + void f(BOOL b) { CFStringRef cfstr; NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ diff --git a/test/ARCMT/nonobjc-to-objc-cast.m b/test/ARCMT/nonobjc-to-objc-cast.m index fcdcd89c9c83..55b6655fa404 100644 --- a/test/ARCMT/nonobjc-to-objc-cast.m +++ b/test/ARCMT/nonobjc-to-objc-cast.m @@ -5,11 +5,6 @@ #include "Common.h" -@interface NSString : NSObject --(id)string; --(id)newString; -@end - typedef const struct __CFString * CFStringRef; extern const CFStringRef kUTTypePlainText; extern const CFStringRef kUTTypeRTF; @@ -21,6 +16,18 @@ extern const CFAllocatorRef kCFAllocatorDefault; extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); +struct StrS { + CFStringRef sref_member; +}; + +@interface NSString : NSObject { + CFStringRef sref; + struct StrS *strS; +} +-(id)string; +-(id)newString; +@end + void f(BOOL b, id p) { NSString *str = (NSString *)kUTTypePlainText; str = b ? kUTTypeRTF : kUTTypePlainText; @@ -41,6 +48,16 @@ void f(BOOL b, id p) { } @end +@implementation NSString +-(id)string { + if (0) + return sref; + else + return strS->sref_member; +} +-(id)newString { return 0; } +@end + extern void consumeParam(CFStringRef CF_CONSUMED p); void f2(NSString *s) { diff --git a/test/ARCMT/nonobjc-to-objc-cast.m.result b/test/ARCMT/nonobjc-to-objc-cast.m.result index b50a948e27ca..4f508f6adfb6 100644 --- a/test/ARCMT/nonobjc-to-objc-cast.m.result +++ b/test/ARCMT/nonobjc-to-objc-cast.m.result @@ -5,11 +5,6 @@ #include "Common.h" -@interface NSString : NSObject --(id)string; --(id)newString; -@end - typedef const struct __CFString * CFStringRef; extern const CFStringRef kUTTypePlainText; extern const CFStringRef kUTTypeRTF; @@ -21,6 +16,18 @@ extern const CFAllocatorRef kCFAllocatorDefault; extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); +struct StrS { + CFStringRef sref_member; +}; + +@interface NSString : NSObject { + CFStringRef sref; + struct StrS *strS; +} +-(id)string; +-(id)newString; +@end + void f(BOOL b, id p) { NSString *str = (__bridge NSString *)kUTTypePlainText; str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText); @@ -28,9 +35,9 @@ void f(BOOL b, id p) { 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)); + NSString *_uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); + _uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); + _uuidString = CFBridgingRelease(CFRetain(_uuid)); } @implementation NSString (StrExt) @@ -41,22 +48,32 @@ void f(BOOL b, id p) { } @end +@implementation NSString +-(id)string { + if (0) + return (__bridge id)(sref); + else + return (__bridge id)(strS->sref_member); +} +-(id)newString { return 0; } +@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)); + ref = CFBridgingRetain([NSString new]); + ref = CFBridgingRetain([s newString]); + ref = (CFStringRef)CFBridgingRetain([NSString new]); + ref = CFBridgingRetain([[NSString alloc] init]); + ref = CFBridgingRetain([s string]); + ref = (CFStringRef)CFBridgingRetain([s string]); + ref = CFBridgingRetain([s string]); + ref = CFBridgingRetain(s); + ref = CFBridgingRetain(s); + + consumeParam((CFStringRef)CFBridgingRetain(s)); + consumeParam(CFBridgingRetain(s)); } diff --git a/test/ARCMT/objcmt-boxing.m b/test/ARCMT/objcmt-boxing.m new file mode 100644 index 000000000000..2ad65a1399db --- /dev/null +++ b/test/ARCMT/objcmt-boxing.m @@ -0,0 +1,102 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result + +#define YES __objc_yes +#define NO __objc_no + +typedef long NSInteger; +typedef unsigned long NSUInteger; +typedef signed char BOOL; +#define nil ((void*) 0) + +#define INT_MIN (-__INT_MAX__ -1) + +@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 + +enum { + NSASCIIStringEncoding = 1, + NSUTF8StringEncoding = 4, + NSUnicodeStringEncoding = 10 +}; +typedef NSUInteger NSStringEncoding; + +@interface NSString : NSObject +@end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; ++ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; ++ (id)stringWithCString:(const char *)bytes; +@end + +enum MyEnm { + ME_foo +}; + +void foo() { + [NSNumber numberWithInt:INT_MIN]; + bool cppb; + [NSNumber numberWithBool:cppb]; + MyEnm myenum; + [NSNumber numberWithInteger:myenum]; + [NSNumber numberWithInteger:ME_foo]; + [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} +} + +void boxString() { + NSString *s = [NSString stringWithUTF8String:"box"]; + const char *cstr1; + char *cstr2; + s = [NSString stringWithUTF8String:cstr1]; + s = [NSString stringWithUTF8String:cstr2]; + s = [NSString stringWithCString:cstr1 encoding:NSASCIIStringEncoding]; + s = [NSString stringWithCString:cstr1 encoding:NSUTF8StringEncoding]; + s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; + NSStringEncoding encode; + s = [NSString stringWithCString:cstr1 encoding:encode]; + s = [NSString stringWithCString:cstr1]; + + static const char strarr[] = "coolbox"; + s = [NSString stringWithUTF8String:strarr]; +} diff --git a/test/ARCMT/objcmt-boxing.m.result b/test/ARCMT/objcmt-boxing.m.result new file mode 100644 index 000000000000..f1019892ff37 --- /dev/null +++ b/test/ARCMT/objcmt-boxing.m.result @@ -0,0 +1,102 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result + +#define YES __objc_yes +#define NO __objc_no + +typedef long NSInteger; +typedef unsigned long NSUInteger; +typedef signed char BOOL; +#define nil ((void*) 0) + +#define INT_MIN (-__INT_MAX__ -1) + +@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 + +enum { + NSASCIIStringEncoding = 1, + NSUTF8StringEncoding = 4, + NSUnicodeStringEncoding = 10 +}; +typedef NSUInteger NSStringEncoding; + +@interface NSString : NSObject +@end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; ++ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; ++ (id)stringWithCString:(const char *)bytes; +@end + +enum MyEnm { + ME_foo +}; + +void foo() { + @INT_MIN; + bool cppb; + @(cppb); + MyEnm myenum; + @(myenum); + @(ME_foo); + [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} +} + +void boxString() { + NSString *s = @"box"; + const char *cstr1; + char *cstr2; + s = @(cstr1); + s = @(cstr2); + s = @(cstr1); + s = @(cstr1); + s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; + NSStringEncoding encode; + s = [NSString stringWithCString:cstr1 encoding:encode]; + s = @(cstr1); + + static const char strarr[] = "coolbox"; + s = @(strarr); +} diff --git a/test/ARCMT/objcmt-numeric-literals.m b/test/ARCMT/objcmt-numeric-literals.m index b86af4d056a1..7f33dc27997e 100644 --- a/test/ARCMT/objcmt-numeric-literals.m +++ b/test/ARCMT/objcmt-numeric-literals.m @@ -1,6 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result #define YES __objc_yes #define NO __objc_no diff --git a/test/ARCMT/objcmt-numeric-literals.m.result b/test/ARCMT/objcmt-numeric-literals.m.result index 1c4187aaef5c..bb7b515566d0 100644 --- a/test/ARCMT/objcmt-numeric-literals.m.result +++ b/test/ARCMT/objcmt-numeric-literals.m.result @@ -1,6 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result #define YES __objc_yes #define NO __objc_no @@ -467,7 +468,7 @@ void foo() { [NSNumber numberWithInteger:NO]; [NSNumber numberWithInteger:true]; [NSNumber numberWithInteger:false]; - [NSNumber numberWithInteger:VAL_INT]; + @VAL_INT; [NSNumber numberWithInteger:VAL_UINT]; [NSNumber numberWithUnsignedInteger:'a']; @@ -497,5 +498,5 @@ void foo() { [NSNumber numberWithUnsignedInteger:true]; [NSNumber numberWithUnsignedInteger:false]; [NSNumber numberWithUnsignedInteger:VAL_INT]; - [NSNumber numberWithUnsignedInteger:VAL_UINT]; + @VAL_UINT; } diff --git a/test/ARCMT/objcmt-subscripting-literals-in-arc.m b/test/ARCMT/objcmt-subscripting-literals-in-arc.m new file mode 100644 index 000000000000..4d941626c0d0 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-literals-in-arc.m @@ -0,0 +1,106 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result + +typedef signed char BOOL; +#define nil ((void*) 0) + +typedef const struct __CFString * CFStringRef; + +@interface NSObject ++ (id)alloc; +@end + +@protocol NSCopying +@end + +@interface NSString : NSObject ++ (id)stringWithString:(NSString *)string; +- (id)initWithString:(NSString *)aString; +@end + +@interface NSArray : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; +@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; +@end + +@interface NSMutableArray : NSArray +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; +@end + +@interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) +- (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; +@end + +@interface NSMutableDictionary : NSDictionary +- (void)setObject:(id)anObject forKey:(id)aKey; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id )key; +@end + +@interface NSNumber : NSObject +@end + +@interface NSNumber (NSNumberCreation) ++ (NSNumber *)numberWithInt:(int)value; +- (id)initWithInt:(int)value; +@end + +@interface I { + NSArray *ivarArr; +} +@end +@implementation I +-(void) foo { + NSString *str; + NSArray *arr; + NSDictionary *dict; + + arr = [NSArray arrayWithObjects:str, str, nil]; + arr = [[NSArray alloc] initWithObjects:str, str, nil]; + dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; + dict = [[NSDictionary alloc] initWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; + + NSNumber *n = [[NSNumber alloc] initWithInt:2]; +} +@end diff --git a/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result b/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result new file mode 100644 index 000000000000..6f7a723bc473 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result @@ -0,0 +1,106 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result + +typedef signed char BOOL; +#define nil ((void*) 0) + +typedef const struct __CFString * CFStringRef; + +@interface NSObject ++ (id)alloc; +@end + +@protocol NSCopying +@end + +@interface NSString : NSObject ++ (id)stringWithString:(NSString *)string; +- (id)initWithString:(NSString *)aString; +@end + +@interface NSArray : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; +@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; +@end + +@interface NSMutableArray : NSArray +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; +@end + +@interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) +- (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; +@end + +@interface NSMutableDictionary : NSDictionary +- (void)setObject:(id)anObject forKey:(id)aKey; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id )key; +@end + +@interface NSNumber : NSObject +@end + +@interface NSNumber (NSNumberCreation) ++ (NSNumber *)numberWithInt:(int)value; +- (id)initWithInt:(int)value; +@end + +@interface I { + NSArray *ivarArr; +} +@end +@implementation I +-(void) foo { + NSString *str; + NSArray *arr; + NSDictionary *dict; + + arr = @[str, str]; + arr = @[str, str]; + dict = @{@"key1": @"value1", @"key2": @"value2"}; + dict = @{@"key1": @"value1", @"key2": @"value2"}; + + NSNumber *n = @2; +} +@end diff --git a/test/ARCMT/objcmt-subscripting-literals.m b/test/ARCMT/objcmt-subscripting-literals.m index 3d26efefda82..0174fcf060e9 100644 --- a/test/ARCMT/objcmt-subscripting-literals.m +++ b/test/ARCMT/objcmt-subscripting-literals.m @@ -1,14 +1,20 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result typedef signed char BOOL; #define nil ((void*) 0) +typedef const struct __CFString * CFStringRef; + @interface NSObject + (id)alloc; @end +@protocol NSCopying +@end + @interface NSString : NSObject + (id)stringWithString:(NSString *)string; - (id)initWithString:(NSString *)aString; @@ -16,7 +22,10 @@ typedef signed char BOOL; @interface NSArray : NSObject - (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; @end @interface NSArray (NSArrayCreation) @@ -29,16 +38,21 @@ typedef signed char BOOL; - (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 NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; @end @interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) - (id)objectForKeyedSubscript:(id)key; @end @@ -54,13 +68,14 @@ typedef signed char BOOL; - (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 NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id )key; @end @interface NSNumber : NSObject @@ -74,7 +89,9 @@ typedef signed char BOOL; #define PAIR(x) @#x, [NSNumber numberWithInt:(x)] #define TWO(x) ((x), (x)) -@interface I +@interface I { + NSArray *ivarArr; +} @end @implementation I -(void) foo { @@ -133,5 +150,74 @@ typedef signed char BOOL; [mdict setObject:[dict objectForKey:@"key1"] forKey:[dict objectForKey:[NSArray arrayWithObject:@"arrkey"]]]; __strong NSArray **parr = 0; o = [*parr objectAtIndex:2]; + void *hd; + o = [(NSArray*)hd objectAtIndex:2]; + o = [ivarArr objectAtIndex:2]; +} +@end + +extern const CFStringRef globStr; + +void test1(NSString *str) { + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: str, globStr, nil]; + dict = [NSDictionary dictionaryWithObjectsAndKeys: globStr, str, nil]; + dict = [NSDictionary dictionaryWithObject:str forKey:globStr]; + dict = [NSDictionary dictionaryWithObject:globStr forKey:str]; + + NSArray *arr = [NSArray arrayWithObjects: globStr, globStr, nil]; + arr = [NSArray arrayWithObjects: str, globStr, nil]; + arr = [NSArray arrayWithObjects: globStr, str, nil]; + arr = [NSArray arrayWithObject:globStr]; +} + +@interface Custom : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface Custom (Extended) +- (id)objectAtIndexedSubscript:(unsigned)idx; +@end + +@interface MutableCustom : Custom +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface MutableCustom (Extended) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; +@end + +@interface CustomUnavail : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface CustomUnavail (Extended) +- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable)); +@end + +@interface MutableCustomUnavail : CustomUnavail +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface MutableCustomUnavail (Extended) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable)); +@end + +void test2() { + MutableCustom *mutc; + id o = [mutc objectAtIndex:4]; + [mutc replaceObjectAtIndex:2 withObject:@"val"]; + + MutableCustomUnavail *mutcunaval; + o = [mutcunaval objectAtIndex:4]; + [mutcunaval replaceObjectAtIndex:2 withObject:@"val"]; } + +@interface NSLocale : NSObject ++ (id)systemLocale; ++ (id)currentLocale; +- (id)objectForKey:(id)key; @end + +void test3(id key) { + id o = [[NSLocale currentLocale] objectForKey:key]; +} diff --git a/test/ARCMT/objcmt-subscripting-literals.m.result b/test/ARCMT/objcmt-subscripting-literals.m.result index 8ac6dcc20751..9975996524bd 100644 --- a/test/ARCMT/objcmt-subscripting-literals.m.result +++ b/test/ARCMT/objcmt-subscripting-literals.m.result @@ -1,14 +1,20 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result typedef signed char BOOL; #define nil ((void*) 0) +typedef const struct __CFString * CFStringRef; + @interface NSObject + (id)alloc; @end +@protocol NSCopying +@end + @interface NSString : NSObject + (id)stringWithString:(NSString *)string; - (id)initWithString:(NSString *)aString; @@ -16,7 +22,10 @@ typedef signed char BOOL; @interface NSArray : NSObject - (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; @end @interface NSArray (NSArrayCreation) @@ -29,16 +38,21 @@ typedef signed char BOOL; - (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 NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; @end @interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) - (id)objectForKeyedSubscript:(id)key; @end @@ -54,13 +68,14 @@ typedef signed char BOOL; - (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 NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id )key; @end @interface NSNumber : NSObject @@ -74,7 +89,9 @@ typedef signed char BOOL; #define PAIR(x) @#x, [NSNumber numberWithInt:(x)] #define TWO(x) ((x), (x)) -@interface I +@interface I { + NSArray *ivarArr; +} @end @implementation I -(void) foo { @@ -133,5 +150,74 @@ typedef signed char BOOL; mdict[dict[@[@"arrkey"]]] = dict[@"key1"]; __strong NSArray **parr = 0; o = (*parr)[2]; + void *hd; + o = ((NSArray*)hd)[2]; + o = ivarArr[2]; +} +@end + +extern const CFStringRef globStr; + +void test1(NSString *str) { + NSDictionary *dict = @{(id)globStr: str}; + dict = @{str: (id)globStr}; + dict = @{(id)globStr: str}; + dict = @{str: (id)globStr}; + + NSArray *arr = @[(id)globStr, (id)globStr]; + arr = @[str, (id)globStr]; + arr = @[(id)globStr, str]; + arr = @[(id)globStr]; +} + +@interface Custom : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface Custom (Extended) +- (id)objectAtIndexedSubscript:(unsigned)idx; +@end + +@interface MutableCustom : Custom +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface MutableCustom (Extended) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; +@end + +@interface CustomUnavail : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface CustomUnavail (Extended) +- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable)); +@end + +@interface MutableCustomUnavail : CustomUnavail +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface MutableCustomUnavail (Extended) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable)); +@end + +void test2() { + MutableCustom *mutc; + id o = mutc[4]; + mutc[2] = @"val"; + + MutableCustomUnavail *mutcunaval; + o = [mutcunaval objectAtIndex:4]; + [mutcunaval replaceObjectAtIndex:2 withObject:@"val"]; } + +@interface NSLocale : NSObject ++ (id)systemLocale; ++ (id)currentLocale; +- (id)objectForKey:(id)key; @end + +void test3(id key) { + id o = [[NSLocale currentLocale] objectForKey:key]; +} diff --git a/test/ARCMT/objcmt-subscripting-unavailable.m b/test/ARCMT/objcmt-subscripting-unavailable.m new file mode 100644 index 000000000000..d72c362e30f4 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-unavailable.m @@ -0,0 +1,79 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result + +typedef signed char BOOL; +#define nil ((void*) 0) + +@interface NSObject ++ (id)alloc; +@end + +@interface NSArray : NSObject +- (id)objectAtIndex:(unsigned long)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; +@end + +@interface NSMutableArray : NSArray +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface NSDictionary : NSObject +@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; +@end + +@interface I +@end +@implementation I +-(void) foo { + id str; + NSArray *arr; + NSDictionary *dict; + + arr = [NSArray array]; + arr = [NSArray arrayWithObject:str]; + arr = [NSArray arrayWithObjects:str, str, nil]; + dict = [NSDictionary dictionary]; + dict = [NSDictionary dictionaryWithObject:arr forKey:str]; + + id o = [arr objectAtIndex:2]; + o = [dict objectForKey:@"key"]; + NSMutableArray *marr = 0; + NSMutableDictionary *mdict = 0; + [marr replaceObjectAtIndex:2 withObject:@"val"]; + [mdict setObject:@"value" forKey:@"key"]; + [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; + [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; +} +@end diff --git a/test/ARCMT/objcmt-subscripting-unavailable.m.result b/test/ARCMT/objcmt-subscripting-unavailable.m.result new file mode 100644 index 000000000000..bd74d5583860 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-unavailable.m.result @@ -0,0 +1,79 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result + +typedef signed char BOOL; +#define nil ((void*) 0) + +@interface NSObject ++ (id)alloc; +@end + +@interface NSArray : NSObject +- (id)objectAtIndex:(unsigned long)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; +@end + +@interface NSMutableArray : NSArray +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface NSDictionary : NSObject +@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; +@end + +@interface I +@end +@implementation I +-(void) foo { + id str; + NSArray *arr; + NSDictionary *dict; + + arr = @[]; + arr = @[str]; + arr = @[str, str]; + dict = @{}; + dict = @{str: arr}; + + id o = [arr objectAtIndex:2]; + o = [dict objectForKey:@"key"]; + NSMutableArray *marr = 0; + NSMutableDictionary *mdict = 0; + [marr replaceObjectAtIndex:2 withObject:@"val"]; + [mdict setObject:@"value" forKey:@"key"]; + [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; + [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; +} +@end diff --git a/test/ARCMT/releases-driver.m b/test/ARCMT/releases-driver.m index b75432ac2318..7b1d2fb8e5b2 100644 --- a/test/ARCMT/releases-driver.m +++ b/test/ARCMT/releases-driver.m @@ -53,9 +53,8 @@ void func(Foo *p) { @end @implementation Baz -- dealloc { +- (void) dealloc { [_foo release]; - return 0; } @end diff --git a/test/ARCMT/releases-driver.m.result b/test/ARCMT/releases-driver.m.result index 70c0aecaf475..4c864bd2a874 100644 --- a/test/ARCMT/releases-driver.m.result +++ b/test/ARCMT/releases-driver.m.result @@ -49,9 +49,6 @@ void func(Foo *p) { @end @implementation Baz -- dealloc { - return 0; -} @end #define RELEASE_MACRO(x) [x release] diff --git a/test/ARCMT/releases.m b/test/ARCMT/releases.m index 867fab9cec74..55008959efc4 100644 --- a/test/ARCMT/releases.m +++ b/test/ARCMT/releases.m @@ -58,9 +58,8 @@ void func(Foo *p) { @end @implementation Baz -- dealloc { +- (void) dealloc { [_foo release]; - return 0; } @end diff --git a/test/ARCMT/releases.m.result b/test/ARCMT/releases.m.result index 556610ab2a53..473750e4e899 100644 --- a/test/ARCMT/releases.m.result +++ b/test/ARCMT/releases.m.result @@ -54,9 +54,6 @@ void func(Foo *p) { @end @implementation Baz -- dealloc { - return 0; -} @end void block_test(Foo *p) { diff --git a/test/ARCMT/verify.m b/test/ARCMT/verify.m new file mode 100644 index 000000000000..9110fe6efae2 --- /dev/null +++ b/test/ARCMT/verify.m @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -arcmt-check -verify %s +// RUN: %clang_cc1 -arcmt-check -verify %t.invalid 2>&1 | FileCheck %s + +#if 0 +// expected-error {{should be ignored}} +#endif + +#error should not be ignored +// expected-error@-1 {{should not be ignored}} + +// CHECK: error: 'error' diagnostics seen but not expected: +// CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid' +// CHECK-NEXT: 1 error generated. diff --git a/test/ASTMerge/function.c b/test/ASTMerge/function.c index f97eceed9866..320bca2a36f1 100644 --- a/test/ASTMerge/function.c +++ b/test/ASTMerge/function.c @@ -1,9 +1,15 @@ // 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 +// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %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 + +// expected-error@3 {{external function 'f1' declared with incompatible types}} +// expected-note@2 {{declared here}} +// expected-error@5 {{external function 'f3' declared with incompatible types}} +// expected-note@4 {{declared here}} diff --git a/test/Analysis/MissingDealloc.m b/test/Analysis/MissingDealloc.m index 51a5912d4443..589fcf57f40c 100644 --- a/test/Analysis/MissingDealloc.m +++ b/test/Analysis/MissingDealloc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.cocoa.Dealloc '-DIBOutlet=__attribute__((iboutlet))' %s -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.cocoa.Dealloc %s -verify typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; @@ -53,10 +53,6 @@ typedef struct objc_selector *SEL; //===------------------------------------------------------------------------=== // Don't warn about iVars that are IBOutlets. -#ifndef IBOutlet -#define IBOutlet -#endif - @class NSWindow; @interface HasOutlet : NSObject { diff --git a/test/Analysis/NoReturn.m b/test/Analysis/NoReturn.m index ea2efd061711..1d948fa66f6d 100644 --- a/test/Analysis/NoReturn.m +++ b/test/Analysis/NoReturn.m @@ -76,3 +76,15 @@ int f3(int* x) { return *x; // no-warning } + +@interface CustomException : NSException +@end + +int testCustomException(int *x) { + if (x != 0) return 0; + + [CustomException raise:@"Blah" format:@"abc"]; + + return *x; // no-warning +} + diff --git a/test/Analysis/PR12905.c b/test/Analysis/PR12905.c new file mode 100644 index 000000000000..8f678d114472 --- /dev/null +++ b/test/Analysis/PR12905.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core %s +// PR12905 + +void C(void); + +void t(void) { + C(); +} diff --git a/test/Analysis/additive-folding-range-constraints.c b/test/Analysis/additive-folding-range-constraints.c index 32e0cfe142ad..7eb55ab1e125 100644 --- a/test/Analysis/additive-folding-range-constraints.c +++ b/test/Analysis/additive-folding-range-constraints.c @@ -1,53 +1,37 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -verify -analyzer-constraints=range %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=range %s + +void clang_analyzer_eval(int); + +#define UINT_MAX (~0U) +#define INT_MAX (UINT_MAX & (UINT_MAX >> 1)) +#define INT_MIN (-INT_MAX - 1) -// 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 + clang_analyzer_eval(a < UINT_MAX-1); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a == UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}} } 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 + clang_analyzer_eval(a < UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a == UINT_MAX-1); // expected-warning{{TRUE}} } 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 + clang_analyzer_eval(a == 0 || a == UINT_MAX); // expected-warning{{TRUE}} } 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 + clang_analyzer_eval(a == 0 || a == 1 || a == UINT_MAX); // expected-warning{{TRUE}} } @@ -55,45 +39,134 @@ void smallAdjustmentLE (unsigned a) { // 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 + clang_analyzer_eval(a == 1); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a != 1); // expected-warning{{TRUE}} } 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 + clang_analyzer_eval(a == 1 || a == 0); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a > 1); // expected-warning{{TRUE}} } 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 + clang_analyzer_eval(a == UINT_MAX-1); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a != UINT_MAX-1); // expected-warning{{TRUE}} } 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 + clang_analyzer_eval(a == UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a < UINT_MAX-1); // expected-warning{{TRUE}} +} + + +// Test the nine cases in RangeConstraintManager's pinning logic. +// For out-of-range tautologies, it may be the negation that actually +// triggers the case in question. +void mixedComparisons1(signed char a) { + // Case 1: The range is entirely below the symbol's range. + int min = INT_MIN; + + clang_analyzer_eval((a - 2) >= (min + 5LL)); // expected-warning{{TRUE}} + + clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}} +} + +void mixedComparisons2(signed char a) { + // Case 2: Only the lower end of the range is outside. + clang_analyzer_eval((a - 5) < (-0x81LL)); // expected-warning{{UNKNOWN}} + + if ((a - 5) < (-0x81LL)) { + clang_analyzer_eval(a == 0); // expected-warning{{FALSE}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}} + clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}} + } +} + +void mixedComparisons3(signed char a) { + // Case 3: The entire symbol range is covered. + clang_analyzer_eval((a - 0x200) < -0x100LL); // expected-warning{{TRUE}} + + clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}} +} + +void mixedComparisons4(signed char a) { + // Case 4: The range wraps around, but the lower wrap is out-of-range. + clang_analyzer_eval((a - 5) > 0LL); // expected-warning{{UNKNOWN}} + + if ((a - 5) > 0LL) { + clang_analyzer_eval(a == 0); // expected-warning{{FALSE}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}} + } +} + +void mixedComparisons5(signed char a) { + // Case 5: The range is inside and may or may not wrap. + clang_analyzer_eval((a + 5) == 0LL); // expected-warning{{UNKNOWN}} + + if ((a + 5) == 0LL) { + clang_analyzer_eval(a == 0); // expected-warning{{FALSE}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}} + clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}} + } else { + clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}} + } +} + +void mixedComparisons6(signed char a) { + // Case 6: Only the upper end of the range is outside. + clang_analyzer_eval((a + 5) > 0x81LL); // expected-warning{{UNKNOWN}} + + if ((a + 5) > 0x81LL) { + clang_analyzer_eval(a == 0); // expected-warning{{FALSE}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}} + } +} + +void mixedComparisons7(signed char a) { + // Case 7: The range wraps around but is entirely outside the symbol's range. + int min = INT_MIN; + + clang_analyzer_eval((a + 2) >= (min + 5LL)); // expected-warning{{TRUE}} + + clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}} +} + +void mixedComparisons8(signed char a) { + // Case 8: The range wraps, but the upper wrap is out of range. + clang_analyzer_eval((a + 5) < 0LL); // expected-warning{{UNKNOWN}} + + if ((a + 5) < 0LL) { + clang_analyzer_eval(a == 0); // expected-warning{{FALSE}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}} + clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}} + } +} + +void mixedComparisons9(signed char a) { + // Case 9: The range is entirely above the symbol's range. + int max = INT_MAX; + + clang_analyzer_eval((a + 2) <= (max - 5LL)); // expected-warning{{TRUE}} + + clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}} } diff --git a/test/Analysis/additive-folding.c b/test/Analysis/additive-folding.c deleted file mode 100644 index beb08aa59c2f..000000000000 --- a/test/Analysis/additive-folding.c +++ /dev/null @@ -1,203 +0,0 @@ -// 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/test/Analysis/additive-folding.cpp b/test/Analysis/additive-folding.cpp new file mode 100644 index 000000000000..0d749ec3cbaf --- /dev/null +++ b/test/Analysis/additive-folding.cpp @@ -0,0 +1,196 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=basic -Wno-tautological-compare %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=range -Wno-tautological-compare %s + +void clang_analyzer_eval(bool); + +#define UINT_MAX (~0U) +#define INT_MAX (UINT_MAX & (UINT_MAX >> 1)) +#define INT_MIN (-INT_MAX - 1) + +//--------------- +// Plus/minus +//--------------- + +void separateExpressions (int a) { + int b = a + 1; + --b; + + clang_analyzer_eval(a != 0 && b == 0); // expected-warning{{FALSE}} +} + +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; + + clang_analyzer_eval(a != 0 && b == 0); // expected-warning{{FALSE}} +} + +void mixedTypes (int a) { + // Different additive types should not cause crashes when constant-folding. + // This is part of PR7406. + int b = a + 1LL; + clang_analyzer_eval(a != 0 && (b-1) == 0); // not crash, expected-warning{{FALSE}} + + int c = a + 1U; + clang_analyzer_eval(a != 0 && (c-1) == 0); // not crash, expected-warning{{FALSE}} +} + +//--------------- +// Comparisons +//--------------- + +// Equality and inequality only +void eq_ne (unsigned a) { + if (a == UINT_MAX) { + clang_analyzer_eval(a+1 == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(a-1 == UINT_MAX-1); // expected-warning{{TRUE}} + } else { + clang_analyzer_eval(a+1 != 0); // expected-warning{{TRUE}} + clang_analyzer_eval(a-1 != UINT_MAX-1); // expected-warning{{TRUE}} + } +} + +// Mixed typed inequalities (part of PR7406) +// These should not crash. +void mixed_eq_ne (int a) { + if (a == 1) { + clang_analyzer_eval(a+1U == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(a-1U == 0); // expected-warning{{TRUE}} + } else { + clang_analyzer_eval(a+1U != 2); // expected-warning{{TRUE}} + clang_analyzer_eval(a-1U != 0); // expected-warning{{TRUE}} + } +} + + +// Simple order comparisons with no adjustment +void baselineGT (unsigned a) { + if (a > 0) + clang_analyzer_eval(a != 0); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a == 0); // expected-warning{{TRUE}} +} + +void baselineGE (unsigned a) { + if (a >= UINT_MAX) + clang_analyzer_eval(a == UINT_MAX); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a != UINT_MAX); // expected-warning{{TRUE}} +} + +void baselineLT (unsigned a) { + if (a < UINT_MAX) + clang_analyzer_eval(a != UINT_MAX); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a == UINT_MAX); // expected-warning{{TRUE}} +} + +void baselineLE (unsigned a) { + if (a <= 0) + clang_analyzer_eval(a == 0); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a != 0); // expected-warning{{TRUE}} +} + + +// Adjustment gives each of these an extra solution! +void adjustedGT (unsigned a) { + clang_analyzer_eval(a-1 > UINT_MAX-1); // expected-warning{{UNKNOWN}} +} + +void adjustedGE (unsigned a) { + clang_analyzer_eval(a-1 > UINT_MAX-1); // expected-warning{{UNKNOWN}} + + if (a-1 >= UINT_MAX-1) + clang_analyzer_eval(a == UINT_MAX); // expected-warning{{UNKNOWN}} +} + +void adjustedLT (unsigned a) { + clang_analyzer_eval(a+1 < 1); // expected-warning{{UNKNOWN}} +} + +void adjustedLE (unsigned a) { + clang_analyzer_eval(a+1 <= 1); // expected-warning{{UNKNOWN}} + + if (a+1 <= 1) + clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}} +} + + +// Tautologies +// The negative forms are exercised as well +// because clang_analyzer_eval tests both possibilities. +void tautologies(unsigned a) { + clang_analyzer_eval(a <= UINT_MAX); // expected-warning{{TRUE}} + clang_analyzer_eval(a >= 0); // expected-warning{{TRUE}} +} + + +// Tautologies from outside the range of the symbol +void tautologiesOutside(unsigned char a) { + clang_analyzer_eval(a <= 0x100); // expected-warning{{TRUE}} + clang_analyzer_eval(a < 0x100); // expected-warning{{TRUE}} + + clang_analyzer_eval(a != 0x100); // expected-warning{{TRUE}} + clang_analyzer_eval(a != -1); // expected-warning{{TRUE}} + + clang_analyzer_eval(a > -1); // expected-warning{{TRUE}} + clang_analyzer_eval(a >= -1); // expected-warning{{TRUE}} +} + + +// Wraparound with mixed types. Note that the analyzer assumes +// -fwrapv semantics. +void mixedWraparoundSanityCheck(int a) { + int max = INT_MAX; + int min = INT_MIN; + + int b = a + 1; + clang_analyzer_eval(a == max && b != min); // expected-warning{{FALSE}} +} + +void mixedWraparoundLE_GT(int a) { + int max = INT_MAX; + int min = INT_MIN; + + clang_analyzer_eval((a + 2) <= (max + 1LL)); // expected-warning{{TRUE}} + clang_analyzer_eval((a - 2) > (min - 1LL)); // expected-warning{{TRUE}} + clang_analyzer_eval((a + 2LL) <= max); // expected-warning{{UNKNOWN}} +} + +void mixedWraparoundGE_LT(int a) { + int max = INT_MAX; + int min = INT_MIN; + + clang_analyzer_eval((a + 2) < (max + 1LL)); // expected-warning{{TRUE}} + clang_analyzer_eval((a - 2) >= (min - 1LL)); // expected-warning{{TRUE}} + clang_analyzer_eval((a - 2LL) >= min); // expected-warning{{UNKNOWN}} +} + +void mixedWraparoundEQ_NE(int a) { + int max = INT_MAX; + + clang_analyzer_eval((a + 2) != (max + 1LL)); // expected-warning{{TRUE}} + clang_analyzer_eval((a + 2LL) == (max + 1LL)); // expected-warning{{UNKNOWN}} +} + + +// Mixed-signedness comparisons. +void mixedSignedness(int a, unsigned b) { + int sMin = INT_MIN; + unsigned uMin = INT_MIN; + + clang_analyzer_eval(a == sMin && a != uMin); // expected-warning{{FALSE}} + clang_analyzer_eval(b == uMin && b != sMin); // expected-warning{{FALSE}} +} + + +void multiplicativeSanityTest(int x) { + // At one point we were ignoring the *4 completely -- the constraint manager + // would see x < 8 and then declare the assertion to be known false. + if (x*4 < 8) + return; + + clang_analyzer_eval(x == 3); // expected-warning{{UNKNOWN}} +} diff --git a/test/Analysis/array-struct-region.c b/test/Analysis/array-struct-region.c index 4b085c8d7002..244bc977b511 100644 --- a/test/Analysis/array-struct-region.c +++ b/test/Analysis/array-struct-region.c @@ -1,32 +1,28 @@ -// 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 +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=basic -analyzer-ipa=inlining -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=range -analyzer-ipa=inlining -verify %s + +void clang_analyzer_eval(int); 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}} + clang_analyzer_eval(a[1] == 'b'); // expected-warning{{TRUE}} + clang_analyzer_eval(b[1] == 'b'); // expected-warning{{TRUE}} + clang_analyzer_eval(c[1] == 'b'); // expected-warning{{TRUE}} - if (a[3] != 0) - return 0; // expected-warning{{never executed}} - if (c[3] != 0) - return 0; // expected-warning{{never executed}} + clang_analyzer_eval(a[3] == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(c[3] == 0); // expected-warning{{TRUE}} - if (c[4] != 0) - return 0; // expected-warning{{never executed}} + clang_analyzer_eval(c[4] == 0); // expected-warning{{TRUE}} 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 vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, // expected-warning 6 {{implicit conversion from 'double' to 'int' changes value from}} + {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; // expected-warning 6 {{implicit conversion from 'double' to 'int' changes value from}} int a; for (a = 0; a < 6; ++a) { @@ -45,3 +41,146 @@ void nested_compound_literals_float(float rad) { vec[a][1] *= rad; // no-warning } } + + +void struct_as_array() { + struct simple { int x; int y; }; + struct simple a; + struct simple *p = &a; + + p->x = 5; + clang_analyzer_eval(a.x == 5); // expected-warning{{TRUE}} + clang_analyzer_eval(p[0].x == 5); // expected-warning{{TRUE}} + + p[0].y = 5; + clang_analyzer_eval(a.y == 5); // expected-warning{{TRUE}} + clang_analyzer_eval(p->y == 5); // expected-warning{{TRUE}} +} + + +// PR13264 / +struct point { int x; int y; }; +struct circle { struct point o; int r; }; +struct circle get_circle() { + struct circle result; + result.r = 5; + result.o = (struct point){0, 0}; + return result; +} + +void struct_in_struct() { + struct circle c; + c = get_circle(); + // This used to think c.r was undefined because c.o is a LazyCompoundVal. + clang_analyzer_eval(c.r == 5); // expected-warning{{TRUE}} +} + +// We also test with floats because we don't model floats right now, +// and the original bug report used a float. +struct circle_f { struct point o; float r; }; +struct circle_f get_circle_f() { + struct circle_f result; + result.r = 5.0; + result.o = (struct point){0, 0}; + return result; +} + +float struct_in_struct_f() { + struct circle_f c; + c = get_circle_f(); + + return c.r; // no-warning +} + + +int randomInt(); + +int testSymbolicInvalidation(int index) { + int vals[10]; + + vals[0] = 42; + clang_analyzer_eval(vals[0] == 42); // expected-warning{{TRUE}} + + vals[index] = randomInt(); + clang_analyzer_eval(vals[0] == 42); // expected-warning{{UNKNOWN}} + + return vals[index]; // no-warning +} + +int testConcreteInvalidation(int index) { + int vals[10]; + + vals[index] = 42; + clang_analyzer_eval(vals[index] == 42); // expected-warning{{TRUE}} + vals[0] = randomInt(); + clang_analyzer_eval(vals[index] == 42); // expected-warning{{UNKNOWN}} + + return vals[0]; // no-warning +} + + +typedef struct { + int x, y, z; +} S; + +S makeS(); + +int testSymbolicInvalidationStruct(int index) { + S vals[10]; + + vals[0].x = 42; + clang_analyzer_eval(vals[0].x == 42); // expected-warning{{TRUE}} + + vals[index] = makeS(); + clang_analyzer_eval(vals[0].x == 42); // expected-warning{{UNKNOWN}} + + return vals[index].x; // no-warning +} + +int testConcreteInvalidationStruct(int index) { + S vals[10]; + + vals[index].x = 42; + clang_analyzer_eval(vals[index].x == 42); // expected-warning{{TRUE}} + vals[0] = makeS(); + clang_analyzer_eval(vals[index].x == 42); // expected-warning{{UNKNOWN}} + + return vals[0].x; // no-warning +} + +typedef struct { + S a[5]; + S b[5]; +} SS; + +int testSymbolicInvalidationDoubleStruct(int index) { + SS vals; + + vals.a[0].x = 42; + vals.b[0].x = 42; + clang_analyzer_eval(vals.a[0].x == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(vals.b[0].x == 42); // expected-warning{{TRUE}} + + vals.a[index] = makeS(); + clang_analyzer_eval(vals.a[0].x == 42); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(vals.b[0].x == 42); // expected-warning{{TRUE}} + + return vals.b[index].x; // no-warning +} + +int testConcreteInvalidationDoubleStruct(int index) { + SS vals; + + vals.a[index].x = 42; + vals.b[index].x = 42; + clang_analyzer_eval(vals.a[index].x == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(vals.b[index].x == 42); // expected-warning{{TRUE}} + + vals.a[0] = makeS(); + clang_analyzer_eval(vals.a[index].x == 42); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(vals.b[index].x == 42); // expected-warning{{TRUE}} + + return vals.b[0].x; // no-warning +} + + diff --git a/test/Analysis/auto-obj-dtors-cfg-output.cpp b/test/Analysis/auto-obj-dtors-cfg-output.cpp index 67a8f2e555bd..566e6caed60d 100644 --- a/test/Analysis/auto-obj-dtors-cfg-output.cpp +++ b/test/Analysis/auto-obj-dtors-cfg-output.cpp @@ -416,121 +416,121 @@ void test_catch_copy() { // CHECK: [B6 (ENTRY)] // CHECK: Succs (1): B5 // CHECK: [B1] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: [B4.4].~A() (Implicit destructor) // CHECK: 2: [B5.2].~A() (Implicit destructor) -// CHECK: Preds (1): B2 +// CHECK: Preds (1): B4 // 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: Preds (1): B3 +// CHECK: Succs (1): B4 // CHECK: [B3] +// CHECK: 1: (CXXConstructExpr, class A) +// CHECK: 2: A c; +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B4.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: 4: [B2.4].~A() (Implicit destructor) -// CHECK: Preds (1): B2 -// CHECK: Succs (1): B3 +// CHECK: 1: a +// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 3: [B4.2] (CXXConstructExpr, class A) +// CHECK: 4: A b = a; +// CHECK: 5: b +// CHECK: 6: [B4.5] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 7: [B4.6].operator int +// CHECK: 8: [B4.7]() +// CHECK: 9: [B4.8] (ImplicitCastExpr, UserDefinedConversion, int) +// CHECK: 10: [B4.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) +// CHECK: T: while [B4.10] +// CHECK: Preds (2): B2 B5 +// CHECK: Succs (2): B3 B1 // CHECK: [B5] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A a; // CHECK: Preds (1): B6 -// CHECK: Succs (1): B2 +// CHECK: Succs (1): B4 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B12 (ENTRY)] // CHECK: Succs (1): B11 // CHECK: [B1] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: [B10.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: Preds (2): B8 B10 // 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: Preds (2): B3 B6 +// CHECK: Succs (1): B10 // 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: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B9.2].~A() (Implicit destructor) +// CHECK: 5: [B10.4].~A() (Implicit destructor) +// CHECK: Preds (1): B5 +// CHECK: Succs (1): B2 +// CHECK: [B4] // CHECK: 1: return; -// CHECK: 2: [B10.2].~A() (Implicit destructor) -// CHECK: 3: [B2.4].~A() (Implicit destructor) +// CHECK: 2: [B9.2].~A() (Implicit destructor) +// CHECK: 3: [B10.4].~A() (Implicit destructor) // CHECK: 4: [B11.2].~A() (Implicit destructor) -// CHECK: Preds (1): B6 +// CHECK: Preds (1): B5 // CHECK: Succs (1): B0 -// CHECK: [B6] +// CHECK: [B5] // 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: 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: 2: [B10.4].~A() (Implicit destructor) // CHECK: T: continue; -// CHECK: Preds (1): B8 -// CHECK: Succs (1): B3 -// CHECK: [B8] +// CHECK: Preds (1): B7 +// CHECK: Succs (1): B2 +// CHECK: [B7] // 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: 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): B10 +// CHECK: Preds (1): B9 // CHECK: Succs (1): B1 -// CHECK: [B10] +// CHECK: [B9] // 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: 4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK: T: if [B9.4] +// CHECK: Preds (1): B10 +// CHECK: Succs (2): B8 B7 +// CHECK: [B10] +// CHECK: 1: a +// CHECK: 2: [B10.1] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 3: [B10.2] (CXXConstructExpr, class A) +// CHECK: 4: A b = a; +// CHECK: 5: b +// CHECK: 6: [B10.5] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 7: [B10.6].operator int +// CHECK: 8: [B10.7]() +// CHECK: 9: [B10.8] (ImplicitCastExpr, UserDefinedConversion, int) +// CHECK: 10: [B10.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) +// CHECK: T: while [B10.10] +// CHECK: Preds (2): B2 B11 +// CHECK: Succs (2): B9 B1 // CHECK: [B11] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A a; // CHECK: Preds (1): B12 -// CHECK: Succs (1): B2 +// CHECK: Succs (1): B10 // CHECK: [B0 (EXIT)] -// CHECK: Preds (2): B1 B5 +// CHECK: Preds (2): B1 B4 // CHECK: [B4 (ENTRY)] // CHECK: Succs (1): B2 // CHECK: [B1] @@ -717,124 +717,124 @@ void test_catch_copy() { // CHECK: [B6 (ENTRY)] // CHECK: Succs (1): B5 // CHECK: [B1] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: [B4.4].~A() (Implicit destructor) // CHECK: 2: [B5.2].~A() (Implicit destructor) -// CHECK: Preds (1): B2 +// CHECK: Preds (1): B4 // 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: Preds (1): B3 +// CHECK: Succs (1): B4 // CHECK: [B3] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: (CXXConstructExpr, class A) +// CHECK: 2: A c; +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B4.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: 1: a +// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 3: [B4.2] (CXXConstructExpr, class A) +// CHECK: 4: A b = a; +// CHECK: 5: b +// CHECK: 6: [B4.5] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 7: [B4.6].operator int +// CHECK: 8: [B4.7]() +// CHECK: 9: [B4.8] (ImplicitCastExpr, UserDefinedConversion, int) +// CHECK: 10: [B4.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) +// CHECK: T: for (...; [B4.10]; ) +// CHECK: Preds (2): B2 B5 +// CHECK: Succs (2): B3 B1 // CHECK: [B5] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A a; // CHECK: Preds (1): B6 -// CHECK: Succs (1): B2 +// CHECK: Succs (1): B4 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B12 (ENTRY)] // CHECK: Succs (1): B11 // CHECK: [B1] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: [B10.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: Preds (2): B8 B10 // 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: Preds (2): B3 B6 +// CHECK: Succs (1): B10 // 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: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B9.2].~A() (Implicit destructor) +// CHECK: 5: [B10.4].~A() (Implicit destructor) +// CHECK: Preds (1): B5 +// CHECK: Succs (1): B2 +// CHECK: [B4] // CHECK: 1: return; -// CHECK: 2: [B10.2].~A() (Implicit destructor) -// CHECK: 3: [B2.4].~A() (Implicit destructor) +// CHECK: 2: [B9.2].~A() (Implicit destructor) +// CHECK: 3: [B10.4].~A() (Implicit destructor) // CHECK: 4: [B11.4].~A() (Implicit destructor) // CHECK: 5: [B11.2].~A() (Implicit destructor) -// CHECK: Preds (1): B6 +// CHECK: Preds (1): B5 // CHECK: Succs (1): B0 -// CHECK: [B6] +// CHECK: [B5] // 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: [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): B8 -// CHECK: Succs (1): B3 -// CHECK: [B8] +// CHECK: Preds (1): B7 +// CHECK: Succs (1): B2 +// CHECK: [B7] // 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: 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): B10 +// CHECK: Preds (1): B9 // CHECK: Succs (1): B1 -// CHECK: [B10] +// CHECK: [B9] // 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: 4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK: T: if [B9.4] +// CHECK: Preds (1): B10 +// CHECK: Succs (2): B8 B7 +// CHECK: [B10] +// CHECK: 1: b +// CHECK: 2: [B10.1] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 3: [B10.2] (CXXConstructExpr, class A) +// CHECK: 4: A c = b; +// CHECK: 5: c +// CHECK: 6: [B10.5] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 7: [B10.6].operator int +// CHECK: 8: [B10.7]() +// CHECK: 9: [B10.8] (ImplicitCastExpr, UserDefinedConversion, int) +// CHECK: 10: [B10.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) +// CHECK: T: for (...; [B10.10]; ) +// CHECK: Preds (2): B2 B11 +// CHECK: Succs (2): B9 B1 // 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: Succs (1): B10 // CHECK: [B0 (EXIT)] -// CHECK: Preds (2): B1 B5 +// CHECK: Preds (2): B1 B4 // CHECK: [B3 (ENTRY)] // CHECK: Succs (1): B0 // CHECK: [B1] @@ -862,3 +862,4 @@ void test_catch_copy() { // CHECK: Succs (1): B0 // CHECK: [B0 (EXIT)] // CHECK: Preds (3): B2 B1 B3 + diff --git a/test/Analysis/base-init.cpp b/test/Analysis/base-init.cpp index 8fd7abcc3778..e63d50855e10 100644 --- a/test/Analysis/base-init.cpp +++ b/test/Analysis/base-init.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-inline-call -cfg-add-initializers -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -analyzer-ipa=inlining -verify %s // XFAIL: * +void clang_analyzer_eval(bool); + class A { int x; public: @@ -24,8 +26,5 @@ B::B() { void f() { B b; - if (b.getx() != 0) { - int *p = 0; - *p = 0; // no-warning - } + clang_analyzer_eval(b.getx() == 0); // expected-warning{{TRUE}} } diff --git a/test/Analysis/blocks-no-inline.c b/test/Analysis/blocks-no-inline.c new file mode 100644 index 000000000000..1ec14e820b0e --- /dev/null +++ b/test/Analysis/blocks-no-inline.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=none -fblocks -verify %s + +void clang_analyzer_eval(int); + +void testInvalidation() { + __block int i = 0; + ^{ + ++i; + }(); + + // Under inlining, we will know that i == 1. + clang_analyzer_eval(i == 0); // expected-warning{{UNKNOWN}} +} diff --git a/test/Analysis/blocks.m b/test/Analysis/blocks.m index 7a604ddb4d91..ff376d17a1a1 100644 --- a/test/Analysis/blocks.m +++ b/test/Analysis/blocks.m @@ -79,9 +79,7 @@ void test2() { 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 + ^{ y = x + 1; }(); // expected-warning {{left operand of '+' is a garbage value}} } void test2_c() { diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c index 833c917613ed..d383d421d444 100644 --- a/test/Analysis/bstring.c +++ b/test/Analysis/bstring.c @@ -1,7 +1,7 @@ -// 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 +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s //===----------------------------------------------------------------------=== // Declarations @@ -26,6 +26,8 @@ typedef typeof(sizeof(int)) size_t; +void clang_analyzer_eval(int); + //===----------------------------------------------------------------------=== // memcpy() //===----------------------------------------------------------------------=== @@ -52,12 +54,11 @@ void memcpy0 () { memcpy(dst, src, 4); // no-warning - if (memcpy(dst, src, 4) != dst) { - (void)*(char*)0; // no-warning - } + clang_analyzer_eval(memcpy(dst, src, 4) == dst); // expected-warning{{TRUE}} - if (dst[0] != 0) - (void)*(char*)0; // expected-warning{{null}} + // If we actually model the copy, we can make this known. + // The important thing for now is that the old value has been invalidated. + clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}} } void memcpy1 () { @@ -138,14 +139,13 @@ void memcpy13() { void memcpy_unknown_size (size_t n) { char a[4], b[4] = {1}; - if (memcpy(a, b, n) != a) - (void)*(char*)0; // no-warning + clang_analyzer_eval(memcpy(a, b, n) == a); // expected-warning{{TRUE}} } 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 + void *result = memcpy(a, 0, n); // expected-warning{{Null pointer argument in call to memory copy function}} + clang_analyzer_eval(result == a); // no-warning (above is fatal) } //===----------------------------------------------------------------------=== @@ -174,12 +174,11 @@ void mempcpy0 () { mempcpy(dst, src, 4); // no-warning - if (mempcpy(dst, src, 4) != &dst[4]) { - (void)*(char*)0; // no-warning - } + clang_analyzer_eval(mempcpy(dst, src, 4) == &dst[4]); // expected-warning{{TRUE}} - if (dst[0] != 0) - (void)*(char*)0; // expected-warning{{null}} + // If we actually model the copy, we can make this known. + // The important thing for now is that the old value has been invalidated. + clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}} } void mempcpy1 () { @@ -260,8 +259,8 @@ void mempcpy13() { 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 *result = mempcpy(a, 0, n); // expected-warning{{Null pointer argument in call to memory copy function}} + clang_analyzer_eval(result == a); // no-warning (above is fatal) } void mempcpy_unknownable_size (char *src, float n) { @@ -295,12 +294,11 @@ void memmove0 () { memmove(dst, src, 4); // no-warning - if (memmove(dst, src, 4) != dst) { - (void)*(char*)0; // no-warning - } + clang_analyzer_eval(memmove(dst, src, 4) == dst); // expected-warning{{TRUE}} - if (dst[0] != 0) - (void)*(char*)0; // expected-warning{{null}} + // If we actually model the copy, we can make this known. + // The important thing for now is that the old value has been invalidated. + clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}} } void memmove1 () { @@ -327,7 +325,7 @@ void memmove2 () { // __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) @@ -360,34 +358,32 @@ void memcmp2 () { void memcmp3 () { char a[] = {1, 2, 3, 4}; - if (memcmp(a, a, 4)) - (void)*(char*)0; // no-warning + clang_analyzer_eval(memcmp(a, a, 4) == 0); // expected-warning{{TRUE}} } void memcmp4 (char *input) { char a[] = {1, 2, 3, 4}; - if (memcmp(a, input, 4)) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(memcmp(a, input, 4) == 0); // expected-warning{{UNKNOWN}} } 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 + clang_analyzer_eval(memcmp(a, 0, 0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(memcmp(0, a, 0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(memcmp(a, input, 0) == 0); // expected-warning{{TRUE}} } 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}} + clang_analyzer_eval(n != 0); // expected-warning{{TRUE}} + // else + // analyzer_assert_unknown(n == 0); + + // We can't do the above comparison because n has already been constrained. + // On one path n == 0, on the other n != 0. } int memcmp7 (char *a, size_t x, size_t y, size_t n) { @@ -411,8 +407,9 @@ void bcopy0 () { bcopy(src, dst, 4); // no-warning - if (dst[0] != 0) - (void)*(char*)0; // expected-warning{{null}} + // If we actually model the copy, we can make this known. + // The important thing for now is that the old value has been invalidated. + clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}} } void bcopy1 () { @@ -428,3 +425,13 @@ void bcopy2 () { bcopy(src, dst, 4); // expected-warning{{overflow}} } + +void *malloc(size_t); +void free(void *); +char radar_11125445_memcopythenlogfirstbyte(const char *input, size_t length) { + char *bytes = malloc(sizeof(char) * (length + 1)); + memcpy(bytes, input, length); + char x = bytes[0]; // no warning + free(bytes); + return x; +} diff --git a/test/Analysis/casts.c b/test/Analysis/casts.c index 8b88a2db432e..f862ddf57315 100644 --- a/test/Analysis/casts.c +++ b/test/Analysis/casts.c @@ -65,3 +65,11 @@ void pr6013_6035_test(void *p) { foo = ((long)(p)); (void) foo; } + +// PR12511 and radar://11215362 - Test that we support SymCastExpr, which represents symbolic int to float cast. +char ttt(int intSeconds) { + double seconds = intSeconds; + if (seconds) + return 0; + return 0; +} diff --git a/test/Analysis/comparison-implicit-casts.cpp b/test/Analysis/comparison-implicit-casts.cpp new file mode 100644 index 000000000000..df9d8700099e --- /dev/null +++ b/test/Analysis/comparison-implicit-casts.cpp @@ -0,0 +1,98 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=basic -triple i386-apple-darwin9 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=basic -triple x86_64-apple-darwin9 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=range -triple i386-apple-darwin9 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=range -triple x86_64-apple-darwin9 -verify %s + +// This file runs in C++ mode so that the comparison type is 'bool', not 'int'. +void clang_analyzer_eval(int); +typedef typeof(sizeof(int)) size_t; + +// PR12206/12510 - When SimpleSValBuilder figures out that a symbol is fully +// constrained, it should cast the value to the result type in a binary +// operation...unless the binary operation is a comparison, in which case the +// two arguments should be the same type, but won't match the result type. +// +// This is not directly related to additive folding, but we use SValBuilder's +// additive folding to tickle the bug. ExprEngine will simplify fully-constrained +// symbols, so SValBuilder will only see them if they are (a) part of an evaluated +// SymExpr (e.g. with additive folding) or (b) generated by a checker (e.g. +// unix.cstring's strlen() modelling). +void PR12206(int x) { + size_t comparisonSize = sizeof(1 == 1); + + // Sanity check. This test is useless if size_t isn't bigger than bool. + clang_analyzer_eval(sizeof(size_t) > comparisonSize); // expected-warning{{TRUE}} + + // Build a SymIntExpr, dependent on x. + int local = x - 1; + + // Create a value that requires more bits to store than a comparison result. + int value = 1; + value <<= 8 * comparisonSize; + value += 1; + + // Constrain the value of x. + if (x != value) return; + + // Constant-folding will turn (local+1) back into the symbol for x. + // The point of this dance is to make SValBuilder be responsible for + // turning the symbol into a ConcreteInt, rather than ExprEngine. + + // Test relational operators. + clang_analyzer_eval((local + 1) >= 2); // expected-warning{{TRUE}} + clang_analyzer_eval(2 <= (local + 1)); // expected-warning{{TRUE}} + + // Test equality operators. + clang_analyzer_eval((local + 1) != 1); // expected-warning{{TRUE}} + clang_analyzer_eval(1 != (local + 1)); // expected-warning{{TRUE}} +} + +void PR12206_truncation(signed char x) { + // Build a SymIntExpr, dependent on x. + signed char local = x - 1; + + // Constrain the value of x. + if (x != 1) return; + + // Constant-folding will turn (local+1) back into the symbol for x. + // The point of this dance is to make SValBuilder be responsible for + // turning the symbol into a ConcreteInt, rather than ExprEngine. + + // Construct a value that cannot be represented by 'char', + // but that has the same lower bits as x. + signed int value = 1 + (1 << 8); + + // Test relational operators. + clang_analyzer_eval((local + 1) < value); // expected-warning{{TRUE}} + clang_analyzer_eval(value > (local + 1)); // expected-warning{{TRUE}} + + // Test equality operators. + clang_analyzer_eval((local + 1) != value); // expected-warning{{TRUE}} + clang_analyzer_eval(value != (local + 1)); // expected-warning{{TRUE}} +} + +// This test is insurance in case we significantly change how SymExprs are +// evaluated. +size_t strlen(const char *s); +void PR12206_strlen(const char *x) { + size_t comparisonSize = sizeof(1 == 1); + + // Sanity check. This test is useless if size_t isn't bigger than bool. + clang_analyzer_eval(sizeof(size_t) > comparisonSize); // expected-warning{{TRUE}} + + // Create a value that requires more bits to store than a comparison result. + size_t value = 1UL; + value <<= 8 * comparisonSize; + value += 1; + + // Constrain the length of x. + if (strlen(x) != value) return; + + // Test relational operators. + clang_analyzer_eval(strlen(x) >= 2); // expected-warning{{TRUE}} + clang_analyzer_eval(2 <= strlen(x)); // expected-warning{{TRUE}} + + // Test equality operators. + clang_analyzer_eval(strlen(x) != 1); // expected-warning{{TRUE}} + clang_analyzer_eval(1 != strlen(x)); // expected-warning{{TRUE}} +} diff --git a/test/Analysis/constant-folding.c b/test/Analysis/constant-folding.c index e7a5705fa59a..81d119392658 100644 --- a/test/Analysis/constant-folding.c +++ b/test/Analysis/constant-folding.c @@ -1,7 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s -// Trigger a warning if the analyzer reaches this point in the control flow. -#define WARN ((void)*(char*)0) +void clang_analyzer_eval(int); // There should be no warnings unless otherwise indicated. @@ -9,64 +8,71 @@ void testComparisons (int a) { // Sema can already catch the simple comparison a==a, // since that's usually a logic error (and not path-dependent). int b = a; - if (!(b==a)) WARN; // expected-warning{{never executed}} - if (!(b>=a)) WARN; // expected-warning{{never executed}} - if (!(b<=a)) WARN; // expected-warning{{never executed}} - if (b!=a) WARN; // expected-warning{{never executed}} - if (b>a) WARN; // expected-warning{{never executed}} - if (b= a); // expected-warning{{TRUE}} + clang_analyzer_eval(b <= a); // expected-warning{{TRUE}} + clang_analyzer_eval(b != a); // expected-warning{{FALSE}} + clang_analyzer_eval(b > a); // expected-warning{{FALSE}} + clang_analyzer_eval(b < a); // expected-warning{{FALSE}} } void testSelfOperations (int a) { - if ((a|a) != a) WARN; // expected-warning{{never executed}} - if ((a&a) != a) WARN; // expected-warning{{never executed}} - if ((a^a) != 0) WARN; // expected-warning{{never executed}} - if ((a-a) != 0) WARN; // expected-warning{{never executed}} + clang_analyzer_eval((a|a) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a&a) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a^a) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval((a-a) == 0); // expected-warning{{TRUE}} } void testIdempotent (int a) { - if ((a*1) != a) WARN; // expected-warning{{never executed}} - if ((a/1) != a) WARN; // expected-warning{{never executed}} - if ((a+0) != a) WARN; // expected-warning{{never executed}} - if ((a-0) != a) WARN; // expected-warning{{never executed}} - if ((a<<0) != a) WARN; // expected-warning{{never executed}} - if ((a>>0) != a) WARN; // expected-warning{{never executed}} - if ((a^0) != a) WARN; // expected-warning{{never executed}} - if ((a&(~0)) != a) WARN; // expected-warning{{never executed}} - if ((a|0) != a) WARN; // expected-warning{{never executed}} + clang_analyzer_eval((a*1) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a/1) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a+0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a-0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a<<0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a>>0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a^0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a&(~0)) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a|0) == a); // expected-warning{{TRUE}} } 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}} + clang_analyzer_eval((a*0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval((a&0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval((a|(~0)) == (~0)); // expected-warning{{TRUE}} } 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}} + clang_analyzer_eval((2+a) == (a+2)); // expected-warning{{TRUE}} + clang_analyzer_eval((2*a) == (a*2)); // expected-warning{{TRUE}} + clang_analyzer_eval((2&a) == (a&2)); // expected-warning{{TRUE}} + clang_analyzer_eval((2^a) == (a^2)); // expected-warning{{TRUE}} + clang_analyzer_eval((2|a) == (a|2)); // expected-warning{{TRUE}} } 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}} + clang_analyzer_eval(((~0) >> a) == (~0)); // expected-warning{{TRUE}} + clang_analyzer_eval((0 >> a) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval((0 << a) == 0); // expected-warning{{TRUE}} // Unsigned right shift shifts in zeroes. - if ((((unsigned)(~0)) >> ((unsigned) a)) != ((unsigned)(~0))) - WARN; // expected-warning{{}} + clang_analyzer_eval(((~0U) >> a) != (~0U)); // expected-warning{{UNKNOWN}} } void testLocations (char *a) { char *b = a; - if (!(b==a)) WARN; // expected-warning{{never executed}} - if (!(b>=a)) WARN; // expected-warning{{never executed}} - if (!(b<=a)) WARN; // expected-warning{{never executed}} - if (b!=a) WARN; // expected-warning{{never executed}} - if (b>a) WARN; // expected-warning{{never executed}} - if (b= a); // expected-warning{{TRUE}} + clang_analyzer_eval(b <= a); // expected-warning{{TRUE}} + clang_analyzer_eval(b != a); // expected-warning{{FALSE}} + clang_analyzer_eval(b > a); // expected-warning{{FALSE}} + clang_analyzer_eval(b < a); // expected-warning{{FALSE}} +} + +void testMixedTypeComparisons (char a, unsigned long b) { + if (a != 0) return; + if (b != 0x100) return; + + clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} + clang_analyzer_eval(b >= a); // expected-warning{{TRUE}} + clang_analyzer_eval(a != b); // expected-warning{{TRUE}} } diff --git a/test/Analysis/coverage.c b/test/Analysis/coverage.c index 73d78da18644..811691391eb1 100644 --- a/test/Analysis/coverage.c +++ b/test/Analysis/coverage.c @@ -92,3 +92,11 @@ void coverage9(int *x) { function_which_gives_up_settonull(&x); y = (*x); // no warning } + +static void empty_function(){ +} +int use_empty_function(int x) { + x = 0; + empty_function(); + return 5/x; //expected-warning {{Division by zero}} +} diff --git a/test/Analysis/cstring-syntax.c b/test/Analysis/cstring-syntax.c index 64ecb67008f8..4aa88ed3b7ed 100644 --- a/test/Analysis/cstring-syntax.c +++ b/test/Analysis/cstring-syntax.c @@ -1,4 +1,4 @@ -// 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 +// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -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); diff --git a/test/Analysis/ctor-inlining.mm b/test/Analysis/ctor-inlining.mm new file mode 100644 index 000000000000..54d51b46dc5e --- /dev/null +++ b/test/Analysis/ctor-inlining.mm @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fobjc-arc -cfg-add-implicit-dtors -Wno-null-dereference -verify %s + +void clang_analyzer_eval(bool); + +struct Wrapper { + __strong id obj; +}; + +void test() { + Wrapper w; + // force a diagnostic + *(char *)0 = 1; // expected-warning{{Dereference of null pointer}} +} + + +struct IntWrapper { + int x; +}; + +void testCopyConstructor() { + IntWrapper a; + a.x = 42; + + IntWrapper b(a); + clang_analyzer_eval(b.x == 42); // expected-warning{{TRUE}} +} + +struct NonPODIntWrapper { + int x; + + virtual int get(); +}; + +void testNonPODCopyConstructor() { + NonPODIntWrapper a; + a.x = 42; + + NonPODIntWrapper b(a); + clang_analyzer_eval(b.x == 42); // expected-warning{{TRUE}} +} + diff --git a/test/Analysis/cxx-crashes.cpp b/test/Analysis/cxx-crashes.cpp index 17fc74d06f46..8912bf68de3f 100644 --- a/test/Analysis/cxx-crashes.cpp +++ b/test/Analysis/cxx-crashes.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s + +void clang_analyzer_eval(bool); int f1(char *dst) { char *p = dst + 4; @@ -54,3 +56,22 @@ struct C { void C::f() { } } + + +void vla(int n) { + int nums[n]; + nums[0] = 1; + clang_analyzer_eval(nums[0] == 1); // expected-warning{{TRUE}} + + // This used to fail with MallocChecker on, and /only/ in C++ mode. + // This struct is POD, though, so it should be fine to put it in a VLA. + struct { int x; } structs[n]; + structs[0].x = 1; + clang_analyzer_eval(structs[0].x == 1); // expected-warning{{TRUE}} +} + +void useIntArray(int []); +void testIntArrayLiteral() { + useIntArray((int []){ 1, 2, 3 }); +} + diff --git a/test/Analysis/cxx-for-range-cfg.cpp b/test/Analysis/cxx-for-range-cfg.cpp new file mode 100644 index 000000000000..e258c7a1e208 --- /dev/null +++ b/test/Analysis/cxx-for-range-cfg.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -Wall -fsyntax-only %s -std=c++11 -verify + +// The rdar11671507_vector[]> would previously crash CFG construction +// because of the temporary array of vectors. +template +class rdar11671507_vector { +public: + rdar11671507_vector(); + ~rdar11671507_vector(); + T *Base; + T *End; +}; + +void rdar11671507(rdar11671507_vector v, rdar11671507_vector w) { + for (auto &vec : (rdar11671507_vector[]){ v, w }) {} // expected-warning {{unused}} +} diff --git a/test/Analysis/cxx-method-names.cpp b/test/Analysis/cxx-method-names.cpp new file mode 100644 index 000000000000..8afbb85c1730 --- /dev/null +++ b/test/Analysis/cxx-method-names.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix,osx,experimental.unix,experimental.security.taint -analyzer-store region -verify %s + +class Evil { +public: + void system(int); // taint checker + void malloc(void *); // taint checker, malloc checker + void free(); // malloc checker, keychain checker + void fopen(); // stream checker + void feof(int, int); // stream checker + void open(); // unix api checker +}; + +void test(Evil &E) { + // no warnings, no crashes + E.system(0); + E.malloc(0); + E.free(); + E.fopen(); + E.feof(0,1); + E.open(); +} diff --git a/test/Analysis/cxx11-crashes.cpp b/test/Analysis/cxx11-crashes.cpp new file mode 100644 index 000000000000..16bfc891000f --- /dev/null +++ b/test/Analysis/cxx11-crashes.cpp @@ -0,0 +1,66 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -std=c++11 -verify %s + +// radar://11485149, PR12871 +class PlotPoint { + bool valid; +}; + +PlotPoint limitedFit () { + PlotPoint fit0; + fit0 = limitedFit (); + return fit0; +} + +// radar://11487541, NamespaceAlias +namespace boost {namespace filesystem3 { +class path { +public: + path(){} +}; + +}} +namespace boost +{ + namespace filesystem + { + using filesystem3::path; + } +} + +void radar11487541() { + namespace fs = boost::filesystem; + fs::path p; +} + +// PR12873 radar://11499139 +void testFloatInitializer() { + const float ysize={0.015}, xsize={0.01}; +} + + +// PR12874, radar://11487525 +template struct addr_impl_ref { + T & v_; + inline addr_impl_ref( T & v ): v_( v ) { + } + inline operator T& () const {return v_;} +}; +template struct addressof_impl { + static inline T * f( T & v, long ) { + return reinterpret_cast(&const_cast(reinterpret_cast(v))); + } +}; +template T * addressof( T & v ) { + return addressof_impl::f( addr_impl_ref( v ), 0 ); +} +void testRadar11487525_1(){ + bool s[25]; + addressof(s); +} + +// radar://11487525 Don't crash on CK_LValueBitCast. +bool begin(double *it) { + typedef bool type[25]; + bool *a = reinterpret_cast(*( reinterpret_cast( it ))); + return *a; +} diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m index 083427478d7e..fe565547e12a 100644 --- a/test/Analysis/dead-stores.m +++ b/test/Analysis/dead-stores.m @@ -88,3 +88,23 @@ void rdar10591355() { RDar10591355 *p = rdar10591355_aux(); ^{ (void) p.x; }(); } + +@interface Radar11059352_1 { +@private + int *_pathString; +} +@property int *pathString; +@end +@interface Radar11059352 { +@private +Radar11059352_1 *_Path; +} +@end +@implementation Radar11059352 + +- (int*)usePath { + Radar11059352_1 *xxxxx = _Path; // no warning + int *wp = xxxxx.pathString; + return wp; +} +@end diff --git a/test/Analysis/delegates.m b/test/Analysis/delegates.m index 8f42b83b0eeb..7fc4f2bb9616 100644 --- a/test/Analysis/delegates.m +++ b/test/Analysis/delegates.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -Wno-objc-root-class -verify %s //===----------------------------------------------------------------------===// @@ -96,13 +96,12 @@ extern void *_NSConstantStringClassReference; @implementation test_6062730 - (void) foo { - NSString *str = [[NSString alloc] init]; + NSString *str = [[NSString alloc] init]; // no-warning [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'. + NSString *str = [[NSString alloc] init]; // no-warning [[self class] performSelectorOnMainThread:@selector(postNotification:) withObject:str waitUntilDone:1]; } @@ -111,3 +110,21 @@ extern void *_NSConstantStringClassReference; } @end + +@interface ObjectThatRequiresDelegate : NSObject +- (id)initWithDelegate:(id)delegate; +- (id)initWithNumber:(int)num delegate:(id)delegate; +@end + + +@interface DelegateRequirerTest +@end +@implementation DelegateRequirerTest + +- (void)test { + (void)[[ObjectThatRequiresDelegate alloc] initWithDelegate:self]; + (void)[[ObjectThatRequiresDelegate alloc] initWithNumber:0 delegate:self]; + // no leak warnings -- these objects could be released in callback methods +} + +@end diff --git a/test/Analysis/derived-to-base.cpp b/test/Analysis/derived-to-base.cpp index f65b9db17b65..f8336785de8f 100644 --- a/test/Analysis/derived-to-base.cpp +++ b/test/Analysis/derived-to-base.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify %s + +void clang_analyzer_eval(bool); class A { protected: @@ -13,3 +15,123 @@ public: void B::f() { x = 3; } + + +class C : public B { +public: + void g() { + // This used to crash because we are upcasting through two bases. + x = 5; + } +}; + + +namespace VirtualBaseClasses { + class A { + protected: + int x; + }; + + class B : public virtual A { + public: + int getX() { return x; } + }; + + class C : public virtual A { + public: + void setX() { x = 42; } + }; + + class D : public B, public C {}; + class DV : virtual public B, public C {}; + class DV2 : public B, virtual public C {}; + + void test() { + D d; + d.setX(); + clang_analyzer_eval(d.getX() == 42); // expected-warning{{TRUE}} + + DV dv; + dv.setX(); + clang_analyzer_eval(dv.getX() == 42); // expected-warning{{TRUE}} + + DV2 dv2; + dv2.setX(); + clang_analyzer_eval(dv2.getX() == 42); // expected-warning{{TRUE}} + } + + + // Make sure we're consistent about the offset of the A subobject within an + // Intermediate virtual base class. + class Padding1 { int unused; }; + class Padding2 { int unused; }; + class Intermediate : public Padding1, public A, public Padding2 {}; + + class BI : public virtual Intermediate { + public: + int getX() { return x; } + }; + + class CI : public virtual Intermediate { + public: + void setX() { x = 42; } + }; + + class DI : public BI, public CI {}; + + void testIntermediate() { + DI d; + d.setX(); + clang_analyzer_eval(d.getX() == 42); // expected-warning{{TRUE}} + } +} + + +namespace DynamicVirtualUpcast { + class A { + public: + virtual ~A(); + }; + + class B : virtual public A {}; + class C : virtual public B {}; + class D : virtual public C {}; + + bool testCast(A *a) { + return dynamic_cast(a) && dynamic_cast(a); + } + + void test() { + D d; + clang_analyzer_eval(testCast(&d)); // expected-warning{{TRUE}} + } +} + +namespace DynamicMultipleInheritanceUpcast { + class B { + public: + virtual ~B(); + }; + class C { + public: + virtual ~C(); + }; + class D : public B, public C {}; + + bool testCast(B *a) { + return dynamic_cast(a); + } + + void test() { + D d; + clang_analyzer_eval(testCast(&d)); // expected-warning{{TRUE}} + } + + + class DV : virtual public B, virtual public C {}; + + void testVirtual() { + DV d; + clang_analyzer_eval(testCast(&d)); // expected-warning{{TRUE}} + } +} diff --git a/test/Analysis/diagnostics/undef-value-callee.h b/test/Analysis/diagnostics/undef-value-callee.h new file mode 100644 index 000000000000..ea48c46a62c1 --- /dev/null +++ b/test/Analysis/diagnostics/undef-value-callee.h @@ -0,0 +1,4 @@ + +void callee() { + ; +} diff --git a/test/Analysis/diagnostics/undef-value-caller.c b/test/Analysis/diagnostics/undef-value-caller.c new file mode 100644 index 000000000000..928839d0404d --- /dev/null +++ b/test/Analysis/diagnostics/undef-value-caller.c @@ -0,0 +1,238 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist -o %t %s +// RUN: FileCheck --input-file %t %s + +#include "undef-value-callee.h" + +// This code used to cause a crash since we were not adding fileID of the header to the plist diagnostic. +// Note, in the future, we do not even need to step into this callee since it does not influence the result. +int test_calling_unimportant_callee(int argc, char *argv[]) { + int x; + callee(); + return x; // expected-warning {{Undefined or garbage value returned to caller}} +} + +// CHECK: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line9 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'x' declared without an initial value +// CHECK: message +// CHECK: Variable 'x' declared without an initial value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col8 +// 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: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'callee' +// CHECK: message +// CHECK: Calling 'callee' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line2 +// CHECK: col1 +// CHECK: file1 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'test_calling_unimportant_callee' +// CHECK: message +// CHECK: Entered call from 'test_calling_unimportant_callee' +// 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: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Returning from 'callee' +// CHECK: message +// CHECK: Returning from 'callee' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line11 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Undefined or garbage value returned to caller +// CHECK: message +// CHECK: Undefined or garbage value returned to caller +// CHECK: +// CHECK: +// CHECK: descriptionUndefined or garbage value returned to caller +// CHECK: categoryLogic error +// CHECK: typeGarbage return value +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_calling_unimportant_callee +// CHECK: location +// CHECK: +// CHECK: line11 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: diff --git a/test/Analysis/domtest.c b/test/Analysis/domtest.c index 245186a1c239..0f370db5c132 100644 --- a/test/Analysis/domtest.c +++ b/test/Analysis/domtest.c @@ -1,4 +1,6 @@ -// RUN: %clang -cc1 -analyze -analyzer-checker=debug.DumpDominators %s 2>&1 | FileCheck %s +// RUN: rm -f %t +// RUN: %clang -cc1 -analyze -analyzer-checker=debug.DumpDominators %s > %t 2>&1 +// RUN: FileCheck --input-file=%t %s // Test the DominatorsTree implementation with various control flows int test1() @@ -24,13 +26,13 @@ int test1() // 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: (1,7) +// CHECK: (2,3) +// CHECK: (3,6) +// CHECK: (4,6) +// CHECK: (5,6) // CHECK: (6,7) -// CHECK: (7,2) +// CHECK: (7,8) // CHECK: (8,9) // CHECK: (9,9) @@ -55,9 +57,9 @@ int test2() // CHECK: Immediate dominance tree (Node#,IDom#): // CHECK: (0,1) // CHECK: (1,6) -// CHECK: (2,6) +// CHECK: (2,3) // CHECK: (3,4) -// CHECK: (4,2) +// CHECK: (4,6) // CHECK: (5,6) // CHECK: (6,7) // CHECK: (7,7) @@ -83,11 +85,11 @@ int test3() // CHECK: Immediate dominance tree (Node#,IDom#): // CHECK: (0,1) // CHECK: (1,7) -// CHECK: (2,7) +// CHECK: (2,5) // CHECK: (3,4) -// CHECK: (4,2) +// CHECK: (4,5) // CHECK: (5,6) -// CHECK: (6,4) +// CHECK: (6,7) // CHECK: (7,8) // CHECK: (8,8) @@ -108,16 +110,16 @@ int test4() // 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: (1,10) +// CHECK: (2,9) +// CHECK: (3,4) +// CHECK: (4,5) +// CHECK: (5,9) +// CHECK: (6,7) +// CHECK: (7,8) // CHECK: (8,9) -// CHECK: (9,7) -// CHECK: (10,2) +// CHECK: (9,10) +// CHECK: (10,11) // CHECK: (11,12) // CHECK: (12,12) @@ -163,3 +165,4 @@ int test5() // CHECK: (10,11) // CHECK: (11,11) + diff --git a/test/Analysis/dtor.cpp b/test/Analysis/dtor.cpp index 8d63cc47bed4..620994858c7c 100644 --- a/test/Analysis/dtor.cpp +++ b/test/Analysis/dtor.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-ipa=inlining -cfg-add-implicit-dtors -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -analyzer-ipa=inlining -cfg-add-implicit-dtors -Wno-null-dereference -verify %s + +void clang_analyzer_eval(bool); class A { public: @@ -11,3 +13,163 @@ public: int main() { A a; } + + +typedef __typeof(sizeof(int)) size_t; +void *malloc(size_t); +void free(void *); + +class SmartPointer { + void *X; +public: + SmartPointer(void *x) : X(x) {} + ~SmartPointer() { + free(X); + } +}; + +void testSmartPointer() { + char *mem = (char*)malloc(4); + { + SmartPointer Deleter(mem); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + + +void doSomething(); +void testSmartPointer2() { + char *mem = (char*)malloc(4); + { + SmartPointer Deleter(mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + + +class Subclass : public SmartPointer { +public: + Subclass(void *x) : SmartPointer(x) {} +}; + +void testSubclassSmartPointer() { + char *mem = (char*)malloc(4); + { + Subclass Deleter(mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + + +class MultipleInheritance : public Subclass, public SmartPointer { +public: + MultipleInheritance(void *a, void *b) : Subclass(a), SmartPointer(b) {} +}; + +void testMultipleInheritance1() { + char *mem = (char*)malloc(4); + { + MultipleInheritance Deleter(mem, 0); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + +void testMultipleInheritance2() { + char *mem = (char*)malloc(4); + { + MultipleInheritance Deleter(0, mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + +void testMultipleInheritance3() { + char *mem = (char*)malloc(4); + { + MultipleInheritance Deleter(mem, mem); + // Remove dead bindings... + doSomething(); + // destructor called here + // expected-warning@27 {{Attempt to free released memory}} + } +} + + +class SmartPointerMember { + SmartPointer P; +public: + SmartPointerMember(void *x) : P(x) {} +}; + +void testSmartPointerMember() { + char *mem = (char*)malloc(4); + { + SmartPointerMember Deleter(mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + + +struct IntWrapper { + IntWrapper() : x(0) {} + ~IntWrapper(); + int *x; +}; + +void testArrayInvalidation() { + int i = 42; + int j = 42; + + { + IntWrapper arr[2]; + + // There should be no undefined value warnings here. + // Eventually these should be TRUE as well, but right now + // we can't handle array constructors. + clang_analyzer_eval(arr[0].x == 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(arr[1].x == 0); // expected-warning{{UNKNOWN}} + + arr[0].x = &i; + arr[1].x = &j; + clang_analyzer_eval(*arr[0].x == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(*arr[1].x == 42); // expected-warning{{TRUE}} + } + + // The destructors should have invalidated i and j. + clang_analyzer_eval(i == 42); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(j == 42); // expected-warning{{UNKNOWN}} +} + + + +// Don't crash on a default argument inside an initializer. +struct DefaultArg { + DefaultArg(int x = 0) {} + ~DefaultArg(); +}; + +struct InheritsDefaultArg : DefaultArg { + InheritsDefaultArg() {} + virtual ~InheritsDefaultArg(); +}; + +void testDefaultArg() { + InheritsDefaultArg a; + // Force a bug to be emitted. + *(char *)0 = 1; // expected-warning{{Dereference of null pointer}} +} diff --git a/test/Analysis/dynamic-cast.cpp b/test/Analysis/dynamic-cast.cpp index 8e63b2bcb363..b1133ac2bee5 100644 --- a/test/Analysis/dynamic-cast.cpp +++ b/test/Analysis/dynamic-cast.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=none -verify %s + +void clang_analyzer_eval(bool); class A { public: @@ -196,6 +198,9 @@ int testDynCastMostLikelyWillFail(C *c) { } else { res = 0; } + + // Note: IPA is turned off for this test because the code below shows how the + // dynamic_cast could succeed. return *res; // expected-warning{{Dereference of null pointer}} } @@ -205,7 +210,25 @@ void callTestDynCastMostLikelyWillFail() { testDynCastMostLikelyWillFail(&m); } + +void testDynCastToMiddleClass () { + class BBB : public BB {}; + BBB obj; + A &ref = obj; + + // These didn't always correctly layer base regions. + B *ptr = dynamic_cast(&ref); + clang_analyzer_eval(ptr != 0); // expected-warning{{TRUE}} + + // This is actually statically resolved to be a DerivedToBase cast. + ptr = dynamic_cast(&obj); + clang_analyzer_eval(ptr != 0); // expected-warning{{TRUE}} +} + + +// ----------------------------- // False positives/negatives. +// ----------------------------- // Due to symbolic regions not being typed. int testDynCastFalsePositive(BB *c) { diff --git a/test/Analysis/engine/replay-without-inlining.c b/test/Analysis/engine/replay-without-inlining.c new file mode 100644 index 000000000000..9ec2d08f3993 --- /dev/null +++ b/test/Analysis/engine/replay-without-inlining.c @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s + +typedef struct { + char I[4]; + int S; +} Hdr; +typedef struct { + short w; +} Hdr2; +typedef struct { + Hdr2 usedtobeundef; +} Info; +typedef struct { + const unsigned char *ib; + int cur; + int end; +} IB; +inline unsigned long gl(IB *input); +inline void gbs(IB *input, unsigned char *buf, int count); +void getB(IB *st, Hdr2 *usedtobeundef); +inline unsigned char gb(IB *input) { + if (input->cur + 1 > input->end) + ; + return input->ib[(input->cur)++]; +} +static void getID(IB *st, char str[4]) { + str[0] = gb(st); + str[1] = gb(st); + str[2] = gb(st); + str[3] = gb(st); +} +static void getH(IB *st, Hdr *header) { + getID (st, header->I); + header->S = gl(st); +} +static void readILBM(IB *st, Info *pic) { + // Initialize field; + pic->usedtobeundef.w = 5; + + // Time out in the function so that we will be forced to retry with no inlining. + Hdr header; + getH (st, &header); + getID(st, header.I); + int i = 0; + while (st->cur < st->end && i < 4) { + i++; + getH (st, &header); + } +} +int bitmapImageRepFromIFF(IB st, const unsigned char *ib, int il) { + Info pic; + st.ib = ib; + st.cur = 0; + st.end = il; + readILBM(&st,&pic); + return pic.usedtobeundef.w; // No undefined value warning here. +} diff --git a/test/Analysis/global-region-invalidation.c b/test/Analysis/global-region-invalidation.c index 184ffb870fb8..71a7285e1f1d 100644 --- a/test/Analysis/global-region-invalidation.c +++ b/test/Analysis/global-region-invalidation.c @@ -1,4 +1,6 @@ -// 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 +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,experimental.security.taint,debug.TaintTest,debug.ExprInspection -verify %s + +void clang_analyzer_eval(int); // 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" @@ -73,3 +75,12 @@ int constIntGlobExtern() { } return 0; } + +void testAnalyzerEvalIsPure() { + extern int someGlobal; + if (someGlobal == 0) { + clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}} + } +} + diff --git a/test/Analysis/html-diags.c b/test/Analysis/html-diags.c index 59d81a56a4e9..b9361f72c64c 100644 --- a/test/Analysis/html-diags.c +++ b/test/Analysis/html-diags.c @@ -1,5 +1,5 @@ // RUN: mkdir %t.dir -// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T.dir %s +// 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 diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp index 656a8bf8eed8..d43c8cfd9a0a 100644 --- a/test/Analysis/initializer.cpp +++ b/test/Analysis/initializer.cpp @@ -1,4 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -cfg-add-initializers -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -cfg-add-implicit-dtors -std=c++11 -verify %s + +// We don't inline constructors unless we have destructors turned on. + +void clang_analyzer_eval(bool); class A { int x; @@ -7,8 +11,68 @@ public: }; A::A() : x(0) { - if (x != 0) { - int *p = 0; - *p = 0; // no-warning - } + clang_analyzer_eval(x == 0); // expected-warning{{TRUE}} +} + + +class DirectMember { + int x; +public: + DirectMember(int value) : x(value) {} + + int getX() { return x; } +}; + +void testDirectMember() { + DirectMember obj(3); + clang_analyzer_eval(obj.getX() == 3); // expected-warning{{TRUE}} +} + + +class IndirectMember { + struct { + int x; + }; +public: + IndirectMember(int value) : x(value) {} + + int getX() { return x; } +}; + +void testIndirectMember() { + IndirectMember obj(3); + clang_analyzer_eval(obj.getX() == 3); // expected-warning{{TRUE}} +} + + +struct DelegatingConstructor { + int x; + DelegatingConstructor(int y) { x = y; } + DelegatingConstructor() : DelegatingConstructor(42) {} +}; + +void testDelegatingConstructor() { + DelegatingConstructor obj; + clang_analyzer_eval(obj.x == 42); // expected-warning{{TRUE}} +} + + +// ------------------------------------ +// False negatives +// ------------------------------------ + +struct RefWrapper { + RefWrapper(int *p) : x(*p) {} + RefWrapper(int &r) : x(r) {} + int &x; +}; + +void testReferenceMember() { + int *p = 0; + RefWrapper X(p); // should warn in the constructor +} + +void testReferenceMember2() { + int *p = 0; + RefWrapper X(*p); // should warn here } diff --git a/test/Analysis/initializers-cfg-output.cpp b/test/Analysis/initializers-cfg-output.cpp index 8a7a3f5d013d..8aaa94cd84c7 100644 --- a/test/Analysis/initializers-cfg-output.cpp +++ b/test/Analysis/initializers-cfg-output.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-initializers %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s // XPASS: * class A { diff --git a/test/Analysis/inline-plist.c b/test/Analysis/inline-plist.c index 549082dc9ca2..1523e82cc2ea 100644 --- a/test/Analysis/inline-plist.c +++ b/test/Analysis/inline-plist.c @@ -1,4 +1,4 @@ -// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -o %t +// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -fblocks -o %t // RUN: FileCheck -input-file %t %s // @@ -23,6 +23,45 @@ void test_has_bug() { has_bug(0); } +void triggers_bug(int *p) { + *p = 0xDEADBEEF; +} + +// This function triggers a bug by calling triggers_bug(). The diagnostics +// should show when p is assumed to be null. +void bar(int *p) { + if (!!p) + return; + + if (p == 0) + triggers_bug(p); +} + +// ========================================================================== // +// Test inlining of blocks. +// ========================================================================== // + +void test_block__capture_null() { + int *p = 0; + ^(){ *p = 1; }(); +} + +void test_block_ret() { + int *p = ^(){ int *q = 0; return q; }(); + *p = 1; +} + +void test_block_blockvar() { + __block int *p; + ^(){ p = 0; }(); + *p = 1; +} + +void test_block_arg() { + int *p; + ^(int **q){ *q = 0; }(&p); + *p = 1; +} // CHECK: // CHECK: @@ -49,7 +88,7 @@ void test_has_bug() { // CHECK: // CHECK: // CHECK: line11 -// CHECK: col10 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -62,7 +101,7 @@ void test_has_bug() { // CHECK: // CHECK: // CHECK: line12 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -83,7 +122,7 @@ void test_has_bug() { // CHECK: // CHECK: // CHECK: line12 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -159,7 +198,7 @@ void test_has_bug() { // CHECK: // CHECK: // CHECK: line14 -// CHECK: col5 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -180,7 +219,7 @@ void test_has_bug() { // CHECK: // CHECK: // CHECK: line14 -// CHECK: col5 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -235,6 +274,7 @@ void test_has_bug() { // CHECK: typeDivision by zero // CHECK: issue_context_kindfunction // CHECK: issue_contextfoo +// CHECK: issue_hash4 // CHECK: location // CHECK: // CHECK: line14 @@ -302,7 +342,7 @@ void test_has_bug() { // CHECK: // CHECK: // CHECK: line18 -// CHECK: col1 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -357,6 +397,7 @@ void test_has_bug() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexthas_bug +// CHECK: issue_hash1 // CHECK: location // CHECK: // CHECK: line19 @@ -364,6 +405,785 @@ void test_has_bug() { // CHECK: file0 // CHECK: // CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line33 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col9 +// 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: line33 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col16 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line37 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'triggers_bug' +// CHECK: message +// CHECK: Calling 'triggers_bug' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line26 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'bar' +// CHECK: message +// CHECK: Entered call from 'bar' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line26 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line27 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line27 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line27 +// 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_contexttriggers_bug +// CHECK: issue_hash1 +// CHECK: location +// CHECK: +// CHECK: line27 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line45 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling anonymous block +// CHECK: message +// CHECK: Calling anonymous block +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'test_block__capture_null' +// CHECK: message +// CHECK: Entered call from 'test_block__capture_null' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line46 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col9 +// 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: location +// CHECK: +// CHECK: line46 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col12 +// 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_block_ret +// CHECK: issue_hash2 +// 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: line55 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// 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: kindevent +// CHECK: location +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// 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_block_blockvar +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line61 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line61 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line62 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line62 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line62 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line62 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line63 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line63 +// 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_block_arg +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line63 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: // CHECK: // CHECK: // CHECK: diff --git a/test/Analysis/inline-unique-reports.c b/test/Analysis/inline-unique-reports.c index ae94267d2c25..9248ad2632f5 100644 --- a/test/Analysis/inline-unique-reports.c +++ b/test/Analysis/inline-unique-reports.c @@ -34,26 +34,26 @@ void test_bug_2() { // CHECK: start // CHECK: // CHECK: -// CHECK: line9 +// CHECK: line14 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line9 -// CHECK: col3 +// CHECK: line14 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line10 +// CHECK: line15 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line10 -// CHECK: col3 +// CHECK: line15 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: @@ -64,7 +64,7 @@ void test_bug_2() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line10 +// CHECK: line15 // CHECK: col3 // CHECK: file0 // CHECK: @@ -72,12 +72,12 @@ void test_bug_2() { // CHECK: // CHECK: // CHECK: -// CHECK: line10 +// CHECK: line15 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line10 +// CHECK: line15 // CHECK: col8 // CHECK: file0 // CHECK: @@ -99,9 +99,9 @@ void test_bug_2() { // CHECK: // CHECK: depth1 // CHECK: extended_message -// CHECK: Entered call from 'test_bug_1' +// CHECK: Entered call from 'test_bug_2' // CHECK: message -// CHECK: Entered call from 'test_bug_1' +// CHECK: Entered call from 'test_bug_2' // CHECK: // CHECK: // CHECK: kindcontrol @@ -117,7 +117,7 @@ void test_bug_2() { // CHECK: // CHECK: // CHECK: line4 -// CHECK: col1 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -172,6 +172,7 @@ void test_bug_2() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contextbug +// CHECK: issue_hash1 // CHECK: location // CHECK: // CHECK: line5 @@ -182,3 +183,4 @@ void test_bug_2() { // CHECK: // CHECK: // CHECK: + diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c index 0827d934614a..944e1e2985f1 100644 --- a/test/Analysis/inline.c +++ b/test/Analysis/inline.c @@ -1,8 +1,12 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -analyzer-store region -verify %s + +void clang_analyzer_eval(int); +void clang_analyzer_checkInlined(int); int test1_f1() { int y = 1; y++; + clang_analyzer_checkInlined(1); // expected-warning{{TRUE}} return y; } @@ -90,3 +94,19 @@ int test_rdar10977037() { } +// Test inlining a forward-declared function. +// This regressed when CallEvent was first introduced. +int plus1(int x); +void test() { + clang_analyzer_eval(plus1(2) == 3); // expected-warning{{TRUE}} +} + +int plus1(int x) { + return x + 1; +} + + +void never_called_by_anyone() { + clang_analyzer_checkInlined(0); // no-warning +} + diff --git a/test/Analysis/inline.cpp b/test/Analysis/inline.cpp new file mode 100644 index 000000000000..4eaed9fed13c --- /dev/null +++ b/test/Analysis/inline.cpp @@ -0,0 +1,168 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -verify %s + +void clang_analyzer_eval(bool); +void clang_analyzer_checkInlined(bool); + +class A { +public: + int getZero() { return 0; } + virtual int getNum() { return 0; } +}; + +void test(A &a) { + clang_analyzer_eval(a.getZero() == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(a.getNum() == 0); // expected-warning{{UNKNOWN}} + + A copy(a); + clang_analyzer_eval(copy.getZero() == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(copy.getNum() == 0); // expected-warning{{TRUE}} +} + + +class One : public A { +public: + virtual int getNum() { return 1; } +}; + +void testPathSensitivity(int x) { + A a; + One b; + + A *ptr; + switch (x) { + case 0: + ptr = &a; + break; + case 1: + ptr = &b; + break; + default: + return; + } + + // This should be true on both branches. + clang_analyzer_eval(ptr->getNum() == x); // expected-warning {{TRUE}} +} + + +namespace PureVirtualParent { + class Parent { + public: + virtual int pureVirtual() const = 0; + int callVirtual() const { + return pureVirtual(); + } + }; + + class Child : public Parent { + public: + virtual int pureVirtual() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return 42; + } + }; + + void testVirtual() { + Child x; + + clang_analyzer_eval(x.pureVirtual() == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(x.callVirtual() == 42); // expected-warning{{TRUE}} + } +} + + +namespace PR13569 { + class Parent { + protected: + int m_parent; + virtual int impl() const = 0; + + Parent() : m_parent(0) {} + + public: + int interface() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return impl(); + } + }; + + class Child : public Parent { + protected: + virtual int impl() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return m_parent + m_child; + } + + public: + Child() : m_child(0) {} + + int m_child; + }; + + void testVirtual() { + Child x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } + + + class Grandchild : public Child {}; + + void testDevirtualizeToMiddle() { + Grandchild x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } +} + +namespace PR13569_virtual { + class Parent { + protected: + int m_parent; + virtual int impl() const = 0; + + Parent() : m_parent(0) {} + + public: + int interface() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return impl(); + } + }; + + class Child : virtual public Parent { + protected: + virtual int impl() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return m_parent + m_child; + } + + public: + Child() : m_child(0) {} + + int m_child; + }; + + void testVirtual() { + Child x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } + + + class Grandchild : virtual public Child {}; + + void testDevirtualizeToMiddle() { + Grandchild x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } +} diff --git a/test/Analysis/inlining/DynDispatchBifurcate.m b/test/Analysis/inlining/DynDispatchBifurcate.m new file mode 100644 index 000000000000..e78b90bb8c1f --- /dev/null +++ b/test/Analysis/inlining/DynDispatchBifurcate.m @@ -0,0 +1,181 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic-bifurcate -verify %s + +#include "InlineObjCInstanceMethod.h" + +@interface MyParent : NSObject +- (int)getZero; +@end +@implementation MyParent +- (int)getZero { + return 0; +} +@end + +@interface PublicClass () { + int value2; +} +@property (readwrite) int value1; +- (void)setValue2:(int)newValue2; +@end + +@implementation PublicClass + +- (int)getZeroPublic { + return 0; +} + +@synthesize value1; + +- (int)value2 { + return value2; +} +- (void)setValue2:(int)newValue { + value2 = newValue; +} + +- (int)value3 { + return value3; +} +- (void)setValue3:(int)newValue { + value3 = newValue; +} + +@end + +@interface MyClassWithPublicParent : PublicClass +- (int)getZeroPublic; +@end +@implementation MyClassWithPublicParent +- (int)getZeroPublic { + return 0; +} +@end + +// Category overrides a public method. +@interface PublicSubClass (PrvateCat) + - (int) getZeroPublic; +@end +@implementation PublicSubClass (PrvateCat) +- (int)getZeroPublic { + return 0; +} +@end + + +@interface MyClass : MyParent { + int value; +} +- (int)getZero; +@property int value; +@end + +// Since class is private, we assume that it cannot be subclassed. +// False negative: this class is "privately subclassed". this is very rare +// in practice. +@implementation MyClass ++ (int) testTypeFromParam:(MyParent*) p { + int m = 0; + int z = [p getZero]; + if (z) + return 5/m; // false negative + return 5/[p getZero];// expected-warning {{Division by zero}} +} + +// Here only one definition is possible, since the declaration is not visible +// from outside. ++ (int) testTypeFromParamPrivateChild:(MyClass*) c { + int m = 0; + int z = [c getZero]; // MyClass overrides getZero to return '1'. + if (z) + return 5/m; // expected-warning {{Division by zero}} + return 5/[c getZero];//no warning +} + +- (int)getZero { + return 1; +} + +- (int)value { + return value; +} + +- (void)setValue:(int)newValue { + value = newValue; +} + +// Test ivar access. +- (int) testIvarInSelf { + value = 0; + return 5/value; // expected-warning {{Division by zero}} +} + ++ (int) testIvar: (MyClass*) p { + p.value = 0; + return 5/p.value; // expected-warning {{Division by zero}} +} + +// Test simple property access. ++ (int) testProperty: (MyClass*) p { + int x= 0; + [p setValue:0]; + return 5/[p value]; // expected-warning {{Division by zero}} +} + +@end + +// The class is prvate and is not subclassed. +int testCallToPublicAPIInParent(MyClassWithPublicParent *p) { + int m = 0; + int z = [p getZeroPublic]; + if (z) + return 5/m; // no warning + return 5/[p getZeroPublic];// expected-warning {{Division by zero}} +} + +// When the called method is public (due to it being defined outside of main file), +// split the path and analyze both branches. +// In this case, p can be either the object of type MyParent* or MyClass*: +// - If it's MyParent*, getZero returns 0. +// - If it's MyClass*, getZero returns 1 and 'return 5/m' is reachable. +// Declaration is provate, but p can be a subclass (MyClass*). +int testCallToPublicAPI(PublicClass *p) { + int m = 0; + int z = [p getZeroPublic]; + if (z) + return 5/m; // expected-warning {{Division by zero}} + return 5/[p getZeroPublic];// expected-warning {{Division by zero}} +} + +// Even though the method is privately declared in the category, the parent +// declares the method as public. Assume the instance can be subclassed. +int testCallToPublicAPICat(PublicSubClass *p) { + int m = 0; + int z = [p getZeroPublic]; + if (z) + return 5/m; // expected-warning {{Division by zero}} + return 5/[p getZeroPublic];// expected-warning {{Division by zero}} +} + +// Test public property - properties should always be inlined, regardless +// weither they are "public" or private. +int testPublicProperty(PublicClass *p) { + int x = 0; + [p setValue3:0]; + if ([p value3] != 0) + return 5/x; // expected-warning {{Division by zero}} // TODO: no warning, we should always inline the property. + return 5/[p value3];// expected-warning {{Division by zero}} +} + +int testExtension(PublicClass *p) { + int x = 0; + [p setValue2:0]; + if ([p value2] != 0) + return 5/x; // expected-warning {{Division by zero}} // TODO: no warning, we should always inline the property. + return 5/[p value2]; // expected-warning {{Division by zero}} +} + +// TODO: we do not handle synthesized properties yet. +int testPropertySynthesized(PublicClass *p) { + [p setValue1:0]; + return 5/[p value1]; +} diff --git a/test/Analysis/inlining/InlineObjCClassMethod.m b/test/Analysis/inlining/InlineObjCClassMethod.m new file mode 100644 index 000000000000..7e8b51fe0be0 --- /dev/null +++ b/test/Analysis/inlining/InlineObjCClassMethod.m @@ -0,0 +1,181 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic-bifurcate -verify %s + +// Test inlining of ObjC class methods. + +typedef signed char BOOL; +typedef struct objc_class *Class; +typedef struct objc_object { + Class isa; +} *id; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface NSObject {} ++(id)alloc; +-(id)init; +-(id)autorelease; +-(id)copy; +- (Class)class; +-(id)retain; +@end + +// Vanila: ObjC class method is called by name. +@interface MyParent : NSObject ++ (int)getInt; +@end +@interface MyClass : MyParent ++ (int)getInt; +@end +@implementation MyClass ++ (int)testClassMethodByName { + int y = [MyClass getInt]; + return 5/y; // expected-warning {{Division by zero}} +} ++ (int)getInt { + return 0; +} +@end + +// The definition is defined by the parent. Make sure we find it and inline. +@interface MyParentDIP : NSObject ++ (int)getInt; +@end +@interface MyClassDIP : MyParentDIP +@end +@implementation MyClassDIP ++ (int)testClassMethodByName { + int y = [MyClassDIP getInt]; + return 5/y; // expected-warning {{Division by zero}} +} +@end +@implementation MyParentDIP ++ (int)getInt { + return 0; +} +@end + +// ObjC class method is called by name. Definition is in the category. +@interface AAA : NSObject +@end +@interface AAA (MyCat) ++ (int)getInt; +@end +int foo() { + int y = [AAA getInt]; + return 5/y; // expected-warning {{Division by zero}} +} +@implementation AAA +@end +@implementation AAA (MyCat) ++ (int)getInt { + return 0; +} +@end + +// ObjC class method is called by name. Definition is in the parent category. +@interface PPP : NSObject +@end +@interface PPP (MyCat) ++ (int)getInt; +@end +@interface CCC : PPP +@end +int foo4() { + int y = [CCC getInt]; + return 5/y; // expected-warning {{Division by zero}} +} +@implementation PPP +@end +@implementation PPP (MyCat) ++ (int)getInt { + return 0; +} +@end + +// There is no declaration in the class but there is one in the parent. Make +// sure we pick the definition from the class and not the parent. +@interface MyParentTricky : NSObject ++ (int)getInt; +@end +@interface MyClassTricky : MyParentTricky +@end +@implementation MyParentTricky ++ (int)getInt { + return 0; +} +@end +@implementation MyClassTricky ++ (int)getInt { + return 1; +} ++ (int)testClassMethodByName { + int y = [MyClassTricky getInt]; + return 5/y; // no-warning +} +@end + +// ObjC class method is called by unknown class declaration (passed in as a +// parameter). We should not inline in such case. +@interface MyParentUnknown : NSObject ++ (int)getInt; +@end +@interface MyClassUnknown : MyParentUnknown ++ (int)getInt; +@end +@implementation MyClassUnknown ++ (int)testClassVariableByUnknownVarDecl: (Class)cl { + int y = [cl getInt]; + return 3/y; // no-warning +} ++ (int)getInt { + return 0; +} +@end + + +// False negative. +// ObjC class method call through a decl with a known type. +// We should be able to track the type of currentClass and inline this call. +// Note, [self class] could be a subclass. Do we still want to inline here? +@interface MyClassKT : NSObject +@end +@interface MyClassKT (MyCatKT) ++ (int)getInt; +@end +@implementation MyClassKT (MyCatKT) ++ (int)getInt { + return 0; +} +@end +@implementation MyClassKT +- (int)testClassMethodByKnownVarDecl { + Class currentClass = [self class]; + int y = [currentClass getInt]; + return 5/y; // Would be great to get a warning here. +} +@end + +// Another false negative due to us not reasoning about self, which in this +// case points to the object of the class in the call site and should be equal +// to [MyParent class]. +@interface MyParentSelf : NSObject ++ (int)testSelf; +@end +@implementation MyParentSelf ++ (int)testSelf { + if (self == [MyParentSelf class]) + return 0; + else + return 1; +} +@end +@interface MyClassSelf : MyParentSelf +@end +@implementation MyClassSelf ++ (int)testClassMethodByKnownVarDecl { + int y = [MyParentSelf testSelf]; + return 5/y; // Should warn here. +} +@end +int foo2() { + int y = [MyParentSelf testSelf]; + return 5/y; // Should warn here. +} diff --git a/test/Analysis/inlining/InlineObjCInstanceMethod.h b/test/Analysis/inlining/InlineObjCInstanceMethod.h new file mode 100644 index 000000000000..bb0da280c8ef --- /dev/null +++ b/test/Analysis/inlining/InlineObjCInstanceMethod.h @@ -0,0 +1,46 @@ + +// Define a public header for the ObjC methods that are "visible" externally +// and, thus, could be sub-classed. We should explore the path on which these +// are sub-classed with unknown class by not inlining them. + +typedef signed char BOOL; +typedef struct objc_class *Class; +typedef struct objc_object { + Class isa; +} *id; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface NSObject {} ++(id)alloc; ++(id)new; +-(id)init; +-(id)autorelease; +-(id)copy; +- (Class)class; +-(id)retain; +@end + +@interface PublicClass : NSObject { + int value3; +} +- (int)getZeroPublic; + +- (int) value2; + +@property (readonly) int value1; + +@property int value3; +- (int)value3; +- (void)setValue3:(int)newValue; +@end + +@interface PublicSubClass : PublicClass +@end + +@interface PublicParent : NSObject +- (int)getZeroOverridden; +@end + +@interface PublicSubClass2 : PublicParent +- (int) getZeroOverridden; +@end + diff --git a/test/Analysis/inlining/InlineObjCInstanceMethod.m b/test/Analysis/inlining/InlineObjCInstanceMethod.m new file mode 100644 index 000000000000..31b6d5baa6f8 --- /dev/null +++ b/test/Analysis/inlining/InlineObjCInstanceMethod.m @@ -0,0 +1,86 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic-bifurcate -verify %s + +#include "InlineObjCInstanceMethod.h" + +// Method is defined in the parent; called through self. +@interface MyParent : NSObject +- (int)getInt; +@end +@implementation MyParent +- (int)getInt { + return 0; +} +@end + +@interface MyClass : MyParent +@end +@implementation MyClass +- (int)testDynDispatchSelf { + int y = [self getInt]; + return 5/y; // expected-warning {{Division by zero}} +} + +// Get the dynamic type info from a cast (from id to MyClass*). ++ (int)testAllocInit { + MyClass *a = [[self alloc] init]; + return 5/[a getInt]; // expected-warning {{Division by zero}} +} + +// Method is called on inited object. ++ (int)testAllocInit2 { + MyClass *a = [[MyClass alloc] init]; + return 5/[a getInt]; // expected-warning {{Division by zero}} +} + +// Method is called on a parameter. ++ (int)testParam: (MyClass*) a { + return 5/[a getInt]; // expected-warning {{Division by zero}} +} + +// Method is called on a parameter of unnown type. ++ (int)testParamUnknownType: (id) a { + return 5/[a getInt]; // no warning +} + +@end + +// TODO: When method is inlined, the attribute reset should be visible. +@interface TestSettingAnAttributeInCallee : NSObject { + int _attribute; +} + - (void) method2; +@end + +@implementation TestSettingAnAttributeInCallee +- (int) method1 { + [self method2]; + return 5/_attribute; // expected-warning {{Division by zero}} +} + +- (void) method2 { + _attribute = 0; +} +@end + +@interface TestSettingAnAttributeInCaller : NSObject { + int _attribute; +} + - (int) method2; +@end + +@implementation TestSettingAnAttributeInCaller +- (void) method1 { + _attribute = 0; + [self method2]; +} + +- (int) method2 { + return 5/_attribute; // expected-warning {{Division by zero}} +} +@end + + +// Don't crash if we don't know the receiver's region. +void randomlyMessageAnObject(MyClass *arr[], int i) { + (void)[arr[i] getInt]; +} \ No newline at end of file diff --git a/test/Analysis/inlining/ObjCDynTypePopagation.m b/test/Analysis/inlining/ObjCDynTypePopagation.m new file mode 100644 index 000000000000..4faaa2cb3033 --- /dev/null +++ b/test/Analysis/inlining/ObjCDynTypePopagation.m @@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=dynamic-bifurcate -verify %s + +#include "InlineObjCInstanceMethod.h" + +void clang_analyzer_eval(int); + +PublicSubClass2 *getObj(); + +@implementation PublicParent +- (int) getZeroOverridden { + return 1; +} +- (int) getZero { + return 0; +} +@end + +@implementation PublicSubClass2 +- (int) getZeroOverridden { + return 0; +} + +/* Test that we get the right type from call to alloc. */ ++ (void) testAllocSelf { + id a = [self alloc]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + + ++ (void) testAllocClass { + id a = [PublicSubClass2 alloc]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + ++ (void) testAllocSuperOverriden { + id a = [super alloc]; + // Evaluates to 1 in the parent. + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{FALSE}} +} + ++ (void) testAllocSuper { + id a = [super alloc]; + clang_analyzer_eval([a getZero] == 0); // expected-warning{{TRUE}} +} + ++ (void) testAllocInit { + id a = [[self alloc] init]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + ++ (void) testNewSelf { + id a = [self new]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + +// Casting to parent should not pessimize the dynamic type. ++ (void) testCastToParent { + id a = [[self alloc] init]; + PublicParent *p = a; + clang_analyzer_eval([p getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + +// The type of parameter gets used. ++ (void)testTypeFromParam:(PublicParent*) p { + clang_analyzer_eval([p getZero] == 0); // expected-warning{{TRUE}} +} + +// Test implicit cast. +// Note, in this case, p could also be a subclass of MyParent. ++ (void) testCastFromId:(id) a { + PublicParent *p = a; + clang_analyzer_eval([p getZero] == 0); // expected-warning{{TRUE}} +} +@end + +// TODO: Would be nice to handle the case of dynamically obtained class info +// as well. We need a MemRegion for class types for this. +int testDynamicClass(BOOL coin) { + Class AllocClass = (coin ? [NSObject class] : [PublicSubClass2 class]); + id x = [[AllocClass alloc] init]; + if (coin) + return [x getZero]; + return 1; +} diff --git a/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m b/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m new file mode 100644 index 000000000000..739e10f2a5f9 --- /dev/null +++ b/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=dynamic-bifurcate -verify %s + +typedef signed char BOOL; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface NSObject {} ++(id)alloc; +-(id)init; ++(id)new; +-(id)autorelease; +-(id)copy; +- (Class)class; +-(id)retain; +@end +void clang_analyzer_eval(BOOL); + +@interface SomeOtherClass : NSObject +- (int)getZero; +@end +@implementation SomeOtherClass +- (int)getZero { return 0; } +@end + +@interface MyClass : NSObject +- (int)getZero; +@end + +@implementation MyClass +- (int)getZero { return 1; } + +// TODO: Not only we should correctly determine that the type of o at runtime +// is MyClass, but we should also warn about it. ++ (void) testCastToParent { + id a = [[self alloc] init]; + SomeOtherClass *o = a; + clang_analyzer_eval([o getZero] == 0); // expected-warning{{FALSE}} +} +@end diff --git a/test/Analysis/inlining/RetainCountExamples.m b/test/Analysis/inlining/RetainCountExamples.m new file mode 100644 index 000000000000..2b682c2b4bf0 --- /dev/null +++ b/test/Analysis/inlining/RetainCountExamples.m @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-ipa=dynamic-bifurcate -verify %s + +typedef signed char BOOL; +typedef struct objc_class *Class; +typedef struct objc_object { + Class isa; +} *id; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface NSObject {} ++(id)alloc; ++(id)new; +- (oneway void)release; +-(id)init; +-(id)autorelease; +-(id)copy; +- (Class)class; +-(id)retain; +@end + +@interface SelfStaysLive : NSObject +- (id)init; +@end + +@implementation SelfStaysLive +- (id)init { + return [super init]; +} +@end + +void selfStaysLive() { + SelfStaysLive *foo = [[SelfStaysLive alloc] init]; + [foo release]; +} \ No newline at end of file diff --git a/test/Analysis/inlining/path-notes.c b/test/Analysis/inlining/path-notes.c new file mode 100644 index 000000000000..0885eafa5b93 --- /dev/null +++ b/test/Analysis/inlining/path-notes.c @@ -0,0 +1,1291 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-output=text -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-output=plist-multi-file %s -o - | FileCheck %s + +void zero(int **p) { + *p = 0; + // expected-note@-1 {{Null pointer value stored to 'a'}} +} + +void testZero(int *a) { + zero(&a); + // expected-note@-1 {{Calling 'zero'}} + // expected-note@-2 {{Returning from 'zero'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + + +void check(int *p) { + if (p) { + // expected-note@-1 + {{Assuming 'p' is null}} + // expected-note@-2 + {{Assuming pointer value is null}} + // expected-note@-3 + {{Taking false branch}} + return; + } + return; +} + +void testCheck(int *a) { + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + + +int *getPointer(); + +void testInitCheck() { + int *a = getPointer(); + // expected-note@-1 {{Variable 'a' initialized here}} + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + +void testStoreCheck(int *a) { + a = getPointer(); + // expected-note@-1 {{Value assigned to 'a'}} + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + + +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: {{.*}}path-notes.c +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// 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: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'zero' +// CHECK: message +// CHECK: Calling 'zero' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line4 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'testZero' +// CHECK: message +// CHECK: Entered call from 'testZero' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col4 +// 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: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Null pointer value stored to 'a' +// CHECK: message +// CHECK: Null pointer value stored to 'a' +// 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: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Returning from 'zero' +// CHECK: message +// CHECK: Returning from 'zero' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line13 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line13 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'a') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'a') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'a') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestZero +// CHECK: issue_hash4 +// CHECK: location +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'check' +// CHECK: message +// CHECK: Calling 'check' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'testCheck' +// CHECK: message +// CHECK: Entered call from 'testCheck' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Assuming 'p' is null +// CHECK: message +// CHECK: Assuming 'p' is null +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Assuming pointer value is null +// CHECK: message +// CHECK: Assuming pointer value is null +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line25 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line25 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Returning from 'check' +// CHECK: message +// CHECK: Returning from 'check' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line32 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line32 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line32 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line32 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line32 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'a') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'a') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'a') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestCheck +// CHECK: issue_hash4 +// CHECK: location +// CHECK: +// CHECK: line32 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line40 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line40 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line40 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'a' initialized here +// CHECK: message +// CHECK: Variable 'a' initialized here +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line40 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line40 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line42 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'check' +// CHECK: message +// CHECK: Calling 'check' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'testInitCheck' +// CHECK: message +// CHECK: Entered call from 'testInitCheck' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// 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: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line25 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line25 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line42 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Returning from 'check' +// CHECK: message +// CHECK: Returning from 'check' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line45 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'a') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'a') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'a') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestInitCheck +// CHECK: issue_hash6 +// CHECK: location +// CHECK: +// CHECK: line45 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Value assigned to 'a' +// CHECK: message +// CHECK: Value assigned to 'a' +// 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: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'check' +// CHECK: message +// CHECK: Calling 'check' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'testStoreCheck' +// CHECK: message +// CHECK: Entered call from 'testStoreCheck' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// 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: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line19 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line25 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line25 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Returning from 'check' +// CHECK: message +// CHECK: Returning from 'check' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col7 +// 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: kindevent +// CHECK: location +// CHECK: +// CHECK: line55 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'a') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'a') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'a') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestStoreCheck +// CHECK: issue_hash6 +// CHECK: location +// CHECK: +// CHECK: line55 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: diff --git a/test/Analysis/iterators.cpp b/test/Analysis/iterators.cpp deleted file mode 100644 index 1b6340b2af28..000000000000 --- a/test/Analysis/iterators.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// 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/test/Analysis/ivars.m b/test/Analysis/ivars.m new file mode 100644 index 000000000000..42e92d259a9f --- /dev/null +++ b/test/Analysis/ivars.m @@ -0,0 +1,132 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s + +void clang_analyzer_eval(int); + +@interface Root { +@public + int uniqueID; +} + +- (void)refreshID; +@end + +void testInvalidation(Root *obj) { + int savedID = obj->uniqueID; + clang_analyzer_eval(savedID == obj->uniqueID); // expected-warning{{TRUE}} + + [obj refreshID]; + clang_analyzer_eval(savedID == obj->uniqueID); // expected-warning{{UNKNOWN}} +} + + +@interface Child : Root +@end + +@implementation Child +- (void)testSuperInvalidation { + int savedID = self->uniqueID; + clang_analyzer_eval(savedID == self->uniqueID); // expected-warning{{TRUE}} + + [super refreshID]; + clang_analyzer_eval(savedID == self->uniqueID); // expected-warning{{UNKNOWN}} +} +@end + + +@interface ManyIvars { + struct S { int a, b; } s; + int c; + int d; +} +@end + +struct S makeS(); + +@implementation ManyIvars + +- (void)testMultipleIvarInvalidation:(int)useConstraints { + if (useConstraints) { + if (s.a != 1) return; + if (s.b != 2) return; + if (c != 3) return; + if (d != 4) return; + return; + } else { + s.a = 1; + s.b = 2; + c = 3; + d = 4; + } + + clang_analyzer_eval(s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(s.b == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(d == 4); // expected-warning{{TRUE}} + + d = 0; + + clang_analyzer_eval(s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(s.b == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(d == 0); // expected-warning{{TRUE}} + + d = 4; + s = makeS(); + + clang_analyzer_eval(s.a == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(s.b == 2); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(d == 4); // expected-warning{{TRUE}} + + s.a = 1; + + clang_analyzer_eval(s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(s.b == 2); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(d == 4); // expected-warning{{TRUE}} +} + ++ (void)testMultipleIvarInvalidation:(int)useConstraints + forObject:(ManyIvars *)obj { + if (useConstraints) { + if (obj->s.a != 1) return; + if (obj->s.b != 2) return; + if (obj->c != 3) return; + if (obj->d != 4) return; + return; + } else { + obj->s.a = 1; + obj->s.b = 2; + obj->c = 3; + obj->d = 4; + } + + clang_analyzer_eval(obj->s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->s.b == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->d == 4); // expected-warning{{TRUE}} + + obj->d = 0; + + clang_analyzer_eval(obj->s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->s.b == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->d == 0); // expected-warning{{TRUE}} + + obj->d = 4; + obj->s = makeS(); + + clang_analyzer_eval(obj->s.a == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(obj->s.b == 2); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(obj->c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->d == 4); // expected-warning{{TRUE}} + + obj->s.a = 1; + + clang_analyzer_eval(obj->s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->s.b == 2); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(obj->c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->d == 4); // expected-warning{{TRUE}} +} + +@end diff --git a/test/Analysis/malloc-annotations.c b/test/Analysis/malloc-annotations.c index a0c145279d92..1dc0f7837bad 100644 --- a/test/Analysis/malloc-annotations.c +++ b/test/Analysis/malloc-annotations.c @@ -70,10 +70,9 @@ 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 + mystuff.somefield = my_malloc(12); // expected-warning{{Memory is never released; potential leak}} } // Test that we can pass out allocated memory via pointer-to-pointer. @@ -123,12 +122,11 @@ void af2e() { 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. +// This case inflicts a possible double-free. void af3() { int *p = my_malloc(12); my_hold(p); - free(p); // no-warning + free(p); // expected-warning{{Attempt to free non-owned memory}} } int * af4() { diff --git a/test/Analysis/malloc-plist.c b/test/Analysis/malloc-plist.c index db2e0f01e73b..11eef3e14006 100644 --- a/test/Analysis/malloc-plist.c +++ b/test/Analysis/malloc-plist.c @@ -97,6 +97,77 @@ void LeakedSymbol(int in) { in++; } +// Tests that exercise running remove dead bindings at Call exit. +static void function_with_leak1() { + char *x = (char*)malloc(12); +} +void use_function_with_leak1() { + function_with_leak1(); + int y = 0; +} + +static void function_with_leak2() { + char *x = (char*)malloc(12); + int m = 0; +} +void use_function_with_leak2() { + function_with_leak2(); +} + +static void function_with_leak3(int y) { + char *x = (char*)malloc(12); + if (y) + y++; +} +void use_function_with_leak3(int y) { + function_with_leak3(y); +} + +static void function_with_leak4(int y) { + char *x = (char*)malloc(12); + if (y) + y++; + else + y--; +} +void use_function_with_leak4(int y) { + function_with_leak4(y); +} + +int anotherFunction5() { + return 5; +} +static int function_with_leak5() { + char *x = (char*)malloc(12); + return anotherFunction5(); +} +void use_function_with_leak5() { + function_with_leak5(); +} + +void anotherFunction6(int m) { + m++; +} +static void function_with_leak6() { + char *x = (char*)malloc(12); + anotherFunction6(3); +} +void use_function_with_leak6() { + function_with_leak6(); +} + +static void empty_function(){ +} +void use_empty_function() { + empty_function(); +} +static char *function_with_leak7() { + return (char*)malloc(12); +} +void use_function_with_leak7() { + function_with_leak7(); +} + // CHECK: // CHECK: // CHECK: @@ -122,7 +193,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line10 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -135,7 +206,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line10 -// CHECK: col9 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -156,7 +227,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line10 -// CHECK: col9 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -169,7 +240,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line11 -// CHECK: col9 +// CHECK: col11 // CHECK: file0 // CHECK: // CHECK: @@ -190,7 +261,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line11 -// CHECK: col9 +// CHECK: col11 // CHECK: file0 // CHECK: // CHECK: @@ -203,7 +274,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line11 -// CHECK: col27 +// CHECK: col23 // CHECK: file0 // CHECK: // CHECK: @@ -253,7 +324,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line11 -// CHECK: col27 +// CHECK: col23 // CHECK: file0 // CHECK: // CHECK: @@ -281,21 +352,6 @@ void LeakedSymbol(int in) { // 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' @@ -308,6 +364,7 @@ void LeakedSymbol(int in) { // CHECK: typeMemory leak // CHECK: issue_context_kindfunction // CHECK: issue_contextdiagnosticTest +// CHECK: issue_hash5 // CHECK: location // CHECK: // CHECK: line14 @@ -332,7 +389,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line18 -// CHECK: col5 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -379,7 +436,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line19 -// CHECK: col30 +// CHECK: col14 // CHECK: file0 // CHECK: // CHECK: @@ -429,7 +486,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line19 -// CHECK: col30 +// CHECK: col14 // CHECK: file0 // CHECK: // CHECK: @@ -469,6 +526,7 @@ void LeakedSymbol(int in) { // CHECK: typeMemory leak // CHECK: issue_context_kindfunction // CHECK: issue_contextmyArrayAllocation +// CHECK: issue_hash4 // CHECK: location // CHECK: // CHECK: line21 @@ -493,7 +551,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line24 -// CHECK: col5 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -506,7 +564,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line24 -// CHECK: col28 +// CHECK: col23 // CHECK: file0 // CHECK: // CHECK: @@ -556,7 +614,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line24 -// CHECK: col28 +// CHECK: col23 // CHECK: file0 // CHECK: // CHECK: @@ -569,7 +627,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line26 -// CHECK: col5 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -590,7 +648,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line26 -// CHECK: col5 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -603,7 +661,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line26 -// CHECK: col40 +// CHECK: col24 // CHECK: file0 // CHECK: // CHECK: @@ -653,7 +711,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line26 -// CHECK: col40 +// CHECK: col24 // CHECK: file0 // CHECK: // CHECK: @@ -666,7 +724,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line27 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -687,7 +745,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line27 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -700,7 +758,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line27 -// CHECK: col12 +// CHECK: col9 // CHECK: file0 // CHECK: // CHECK: @@ -750,7 +808,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line27 -// CHECK: col12 +// CHECK: col9 // CHECK: file0 // CHECK: // CHECK: @@ -841,21 +899,6 @@ void LeakedSymbol(int in) { // 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' @@ -868,6 +911,7 @@ void LeakedSymbol(int in) { // CHECK: typeMemory leak // CHECK: issue_context_kindfunction // CHECK: issue_contextreallocDiagnostics +// CHECK: issue_hash5 // CHECK: location // CHECK: // CHECK: line28 @@ -892,7 +936,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line43 -// CHECK: col3 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -905,7 +949,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line43 -// CHECK: col15 +// CHECK: col21 // CHECK: file0 // CHECK: // CHECK: @@ -969,7 +1013,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line34 -// CHECK: col1 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -982,7 +1026,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line35 -// CHECK: col3 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -1003,7 +1047,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line35 -// CHECK: col3 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -1016,7 +1060,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line35 -// CHECK: col23 +// CHECK: col18 // CHECK: file0 // CHECK: // CHECK: @@ -1066,7 +1110,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line35 -// CHECK: col23 +// CHECK: col18 // CHECK: file0 // CHECK: // CHECK: @@ -1079,7 +1123,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line37 -// CHECK: col3 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -1100,7 +1144,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line37 -// CHECK: col3 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -1176,7 +1220,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line38 -// CHECK: col5 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -1226,7 +1270,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line43 -// CHECK: col23 +// CHECK: col21 // CHECK: file0 // CHECK: // CHECK: @@ -1266,6 +1310,7 @@ void LeakedSymbol(int in) { // CHECK: typeMemory leak // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_wrapper +// CHECK: issue_hash3 // CHECK: location // CHECK: // CHECK: line45 @@ -1290,7 +1335,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line59 -// CHECK: col5 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -1303,7 +1348,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line60 -// CHECK: col5 +// CHECK: col22 // CHECK: file0 // CHECK: // CHECK: @@ -1367,7 +1412,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line52 -// CHECK: col1 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -1414,7 +1459,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line53 -// CHECK: col20 +// CHECK: col15 // CHECK: file0 // CHECK: // CHECK: @@ -1464,7 +1509,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line53 -// CHECK: col20 +// CHECK: col15 // CHECK: file0 // CHECK: // CHECK: @@ -1477,7 +1522,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line54 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -1498,7 +1543,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line54 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -1511,7 +1556,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line55 -// CHECK: col7 +// CHECK: col13 // CHECK: file0 // CHECK: // CHECK: @@ -1575,7 +1620,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line49 -// CHECK: col1 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -1588,7 +1633,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line50 -// CHECK: col11 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -1667,7 +1712,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line55 -// CHECK: col17 +// CHECK: col13 // CHECK: file0 // CHECK: // CHECK: @@ -1680,7 +1725,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line56 -// CHECK: col5 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -1730,7 +1775,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line60 -// CHECK: col28 +// CHECK: col22 // CHECK: file0 // CHECK: // CHECK: @@ -1743,7 +1788,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line61 -// CHECK: col14 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -1785,6 +1830,7 @@ void LeakedSymbol(int in) { // CHECK: typeUse-after-free // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_double_action_call +// CHECK: issue_hash3 // CHECK: location // CHECK: // CHECK: line61 @@ -1809,7 +1855,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line74 -// CHECK: col5 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -1822,7 +1868,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line74 -// CHECK: col35 +// CHECK: col30 // CHECK: file0 // CHECK: // CHECK: @@ -1872,7 +1918,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line74 -// CHECK: col35 +// CHECK: col30 // CHECK: file0 // CHECK: // CHECK: @@ -1885,7 +1931,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line75 -// CHECK: col11 +// CHECK: col20 // CHECK: file0 // CHECK: // CHECK: @@ -1949,7 +1995,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line65 -// CHECK: col1 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -1962,7 +2008,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line66 -// CHECK: col5 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -1983,7 +2029,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line66 -// CHECK: col5 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -1996,7 +2042,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line67 -// CHECK: col5 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -2017,7 +2063,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line67 -// CHECK: col5 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -2030,7 +2076,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line67 -// CHECK: col40 +// CHECK: col24 // CHECK: file0 // CHECK: // CHECK: @@ -2080,7 +2126,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line67 -// CHECK: col40 +// CHECK: col24 // CHECK: file0 // CHECK: // CHECK: @@ -2093,7 +2139,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line68 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -2114,7 +2160,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line68 -// CHECK: col5 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -2127,7 +2173,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line68 -// CHECK: col12 +// CHECK: col9 // CHECK: file0 // CHECK: // CHECK: @@ -2177,7 +2223,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line68 -// CHECK: col12 +// CHECK: col9 // CHECK: file0 // CHECK: // CHECK: @@ -2253,7 +2299,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line69 -// CHECK: col9 +// CHECK: col14 // CHECK: file0 // CHECK: // CHECK: @@ -2303,7 +2349,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line75 -// CHECK: col25 +// CHECK: col20 // CHECK: file0 // CHECK: // CHECK: @@ -2316,7 +2362,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line76 -// CHECK: col13 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -2331,21 +2377,6 @@ void LeakedSymbol(int in) { // 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' @@ -2358,6 +2389,7 @@ void LeakedSymbol(int in) { // CHECK: typeMemory leak // CHECK: issue_context_kindfunction // CHECK: issue_contextreallocIntra +// CHECK: issue_hash3 // CHECK: location // CHECK: // CHECK: line76 @@ -2382,7 +2414,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line84 -// CHECK: col5 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -2395,7 +2427,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line85 -// CHECK: col9 +// CHECK: col26 // CHECK: file0 // CHECK: // CHECK: @@ -2459,7 +2491,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line80 -// CHECK: col1 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -2472,7 +2504,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line81 -// CHECK: col5 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -2493,7 +2525,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line81 -// CHECK: col5 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -2506,7 +2538,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line81 -// CHECK: col28 +// CHECK: col24 // CHECK: file0 // CHECK: // CHECK: @@ -2585,7 +2617,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line85 -// CHECK: col28 +// CHECK: col26 // CHECK: file0 // CHECK: // CHECK: @@ -2625,6 +2657,7 @@ void LeakedSymbol(int in) { // CHECK: typeMemory leak // CHECK: issue_context_kindfunction // CHECK: issue_contextuse_ret +// CHECK: issue_hash3 // CHECK: location // CHECK: // CHECK: line86 @@ -2649,7 +2682,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line90 -// CHECK: col5 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -2696,7 +2729,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line92 -// CHECK: col24 +// CHECK: col20 // CHECK: file0 // CHECK: // CHECK: @@ -2746,7 +2779,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line92 -// CHECK: col24 +// CHECK: col20 // CHECK: file0 // CHECK: // CHECK: @@ -2759,7 +2792,7 @@ void LeakedSymbol(int in) { // CHECK: // CHECK: // CHECK: line97 -// CHECK: col8 +// CHECK: col6 // CHECK: file0 // CHECK: // CHECK: @@ -2774,21 +2807,6 @@ void LeakedSymbol(int in) { // 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' @@ -2801,6 +2819,7 @@ void LeakedSymbol(int in) { // CHECK: typeMemory leak // CHECK: issue_context_kindfunction // CHECK: issue_contextLeakedSymbol +// CHECK: issue_hash8 // CHECK: location // CHECK: // CHECK: line97 @@ -2808,7 +2827,1606 @@ void LeakedSymbol(int in) { // CHECK: file0 // CHECK: // CHECK: -// CHECK: -// CHECK: -// CHECK: - +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line105 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line105 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line105 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'function_with_leak1' +// CHECK: message +// CHECK: Calling 'function_with_leak1' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line101 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'use_function_with_leak1' +// CHECK: message +// CHECK: Entered call from 'use_function_with_leak1' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line102 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col31 +// 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: line102 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line102 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'x' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextfunction_with_leak1 +// CHECK: issue_hash1 +// CHECK: location +// CHECK: +// CHECK: line102 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line114 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line114 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line114 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'function_with_leak2' +// CHECK: message +// CHECK: Calling 'function_with_leak2' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line109 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'use_function_with_leak2' +// CHECK: message +// CHECK: Entered call from 'use_function_with_leak2' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line109 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line109 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line110 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col31 +// 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: line110 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line110 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line111 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line111 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line111 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'x' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextfunction_with_leak2 +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line111 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line123 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col26 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'function_with_leak3' +// CHECK: message +// CHECK: Calling 'function_with_leak3' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line117 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'use_function_with_leak3' +// CHECK: message +// CHECK: Entered call from 'use_function_with_leak3' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line117 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line117 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line118 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col31 +// 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: line118 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line120 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line120 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line120 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'x' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextfunction_with_leak3 +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line120 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line134 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col26 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'function_with_leak4' +// CHECK: message +// CHECK: Calling 'function_with_leak4' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line126 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'use_function_with_leak4' +// CHECK: message +// CHECK: Entered call from 'use_function_with_leak4' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line126 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line126 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line127 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col31 +// 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: line127 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line127 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line131 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line131 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line131 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'x' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextfunction_with_leak4 +// CHECK: issue_hash5 +// CHECK: location +// CHECK: +// CHECK: line131 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line145 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line145 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line145 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'function_with_leak5' +// CHECK: message +// CHECK: Calling 'function_with_leak5' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line140 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'use_function_with_leak5' +// CHECK: message +// CHECK: Entered call from 'use_function_with_leak5' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line141 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col31 +// 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: line141 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line141 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line142 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line142 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line142 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'x' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextfunction_with_leak5 +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line142 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line156 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line156 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line156 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'function_with_leak6' +// CHECK: message +// CHECK: Calling 'function_with_leak6' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line151 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'use_function_with_leak6' +// CHECK: message +// CHECK: Entered call from 'use_function_with_leak6' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line151 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line151 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line152 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col31 +// 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: line152 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line152 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line153 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line153 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line153 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: message +// CHECK: Memory is never released; potential leak of memory pointed to by 'x' +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak of memory pointed to by 'x' +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextfunction_with_leak6 +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line153 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line168 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col25 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Calling 'function_with_leak7' +// CHECK: message +// CHECK: Calling 'function_with_leak7' +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line164 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth1 +// CHECK: extended_message +// CHECK: Entered call from 'use_function_with_leak7' +// CHECK: message +// CHECK: Entered call from 'use_function_with_leak7' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line164 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line164 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line165 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line165 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line165 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line165 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line165 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line165 +// CHECK: col24 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line165 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line165 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line165 +// 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: line168 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col25 +// 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: line168 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line169 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line169 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line169 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Memory is never released; potential leak +// CHECK: message +// CHECK: Memory is never released; potential leak +// CHECK: +// CHECK: +// CHECK: descriptionMemory is never released; potential leak +// CHECK: categoryMemory Error +// CHECK: typeMemory leak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextuse_function_with_leak7 +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line169 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: diff --git a/test/Analysis/malloc-sizeof.c b/test/Analysis/malloc-sizeof.c index d2b3bcf3c84d..6eb466ac6a11 100644 --- a/test/Analysis/malloc-sizeof.c +++ b/test/Analysis/malloc-sizeof.c @@ -1,27 +1,36 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.MallocSizeof -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=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); +void free(void *ptr); struct A {}; struct B {}; -void foo() { +void foo(unsigned int unsignedInt, unsigned int readSize) { 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'}} + long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'short'}} + long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'double'}} + char *cp3 = malloc(5 * sizeof(char) + 2); // no warning + unsigned char *buf = malloc(readSize + sizeof(unsignedInt)); // no warning 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 *ap3 = calloc(2, sizeof(ap1)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct A *'}} + struct A *ap4 = calloc(3, sizeof(struct A*)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct A *'}} + struct A *ap5 = calloc(4, sizeof(struct B)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which 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'}} + struct A *ap7 = realloc(ap5, sizeof(struct B)); // expected-warning {{Result of 'realloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct B'}} +} + +// Don't warn when the types differ only by constness. +void ignore_const() { + const char **x = (const char **)malloc(1 * sizeof(char *)); // no-warning + const char ***y = (const char ***)malloc(1 * sizeof(char *)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'const char **', which is incompatible with sizeof operand type 'char *'}} + free(x); } diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index 3b4712320b72..f60271f39f4c 100644 --- a/test/Analysis/malloc.c +++ b/test/Analysis/malloc.c @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s #include "system-header-simulator.h" +void clang_analyzer_eval(int); + typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); void *valloc(size_t); @@ -8,6 +10,8 @@ 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); +char *strdup(const char *s); +char *strndup(const char *s, size_t n); void myfoo(int *p); void myfooint(int p); @@ -15,7 +19,7 @@ char *fooRetPtr(); void f1() { int *p = malloc(12); - return; // expected-warning{{Memory is never released; potential leak}} + return; // expected-warning{{Memory is never released; potential leak of memory pointed to by 'p'}} } void f2() { @@ -40,7 +44,7 @@ void reallocNotNullPtr(unsigned sizeIn) { char *p = (char*)malloc(size); if (p) { char *q = (char*)realloc(p, sizeIn); - char x = *q; // expected-warning {{Memory is never released; potential leak}} + char x = *q; // expected-warning {{Memory is never released; potential leak of memory pointed to by 'q'}} } } @@ -65,7 +69,7 @@ void reallocSizeZero1() { char *p = malloc(12); char *r = realloc(p, 0); if (!r) { - free(p); + free(p); // expected-warning {{Attempt to free released memory}} } else { free(r); } @@ -75,7 +79,7 @@ void reallocSizeZero2() { char *p = malloc(12); char *r = realloc(p, 0); if (!r) { - free(p); + free(p); // expected-warning {{Attempt to free released memory}} } else { free(r); } @@ -98,7 +102,7 @@ void reallocSizeZero5() { } void reallocPtrZero1() { - char *r = realloc(0, 12); // expected-warning {{Memory is never released; potential leak}} + char *r = realloc(0, 12); // expected-warning {{Memory is never released; potential leak of memory pointed to by 'r'}} } void reallocPtrZero2() { @@ -243,6 +247,12 @@ void f7() { x[0] = 'a'; // expected-warning{{Use of memory after it is freed}} } +void f8() { + char *x = (char*) malloc(4); + free(x); + char *y = strndup(x, 4); // expected-warning{{Use of memory after it is freed}} +} + void f7_realloc() { char *x = (char*) malloc(4); realloc(x,0); @@ -311,7 +321,7 @@ void nullFree() { void paramFree(int *p) { myfoo(p); free(p); // no warning - myfoo(p); // TODO: This should be a warning. + myfoo(p); // expected-warning {{Use of memory after it is freed}} } int* mallocEscapeRet() { @@ -503,20 +513,26 @@ void testMalloc() { int *x = malloc(12); StructWithPtr St; St.memP = x; - arrOfStructs[0] = St; + arrOfStructs[0] = St; // no-warning } StructWithPtr testMalloc2() { int *x = malloc(12); StructWithPtr St; St.memP = x; - return St; + return St; // no-warning } int *testMalloc3() { int *x = malloc(12); int *y = x; - return y; + return y; // no-warning +} + +void testStructLeak() { + StructWithPtr St; + St.memP = malloc(12); + return; // expected-warning {{Memory is never released; potential leak of memory pointed to by 'St.memP'}} } void testElemRegion1() { @@ -653,10 +669,6 @@ int *specialMallocWithStruct() { } // 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}} @@ -711,6 +723,18 @@ FILE *useFunOpenNoReleaseFunction() { return f; // expected-warning{{leak}} } +static int readNothing(void *_ctx, char *buf, int size) { + return 0; +} +FILE *useFunOpenReadNoRelease() { + void *ctx = malloc(sizeof(int)); + FILE *f = funopen(ctx, readNothing, 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); @@ -760,10 +784,83 @@ void radar10978247_positive(int myValueSize) { return; } -// ---------------------------------------------------------------------------- -// Below are the known false positives. +// Previously this triggered a false positive +// because malloc() is known to return uninitialized memory and the binding +// of 'o' to 'p->n' was not getting propertly handled. Now we report a leak. +struct rdar11269741_a_t { + struct rdar11269741_b_t { + int m; + } n; +}; + +int rdar11269741(struct rdar11269741_b_t o) +{ + struct rdar11269741_a_t *p = (struct rdar11269741_a_t *) malloc(sizeof(*p)); + p->n = o; + return p->n.m; // expected-warning {{leak}} +} + +// Pointer arithmetic, returning an ElementRegion. +void *radar11329382(unsigned bl) { + void *ptr = malloc (16); + ptr = ptr + (2 - bl); + return ptr; // no warning +} + +void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__)); +int strcmp(const char *, const char *); +char *a (void); +void radar11270219(void) { + char *x = a(), *y = a(); + (__builtin_expect(!(x && y), 0) ? __assert_rtn(__func__, "/Users/zaks/tmp/ex.c", 24, "x && y") : (void)0); + strcmp(x, y); // no warning +} + +void radar_11358224_test_double_assign_ints_positive_2() +{ + void *ptr = malloc(16); + ptr = ptr; // expected-warning {{leak}} +} + +// Assume that functions which take a function pointer can free memory even if +// they are defined in system headers and take the const pointer to the +// allocated memory. (radar://11160612) +int const_ptr_and_callback(int, const char*, int n, void(*)(void*)); +void r11160612_1() { + char *x = malloc(12); + const_ptr_and_callback(0, x, 12, free); // no - warning +} + +// Null is passed as callback. +void r11160612_2() { + char *x = malloc(12); + const_ptr_and_callback(0, x, 12, 0); // expected-warning {{leak}} +} + +// Callback is passed to a function defined in a system header. +void r11160612_4() { + char *x = malloc(12); + sqlite3_bind_text_my(0, x, 12, free); // no - warning +} + +// Passing callbacks in a struct. +void r11160612_5(StWithCallback St) { + void *x = malloc(12); + dealocateMemWhenDoneByVal(x, St); +} +void r11160612_6(StWithCallback St) { + void *x = malloc(12); + dealocateMemWhenDoneByRef(&St, x); +} + +int mySub(int, int); +int myAdd(int, int); +int fPtr(unsigned cond, int x) { + return (cond ? mySub : myAdd)(x, x); +} + +// Test anti-aliasing. -// TODO: There should be no warning here. This one might be difficult to get rid of. void dependsOnValueOfPtr(int *g, unsigned f) { int *p; @@ -776,20 +873,147 @@ void dependsOnValueOfPtr(int *g, unsigned f) { if (p != g) free(p); else - return; // expected-warning{{Memory is never released; potential leak}} + return; // no warning return; } -// ---------------------------------------------------------------------------- -// False negatives. +int CMPRegionHeapToStack() { + int x = 0; + int *x1 = malloc(8); + int *x2 = &x; + clang_analyzer_eval(x1 == x2); // expected-warning{{FALSE}} + free(x1); + return x; +} + +int CMPRegionHeapToHeap2() { + int x = 0; + int *x1 = malloc(8); + int *x2 = malloc(8); + int *x4 = x1; + int *x5 = x2; + clang_analyzer_eval(x4 == x5); // expected-warning{{FALSE}} + free(x1); + free(x2); + return x; +} + +int CMPRegionHeapToHeap() { + int x = 0; + int *x1 = malloc(8); + int *x4 = x1; + if (x1 == x4) { + free(x1); + return 5/x; // expected-warning{{Division by zero}} + } + return x;// expected-warning{{This statement is never executed}} +} -// TODO: This requires tracking symbols stored inside the structs/arrays. -void testMalloc5() { +int HeapAssignment() { + int m = 0; + int *x = malloc(4); + int *y = x; + *x = 5; + clang_analyzer_eval(*x != *y); // expected-warning{{FALSE}} + free(x); + return 0; +} + +int *retPtr(); +int *retPtrMightAlias(int *x); +int cmpHeapAllocationToUnknown() { + int zero = 0; + int *yBefore = retPtr(); + int *m = malloc(8); + int *yAfter = retPtrMightAlias(m); + clang_analyzer_eval(yBefore == m); // expected-warning{{FALSE}} + clang_analyzer_eval(yAfter == m); // expected-warning{{FALSE}} + free(m); + return 0; +} + +void localArrayTest() { + char *p = (char*)malloc(12); + char *ArrayL[12]; + ArrayL[0] = p; // expected-warning {{leak}} +} + +void localStructTest() { StructWithPtr St; StructWithPtr *pSt = &St; - pSt->memP = malloc(12); + pSt->memP = malloc(12); // expected-warning{{Memory is never released; potential leak}} } +// Test double assignment through integers. +static long glob; +void test_double_assign_ints() +{ + void *ptr = malloc (16); // no-warning + glob = (long)(unsigned long)ptr; +} + +void test_double_assign_ints_positive() +{ + void *ptr = malloc(16); + (void*)(long)(unsigned long)ptr; // expected-warning {{unused}} expected-warning {{leak}} +} + + +void testCGContextNoLeak() +{ + void *ptr = malloc(16); + CGContextRef context = CGBitmapContextCreate(ptr); + + // Because you can get the data back out like this, even much later, + // CGBitmapContextCreate is one of our "stop-tracking" exceptions. + free(CGBitmapContextGetData(context)); +} + +void testCGContextLeak() +{ + void *ptr = malloc(16); + CGContextRef context = CGBitmapContextCreate(ptr); + // However, this time we're just leaking the data, because the context + // object doesn't escape and it hasn't been freed in this function. +} + +// Allow xpc context to escape. radar://11635258 +// TODO: Would be great if we checked that the finalize_connection_context actually releases it. +static void finalize_connection_context(void *ctx) { + int *context = ctx; + free(context); +} +void foo (xpc_connection_t peer) { + int *ctx = calloc(1, sizeof(int)); + xpc_connection_set_context(peer, ctx); + xpc_connection_set_finalizer_f(peer, finalize_connection_context); + xpc_connection_resume(peer); +} + +// Make sure we catch errors when we free in a function which does not allocate memory. +void freeButNoMalloc(int *p, int x){ + if (x) { + free(p); + //user forgot a return here. + } + free(p); // expected-warning {{Attempt to free released memory}} +} + +struct HasPtr { + int *p; +}; + +int* reallocButNoMalloc(struct HasPtr *a, int c, int size) { + int *s; + a->p = (int *)realloc(a->p, size); + if (a->p == 0) + return 0; // expected-warning{{Memory is never released; potential leak}} + return a->p; +} + +// ---------------------------------------------------------------------------- +// False negatives. + // TODO: This is another false negative. void testMallocWithParam(int **p) { *p = (int*) malloc(sizeof(int)); @@ -799,11 +1023,3 @@ void testMallocWithParam(int **p) { 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/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp index 8f80b2b76f29..72b92722133b 100644 --- a/test/Analysis/malloc.cpp +++ b/test/Analysis/malloc.cpp @@ -14,3 +14,24 @@ struct Foo { Foo aFunction() { return malloc(10); } + +// Assume that functions which take a function pointer can free memory even if +// they are defined in system headers and take the const pointer to the +// allocated memory. (radar://11160612) +// Test default parameter. +int const_ptr_and_callback_def_param(int, const char*, int n, void(*)(void*) = 0); +void r11160612_3() { + char *x = (char*)malloc(12); + const_ptr_and_callback_def_param(0, x, 12); +} + +// Test member function pointer. +struct CanFreeMemory { + static void myFree(void*); +}; +//This is handled because we look at the type of the parameter(not argument). +void r11160612_3(CanFreeMemory* p) { + char *x = (char*)malloc(12); + const_ptr_and_callback_def_param(0, x, 12, p->myFree); +} + diff --git a/test/Analysis/malloc.m b/test/Analysis/malloc.m index 6c94118286ab..08206f3bf14c 100644 --- a/test/Analysis/malloc.m +++ b/test/Analysis/malloc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class -fblocks %s #include "system-header-simulator-objc.h" @class NSString; diff --git a/test/Analysis/malloc.mm b/test/Analysis/malloc.mm index 3515a4f99af0..7a9d881b1518 100644 --- a/test/Analysis/malloc.mm +++ b/test/Analysis/malloc.mm @@ -9,7 +9,6 @@ void free(void *); 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) { @@ -22,6 +21,16 @@ void testNSDataFreeWhenDoneYES2(NSUInteger dataLength) { NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning } +void testNSStringFreeWhenDoneYES3(NSUInteger dataLength) { + unsigned char *data = (unsigned char *)malloc(42); + NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:1]; +} + +void testNSStringFreeWhenDoneYES4(NSUInteger dataLength) { + unichar *data = (unichar*)malloc(42); + NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:1]; + free(data); //expected-warning {{Attempt to free non-owned memory}} +} void testNSStringFreeWhenDoneYES(NSUInteger dataLength) { unsigned char *data = (unsigned char *)malloc(42); @@ -55,11 +64,17 @@ void testNSStringFreeWhenDoneNO2(NSUInteger dataLength) { 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 +void testRelinquished1() { + void *data = malloc(42); + NSData *nsdata = [NSData dataWithBytesNoCopy:data length:42 freeWhenDone:1]; + free(data); // expected-warning {{Attempt to free non-owned memory}} +} + +void testRelinquished2() { + void *data = malloc(42); + NSData *nsdata; + free(data); + [NSData dataWithBytesNoCopy:data length:42]; // expected-warning {{Attempt to free released memory}} } // Test CF/NS...NoCopy. PR12100: Pointers can escape when custom deallocators are provided. @@ -153,4 +168,57 @@ static void releaseDataCallback (void *info, const void *data, size_t size) { void testCGDataProviderCreateWithData() { void* b = calloc(8, 8); CGDataProviderRef p = CGDataProviderCreateWithData(0, b, 8*8, releaseDataCallback); +} + +// Assume that functions which take a function pointer can free memory even if +// they are defined in system headers and take the const pointer to the +// allocated memory. (radar://11160612) +extern CGDataProviderRef UnknownFunWithCallback(void *info, + const void *data, size_t size, + CGDataProviderReleaseDataCallback releaseData) + __attribute__((visibility("default"))); +void testUnknownFunWithCallBack() { + void* b = calloc(8, 8); + CGDataProviderRef p = UnknownFunWithCallback(0, b, 8*8, releaseDataCallback); +} + +// Test blocks. +void acceptBlockParam(void *, void (^block)(void *), unsigned); +void testCallWithBlockCallback() { + void *l = malloc(12); + acceptBlockParam(l, ^(void *i) { free(i); }, sizeof(char *)); +} + +// Test blocks in system headers. +void testCallWithBlockCallbackInSystem() { + void *l = malloc(12); + SystemHeaderFunctionWithBlockParam(l, ^(void *i) { free(i); }, sizeof(char *)); +} + +// Test escape into NSPointerArray. radar://11691035, PR13140 +void foo(NSPointerArray* pointerArray) { + + void* p1 = malloc (1024); + if (p1) { + [pointerArray addPointer:p1]; + } + + void* p2 = malloc (1024); + if (p2) { + [pointerArray insertPointer:p2 atIndex:1]; + } + + void* p3 = malloc (1024); + if (p3) { + [pointerArray replacePointerAtIndex:1 withPointer:p3]; + } + + // Freeing the buffer is allowed. + void* buffer = [pointerArray pointerAtIndex:0]; + free(buffer); +} + +void noCrashOnVariableArgumentSelector() { + NSMutableString *myString = [NSMutableString stringWithString:@"some text"]; + [myString appendFormat:@"some text = %d", 3]; } \ No newline at end of file diff --git a/test/Analysis/method-call-path-notes.cpp b/test/Analysis/method-call-path-notes.cpp new file mode 100644 index 000000000000..fbf0cae7d8a6 --- /dev/null +++ b/test/Analysis/method-call-path-notes.cpp @@ -0,0 +1,664 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-output=text -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-output=plist-multi-file %s -o - | FileCheck %s + +// Test warning about null or uninitialized pointer values used as instance member +// calls. +class TestInstanceCall { +public: + void foo() {} +}; + +void test_ic() { + TestInstanceCall *p; // expected-note {{Variable 'p' declared without an initial value}} + p->foo(); // expected-warning {{Called C++ object pointer is uninitialized}} expected-note {{Called C++ object pointer is uninitialized}} +} + +void test_ic_null() { + TestInstanceCall *p = 0; // expected-note {{Variable 'p' initialized to a null pointer value}} + p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note {{Called C++ object pointer is null}} +} + +void test_ic_set_to_null() { + TestInstanceCall *p; + p = 0; // expected-note {{Null pointer value stored to 'p'}} + p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note {{Called C++ object pointer is null}} +} + +void test_ic_null(TestInstanceCall *p) { + if (!p) // expected-note {{Assuming pointer value is null}} expected-note {{Taking true branch}} + p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note{{Called C++ object pointer is null}} +} + +void test_ic_member_ptr() { + TestInstanceCall *p = 0; // expected-note {{Variable 'p' initialized to a null pointer value}} + typedef void (TestInstanceCall::*IC_Ptr)(); + IC_Ptr bar = &TestInstanceCall::foo; + (p->*bar)(); // expected-warning {{Called C++ object pointer is null}} expected-note{{Called C++ object pointer is null}} +} + +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: {{.*}}method-call-path-notes.cpp +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col21 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'p' declared without an initial value +// CHECK: message +// CHECK: Variable 'p' declared without an initial value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line12 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Called C++ object pointer is uninitialized +// CHECK: message +// CHECK: Called C++ object pointer is uninitialized +// CHECK: +// CHECK: +// CHECK: descriptionCalled C++ object pointer is uninitialized +// CHECK: categoryLogic error +// CHECK: typeCalled C++ object pointer is uninitialized +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_ic +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line13 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col21 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Called C++ object pointer is null +// CHECK: message +// CHECK: Called C++ object pointer is null +// CHECK: +// CHECK: +// CHECK: descriptionCalled C++ object pointer is null +// CHECK: categoryLogic error +// CHECK: typeCalled C++ object pointer is null +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_ic_null +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line22 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line22 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// 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: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Null pointer value stored to 'p' +// CHECK: message +// CHECK: Null pointer value stored to 'p' +// 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: line24 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line24 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line24 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Called C++ object pointer is null +// CHECK: message +// CHECK: Called C++ object pointer is null +// CHECK: +// CHECK: +// CHECK: descriptionCalled C++ object pointer is null +// CHECK: categoryLogic error +// CHECK: typeCalled C++ object pointer is null +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_ic_set_to_null +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line24 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line28 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Assuming pointer value is null +// CHECK: message +// CHECK: Assuming pointer value is null +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Called C++ object pointer is null +// CHECK: message +// CHECK: Called C++ object pointer is null +// CHECK: +// CHECK: +// CHECK: descriptionCalled C++ object pointer is null +// CHECK: categoryLogic error +// CHECK: typeCalled C++ object pointer is null +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_ic_null +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line33 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col21 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line33 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line36 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line36 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Called C++ object pointer is null +// CHECK: message +// CHECK: Called C++ object pointer is null +// CHECK: +// CHECK: +// CHECK: descriptionCalled C++ object pointer is null +// CHECK: categoryLogic error +// CHECK: typeCalled C++ object pointer is null +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttest_ic_member_ptr +// CHECK: issue_hash4 +// CHECK: location +// CHECK: +// CHECK: line36 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: diff --git a/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp index 323fffebcdbe..91da532456d7 100644 --- a/test/Analysis/method-call.cpp +++ b/test/Analysis/method-call.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -analyzer-store region -verify %s // XFAIL: * +void clang_analyzer_eval(bool); + struct A { int x; A(int a) { x = a; } @@ -9,33 +11,15 @@ struct A { 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 - } + clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} } 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 - } + clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} } 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 - } + clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} } diff --git a/test/Analysis/misc-ps-arm.m b/test/Analysis/misc-ps-arm.m new file mode 100644 index 000000000000..a909ef13d0f8 --- /dev/null +++ b/test/Analysis/misc-ps-arm.m @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple thumbv7-apple-ios0.0.0 -analyze -analyzer-checker=core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s + +// - Handle casts of vectors to structs, and loading +// a value. +typedef float float32_t; +typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t; + +typedef struct +{ + float x, y; +} Rdar11405978Vec; + +float32x2_t rdar11405978_bar(); +float32_t rdar11405978() { + float32x2_t v = rdar11405978_bar(); + Rdar11405978Vec w = *(Rdar11405978Vec *)&v; + return w.x; // no-warning +} diff --git a/test/Analysis/misc-ps-cxx0x.cpp b/test/Analysis/misc-ps-cxx0x.cpp index b4dee3122e2c..164af5dc3dfe 100644 --- a/test/Analysis/misc-ps-cxx0x.cpp +++ b/test/Analysis/misc-ps-cxx0x.cpp @@ -73,3 +73,17 @@ void test2() { struct RDar11178609 { ~RDar11178609() = delete; }; + +// Tests that dynamic_cast handles references to C++ classes. Previously +// this crashed. +class rdar11817693_BaseBase {}; +class rdar11817693_BaseInterface {}; +class rdar11817693_Base : public rdar11817693_BaseBase, public rdar11817693_BaseInterface {}; +class rdar11817693 : public rdar11817693_Base { + virtual void operator=(const rdar11817693_BaseBase& src); + void operator=(const rdar11817693& src); +}; +void rdar11817693::operator=(const rdar11817693& src) { + operator=(dynamic_cast(src)); +} + diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index 8d75fb8ef350..e30cedb91189 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/test/Analysis/misc-ps-region-store.cpp @@ -271,13 +271,27 @@ class Rdar9212495_A : public Rdar9212495_B {}; const Rdar9212495_A& rdar9212495(const Rdar9212495_C* ptr) { const Rdar9212495_A& val = dynamic_cast(*ptr); + // This is not valid C++; dynamic_cast with a reference type will throw an + // exception if the pointer does not match the expected type. However, our + // implementation of dynamic_cast will pass through a null pointer...or a + // "null reference"! So this branch is actually possible. if (&val == 0) { - val.bar(); // FIXME: This should eventually be a null dereference. + val.bar(); // expected-warning{{Called C++ object pointer is null}} } return val; } +const Rdar9212495_A* rdar9212495_ptr(const Rdar9212495_C* ptr) { + const Rdar9212495_A* val = dynamic_cast(ptr); + + if (val == 0) { + val->bar(); // expected-warning{{Called C++ object pointer is null}} + } + + return val; +} + // Test constructors invalidating arguments. Previously this raised // an uninitialized value warning. extern "C" void __attribute__((noreturn)) PR9645_exit(int i); @@ -578,3 +592,37 @@ void rdar10924675(unsigned short x[], int index, int index2) { if (y == 0) return; } + +// Test handling CXXScalarValueInitExprs. +void rdar11401827() { + int x = int(); + if (!x) { + int *p = 0; + *p = 0xDEADBEEF; // expected-warning {{null pointer}} + } + else { + int *p = 0; + *p = 0xDEADBEEF; + } +} + +//===---------------------------------------------------------------------===// +// Handle inlining of C++ method calls. +//===---------------------------------------------------------------------===// + +struct A { + int *p; + void foo(int *q) { + p = q; + } + void bar() { + *p = 0; // expected-warning {{null pointer}} + } +}; + +void test_inline() { + A a; + a.foo(0); + a.bar(); +} + diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index d263d4da30cc..88860bbe10d3 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -673,7 +673,7 @@ typedef void (^RDar_7462324_Callback)(id obj); builder = ^(id object) { id x; if (object) { - builder(x); // expected-warning{{Function call argument is an uninitialized value}} + builder(x); // expected-warning{{Block call argument is an uninitialized value}} } }; builder(target); @@ -1341,3 +1341,23 @@ static unsigned rdar_11127008(void) { return values[index].value; } +// Test handling invalidating arrays passed to a block via captured +// pointer value (not a __block variable). +typedef void (^radar11125868_cb)(int *, unsigned); + +void rdar11125868_aux(radar11125868_cb cb); + +int rdar11125868() { + int integersStackArray[1]; + int *integers = integersStackArray; + rdar11125868_aux(^(int *integerValue, unsigned index) { + integers[index] = integerValue[index]; + }); + return integers[0] == 0; // no-warning +} + +int rdar11125868_positive() { + int integersStackArray[1]; + int *integers = integersStackArray; + return integers[0] == 0; // expected-warning {{he left operand of '==' is a}} +} diff --git a/test/Analysis/misc-ps.c b/test/Analysis/misc-ps.c index f81b0ddc68d2..8ff710b12f56 100644 --- a/test/Analysis/misc-ps.c +++ b/test/Analysis/misc-ps.c @@ -126,3 +126,10 @@ void rdar10686586() { } } +// This example tests CFG handling of '||' nested in a ternary expression, +// and seeing that the analyzer doesn't crash. +int isctype(char c, unsigned long f) +{ + return (c < 1 || c > 10) ? 0 : !!(c & f); +} + diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 9d2ff5b6ea37..bcc0472984e9 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -1,8 +1,8 @@ // 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 +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -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,osx.AtomicCAS -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,osx.AtomicCAS -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,osx.AtomicCAS -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 @@ -494,6 +494,17 @@ int OSAtomicCompareAndSwap32Barrier(); } @end +// Do not crash when performing compare and swap on symbolic values. +typedef int int32_t; +typedef int int32; +typedef int32 Atomic32; +int OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue); +void radar11390991_NoBarrier_CompareAndSwap(volatile Atomic32 *ptr, + Atomic32 old_value, + Atomic32 new_value) { + OSAtomicCompareAndSwap32(old_value, new_value, ptr); +} + // PR 4594 - This was a crash when handling casts in SimpleSValuator. void PR4594() { char *buf[1]; @@ -1345,3 +1356,20 @@ void radar9414427() { } @end +// Don't crash when a ?: is only preceded by a statement (not an expression) +// in the CFG. +void __assert_fail(); + +enum rdar1196620_e { E_A, E_B, E_C, E_D }; +struct rdar1196620_s { int ints[E_D+1]; }; + +static void rdar1196620_call_assert(struct rdar1196620_s* s) { + int i = 0; + s?(void)0:__assert_fail(); +} + +static void rdar1196620(struct rdar1196620_s* s) { + rdar1196620_call_assert(s); +} + + diff --git a/test/Analysis/new.cpp b/test/Analysis/new.cpp index 5ca8c462bdf5..fb77de22f127 100644 --- a/test/Analysis/new.cpp +++ b/test/Analysis/new.cpp @@ -1,15 +1,100 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s -// XFAIL: * +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -std=c++11 -verify %s -void f1() { - int *n = new int; - if (*n) { // expected-warning {{Branch condition evaluates to a garbage value}} - } +void clang_analyzer_eval(bool); + +typedef __typeof__(sizeof(int)) size_t; +extern "C" void *malloc(size_t); + +int someGlobal; +void testImplicitlyDeclaredGlobalNew() { + if (someGlobal != 0) + return; + + // This used to crash because the global operator new is being implicitly + // declared and it does not have a valid source location. (PR13090) + void *x = ::operator new(0); + ::operator delete(x); + + // Check that the new/delete did not invalidate someGlobal; + clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}} +} + + +// This is the standard placement new. +inline void* operator new(size_t, void* __p) throw() +{ + return __p; +} + +void *testPlacementNew() { + int *x = (int *)malloc(sizeof(int)); + *x = 1; + clang_analyzer_eval(*x == 1); // expected-warning{{TRUE}}; + + void *y = new (x) int; + clang_analyzer_eval(x == y); // expected-warning{{TRUE}}; + clang_analyzer_eval(*x == 1); // expected-warning{{UNKNOWN}}; + + return y; +} + +void *operator new(size_t, size_t, int *); +void *testCustomNew() { + int x[1] = {1}; + clang_analyzer_eval(*x == 1); // expected-warning{{TRUE}}; + + void *y = new (0, x) int; + clang_analyzer_eval(*x == 1); // expected-warning{{UNKNOWN}}; + + return y; // no-warning } -void f2() { +void *operator new(size_t, void *, void *); +void *testCustomNewMalloc() { + int *x = (int *)malloc(sizeof(int)); + + // Should be no-warning (the custom allocator could have freed x). + void *y = new (0, x) int; // no-warning + + return y; +} + +void testScalarInitialization() { int *n = new int(3); + clang_analyzer_eval(*n == 3); // expected-warning{{TRUE}} + + new (n) int(); + clang_analyzer_eval(*n == 0); // expected-warning{{TRUE}} + + new (n) int{3}; + clang_analyzer_eval(*n == 3); // expected-warning{{TRUE}} + + new (n) int{}; + clang_analyzer_eval(*n == 0); // expected-warning{{TRUE}} +} + + +//-------------------------------- +// Incorrectly-modelled behavior +//-------------------------------- + +int testNoInitialization() { + int *n = new int; + + // Should warn that *n is uninitialized. if (*n) { // no-warning + return 0; } + return 1; } +int testNoInitializationPlacement() { + int n; + new (&n) int; + + // Should warn that n is uninitialized. + if (n) { // no-warning + return 0; + } + return 1; +} diff --git a/test/Analysis/nonnull.m b/test/Analysis/nonnull.m new file mode 100644 index 000000000000..c32a7f780ece --- /dev/null +++ b/test/Analysis/nonnull.m @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s + +@interface MyObject +- (void)takePointer:(void *)ptr __attribute__((nonnull(1))); +@end + +void testNonNullMethod(int *p, MyObject *obj) { + if (p) + return; + [obj takePointer:p]; // expected-warning{{nonnull}} +} + + +@interface Subclass : MyObject +// [[nonnull]] is an inherited attribute. +- (void)takePointer:(void *)ptr; +@end + +void testSubclass(int *p, Subclass *obj) { + if (p) + return; + [obj takePointer:p]; // expected-warning{{nonnull}} +} diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp index 3119b4fc390c..050c3f8dc56a 100644 --- a/test/Analysis/nullptr.cpp +++ b/test/Analysis/nullptr.cpp @@ -55,7 +55,7 @@ void zoo2() { int **a = 0; int **b = 0; asm ("nop" - :"=a"(*a) + :"=r"(*a) :"0"(*b) // expected-warning{{Dereference of null pointer}} ); } diff --git a/test/Analysis/objc-boxing.m b/test/Analysis/objc-boxing.m new file mode 100644 index 000000000000..16915788d63a --- /dev/null +++ b/test/Analysis/objc-boxing.m @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s + +typedef signed char BOOL; +typedef long NSInteger; +typedef unsigned long NSUInteger; +@interface NSString @end +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end + +@interface NSNumber ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value ; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ; +@end + + +extern char *strdup(const char *str); + +id constant_string() { + return @("boxed constant string."); +} + +id dynamic_string() { + return @(strdup("boxed dynamic string")); // expected-warning{{Memory is never released; potential leak}} +} + +id const_char_pointer(int *x) { + if (x) + return @(3); + return @(*x); // expected-warning {{Dereference of null pointer (loaded from variable 'x')}} +} \ No newline at end of file diff --git a/test/Analysis/objc-for.m b/test/Analysis/objc-for.m new file mode 100644 index 000000000000..52a55b07db5d --- /dev/null +++ b/test/Analysis/objc-for.m @@ -0,0 +1,58 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Loops,debug.ExprInspection -verify + +void clang_analyzer_eval(int); + +#define nil ((id)0) + +@protocol NSFastEnumeration +- (int)countByEnumeratingWithState:(void *)state objects:(id *)objects count:(unsigned)count; +@end + +@interface NSObject ++ (instancetype)testObject; +@end + +@interface NSEnumerator +@end + +@interface NSArray : NSObject +- (NSEnumerator *)objectEnumerator; +@end + +@interface NSDictionary : NSObject +@end + +@interface NSMutableDictionary : NSDictionary +@end + +@interface NSSet : NSObject +@end + +@interface NSPointerArray : NSObject +@end + +void test() { + id x; + for (x in [NSArray testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + + for (x in [NSMutableDictionary testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + + for (x in [NSSet testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + + for (x in [[NSArray testObject] objectEnumerator]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + + for (x in [NSPointerArray testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{UNKNOWN}} +} + +void testWithVarInFor() { + for (id x in [NSArray testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + for (id x in [NSPointerArray testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{UNKNOWN}} +} + diff --git a/test/Analysis/objc-subscript.m b/test/Analysis/objc-subscript.m new file mode 100644 index 000000000000..324bf1c785c1 --- /dev/null +++ b/test/Analysis/objc-subscript.m @@ -0,0 +1,89 @@ +// 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; + +@interface NSObject ++(id)alloc; +-(id)init; +-(id)autorelease; +-(id)copy; +-(id)retain; +@end + +@interface Subscriptable : NSObject +- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index; +- (id)objectAtIndexedSubscript:(NSUInteger)index; + +- (void)setObject:(id)obj forKeyedSubscript:(id)key; +- (id)objectForKeyedSubscript:(id)key; +@end + +@interface Test : Subscriptable +@end + +@implementation Test + +// for subscripting +- (id)storeDoesNotRetain { + Test *cell = [[[Test alloc] init] autorelease]; + + NSObject *string1 = [[NSObject alloc] init]; // expected-warning {{Potential leak}} + cell[0] = string1; + cell[self] = string1; + cell[string1] = self; + + return cell; +} + +// for subscripting +- (id)getDoesNotRetain:(BOOL)keyed { + if (keyed) + return [self[self] autorelease]; // expected-warning{{Object sent -autorelease too many times}} + else + return [self[0] autorelease]; // expected-warning{{Object sent -autorelease too many times}} +} + +// for subscripting +- (id)testUninitializedObject:(BOOL)keyed { + Test *o; + if (keyed) { + if (o[self]) // expected-warning {{Subscript access on an uninitialized object pointer}} + return o; // no-warning (sink) + } else { + if (o[0]) // expected-warning {{Subscript access on an uninitialized object pointer}} + return o; // no-warning (sink) + } + return self; +} + +- (void)testUninitializedArgument:(id)input testCase:(unsigned)testCase { + NSUInteger i; + id o; + + switch (testCase) { + case 0: + self[0] = o; // expected-warning {{Argument for subscript setter is an uninitialized value}} + break; + case 1: + self[i] = input; // expected-warning {{Subscript index is an uninitialized value}} + break; + case 2: + (void)self[i]; // expected-warning {{Subscript index is an uninitialized value}} + break; + case 3: + self[input] = o; // expected-warning {{Argument for subscript setter is an uninitialized value}} + break; + case 4: + self[o] = input; // expected-warning {{Subscript index is an uninitialized value}} + break; + case 5: + (void)self[o]; // expected-warning {{Subscript index is an uninitialized value}} + break; + default: + break; + } + +} + +@end diff --git a/test/Analysis/operator-calls.cpp b/test/Analysis/operator-calls.cpp index 73cd28ac0d56..dbc63bc4bed8 100644 --- a/test/Analysis/operator-calls.cpp +++ b/test/Analysis/operator-calls.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-ipa=inlining -verify %s +void clang_analyzer_eval(bool); + struct X0 { }; bool operator==(const X0&, const X0&); @@ -14,3 +16,17 @@ void t2() { bool PR7287(X0 a, X0 b) { return operator==(a, b); } + + +// Inlining non-static member operators mistakenly treated 'this' as the first +// argument for a while. + +struct IntComparable { + bool operator==(int x) const { + return x == 0; + } +}; + +void testMemberOperator(IntComparable B) { + clang_analyzer_eval(B == 0); // expected-warning{{TRUE}} +} diff --git a/test/Analysis/out-of-bounds.c b/test/Analysis/out-of-bounds.c index a97bba5bb3b8..c1721703fb86 100644 --- a/test/Analysis/out-of-bounds.c +++ b/test/Analysis/out-of-bounds.c @@ -128,11 +128,13 @@ void test2_multi_ok(int x) { buf[0][0] = 1; // no-warning } -// Testing if solver handles (symbol * constant) < constant +// *** FIXME *** +// We don't get a warning here yet because our symbolic constraint solving +// doesn't handle: (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)}} + buf[x] = 1; } // *** FIXME *** diff --git a/test/Analysis/outofbound-notwork.c b/test/Analysis/outofbound-notwork.c index 45e713b6880a..c1fa2d7148e8 100644 --- a/test/Analysis/outofbound-notwork.c +++ b/test/Analysis/outofbound-notwork.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.unix,experimental.security.ArrayBound -analyzer-store=region -verify %s +// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.security.ArrayBound -analyzer-store=region -verify %s // XFAIL: * // Once we better handle modeling of sizes of VLAs, we can pull this back diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c index 2e7a7d30d67f..2783ac28313c 100644 --- a/test/Analysis/outofbound.c +++ b/test/Analysis/outofbound.c @@ -86,3 +86,39 @@ int symbolic_index2(int a) { } return 0; } + +int overflow_binary_search(double in) { + int eee = 16; + if (in < 1e-8 || in > 1e23) { + return 0; + } else { + static const double ins[] = {1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, + 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, + 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; + if (in < ins[eee]) { + eee -= 8; + } else { + eee += 8; + } + if (in < ins[eee]) { + eee -= 4; + } else { + eee += 4; + } + if (in < ins[eee]) { + eee -= 2; + } else { + eee += 2; + } + if (in < ins[eee]) { + eee -= 1; + } else { + eee += 1; + } + if (in < ins[eee]) { // expected-warning {{Access out-of-bound array element (buffer overflow)}} + eee -= 1; + } + } + return eee; +} diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m index 83100dc20944..a338a79491fd 100644 --- a/test/Analysis/plist-output-alternate.m +++ b/test/Analysis/plist-output-alternate.m @@ -82,7 +82,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line5 -// CHECK: col3 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: @@ -137,6 +137,7 @@ void rdar8331641(int x) { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_init +// CHECK: issue_hash2 // CHECK: location // CHECK: // CHECK: line6 @@ -161,7 +162,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line10 -// CHECK: col3 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: @@ -216,6 +217,7 @@ void rdar8331641(int x) { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_assign +// CHECK: issue_hash3 // CHECK: location // CHECK: // CHECK: line12 @@ -240,7 +242,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line16 -// CHECK: col3 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: @@ -295,6 +297,7 @@ void rdar8331641(int x) { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_assign_transitive +// CHECK: issue_hash4 // CHECK: location // CHECK: // CHECK: line19 @@ -319,7 +322,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line23 -// CHECK: col3 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -332,7 +335,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line23 -// CHECK: col8 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -382,7 +385,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line23 -// CHECK: col8 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -437,6 +440,7 @@ void rdar8331641(int x) { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_cond +// CHECK: issue_hash2 // CHECK: location // CHECK: // CHECK: line24 @@ -461,7 +465,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line29 -// CHECK: col3 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -474,7 +478,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line29 -// CHECK: col8 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -495,7 +499,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line29 -// CHECK: col8 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -508,7 +512,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line30 -// CHECK: col5 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -529,7 +533,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line30 -// CHECK: col5 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -584,6 +588,7 @@ void rdar8331641(int x) { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_cond_transitive +// CHECK: issue_hash3 // CHECK: location // CHECK: // CHECK: line31 @@ -608,7 +613,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line36 -// CHECK: col3 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -697,6 +702,7 @@ void rdar8331641(int x) { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_field +// CHECK: issue_hash3 // CHECK: location // CHECK: // CHECK: line38 @@ -721,7 +727,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line53 -// CHECK: col3 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -734,7 +740,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line54 -// CHECK: col3 +// CHECK: col13 // CHECK: file0 // CHECK: // CHECK: @@ -755,7 +761,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line54 -// CHECK: col3 +// CHECK: col13 // CHECK: file0 // CHECK: // CHECK: @@ -768,7 +774,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line54 -// CHECK: col82 +// CHECK: col36 // CHECK: file0 // CHECK: // CHECK: @@ -818,7 +824,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line54 -// CHECK: col82 +// CHECK: col36 // CHECK: file0 // CHECK: // CHECK: @@ -831,7 +837,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line55 -// CHECK: col3 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -852,7 +858,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line55 -// CHECK: col3 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -899,7 +905,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line57 -// CHECK: col10 +// CHECK: col14 // CHECK: file0 // CHECK: // CHECK: @@ -920,7 +926,7 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: line57 -// CHECK: col10 +// CHECK: col14 // CHECK: file0 // CHECK: // CHECK: @@ -960,6 +966,7 @@ void rdar8331641(int x) { // CHECK: typeLeak // CHECK: issue_context_kindfunction // CHECK: issue_contextrdar8331641 +// CHECK: issue_hash6 // CHECK: location // CHECK: // CHECK: line58 diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m index 72e8f8d0aa66..769c1bc60247 100644 --- a/test/Analysis/plist-output.m +++ b/test/Analysis/plist-output.m @@ -1,5 +1,4 @@ -// RUN: %clang --analyze %s -o %t > /dev/null 2>&1 -// RUN: FileCheck -input-file %t %s +// RUN: %clang --analyze %s -o - 2>/dev/null | FileCheck %s void test_null_init(void) { int *p = 0; @@ -27,7 +26,6 @@ void test_null_cond(int *p) { 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; } @@ -81,10 +79,12 @@ int test_cond_assign() { @end // CHECK: +// CHECK: // CHECK: // CHECK: // CHECK: files // CHECK: +// CHECK: {{.*}}plist-output.m // CHECK: // CHECK: diagnostics // CHECK: @@ -92,6 +92,35 @@ int test_cond_assign() { // CHECK: path // CHECK: // CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line4 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: +// CHECK: // CHECK: kindcontrol // CHECK: edges // CHECK: @@ -99,25 +128,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line5 +// CHECK: line4 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line5 -// CHECK: col3 +// CHECK: line4 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line6 +// CHECK: line5 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line6 +// CHECK: line5 // CHECK: col3 // CHECK: file0 // CHECK: @@ -129,7 +158,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line6 +// CHECK: line5 // CHECK: col3 // CHECK: file0 // CHECK: @@ -137,12 +166,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line6 +// CHECK: line5 // CHECK: col4 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line6 +// CHECK: line5 // CHECK: col4 // CHECK: file0 // CHECK: @@ -160,9 +189,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_init +// CHECK: issue_hash2 // CHECK: location // CHECK: -// CHECK: line6 +// CHECK: line5 // CHECK: col3 // CHECK: file0 // CHECK: @@ -178,6 +208,69 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: +// CHECK: line9 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col5 +// 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: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Null pointer value stored to 'p' +// CHECK: message +// CHECK: Null pointer value stored to 'p' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: // CHECK: line10 // CHECK: col3 // CHECK: file0 @@ -191,12 +284,12 @@ int test_cond_assign() { // CHECK: end // CHECK: // CHECK: -// CHECK: line12 +// CHECK: line11 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line12 +// CHECK: line11 // CHECK: col3 // CHECK: file0 // CHECK: @@ -208,7 +301,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line12 +// CHECK: line11 // CHECK: col3 // CHECK: file0 // CHECK: @@ -216,12 +309,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line12 +// CHECK: line11 // CHECK: col4 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line12 +// CHECK: line11 // CHECK: col4 // CHECK: file0 // CHECK: @@ -239,9 +332,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_assign +// CHECK: issue_hash3 // CHECK: location // CHECK: -// CHECK: line12 +// CHECK: line11 // CHECK: col3 // CHECK: file0 // CHECK: @@ -257,25 +351,88 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line16 +// CHECK: line15 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line16 +// CHECK: line15 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line17 // CHECK: col3 // CHECK: file0 // CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'q' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'q' initialized to a null pointer value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col5 +// CHECK: file0 +// CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line19 +// CHECK: line18 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line19 +// CHECK: line18 // CHECK: col3 // CHECK: file0 // CHECK: @@ -287,7 +444,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line19 +// CHECK: line18 // CHECK: col3 // CHECK: file0 // CHECK: @@ -295,12 +452,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line19 +// CHECK: line18 // CHECK: col4 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line19 +// CHECK: line18 // CHECK: col4 // CHECK: file0 // CHECK: @@ -318,9 +475,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_assign_transitive +// CHECK: issue_hash4 // CHECK: location // CHECK: -// CHECK: line19 +// CHECK: line18 // CHECK: col3 // CHECK: file0 // CHECK: @@ -336,26 +494,26 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line23 +// CHECK: line22 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line23 -// CHECK: col3 +// CHECK: line22 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line23 +// CHECK: line22 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line23 -// CHECK: col8 +// CHECK: line22 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -366,7 +524,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line23 +// CHECK: line22 // CHECK: col7 // CHECK: file0 // CHECK: @@ -374,12 +532,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line23 +// CHECK: line22 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line23 +// CHECK: line22 // CHECK: col8 // CHECK: file0 // CHECK: @@ -392,6 +550,35 @@ int test_cond_assign() { // CHECK: Assuming 'p' is null // CHECK: // CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line22 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line22 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line22 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Assuming pointer value is null +// CHECK: message +// CHECK: Assuming pointer value is null +// CHECK: +// CHECK: // CHECK: kindcontrol // CHECK: edges // CHECK: @@ -399,25 +586,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line23 +// CHECK: line22 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line23 -// CHECK: col8 +// CHECK: line22 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line24 +// CHECK: line23 // CHECK: col5 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line24 +// CHECK: line23 // CHECK: col5 // CHECK: file0 // CHECK: @@ -429,7 +616,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line24 +// CHECK: line23 // CHECK: col5 // CHECK: file0 // CHECK: @@ -437,12 +624,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line24 +// CHECK: line23 // CHECK: col6 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line24 +// CHECK: line23 // CHECK: col6 // CHECK: file0 // CHECK: @@ -460,9 +647,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_cond +// CHECK: issue_hash2 // CHECK: location // CHECK: -// CHECK: line24 +// CHECK: line23 // CHECK: col5 // CHECK: file0 // CHECK: @@ -478,26 +666,26 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line29 +// CHECK: line28 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line29 -// CHECK: col3 +// CHECK: line28 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line29 +// CHECK: line28 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line29 -// CHECK: col8 +// CHECK: line28 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -512,26 +700,26 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line29 +// CHECK: line28 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line29 -// CHECK: col8 +// CHECK: line28 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line31 +// CHECK: line29 // CHECK: col5 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line31 -// CHECK: col5 +// CHECK: line29 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: @@ -539,6 +727,35 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: +// CHECK: // CHECK: kindcontrol // CHECK: edges // CHECK: @@ -546,25 +763,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line31 +// CHECK: line29 // CHECK: col5 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line31 -// CHECK: col5 +// CHECK: line29 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line32 +// CHECK: line30 // CHECK: col5 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line32 +// CHECK: line30 // CHECK: col5 // CHECK: file0 // CHECK: @@ -576,7 +793,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line32 +// CHECK: line30 // CHECK: col5 // CHECK: file0 // CHECK: @@ -584,12 +801,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line32 +// CHECK: line30 // CHECK: col6 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line32 +// CHECK: line30 // CHECK: col6 // CHECK: file0 // CHECK: @@ -607,9 +824,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_cond_transitive +// CHECK: issue_hash3 // CHECK: location // CHECK: -// CHECK: line32 +// CHECK: line30 // CHECK: col5 // CHECK: file0 // CHECK: @@ -625,25 +843,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line37 +// CHECK: line35 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line37 -// CHECK: col3 +// CHECK: line35 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line37 +// CHECK: line35 // CHECK: col10 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line37 +// CHECK: line35 // CHECK: col10 // CHECK: file0 // CHECK: @@ -659,12 +877,12 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line37 +// CHECK: line35 // CHECK: col10 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line37 +// CHECK: line35 // CHECK: col10 // CHECK: file0 // CHECK: @@ -672,12 +890,12 @@ int test_cond_assign() { // CHECK: end // CHECK: // CHECK: -// CHECK: line39 +// CHECK: line37 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line39 +// CHECK: line37 // CHECK: col3 // CHECK: file0 // CHECK: @@ -689,7 +907,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line39 +// CHECK: line37 // CHECK: col3 // CHECK: file0 // CHECK: @@ -697,12 +915,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line39 +// CHECK: line37 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line39 +// CHECK: line37 // CHECK: col7 // CHECK: file0 // CHECK: @@ -720,9 +938,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_null_field +// CHECK: issue_hash3 // CHECK: location // CHECK: -// CHECK: line39 +// CHECK: line37 // CHECK: col3 // CHECK: file0 // CHECK: @@ -738,25 +957,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line44 +// CHECK: line42 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line44 -// CHECK: col3 +// CHECK: line42 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line44 +// CHECK: line42 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line44 +// CHECK: line42 // CHECK: col7 // CHECK: file0 // CHECK: @@ -772,12 +991,12 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line44 +// CHECK: line42 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line44 +// CHECK: line42 // CHECK: col7 // CHECK: file0 // CHECK: @@ -785,13 +1004,13 @@ int test_cond_assign() { // CHECK: end // CHECK: // CHECK: -// CHECK: line47 +// CHECK: line45 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line47 -// CHECK: col3 +// CHECK: line45 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -806,25 +1025,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line47 +// CHECK: line45 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line47 -// CHECK: col3 +// CHECK: line45 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line47 +// CHECK: line45 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line47 +// CHECK: line45 // CHECK: col7 // CHECK: file0 // CHECK: @@ -840,12 +1059,12 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line47 +// CHECK: line45 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line47 +// CHECK: line45 // CHECK: col7 // CHECK: file0 // CHECK: @@ -853,13 +1072,13 @@ int test_cond_assign() { // CHECK: end // CHECK: // CHECK: -// CHECK: line50 +// CHECK: line48 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line50 -// CHECK: col3 +// CHECK: line48 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: @@ -867,6 +1086,35 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line48 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: +// CHECK: // CHECK: kindcontrol // CHECK: edges // CHECK: @@ -874,25 +1122,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line50 +// CHECK: line48 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line50 -// CHECK: col3 +// CHECK: line48 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line51 +// CHECK: line49 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line51 +// CHECK: line49 // CHECK: col3 // CHECK: file0 // CHECK: @@ -904,7 +1152,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line51 +// CHECK: line49 // CHECK: col3 // CHECK: file0 // CHECK: @@ -912,12 +1160,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line51 +// CHECK: line49 // CHECK: col4 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line51 +// CHECK: line49 // CHECK: col4 // CHECK: file0 // CHECK: @@ -935,9 +1183,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_assumptions +// CHECK: issue_hash8 // CHECK: location // CHECK: -// CHECK: line51 +// CHECK: line49 // CHECK: col3 // CHECK: file0 // CHECK: @@ -953,26 +1202,26 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line56 +// CHECK: line54 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line56 -// CHECK: col3 +// CHECK: line54 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line57 -// CHECK: col3 +// CHECK: line55 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: @@ -987,25 +1236,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line57 -// CHECK: col3 +// CHECK: line55 +// CHECK: col4 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col7 // CHECK: file0 // CHECK: @@ -1017,7 +1266,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col7 // CHECK: file0 // CHECK: @@ -1025,12 +1274,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col7 // CHECK: file0 // CHECK: @@ -1050,12 +1299,12 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col7 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line57 +// CHECK: line55 // CHECK: col7 // CHECK: file0 // CHECK: @@ -1063,13 +1312,13 @@ int test_cond_assign() { // CHECK: end // CHECK: // CHECK: -// CHECK: line59 +// CHECK: line57 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line59 -// CHECK: col3 +// CHECK: line57 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: @@ -1084,26 +1333,26 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line59 +// CHECK: line57 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line59 -// CHECK: col3 +// CHECK: line57 +// CHECK: col8 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line59 +// CHECK: line57 // CHECK: col10 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line59 -// CHECK: col11 +// CHECK: line57 +// CHECK: col10 // CHECK: file0 // CHECK: // CHECK: @@ -1114,7 +1363,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line59 +// CHECK: line57 // CHECK: col10 // CHECK: file0 // CHECK: @@ -1122,12 +1371,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line59 +// CHECK: line57 // CHECK: col11 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line59 +// CHECK: line57 // CHECK: col11 // CHECK: file0 // CHECK: @@ -1145,9 +1394,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindfunction // CHECK: issue_contexttest_cond_assign +// CHECK: issue_hash4 // CHECK: location // CHECK: -// CHECK: line59 +// CHECK: line57 // CHECK: col10 // CHECK: file0 // CHECK: @@ -1163,99 +1413,60 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line76 +// CHECK: line74 // CHECK: col3 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line76 -// CHECK: col3 +// CHECK: line74 +// CHECK: col4 // 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: line75 +// CHECK: col5 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line76 +// CHECK: line75 // 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: kindevent +// CHECK: location +// CHECK: +// CHECK: line75 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value // CHECK: // CHECK: // CHECK: kindcontrol @@ -1265,25 +1476,25 @@ int test_cond_assign() { // CHECK: start // CHECK: // CHECK: -// CHECK: line77 +// CHECK: line75 // CHECK: col5 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line77 -// CHECK: col5 +// CHECK: line75 +// CHECK: col7 // CHECK: file0 // CHECK: // CHECK: // CHECK: end // CHECK: // CHECK: -// CHECK: line78 +// CHECK: line76 // CHECK: col5 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line78 +// CHECK: line76 // CHECK: col5 // CHECK: file0 // CHECK: @@ -1295,7 +1506,7 @@ int test_cond_assign() { // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line78 +// CHECK: line76 // CHECK: col5 // CHECK: file0 // CHECK: @@ -1303,12 +1514,12 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: -// CHECK: line78 +// CHECK: line76 // CHECK: col6 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line78 +// CHECK: line76 // CHECK: col6 // CHECK: file0 // CHECK: @@ -1326,9 +1537,10 @@ int test_cond_assign() { // CHECK: typeDereference of null pointer // CHECK: issue_context_kindObjective-C method // CHECK: issue_contexttest +// CHECK: issue_hash3 // CHECK: location // CHECK: -// CHECK: line78 +// CHECK: line76 // CHECK: col5 // CHECK: file0 // CHECK: @@ -1336,4 +1548,3 @@ int test_cond_assign() { // CHECK: // CHECK: // CHECK: - diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c index fb37f1c791a3..6567000c735f 100644 --- a/test/Analysis/ptr-arith.c +++ b/test/Analysis/ptr-arith.c @@ -1,8 +1,7 @@ -// 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 +// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub,debug.ExprInspection -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,debug.ExprInspection -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 clang_analyzer_eval(int); void f1() { int a[10]; @@ -67,111 +66,48 @@ void f6(int *p, int *q) { 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 + clang_analyzer_eval(&&start != 0); // expected-warning{{TRUE}} + clang_analyzer_eval(&&start >= 0); // expected-warning{{TRUE}} + clang_analyzer_eval(&&start > 0); // expected-warning{{TRUE}} + clang_analyzer_eval((&&start - 0) != 0); // expected-warning{{TRUE}} // 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 + clang_analyzer_eval(&a != 0); // expected-warning{{TRUE}} + clang_analyzer_eval(&a >= 0); // expected-warning{{TRUE}} + clang_analyzer_eval(&a > 0); // expected-warning{{TRUE}} + clang_analyzer_eval((&a - 0) != 0); // expected-warning{{TRUE}} expected-warning{{Pointer arithmetic done on non-array variables}} // 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 + clang_analyzer_eval(0 != &a); // expected-warning{{TRUE}} + clang_analyzer_eval(0 <= &a); // expected-warning{{TRUE}} + clang_analyzer_eval(0 < &a); // expected-warning{{TRUE}} // 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{{}} + clang_analyzer_eval(a != 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a >= 0); // expected-warning{{TRUE}} + clang_analyzer_eval(a <= 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval((a - 0) != 0); // expected-warning{{UNKNOWN}} // 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 + clang_analyzer_eval(0 != a); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(0 <= a); // expected-warning{{TRUE}} + clang_analyzer_eval(0 < a); // expected-warning{{UNKNOWN}} } 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{{}} + clang_analyzer_eval(a != b); // expected-warning{{TRUE}} + clang_analyzer_eval(a < b); // expected-warning{{TRUE}} + clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} + clang_analyzer_eval((b-a) == 0x100); // expected-warning{{TRUE}} + + clang_analyzer_eval(&&start == a); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == &&start); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&a == (char**)a); // expected-warning{{UNKNOWN}} + clang_analyzer_eval((char**)a == &a); // expected-warning{{UNKNOWN}} } void array_matching_types() { @@ -179,20 +115,10 @@ void array_matching_types() { 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 + clang_analyzer_eval(a != b); // expected-warning{{TRUE}} + clang_analyzer_eval(a < b); // expected-warning{{TRUE}} + clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} + clang_analyzer_eval((b-a) != 0); // expected-warning{{TRUE}} } // This takes a different code path than array_matching_types() @@ -201,49 +127,22 @@ void array_different_types() { 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 + clang_analyzer_eval(a != b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}} + clang_analyzer_eval(a < b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}} + clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}} } 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 + clang_analyzer_eval(&a.x != &a.y); // expected-warning{{TRUE}} + clang_analyzer_eval(&a.x < &a.y); // expected-warning{{TRUE}} + clang_analyzer_eval(&a.x <= &a.y); // expected-warning{{TRUE}} - 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{{}} + clang_analyzer_eval(&a.x != &b.x); // expected-warning{{TRUE}} + clang_analyzer_eval(&a.x > &b.x); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&a.x >= &b.x); // expected-warning{{UNKNOWN}} } void mixed_region_types() { @@ -251,35 +150,17 @@ void mixed_region_types() { 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{{}} + clang_analyzer_eval(&a != &b); // expected-warning{{TRUE}} + clang_analyzer_eval(&a > &b); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&a >= &b); // expected-warning{{UNKNOWN}} } 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{{}} + clang_analyzer_eval(&a != p); // expected-warning{{TRUE}} + clang_analyzer_eval(&a > p); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&a >= p); // expected-warning{{UNKNOWN}} } void PR7527 (int *p) { diff --git a/test/Analysis/rdar-7168531.m b/test/Analysis/rdar-7168531.m index 151625569ca7..4ccc7d7a2b34 100644 --- a/test/Analysis/rdar-7168531.m +++ b/test/Analysis/rdar-7168531.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -triple i386-apple-darwin10 -fobjc-fragile-abi -analyzer-store=region %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -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. diff --git a/test/Analysis/refcnt_naming.m b/test/Analysis/refcnt_naming.m index aff713be49f2..1d3a9b7589e3 100644 --- a/test/Analysis/refcnt_naming.m +++ b/test/Analysis/refcnt_naming.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-ipa=none -analyzer-store=region -verify %s typedef const struct __CFString * CFStringRef; typedef const struct __CFAllocator * CFAllocatorRef; diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp index 5897e682884c..06e4a50e44cc 100644 --- a/test/Analysis/reference.cpp +++ b/test/Analysis/reference.cpp @@ -1,11 +1,12 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s -// XFAIL +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s + +void clang_analyzer_eval(bool); 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 const &i = 3; int b = i; int *p = 0; @@ -56,3 +57,75 @@ char t6 (char* p) { if (*p) return *p; return *(char*)0; // no-warning } + + +// PR13440 / +// Test that the array-to-pointer decay works for array references as well. +// More generally, when we want an lvalue for a reference field, we still need +// to do one level of load. +namespace PR13440 { + typedef int T[1]; + struct S { + T &x; + + int *m() { return x; } + }; + + struct S2 { + int (&x)[1]; + + int *m() { return x; } + }; + + void test() { + int a[1]; + S s = { a }; + S2 s2 = { a }; + + if (s.x != a) return; + if (s2.x != a) return; + + a[0] = 42; + clang_analyzer_eval(s.x[0] == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(s2.x[0] == 42); // expected-warning{{TRUE}} + } +} + +void testNullReference() { + int *x = 0; + int &y = *x; // expected-warning{{Dereference of null pointer}} + y = 5; +} + +void testRetroactiveNullReference(int *x) { + // According to the C++ standard, there is no such thing as a + // "null reference". So the 'if' statement ought to be dead code. + // However, Clang (and other compilers) don't actually check that a pointer + // value is non-null in the implementation of references, so it is possible + // to produce a supposed "null reference" at runtime. The analyzer shoeuld + // still warn when it can prove such errors. + int &y = *x; + if (x != 0) + return; + y = 5; // expected-warning{{Dereference of null pointer}} +} + + +// ------------------------------------ +// False negatives +// ------------------------------------ + +namespace rdar11212286 { + class B{}; + + B test() { + B *x = 0; + return *x; // should warn here! + } + + B &testRef() { + B *x = 0; + return *x; // should warn here! + } + +} diff --git a/test/Analysis/region-store.c b/test/Analysis/region-store.c new file mode 100644 index 000000000000..09c3f102e3ad --- /dev/null +++ b/test/Analysis/region-store.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -verify %s + +int printf(const char *restrict,...); + +// Testing core functionality of the region store. +// radar://10127782 +int compoundLiteralTest() { + int index = 0; + for (index = 0; index < 2; index++) { + int thing = (int []){0, 1}[index]; + printf("thing: %i\n", thing); + } + return 0; +} + +int compoundLiteralTest2() { + int index = 0; + for (index = 0; index < 3; index++) { + int thing = (int [][3]){{0,0,0}, {1,1,1}, {2,2,2}}[index][index]; + printf("thing: %i\n", thing); + } + return 0; +} diff --git a/test/Analysis/retain-release-path-notes-gc.m b/test/Analysis/retain-release-path-notes-gc.m index 1e74f003e1a7..feee525b85a3 100644 --- a/test/Analysis/retain-release-path-notes-gc.m +++ b/test/Analysis/retain-release-path-notes-gc.m @@ -1,4 +1,5 @@ -// 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 +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=text -verify %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 -fobjc-gc-only -analyzer-output=plist-multi-file %s -o - | FileCheck %s /*** This file is for testing the path-sensitive notes for retain/release errors. @@ -71,3 +72,1339 @@ void retainReleaseIgnored () { } @end + +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: {{.*}}retain-release-path-notes-gc.m +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line42 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK: message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line42 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line43 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line43 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'leaked' 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 'leaked' is not referenced later in this execution path and has a retain count of +1 +// CHECK: +// CHECK: +// CHECK: descriptionPotential leak (when using garbage collection) of an object stored into 'leaked' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak of object when using garbage collection +// CHECK: issue_context_kindfunction +// CHECK: issue_contextcreationViaCFCreate +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line43 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line47 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK: message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line47 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line48 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reference count incremented. The object now has a +2 retain count +// CHECK: message +// CHECK: Reference count incremented. The object now has a +2 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line48 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line49 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col21 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col26 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: 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 +// CHECK: message +// CHECK: 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 +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line49 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col21 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col26 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: 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 +// CHECK: message +// CHECK: 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 +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col10 +// 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: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: 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 +// CHECK: message +// CHECK: 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 +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'leaked' 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 'leaked' is not referenced later in this execution path and has a retain count of +1 +// CHECK: +// CHECK: +// CHECK: descriptionPotential leak (when using garbage collection) of an object stored into 'leaked' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak of object when using garbage collection +// CHECK: issue_context_kindfunction +// CHECK: issue_contextmakeCollectable +// CHECK: issue_hash6 +// CHECK: location +// CHECK: +// CHECK: line52 +// 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: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line56 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col37 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Method returns an Objective-C object with a +0 retain count +// CHECK: message +// CHECK: Method returns an Objective-C object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col15 +// 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: kindevent +// CHECK: location +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: In GC mode the 'retain' message has no effect +// CHECK: message +// CHECK: In GC mode the 'retain' message has no effect +// 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: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: In GC mode the 'release' message has no effect +// CHECK: message +// CHECK: In GC mode the 'release' message has no effect +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col3 +// 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: kindevent +// CHECK: location +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: In GC mode an 'autorelease' has no effect +// CHECK: message +// CHECK: In GC mode an 'autorelease' has no effect +// 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: line60 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line60 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col13 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line60 +// CHECK: col29 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: +// CHECK: +// CHECK: descriptionIncorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeBad release +// CHECK: issue_context_kindfunction +// CHECK: issue_contextretainReleaseIgnored +// CHECK: issue_hash5 +// CHECK: location +// CHECK: +// CHECK: line60 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col36 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line65 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK: message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col36 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line66 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK: message +// CHECK: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line66 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line66 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: 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 +// CHECK: message +// CHECK: 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 +// CHECK: +// CHECK: +// CHECK: descriptionPotential leak (when using garbage collection) of an object stored into 'object' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak of returned object when using garbage collection +// CHECK: issue_context_kindObjective-C method +// CHECK: issue_contextgetViolation +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line66 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col36 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line70 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK: message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col36 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK: message +// CHECK: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: 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 +// CHECK: message +// CHECK: 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 +// CHECK: +// CHECK: +// CHECK: descriptionPotential leak (when using garbage collection) of an object stored into 'object' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak of returned object when using garbage collection +// CHECK: issue_context_kindObjective-C method +// CHECK: issue_contextcopyViolation +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: diff --git a/test/Analysis/retain-release-path-notes.m b/test/Analysis/retain-release-path-notes.m index c3f5fcda4442..ebcfd6adf5d4 100644 --- a/test/Analysis/retain-release-path-notes.m +++ b/test/Analysis/retain-release-path-notes.m @@ -1,8 +1,5 @@ // 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 +// RN: %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=plist-multi-file %s -o - | FileCheck %s /*** This file is for testing the path-sensitive notes for retain/release errors. @@ -28,6 +25,9 @@ GC-specific notes should go in retain-release-path-notes-gc.m. @interface Foo : NSObject - (id)methodWithValue; @property(retain) id propertyValue; + +- (id)objectAtIndexedSubscript:(unsigned)index; +- (id)objectForKeyedSubscript:(id)key; @end typedef struct CFType *CFTypeRef; @@ -119,6 +119,16 @@ CFTypeRef CFGetRuleViolation () { 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)copyViolationIndexedSubscript { + id result = self[0]; // expected-note{{Subscript 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)copyViolationKeyedSubscript { + id result = self[self]; // expected-note{{Subscript 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}} @@ -130,3 +140,4474 @@ CFTypeRef CFGetRuleViolation () { 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 + + +typedef unsigned long NSUInteger; + +@interface NSValue : NSObject +@end + +@interface NSNumber : NSValue ++ (NSNumber *)numberWithInt:(int)i; +@end + +@interface NSString : NSObject ++ (NSString *)stringWithUTF8String:(const char *)str; +@end + +@interface NSArray : NSObject ++ (NSArray *)arrayWithObjects:(const id [])objects count:(NSUInteger)count; +@end + +@interface NSDictionary : NSObject ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id /* */ [])keys count:(NSUInteger)count; +@end + + +void testNumericLiteral() { + id result = @1; // expected-note{{NSNumber literal is an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + +void testBoxedInt(int x) { + id result = @(x); // expected-note{{NSNumber boxed expression produces an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + +void testBoxedString(const char *str) { + id result = @(str); // expected-note{{NSString boxed expression produces an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + +void testArray(id obj) { + id result = @[obj]; // expected-note{{NSArray literal is an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + +void testDictionary(id key, id value) { + id result = @{key: value}; // expected-note{{NSDictionary literal is an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + + +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: {{.*}}retain-release-path-notes.m +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line45 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col37 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line45 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line46 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'leaked' 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 'leaked' 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 'leaked' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextcreationViaAlloc +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line46 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line50 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK: message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line50 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col8 +// 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: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line51 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'leaked' 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 'leaked' 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 'leaked' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextcreationViaCFCreate +// CHECK: issue_hash2 +// 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: line55 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line55 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col35 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Method returns an Objective-C object with a +0 retain count +// CHECK: message +// CHECK: Method returns an Objective-C object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line55 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reference count incremented. The object now has a +1 retain count +// CHECK: message +// CHECK: Reference count incremented. The object now has a +1 retain count +// 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: kindevent +// CHECK: location +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reference count incremented. The object now has a +2 retain count +// CHECK: message +// CHECK: Reference count incremented. The object now has a +2 retain count +// 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: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reference count decremented. The object now has a +1 retain count +// CHECK: message +// CHECK: Reference count decremented. The object now has a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line58 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line59 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'leaked' 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 'leaked' 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 'leaked' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextacquisitionViaMethod +// CHECK: issue_hash5 +// CHECK: location +// CHECK: +// CHECK: line59 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col31 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line63 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col31 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Property returns an Objective-C object with a +0 retain count +// CHECK: message +// CHECK: Property returns an Objective-C object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line63 +// CHECK: col31 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line64 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line64 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line64 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line64 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line64 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line64 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line64 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reference count incremented. The object now has a +1 retain count +// CHECK: message +// CHECK: Reference count incremented. The object now has a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line64 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line64 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line65 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line65 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'leaked' 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 'leaked' 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 'leaked' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextacquisitionViaProperty +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line65 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col35 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line69 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col37 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK: message +// CHECK: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line69 +// CHECK: col35 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line70 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col17 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reference count incremented. The object now has a +1 retain count +// CHECK: message +// CHECK: Reference count incremented. The object now has a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line70 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line71 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'leaked' 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 'leaked' 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 'leaked' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextacquisitionViaCFFunction +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line71 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line75 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col37 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line75 +// CHECK: col15 +// 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: kindevent +// CHECK: location +// CHECK: +// CHECK: line76 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line76 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object released by directly sending the '-dealloc' message +// CHECK: message +// CHECK: Object released by directly sending the '-dealloc' message +// 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: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line77 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line77 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line77 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line77 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reference-counted object is used after it is released +// CHECK: message +// CHECK: Reference-counted object is used after it is released +// CHECK: +// CHECK: +// CHECK: descriptionReference-counted object is used after it is released +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeUse-after-release +// CHECK: issue_context_kindfunction +// CHECK: issue_contextexplicitDealloc +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line77 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line81 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col37 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line81 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line82 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line82 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line82 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line82 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line82 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line82 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line82 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object released +// CHECK: message +// CHECK: Object released +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line82 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line82 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line83 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line83 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line83 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line83 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line83 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Reference-counted object is used after it is released +// CHECK: message +// CHECK: Reference-counted object is used after it is released +// CHECK: +// CHECK: +// CHECK: descriptionReference-counted object is used after it is released +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeUse-after-release +// CHECK: issue_context_kindfunction +// CHECK: issue_contextimplicitDealloc +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line83 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line87 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line87 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line87 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line87 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line87 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line87 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line87 +// CHECK: col37 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line87 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line87 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line88 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line88 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line88 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line88 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line88 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line88 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line88 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object sent -autorelease message +// CHECK: message +// CHECK: Object sent -autorelease message +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line88 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line88 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line89 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line89 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line89 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line89 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line89 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line89 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line89 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object sent -autorelease message +// CHECK: message +// CHECK: Object sent -autorelease message +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line89 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line89 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line90 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line90 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line90 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line90 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line90 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object over-autoreleased: object was sent -autorelease 2 times but the object has a +1 retain count +// CHECK: message +// CHECK: Object over-autoreleased: object was sent -autorelease 2 times but the object has a +1 retain count +// CHECK: +// CHECK: +// CHECK: descriptionObject sent -autorelease too many times +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeObject sent -autorelease too many times +// CHECK: issue_context_kindfunction +// CHECK: issue_contextoverAutorelease +// CHECK: issue_hash4 +// CHECK: location +// CHECK: +// CHECK: line90 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line94 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line94 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line94 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line94 +// CHECK: col31 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line94 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line94 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line94 +// CHECK: col31 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Property returns an Objective-C object with a +0 retain count +// CHECK: message +// CHECK: Property returns an Objective-C object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line94 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line94 +// CHECK: col31 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line95 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line95 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line95 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line95 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line95 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line95 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line95 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object sent -autorelease message +// CHECK: message +// CHECK: Object sent -autorelease message +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line95 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line95 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line96 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line96 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line96 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line96 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line96 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object over-autoreleased: object was sent -autorelease but the object has a +0 retain count +// CHECK: message +// CHECK: Object over-autoreleased: object was sent -autorelease but the object has a +0 retain count +// CHECK: +// CHECK: +// CHECK: descriptionObject sent -autorelease too many times +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeObject sent -autorelease too many times +// CHECK: issue_context_kindfunction +// CHECK: issue_contextautoreleaseUnowned +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line96 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line100 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line100 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line100 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line100 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line100 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line100 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line100 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK: message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line100 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line100 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line101 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col21 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col26 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument +// CHECK: message +// CHECK: When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line101 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line102 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col21 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col26 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument +// CHECK: message +// CHECK: When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line102 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line103 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line103 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line103 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line103 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line103 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object leaked: object allocated and stored into 'leaked' 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 'leaked' 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 'leaked' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak +// CHECK: issue_context_kindfunction +// CHECK: issue_contextmakeCollectableIgnored +// CHECK: issue_hash4 +// CHECK: location +// CHECK: +// CHECK: line103 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line107 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line107 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line107 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line107 +// CHECK: col35 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line107 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line107 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line107 +// CHECK: col37 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK: message +// CHECK: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line107 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line107 +// CHECK: col35 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line108 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line108 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line108 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line108 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line108 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line108 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line108 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line108 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line108 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line108 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: +// CHECK: +// CHECK: descriptionObject with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeMethod should return an owned object +// CHECK: issue_context_kindfunction +// CHECK: issue_contextCFCopyRuleViolation +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line108 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line112 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line112 +// CHECK: col11 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line112 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line112 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line112 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line112 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line112 +// CHECK: col40 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK: message +// CHECK: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line112 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line112 +// CHECK: col38 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line113 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line113 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line113 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line113 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line113 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line113 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line113 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK: message +// CHECK: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line113 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line113 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line113 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: 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 +// CHECK: message +// CHECK: 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 +// CHECK: +// CHECK: +// CHECK: descriptionPotential leak of an object stored into 'object' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak of returned object +// CHECK: issue_context_kindfunction +// CHECK: issue_contextCFGetRuleViolation +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line113 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col32 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line118 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col32 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Property returns an Objective-C object with a +0 retain count +// CHECK: message +// CHECK: Property returns an Objective-C object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line118 +// CHECK: col32 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line119 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line119 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line119 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: +// CHECK: +// CHECK: descriptionObject with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeMethod should return an owned object +// CHECK: issue_context_kindObjective-C method +// CHECK: issue_contextcopyViolation +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line119 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line123 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Subscript returns an Objective-C object with a +0 retain count +// CHECK: message +// CHECK: Subscript returns an Objective-C object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line123 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line124 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line124 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line124 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line124 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line124 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line124 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line124 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line124 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line124 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line124 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: +// CHECK: +// CHECK: descriptionObject with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeMethod should return an owned object +// CHECK: issue_context_kindObjective-C method +// CHECK: issue_contextcopyViolationIndexedSubscript +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line124 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line128 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Subscript returns an Objective-C object with a +0 retain count +// CHECK: message +// CHECK: Subscript returns an Objective-C object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line128 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line129 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line129 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line129 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line129 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line129 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line129 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line129 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line129 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line129 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line129 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: +// CHECK: +// CHECK: descriptionObject with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeMethod should return an owned object +// CHECK: issue_context_kindObjective-C method +// CHECK: issue_contextcopyViolationKeyedSubscript +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line129 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line133 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line133 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line133 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line133 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line133 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line133 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line133 +// CHECK: col32 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line133 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line133 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line134 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK: message +// CHECK: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line134 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line134 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: 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 +// CHECK: message +// CHECK: 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 +// CHECK: +// CHECK: +// CHECK: descriptionPotential leak of an object stored into 'result' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak of returned object +// CHECK: issue_context_kindObjective-C method +// CHECK: issue_contextgetViolation +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line134 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line138 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line138 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line138 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line138 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line138 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line138 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line138 +// CHECK: col32 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: message +// CHECK: Method returns an Objective-C object with a +1 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line138 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line138 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line139 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line139 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line139 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line139 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line139 +// CHECK: col22 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line139 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line139 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object sent -autorelease message +// CHECK: message +// CHECK: Object sent -autorelease message +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line139 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line139 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line140 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: message +// CHECK: Object returned to caller with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line140 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line140 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: message +// CHECK: Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: +// CHECK: +// CHECK: descriptionObject with a +0 retain count returned to caller where a +1 (owning) retain count is expected +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeMethod should return an owned object +// CHECK: issue_context_kindObjective-C method +// CHECK: issue_contextcopyAutorelease +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line140 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line168 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col16 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: NSNumber literal is an object with a +0 retain count +// CHECK: message +// CHECK: NSNumber literal is an object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line168 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line169 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line169 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line169 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line169 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line169 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: +// CHECK: +// CHECK: descriptionIncorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeBad release +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestNumericLiteral +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line169 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line173 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line173 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line173 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line173 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line173 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line173 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line173 +// CHECK: col18 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: NSNumber boxed expression produces an object with a +0 retain count +// CHECK: message +// CHECK: NSNumber boxed expression produces an object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line173 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line173 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line174 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line174 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line174 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line174 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line174 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: +// CHECK: +// CHECK: descriptionIncorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeBad release +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestBoxedInt +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line174 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line178 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line178 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line178 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line178 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line178 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line178 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line178 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: NSString boxed expression produces an object with a +0 retain count +// CHECK: message +// CHECK: NSString boxed expression produces an object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line178 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line178 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line179 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line179 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line179 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line179 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line179 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: +// CHECK: +// CHECK: descriptionIncorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeBad release +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestBoxedString +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line179 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line183 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line183 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line183 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line183 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line183 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line183 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line183 +// CHECK: col20 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: NSArray literal is an object with a +0 retain count +// CHECK: message +// CHECK: NSArray literal is an object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line183 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line183 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line184 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line184 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line184 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line184 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line184 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: +// CHECK: +// CHECK: descriptionIncorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeBad release +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestArray +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line184 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line188 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line188 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line188 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line188 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line188 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line188 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line188 +// CHECK: col27 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: NSDictionary literal is an object with a +0 retain count +// CHECK: message +// CHECK: NSDictionary literal is an object with a +0 retain count +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line188 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line188 +// CHECK: col15 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line189 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line189 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line189 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line189 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line189 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: message +// CHECK: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: +// CHECK: +// CHECK: descriptionIncorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeBad release +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttestDictionary +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line189 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 06c510e5dd3e..ba492b7b19a7 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -142,9 +142,13 @@ NSFastEnumerationState; @end @class NSString, NSDictionary; @interface NSValue : NSObject - (void)getValue:(void *)value; -@end @interface NSNumber : NSValue - (char)charValue; +@end +@interface NSNumber : NSValue +- (char)charValue; - (id)initWithInt:(int)value; -@end @class NSString; ++ (NSNumber *)numberWithInt:(int)value; +@end +@class NSString; @interface NSArray : NSObject - (NSUInteger)count; - (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt; @@ -195,7 +199,7 @@ 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 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)); // expected-note {{'IOServiceAddNotification' declared here}} kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification ); CFMutableDictionaryRef IOServiceMatching( const char * name ); CFMutableDictionaryRef IOServiceNameMatching( const char * name ); @@ -222,8 +226,10 @@ typedef struct CGLayer *CGLayerRef; @end @protocol NSValidatedUserInterfaceItem - (SEL)action; @end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id )anItem; @end @class NSDate, NSDictionary, NSError, NSException, NSNotification; +@class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; @interface NSApplication : NSResponder { } +- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo; @end enum { NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; typedef NSUInteger NSApplicationTerminateReply; @@ -231,7 +237,7 @@ typedef NSUInteger NSApplicationTerminateReply; @end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; @interface NSCell : NSObject { } -@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; +@end typedef struct { } CVTimeStamp; @@ -294,6 +300,9 @@ extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void); + (id)array; @end +// This is how NSMakeCollectable is declared in the OS X 10.8 headers. +id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained)); + //===----------------------------------------------------------------------===// // Test cases. @@ -747,7 +756,7 @@ typedef CFTypeRef OtherRef; @end //===----------------------------------------------------------------------===// -// false positive - init method returns an object +// false positive - init method returns an object // owned by caller //===----------------------------------------------------------------------===// @@ -1055,10 +1064,14 @@ typedef struct _opaque_pthread_t *__darwin_pthread_t; typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; typedef __darwin_pthread_t pthread_t; typedef __darwin_pthread_attr_t pthread_attr_t; +typedef unsigned long __darwin_pthread_key_t; +typedef __darwin_pthread_key_t pthread_key_t; int pthread_create(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *); +int pthread_setspecific(pthread_key_t key, const void *value); + void *rdar_7299394_start_routine(void *p) { [((id) p) release]; return 0; @@ -1071,6 +1084,16 @@ void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) { NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} } +//===----------------------------------------------------------------------===// +// false positive with not understanding thread +// local storage +//===----------------------------------------------------------------------===// + +void rdar11282706(pthread_key_t key) { + NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning + pthread_setspecific(key, (void*) number); +} + //===----------------------------------------------------------------------===// // False leak associated with call to // CVPixelBufferCreateWithBytes () @@ -1291,6 +1314,11 @@ void testattr2_b() { TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}} } +void testattr2_b_11358224_self_assign_looses_the_leak() { + TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}} + x = x; +} + void testattr2_c() { TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning [x release]; @@ -1427,8 +1455,7 @@ void test_blocks_1_indirect_release_via_call(void) { } 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 + NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning {{leak}} ^(NSObject *o){ [o retain]; }(number); } @@ -1667,6 +1694,58 @@ void rdar_10824732() { } } +// Stop tracking objects passed to functions, which take callbacks as parameters. +// radar://10973977 +typedef int (*CloseCallback) (void *); +void ReaderForIO(CloseCallback ioclose, void *ioctx); +int IOClose(void *context); + +@protocol SInS +@end + +@interface radar10973977 : NSObject +- (id)inputS; +- (void)reader; +@end + +@implementation radar10973977 +- (void)reader +{ + id inputS = [[self inputS] retain]; + ReaderForIO(IOClose, inputS); +} +- (id)inputS +{ + return 0; +} +@end + +// Object escapes through a selector callback: radar://11398514 +extern id NSApp; +@interface MySheetController +- (id)inputS; +- (void)showDoSomethingSheetAction:(id)action; +- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; +@end + +@implementation MySheetController +- (id)inputS { + return 0; +} +- (void)showDoSomethingSheetAction:(id)action { + id inputS = [[self inputS] retain]; + [NSApp beginSheet:0 + modalForWindow:0 + modalDelegate:0 + didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) + contextInfo:(void *)inputS]; // no - warning +} +- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { + + id contextObject = (id)contextInfo; + [contextObject release]; +} +@end //===----------------------------------------------------------------------===// // Test returning allocated memory in a struct. // @@ -1739,3 +1818,40 @@ void test_objc_arrays() { } } +void test_objc_integer_literals() { + id value = [@1 retain]; // expected-warning {{leak}} + [value description]; +} + +void test_objc_boxed_expressions(int x, const char *y) { + id value = [@(x) retain]; // expected-warning {{leak}} + [value description]; + + value = [@(y) retain]; // expected-warning {{leak}} + [value description]; +} + +// Test NSLog doesn't escape tracked objects. +void rdar11400885(int y) +{ + @autoreleasepool { + NSString *printString; + if(y > 2) + printString = [[NSString alloc] init]; + else + printString = [[NSString alloc] init]; + NSLog(@"Once %@", printString); + [printString release]; + NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}} + } +} + +id makeCollectableNonLeak() { + extern CFTypeRef CFCreateSomething(); + + CFTypeRef object = CFCreateSomething(); // +1 + CFRetain(object); // +2 + id objCObject = NSMakeCollectable(object); // +2 + [objCObject release]; // +1 + return [objCObject autorelease]; // +0 +} diff --git a/test/Analysis/self-init.m b/test/Analysis/self-init.m index d5151733430d..b0c51a2b37e1 100644 --- a/test/Analysis/self-init.m +++ b/test/Analysis/self-init.m @@ -1,7 +1,9 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties %s -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -analyzer-ipa=dynamic -fno-builtin %s -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -fno-builtin %s -verify @class NSZone, NSCoder; -@protocol NSObject- (id)self; +@protocol NSObject +- (id)self; @end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end @@ -254,3 +256,28 @@ extern id _commonInit(MyObj *self); return self; } @end + +// Test for radar://11125870: init constructing a special instance. +typedef signed char BOOL; +@interface MyClass : NSObject +@end +@implementation MyClass ++ (id)specialInstance { + return [[MyClass alloc] init]; +} +- (id)initSpecially:(BOOL)handleSpecially { + if ((self = [super init])) { + if (handleSpecially) { + self = [MyClass specialInstance]; + } + } + return self; +} +- (id)initSelfSelf { + if ((self = [super init])) { + self = self; + } + return self; +} +@end + diff --git a/test/Analysis/stack-addr-ps.cpp b/test/Analysis/stack-addr-ps.cpp index b09e43560830..b21a03dc38a4 100644 --- a/test/Analysis/stack-addr-ps.cpp +++ b/test/Analysis/stack-addr-ps.cpp @@ -84,3 +84,9 @@ struct TS { return x; } }; + +// rdar://11345441 +int* f5() { + int& i = i; // expected-warning {{Assigned value is garbage or undefined}} expected-note {{binding reference variable 'i' here}} + return &i; // expected-warning {{address of stack memory associated with local variable 'i' returned}} +} diff --git a/test/Analysis/string-fail.c b/test/Analysis/string-fail.c index 3bff6d40dd51..ac5c6d057235 100644 --- a/test/Analysis/string-fail.c +++ b/test/Analysis/string-fail.c @@ -1,5 +1,5 @@ -// 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 +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s // XFAIL: * // This file is for tests that may eventually go into string.c, or may be @@ -32,6 +32,7 @@ #define NULL 0 typedef typeof(sizeof(int)) size_t; +void clang_analyzer_eval(int); //===----------------------------------------------------------------------=== // strnlen() @@ -43,8 +44,7 @@ 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 + clang_analyzer_eval(strnlen(x, 10) < 5); // expected-warning{{FALSE}} } void strnlen_subregion() { @@ -57,43 +57,43 @@ void strnlen_subregion() { 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}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} use_two_stringsn(&z); size_t c = strnlen(z.a, 10); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } 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}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} use_stringn(x); size_t c = strnlen(x, 10); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } 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}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} // 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}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } void strnlen_indirect(char *x) { @@ -101,13 +101,13 @@ void strnlen_indirect(char *x) { char *p = x; char **p2 = &p; size_t b = strnlen(x, 10); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 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}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } diff --git a/test/Analysis/string.c b/test/Analysis/string.c index c0814b89c17c..32f5db3a9a43 100644 --- a/test/Analysis/string.c +++ b/test/Analysis/string.c @@ -1,7 +1,7 @@ -// 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 +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -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,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s //===----------------------------------------------------------------------=== // Declarations @@ -26,6 +26,9 @@ #define NULL 0 typedef typeof(sizeof(int)) size_t; + +void clang_analyzer_eval(int); + int scanf(const char *restrict format, ...); //===----------------------------------------------------------------------=== @@ -36,23 +39,20 @@ int scanf(const char *restrict format, ...); size_t strlen(const char *s); void strlen_constant0() { - if (strlen("123") != 3) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen("123") == 3); // expected-warning{{TRUE}} } void strlen_constant1() { const char *a = "123"; - if (strlen(a) != 3) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(a) == 3); // expected-warning{{TRUE}} } void strlen_constant2(char x) { char a[] = "123"; - if (strlen(a) != 3) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(a) == 3); // expected-warning{{TRUE}} + a[0] = x; - if (strlen(a) != 3) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strlen(a) == 3); // expected-warning{{UNKNOWN}} } size_t strlen_null() { @@ -78,43 +78,46 @@ void strlen_subregion() { 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}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} use_two_strings(&z); size_t c = strlen(z.a); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } 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}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} use_string(x); size_t c = strlen(x); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } 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}} + if (a == 0) { + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} + // Make sure clang_analyzer_eval does not invalidate globals. + clang_analyzer_eval(strlen(global_str) == 0); // expected-warning{{TRUE}} + } // 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}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } void strlen_indirect(char *x) { @@ -122,15 +125,15 @@ void strlen_indirect(char *x) { char *p = x; char **p2 = &p; size_t b = strlen(x); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 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}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } void strlen_indirect2(char *x) { @@ -141,15 +144,14 @@ void strlen_indirect2(char *x) { use_string_ptr2(p2); size_t c = strlen(x); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } void strlen_liveness(const char *x) { if (strlen(x) < 5) return; - if (strlen(x) < 5) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(x) < 5); // expected-warning{{FALSE}} } //===----------------------------------------------------------------------=== @@ -159,43 +161,35 @@ void strlen_liveness(const char *x) { size_t strnlen(const char *s, size_t maxlen); void strnlen_constant0() { - if (strnlen("123", 10) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen("123", 10) == 3); // expected-warning{{TRUE}} } void strnlen_constant1() { const char *a = "123"; - if (strnlen(a, 10) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{TRUE}} } void strnlen_constant2(char x) { char a[] = "123"; - if (strnlen(a, 10) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{TRUE}} a[0] = x; - if (strnlen(a, 10) != 3) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{UNKNOWN}} } void strnlen_constant4() { - if (strnlen("123456", 3) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen("123456", 3) == 3); // expected-warning{{TRUE}} } void strnlen_constant5() { const char *a = "123456"; - if (strnlen(a, 3) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{TRUE}} } void strnlen_constant6(char x) { char a[] = "123456"; - if (strnlen(a, 3) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{TRUE}} a[0] = x; - if (strnlen(a, 3) != 3) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{UNKNOWN}} } size_t strnlen_null() { @@ -212,10 +206,8 @@ label: } 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 + clang_analyzer_eval(strnlen("abc", 0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(strnlen(NULL, 0) == 0); // expected-warning{{TRUE}} } size_t strnlen_compound_literal() { @@ -230,40 +222,26 @@ size_t strnlen_unknown_limit(float f) { } void strnlen_is_not_strlen(char *x) { - if (strnlen(x, 10) != strlen(x)) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strnlen(x, 10) == strlen(x)); // expected-warning{{UNKNOWN}} } 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}} + clang_analyzer_eval(len <= 10); // expected-warning{{TRUE}} + clang_analyzer_eval(len == 10); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(len < 10); // expected-warning{{UNKNOWN}} } 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}} + clang_analyzer_eval(len <= 3); // expected-warning{{TRUE}} + // This is due to eager assertion in strnlen. + if (limit == 0) { + clang_analyzer_eval(len == 0); // expected-warning{{TRUE}} + } else { + clang_analyzer_eval(len == 3); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(len < 3); // expected-warning{{UNKNOWN}} + } } //===----------------------------------------------------------------------=== @@ -304,14 +282,9 @@ void strcpy_fn_const(char *x) { 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}} + clang_analyzer_eval(strcpy(x, y) == x); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{TRUE}} + clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}} } void strcpy_overflow(char *y) { @@ -348,14 +321,9 @@ char *stpcpy(char *restrict s1, const char *restrict s2); 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}} + clang_analyzer_eval(stpcpy(x, y) == &x[strlen(y)]); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{TRUE}} + clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}} } void stpcpy_overflow(char *y) { @@ -409,11 +377,8 @@ void strcat_effects(char *y) { 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 + clang_analyzer_eval(strcat(x, y) == x); // expected-warning{{TRUE}} + clang_analyzer_eval((int)strlen(x) == (orig_len + strlen(y))); // expected-warning{{TRUE}} } void strcat_overflow_0(char *y) { @@ -442,29 +407,25 @@ void strcat_no_overflow(char *y) { void strcat_symbolic_dst_length(char *dst) { strcat(dst, "1234"); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } void strcat_symbolic_src_length(char *src) { char dst[8] = "1234"; strcat(dst, src); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } 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 + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } 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 + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } // There is no strcat_unknown_dst_length because if we can't get a symbolic @@ -513,14 +474,9 @@ void strncpy_fn(char *x) { 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}} + clang_analyzer_eval(strncpy(x, y, 5) == x); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}} } void strncpy_overflow(char *y) { @@ -562,8 +518,7 @@ void strncpy_exactly_matching_buffer(char *y) { // 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}} + clang_analyzer_eval(strlen(x) > 4); // expected-warning{{UNKNOWN}} } void strncpy_exactly_matching_buffer2(char *y) { @@ -574,8 +529,18 @@ void strncpy_exactly_matching_buffer2(char *y) { 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 + clang_analyzer_eval(strlen(x) <= 3); // expected-warning{{TRUE}} +} + +void strncpy_zero(char *src) { + char dst[] = "123"; + strncpy(dst, src, 0); // no-warning +} + +void strncpy_empty() { + char dst[] = "123"; + char src[] = ""; + strncpy(dst, src, 4); // no-warning } //===----------------------------------------------------------------------=== @@ -617,11 +582,8 @@ void strncat_effects(char *y) { 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 + clang_analyzer_eval(strncat(x, y, strlen(y)) == x); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(x) == (orig_len + strlen(y))); // expected-warning{{TRUE}} } void strncat_overflow_0(char *y) { @@ -661,15 +623,13 @@ void strncat_no_overflow_2(char *y) { void strncat_symbolic_dst_length(char *dst) { strncat(dst, "1234", 5); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } void strncat_symbolic_src_length(char *src) { char dst[8] = "1234"; strncat(dst, src, 3); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} char dst2[8] = "1234"; strncat(dst2, src, 4); // expected-warning{{Size argument is greater than the free space in the destination buffer}} @@ -678,8 +638,7 @@ void strncat_symbolic_src_length(char *src) { 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 + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} char dst2[8] = "1234"; strncat(dst2, &src[offset], 4); // expected-warning{{Size argument is greater than the free space in the destination buffer}} @@ -692,20 +651,18 @@ 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}} + + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(dst) == 4); // expected-warning{{UNKNOWN}} } 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}} + + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(dst) == 4); // expected-warning{{UNKNOWN}} } void strncat_too_big(char *dst, char *src) { @@ -716,6 +673,17 @@ void strncat_too_big(char *dst, char *src) { strncat(dst, src, 2); // expected-warning{{This expression will create a string whose length is too big to be represented as a size_t}} } +void strncat_zero(char *src) { + char dst[] = "123"; + strncat(dst, src, 0); // no-warning +} + +void strncat_empty() { + char dst[8] = "123"; + char src[] = ""; + strncat(dst, src, 4); // no-warning +} + //===----------------------------------------------------------------------=== // strcmp() //===----------------------------------------------------------------------=== @@ -724,41 +692,35 @@ void strncat_too_big(char *dst, char *src) { int strcmp(const char * s1, const char * s2); void strcmp_constant0() { - if (strcmp("123", "123") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp("123", "123") == 0); // expected-warning{{TRUE}} } void strcmp_constant_and_var_0() { char *x = "123"; - if (strcmp(x, "123") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, "123") == 0); // expected-warning{{TRUE}} } void strcmp_constant_and_var_1() { char *x = "123"; - if (strcmp("123", x) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp("123", x) == 0); // expected-warning{{TRUE}} } void strcmp_0() { char *x = "123"; char *y = "123"; - if (strcmp(x, y) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == 0); // expected-warning{{TRUE}} } void strcmp_1() { char *x = "234"; char *y = "123"; - if (strcmp(x, y) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}} } void strcmp_2() { char *x = "123"; char *y = "234"; - if (strcmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}} } void strcmp_null_0() { @@ -776,39 +738,33 @@ void strcmp_null_1() { void strcmp_diff_length_0() { char *x = "12345"; char *y = "234"; - if (strcmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}} } void strcmp_diff_length_1() { char *x = "123"; char *y = "23456"; - if (strcmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}} } void strcmp_diff_length_2() { char *x = "12345"; char *y = "123"; - if (strcmp(x, y) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}} } void strcmp_diff_length_3() { char *x = "123"; char *y = "12345"; - if (strcmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}} } void strcmp_embedded_null () { - if (strcmp("\0z", "\0y") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp("\0z", "\0y") == 0); // expected-warning{{TRUE}} } void strcmp_unknown_arg (char *unknown) { - if (strcmp(unknown, unknown) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(unknown, unknown) == 0); // expected-warning{{TRUE}} } //===----------------------------------------------------------------------=== @@ -819,41 +775,35 @@ void strcmp_unknown_arg (char *unknown) { 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 + clang_analyzer_eval(strncmp("123", "123", 3) == 0); // expected-warning{{TRUE}} } void strncmp_constant_and_var_0() { char *x = "123"; - if (strncmp(x, "123", 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, "123", 3) == 0); // expected-warning{{TRUE}} } void strncmp_constant_and_var_1() { char *x = "123"; - if (strncmp("123", x, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp("123", x, 3) == 0); // expected-warning{{TRUE}} } void strncmp_0() { char *x = "123"; char *y = "123"; - if (strncmp(x, y, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == 0); // expected-warning{{TRUE}} } void strncmp_1() { char *x = "234"; char *y = "123"; - if (strncmp(x, y, 3) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == 1); // expected-warning{{TRUE}} } void strncmp_2() { char *x = "123"; char *y = "234"; - if (strncmp(x, y, 3) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}} } void strncmp_null_0() { @@ -871,55 +821,47 @@ void strncmp_null_1() { void strncmp_diff_length_0() { char *x = "12345"; char *y = "234"; - if (strncmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncmp_diff_length_1() { char *x = "123"; char *y = "23456"; - if (strncmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncmp_diff_length_2() { char *x = "12345"; char *y = "123"; - if (strncmp(x, y, 5) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 5) == 1); // expected-warning{{TRUE}} } void strncmp_diff_length_3() { char *x = "123"; char *y = "12345"; - if (strncmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncmp_diff_length_4() { char *x = "123"; char *y = "12345"; - if (strncmp(x, y, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == 0); // expected-warning{{TRUE}} } void strncmp_diff_length_5() { char *x = "012"; char *y = "12345"; - if (strncmp(x, y, 3) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}} } void strncmp_diff_length_6() { char *x = "234"; char *y = "12345"; - if (strncmp(x, y, 3) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == 1); // expected-warning{{TRUE}} } void strncmp_embedded_null () { - if (strncmp("ab\0zz", "ab\0yy", 4) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp("ab\0zz", "ab\0yy", 4) == 0); // expected-warning{{TRUE}} } //===----------------------------------------------------------------------=== @@ -930,41 +872,35 @@ void strncmp_embedded_null () { int strcasecmp(const char *s1, const char *s2); void strcasecmp_constant0() { - if (strcasecmp("abc", "Abc") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp("abc", "Abc") == 0); // expected-warning{{TRUE}} } void strcasecmp_constant_and_var_0() { char *x = "abc"; - if (strcasecmp(x, "Abc") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, "Abc") == 0); // expected-warning{{TRUE}} } void strcasecmp_constant_and_var_1() { char *x = "abc"; - if (strcasecmp("Abc", x) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp("Abc", x) == 0); // expected-warning{{TRUE}} } void strcasecmp_0() { char *x = "abc"; char *y = "Abc"; - if (strcasecmp(x, y) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == 0); // expected-warning{{TRUE}} } void strcasecmp_1() { char *x = "Bcd"; char *y = "abc"; - if (strcasecmp(x, y) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == 1); // expected-warning{{TRUE}} } void strcasecmp_2() { char *x = "abc"; char *y = "Bcd"; - if (strcasecmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}} } void strcasecmp_null_0() { @@ -982,34 +918,29 @@ void strcasecmp_null_1() { void strcasecmp_diff_length_0() { char *x = "abcde"; char *y = "aBd"; - if (strcasecmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}} } void strcasecmp_diff_length_1() { char *x = "abc"; char *y = "aBdef"; - if (strcasecmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}} } void strcasecmp_diff_length_2() { char *x = "aBcDe"; char *y = "abc"; - if (strcasecmp(x, y) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == 1); // expected-warning{{TRUE}} } void strcasecmp_diff_length_3() { char *x = "aBc"; char *y = "abcde"; - if (strcasecmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}} } void strcasecmp_embedded_null () { - if (strcasecmp("ab\0zz", "ab\0yy") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp("ab\0zz", "ab\0yy") == 0); // expected-warning{{TRUE}} } //===----------------------------------------------------------------------=== @@ -1020,41 +951,35 @@ void strcasecmp_embedded_null () { 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 + clang_analyzer_eval(strncasecmp("abc", "Abc", 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_constant_and_var_0() { char *x = "abc"; - if (strncasecmp(x, "Abc", 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, "Abc", 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_constant_and_var_1() { char *x = "abc"; - if (strncasecmp("Abc", x, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp("Abc", x, 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_0() { char *x = "abc"; char *y = "Abc"; - if (strncasecmp(x, y, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_1() { char *x = "Bcd"; char *y = "abc"; - if (strncasecmp(x, y, 3) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == 1); // expected-warning{{TRUE}} } void strncasecmp_2() { char *x = "abc"; char *y = "Bcd"; - if (strncasecmp(x, y, 3) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == -1); // expected-warning{{TRUE}} } void strncasecmp_null_0() { @@ -1072,53 +997,45 @@ void strncasecmp_null_1() { void strncasecmp_diff_length_0() { char *x = "abcde"; char *y = "aBd"; - if (strncasecmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_1() { char *x = "abc"; char *y = "aBdef"; - if (strncasecmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_2() { char *x = "aBcDe"; char *y = "abc"; - if (strncasecmp(x, y, 5) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 5) == 1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_3() { char *x = "aBc"; char *y = "abcde"; - if (strncasecmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_4() { char *x = "abcde"; char *y = "aBc"; - if (strncasecmp(x, y, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_diff_length_5() { char *x = "abcde"; char *y = "aBd"; - if (strncasecmp(x, y, 3) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == -1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_6() { char *x = "aBDe"; char *y = "abc"; - if (strncasecmp(x, y, 3) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == 1); // expected-warning{{TRUE}} } void strncasecmp_embedded_null () { - if (strncasecmp("ab\0zz", "ab\0yy", 4) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp("ab\0zz", "ab\0yy", 4) == 0); // expected-warning{{TRUE}} } diff --git a/test/Analysis/svalbuilder-logic.c b/test/Analysis/svalbuilder-logic.c new file mode 100644 index 000000000000..bc79f859053c --- /dev/null +++ b/test/Analysis/svalbuilder-logic.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -verify %s + +// Testing core functionality of the SValBuilder. + +int SValBuilderLogicNoCrash(int *x) { + return 3 - (int)(x +3); +} diff --git a/test/Analysis/system-header-simulator-objc.h b/test/Analysis/system-header-simulator-objc.h index 92d5899abf8d..a647b3740406 100644 --- a/test/Analysis/system-header-simulator-objc.h +++ b/test/Analysis/system-header-simulator-objc.h @@ -85,7 +85,13 @@ typedef double NSTimeInterval; - (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; ++ (id)stringWithString:(NSString *)string; @end @class NSString, NSURL, NSError; + +@interface NSMutableString : NSString +- (void)appendFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); +@end + @interface NSData : NSObject - (NSUInteger)length; + (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; + (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; @@ -112,3 +118,13 @@ 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); + +void SystemHeaderFunctionWithBlockParam(void *, void (^block)(void *), unsigned); + +@interface NSPointerArray : NSObject +- (void)addPointer:(void *)pointer; +- (void)insertPointer:(void *)item atIndex:(NSUInteger)index; +- (void)replacePointerAtIndex:(NSUInteger)index withPointer:(void *)item; +- (void *)pointerAtIndex:(NSUInteger)index; +@end + diff --git a/test/Analysis/system-header-simulator.h b/test/Analysis/system-header-simulator.h index 6212131071de..5790fb9cff4a 100644 --- a/test/Analysis/system-header-simulator.h +++ b/test/Analysis/system-header-simulator.h @@ -36,3 +36,27 @@ FILE *funopen(const void *, fpos_t (*)(void *, fpos_t, int), int (*)(void *)); +int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*)); + +typedef void (*freeCallback) (void*); +typedef struct { + int i; + freeCallback fc; +} StWithCallback; + +int dealocateMemWhenDoneByVal(void*, StWithCallback); +int dealocateMemWhenDoneByRef(StWithCallback*, const void*); + +typedef struct CGContext *CGContextRef; +CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height, + size_t bitsPerComponent, size_t bytesPerRow, + CGColorSpaceRef space, + CGBitmapInfo bitmapInfo*/); +void *CGBitmapContextGetData(CGContextRef context); + +// Include xpc. +typedef struct _xpc_connection_s * xpc_connection_t; +typedef void (*xpc_finalizer_t)(void *value); +void xpc_connection_set_context(xpc_connection_t connection, void *context); +void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer); +void xpc_connection_resume(xpc_connection_t connection); diff --git a/test/Analysis/taint-generic.c b/test/Analysis/taint-generic.c index b00372a3ffbd..8ee1896e96e9 100644 --- a/test/Analysis/taint-generic.c +++ b/test/Analysis/taint-generic.c @@ -183,3 +183,32 @@ void testTaintedVLASize() { scanf("%d", &x); int vla[x]; // expected-warning{{Declared variable-length array (VLA) has tainted size}} } + +// This computation used to take a very long time. +#define longcmp(a,b,c) { \ + a -= c; a ^= c; c += b; b -= a; b ^= (a<<6) | (a >> (32-b)); a += c; c -= b; c ^= b; b += a; \ + a -= c; a ^= c; c += b; b -= a; b ^= a; a += c; c -= b; c ^= b; b += a; } + +unsigned radar11369570_hanging(const unsigned char *arr, int l) { + unsigned a, b, c; + a = b = c = 0x9899e3 + l; + while (l >= 6) { + unsigned t; + scanf("%d", &t); + a += b; + a ^= a; + a += (arr[3] + ((unsigned) arr[2] << 8) + ((unsigned) arr[1] << 16) + ((unsigned) arr[0] << 24)); + longcmp(a, t, c); + l -= 12; + } + return 5/a; // expected-warning {{Division by a tainted value, possibly zero}} +} + +// Check that we do not assert of the following code. +int SymSymExprWithDiffTypes(void* p) { + int i; + scanf("%d", &i); + int j = (i % (int)(long)p); + return 5/j; // expected-warning {{Division by a tainted value, possibly zero}} +} + diff --git a/test/Analysis/taint-tester.c b/test/Analysis/taint-tester.c index 377333505e18..a83ee32baca8 100644 --- a/test/Analysis/taint-tester.c +++ b/test/Analysis/taint-tester.c @@ -40,7 +40,7 @@ void taintTracking(int x) { // 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; + int _addrDeref = addrDeref; // expected-warning + {{tainted}} // Tainted struct address, casts. struct XYStruct *xyPtr = 0; diff --git a/test/Analysis/temp-obj-dtors-cfg-output.cpp b/test/Analysis/temp-obj-dtors-cfg-output.cpp index 53ab211615c3..6dbbc821bbbb 100644 --- a/test/Analysis/temp-obj-dtors-cfg-output.cpp +++ b/test/Analysis/temp-obj-dtors-cfg-output.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors -cfg-add-initializers %s 2>&1 | FileCheck %s +// RUN: rm -f %t +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s > %t 2>&1 +// RUN: FileCheck --input-file=%t %s // XPASS: * class A { @@ -106,9 +108,88 @@ TestCtorInits::TestCtorInits() : a(int(A()) + int(B())) , b() {} +// 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: 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() (Temporary object destructor) +// CHECK: 7: return [B1.5]; +// 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: false +// 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: 0 +// CHECK: 2: return [B1.1]; +// CHECK: Preds (1): B2 +// 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: [B1 (ENTRY)] +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B2 (ENTRY)] +// CHECK: Succs (1): B1 +// CHECK: [B1] +// CHECK: 1: true +// 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: 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: 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() (Temporary object destructor) +// CHECK: 7: return [B1.5]; +// 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) @@ -150,7 +231,7 @@ TestCtorInits::TestCtorInits() // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B10 (ENTRY)] -// CHECK: Succs (1): B8 +// CHECK: Succs (1): B9 // CHECK: [B1] // CHECK: 1: ~A() (Temporary object destructor) // CHECK: 2: int b; @@ -161,62 +242,62 @@ TestCtorInits::TestCtorInits() // CHECK: Preds (1): B3 // CHECK: Succs (1): B1 // CHECK: [B3] -// CHECK: 1: [B4.6] && [B5.5] +// CHECK: 1: [B5.6] && [B4.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: T: [B5.6] && ... +// CHECK: Preds (2): B4 B5 // CHECK: Succs (2): B2 B1 // CHECK: [B4] +// CHECK: 1: B() (CXXConstructExpr, class B) +// CHECK: 2: [B4.1] (BindTemporary) +// CHECK: 3: [B4.2].operator _Bool +// CHECK: 4: [B4.3]() +// CHECK: 5: [B4.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) +// CHECK: Preds (1): B5 +// CHECK: Succs (1): B3 +// CHECK: [B5] // 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: 3: [B5.2] (BindTemporary) +// CHECK: 4: [B5.3].operator _Bool +// CHECK: 5: [B5.4]() +// CHECK: 6: [B5.5] (ImplicitCastExpr, UserDefinedConversion, _Bool) +// CHECK: T: [B5.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: Succs (2): B4 B3 // CHECK: [B6] // CHECK: 1: ~B() (Temporary object destructor) // CHECK: Preds (1): B7 -// CHECK: Succs (1): B4 +// CHECK: Succs (1): B5 // CHECK: [B7] -// CHECK: 1: [B8.5] && [B9.5] +// CHECK: 1: [B9.5] && [B8.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: T: [B9.5] && ... +// CHECK: Preds (2): B8 B9 +// CHECK: Succs (2): B6 B5 // CHECK: [B8] -// CHECK: 1: A() (CXXConstructExpr, class A) +// CHECK: 1: B() (CXXConstructExpr, class B) // 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: Preds (1): B9 +// CHECK: Succs (1): B7 // CHECK: [B9] -// CHECK: 1: B() (CXXConstructExpr, class B) +// CHECK: 1: A() (CXXConstructExpr, class A) // 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: T: [B9.5] && ... +// CHECK: Preds (1): B10 +// CHECK: Succs (2): B8 B7 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B10 (ENTRY)] -// CHECK: Succs (1): B8 +// CHECK: Succs (1): B9 // CHECK: [B1] // CHECK: 1: ~A() (Temporary object destructor) // CHECK: 2: int b; @@ -227,58 +308,58 @@ TestCtorInits::TestCtorInits() // CHECK: Preds (1): B3 // CHECK: Succs (1): B1 // CHECK: [B3] -// CHECK: 1: [B4.6] || [B5.5] +// CHECK: 1: [B5.6] || [B4.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: T: [B5.6] || ... +// CHECK: Preds (2): B4 B5 // CHECK: Succs (2): B1 B2 // CHECK: [B4] +// CHECK: 1: B() (CXXConstructExpr, class B) +// CHECK: 2: [B4.1] (BindTemporary) +// CHECK: 3: [B4.2].operator _Bool +// CHECK: 4: [B4.3]() +// CHECK: 5: [B4.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) +// CHECK: Preds (1): B5 +// CHECK: Succs (1): B3 +// CHECK: [B5] // 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: 3: [B5.2] (BindTemporary) +// CHECK: 4: [B5.3].operator _Bool +// CHECK: 5: [B5.4]() +// CHECK: 6: [B5.5] (ImplicitCastExpr, UserDefinedConversion, _Bool) +// CHECK: T: [B5.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: Succs (2): B3 B4 // CHECK: [B6] // CHECK: 1: ~B() (Temporary object destructor) // CHECK: Preds (1): B7 -// CHECK: Succs (1): B4 +// CHECK: Succs (1): B5 // CHECK: [B7] -// CHECK: 1: [B8.5] || [B9.5] +// CHECK: 1: [B9.5] || [B8.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: T: [B9.5] || ... +// CHECK: Preds (2): B8 B9 +// CHECK: Succs (2): B5 B6 // CHECK: [B8] -// CHECK: 1: A() (CXXConstructExpr, class A) +// CHECK: 1: B() (CXXConstructExpr, class B) // 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: Preds (1): B9 +// CHECK: Succs (1): B7 // CHECK: [B9] -// CHECK: 1: B() (CXXConstructExpr, class B) +// CHECK: 1: A() (CXXConstructExpr, class A) // 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: T: [B9.5] || ... +// CHECK: Preds (1): B10 +// CHECK: Succs (2): B7 B8 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B11 (ENTRY)] diff --git a/test/Analysis/templates.cpp b/test/Analysis/templates.cpp new file mode 100644 index 000000000000..671aa7858204 --- /dev/null +++ b/test/Analysis/templates.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fblocks -verify %s + +void clang_analyzer_eval(bool); + +// Do not crash on this templated code which uses a block. +typedef void (^my_block)(void); +static void useBlock(my_block block){} +template class MyClass; +typedef MyClass Mf; + +template +class MyClass +{ +public: + MyClass() {} + MyClass(T a); + void I(); +private: + static const T one; +}; + +template const T MyClass::one = static_cast(1); +template inline MyClass::MyClass(T a){} +template void MyClass::I() { + static MyClass* mPtr = 0; + useBlock(^{ mPtr = new MyClass (MyClass::one); }); +}; +int main(){ + Mf m; + m.I(); +} + + +// +template +inline unsigned array_lengthof(T (&)[N]) { + return N; +} + +void testNonTypeTemplateInstantiation() { + const char *S[] = { "a", "b" }; + clang_analyzer_eval(array_lengthof(S) == 2); // expected-warning{{TRUE}} +} + diff --git a/test/Analysis/test-variably-modified-types.c b/test/Analysis/test-variably-modified-types.c new file mode 100644 index 000000000000..a833434228d1 --- /dev/null +++ b/test/Analysis/test-variably-modified-types.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyze-function=testVariablyModifiedTypes -verify %s + +// Test that we process variably modified type correctly - the call graph construction should pick up function_with_bug while recursively visiting test_variably_modifiable_types. +unsigned getArraySize(int *x) { + if (!x) + return *x; // expected-warning {{Dereference of null pointer}} + return 1; +} + +int testVariablyModifiedTypes(int *x) { + int mytype[getArraySize(x)]; + return 0; +} diff --git a/test/Analysis/traversal-algorithm.mm b/test/Analysis/traversal-algorithm.mm new file mode 100644 index 000000000000..8a3dc8b3a222 --- /dev/null +++ b/test/Analysis/traversal-algorithm.mm @@ -0,0 +1,213 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpTraversal -analyzer-max-loop 4 -std=c++11 %s | FileCheck -check-prefix=DFS %s + +int a(); +int b(); +int c(); + +int work(); + +void test(id input) { + if (a()) { + if (a()) + b(); + else + c(); + } else { + if (b()) + a(); + else + c(); + } + + if (a()) + work(); +} + +void testLoops(id input) { + while (a()) { + work(); + work(); + work(); + } + + for (int i = 0; i != b(); ++i) { + work(); + } + + for (id x in input) { + work(); + work(); + work(); + } + + int z[] = {1,2,3}; + for (int y : z) { + work(); + work(); + work(); + } +} + +// This ordering assumes that false cases happen before the true cases. + +// DFS:27 WhileStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:27 WhileStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:27 WhileStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:27 WhileStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:10 IfStmt +// DFS-next:16 IfStmt +// DFS-next:22 IfStmt +// DFS-next:--END PATH-- +// DFS-next:--END PATH-- +// DFS-next:22 IfStmt +// DFS-next:--END PATH-- +// DFS-next:--END PATH-- +// DFS-next:11 IfStmt +// DFS-next:22 IfStmt +// DFS-next:--END PATH-- +// DFS-next:--END PATH-- +// DFS-next:22 IfStmt +// DFS-next:--END PATH-- +// DFS-next:--END PATH-- + diff --git a/test/Analysis/uninit-sometimes.cpp b/test/Analysis/uninit-sometimes.cpp new file mode 100644 index 000000000000..7825e8734616 --- /dev/null +++ b/test/Analysis/uninit-sometimes.cpp @@ -0,0 +1,387 @@ +// RUN: %clang_cc1 -std=gnu++11 -Wsometimes-uninitialized -verify %s +// RUN: %clang_cc1 -std=gnu++11 -Wsometimes-uninitialized -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s + +bool maybe(); + +int test_if_false(bool b) { + int x; // expected-note {{variable}} + if (b) // expected-warning {{whenever 'if' condition is false}} \ + // expected-note {{remove the 'if' if its condition is always true}} + x = 1; + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{8:3-10:5}:"" +// CHECK: fix-it:"{{.*}}":{7:8-7:8}:" = 0" + + +int test_if_true(bool b) { + int x; // expected-note {{variable}} + if (b) {} // expected-warning {{whenever 'if' condition is true}} \ + // expected-note {{remove the 'if' if its condition is always false}} + else x = 1; + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{20:3-22:8}:"" +// CHECK: fix-it:"{{.*}}":{19:8-19:8}:" = 0" + + +int test_while_false(bool b) { + int x; // expected-note {{variable}} + while (b) { // expected-warning {{whenever 'while' loop exits because its condition is false}} \ + // expected-note {{remove the condition if it is always true}} + if (maybe()) { + x = 1; + break; + } + }; + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{32:10-32:11}:"true" +// CHECK: fix-it:"{{.*}}":{31:8-31:8}:" = 0" + + +int test_while_true(bool b) { + int x; // expected-note {{variable}} + while (b) { // expected-warning {{whenever 'while' loop is entered}} \ + // expected-note {{remove the condition if it is always false}} +label: + return x; // expected-note {{uninitialized use}} + } + x = 0; + goto label; +} + +// CHECK: fix-it:"{{.*}}":{48:10-48:11}:"false" +// CHECK: fix-it:"{{.*}}":{47:8-47:8}:" = 0" + + +int test_do_while_false(bool b) { + int x; // expected-note {{variable}} + do { + if (maybe()) { + x = 1; + break; + } + } while (b); // expected-warning {{whenever 'do' loop exits because its condition is false}} \ + // expected-note {{remove the condition if it is always true}} + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{68:12-68:13}:"true" +// CHECK: fix-it:"{{.*}}":{62:8-62:8}:" = 0" + + +int test_do_while_true(bool b) { + int x; // expected-note {{variable}} +goto label2; + do { +label1: + return x; // expected-note {{uninitialized use}} +label2: ; + } while (b); // expected-warning {{whenever 'do' loop condition is true}} \ + // expected-note {{remove the condition if it is always false}} + x = 0; + goto label1; +} + +// CHECK: fix-it:"{{.*}}":{84:12-84:13}:"false" +// CHECK: fix-it:"{{.*}}":{78:8-78:8}:" = 0" + + +int test_for_false(int k) { + int x; // expected-note {{variable}} + for (int n = 0; + n < k; // expected-warning {{whenever 'for' loop exits because its condition is false}} \ + // expected-note {{remove the condition if it is always true}} + ++n) { + if (maybe()) { + x = n; + break; + } + } + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{97:8-97:13}:"" +// CHECK: fix-it:"{{.*}}":{95:8-95:8}:" = 0" + + +int test_for_true(int k) { + int x; // expected-note {{variable}} + int n = 0; + for (; + n < k; // expected-warning {{whenever 'for' loop is entered}} \ + // expected-note {{remove the condition if it is always false}} + ++n) { +label: + return x; // expected-note {{uninitialized use}} + } + x = 1; + goto label; +} + +// CHECK: fix-it:"{{.*}}":{116:8-116:13}:"false" +// CHECK: fix-it:"{{.*}}":{113:8-113:8}:" = 0" + + +int test_for_range_false(int k) { + int arr[3] = { 1, 2, 3 }; + int x; + for (int &a : arr) { // no-warning, condition was not explicitly specified + if (a == k) { + x = &a - arr; + break; + } + } + return x; +} + + + + + +int test_for_range_true(int k) { + int arr[3] = { 1, 2, 3 }; + int x; + for (int &a : arr) { // no-warning + goto label; + } + x = 0; +label: + return x; +} + + + + + +int test_conditional_false(int k) { + int x; // expected-note {{variable}} + (void)( + maybe() // expected-warning {{whenever '?:' condition is false}} \ + // expected-note {{remove the '?:' if its condition is always true}} + ? x = 1 : 0); + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{164:7-166:9}:"" +// CHECK: fix-it:"{{.*}}":{166:14-166:18}:"" +// CHECK: fix-it:"{{.*}}":{162:8-162:8}:" = 0" + +int test_conditional_true(int k) { + int x; // expected-note {{variable}} + (void)( + maybe() // expected-warning {{whenever '?:' condition is true}} \ + // expected-note {{remove the '?:' if its condition is always false}} + ? 0 : x = 1); + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{177:7-179:13}:"" +// CHECK: fix-it:"{{.*}}":{175:8-175:8}:" = 0" + + +int test_logical_and_false(int k) { + int x; // expected-note {{variable}} + maybe() // expected-warning {{whenever '&&' condition is false}} \ + // expected-note {{remove the '&&' if its condition is always true}} + && (x = 1); + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{189:3-191:9}:"" +// CHECK: fix-it:"{{.*}}":{188:8-188:8}:" = 0" + + +int test_logical_and_true(int k) { + int x; // expected-note {{variable}} + maybe() // expected-warning {{whenever '&&' condition is true}} \ + // expected-note {{remove the '&&' if its condition is always false}} + && ({ goto skip_init; 0; }); + x = 1; +skip_init: + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{201:3-203:34}:"false" +// CHECK: fix-it:"{{.*}}":{200:8-200:8}:" = 0" + + +int test_logical_or_false(int k) { + int x; // expected-note {{variable}} + maybe() // expected-warning {{whenever '||' condition is false}} \ + // expected-note {{remove the '||' if its condition is always true}} + || ({ goto skip_init; 0; }); + x = 1; +skip_init: + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{215:3-217:34}:"true" +// CHECK: fix-it:"{{.*}}":{214:8-214:8}:" = 0" + + +int test_logical_or_true(int k) { + int x; // expected-note {{variable}} + maybe() // expected-warning {{whenever '||' condition is true}} \ + // expected-note {{remove the '||' if its condition is always false}} + || (x = 1); + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{229:3-231:9}:"" +// CHECK: fix-it:"{{.*}}":{228:8-228:8}:" = 0" + + +int test_switch_case(int k) { + int x; // expected-note {{variable}} + switch (k) { + case 0: + x = 0; + break; + case 1: // expected-warning {{whenever switch case is taken}} + break; + } + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{240:8-240:8}:" = 0" + + + +int test_switch_default(int k) { + int x; // expected-note {{variable}} + switch (k) { + case 0: + x = 0; + break; + case 1: + x = 1; + break; + default: // expected-warning {{whenever switch default is taken}} + break; + } + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{256:8-256:8}:" = 0" + + + +int test_switch_suppress_1(int k) { + int x; + switch (k) { + case 0: + x = 0; + break; + case 1: + x = 1; + break; + } + return x; // no-warning +} + + + + + +int test_switch_suppress_2(int k) { + int x; + switch (k) { + case 0: + case 1: + switch (k) { + case 0: + return 0; + case 1: + return 1; + } + case 2: + case 3: + x = 1; + } + return x; // no-warning +} + + + + + +int test_multiple_notes(int k) { + int x; // expected-note {{variable}} + if (k > 0) { + if (k == 5) + x = 1; + else if (k == 2) // expected-warning {{whenever 'if' condition is false}} \ + // expected-note {{remove the 'if' if its condition is always true}} + x = 2; + } else { + if (k == -5) + x = 3; + else if (k == -2) // expected-warning {{whenever 'if' condition is false}} \ + // expected-note {{remove the 'if' if its condition is always true}} + x = 4; + } + return x; // expected-note 2{{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{324:10-326:7}:"" +// CHECK: fix-it:"{{.*}}":{318:10-320:7}:"" +// CHECK: fix-it:"{{.*}}":{314:8-314:8}:" = 0" + +int test_no_false_positive_1(int k) { + int x; + if (k) + x = 5; + while (!k) + maybe(); + return x; +} + + + + + +int test_no_false_positive_2() { + int x; + bool b = false; + if (maybe()) { + x = 5; + b = true; + } + return b ? x : 0; +} + + +// FIXME: In this case, the variable is used uninitialized whenever the +// function's entry block is reached. Produce a diagnostic saying that +// the variable is uninitialized the first time it is used. +void test_null_pred_succ() { + int x; + if (0) + foo: x = 0; + if (x) + goto foo; +} + + + + +void foo(); +int PR13360(bool b) { + int x; // expected-note {{variable}} + if (b) { // expected-warning {{variable 'x' is used uninitialized whenever 'if' condition is true}} expected-note {{remove}} + do { + foo(); + } while (0); + } else { + x = 1; + } + return x; // expected-note {{uninitialized use occurs here}} +} + +// CHECK: fix-it:"{{.*}}":{376:3-380:10}:"" +// CHECK: fix-it:"{{.*}}":{375:8-375:8}:" = 0" diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m index 894184078039..f04132ba4570 100644 --- a/test/Analysis/unused-ivars.m +++ b/test/Analysis/unused-ivars.m @@ -108,3 +108,24 @@ int radar_7254495(RDar7254495 *a) { @implementation RDar8481311 @end + +@class NSString; +@interface Radar11059352_1 { +@private + NSString *_pathString; +} +@property (readonly, strong) NSString *pathString; +@end + +@interface Radar11059352 { +@private +Radar11059352_1 *_workspacePath; +} +@end + +@implementation Radar11059352 + +- (void)useWorkspace { + NSString *workspacePathString = _workspacePath.pathString; +} +@end \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ae9de78d19ad..8184c3d3638a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,117 +1,93 @@ -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") +# Test runner infrastructure for Clang. This configures the Clang test trees +# for use by Lit, and delegates to LLVM's lit test handlers. +# +# If this is a stand-alone Clang build, we fake up our own Lit support here +# rather than relying on LLVM's. -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( +configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) -configure_file( +configure_lit_site_cfg( ${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() - 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 () + +if( NOT CLANG_BUILT_STANDALONE ) - 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(CLANG_TEST_DEPS + clang clang-headers + c-index-test diagtool arcmt-test c-arcmt-test + clang-check + llvm-dis llc opt FileCheck count not + ) + set(CLANG_TEST_PARAMS + clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) - set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") - separate_arguments(LIT_ARGS) + if(LLVM_INCLUDE_TESTS) + list(APPEND CLANG_TEST_DEPS ClangUnitTests) + list(APPEND CLANG_TEST_PARAMS + clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + ) + endif() + add_lit_testsuite(check-clang "Running the Clang regression tests" + ${CMAKE_CURRENT_BINARY_DIR} + PARAMS ${CLANG_TEST_PARAMS} + DEPENDS ${CLANG_TEST_DEPS} + ARGS ${CLANG_TEST_EXTRA_ARGS} + ) + set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") + +else() - add_custom_target(clang-test.deps) - set_target_properties(clang-test.deps PROPERTIES FOLDER "Clang tests") + include(FindPythonInterp) + if(PYTHONINTERP_FOUND) + if( LLVM_MAIN_SRC_DIR ) + set(LIT "${LLVM_MAIN_SRC_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() - 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") + set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") + separate_arguments(LIT_ARGS) - if( NOT CLANG_BUILT_STANDALONE ) - add_custom_target(check-all + add_custom_target(check-clang 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 - ) + ${LIT} + --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/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" + DEPENDS clang clang-headers + c-index-test diagtool arcmt-test c-arcmt-test + clang-check + ) + set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") 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() + +# Add a legacy target spelling: clang-test +add_custom_target(clang-test) +add_dependencies(clang-test check-clang) +set_target_properties(clang-test PROPERTIES FOLDER "Clang tests") diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp new file mode 100644 index 000000000000..f812ea1bd8be --- /dev/null +++ b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fdiagnostics-show-option -verify %s + +template +struct set{}; +struct Value { + template + void set(T value) {} + + 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); + } + { + 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/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp new file mode 100644 index 000000000000..792545453e73 --- /dev/null +++ b/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +struct A { void f(); }; +struct C { void f(); }; +struct B : A { typedef A X; }; +struct D : C { typedef C X; void g(); }; + +void D::g() +{ + B * b = new B; + b->X::f(); // lookup for X finds B::X +} + +typedef int X; +void h(void) +{ + B * b = new B; + b->X::f(); // lookup for X finds B::X +} + + diff --git a/test/CXX/basic/basic.types/p10.cpp b/test/CXX/basic/basic.types/p10.cpp index 83b910b60640..191d42bebd83 100644 --- a/test/CXX/basic/basic.types/p10.cpp +++ b/test/CXX/basic/basic.types/p10.cpp @@ -22,11 +22,11 @@ struct BeingDefined { // (implied) - it is complete -struct Incomplete; +struct Incomplete; // expected-note 2{{forward declaration of '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 Incomplete incomplete = {}; // expected-error {{constexpr variable cannot have non-literal type 'const Incomplete'}} expected-note {{incomplete type 'const Incomplete' is not a literal type}} +constexpr Incomplete incomplete2[] = {}; // expected-error {{constexpr variable cannot have non-literal type 'Incomplete const[]'}} expected-note {{incomplete type 'Incomplete const[]' is not a literal type}} constexpr ClassTemp classtemplate = {}; constexpr ClassTemp classtemplate2[] = {}; diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp index 68ff83fee83c..7cb192b5a1f3 100644 --- a/test/CXX/class.access/class.friend/p1.cpp +++ b/test/CXX/class.access/class.friend/p1.cpp @@ -64,6 +64,7 @@ namespace test0 { }; class MemberFriend { + public: void test(); }; @@ -309,6 +310,7 @@ namespace test10 { // PR8705 namespace test11 { class A { + public: void test0(int); void test1(int); void test2(int); diff --git a/test/CXX/class.access/class.friend/p9-cxx0x.cpp b/test/CXX/class.access/class.friend/p9-cxx0x.cpp new file mode 100644 index 000000000000..f748a2bb3ba6 --- /dev/null +++ b/test/CXX/class.access/class.friend/p9-cxx0x.cpp @@ -0,0 +1,117 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// C++98 [class.friend]p7: +// C++11 [class.friend]p9: +// A name nominated by a friend declaration shall be accessible in +// the scope of the class containing the friend declaration. + +// PR12328 +// Simple, non-templated case. +namespace test0 { + class X { + void f(); // expected-note {{implicitly declared private here}} + }; + + class Y { + friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test0::X'}} + }; +} + +// Templated but non-dependent. +namespace test1 { + class X { + void f(); // expected-note {{implicitly declared private here}} + }; + + template class Y { + friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test1::X'}} + }; +} + +// Dependent but instantiated at the right type. +namespace test2 { + template class Y; + + class X { + void f(); + friend class Y; + }; + + template class Y { + friend void X::f(); + }; + + template class Y; +} + +// Dependent and instantiated at the wrong type. +namespace test3 { + template class Y; + + class X { + void f(); // expected-note {{implicitly declared private here}} + friend class Y; + }; + + template class Y { + friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test3::X'}} + }; + + template class Y; // expected-note {{in instantiation}} +} + +// Dependent because dependently-scoped. +namespace test4 { + template class X { + void f(); + }; + + template class Y { + friend void X::f(); + }; +} + +// Dependently-scoped, no friends. +namespace test5 { + template class X { + void f(); // expected-note {{implicitly declared private here}} + }; + + template class Y { + friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test5::X'}} + }; + + template class Y; // expected-note {{in instantiation}} +} + +// Dependently-scoped, wrong friend. +namespace test6 { + template class Y; + + template class X { + void f(); // expected-note {{implicitly declared private here}} + friend class Y; + }; + + template class Y { + friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test6::X'}} + }; + + template class Y; // expected-note {{in instantiation}} +} + +// Dependently-scoped, right friend. +namespace test7 { + template class Y; + + template class X { + void f(); + friend class Y; + }; + + template class Y { + friend void X::f(); + }; + + template class Y; +} diff --git a/test/CXX/class.derived/class.virtual/p3-0x.cpp b/test/CXX/class.derived/class.virtual/p3-0x.cpp index c4a401bb27c5..16f98280ed87 100644 --- a/test/CXX/class.derived/class.virtual/p3-0x.cpp +++ b/test/CXX/class.derived/class.virtual/p3-0x.cpp @@ -20,9 +20,15 @@ struct A { template struct B : A { + // FIXME: Diagnose this. virtual void f(T) override; }; +template +struct C : A { + virtual void f(int) override; // expected-error {{does not override}} +}; + } namespace Test3 { @@ -51,3 +57,46 @@ struct D : B { }; } + +namespace PR13499 { + struct X { + virtual void f(); + virtual void h(); + }; + template struct A : X { + void f() override; + void h() final; + }; + template struct B : X { + void g() override; // expected-error {{only virtual member functions can be marked 'override'}} + void i() final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + B b; // no-note + template struct C : T { + void g() override; + void i() final; + }; + template struct D : X { + virtual void g() override; // expected-error {{does not override}} + virtual void i() final; + }; + template struct E : X { + void f(T...) override; + void g(T...) override; // expected-error {{only virtual member functions can be marked 'override'}} + void h(T...) final; + void i(T...) final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + // FIXME: Diagnose these in the template definition, not in the instantiation. + E<> e; // expected-note {{in instantiation of}} + + template struct Y : T { + void f() override; + void h() final; + }; + template struct Z : T { + void g() override; // expected-error {{only virtual member functions can be marked 'override'}} + void i() final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + Y y; + Z z; // expected-note {{in instantiation of}} +} diff --git a/test/CXX/class/class.mem/p14.cpp b/test/CXX/class/class.mem/p14.cpp index 72b232e8f715..3f14099ef896 100644 --- a/test/CXX/class/class.mem/p14.cpp +++ b/test/CXX/class/class.mem/p14.cpp @@ -9,8 +9,9 @@ struct X0 { }; struct X1 { - int X1; - X1(); // expected-error{{declarator requires an identifier}} + int X1; // expected-note{{hidden by a non-type declaration of 'X1' here}} + X1(); // expected-error{{must use 'struct' tag to refer to type 'X1' in this scope}} \ + // expected-error{{expected member name or ';' after declaration specifiers}} }; struct X2 { diff --git a/test/CXX/class/class.union/p1.cpp b/test/CXX/class/class.union/p1.cpp index f344ae5b01fb..ee97410aebfe 100644 --- a/test/CXX/class/class.union/p1.cpp +++ b/test/CXX/class/class.union/p1.cpp @@ -27,9 +27,8 @@ 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 CopyAssign { + CopyAssign& operator=(CopyAssign& CA) { abort(); } // expected-note 4 {{because type 'CopyAssign' has a user-declared copy assignment operator}} }; class Dtor { diff --git a/test/CXX/class/p6-0x.cpp b/test/CXX/class/p6-0x.cpp index f2cf48282112..e153b4daaf3c 100644 --- a/test/CXX/class/p6-0x.cpp +++ b/test/CXX/class/p6-0x.cpp @@ -19,7 +19,7 @@ struct Trivial2 { Trivial2(const Trivial2 &) = default; Trivial2(Trivial2 &&) = default; Trivial2 &operator=(const Trivial2 &) = default; - Trivial2 &operator=(Trivial2 &) = default; + Trivial2 &operator=(Trivial2 &&) = default; ~Trivial2() = default; }; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp index 65573c753362..dfc1d3d04bf9 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp @@ -209,7 +209,7 @@ struct ConstexprBaseMemberCtors : Literal { {} }; -// - every assignment-expression that is an initializer-caluse appearing +// - every assignment-expression that is an initializer-clause 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 @@ -224,6 +224,25 @@ struct X { constexpr X(int c) : a(c) {} // ok, b initialized by 2 * c + 1 }; +union XU1 { int a; constexpr XU1() = default; }; // expected-error{{not constexpr}} +union XU2 { int a = 1; constexpr XU2() = default; }; + +struct XU3 { + union { + int a; + }; + constexpr XU3() = default; // expected-error{{not constexpr}} +}; +struct XU4 { + union { + int a = 1; + }; + constexpr XU4() = default; +}; + +static_assert(XU2().a == 1, ""); +static_assert(XU4().a == 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 @@ -247,3 +266,30 @@ namespace StdExample { int val; }; } + +namespace CtorLookup { + // Ensure that we look up which constructor will actually be used. + struct A { + constexpr A(const A&) {} + A(A&) {} + constexpr A(int); // expected-note {{previous}} + }; + constexpr A::A(int = 0) {} // expected-warning {{default constructor}} + + struct B : A { + B() = default; + constexpr B(const B&); + constexpr B(B&); + }; + constexpr B::B(const B&) = default; + constexpr B::B(B&) = default; // expected-error {{not constexpr}} + + struct C { + A a; + C() = default; + constexpr C(const C&); + constexpr C(C&); + }; + constexpr C::C(const C&) = default; + constexpr C::C(C&) = default; // expected-error {{not constexpr}} +} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp index 1daf02f6ea51..f732255a8a4f 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp @@ -49,3 +49,40 @@ void p3example() { same<__typeof(u), const int> uHasTypeConstInt; same<__typeof(y), double> yHasTypeDouble; } + +#if __cplusplus >= 201103L +namespace PR13293 { + // Ensure that dependent declarators have their deduction delayed. + int f(char); + double f(short); + template struct S { + static constexpr auto (*p)(T) = &f; + }; + + constexpr int (*f1)(char) = &f; + constexpr double (*f2)(short) = &f; + static_assert(S::p == f1, ""); + static_assert(S::p == f2, ""); + + struct K { int n; }; + template struct U { + static constexpr auto (T::*p) = &K::n; + }; + static_assert(U::p == &K::n, ""); + + template + using X = auto(int) -> auto(*)(T) -> auto(*)(char) -> long; + X x; + template struct V { + //static constexpr auto (*p)(int) -> auto(*)(T) -> auto(*)(char) = &x; // ill-formed + static constexpr auto (*(*(*p)(int))(T))(char) = &x; // ok + }; + V v; + + int *g(double); + template void h() { + new (auto(*)(T)) (&g); + } + template void h(); +} +#endif diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp index 71f57dcc66e7..7499829185eb 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp @@ -64,5 +64,4 @@ template struct G { }; // expected-error{{'auto' not allowed 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}} +auto k() -> auto; // expected-error{{'auto' not allowed in function return type}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp index 2bd5d234ce7f..093bc14d47f1 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp @@ -21,7 +21,7 @@ void r() { class PD { friend struct A; - ~PD(); // expected-note 4{{here}} + ~PD(); // expected-note 5{{here}} public: typedef int n; }; @@ -37,8 +37,14 @@ struct A { }; // 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( + PD(), // expected-error {{private destructor}} + PD()) pd1; // expected-error {{private destructor}} +decltype(DD(), // expected-error {{deleted function}} + DD()) dd1; // expected-error {{deleted function}} +decltype( + PD(), // expected-error {{temporary of type 'PD' has private destructor}} + 0) pd2; decltype(((13, ((DD())))))::n dd_parens; // ok decltype(((((42)), PD())))::n pd_parens_comma; // ok diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp index b06eb01a7fb5..89a28adcc65c 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp @@ -124,9 +124,7 @@ namespace TagName { } 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}} + using T = T; // expected-error {{unknown type name 'T'}} } namespace StdExample { diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp index 06dd1bb05560..783aba182319 100644 --- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp +++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -fcxx-exceptions %s // An explicitly-defaulted function may be declared constexpr only if it would // have been implicitly declared as constexpr. @@ -27,7 +27,7 @@ struct S2 { // -- it is implicitly considered to be constexpr if the implicit declaration // would be struct S3 { - S3() = default; // expected-note {{here}} + S3() = default; S3(const S3&) = default; S3(S3&&) = default; constexpr S3(int n) : n(n) {} @@ -36,7 +36,7 @@ struct S3 { 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}} +constexpr S3 s3d; // expected-error {{default initialization of an object of const type 'const S3' requires a user-provided default constructor}} struct S4 { S4() = default; @@ -44,7 +44,7 @@ struct S4 { S4(S4&&) = default; // expected-note {{here}} NoCopyMove ncm; }; -constexpr S4 s4a; // ok +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}} @@ -54,3 +54,71 @@ struct S5 { }; constexpr S5::S5() = default; static_assert(S5().m == 4, ""); + + +// An explicitly-defaulted function may have an exception specification only if +// it is compatible with the exception specification on an implicit declaration. +struct E1 { + E1() noexcept = default; + E1(const E1&) noexcept = default; + E1(E1&&) noexcept = default; + E1 &operator=(const E1&) noexcept = default; + E1 &operator=(E1&&) noexcept = default; + ~E1() noexcept = default; +}; +struct E2 { + E2() noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted default constructor does not match the calculated one}} + E2(const E2&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted copy constructor does not match the calculated one}} + E2(E2&&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted move constructor does not match the calculated one}} + E2 &operator=(const E2&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted copy assignment operator does not match the calculated one}} + E2 &operator=(E2&&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted move assignment operator does not match the calculated one}} + ~E2() noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted destructor does not match the calculated one}} +}; + +// If a function is explicitly defaulted on its first declaration +// -- it is implicitly considered to have the same exception-specification as +// if it had been implicitly declared +struct E3 { + E3() = default; + E3(const E3&) = default; + E3(E3&&) = default; + E3 &operator=(const E3&) = default; + E3 &operator=(E3&&) = default; + ~E3() = default; +}; +E3 e3; +static_assert(noexcept(E3(), E3(E3()), E3(e3), e3 = E3(), e3 = e3), ""); +struct E4 { + E4() noexcept(false); + E4(const E4&) noexcept(false); + E4(E4&&) noexcept(false); + E4 &operator=(const E4&) noexcept(false); + E4 &operator=(E4&&) noexcept(false); + ~E4() noexcept(false); +}; +struct E5 { + E5() = default; + E5(const E5&) = default; + E5(E5&&) = default; + E5 &operator=(const E5&) = default; + E5 &operator=(E5&&) = default; + ~E5() = default; + + E4 e4; +}; +E5 e5; +static_assert(!noexcept(E5()), ""); +static_assert(!noexcept(E5(static_cast(e5))), ""); +static_assert(!noexcept(E5(e5)), ""); +static_assert(!noexcept(e5 = E5()), ""); +static_assert(!noexcept(e5 = e5), ""); + +namespace PR13492 { + struct B { + B() = default; + }; + + void f() { + const B b; // expected-error {{default initialization of an object of const type 'const PR13492::B' requires a user-provided default constructor}} + } +} diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp new file mode 100644 index 000000000000..16fd5e6dbda1 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +template void func(); +template<> void func() = delete; + +template void func2(); +template<> void func2(); // expected-note {{previous declaration is here}} +template<> void func2() = delete; // expected-error {{deleted definition must be first declaration}} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp index 7764980e34f7..fef3692609fa 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp @@ -72,7 +72,7 @@ struct DefaultedAggr { DefaultedAggr(const DefaultedAggr &) = default; DefaultedAggr(DefaultedAggr &&) = default; DefaultedAggr &operator=(const DefaultedAggr &) = default; - DefaultedAggr &operator=(DefaultedAggr &) = default; + DefaultedAggr &operator=(DefaultedAggr &&) = default; ~DefaultedAggr() = default; }; DefaultedAggr da = { 42 } ; diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp new file mode 100644 index 000000000000..3450003a6e2d --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp @@ -0,0 +1,113 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +namespace std { + typedef decltype(sizeof(int)) size_t; + + template + struct initializer_list + { + const E *p; + size_t n; + initializer_list(const E *p, size_t n) : p(p), n(n) {} + }; + + struct string { + string(const char *); + }; + + template + struct pair { + pair(const A&, const B&); + }; +} + +namespace bullet2 { + double ad[] = { 1, 2.0 }; + int ai[] = { 1, 2.0 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} + + struct S2 { + int m1; + double m2, m3; + }; + + S2 s21 = { 1, 2, 3.0 }; + S2 s22 { 1.0, 2, 3 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} + S2 s23 { }; +} + +namespace bullet4_example1 { + struct S { + S(std::initializer_list d) {} + S(std::initializer_list i) {} + S() {} + }; + + S s1 = { 1.0, 2.0, 3.0 }; + S s2 = { 1, 2, 3 }; + S s3 = { }; +} + +namespace bullet4_example2 { + struct Map { + Map(std::initializer_list>) {} + }; + + Map ship = {{"Sophie",14}, {"Surprise",28}}; +} + +namespace bullet4_example3 { + struct S { + S(int, double, double) {} + S() {} + }; + + S s1 = { 1, 2, 3.0 }; + // FIXME: This is an ill-formed narrowing initialization. + S s2 { 1.0, 2, 3 }; + S s3 {}; +} + +namespace bullet5 { + struct S { + S(std::initializer_list) {} + S(const std::string &) {} + }; + + const S& r1 = { 1, 2, 3.0 }; + const S& r2 = { "Spinach" }; + S& r3 = { 1, 2, 3 }; // expected-error {{non-const lvalue reference to type 'bullet5::S' cannot bind to an initializer list temporary}} + const int& i1 = { 1 }; + const int& i2 = { 1.1 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} expected-warning {{implicit conversion}} + const int (&iar)[2] = { 1, 2 }; +} + +namespace bullet6 { + int x1 {2}; + int x2 {2.0}; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} +} + +namespace bullet7 { + int** pp {}; +} + +namespace bullet8 { + struct A { int i; int j; }; + A a1 { 1, 2 }; + A a2 { 1.2 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} expected-warning {{implicit conversion}} + + struct B { + B(std::initializer_list i) {} + }; + B b1 { 1, 2 }; + B b2 { 1, 2.0 }; + + struct C { + C(int i, double j) {} + }; + C c1 = { 1, 2.2 }; + // FIXME: This is an ill-formed narrowing initialization. + C c2 = { 1.1, 2 }; // expected-warning {{implicit conversion}} + + int j { 1 }; + int k { }; +} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp index db20ea6426e0..9b1727fd04af 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp @@ -167,6 +167,20 @@ void shrink_int() { 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}} + + // Negative -> larger unsigned type. + unsigned long long ll1 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} + unsigned long long ll2 = { 1 }; // OK + unsigned long long ll3 = { s }; // expected-error {{cannot be narrowed from type 'short'}} expected-note {{override}} + unsigned long long ll4 = { us }; // OK + unsigned long long ll5 = { ll }; // expected-error {{cannot be narrowed from type 'long long'}} expected-note {{override}} + Agg ll6 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} + Agg ll7 = { 18446744073709551615ULL }; // OK + Agg ll8 = { __int128(18446744073709551615ULL) + 1 }; // expected-error {{ 18446744073709551616 which cannot be narrowed}} expected-note {{override}} expected-warning {{changes value}} + signed char c = 'x'; + unsigned short usc1 = { c }; // expected-error {{non-constant-expression cannot be narrowed from type 'signed char'}} expected-note {{override}} + unsigned short usc2 = { (signed char)'x' }; // OK + unsigned short usc3 = { (signed char)-1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} } // Be sure that type- and value-dependent expressions in templates get the error diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp index d58a12953e0d..4ba75efebbb3 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp @@ -22,7 +22,7 @@ struct X3 { X3(); private: - X3(X3&); // expected-note{{candidate constructor not viable: no known conversion from 'X3' to 'X3 &' for 1st argument}} + X3(X3&); // expected-note{{candidate constructor not viable: expects an l-value for 1st argument}} }; // Check for instantiation of default arguments diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp new file mode 100644 index 000000000000..21f71f05419c --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +// A function that is explicitly defaulted shall +// [...] +// -- not have default arguments +struct DefArg { + static DefArg &&make(); + DefArg(int n = 5) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} + DefArg(const DefArg &DA = make()) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} + DefArg(const DefArg &DA, int k = 3) = default; // expected-error {{an explicitly-defaulted copy constructor cannot have default arguments}} + DefArg(DefArg &&DA = make()) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} + DefArg(DefArg &&DA, int k = 3) = default; // expected-error {{an explicitly-defaulted move constructor cannot have default arguments}} + DefArg &operator=(const DefArg&, int k = 4) = default; // expected-error {{parameter of overloaded 'operator=' cannot have a default argument}} + DefArg &operator=(DefArg&&, int k = 4) = default; // expected-error {{parameter of overloaded 'operator=' cannot have a default argument}} + ~DefArg(int k = 5) = default; // expected-error {{destructor cannot have any parameters}} +}; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp index a87982906631..9b5ef788974e 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp @@ -14,11 +14,11 @@ namespace move { }; struct AssignmentRet1 { - AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}} + AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet1 &'}} }; 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}} + const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet2 &'}} }; struct ConstAssignment { @@ -38,22 +38,35 @@ namespace copy { }; struct NonConst { - NonConst(NonConst&) = default; - NonConst& operator=(NonConst&) = default; + NonConst(NonConst&) = default; // expected-error {{must be defaulted outside the class}} + NonConst& operator=(NonConst&) = default; // expected-error {{must be defaulted outside the class}} + }; + + struct NonConst2 { + NonConst2(NonConst2&); + NonConst2& operator=(NonConst2&); + }; + NonConst2::NonConst2(NonConst2&) = default; + NonConst2 &NonConst2::operator=(NonConst2&) = default; + + struct NonConst3 { + NonConst3(NonConst3&) = default; + NonConst3& operator=(NonConst3&) = default; + NonConst nc; }; 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}} + NonConst nc; // makes implicit copy non-const }; 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}} + AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet1 &'}} }; 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}} + const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet2 &'}} }; struct ConstAssignment { diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp index 574a3e7a7934..719aeeddebcc 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp @@ -1,3 +1,7 @@ // 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}} +// FIXME: We should catch the case of tag with an incomplete type here (which +// will necessarily be ill-formed as a trailing return type for a function +// definition), and recover with a "type cannot be defined in a trailing return +// type" error. +auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{expected a type}} diff --git a/test/CXX/except/except.spec/p14.cpp b/test/CXX/except/except.spec/p14.cpp index 8763a7028195..4f50afb54887 100644 --- a/test/CXX/except/except.spec/p14.cpp +++ b/test/CXX/except/except.spec/p14.cpp @@ -39,3 +39,27 @@ struct IC1 { // we cannot currently compute the set of thrown types. static_assert(noexcept(IC0()), "IC0() does not throw"); static_assert(!noexcept(IC1()), "IC1() throws"); + +namespace PR13381 { + struct NoThrowMove { + NoThrowMove(const NoThrowMove &); + NoThrowMove(NoThrowMove &&) noexcept; + NoThrowMove &operator=(const NoThrowMove &); + NoThrowMove &operator=(NoThrowMove &&) noexcept; + }; + struct NoThrowMoveOnly { + NoThrowMoveOnly(NoThrowMoveOnly &&) noexcept; + NoThrowMoveOnly &operator=(NoThrowMoveOnly &&) noexcept; + }; + struct X { + const NoThrowMove a; + NoThrowMoveOnly b; + + static X val(); + static X &ref(); + }; + // These both perform a move, but that copy might throw, because it calls + // NoThrowMove's copy constructor (because PR13381::a is const). + static_assert(!noexcept(X(X::val())), ""); + static_assert(!noexcept(X::ref() = X::val()), ""); +} diff --git a/test/CXX/except/except.spec/p5-pointers.cpp b/test/CXX/except/except.spec/p5-pointers.cpp index dd3c0600ce92..f855520aa24d 100644 --- a/test/CXX/except/except.spec/p5-pointers.cpp +++ b/test/CXX/except/except.spec/p5-pointers.cpp @@ -65,9 +65,9 @@ void fnptrs() 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}} + void (*t10)(void (*)() throw(B1)) = &s9; // valid + void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}} + void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}} } // Member function stuff diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp index 054669ef788d..9e6716d0b8ec 100644 --- a/test/CXX/expr/expr.const/p2-0x.cpp +++ b/test/CXX/expr/expr.const/p2-0x.cpp @@ -131,14 +131,14 @@ namespace IncompleteClassTypeAddr { 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)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} expected-note {{previous case defined here}} 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)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} expected-error {{duplicate case value '2147483647'}} expected-note {{previous case defined here}} 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'}} + case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}} expected-error {{duplicate case value '2147483647'}} break; } } diff --git a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp index 22892a63ab16..212adc8c2bd4 100644 --- a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp +++ b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp @@ -10,7 +10,10 @@ 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 &&ir1 = reinterpret_cast(0); // expected-error {{rvalue to reference type}} + int &&ir2 = reinterpret_cast('a'); // expected-error {{rvalue to reference type}} int &&ir3 = reinterpret_cast(xvalue()); + // Per DR1268, reinterpret_cast can convert between lvalues and xvalues. + int &ir4 = reinterpret_cast(xvalue()); + int &&ir5 = reinterpret_cast(*ptr); } diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm new file mode 100644 index 000000000000..9f9867106930 --- /dev/null +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -std=c++11 -fblocks -emit-llvm -o - -triple x86_64-apple-darwin11.3 %s | FileCheck %s + +namespace PR12746 { + // CHECK: define zeroext i1 @_ZN7PR127462f1EPi + bool f1(int *x) { + // CHECK: store i8* bitcast (i1 (i8*)* @___ZN7PR127462f1EPi_block_invoke to i8*) + bool (^outer)() = ^ { + auto inner = [&]() -> bool { + return x == 0; + }; + return inner(); + }; + return outer(); + } + + // CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke + // CHECK: call zeroext i1 @"_ZNK7PR127462f132___ZN7PR127462f1EPi_block_invoke3$_0clEv" + + bool f2(int *x) { + auto outer = [&]() -> bool { + bool (^inner)() = ^ { + return x == 0; + }; + return inner(); + }; + return outer(); + } +} + diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm index 0c3fdb2d80eb..0db2bf5646ff 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm @@ -86,3 +86,41 @@ namespace overloading { int &ir = accept_lambda_conv([](int x) { return x + 1; }); } } + +namespace PR13117 { + struct A { + template static void f(Args...); + + template static void f1() + { + (void)^(Args args) { // expected-error{{block contains unexpanded parameter pack 'Args'}} + }; + } + + template static void f2() + { + // FIXME: Allow this. + f( + ^(Args args) // expected-error{{block contains unexpanded parameter pack 'Args'}} + { } + ... // expected-error{{pack expansion does not contain any unexpanded parameter packs}} + ); + } + + template static void f3() + { + (void)[](Args args) { // expected-error{{expression contains unexpanded parameter pack 'Args'}} + }; + } + + template static void f4() + { + f([](Args args) { } ...); + } + }; + + void g() { + A::f1(); + A::f2(); + } +} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp index 174db257c891..82fc04a48fb6 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp @@ -9,8 +9,8 @@ void print(T first, Ts... rest) { } template -void unsupported(Ts ...values) { - auto unsup = [values] {}; // expected-error{{unexpanded function parameter pack capture is unsupported}} +void unexpanded_capture(Ts ...values) { + auto unexp = [values] {}; // expected-error{{initializer contains unexpanded parameter pack 'values'}} } template diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp index d816e1702a6d..f580e7e4c46f 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp @@ -25,7 +25,7 @@ void infer_void_return_type(int i) { struct X { }; X infer_X_return_type(X x) { - return [&x](int y) { // expected-warning{{omitted result type}} + return [&x](int y) { if (y > 0) return X(); else @@ -33,11 +33,11 @@ X infer_X_return_type(X x) { }(5); } -X infer_X_return_type_fail(X x) { - return [x](int y) { // expected-warning{{omitted result type}} +X infer_X_return_type_fail(X x) { + return [x](int y) { if (y > 0) return X(); - else + else return x; // expected-error{{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}} }(5); } diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp index ac11940c80da..2646264273eb 100644 --- a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp +++ b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp @@ -4,7 +4,7 @@ bool b = !0; -bool b2 = !1.2; +bool b2 = !1.2; //expected-warning{{implicit conversion from 'double' to 'bool' changes value from 1.2 to true}} bool b3 = !4; diff --git a/test/CXX/expr/p10-0x.cpp b/test/CXX/expr/p10-0x.cpp new file mode 100644 index 000000000000..564df8843a57 --- /dev/null +++ b/test/CXX/expr/p10-0x.cpp @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-linux-gnu %s -o - -std=c++11 | FileCheck %s + +volatile int g1; +struct S { + volatile int a; +} g2; + +volatile int& refcall(); + +// CHECK: define void @_Z2f1PViPV1S +void f1(volatile int *x, volatile S* s) { + // We should perform the load in these cases. + // CHECK: load volatile i32* + (*x); + // CHECK: load volatile i32* + __extension__ g1; + // CHECK: load volatile i32* + s->a; + // CHECK: load volatile i32* + g2.a; + // CHECK: load volatile i32* + s->*(&S::a); + // CHECK: load volatile i32* + // CHECK: load volatile i32* + x[0], 1 ? x[0] : *x; + + // CHECK: load volatile i32* + // CHECK: load volatile i32* + // CHECK: load volatile i32* + *x ?: *x; + + // CHECK: load volatile i32* + ({ *x; }); + + // CHECK-NOT: load volatile + // CHECK: ret +} + +// CHECK: define void @_Z2f2PVi +// CHECK-NOT: load volatile +// CHECK: ret +void f2(volatile int *x) { + // We shouldn't perform the load in these cases. + refcall(); + 1 ? refcall() : *x; +} diff --git a/test/CXX/special/class.conv/class.conv.ctor/p1.cpp b/test/CXX/special/class.conv/class.conv.ctor/p1.cpp new file mode 100644 index 000000000000..d2add82f420f --- /dev/null +++ b/test/CXX/special/class.conv/class.conv.ctor/p1.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +namespace PR13003 { + struct void_type + { + template + void_type(Arg0&&, Args&&...) { } + }; + + struct void_type2 + { + template + void_type2(Args&&...) { } + }; + + struct atom { }; + + void_type v1 = atom(); + void_type2 v2 = atom(); +} + diff --git a/test/CXX/special/class.copy/implicit-move.cpp b/test/CXX/special/class.copy/implicit-move.cpp index 3e9accfbf6a7..597e327a414d 100644 --- a/test/CXX/special/class.copy/implicit-move.cpp +++ b/test/CXX/special/class.copy/implicit-move.cpp @@ -234,3 +234,10 @@ namespace DR1402 { friend NoMove11 &NoMove11::operator=(NoMove11 &&); // expected-error {{no matching function}} }; } + +namespace PR12625 { + struct X; // expected-note {{forward decl}} + struct Y { + X x; // expected-error {{incomplete}} + } y = Y(); +} diff --git a/test/CXX/special/class.copy/p11.0x.copy.cpp b/test/CXX/special/class.copy/p11.0x.copy.cpp index b2b4f6a87f7c..fab3b9dd7bf1 100644 --- a/test/CXX/special/class.copy/p11.0x.copy.cpp +++ b/test/CXX/special/class.copy/p11.0x.copy.cpp @@ -8,7 +8,7 @@ struct NonTrivial { // -- 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}} + NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}} DeletedNTVariant(); }; DeletedNTVariant DVa; @@ -16,7 +16,7 @@ DeletedNTVariant DVb(DVa); // expected-error{{call to implicitly-deleted copy co struct DeletedNTVariant2 { union { - NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant2' is implicitly deleted because field 'NT' has a non-trivial copy constructor}} + NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant2' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}} }; DeletedNTVariant2(); }; @@ -119,3 +119,15 @@ struct RValue { }; RValue RVa; RValue RVb(RVa); // expected-error{{call to implicitly-deleted copy constructor}} + +namespace PR13381 { + struct S { + S(const S&); + S(const volatile S&) = delete; // expected-note{{deleted here}} + }; + struct T { + volatile S s; // expected-note{{field 's' has a deleted copy constructor}} + }; + T &f(); + T t = f(); // expected-error{{call to implicitly-deleted copy constructor}} +} diff --git a/test/CXX/special/class.copy/p13-0x.cpp b/test/CXX/special/class.copy/p13-0x.cpp index 0a9aa6214594..5d436016a056 100644 --- a/test/CXX/special/class.copy/p13-0x.cpp +++ b/test/CXX/special/class.copy/p13-0x.cpp @@ -58,3 +58,59 @@ struct Constexpr5Base {}; struct Constexpr5 : Constexpr5Base { constexpr Constexpr5() {} }; constexpr Constexpr5 ce5move = Constexpr5(); constexpr Constexpr5 ce5copy = ce5move; + +// An explicitly-defaulted constructor doesn't become constexpr until the end of +// its class. Make sure we note that the class has a constexpr constructor when +// that happens. +namespace PR13052 { + template struct S { + S() = default; // expected-note 2{{here}} + S(S&&) = default; + S(const S&) = default; + T t; + }; + + struct U { + U() = default; + U(U&&) = default; + U(const U&) = default; + }; + + struct V { + V(); // expected-note {{here}} + V(V&&) = default; + V(const V&) = default; + }; + + struct W { + W(); // expected-note {{here}} + }; + + static_assert(__is_literal_type(U), ""); + static_assert(!__is_literal_type(V), ""); + static_assert(!__is_literal_type(W), ""); + static_assert(__is_literal_type(S), ""); + static_assert(!__is_literal_type(S), ""); + static_assert(!__is_literal_type(S), ""); + + struct X { + friend constexpr U::U() noexcept; + friend constexpr U::U(U&&) noexcept; + friend constexpr U::U(const U&) noexcept; + friend constexpr V::V(); // expected-error {{follows non-constexpr declaration}} + friend constexpr V::V(V&&) noexcept; + friend constexpr V::V(const V&) noexcept; + friend constexpr W::W(); // expected-error {{follows non-constexpr declaration}} + friend constexpr W::W(W&&) noexcept; + friend constexpr W::W(const W&) noexcept; + friend constexpr S::S() noexcept; + friend constexpr S::S(S&&) noexcept; + friend constexpr S::S(const S&) noexcept; + friend constexpr S::S(); // expected-error {{follows non-constexpr declaration}} + friend constexpr S::S(S&&) noexcept; + friend constexpr S::S(const S&) noexcept; + friend constexpr S::S(); // expected-error {{follows non-constexpr declaration}} + friend constexpr S::S(S&&) noexcept; + friend constexpr S::S(const S&) noexcept; + }; +} diff --git a/test/CXX/special/class.copy/p15-inclass.cpp b/test/CXX/special/class.copy/p15-inclass.cpp index c4f8eafd937c..6cfa94fafad5 100644 --- a/test/CXX/special/class.copy/p15-inclass.cpp +++ b/test/CXX/special/class.copy/p15-inclass.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s namespace PR11418 { struct NonPOD { diff --git a/test/CXX/special/class.copy/p23-cxx11.cpp b/test/CXX/special/class.copy/p23-cxx11.cpp new file mode 100644 index 000000000000..7c04a8201804 --- /dev/null +++ b/test/CXX/special/class.copy/p23-cxx11.cpp @@ -0,0 +1,148 @@ +// RUN: %clang_cc1 -verify %s -std=c++11 + +template struct CopyAssign { + static T t; + void test() { + t = t; // expected-error +{{deleted}} + } +}; +template struct MoveAssign { + static T t; + void test() { + t = static_cast(t); // expected-error +{{deleted}} + } +}; + +struct NonTrivialCopyAssign { + NonTrivialCopyAssign &operator=(const NonTrivialCopyAssign &); +}; +struct NonTrivialMoveAssign { + NonTrivialMoveAssign &operator=(NonTrivialMoveAssign &&); +}; +struct AmbiguousCopyAssign { + AmbiguousCopyAssign &operator=(const AmbiguousCopyAssign &); + AmbiguousCopyAssign &operator=(volatile AmbiguousCopyAssign &); +}; +struct AmbiguousMoveAssign { + AmbiguousMoveAssign &operator=(const AmbiguousMoveAssign &&); + AmbiguousMoveAssign &operator=(volatile AmbiguousMoveAssign &&); +}; +struct DeletedCopyAssign { + DeletedCopyAssign &operator=(const DeletedCopyAssign &) = delete; // expected-note 2{{deleted}} +}; +struct DeletedMoveAssign { + DeletedMoveAssign &operator=(DeletedMoveAssign &&) = delete; // expected-note 2{{deleted}} +}; +class InaccessibleCopyAssign { + InaccessibleCopyAssign &operator=(const InaccessibleCopyAssign &); +}; +class InaccessibleMoveAssign { + InaccessibleMoveAssign &operator=(InaccessibleMoveAssign &&); +}; + +// A defaulted copy/move assignment operator for class X is defined as deleted +// if X has: + +// -- a variant member with a non-trivial corresponding assignment operator +// and X is a union-like class +struct A1 { + union { + NonTrivialCopyAssign x; // expected-note {{variant field 'x' has a non-trivial copy assign}} + }; +}; +template struct CopyAssign; // expected-note {{here}} + +struct A2 { + A2 &operator=(A2 &&) = default; // expected-note {{here}} + union { + NonTrivialMoveAssign x; // expected-note {{variant field 'x' has a non-trivial move assign}} + }; +}; +template struct MoveAssign; // expected-note {{here}} + +// -- a non-static const data member of (array of) non-class type +struct B1 { + const int a; // expected-note 2{{field 'a' is of const-qualified type}} +}; +struct B2 { + const void *const a[3][9][2]; // expected-note 2{{field 'a' is of const-qualified type 'const void *const [3][9][2]'}} +}; +struct B3 { + const void *a[3]; +}; +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} +template struct CopyAssign; +template struct MoveAssign; + +// -- a non-static data member of reference type +struct C1 { + int &a; // expected-note 2{{field 'a' is of reference type 'int &'}} +}; +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} + +// -- a non-static data member of class type M that cannot be copied/moved +struct D1 { + AmbiguousCopyAssign a; // expected-note {{field 'a' has multiple copy}} +}; +struct D2 { + D2 &operator=(D2 &&) = default; // expected-note {{here}} + AmbiguousMoveAssign a; // expected-note {{field 'a' has multiple move}} +}; +struct D3 { + DeletedCopyAssign a; // expected-note {{field 'a' has a deleted copy}} +}; +struct D4 { + D4 &operator=(D4 &&) = default; // expected-note {{here}} + DeletedMoveAssign a; // expected-note {{field 'a' has a deleted move}} +}; +struct D5 { + InaccessibleCopyAssign a; // expected-note {{field 'a' has an inaccessible copy}} +}; +struct D6 { + D6 &operator=(D6 &&) = default; // expected-note {{here}} + InaccessibleMoveAssign a; // expected-note {{field 'a' has an inaccessible move}} +}; +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} + +// -- a direct or virtual base that cannot be copied/moved +struct E1 : AmbiguousCopyAssign {}; // expected-note {{base class 'AmbiguousCopyAssign' has multiple copy}} +struct E2 : AmbiguousMoveAssign { // expected-note {{base class 'AmbiguousMoveAssign' has multiple move}} + E2 &operator=(E2 &&) = default; // expected-note {{here}} +}; +struct E3 : DeletedCopyAssign {}; // expected-note {{base class 'DeletedCopyAssign' has a deleted copy}} +struct E4 : DeletedMoveAssign { // expected-note {{base class 'DeletedMoveAssign' has a deleted move}} + E4 &operator=(E4 &&) = default; // expected-note {{here}} +}; +struct E5 : InaccessibleCopyAssign {}; // expected-note {{base class 'InaccessibleCopyAssign' has an inaccessible copy}} +struct E6 : InaccessibleMoveAssign { // expected-note {{base class 'InaccessibleMoveAssign' has an inaccessible move}} + E6 &operator=(E6 &&) = default; // expected-note {{here}} +}; +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} +template struct CopyAssign; // expected-note {{here}} +template struct MoveAssign; // expected-note {{here}} + +namespace PR13381 { + struct S { + S &operator=(const S&); + S &operator=(const volatile S&) = delete; // expected-note{{deleted here}} + }; + struct T { + volatile S s; // expected-note{{field 's' has a deleted copy assignment}} + }; + void g() { + T t; + t = T(); // expected-error{{implicitly-deleted copy assignment}} + } +} diff --git a/test/CXX/special/class.copy/p8-cxx11.cpp b/test/CXX/special/class.copy/p8-cxx11.cpp index 02e6cd1c9ab6..a2613f461298 100644 --- a/test/CXX/special/class.copy/p8-cxx11.cpp +++ b/test/CXX/special/class.copy/p8-cxx11.cpp @@ -43,6 +43,6 @@ struct Test { friend C::C(C &); friend D::D(const D &); friend E::E(E &); - friend F::F(const F &); + constexpr friend F::F(const F &); friend G::G(G &); }; diff --git a/test/CXX/special/class.ctor/p5-0x.cpp b/test/CXX/special/class.ctor/p5-0x.cpp index 694ab5b17535..1aaeef282ae7 100644 --- a/test/CXX/special/class.ctor/p5-0x.cpp +++ b/test/CXX/special/class.ctor/p5-0x.cpp @@ -21,7 +21,7 @@ int n; // - 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}} +union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{default constructor of 'Deleted1a' is implicitly deleted because variant field 'u' has a non-trivial default constructor}} Deleted1a d1a; // expected-error {{implicitly-deleted default constructor}} union NotDeleted1a { DefaultedDefCtor1 nu; }; NotDeleted1a nd1a; @@ -53,7 +53,7 @@ class Deleted3a { const int a; }; // expected-note {{because field 'a' of const- 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}} +class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor1 [42]' 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}} @@ -77,7 +77,7 @@ NotDeleted3g nd3g; union Deleted4a { const int a; const int b; - const UserProvidedDefCtor c; // expected-note {{because field 'c' has a non-trivial default constructor}} + const UserProvidedDefCtor c; // expected-note {{because variant field 'c' has a non-trivial default constructor}} }; Deleted4a d4a; // expected-error {{implicitly-deleted default constructor}} union NotDeleted4a { const int a; int b; }; diff --git a/test/CXX/special/class.ctor/p6-0x.cpp b/test/CXX/special/class.ctor/p6-0x.cpp index 8c8800f2de45..9860317aa122 100644 --- a/test/CXX/special/class.ctor/p6-0x.cpp +++ b/test/CXX/special/class.ctor/p6-0x.cpp @@ -55,3 +55,42 @@ struct A {}; // expected-note {{here}} struct B { friend A::A(); // expected-error {{non-constexpr declaration of 'A' follows constexpr declaration}} }; + +namespace UnionCtors { + union A { // expected-note {{here}} + int a; + int b; + }; + union B { + int a; + int b = 5; + }; + union C { + int a = 5; + int b; + }; + struct D { + union { + int a = 5; + int b; + }; + union { + int c; + int d = 5; + }; + }; + struct E { // expected-note {{here}} + union { + int a; + int b; + }; + }; + + struct Test { + friend constexpr A::A() noexcept; // expected-error {{follows non-constexpr declaration}} + friend constexpr B::B() noexcept; + friend constexpr C::C() noexcept; + friend constexpr D::D() noexcept; + friend constexpr E::E() noexcept; // expected-error {{follows non-constexpr declaration}} + }; +} diff --git a/test/CXX/special/class.dtor/p5-0x.cpp b/test/CXX/special/class.dtor/p5-0x.cpp index dbfa00444075..0d073cea529e 100644 --- a/test/CXX/special/class.dtor/p5-0x.cpp +++ b/test/CXX/special/class.dtor/p5-0x.cpp @@ -16,25 +16,25 @@ class InaccessibleDtor { // destructor. union A1 { A1(); - NonTrivDtor n; // expected-note {{destructor of union 'A1' is implicitly deleted because field 'n' has a non-trivial destructor}} + NonTrivDtor n; // expected-note {{destructor of 'A1' is implicitly deleted because variant 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}} + NonTrivDtor n; // expected-note {{because variant 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}} + NonTrivDtor n[3]; // expected-note {{because variant 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}} + NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}} }; }; A4 a4; // expected-error {{deleted function}} diff --git a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp index a45b35f71592..96bb47212274 100644 --- a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp +++ b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp @@ -1,5 +1,13 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +struct pr12960 { + int begin; + void foo(int x) { + for (int& it : x) { // expected-error {{use of undeclared identifier 'begin'}} expected-note {{range has type 'int'}} + } + } +}; + namespace std { template auto begin(T &&t) -> decltype(t.begin()) { return t.begin(); } // expected-note 4{{ignored: substitution failure}} @@ -207,3 +215,4 @@ void example() { for (int &x : array) x *= 2; } + diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp index 63f569be0861..640d03d4c96f 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp @@ -302,6 +302,7 @@ namespace test14 { }; template class B { + public: void foo() { return A::foo(); } // expected-error {{'foo' is a private member of 'test14::A'}} }; @@ -320,10 +321,12 @@ namespace test15 { }; template class B { + public: void foo() { return A::foo(); } // expected-error {{'foo' is a private member of 'test15::A'}} }; template <> class B { + public: void foo() { return A::foo(); } template void bar(U u) { (void) A::foo(); diff --git a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp index 21aa24fb522d..485068e6486a 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp @@ -249,3 +249,46 @@ namespace PR10230 { int (&ir3)[3] = s().f(); } } + +namespace PR13386 { + template struct tuple {}; + template + struct S { + template + void f(T &&...t, U &&...u) {} // expected-note {{candidate}} + template + void g(U &&...u, T &&...t) {} // expected-note {{candidate}} + template + void h(tuple &&...) {} // expected-note 2{{candidate}} + + template + struct X { + template + void x(tuple &&...); // expected-error {{different lengths}} + }; + }; + + void test() { + S<>().f(); + S<>().f(0); + S().f(0); + S().f(0, 1); + S().f(0); // expected-error {{no matching member function for call}} + + S<>().g(); + S<>().g(0); + S().g(0); + S().g(0, 1); // expected-error {{no matching member function for call}} + S().g(0, 1); + S().g(0, 1); + + S<>().h(); + S<>().h(0); // expected-error {{no matching member function for call}} + S().h({}); // expected-error {{no matching member function for call}} + S().h({}); + S().h(tuple{}); + S().h(tuple{}, tuple{}); + + S::X(); // expected-note {{here}} + } +} diff --git a/test/CXX/temp/temp.names/p3-0x.cpp b/test/CXX/temp/temp.names/p3-0x.cpp new file mode 100644 index 000000000000..85dc75e30199 --- /dev/null +++ b/test/CXX/temp/temp.names/p3-0x.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +template class X { /* ... */ }; +X< 1>2 > x1; // expected-error{{expected unqualified-id}} +X<(1>2)> x2; // OK +template class Y { /* ... */ }; +Y> x3; // OK, same as Y > x3; +Y>1>> x4; // expected-error{{expected unqualified-id}} +Y>1)>> x5; + +int a, b; +Y x6; diff --git a/test/CXX/temp/temp.spec/p5.cpp b/test/CXX/temp/temp.spec/p5.cpp index 0e69a26b04e2..ba92d41e3e8e 100644 --- a/test/CXX/temp/temp.spec/p5.cpp +++ b/test/CXX/temp/temp.spec/p5.cpp @@ -14,7 +14,7 @@ struct X0 { }; template -T X0::value = 3.14; // expected-warning{{implicit conversion turns literal floating-point number into integer}} +T X0::value = 3.14; // expected-warning{{implicit conversion from 'double' to 'int' changes value from 3.14 to 3}} template struct X0; // expected-note{{previous explicit instantiation}} \ expected-note{{requested here}} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp index 121cb8eedf2f..aba9d3640801 100644 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp +++ b/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s template void f(T) { /* ... */ } template inline void g(T) { /* ... */ } diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp index 84841cb60f4d..c8b7def5a448 100644 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp +++ b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp @@ -1,10 +1,14 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s namespace N { - template class X; + template class X; // expected-note {{'N::X' declared here}} \ + // expected-note {{explicitly specialized declaration is here}} } -template<> class X { /* ... */ }; // expected-error {{non-template class 'X'}} +// TODO: Don't add a namespace qualifier to the template if it would trigger +// the warning about the specialization being outside of the namespace. +template<> class X { /* ... */ }; // expected-error {{no template named 'X'; did you mean 'N::X'?}} \ + // expected-warning {{first declaration of class template specialization of 'X' outside namespace 'N' is a C++11 extension}} namespace N { diff --git a/test/CXX/temp/temp.spec/temp.explicit/p12.cpp b/test/CXX/temp/temp.spec/temp.explicit/p12.cpp index c7564868f8ad..9518a0b077b7 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p12.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p12.cpp @@ -1,6 +1,49 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -char* p = 0; -template T g(T x = &p) { return x; } -template int g(int); // OK even though &p isn't an int. +namespace test0 { + char* p = 0; + template T g(T x = &p) { return x; } + template int g(int); // OK even though &p isn't an int. +} +// Don't impose access restrictions on explicit instantiations. +namespace test1 { + class A { + class Private {}; + public: + typedef Private Public; + }; + + template class Temp { + static Temp make() { return Temp(); } + }; + template class Temp; + + // FIXME: this ought to be an error, but it isn't because Sema is + // silently failing to create a declaration for the explicit + // instantiation. + template class Temp Temp::make(); +} + +// Don't impose access restrictions on explicit specializations, +// either. This goes here because it's an extension of the rule for +// explicit instantiations and doesn't have any independent support. +namespace test2 { + class A { + class Private {}; // expected-note {{implicitly declared private here}} + public: + typedef Private Public; + }; + + template class Temp { + static Temp make(); + }; + template <> class Temp { + public: + Temp(int x) {} + }; + + template <> class Temp Temp::make() { // expected-error {{'Private' is a private member of 'test2::A'}} + return Temp(0); + } +} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp b/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp index 04e7df5741e2..ff24ad997dfd 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -O1 -emit-llvm -std=c++11 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -emit-llvm -std=c++11 -o - %s | FileCheck %s template struct X0 { diff --git a/test/CodeCompletion/auto.cpp b/test/CodeCompletion/auto.cpp new file mode 100644 index 000000000000..1fc9fb035d47 --- /dev/null +++ b/test/CodeCompletion/auto.cpp @@ -0,0 +1,2 @@ +// RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:2:9 %s +auto i = diff --git a/test/CodeCompletion/documentation.cpp b/test/CodeCompletion/documentation.cpp new file mode 100644 index 000000000000..c049ae3733b5 --- /dev/null +++ b/test/CodeCompletion/documentation.cpp @@ -0,0 +1,33 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +/// Aaa. +void T1(float x, float y); + +/// Bbb. +class T2 { +public: + /// Ccc. + void T3(); + + int T4; ///< Ddd. +}; + +/// Eee. +namespace T5 { +} + +void test() { + + T2 t2; + t2. +} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:21:1 %s -o - | FileCheck -check-prefix=CC1 %s +// CHECK-CC1: COMPLETION: T1 : [#void#]T1(<#float x#>, <#float y#>) : Aaa. +// CHECK-CC1: COMPLETION: T2 : T2 : Bbb. +// CHECK-CC1: COMPLETION: T5 : T5:: : Eee. + +// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:23:6 %s -o - | FileCheck -check-prefix=CC2 %s +// CHECK-CC2: COMPLETION: T3 : [#void#]T3() : Ccc. +// CHECK-CC2: COMPLETION: T4 : [#int#]T4 : Ddd. diff --git a/test/CodeCompletion/objc-expr.m b/test/CodeCompletion/objc-expr.m new file mode 100644 index 000000000000..b59586ab96cf --- /dev/null +++ b/test/CodeCompletion/objc-expr.m @@ -0,0 +1,17 @@ +// Note: the run lines follow all tests, since line/column matter here + +id testCompleteAfterAtSign() { + return @""; +} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:11 %s -fno-const-strings -o - | FileCheck -check-prefix=AT %s +// CHECK-AT: COMPLETION: Pattern : [#NSString *#]"<#string#>" +// CHECK-AT: COMPLETION: Pattern : [#id#](<#expression#>) +// CHECK-AT: COMPLETION: Pattern : [#NSArray *#][<#objects, ...#>] +// CHECK-AT: COMPLETION: Pattern : [#char[]#]encode(<#type-name#>) +// CHECK-AT: COMPLETION: Pattern : [#Protocol *#]protocol(<#protocol-name#>) +// CHECK-AT: COMPLETION: Pattern : [#SEL#]selector(<#selector#>) +// CHECK-AT: COMPLETION: Pattern : [#NSDictionary *#]{<#key#> : <#object, ...#>} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:11 %s -fconst-strings -o - | FileCheck -check-prefix=CONST-STRINGS %s +// CHECK-CONST-STRINGS: COMPLETION: Pattern : [#const char[]#]encode(<#type-name#>) diff --git a/test/CodeGen/2002-05-24-Alloca.c b/test/CodeGen/2002-05-24-Alloca.c deleted file mode 100644 index 30ba8bb8e218..000000000000 --- a/test/CodeGen/2002-05-24-Alloca.c +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o /dev/null - -typedef __SIZE_TYPE__ size_t; -void *alloca(size_t size); -char *strcpy(char *restrict s1, const char *restrict s2); -int puts(const char *s); -int main(int argc, char **argv) { - char *C = (char*)alloca(argc); - strcpy(C, argv[0]); - puts(C); -} diff --git a/test/CodeGen/2005-07-20-SqrtNoErrno.c b/test/CodeGen/2005-07-20-SqrtNoErrno.c index f40f61d27f31..96761e4cfb2e 100644 --- a/test/CodeGen/2005-07-20-SqrtNoErrno.c +++ b/test/CodeGen/2005-07-20-SqrtNoErrno.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s // llvm.sqrt has undefined behavior on negative inputs, so it is // inappropriate to translate C/C++ sqrt to this. float sqrtf(float x); diff --git a/test/CodeGen/2007-02-25-C-DotDotDot.c b/test/CodeGen/2007-02-25-C-DotDotDot.c index 7b2e418f4918..abc46683cee9 100644 --- a/test/CodeGen/2007-02-25-C-DotDotDot.c +++ b/test/CodeGen/2007-02-25-C-DotDotDot.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -O0 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -O0 %s -emit-llvm -o - | FileCheck %s // Make sure the call to foo is compiled as: // call float @foo() diff --git a/test/CodeGen/2008-01-25-ByValReadNone.c b/test/CodeGen/2008-01-25-ByValReadNone.c index 06ad1eef00f1..d977139b2120 100644 --- a/test/CodeGen/2008-01-25-ByValReadNone.c +++ b/test/CodeGen/2008-01-25-ByValReadNone.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -emit-llvm -o - %s | not grep readonly // RUN: %clang_cc1 -emit-llvm -o - %s | not grep readnone -// XFAIL: arm +// XFAIL: arm,mips // The struct being passed byval means that we cannot mark the // function readnone. Readnone would allow stores to the arg to diff --git a/test/CodeGen/2008-03-05-syncPtr.c b/test/CodeGen/2008-03-05-syncPtr.c index 784295ce6890..93f328a57949 100644 --- a/test/CodeGen/2008-03-05-syncPtr.c +++ b/test/CodeGen/2008-03-05-syncPtr.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s int* foo(int** a, int* b, int* c) { return __sync_val_compare_and_swap (a, b, c); diff --git a/test/CodeGen/2008-04-08-NoExceptions.c b/test/CodeGen/2008-04-08-NoExceptions.c index 6d5d20ff8541..ab2781b58b9c 100644 --- a/test/CodeGen/2008-04-08-NoExceptions.c +++ b/test/CodeGen/2008-04-08-NoExceptions.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s void f(void); void g(void) { diff --git a/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c b/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c index 8787bd453e65..2bcc7c3933ff 100644 --- a/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c +++ b/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 %s -triple powerpc-pc-linux -emit-llvm -o - | grep {i32 32} | count 3 // XFAIL: * // Every printf has 'i32 0' for the GEP of the string; no point counting those. diff --git a/test/CodeGen/2009-09-24-SqrtErrno.c b/test/CodeGen/2009-09-24-SqrtErrno.c index b4a04ff6b6ab..6a3396791fac 100644 --- a/test/CodeGen/2009-09-24-SqrtErrno.c +++ b/test/CodeGen/2009-09-24-SqrtErrno.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -fmath-errno | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fmath-errno | FileCheck %s // llvm.sqrt has undefined behavior on negative inputs, so it is // inappropriate to translate C/C++ sqrt to this. diff --git a/test/CodeGen/2009-10-20-GlobalDebug.c b/test/CodeGen/2009-10-20-GlobalDebug.c index 8828eef40d65..8a9dfdde685f 100644 --- a/test/CodeGen/2009-10-20-GlobalDebug.c +++ b/test/CodeGen/2009-10-20-GlobalDebug.c @@ -6,5 +6,5 @@ int main() { return 0; } -// CHECK: !14 = metadata !{i32 {{.*}}, i32 0, metadata !5, metadata !"localstatic", metadata !"localstatic", metadata !"", metadata !6, i32 5, metadata !9, i32 1, i32 1, i32* @main.localstatic} ; [ DW_TAG_variable ] -// CHECK: !15 = metadata !{i32 {{.*}}, i32 0, null, metadata !"global", metadata !"global", metadata !"", metadata !6, i32 3, metadata !9, i32 0, i32 1, i32* @global} ; [ DW_TAG_variable ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !5, metadata !"localstatic", metadata !"localstatic", metadata !"", metadata !6, i32 5, metadata !9, i32 1, i32 1, i32* @main.localstatic} ; [ DW_TAG_variable ] +// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"global", metadata !"global", metadata !"", metadata !6, i32 3, metadata !9, i32 0, i32 1, i32* @global} ; [ DW_TAG_variable ] diff --git a/test/CodeGen/2010-02-10-PointerName.c b/test/CodeGen/2010-02-10-PointerName.c index 910dd30fc603..2837de4b8b44 100644 --- a/test/CodeGen/2010-02-10-PointerName.c +++ b/test/CodeGen/2010-02-10-PointerName.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -g -o - | grep DW_TAG_pointer_type | grep -v char +// RUN: %clang_cc1 %s -emit-llvm -g -o - | grep DW_TAG_pointer_type | grep -v {"char"} char i = 1; void foo() { diff --git a/test/CodeGen/2010-05-26-AsmSideEffect.c b/test/CodeGen/2010-05-26-AsmSideEffect.c index 7dd86aeb54d7..8ae7cb535408 100644 --- a/test/CodeGen/2010-05-26-AsmSideEffect.c +++ b/test/CodeGen/2010-05-26-AsmSideEffect.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 %s -emit-llvm -triple arm-apple-darwin -o - | FileCheck %s // Radar 8026855 diff --git a/test/CodeGen/Atomics.c b/test/CodeGen/Atomics.c index c440b6c1909e..2bb38fd749c2 100644 --- a/test/CodeGen/Atomics.c +++ b/test/CodeGen/Atomics.c @@ -1,6 +1,6 @@ // Test frontend handling of __sync builtins. // Modified from a gcc testcase. -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s signed char sc; unsigned char uc; diff --git a/test/CodeGen/address-safety-attr.cpp b/test/CodeGen/address-safety-attr.cpp index 9d0fb9596330..da68b1d703fa 100644 --- a/test/CodeGen/address-safety-attr.cpp +++ b/test/CodeGen/address-safety-attr.cpp @@ -33,3 +33,9 @@ int TemplateAddressSafetyOk() { return i; } int force_instance = TemplateAddressSafetyOk<42>() + TemplateNoAddressSafety<42>(); + +// Check that __cxx_global_var_init* get the address_safety attribute. +int global1 = 0; +int global2 = *(int*)((char*)&global1+1); +// CHECK-NOT: @__cxx_global_var_init{{.*}}address_safety +// ASAN: @__cxx_global_var_init{{.*}}address_safety diff --git a/test/CodeGen/address-space.c b/test/CodeGen/address-space.c index 04f88dc20a1a..9de0670b1024 100644 --- a/test/CodeGen/address-space.c +++ b/test/CodeGen/address-space.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s -// RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @A' -// RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @B' +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | grep 'load.*addrspace(2).. @A' +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | grep 'load.*addrspace(2).. @B' // CHECK: @foo = common addrspace(1) global diff --git a/test/CodeGen/alloca.c b/test/CodeGen/alloca.c new file mode 100644 index 000000000000..30ba8bb8e218 --- /dev/null +++ b/test/CodeGen/alloca.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm %s -o /dev/null + +typedef __SIZE_TYPE__ size_t; +void *alloca(size_t size); +char *strcpy(char *restrict s1, const char *restrict s2); +int puts(const char *s); +int main(int argc, char **argv) { + char *C = (char*)alloca(argc); + strcpy(C, argv[0]); + puts(C); +} diff --git a/test/CodeGen/altivec.c b/test/CodeGen/altivec.c index 29823031b56a..6c924a7fe36f 100644 --- a/test/CodeGen/altivec.c +++ b/test/CodeGen/altivec.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s // Check initialization diff --git a/test/CodeGen/annotations-builtin.c b/test/CodeGen/annotations-builtin.c index 42421a0a5200..7938e49aa646 100644 --- a/test/CodeGen/annotations-builtin.c +++ b/test/CodeGen/annotations-builtin.c @@ -25,9 +25,7 @@ int main(int argc, char **argv) { // CHECK: call i32 @llvm.annotation.i32 long long lla = __builtin_annotation(llfoo, "annotation_a"); -// CHECK: trunc i64 {{.*}} to i32 -// CHECK-NEXT: call i32 @llvm.annotation.i32 -// CHECK-NEXT: zext i32 {{.*}} to i64 +// CHECK: call i64 @llvm.annotation.i64 int inta = __builtin_annotation(intfoo, "annotation_a"); // CHECK: load i32* @intfoo @@ -35,15 +33,11 @@ int main(int argc, char **argv) { // CHECK-NEXT: store short shorta = __builtin_annotation(shortfoo, "annotation_a"); -// CHECK: sext i16 {{.*}} to i32 -// CHECK-NEXT: call i32 @llvm.annotation.i32 -// CHECK-NEXT: trunc i32 {{.*}} to i16 +// CHECK: call i16 @llvm.annotation.i16 char chara = __builtin_annotation(charfoo, "annotation_a"); -// CHECK: sext i8 {{.*}} to i32 -// CHECK-NEXT: call i32 @llvm.annotation.i32 -// CHECK-NEXT: trunc i32 {{.*}} to i8 -// +// CHECK: call i8 @llvm.annotation.i8 + char **arg = (char**) __builtin_annotation((int) argv, "annotation_a"); // CHECK: ptrtoint i8** {{.*}} to // CHECK: call i32 @llvm.annotation.i32 diff --git a/test/CodeGen/arm-aapcs-vfp.c b/test/CodeGen/arm-aapcs-vfp.c index 017c14524e97..614b52dad576 100644 --- a/test/CodeGen/arm-aapcs-vfp.c +++ b/test/CodeGen/arm-aapcs-vfp.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \ // RUN: -target-abi aapcs \ // RUN: -target-cpu cortex-a8 \ @@ -33,6 +34,13 @@ void test_complex(__complex__ double cd) { complex_callee(cd); } +// Long double is the same as double on AAPCS, it should be homogeneous. +extern void complex_long_callee(__complex__ long double); +// CHECK: define arm_aapcs_vfpcc void @test_complex_long(double %{{.*}}, double %{{.*}}) +void test_complex_long(__complex__ long double cd) { + complex_callee(cd); +} + // Structs with more than 4 elements of the base type are not treated // as homogeneous aggregates. Test that. @@ -80,3 +88,7 @@ extern void neon_callee(struct neon_struct); void test_neon(struct neon_struct arg) { neon_callee(arg); } + +// CHECK: define arm_aapcs_vfpcc void @f33(%struct.s33* byval %s) +struct s33 { char buf[32*32]; }; +void f33(struct s33 s) { } diff --git a/test/CodeGen/arm-aapcs-zerolength-bitfield.c b/test/CodeGen/arm-aapcs-zerolength-bitfield.c index 9fece197fa82..140ff6c42436 100644 --- a/test/CodeGen/arm-aapcs-zerolength-bitfield.c +++ b/test/CodeGen/arm-aapcs-zerolength-bitfield.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -target-abi aapcs -triple armv7-apple-darwin10 %s -verify #include diff --git a/test/CodeGen/arm-apcs-zerolength-bitfield.c b/test/CodeGen/arm-apcs-zerolength-bitfield.c index 3f9452539408..049ffae4dc6f 100644 --- a/test/CodeGen/arm-apcs-zerolength-bitfield.c +++ b/test/CodeGen/arm-apcs-zerolength-bitfield.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -target-abi apcs-gnu -triple armv7-apple-darwin10 %s -verify // // Note: gcc forces the alignment to 4 bytes, regardless of the type of the diff --git a/test/CodeGen/arm-arguments.c b/test/CodeGen/arm-arguments.c index 4686d4ab9593..2ec729eb9b3d 100644 --- a/test/CodeGen/arm-arguments.c +++ b/test/CodeGen/arm-arguments.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=APCS-GNU %s // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s @@ -165,3 +166,15 @@ void f31(struct s31 s) { } // APCS-GNU: %s = alloca %struct.s31, align 4 // APCS-GNU: alloca [1 x i32] // APCS-GNU: store [1 x i32] %s.coerce, [1 x i32]* + +// PR13562 +struct s32 { double x; }; +void f32(struct s32 s) { } +// AAPCS: @f32([1 x i64] %s.coerce) +// APCS-GNU: @f32([2 x i32] %s.coerce) + +// PR13350 +struct s33 { char buf[32*32]; }; +void f33(struct s33 s) { } +// APCS-GNU: define void @f33(%struct.s33* byval %s) +// AAPCS: define arm_aapcscc void @f33(%struct.s33* byval %s) diff --git a/test/CodeGen/arm-asm-variable.c b/test/CodeGen/arm-asm-variable.c index 865d1971e8b9..f874269b0a01 100644 --- a/test/CodeGen/arm-asm-variable.c +++ b/test/CodeGen/arm-asm-variable.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s typedef long long int64_t; diff --git a/test/CodeGen/arm-asm.c b/test/CodeGen/arm-asm.c index 9b1082a198e3..bd2fe1199369 100644 --- a/test/CodeGen/arm-asm.c +++ b/test/CodeGen/arm-asm.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s int t1() { static float k = 1.0f; diff --git a/test/CodeGen/arm-cc.c b/test/CodeGen/arm-cc.c index 74eecc755f75..80ebe687c11b 100644 --- a/test/CodeGen/arm-cc.c +++ b/test/CodeGen/arm-cc.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=DARWIN-APCS %s // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=DARWIN-AAPCS %s // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-APCS %s diff --git a/test/CodeGen/arm-clear.c b/test/CodeGen/arm-clear.c index eda64ce99ee4..51506dfed10d 100644 --- a/test/CodeGen/arm-clear.c +++ b/test/CodeGen/arm-clear.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s void clear0(void *ptr) { diff --git a/test/CodeGen/arm-homogenous.c b/test/CodeGen/arm-homogenous.c index eb3d5a6bd631..b8d046af9722 100644 --- a/test/CodeGen/arm-homogenous.c +++ b/test/CodeGen/arm-homogenous.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7---eabi -target-abi aapcs -mfloat-abi hard -emit-llvm %s -o - | FileCheck %s typedef long long int64_t; @@ -157,4 +158,4 @@ void test_return_union_with_struct_with_fundamental_elems(void) { // FIXME: Tests necessary: // - Vectors -// - C++ stuff \ No newline at end of file +// - C++ stuff diff --git a/test/CodeGen/arm-inline-asm.c b/test/CodeGen/arm-inline-asm.c index 0152b050fd7f..95bb507c2798 100644 --- a/test/CodeGen/arm-inline-asm.c +++ b/test/CodeGen/arm-inline-asm.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s void t1 (void *f, int g) { diff --git a/test/CodeGen/arm-pcs.c b/test/CodeGen/arm-pcs.c index d722f84cebd7..fc658c3bef6f 100644 --- a/test/CodeGen/arm-pcs.c +++ b/test/CodeGen/arm-pcs.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -emit-llvm -w -o - < %s | FileCheck %s typedef int __attribute__((pcs("aapcs"))) (*aapcs_fn)(void); typedef int __attribute__((pcs("aapcs-vfp"))) (*aapcs_vfp_fn)(void); diff --git a/test/CodeGen/arm-vaarg-align.c b/test/CodeGen/arm-vaarg-align.c index 1187c022914f..2270c8b4f971 100644 --- a/test/CodeGen/arm-vaarg-align.c +++ b/test/CodeGen/arm-vaarg-align.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple arm -target-abi aapcs %s -emit-llvm -o - | FileCheck -check-prefix=AAPCS %s // RUN: %clang_cc1 -triple arm -target-abi apcs-gnu %s -emit-llvm -o - | FileCheck -check-prefix=APCS-GNU %s /* diff --git a/test/CodeGen/arm-vector-align.c b/test/CodeGen/arm-vector-align.c index b481a0c97f8f..9e1ae5da11e2 100644 --- a/test/CodeGen/arm-vector-align.c +++ b/test/CodeGen/arm-vector-align.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumbv7-apple-darwin \ // RUN: -target-abi apcs-gnu \ // RUN: -target-cpu cortex-a8 \ diff --git a/test/CodeGen/arm-vector-arguments.c b/test/CodeGen/arm-vector-arguments.c index 6bfb2f48a7f1..9bdddb72696e 100644 --- a/test/CodeGen/arm-vector-arguments.c +++ b/test/CodeGen/arm-vector-arguments.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \ // RUN: -target-abi apcs-gnu \ // RUN: -target-cpu cortex-a8 \ diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c index 84f26e1013c1..b0097368ec28 100644 --- a/test/CodeGen/asm.c +++ b/test/CodeGen/asm.c @@ -220,3 +220,13 @@ typedef long long __m256i __attribute__((__vector_size__(32))); void t26 (__m256i *p) { __asm__ volatile("vmovaps %0, %%ymm0" :: "m" (*(__m256i*)p) : "ymm0"); } + +// Check to make sure the inline asm non-standard dialect attribute _not_ is +// emitted. +void t27(void) { + asm volatile("nop"); +// CHECK: @t27 +// CHECK: call void asm sideeffect "nop" +// CHECK-NOT: ia_nsdialect +// CHECK: ret void +} diff --git a/test/CodeGen/asm_arm.c b/test/CodeGen/asm_arm.c index 633bf5569dd6..4b764b7d3663 100644 --- a/test/CodeGen/asm_arm.c +++ b/test/CodeGen/asm_arm.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv6-unknown-unknown -emit-llvm -o - %s | FileCheck %s void test0(void) { diff --git a/test/CodeGen/atomic_ops.c b/test/CodeGen/atomic_ops.c index 9a18c9e94492..481d1e06fbd5 100644 --- a/test/CodeGen/atomic_ops.c +++ b/test/CodeGen/atomic_ops.c @@ -1,11 +1,20 @@ // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -void foo(void) +void foo(int x) { _Atomic(int) i = 0; + _Atomic(short) j = 0; // Check that multiply / divides on atomics produce a cmpxchg loop - i *= 2; // CHECK: cmpxchg - i /= 2; // CHECK: cmpxchg + i *= 2; + // CHECK: mul nsw i32 + // CHECK: cmpxchg i32* + i /= 2; + // CHECK: sdiv i32 + // CHECK: cmpxchg i32* + j /= x; + // CHECK: sdiv i32 + // CHECK: cmpxchg i16* + // These should be emitting atomicrmw instructions, but they aren't yet i += 2; // CHECK: cmpxchg i -= 2; // CHECK: cmpxchg diff --git a/test/CodeGen/attr-coldhot.c b/test/CodeGen/attr-coldhot.c new file mode 100644 index 000000000000..b9bb299b5e49 --- /dev/null +++ b/test/CodeGen/attr-coldhot.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s + +int test1() __attribute__((__cold__)) { + return 42; + +// Check that we set the optsize attribute on the function. +// CHECK: @test1{{.*}}optsize +// CHECK: ret +} diff --git a/test/CodeGen/attributes.c b/test/CodeGen/attributes.c index 4e73af60439d..e971a793473a 100644 --- a/test/CodeGen/attributes.c +++ b/test/CodeGen/attributes.c @@ -81,3 +81,11 @@ void t21(void) { } // CHECK: [[FPTRVAR:%[a-z0-9]+]] = load void (i32)** @fptr // CHECK-NEXT: call x86_fastcallcc void [[FPTRVAR]](i32 10) + + +// PR9356: We might want to err on this, but for now at least make sure we +// use the section in the definition. +void __attribute__((section(".foo"))) t22(void); +void __attribute__((section(".bar"))) t22(void) {} + +// CHECK: define void @t22() nounwind section ".bar" diff --git a/test/CodeGen/avx-builtins.c b/test/CodeGen/avx-builtins.c index b963c97cc18a..0e5a741bcf67 100644 --- a/test/CodeGen/avx-builtins.c +++ b/test/CodeGen/avx-builtins.c @@ -23,3 +23,73 @@ __m256i test__mm256_loadu_si256(void* p) { // CHECK: load <4 x i64>* %{{.+}}, align 1 return _mm256_loadu_si256(p); } + +__m128i test_mm_cmpestrm(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestrm128 + return _mm_cmpestrm(A, LA, B, LB, 7); +} + +int test_mm_cmpestri(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestri128 + return _mm_cmpestri(A, LA, B, LB, 7); +} + +int test_mm_cmpestra(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestria128 + return _mm_cmpestra(A, LA, B, LB, 7); +} + +int test_mm_cmpestrc(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestric128 + return _mm_cmpestrc(A, LA, B, LB, 7); +} + +int test_mm_cmpestro(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestrio128 + return _mm_cmpestro(A, LA, B, LB, 7); +} + +int test_mm_cmpestrs(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestris128 + return _mm_cmpestrs(A, LA, B, LB, 7); +} + +int test_mm_cmpestrz(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestriz128 + return _mm_cmpestrz(A, LA, B, LB, 7); +} + +__m128i test_mm_cmpistrm(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistrm128 + return _mm_cmpistrm(A, B, 7); +} + +int test_mm_cmpistri(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistri128 + return _mm_cmpistri(A, B, 7); +} + +int test_mm_cmpistra(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistria128 + return _mm_cmpistra(A, B, 7); +} + +int test_mm_cmpistrc(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistric128 + return _mm_cmpistrc(A, B, 7); +} + +int test_mm_cmpistro(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistrio128 + return _mm_cmpistro(A, B, 7); +} + +int test_mm_cmpistrs(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistris128 + return _mm_cmpistrs(A, B, 7); +} + +int test_mm_cmpistrz(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistriz128 + return _mm_cmpistrz(A, B, 7); +} diff --git a/test/CodeGen/avx2-builtins.c b/test/CodeGen/avx2-builtins.c index 7d166b562638..b5bc60503173 100644 --- a/test/CodeGen/avx2-builtins.c +++ b/test/CodeGen/avx2-builtins.c @@ -10,6 +10,11 @@ __m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) { return _mm256_mpsadbw_epu8(x, y, 3); } +__m256i test_mm256_sad_epu8(__m256i x, __m256i y) { + // CHECK: @llvm.x86.avx2.psad.bw + return _mm256_sad_epu8(x, y); +} + __m256i test_mm256_abs_epi8(__m256i a) { // CHECK: @llvm.x86.avx2.pabs.b return _mm256_abs_epi8(a); @@ -780,3 +785,154 @@ __m128i test_mm_srlv_epi64(__m128i a, __m128i b) { // CHECK: @llvm.x86.avx2.psrlv.q return _mm_srlv_epi64(a, b); } + +__m128d test_mm_mask_i32gather_pd(__m128d a, double const *b, __m128i c, + __m128d d) { + // CHECK: @llvm.x86.avx2.gather.d.pd + return _mm_mask_i32gather_pd(a, b, c, d, 2); +} + +__m256d test_mm256_mask_i32gather_pd(__m256d a, double const *b, __m128i c, + __m256d d) { + // CHECK: @llvm.x86.avx2.gather.d.pd.256 + return _mm256_mask_i32gather_pd(a, b, c, d, 2); +} +__m128d test_mm_mask_i64gather_pd(__m128d a, double const *b, __m128i c, + __m128d d) { + // CHECK: @llvm.x86.avx2.gather.q.pd + return _mm_mask_i64gather_pd(a, b, c, d, 2); +} +__m256d test_mm256_mask_i64gather_pd(__m256d a, double const *b, __m256i c, + __m256d d) { + // CHECK: @llvm.x86.avx2.gather.q.pd.256 + return _mm256_mask_i64gather_pd(a, b, c, d, 2); +} + +__m128 test_mm_mask_i32gather_ps(__m128 a, float const *b, __m128i c, + __m128 d) { + // CHECK: @llvm.x86.avx2.gather.d.ps + return _mm_mask_i32gather_ps(a, b, c, d, 2); +} +__m256 test_mm256_mask_i32gather_ps(__m256 a, float const *b, __m256i c, + __m256 d) { + // CHECK: @llvm.x86.avx2.gather.d.ps.256 + return _mm256_mask_i32gather_ps(a, b, c, d, 2); +} +__m128 test_mm_mask_i64gather_ps(__m128 a, float const *b, __m128i c, + __m128 d) { + // CHECK: @llvm.x86.avx2.gather.q.ps + return _mm_mask_i64gather_ps(a, b, c, d, 2); +} +__m128 test_mm256_mask_i64gather_ps(__m128 a, float const *b, __m256i c, + __m128 d) { + // CHECK: @llvm.x86.avx2.gather.q.ps.256 + return _mm256_mask_i64gather_ps(a, b, c, d, 2); +} + +__m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.d.d + return _mm_mask_i32gather_epi32(a, b, c, d, 2); +} +__m256i test_mm256_mask_i32gather_epi32(__m256i a, int const *b, __m256i c, + __m256i d) { + // CHECK: @llvm.x86.avx2.gather.d.d.256 + return _mm256_mask_i32gather_epi32(a, b, c, d, 2); +} +__m128i test_mm_mask_i64gather_epi32(__m128i a, int const *b, __m128i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.q.d + return _mm_mask_i64gather_epi32(a, b, c, d, 2); +} +__m128i test_mm256_mask_i64gather_epi32(__m128i a, int const *b, __m256i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.q.d.256 + return _mm256_mask_i64gather_epi32(a, b, c, d, 2); +} + +__m128i test_mm_mask_i32gather_epi64(__m128i a, int const *b, __m128i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.d.q + return _mm_mask_i32gather_epi64(a, b, c, d, 2); +} +__m256i test_mm256_mask_i32gather_epi64(__m256i a, int const *b, __m128i c, + __m256i d) { + // CHECK: @llvm.x86.avx2.gather.d.q.256 + return _mm256_mask_i32gather_epi64(a, b, c, d, 2); +} +__m128i test_mm_mask_i64gather_epi64(__m128i a, int const *b, __m128i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.q.q + return _mm_mask_i64gather_epi64(a, b, c, d, 2); +} +__m256i test_mm256_mask_i64gather_epi64(__m256i a, int const *b, __m256i c, + __m256i d) { + // CHECK: @llvm.x86.avx2.gather.q.q.256 + return _mm256_mask_i64gather_epi64(a, b, c, d, 2); +} + +__m128d test_mm_i32gather_pd(double const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.pd + return _mm_i32gather_pd(b, c, 2); +} +__m256d test_mm256_i32gather_pd(double const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.pd.256 + return _mm256_i32gather_pd(b, c, 2); +} +__m128d test_mm_i64gather_pd(double const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.q.pd + return _mm_i64gather_pd(b, c, 2); +} +__m256d test_mm256_i64gather_pd(double const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.q.pd.256 + return _mm256_i64gather_pd(b, c, 2); +} +__m128 test_mm_i32gather_ps(float const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.ps + return _mm_i32gather_ps(b, c, 2); +} +__m256 test_mm256_i32gather_ps(float const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.d.ps.256 + return _mm256_i32gather_ps(b, c, 2); +} +__m128 test_mm_i64gather_ps(float const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.q.ps + return _mm_i64gather_ps(b, c, 2); +} +__m128 test_mm256_i64gather_ps(float const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.q.ps.256 + return _mm256_i64gather_ps(b, c, 2); +} + +__m128i test_mm_i32gather_epi32(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.d + return _mm_i32gather_epi32(b, c, 2); +} +__m256i test_mm256_i32gather_epi32(int const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.d.d.256 + return _mm256_i32gather_epi32(b, c, 2); +} +__m128i test_mm_i64gather_epi32(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.q.d + return _mm_i64gather_epi32(b, c, 2); +} +__m128i test_mm256_i64gather_epi32(int const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.q.d.256 + return _mm256_i64gather_epi32(b, c, 2); +} +__m128i test_mm_i32gather_epi64(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.q + return _mm_i32gather_epi64(b, c, 2); +} +__m256i test_mm256_i32gather_epi64(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.q.256 + return _mm256_i32gather_epi64(b, c, 2); +} +__m128i test_mm_i64gather_epi64(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.q.q + return _mm_i64gather_epi64(b, c, 2); +} +__m256i test_mm256_i64gather_epi64(int const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.q.q.256 + return _mm256_i64gather_epi64(b, c, 2); +} diff --git a/test/CodeGen/block-3.c b/test/CodeGen/block-3.c index 95cb6a735c73..29c1bb5803c7 100644 --- a/test/CodeGen/block-3.c +++ b/test/CodeGen/block-3.c @@ -6,3 +6,15 @@ int main() { __attribute__((__blocks__(byref))) int index = ({ int __a; int __b; __a < __b ? __b : __a; }); }; } + +// PR13229 +// rdar://11777609 +typedef struct {} Z; + +typedef int (^B)(Z); + +void testPR13229() { + Z z1; + B b1 = ^(Z z1) { return 1; }; + b1(z1); +} diff --git a/test/CodeGen/block-byref-aggr.c b/test/CodeGen/block-byref-aggr.c index 3027df04861c..eb342b856e4f 100644 --- a/test/CodeGen/block-byref-aggr.c +++ b/test/CodeGen/block-byref-aggr.c @@ -1,17 +1,66 @@ // RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 | FileCheck %s -// rdar://9309454 -typedef struct { int v; } RetType; +// CHECK: [[AGG:%.*]] = type { i32 } +typedef struct { int v; } Agg; +Agg makeAgg(void); -RetType func(); +// When assigning into a __block variable, ensure that we compute that +// address *after* evaluating the RHS when the RHS has the capacity to +// cause a block copy. rdar://9309454 +void test0() { + __block Agg a = {100}; -int main () { - __attribute__((__blocks__(byref))) RetType a = {100}; + a = makeAgg(); +} +// CHECK: define void @test0() +// CHECK: [[A:%.*]] = alloca [[BYREF:%.*]], align 8 +// CHECK-NEXT: [[TEMP:%.*]] = alloca [[AGG]], align 4 +// CHECK: [[RESULT:%.*]] = call i32 @makeAgg() +// CHECK-NEXT: [[T0:%.*]] = getelementptr [[AGG]]* [[TEMP]], i32 0, i32 0 +// CHECK-NEXT: store i32 [[RESULT]], i32* [[T0]] +// Check that we properly assign into the forwarding pointer. +// CHECK-NEXT: [[A_FORWARDING:%.*]] = getelementptr inbounds [[BYREF]]* [[A]], i32 0, i32 1 +// CHECK-NEXT: [[T0:%.*]] = load [[BYREF]]** [[A_FORWARDING]] +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF]]* [[T0]], i32 0, i32 4 +// CHECK-NEXT: [[T2:%.*]] = bitcast [[AGG]]* [[T1]] to i8* +// CHECK-NEXT: [[T3:%.*]] = bitcast [[AGG]]* [[TEMP]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T2]], i8* [[T3]], i64 4, i32 4, i1 false) +// Verify that there's nothing else significant in the function. +// CHECK-NEXT: [[T0:%.*]] = bitcast [[BYREF]]* [[A]] to i8* +// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8) +// CHECK-NEXT: ret void - a = func(); +// When chaining assignments into __block variables, make sure we +// propagate the actual value into the outer variable. +// rdar://11757470 +void test1() { + __block Agg a, b; + a = b = makeAgg(); } -// CHECK: [[C1:%.*]] = call i32 (...)* @func() -// CHECK-NEXT: [[CO:%.*]] = getelementptr -// CHECK-NEXT: store i32 [[C1]], i32* [[CO]] -// CHECK-NEXT: [[FORWARDING:%.*]] = getelementptr inbounds [[BR:%.*]]* [[A:%.*]], i32 0, i32 1 -// CHECK-NEXT: [[O:%.*]] = load [[BR]]** [[FORWARDING]] +// CHECK: define void @test1() +// CHECK: [[A:%.*]] = alloca [[A_BYREF:%.*]], align 8 +// CHECK-NEXT: [[B:%.*]] = alloca [[B_BYREF:%.*]], align 8 +// CHECK-NEXT: [[TEMP:%.*]] = alloca [[AGG]], align 4 +// CHECK: [[RESULT:%.*]] = call i32 @makeAgg() +// CHECK-NEXT: [[T0:%.*]] = getelementptr [[AGG]]* [[TEMP]], i32 0, i32 0 +// CHECK-NEXT: store i32 [[RESULT]], i32* [[T0]] +// Check that we properly assign into the forwarding pointer, first for b: +// CHECK-NEXT: [[B_FORWARDING:%.*]] = getelementptr inbounds [[B_BYREF]]* [[B]], i32 0, i32 1 +// CHECK-NEXT: [[T0:%.*]] = load [[B_BYREF]]** [[B_FORWARDING]] +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[B_BYREF]]* [[T0]], i32 0, i32 4 +// CHECK-NEXT: [[T2:%.*]] = bitcast [[AGG]]* [[T1]] to i8* +// CHECK-NEXT: [[T3:%.*]] = bitcast [[AGG]]* [[TEMP]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T2]], i8* [[T3]], i64 4, i32 4, i1 false) +// Then for 'a': +// CHECK-NEXT: [[A_FORWARDING:%.*]] = getelementptr inbounds [[A_BYREF]]* [[A]], i32 0, i32 1 +// CHECK-NEXT: [[T0:%.*]] = load [[A_BYREF]]** [[A_FORWARDING]] +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[A_BYREF]]* [[T0]], i32 0, i32 4 +// CHECK-NEXT: [[T2:%.*]] = bitcast [[AGG]]* [[T1]] to i8* +// CHECK-NEXT: [[T3:%.*]] = bitcast [[AGG]]* [[TEMP]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T2]], i8* [[T3]], i64 4, i32 4, i1 false) +// Verify that there's nothing else significant in the function. +// CHECK-NEXT: [[T0:%.*]] = bitcast [[B_BYREF]]* [[B]] to i8* +// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8) +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A_BYREF]]* [[A]] to i8* +// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8) +// CHECK-NEXT: ret void diff --git a/test/CodeGen/blocks.c b/test/CodeGen/blocks.c index bef44c369015..71f7171c7181 100644 --- a/test/CodeGen/blocks.c +++ b/test/CodeGen/blocks.c @@ -12,7 +12,7 @@ struct s0 { int a[64]; }; -// CHECK: define internal void @__f2_block_invoke_0(%struct.s0* noalias sret {{%.*}}, i8* {{%.*}}, %struct.s0* byval align 4 {{.*}}) +// CHECK: define internal void @__f2_block_invoke(%struct.s0* noalias sret {{%.*}}, i8* {{%.*}}, %struct.s0* byval align 4 {{.*}}) struct s0 f2(struct s0 a0) { return ^(struct s0 a1){ return a1; }(a0); } @@ -40,3 +40,29 @@ void f3() { _Bool b = 0; f3_helper(^{ if (b) {} }); } + +// rdar://problem/11322251 +// The bool can fill in between the header and the long long. +// Add the appropriate amount of padding between them. +void f4_helper(long long (^)(void)); +// CHECK: define void @f4() +void f4(void) { + _Bool b = 0; + long long ll = 0; + // CHECK: alloca <{ i8*, i32, i32, i8*, {{%.*}}*, i8, [3 x i8], i64 }>, align 8 + f4_helper(^{ if (b) return ll; return 0LL; }); +} + +// rdar://problem/11354538 +// The alignment after rounding up to the align of F5 is actually +// greater than the required alignment. Don't assert. +struct F5 { + char buffer[32] __attribute((aligned)); +}; +void f5_helper(void (^)(struct F5 *)); +// CHECK: define void @f5() +void f5(void) { + struct F5 value; + // CHECK: alloca <{ i8*, i32, i32, i8*, {{%.*}}*, [12 x i8], [[F5:%.*]] }>, align 16 + f5_helper(^(struct F5 *slot) { *slot = value; }); +} diff --git a/test/CodeGen/blocksignature.c b/test/CodeGen/blocksignature.c index 63fe1248a86d..fd586eb1e139 100644 --- a/test/CodeGen/blocksignature.c +++ b/test/CodeGen/blocksignature.c @@ -8,7 +8,7 @@ // X32: [[STR1:@.*]] = private unnamed_addr constant [6 x i8] c"v4@?0\00" // X32: @__block_descriptor_tmp = internal constant [[FULL_DESCRIPTOR_T:.*]] { i32 0, i32 20, i8* getelementptr inbounds ([6 x i8]* [[STR1]], i32 0, i32 0), i8* null } -// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @__block_global_{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) } +// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @global_block_invoke{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) } // X32: [[STR2:@.*]] = private unnamed_addr constant [11 x i8] c"i12@?0c4f8\00" // X32: @__block_descriptor_tmp{{.*}} = internal constant [[FULL_DESCRIPTOR_T]] { i32 0, i32 24, i8* getelementptr inbounds ([11 x i8]* [[STR2]], i32 0, i32 0), i8* null } // X32: store i32 1073741824, i32* diff --git a/test/CodeGen/blockwithlocalstatic.c b/test/CodeGen/blockwithlocalstatic.c index 1fdaaf37a1b3..8b4210ed1901 100644 --- a/test/CodeGen/blockwithlocalstatic.c +++ b/test/CodeGen/blockwithlocalstatic.c @@ -1,17 +1,17 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-llvm -o - %s | FileCheck %s // pr8707 -// CHECK: @__block_global_0.test = internal global i32 +// CHECK: @block_block_invoke.test = internal global i32 int (^block)(void) = ^ { static int test=0; return test; }; -// CHECK: @__block_global_1.test = internal global i32 +// CHECK: @block1_block_invoke_2.test = internal global i32 void (^block1)(void) = ^ { static int test = 2; return; }; -// CHECK: @__block_global_2.test = internal global i32 +// CHECK: @block2_block_invoke_3.test = internal global i32 int (^block2)(void) = ^ { static int test = 5; return test; diff --git a/test/CodeGen/bmi-builtins.c b/test/CodeGen/bmi-builtins.c index 47b0da204ee9..2e1ba12d9b3c 100644 --- a/test/CodeGen/bmi-builtins.c +++ b/test/CodeGen/bmi-builtins.c @@ -5,9 +5,9 @@ #include -unsigned short test__tzcnt16(unsigned short __X) { +unsigned short test__tzcnt_u16(unsigned short __X) { // CHECK: @llvm.cttz.i16 - return __tzcnt16(__X); + return __tzcnt_u16(__X); } unsigned int test__andn_u32(unsigned int __X, unsigned int __Y) { @@ -39,9 +39,9 @@ unsigned int test__blsr_u32(unsigned int __X) { return __blsr_u32(__X); } -unsigned int test_tzcnt32(unsigned int __X) { +unsigned int test_tzcnt_u32(unsigned int __X) { // CHECK: @llvm.cttz.i32 - return __tzcnt32(__X); + return __tzcnt_u32(__X); } unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) { @@ -73,7 +73,7 @@ unsigned long long test__blsr_u64(unsigned long long __X) { return __blsr_u64(__X); } -unsigned long long test__tzcnt64(unsigned long long __X) { +unsigned long long test__tzcnt_u64(unsigned long long __X) { // CHECK: @llvm.cttz.i64 - return __tzcnt64(__X); + return __tzcnt_u64(__X); } diff --git a/test/CodeGen/bool_test.c b/test/CodeGen/bool_test.c index ffaaef8123cc..715f8467b588 100644 --- a/test/CodeGen/bool_test.c +++ b/test/CodeGen/bool_test.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 -triple powerpc-apple-darwin -emit-llvm -o - %s| FileCheck -check-prefix=DARWINPPC-CHECK %s int boolsize = sizeof(_Bool); diff --git a/test/CodeGen/bounds-checking.c b/test/CodeGen/bounds-checking.c new file mode 100644 index 000000000000..e2786203e6a7 --- /dev/null +++ b/test/CodeGen/bounds-checking.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fbounds-checking=4 -emit-llvm -triple x86_64-apple-darwin10 < %s | FileCheck %s + +// CHECK: @f +double f(int b, int i) { + double a[b]; + // CHECK: trap + return a[i]; +} + +// CHECK: @f2 +void f2() { + // everything is constant; no trap possible + // CHECK-NOT: trap + int a[2]; + a[1] = 42; + + short *b = malloc(64); + b[5] = *a + a[1] + 2; +} + +// CHECK: @f3 +void f3() { + int a[1]; + // CHECK: trap + a[2] = 1; +} diff --git a/test/CodeGen/branch-target-layout.c b/test/CodeGen/branch-target-layout.c new file mode 100644 index 000000000000..a6475d7ef116 --- /dev/null +++ b/test/CodeGen/branch-target-layout.c @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 %s -O3 -emit-llvm -o - | FileCheck %s +// +// PR13214 +// No assumption may be made about the order that a frontend emits branch +// targets (basic blocks). However, the backend's basic block layout makes an +// attempt to preserve source order of control flow, and any bias toward source +// order must start with the frontend. +// +// Note that the frontend inverts branches to simplify the condition, so the +// order of a branch instruction's labels cannot be used as a source order bias. + +void calla(); +void callb(); +void callc(); + +// CHECK: @test1 +// CHECK: @calla +// CHECK: @callb +// CHECK: @callc +// CHECK: ret void +void test1(int a) { + if (a) + calla(); + else + callb(); + callc(); +} + +// CHECK: @test2 +// CHECK: @callb +// CHECK: @calla +// CHECK: @callc +// CHECK: ret void +void test2(int a) { + if (!a) + callb(); + else + calla(); + callc(); +} diff --git a/test/CodeGen/builtin-attributes.c b/test/CodeGen/builtin-attributes.c index 3781eba26694..1d3a94376d5f 100644 --- a/test/CodeGen/builtin-attributes.c +++ b/test/CodeGen/builtin-attributes.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple arm-unknown-linux-gnueabi -emit-llvm -o - %s | FileCheck %s // CHECK: declare i32 @printf(i8*, ...) diff --git a/test/CodeGen/builtins-arm.c b/test/CodeGen/builtins-arm.c index 09df1ef42c74..3611650c38ce 100644 --- a/test/CodeGen/builtins-arm.c +++ b/test/CodeGen/builtins-arm.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -Wall -Werror -triple thumbv7-eabi -target-cpu cortex-a8 -O3 -emit-llvm -o - %s | FileCheck %s void *f0() diff --git a/test/CodeGen/builtins-mips-args.c b/test/CodeGen/builtins-mips-args.c new file mode 100644 index 000000000000..a961b36a9533 --- /dev/null +++ b/test/CodeGen/builtins-mips-args.c @@ -0,0 +1,14 @@ +// REQUIRES: mips-registered-target +// RUN: %clang_cc1 -triple mips-unknown-linux-gnu -fsyntax-only -verify %s + +void foo() { + // MIPS DSP Rev 1 + + int a = 3; + __builtin_mips_wrdsp(2052, a); // expected-error{{argument to '__builtin_mips_wrdsp' must be a constant integer}} + __builtin_mips_rddsp(a); // expected-error{{argument to '__builtin_mips_rddsp' must be a constant integer}} + __builtin_mips_wrdsp(2052, -1); // expected-error{{argument should be a value from 0 to 63}} + __builtin_mips_rddsp(-1); // expected-error{{argument should be a value from 0 to 63}} + __builtin_mips_wrdsp(2052, 64); // expected-error{{argument should be a value from 0 to 63}} + __builtin_mips_rddsp(64); // expected-error{{argument should be a value from 0 to 63}} +} diff --git a/test/CodeGen/builtins-mips.c b/test/CodeGen/builtins-mips.c new file mode 100644 index 000000000000..8155a43c20f0 --- /dev/null +++ b/test/CodeGen/builtins-mips.c @@ -0,0 +1,324 @@ +// REQUIRES: mips-registered-target +// RUN: %clang_cc1 -triple mips-unknown-linux-gnu -emit-llvm %s -o - \ +// RUN: | FileCheck %s + +typedef int q31; +typedef int i32; +typedef unsigned int ui32; +typedef long long a64; + +typedef signed char v4i8 __attribute__ ((vector_size(4))); +typedef short v2q15 __attribute__ ((vector_size(4))); + +void foo() { + v2q15 v2q15_r, v2q15_a, v2q15_b, v2q15_c; + v4i8 v4i8_r, v4i8_a, v4i8_b, v4i8_c; + q31 q31_r, q31_a, q31_b, q31_c; + i32 i32_r, i32_a, i32_b, i32_c; + ui32 ui32_r, ui32_a, ui32_b, ui32_c; + a64 a64_r, a64_a, a64_b; + + // MIPS DSP Rev 1 + + v4i8_a = (v4i8) {1, 2, 3, 0xFF}; + v4i8_b = (v4i8) {2, 4, 6, 8}; + v4i8_r = __builtin_mips_addu_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.addu.qb + v4i8_r = __builtin_mips_addu_s_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.addu.s.qb + v4i8_r = __builtin_mips_subu_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.subu.qb + v4i8_r = __builtin_mips_subu_s_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.subu.s.qb + + v2q15_a = (v2q15) {0x0000, 0x8000}; + v2q15_b = (v2q15) {0x8000, 0x8000}; + v2q15_r = __builtin_mips_addq_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.addq.ph + v2q15_r = __builtin_mips_addq_s_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.addq.s.ph + v2q15_r = __builtin_mips_subq_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.subq.ph + v2q15_r = __builtin_mips_subq_s_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.subq.s.ph + + a64_a = 0x12345678; + i32_b = 0x80000000; + i32_c = 0x11112222; + a64_r = __builtin_mips_madd(a64_a, i32_b, i32_c); +// CHECK: call i64 @llvm.mips.madd + a64_a = 0x12345678; + ui32_b = 0x80000000; + ui32_c = 0x11112222; + a64_r = __builtin_mips_maddu(a64_a, ui32_b, ui32_c); +// CHECK: call i64 @llvm.mips.maddu + a64_a = 0x12345678; + i32_b = 0x80000000; + i32_c = 0x11112222; + a64_r = __builtin_mips_msub(a64_a, i32_b, i32_c); +// CHECK: call i64 @llvm.mips.msub + a64_a = 0x12345678; + ui32_b = 0x80000000; + ui32_c = 0x11112222; + a64_r = __builtin_mips_msubu(a64_a, ui32_b, ui32_c); +// CHECK: call i64 @llvm.mips.msubu + + q31_a = 0x12345678; + q31_b = 0x7FFFFFFF; + q31_r = __builtin_mips_addq_s_w(q31_a, q31_b); +// CHECK: call i32 @llvm.mips.addq.s.w + q31_r = __builtin_mips_subq_s_w(q31_a, q31_b); +// CHECK: call i32 @llvm.mips.subq.s.w + + i32_a = 0xFFFFFFFF; + i32_b = 1; + i32_r = __builtin_mips_addsc(i32_a, i32_b); +// CHECK: call i32 @llvm.mips.addsc + i32_a = 0; + i32_b = 1; + i32_r = __builtin_mips_addwc(i32_a, i32_b); +// CHECK: call i32 @llvm.mips.addwc + + i32_a = 20; + i32_b = 0x1402; + i32_r = __builtin_mips_modsub(i32_a, i32_b); +// CHECK: call i32 @llvm.mips.modsub + + v4i8_a = (v4i8) {1, 2, 3, 4}; + i32_r = __builtin_mips_raddu_w_qb(v4i8_a); +// CHECK: call i32 @llvm.mips.raddu.w.qb + + v2q15_a = (v2q15) {0xFFFF, 0x8000}; + v2q15_r = __builtin_mips_absq_s_ph(v2q15_a); +// CHECK: call <2 x i16> @llvm.mips.absq.s.ph + q31_a = 0x80000000; + q31_r = __builtin_mips_absq_s_w(q31_a); +// CHECK: call i32 @llvm.mips.absq.s.w + + v2q15_a = (v2q15) {0x1234, 0x5678}; + v2q15_b = (v2q15) {0x1111, 0x2222}; + v4i8_r = __builtin_mips_precrq_qb_ph(v2q15_a, v2q15_b); +// CHECK: call <4 x i8> @llvm.mips.precrq.qb.ph + + v2q15_a = (v2q15) {0x7F79, 0xFFFF}; + v2q15_b = (v2q15) {0x7F81, 0x2000}; + v4i8_r = __builtin_mips_precrqu_s_qb_ph(v2q15_a, v2q15_b); +// CHECK: call <4 x i8> @llvm.mips.precrqu.s.qb.ph + q31_a = 0x12345678; + q31_b = 0x11112222; + v2q15_r = __builtin_mips_precrq_ph_w(q31_a, q31_b); +// CHECK: call <2 x i16> @llvm.mips.precrq.ph.w + q31_a = 0x7000FFFF; + q31_b = 0x80000000; + v2q15_r = __builtin_mips_precrq_rs_ph_w(q31_a, q31_b); +// CHECK: call <2 x i16> @llvm.mips.precrq.rs.ph.w + v2q15_a = (v2q15) {0x1234, 0x5678}; + q31_r = __builtin_mips_preceq_w_phl(v2q15_a); +// CHECK: call i32 @llvm.mips.preceq.w.phl + q31_r = __builtin_mips_preceq_w_phr(v2q15_a); +// CHECK: call i32 @llvm.mips.preceq.w.phr + v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78}; + v2q15_r = __builtin_mips_precequ_ph_qbl(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.precequ.ph.qbl + v2q15_r = __builtin_mips_precequ_ph_qbr(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.precequ.ph.qbr + v2q15_r = __builtin_mips_precequ_ph_qbla(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.precequ.ph.qbla + v2q15_r = __builtin_mips_precequ_ph_qbra(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.precequ.ph.qbra + v2q15_r = __builtin_mips_preceu_ph_qbl(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.preceu.ph.qbl + v2q15_r = __builtin_mips_preceu_ph_qbr(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.preceu.ph.qbr + v2q15_r = __builtin_mips_preceu_ph_qbla(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.preceu.ph.qbla + v2q15_r = __builtin_mips_preceu_ph_qbra(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.preceu.ph.qbra + + v4i8_a = (v4i8) {1, 2, 3, 4}; + v4i8_r = __builtin_mips_shll_qb(v4i8_a, 2); +// CHECK: call <4 x i8> @llvm.mips.shll.qb + v4i8_a = (v4i8) {128, 64, 32, 16}; + v4i8_r = __builtin_mips_shrl_qb(v4i8_a, 2); +// CHECK: call <4 x i8> @llvm.mips.shrl.qb + v2q15_a = (v2q15) {0x0001, 0x8000}; + v2q15_r = __builtin_mips_shll_ph(v2q15_a, 2); +// CHECK: call <2 x i16> @llvm.mips.shll.ph + v2q15_r = __builtin_mips_shll_s_ph(v2q15_a, 2); +// CHECK: call <2 x i16> @llvm.mips.shll.s.ph + v2q15_a = (v2q15) {0x7FFF, 0x8000}; + v2q15_r = __builtin_mips_shra_ph(v2q15_a, 2); +// CHECK: call <2 x i16> @llvm.mips.shra.ph + v2q15_r = __builtin_mips_shra_r_ph(v2q15_a, 2); +// CHECK: call <2 x i16> @llvm.mips.shra.r.ph + q31_a = 0x70000000; + q31_r = __builtin_mips_shll_s_w(q31_a, 2); +// CHECK: call i32 @llvm.mips.shll.s.w + q31_a = 0x7FFFFFFF; + q31_r = __builtin_mips_shra_r_w(q31_a, 2); +// CHECK: call i32 @llvm.mips.shra.r.w + a64_a = 0x1234567887654321LL; + a64_r = __builtin_mips_shilo(a64_a, -8); +// CHECK: call i64 @llvm.mips.shilo + + v4i8_a = (v4i8) {0x1, 0x3, 0x5, 0x7}; + v2q15_b = (v2q15) {0x1234, 0x5678}; + v2q15_r = __builtin_mips_muleu_s_ph_qbl(v4i8_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.muleu.s.ph.qbl + v2q15_r = __builtin_mips_muleu_s_ph_qbr(v4i8_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.muleu.s.ph.qbr + v2q15_a = (v2q15) {0x7FFF, 0x8000}; + v2q15_b = (v2q15) {0x7FFF, 0x8000}; + v2q15_r = __builtin_mips_mulq_rs_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.mulq.rs.ph + v2q15_a = (v2q15) {0x1234, 0x8000}; + v2q15_b = (v2q15) {0x5678, 0x8000}; + q31_r = __builtin_mips_muleq_s_w_phl(v2q15_a, v2q15_b); +// CHECK: call i32 @llvm.mips.muleq.s.w.phl + q31_r = __builtin_mips_muleq_s_w_phr(v2q15_a, v2q15_b); +// CHECK: call i32 @llvm.mips.muleq.s.w.phr + a64_a = 0; + v2q15_a = (v2q15) {0x0001, 0x8000}; + v2q15_b = (v2q15) {0x0002, 0x8000}; + a64_r = __builtin_mips_mulsaq_s_w_ph(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.mulsaq.s.w.ph + a64_a = 0; + v2q15_b = (v2q15) {0x0001, 0x8000}; + v2q15_c = (v2q15) {0x0002, 0x8000}; + a64_r = __builtin_mips_maq_s_w_phl(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.maq.s.w.phl + a64_r = __builtin_mips_maq_s_w_phr(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.maq.s.w.phr + a64_a = 0x7FFFFFF0; + a64_r = __builtin_mips_maq_sa_w_phl(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.maq.sa.w.phl + a64_r = __builtin_mips_maq_sa_w_phr(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.maq.sa.w.phr + i32_a = 0x80000000; + i32_b = 0x11112222; + a64_r = __builtin_mips_mult(i32_a, i32_b); +// CHECK: call i64 @llvm.mips.mult + ui32_a = 0x80000000; + ui32_b = 0x11112222; + a64_r = __builtin_mips_multu(ui32_a, ui32_b); +// CHECK: call i64 @llvm.mips.multu + + a64_a = 0; + v4i8_b = (v4i8) {1, 2, 3, 4}; + v4i8_c = (v4i8) {4, 5, 6, 7}; + a64_r = __builtin_mips_dpau_h_qbl(a64_a, v4i8_b, v4i8_c); +// CHECK: call i64 @llvm.mips.dpau.h.qbl + a64_r = __builtin_mips_dpau_h_qbr(a64_a, v4i8_b, v4i8_c); +// CHECK: call i64 @llvm.mips.dpau.h.qbr + a64_r = __builtin_mips_dpsu_h_qbl(a64_a, v4i8_b, v4i8_c); +// CHECK: call i64 @llvm.mips.dpsu.h.qbl + a64_r = __builtin_mips_dpsu_h_qbr(a64_a, v4i8_b, v4i8_c); +// CHECK: call i64 @llvm.mips.dpsu.h.qbr + a64_a = 0; + v2q15_b = (v2q15) {0x0001, 0x8000}; + v2q15_c = (v2q15) {0x0002, 0x8000}; + a64_r = __builtin_mips_dpaq_s_w_ph(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.dpaq.s.w.ph + a64_r = __builtin_mips_dpsq_s_w_ph(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.dpsq.s.w.ph + a64_a = 0; + q31_b = 0x80000000; + q31_c = 0x80000000; + a64_r = __builtin_mips_dpaq_sa_l_w(a64_a, q31_b, q31_c); +// CHECK: call i64 @llvm.mips.dpaq.sa.l.w + a64_r = __builtin_mips_dpsq_sa_l_w(a64_a, q31_b, q31_c); +// CHECK: call i64 @llvm.mips.dpsq.sa.l.w + + v4i8_a = (v4i8) {1, 4, 10, 8}; + v4i8_b = (v4i8) {1, 2, 100, 8}; + __builtin_mips_cmpu_eq_qb(v4i8_a, v4i8_b); +// CHECK: call void @llvm.mips.cmpu.eq.qb + __builtin_mips_cmpu_lt_qb(v4i8_a, v4i8_b); +// CHECK: call void @llvm.mips.cmpu.lt.qb + __builtin_mips_cmpu_le_qb(v4i8_a, v4i8_b); +// CHECK: call void @llvm.mips.cmpu.le.qb + i32_r = __builtin_mips_cmpgu_eq_qb(v4i8_a, v4i8_b); +// CHECK: call i32 @llvm.mips.cmpgu.eq.qb + i32_r = __builtin_mips_cmpgu_lt_qb(v4i8_a, v4i8_b); +// CHECK: call i32 @llvm.mips.cmpgu.lt.qb + i32_r = __builtin_mips_cmpgu_le_qb(v4i8_a, v4i8_b); +// CHECK: call i32 @llvm.mips.cmpgu.le.qb + v2q15_a = (v2q15) {0x1111, 0x1234}; + v2q15_b = (v2q15) {0x4444, 0x1234}; + __builtin_mips_cmp_eq_ph(v2q15_a, v2q15_b); +// CHECK: call void @llvm.mips.cmp.eq.ph + __builtin_mips_cmp_lt_ph(v2q15_a, v2q15_b); +// CHECK: call void @llvm.mips.cmp.lt.ph + __builtin_mips_cmp_le_ph(v2q15_a, v2q15_b); +// CHECK: call void @llvm.mips.cmp.le.ph + + a64_a = 0xFFFFF81230000000LL; + i32_r = __builtin_mips_extr_s_h(a64_a, 4); +// CHECK: call i32 @llvm.mips.extr.s.h + a64_a = 0x8123456712345678LL; + i32_r = __builtin_mips_extr_w(a64_a, 31); +// CHECK: call i32 @llvm.mips.extr.w + i32_r = __builtin_mips_extr_rs_w(a64_a, 31); +// CHECK: call i32 @llvm.mips.extr.rs.w + i32_r = __builtin_mips_extr_r_w(a64_a, 31); +// CHECK: call i32 @llvm.mips.extr.r.w + a64_a = 0x1234567887654321LL; + i32_r = __builtin_mips_extp(a64_a, 3); +// CHECK: call i32 @llvm.mips.extp + a64_a = 0x123456789ABCDEF0LL; + i32_r = __builtin_mips_extpdp(a64_a, 7); +// CHECK: call i32 @llvm.mips.extpdp + + __builtin_mips_wrdsp(2052, 3); +// CHECK: call void @llvm.mips.wrdsp + i32_r = __builtin_mips_rddsp(3); +// CHECK: call i32 @llvm.mips.rddsp + i32_a = 0xFFFFFFFF; + i32_b = 0x12345678; + __builtin_mips_wrdsp((16<<7) + 4, 3); +// CHECK: call void @llvm.mips.wrdsp + i32_r = __builtin_mips_insv(i32_a, i32_b); +// CHECK: call i32 @llvm.mips.insv + i32_a = 0x1234; + i32_r = __builtin_mips_bitrev(i32_a); +// CHECK: call i32 @llvm.mips.bitrev + v2q15_a = (v2q15) {0x1111, 0x2222}; + v2q15_b = (v2q15) {0x3333, 0x4444}; + v2q15_r = __builtin_mips_packrl_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.packrl.ph + i32_a = 100; + v4i8_r = __builtin_mips_repl_qb(i32_a); +// CHECK: call <4 x i8> @llvm.mips.repl.qb + i32_a = 0x1234; + v2q15_r = __builtin_mips_repl_ph(i32_a); +// CHECK: call <2 x i16> @llvm.mips.repl.ph + v4i8_a = (v4i8) {1, 4, 10, 8}; + v4i8_b = (v4i8) {1, 2, 100, 8}; + __builtin_mips_cmpu_eq_qb(v4i8_a, v4i8_b); +// CHECK: call void @llvm.mips.cmpu.eq.qb + v4i8_r = __builtin_mips_pick_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.pick.qb + v2q15_a = (v2q15) {0x1111, 0x1234}; + v2q15_b = (v2q15) {0x4444, 0x1234}; + __builtin_mips_cmp_eq_ph(v2q15_a, v2q15_b); +// CHECK: call void @llvm.mips.cmp.eq.ph + v2q15_r = __builtin_mips_pick_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.pick.ph + a64_a = 0x1234567887654321LL; + i32_b = 0x11112222; + __builtin_mips_wrdsp(0, 1); +// CHECK: call void @llvm.mips.wrdsp + a64_r = __builtin_mips_mthlip(a64_a, i32_b); +// CHECK: call i64 @llvm.mips.mthlip + i32_r = __builtin_mips_bposge32(); +// CHECK: call i32 @llvm.mips.bposge32 + char array_a[100]; + i32_r = __builtin_mips_lbux(array_a, 20); +// CHECK: call i32 @llvm.mips.lbux + short array_b[100]; + i32_r = __builtin_mips_lhx(array_b, 20); +// CHECK: call i32 @llvm.mips.lhx + int array_c[100]; + i32_r = __builtin_mips_lwx(array_c, 20); +// CHECK: call i32 @llvm.mips.lwx +} diff --git a/test/CodeGen/builtins-nvptx.c b/test/CodeGen/builtins-nvptx.c new file mode 100644 index 000000000000..fa6b14c1ca7d --- /dev/null +++ b/test/CodeGen/builtins-nvptx.c @@ -0,0 +1,98 @@ +// RUN: %clang_cc1 -triple nvptx-unknown-unknown -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -emit-llvm -o %t %s + +int read_tid() { + + int x = __builtin_ptx_read_tid_x(); + int y = __builtin_ptx_read_tid_y(); + int z = __builtin_ptx_read_tid_z(); + int w = __builtin_ptx_read_tid_w(); + + return x + y + z + w; + +} + +int read_ntid() { + + int x = __builtin_ptx_read_ntid_x(); + int y = __builtin_ptx_read_ntid_y(); + int z = __builtin_ptx_read_ntid_z(); + int w = __builtin_ptx_read_ntid_w(); + + return x + y + z + w; + +} + +int read_ctaid() { + + int x = __builtin_ptx_read_ctaid_x(); + int y = __builtin_ptx_read_ctaid_y(); + int z = __builtin_ptx_read_ctaid_z(); + int w = __builtin_ptx_read_ctaid_w(); + + return x + y + z + w; + +} + +int read_nctaid() { + + int x = __builtin_ptx_read_nctaid_x(); + int y = __builtin_ptx_read_nctaid_y(); + int z = __builtin_ptx_read_nctaid_z(); + int w = __builtin_ptx_read_nctaid_w(); + + return x + y + z + w; + +} + +int read_ids() { + + int a = __builtin_ptx_read_laneid(); + int b = __builtin_ptx_read_warpid(); + int c = __builtin_ptx_read_nwarpid(); + int d = __builtin_ptx_read_smid(); + int e = __builtin_ptx_read_nsmid(); + int f = __builtin_ptx_read_gridid(); + + return a + b + c + d + e + f; + +} + +int read_lanemasks() { + + int a = __builtin_ptx_read_lanemask_eq(); + int b = __builtin_ptx_read_lanemask_le(); + int c = __builtin_ptx_read_lanemask_lt(); + int d = __builtin_ptx_read_lanemask_ge(); + int e = __builtin_ptx_read_lanemask_gt(); + + return a + b + c + d + e; + +} + + +long read_clocks() { + + int a = __builtin_ptx_read_clock(); + long b = __builtin_ptx_read_clock64(); + + return (long)a + b; + +} + +int read_pms() { + + int a = __builtin_ptx_read_pm0(); + int b = __builtin_ptx_read_pm1(); + int c = __builtin_ptx_read_pm2(); + int d = __builtin_ptx_read_pm3(); + + return a + b + c + d; + +} + +void sync() { + + __builtin_ptx_bar_sync(0); + +} diff --git a/test/CodeGen/builtins-ppc-altivec.c b/test/CodeGen/builtins-ppc-altivec.c index b12ff014c193..e885cb03aa1a 100644 --- a/test/CodeGen/builtins-ppc-altivec.c +++ b/test/CodeGen/builtins-ppc-altivec.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s vector bool char vbc = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; diff --git a/test/CodeGen/builtins-ptx.c b/test/CodeGen/builtins-ptx.c deleted file mode 100644 index 6dd10188e9fb..000000000000 --- a/test/CodeGen/builtins-ptx.c +++ /dev/null @@ -1,99 +0,0 @@ -// RUN: %clang_cc1 -triple ptx32-unknown-unknown -emit-llvm -o %t %s -// RUN: %clang_cc1 -triple ptx64-unknown-unknown -emit-llvm -o %t %s - - -int read_tid() { - - int x = __builtin_ptx_read_tid_x(); - int y = __builtin_ptx_read_tid_y(); - int z = __builtin_ptx_read_tid_z(); - int w = __builtin_ptx_read_tid_w(); - - return x + y + z + w; - -} - -int read_ntid() { - - int x = __builtin_ptx_read_ntid_x(); - int y = __builtin_ptx_read_ntid_y(); - int z = __builtin_ptx_read_ntid_z(); - int w = __builtin_ptx_read_ntid_w(); - - return x + y + z + w; - -} - -int read_ctaid() { - - int x = __builtin_ptx_read_ctaid_x(); - int y = __builtin_ptx_read_ctaid_y(); - int z = __builtin_ptx_read_ctaid_z(); - int w = __builtin_ptx_read_ctaid_w(); - - return x + y + z + w; - -} - -int read_nctaid() { - - int x = __builtin_ptx_read_nctaid_x(); - int y = __builtin_ptx_read_nctaid_y(); - int z = __builtin_ptx_read_nctaid_z(); - int w = __builtin_ptx_read_nctaid_w(); - - return x + y + z + w; - -} - -int read_ids() { - - int a = __builtin_ptx_read_laneid(); - int b = __builtin_ptx_read_warpid(); - int c = __builtin_ptx_read_nwarpid(); - int d = __builtin_ptx_read_smid(); - int e = __builtin_ptx_read_nsmid(); - int f = __builtin_ptx_read_gridid(); - - return a + b + c + d + e + f; - -} - -int read_lanemasks() { - - int a = __builtin_ptx_read_lanemask_eq(); - int b = __builtin_ptx_read_lanemask_le(); - int c = __builtin_ptx_read_lanemask_lt(); - int d = __builtin_ptx_read_lanemask_ge(); - int e = __builtin_ptx_read_lanemask_gt(); - - return a + b + c + d + e; - -} - - -long read_clocks() { - - int a = __builtin_ptx_read_clock(); - long b = __builtin_ptx_read_clock64(); - - return (long)a + b; - -} - -int read_pms() { - - int a = __builtin_ptx_read_pm0(); - int b = __builtin_ptx_read_pm1(); - int c = __builtin_ptx_read_pm2(); - int d = __builtin_ptx_read_pm3(); - - return a + b + c + d; - -} - -void sync() { - - __builtin_ptx_bar_sync(0); - -} diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c index acb5554db4d3..fcf1512ca16e 100644 --- a/test/CodeGen/builtins-x86.c +++ b/test/CodeGen/builtins-x86.c @@ -344,7 +344,6 @@ void f0() { tmp_V16c = __builtin_ia32_lddqu(tmp_cCp); tmp_V2LLi = __builtin_ia32_palignr128(tmp_V2LLi, tmp_V2LLi, imm_i); tmp_V1LLi = __builtin_ia32_palignr(tmp_V1LLi, tmp_V1LLi, imm_i); - (void) __builtin_ia32_storelv4si(tmp_V2ip, tmp_V2LLi); #ifdef USE_SSE4 tmp_V16c = __builtin_ia32_pblendvb128(tmp_V16c, tmp_V16c, tmp_V16c); tmp_V8s = __builtin_ia32_pblendw128(tmp_V8s, tmp_V8s, imm_i_0_256); diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c index fca087e197fc..65b9ad111fd8 100644 --- a/test/CodeGen/builtins.c +++ b/test/CodeGen/builtins.c @@ -203,3 +203,9 @@ void test_builtin_longjmp(void **buffer) { __builtin_longjmp(buffer, 1); // CHECK-NEXT: unreachable } + +// CHECK: define i64 @test_builtin_readcyclecounter +long long test_builtin_readcyclecounter() { + // CHECK: call i64 @llvm.readcyclecounter() + return __builtin_readcyclecounter(); +} diff --git a/test/CodeGen/capture-complex-expr-in-block.c b/test/CodeGen/capture-complex-expr-in-block.c index 9ce7570a4486..86c93d0252bc 100644 --- a/test/CodeGen/capture-complex-expr-in-block.c +++ b/test/CodeGen/capture-complex-expr-in-block.c @@ -12,7 +12,7 @@ int main () b(); } -// CHECK: define internal void @__main_block_invoke_0 +// CHECK: define internal void @__main_block_invoke // CHECK: [[C1:%.*]] = alloca { double, double }, align 8 // CHECK: [[RP:%.*]] = getelementptr inbounds { double, double }* [[C1]], i32 0, i32 0 // CHECK-NEXT: [[R:%.*]] = load double* [[RP]] diff --git a/test/CodeGen/catch-undef-behavior.c b/test/CodeGen/catch-undef-behavior.c index fef1587fad00..ee0b6586dd84 100644 --- a/test/CodeGen/catch-undef-behavior.c +++ b/test/CodeGen/catch-undef-behavior.c @@ -1,7 +1,17 @@ -// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm-only %s +// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm %s -o - | FileCheck %s // PR6805 +// CHECK: @foo void foo() { union { int i; } u; + // CHECK: objectsize + // CHECK: icmp uge u.i=1; } + +// CHECK: @bar +int bar(int *a) { + // CHECK: objectsize + // CHECK: icmp uge + return *a; +} diff --git a/test/CodeGen/compound-literal.c b/test/CodeGen/compound-literal.c index 969c5affe0b2..a8eec615ad62 100644 --- a/test/CodeGen/compound-literal.c +++ b/test/CodeGen/compound-literal.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s int* a = &(int){1}; struct s {int a, b, c;} * b = &(struct s) {1, 2, 3}; diff --git a/test/CodeGen/debug-info-gline-tables-only.c b/test/CodeGen/debug-info-gline-tables-only.c new file mode 100644 index 000000000000..067d8e772189 --- /dev/null +++ b/test/CodeGen/debug-info-gline-tables-only.c @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 %s -gline-tables-only -S -emit-llvm -o - | FileCheck %s +// Checks that clang with "-gline-tables-only" doesn't emit debug info +// for variables and types. + +// CHECK-NOT: DW_TAG_variable +int global = 42; + +// CHECK-NOT: DW_TAG_typedef +// CHECK-NOT: DW_TAG_const_type +// CHECK-NOT: DW_TAG_pointer_type +// CHECK-NOT: DW_TAG_array_type +typedef const char* constCharPtrArray[10]; + +// CHECK-NOT: DW_TAG_structure_type +struct S { + // CHECK-NOT: DW_TAG_member + char a; + double b; + constCharPtrArray c; +}; + +// CHECK-NOT: DW_TAG_enumerator +// CHECK-NOT: DW_TAG_enumeration_type +enum E { ZERO = 0, ONE = 1 }; + +// CHECK-NOT: DW_TAG_arg_variable +int sum(int p, int q) { + // CHECK-NOT: DW_TAG_auto_variable + int r = p + q; + struct S s; + enum E e; + return r; +} diff --git a/test/CodeGen/debug-info-gline-tables-only2.c b/test/CodeGen/debug-info-gline-tables-only2.c new file mode 100644 index 000000000000..8e9cc64e0d69 --- /dev/null +++ b/test/CodeGen/debug-info-gline-tables-only2.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 %s -gline-tables-only -S -emit-llvm -o - | FileCheck %s +// Checks that clang with "-gline-tables-only" emits metadata for +// compile unit, subprogram and file. + +int main() { + // CHECK: ret i32 0, !dbg + return 0; +} + +// CHECK: !llvm.dbg.cu = !{!0} +// CHECK: DW_TAG_compile_unit +// CHECK: {{.*main.* DW_TAG_subprogram}} +// CHECK: DW_TAG_file_type diff --git a/test/CodeGen/debug-info-line2.c b/test/CodeGen/debug-info-line2.c index b5eba8a1a060..893b021360fb 100644 --- a/test/CodeGen/debug-info-line2.c +++ b/test/CodeGen/debug-info-line2.c @@ -6,11 +6,12 @@ int foo(int i) { int j = 0; if (i) { j = bar(); -//CHECK: store i32 -//CHECK-NOT: br label %{{%[a-zA-Z0-9\.]+}}, !dbg } else { + // CHECK: add nsw + // CHECK-NEXT: store i32 %{{[a-zA-Z0-9]+}} + // CHECK-NOT: br label %{{[a-zA-Z0-9\.]+}}, !dbg j = bar() + 2; } return j; diff --git a/test/CodeGen/debug-info-line3.c b/test/CodeGen/debug-info-line3.c index 645ffb9e7485..a4e35e753d74 100644 --- a/test/CodeGen/debug-info-line3.c +++ b/test/CodeGen/debug-info-line3.c @@ -12,5 +12,5 @@ void func(char c, char* d) } -// CHECK: ret void, !dbg !19 -// CHECK: !19 = metadata !{i32 6, +// CHECK: ret void, !dbg !17 +// CHECK: !17 = metadata !{i32 6, diff --git a/test/CodeGen/debug-info-vla.c b/test/CodeGen/debug-info-vla.c new file mode 100644 index 000000000000..20fb6aace41f --- /dev/null +++ b/test/CodeGen/debug-info-vla.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s + +// CHECK: metadata !{i32 {{.*}}, metadata {{.*}}, metadata !"vla", metadata {{.*}}, i32 7, metadata {{.*}}, i32 0, i32 0, i64 2} ; [ DW_TAG_auto_variable ] + +void testVLAwithSize(int s) +{ + int vla[s]; + int i; + for (i = 0; i < s; i++) { + vla[i] = i*i; + } +} diff --git a/test/CodeGen/debug-line-1.c b/test/CodeGen/debug-line-1.c index 00d4f421f8a1..0c2d18583298 100644 --- a/test/CodeGen/debug-line-1.c +++ b/test/CodeGen/debug-line-1.c @@ -4,7 +4,7 @@ // Check to make sure that we emit the block for the break so that we can count the line. // CHECK: sw.bb: ; preds = %entry -// CHECK: br label %sw.epilog, !dbg !21 +// CHECK: br label %sw.epilog, !dbg !19 extern int atoi(const char *); diff --git a/test/CodeGen/fma-builtins.c b/test/CodeGen/fma-builtins.c new file mode 100644 index 000000000000..3424616b1233 --- /dev/null +++ b/test/CodeGen/fma-builtins.c @@ -0,0 +1,166 @@ +// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +fma -emit-llvm -o - | FileCheck %s + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include + +__m128 test_mm_fmadd_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmadd.ps + return _mm_fmadd_ps(a, b, c); +} + +__m128d test_mm_fmadd_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmadd.pd + return _mm_fmadd_pd(a, b, c); +} + +__m128 test_mm_fmadd_ss(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmadd.ss + return _mm_fmadd_ss(a, b, c); +} + +__m128d test_mm_fmadd_sd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmadd.sd + return _mm_fmadd_sd(a, b, c); +} + +__m128 test_mm_fmsub_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmsub.ps + return _mm_fmsub_ps(a, b, c); +} + +__m128d test_mm_fmsub_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmsub.pd + return _mm_fmsub_pd(a, b, c); +} + +__m128 test_mm_fmsub_ss(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmsub.ss + return _mm_fmsub_ss(a, b, c); +} + +__m128d test_mm_fmsub_sd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmsub.sd + return _mm_fmsub_sd(a, b, c); +} + +__m128 test_mm_fnmadd_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfnmadd.ps + return _mm_fnmadd_ps(a, b, c); +} + +__m128d test_mm_fnmadd_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfnmadd.pd + return _mm_fnmadd_pd(a, b, c); +} + +__m128 test_mm_fnmadd_ss(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfnmadd.ss + return _mm_fnmadd_ss(a, b, c); +} + +__m128d test_mm_fnmadd_sd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfnmadd.sd + return _mm_fnmadd_sd(a, b, c); +} + +__m128 test_mm_fnmsub_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfnmsub.ps + return _mm_fnmsub_ps(a, b, c); +} + +__m128d test_mm_fnmsub_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfnmsub.pd + return _mm_fnmsub_pd(a, b, c); +} + +__m128 test_mm_fnmsub_ss(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfnmsub.ss + return _mm_fnmsub_ss(a, b, c); +} + +__m128d test_mm_fnmsub_sd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfnmsub.sd + return _mm_fnmsub_sd(a, b, c); +} + +__m128 test_mm_fmaddsub_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmaddsub.ps + return _mm_fmaddsub_ps(a, b, c); +} + +__m128d test_mm_fmaddsub_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmaddsub.pd + return _mm_fmaddsub_pd(a, b, c); +} + +__m128 test_mm_fmsubadd_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmsubadd.ps + return _mm_fmsubadd_ps(a, b, c); +} + +__m128d test_mm_fmsubadd_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmsubadd.pd + return _mm_fmsubadd_pd(a, b, c); +} + +__m256 test_mm256_fmadd_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfmadd.ps.256 + return _mm256_fmadd_ps(a, b, c); +} + +__m256d test_mm256_fmadd_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfmadd.pd.256 + return _mm256_fmadd_pd(a, b, c); +} + +__m256 test_mm256_fmsub_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfmsub.ps.256 + return _mm256_fmsub_ps(a, b, c); +} + +__m256d test_mm256_fmsub_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfmsub.pd.256 + return _mm256_fmsub_pd(a, b, c); +} + +__m256 test_mm256_fnmadd_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfnmadd.ps.256 + return _mm256_fnmadd_ps(a, b, c); +} + +__m256d test_mm256_fnmadd_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfnmadd.pd.256 + return _mm256_fnmadd_pd(a, b, c); +} + +__m256 test_mm256_fnmsub_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfnmsub.ps.256 + return _mm256_fnmsub_ps(a, b, c); +} + +__m256d test_mm256_fnmsub_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfnmsub.pd.256 + return _mm256_fnmsub_pd(a, b, c); +} + +__m256 test_mm256_fmaddsub_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfmaddsub.ps.256 + return _mm256_fmaddsub_ps(a, b, c); +} + +__m256d test_mm256_fmaddsub_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfmaddsub.pd.256 + return _mm256_fmaddsub_pd(a, b, c); +} + +__m256 test_mm256_fmsubadd_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfmsubadd.ps.256 + return _mm256_fmsubadd_ps(a, b, c); +} + +__m256d test_mm256_fmsubadd_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfmsubadd.pd.256 + return _mm256_fmsubadd_pd(a, b, c); +} diff --git a/test/CodeGen/fma4-builtins.c b/test/CodeGen/fma4-builtins.c index ddbaba748391..b805e9acb879 100644 --- a/test/CodeGen/fma4-builtins.c +++ b/test/CodeGen/fma4-builtins.c @@ -6,161 +6,161 @@ #include __m128 test_mm_macc_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmadd.ps + // CHECK: @llvm.x86.fma.vfmadd.ps return _mm_macc_ps(a, b, c); } __m128d test_mm_macc_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmadd.pd + // CHECK: @llvm.x86.fma.vfmadd.pd return _mm_macc_pd(a, b, c); } __m128 test_mm_macc_ss(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmadd.ss + // CHECK: @llvm.x86.fma.vfmadd.ss return _mm_macc_ss(a, b, c); } __m128d test_mm_macc_sd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmadd.sd + // CHECK: @llvm.x86.fma.vfmadd.sd return _mm_macc_sd(a, b, c); } __m128 test_mm_msub_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmsub.ps + // CHECK: @llvm.x86.fma.vfmsub.ps return _mm_msub_ps(a, b, c); } __m128d test_mm_msub_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmsub.pd + // CHECK: @llvm.x86.fma.vfmsub.pd return _mm_msub_pd(a, b, c); } __m128 test_mm_msub_ss(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmsub.ss + // CHECK: @llvm.x86.fma.vfmsub.ss return _mm_msub_ss(a, b, c); } __m128d test_mm_msub_sd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmsub.sd + // CHECK: @llvm.x86.fma.vfmsub.sd return _mm_msub_sd(a, b, c); } __m128 test_mm_nmacc_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfnmadd.ps + // CHECK: @llvm.x86.fma.vfnmadd.ps return _mm_nmacc_ps(a, b, c); } __m128d test_mm_nmacc_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfnmadd.pd + // CHECK: @llvm.x86.fma.vfnmadd.pd return _mm_nmacc_pd(a, b, c); } __m128 test_mm_nmacc_ss(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfnmadd.ss + // CHECK: @llvm.x86.fma.vfnmadd.ss return _mm_nmacc_ss(a, b, c); } __m128d test_mm_nmacc_sd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfnmadd.sd + // CHECK: @llvm.x86.fma.vfnmadd.sd return _mm_nmacc_sd(a, b, c); } __m128 test_mm_nmsub_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfnmsub.ps + // CHECK: @llvm.x86.fma.vfnmsub.ps return _mm_nmsub_ps(a, b, c); } __m128d test_mm_nmsub_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfnmsub.pd + // CHECK: @llvm.x86.fma.vfnmsub.pd return _mm_nmsub_pd(a, b, c); } __m128 test_mm_nmsub_ss(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfnmsub.ss + // CHECK: @llvm.x86.fma.vfnmsub.ss return _mm_nmsub_ss(a, b, c); } __m128d test_mm_nmsub_sd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfnmsub.sd + // CHECK: @llvm.x86.fma.vfnmsub.sd return _mm_nmsub_sd(a, b, c); } __m128 test_mm_maddsub_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmaddsub.ps + // CHECK: @llvm.x86.fma.vfmaddsub.ps return _mm_maddsub_ps(a, b, c); } __m128d test_mm_maddsub_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmaddsub.pd + // CHECK: @llvm.x86.fma.vfmaddsub.pd return _mm_maddsub_pd(a, b, c); } __m128 test_mm_msubadd_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmsubadd.ps + // CHECK: @llvm.x86.fma.vfmsubadd.ps return _mm_msubadd_ps(a, b, c); } __m128d test_mm_msubadd_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmsubadd.pd + // CHECK: @llvm.x86.fma.vfmsubadd.pd return _mm_msubadd_pd(a, b, c); } __m256 test_mm256_macc_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfmadd.ps.256 + // CHECK: @llvm.x86.fma.vfmadd.ps.256 return _mm256_macc_ps(a, b, c); } __m256d test_mm256_macc_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfmadd.pd.256 + // CHECK: @llvm.x86.fma.vfmadd.pd.256 return _mm256_macc_pd(a, b, c); } __m256 test_mm256_msub_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfmsub.ps.256 + // CHECK: @llvm.x86.fma.vfmsub.ps.256 return _mm256_msub_ps(a, b, c); } __m256d test_mm256_msub_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfmsub.pd.256 + // CHECK: @llvm.x86.fma.vfmsub.pd.256 return _mm256_msub_pd(a, b, c); } __m256 test_mm256_nmacc_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfnmadd.ps.256 + // CHECK: @llvm.x86.fma.vfnmadd.ps.256 return _mm256_nmacc_ps(a, b, c); } __m256d test_mm256_nmacc_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfnmadd.pd.256 + // CHECK: @llvm.x86.fma.vfnmadd.pd.256 return _mm256_nmacc_pd(a, b, c); } __m256 test_mm256_nmsub_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfnmsub.ps.256 + // CHECK: @llvm.x86.fma.vfnmsub.ps.256 return _mm256_nmsub_ps(a, b, c); } __m256d test_mm256_nmsub_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfnmsub.pd.256 + // CHECK: @llvm.x86.fma.vfnmsub.pd.256 return _mm256_nmsub_pd(a, b, c); } __m256 test_mm256_maddsub_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfmaddsub.ps.256 + // CHECK: @llvm.x86.fma.vfmaddsub.ps.256 return _mm256_maddsub_ps(a, b, c); } __m256d test_mm256_maddsub_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfmaddsub.pd.256 + // CHECK: @llvm.x86.fma.vfmaddsub.pd.256 return _mm256_maddsub_pd(a, b, c); } __m256 test_mm256_msubadd_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfmsubadd.ps.256 + // CHECK: @llvm.x86.fma.vfmsubadd.ps.256 return _mm256_msubadd_ps(a, b, c); } __m256d test_mm256_msubadd_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfmsubadd.pd.256 + // CHECK: @llvm.x86.fma.vfmsubadd.pd.256 return _mm256_msubadd_pd(a, b, c); } diff --git a/test/CodeGen/forceinline.c b/test/CodeGen/forceinline.c new file mode 100644 index 000000000000..9a21c0dd2c78 --- /dev/null +++ b/test/CodeGen/forceinline.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple i686-win32 -emit-llvm -fms-extensions < %s | FileCheck %s + +void bar() { +} + +// CHECK-NOT: foo +__forceinline void foo() { + bar(); +} + +void i_want_bar() { +// CHECK: call void @bar + foo(); +} diff --git a/test/CodeGen/fp-contract.c b/test/CodeGen/fp-contract.c new file mode 100644 index 000000000000..eb95f1e21775 --- /dev/null +++ b/test/CodeGen/fp-contract.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple=powerpc-apple-darwin10 -S -o - %s | FileCheck %s +// REQUIRES: ppc32-registered-target + +float fma_test1(float a, float b, float c) { +// CHECK: fmadds + float x = a * b; + float y = x + c; + return y; +} diff --git a/test/CodeGen/fp16-ops.c b/test/CodeGen/fp16-ops.c index cbbfb884df50..e50651330670 100644 --- a/test/CodeGen/fp16-ops.c +++ b/test/CodeGen/fp16-ops.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s typedef unsigned cond_t; diff --git a/test/CodeGen/func-aligned.c b/test/CodeGen/func-aligned.c index f8a4a29d9d2c..64b72932d0d2 100644 --- a/test/CodeGen/func-aligned.c +++ b/test/CodeGen/func-aligned.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s // rdar://7270273 void foo() __attribute__((aligned (64))); diff --git a/test/CodeGen/func-in-block.c b/test/CodeGen/func-in-block.c index 19001357d517..503695f8c378 100644 --- a/test/CodeGen/func-in-block.c +++ b/test/CodeGen/func-in-block.c @@ -15,5 +15,5 @@ int main() return 0; // not reached } -// CHECK: @__func__.__main_block_invoke_0 = private unnamed_addr constant [22 x i8] c"__main_block_invoke_0\00" -// CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke_ +// CHECK: @__func__.__main_block_invoke = private unnamed_addr constant [20 x i8] c"__main_block_invoke\00" +// CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke diff --git a/test/CodeGen/func-return-member.c b/test/CodeGen/func-return-member.c index 8c55a9671cd0..14ecac5d6bbb 100644 --- a/test/CodeGen/func-return-member.c +++ b/test/CodeGen/func-return-member.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s struct frk { float _Complex c; int x; }; struct faz { struct frk f; }; diff --git a/test/CodeGen/incomplete-function-type.c b/test/CodeGen/incomplete-function-type.c index 0ba6633b4adf..b6309472a5bc 100644 --- a/test/CodeGen/incomplete-function-type.c +++ b/test/CodeGen/incomplete-function-type.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s // CHECK: ModuleID // CHECK-NOT: opaque // CHECK: define void @f0 diff --git a/test/CodeGen/integer-overflow.c b/test/CodeGen/integer-overflow.c index 1d460656a1c7..d7fff4ee4a2a 100644 --- a/test/CodeGen/integer-overflow.c +++ b/test/CodeGen/integer-overflow.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT -// RUN: %clang_cc1 %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV -// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV -// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER // Tests for signed integer overflow stuff. diff --git a/test/CodeGen/libcalls.c b/test/CodeGen/libcalls.c index 458c591837ff..ec895ac6e857 100644 --- a/test/CodeGen/libcalls.c +++ b/test/CodeGen/libcalls.c @@ -73,3 +73,48 @@ void test_fma(float a0, double a1, long double a2) { // CHECK-NO: declare float @llvm.fma.f32(float, float, float) nounwind readnone // CHECK-NO: declare double @llvm.fma.f64(double, double, double) nounwind readnone // CHECK-NO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone + +// Just checking to make sure these library functions are marked readnone +void test_builtins(double d, float f, long double ld) { +// CHEC-NO: @test_builtins +// CHEC-YES: @test_builtins + double atan_ = atan(d); + long double atanl_ = atanl(ld); + float atanf_ = atanf(f); +// CHECK-NO: declare double @atan(double) nounwind readnone +// CHECK-NO: declare x86_fp80 @atanl(x86_fp80) nounwind readnone +// CHECK-NO: declare float @atanf(float) nounwind readnone +// CHECK-YES-NOT: declare double @atan(double) nounwind readnone +// CHECK-YES-NOT: declare x86_fp80 @atanl(x86_fp80) nounwind readnone +// CHECK-YES-NOT: declare float @atanf(float) nounwind readnone + + double atan2_ = atan2(d, 2); + long double atan2l_ = atan2l(ld, ld); + float atan2f_ = atan2f(f, f); +// CHECK-NO: declare double @atan2(double, double) nounwind readnone +// CHECK-NO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) nounwind readnone +// CHECK-NO: declare float @atan2f(float, float) nounwind readnone +// CHECK-YES-NOT: declare double @atan2(double, double) nounwind readnone +// CHECK-YES-NOT: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) nounwind readnone +// CHECK-YES-NOT: declare float @atan2f(float, float) nounwind readnone + + double exp_ = exp(d); + long double expl_ = expl(ld); + float expf_ = expf(f); +// CHECK-NO: declare double @exp(double) nounwind readnone +// CHECK-NO: declare x86_fp80 @expl(x86_fp80) nounwind readnone +// CHECK-NO: declare float @expf(float) nounwind readnone +// CHECK-YES-NOT: declare double @exp(double) nounwind readnone +// CHECK-YES-NOT: declare x86_fp80 @expl(x86_fp80) nounwind readnone +// CHECK-YES-NOT: declare float @expf(float) nounwind readnone + + double log_ = log(d); + long double logl_ = logl(ld); + float logf_ = logf(f); +// CHECK-NO: declare double @log(double) nounwind readnone +// CHECK-NO: declare x86_fp80 @logl(x86_fp80) nounwind readnone +// CHECK-NO: declare float @logf(float) nounwind readnone +// CHECK-YES-NOT: declare double @log(double) nounwind readnone +// CHECK-YES-NOT: declare x86_fp80 @logl(x86_fp80) nounwind readnone +// CHECK-YES-NOT: declare float @logf(float) nounwind readnone +} diff --git a/test/CodeGen/mips-byval-arg.c b/test/CodeGen/mips-byval-arg.c new file mode 100644 index 000000000000..4e5f41a14972 --- /dev/null +++ b/test/CodeGen/mips-byval-arg.c @@ -0,0 +1,15 @@ +// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32 +// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s -check-prefix=N64 + +typedef struct { + float f[3]; +} S0; + +extern void foo2(S0); + +// O32: define void @foo1(i32 %a0.coerce0, i32 %a0.coerce1, i32 %a0.coerce2) +// N64: define void @foo1(i64 %a0.coerce0, i32 %a0.coerce1) + +void foo1(S0 a0) { + foo2(a0); +} diff --git a/test/CodeGen/mips-vector-arg.c b/test/CodeGen/mips-vector-arg.c new file mode 100644 index 000000000000..39998d91a64a --- /dev/null +++ b/test/CodeGen/mips-vector-arg.c @@ -0,0 +1,28 @@ +// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32 +// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s -check-prefix=N64 + +// check that +// 1. vector arguments are passed in integer registers +// 2. argument alignment is no larger than 8-byte for O32 and 16-byte for N64. + +typedef float v4sf __attribute__ ((__vector_size__ (16))); +typedef int v4i32 __attribute__ ((__vector_size__ (16))); + +// O32: define void @test_v4sf(i32 %a1.coerce0, i32 %a1.coerce1, i32 %a1.coerce2, i32 %a1.coerce3, i32 %a2, i32, i32 %a3.coerce0, i32 %a3.coerce1, i32 %a3.coerce2, i32 %a3.coerce3) nounwind +// O32: declare i32 @test_v4sf_2(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) +// N64: define void @test_v4sf(i64 %a1.coerce0, i64 %a1.coerce1, i32 %a2, i64, i64 %a3.coerce0, i64 %a3.coerce1) nounwind +// N64: declare i32 @test_v4sf_2(i64, i64, i32, i64, i64, i64) +extern test_v4sf_2(v4sf, int, v4sf); +void test_v4sf(v4sf a1, int a2, v4sf a3) { + test_v4sf_2(a3, a2, a1); +} + +// O32: define void @test_v4i32(i32 %a1.coerce0, i32 %a1.coerce1, i32 %a1.coerce2, i32 %a1.coerce3, i32 %a2, i32, i32 %a3.coerce0, i32 %a3.coerce1, i32 %a3.coerce2, i32 %a3.coerce3) nounwind +// O32: declare i32 @test_v4i32_2(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) +// N64: define void @test_v4i32(i64 %a1.coerce0, i64 %a1.coerce1, i32 %a2, i64, i64 %a3.coerce0, i64 %a3.coerce1) nounwind +// N64: declare i32 @test_v4i32_2(i64, i64, i32, i64, i64, i64) +extern test_v4i32_2(v4i32, int, v4i32); +void test_v4i32(v4i32 a1, int a2, v4i32 a3) { + test_v4i32_2(a3, a2, a1); +} + diff --git a/test/CodeGen/mips-vector-return.c b/test/CodeGen/mips-vector-return.c new file mode 100644 index 000000000000..12e71fadf87b --- /dev/null +++ b/test/CodeGen/mips-vector-return.c @@ -0,0 +1,31 @@ +// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32 +// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s -check-prefix=N64 + +// vectors larger than 16-bytes are returned via the hidden pointer argument. +// N64/N32 returns vectors whose size is equal to or smaller than 16-bytes in +// integer registers. +typedef float v4sf __attribute__ ((__vector_size__ (16))); +typedef double v4df __attribute__ ((__vector_size__ (32))); +typedef int v4i32 __attribute__ ((__vector_size__ (16))); + +// O32: define void @test_v4sf(<4 x float>* noalias nocapture sret +// N64: define { i64, i64 } @test_v4sf +v4sf test_v4sf(float a) { + return (v4sf){0.0f, a, 0.0f, 0.0f}; +} + +// O32: define void @test_v4df(<4 x double>* noalias nocapture sret +// N64: define void @test_v4df(<4 x double>* noalias nocapture sret +v4df test_v4df(double a) { + return (v4df){0.0, a, 0.0, 0.0}; +} + +// O32 returns integer vectors whose size is equal to or smaller than 16-bytes +// in integer registers. +// +// O32: define { i32, i32, i32, i32 } @test_v4i32 +// N64: define { i64, i64 } @test_v4i32 +v4i32 test_v4i32(int a) { + return (v4i32){0, a, 0, 0}; +} + diff --git a/test/CodeGen/mips64-class-return.cpp b/test/CodeGen/mips64-class-return.cpp index dc9ec0f5be4e..8e32d5cbd6f0 100644 --- a/test/CodeGen/mips64-class-return.cpp +++ b/test/CodeGen/mips64-class-return.cpp @@ -39,7 +39,7 @@ void foo3(D2 a0) { gd2 = a0; } -// CHECK: define void @_Z4foo42D0(%class.D0* nocapture byval %a0) +// CHECK: define void @_Z4foo42D0(i64 %a0.coerce0, i64 %a0.coerce1) void foo4(D0 a0) { gd0 = a0; } diff --git a/test/CodeGen/ms-declspecs.c b/test/CodeGen/ms-declspecs.c index d3235aee4364..91862a73b09c 100644 --- a/test/CodeGen/ms-declspecs.c +++ b/test/CodeGen/ms-declspecs.c @@ -1,5 +1,13 @@ // RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -o - | FileCheck %s +struct __declspec(align(16)) S { + char x; +}; +union { struct S s; } u; + +// CHECK: @u = {{.*}}zeroinitializer, align 16 + + // CHECK: define void @t3() nounwind noinline naked { __declspec(naked) void t3() {} diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c new file mode 100644 index 000000000000..8c3e5f7c569b --- /dev/null +++ b/test/CodeGen/ms-inline-asm.c @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fms-extensions -fenable-experimental-ms-inline-asm -w -emit-llvm -o - | FileCheck %s + +void t1() { +// CHECK: @t1 +// CHECK: call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm {} +} + +void t2() { +// CHECK: @t2 +// CHECK: call void asm sideeffect "nop\0Anop\0Anop", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm nop + __asm nop + __asm nop +} + +void t3() { +// CHECK: @t3 +// CHECK: call void asm sideeffect "nop\0Anop\0Anop", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm nop __asm nop __asm nop +} + +void t4(void) { +// CHECK: @t4 +// CHECK: call void asm sideeffect "mov ebx, eax\0Amov ecx, ebx", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm mov ebx, eax + __asm mov ecx, ebx +} + +void t5(void) { +// CHECK: @t5 +// CHECK: call void asm sideeffect "mov ebx, eax\0Amov ecx, ebx", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm mov ebx, eax __asm mov ecx, ebx +} + diff --git a/test/CodeGen/no-common.c b/test/CodeGen/no-common.c index 7beefc7b690d..8d2c4d7d74c8 100644 --- a/test/CodeGen/no-common.c +++ b/test/CodeGen/no-common.c @@ -12,4 +12,4 @@ fn_t ABC __attribute__ ((nocommon)); // CHECK-DEFAULT: @y = common global // CHECK-NOCOMMON: @y = common global -int y __attribute__((common)); \ No newline at end of file +int y __attribute__((common)); diff --git a/test/CodeGen/nobuiltin.c b/test/CodeGen/nobuiltin.c new file mode 100644 index 000000000000..0a8e8bb4b6da --- /dev/null +++ b/test/CodeGen/nobuiltin.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fno-builtin -O1 -S -o - %s | FileCheck %s + +void PR13497() { + char content[2]; + // make sure we don't optimize this call to strcpy() + // CHECK: __strcpy_chk + __builtin___strcpy_chk(content, "", 1); +} diff --git a/test/CodeGen/nvptx-cc.c b/test/CodeGen/nvptx-cc.c new file mode 100644 index 000000000000..1c0d943f956b --- /dev/null +++ b/test/CodeGen/nvptx-cc.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple nvptx-unknown-unknown -O3 -S -o %t %s -emit-llvm +// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -O3 -S -o %t %s -emit-llvm + +// Just make sure Clang uses the proper calling convention for the NVPTX back-end. +// If something is wrong, the back-end will fail. +void foo(float* a, + float* b) { + a[0] = b[0]; +} diff --git a/test/CodeGen/nvptx-inlineasm.c b/test/CodeGen/nvptx-inlineasm.c new file mode 100644 index 000000000000..860b50ff5852 --- /dev/null +++ b/test/CodeGen/nvptx-inlineasm.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple nvptx-unknown-unknown -O3 -S -o - %s -emit-llvm | FileCheck %s +// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -O3 -S -o - %s -emit-llvm | FileCheck %s + +int bar(int a) { + int result; + // CHECK: call i32 asm sideeffect "{ {{.*}} + asm __volatile__ ("{ \n\t" + ".reg .pred \t%%p1; \n\t" + ".reg .pred \t%%p2; \n\t" + "setp.ne.u32 \t%%p1, %1, 0; \n\t" + "vote.any.pred \t%%p2, %%p1; \n\t" + "selp.s32 \t%0, 1, 0, %%p2; \n\t" + "}" : "=r"(result) : "r"(a)); + return result; +} diff --git a/test/CodeGen/object-size.c b/test/CodeGen/object-size.c index 1f16d02d7d64..f6c7db835bf3 100644 --- a/test/CodeGen/object-size.c +++ b/test/CodeGen/object-size.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 | FileCheck %s #define strcpy(dest, src) \ ((__builtin_object_size(dest, 0) != -1ULL) \ @@ -55,7 +55,10 @@ void test6() { // CHECK: define void @test7 void test7() { int i; - // CHECK: = call i64 @llvm.objectsize.i64(i8* {{.*}}@gbuf{{.*}}, i1 false) + // Ensure we only evaluate the side-effect once. + // CHECK: = add + // CHECK-NOT: = add + // CHECK: = call i8* @__strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i64 63) strcpy((++i, gbuf), "Hi there"); } @@ -124,6 +127,7 @@ void test16() { strcpy(gp += 1, "Hi there"); } +// CHECK: @test17 void test17() { // CHECK: store i32 -1 gi = __builtin_object_size(gp++, 0); @@ -134,3 +138,11 @@ void test17() { // CHECK: store i32 0 gi = __builtin_object_size(gp++, 3); } + +// CHECK: @test18 +unsigned test18(int cond) { + int a[4], b[4]; + // CHECK: phi i32* + // CHECK: call i64 @llvm.objectsize.i64 + return __builtin_object_size(cond ? a : b, 0); +} diff --git a/test/CodeGen/packed-nest-unpacked.c b/test/CodeGen/packed-nest-unpacked.c index 0ccc0c41b7e6..6097e3f32eae 100644 --- a/test/CodeGen/packed-nest-unpacked.c +++ b/test/CodeGen/packed-nest-unpacked.c @@ -45,3 +45,21 @@ void test6() { // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* %{{.*}}, i64 24, i32 1, i1 false) g.y = foo(); } + + +struct XBitfield { + unsigned b1 : 10; + unsigned b2 : 12; + unsigned b3 : 10; +}; +struct YBitfield { + char x; + struct XBitfield y; +} __attribute((packed)); +struct YBitfield gbitfield; + +unsigned test7() { + // CHECK: @test7 + // CHECK: load i32* bitcast (%struct.XBitfield* getelementptr inbounds (%struct.YBitfield* @gbitfield, i32 0, i32 1) to i32*), align 1 + return gbitfield.y.b2; +} diff --git a/test/CodeGen/pclmul-builtins.c b/test/CodeGen/pclmul-builtins.c new file mode 100644 index 000000000000..cb0af28dbe0c --- /dev/null +++ b/test/CodeGen/pclmul-builtins.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +pclmul -emit-llvm -o - | FileCheck %s + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include + +__m128i test_mm_clmulepi64_si128(__m128i a, __m128i b) { + // CHECK: @llvm.x86.pclmulqdq + return _mm_clmulepi64_si128(a, b, 0); +} diff --git a/test/CodeGen/powerpc_types.c b/test/CodeGen/powerpc_types.c index b7d0f5de4985..b4de31818845 100644 --- a/test/CodeGen/powerpc_types.c +++ b/test/CodeGen/powerpc_types.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 -triple powerpc-unknown-freebsd -emit-llvm -o - %s| FileCheck -check-prefix=SVR4-CHECK %s #include diff --git a/test/CodeGen/pr12251.c b/test/CodeGen/pr12251.c index a644bb79da55..b01713122141 100644 --- a/test/CodeGen/pr12251.c +++ b/test/CodeGen/pr12251.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -O1 -relaxed-aliasing -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -O1 -relaxed-aliasing -o - | FileCheck %s enum e1 {e1_a = -1 }; enum e1 g1(enum e1 *x) { diff --git a/test/CodeGen/pr13168.c b/test/CodeGen/pr13168.c new file mode 100644 index 000000000000..a848af472c96 --- /dev/null +++ b/test/CodeGen/pr13168.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + +typedef int (*_MD_Open64)(int oflag, ...); +_MD_Open64 _open64; +void PR_OpenFile(int mode) { +_open64(0, mode); +} diff --git a/test/CodeGen/pr5406.c b/test/CodeGen/pr5406.c index da74d6b64fe5..2d198220a770 100644 --- a/test/CodeGen/pr5406.c +++ b/test/CodeGen/pr5406.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 %s -emit-llvm -triple arm-apple-darwin -o - | FileCheck %s // PR 5406 diff --git a/test/CodeGen/pragma-visibility.c b/test/CodeGen/pragma-visibility.c index 16460a28280e..a7fceb3d1ac1 100644 --- a/test/CodeGen/pragma-visibility.c +++ b/test/CodeGen/pragma-visibility.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s #pragma GCC visibility push(hidden) int x = 2; diff --git a/test/CodeGen/ptx-cc.c b/test/CodeGen/ptx-cc.c deleted file mode 100644 index 2212d4260b35..000000000000 --- a/test/CodeGen/ptx-cc.c +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -triple ptx32-unknown-unknown -O3 -S -o %t %s -emit-llvm -// RUN: %clang_cc1 -triple ptx64-unknown-unknown -O3 -S -o %t %s -emit-llvm - -// Just make sure Clang uses the proper calling convention for the PTX back-end. -// If something is wrong, the back-end will fail. -void foo(float* a, - float* b) { - a[0] = b[0]; -} diff --git a/test/CodeGen/rdrand-builtins.c b/test/CodeGen/rdrand-builtins.c new file mode 100644 index 000000000000..b7970f4dd427 --- /dev/null +++ b/test/CodeGen/rdrand-builtins.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +rdrnd -emit-llvm -S -emit-llvm -o - %s | FileCheck %s + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include + +int rdrand16(unsigned short *p) { + return _rdrand16_step(p); +// CHECK: @rdrand16 +// CHECK: call { i16, i32 } @llvm.x86.rdrand.16 +// CHECK: store i16 +} + +int rdrand32(unsigned *p) { + return _rdrand32_step(p); +// CHECK: @rdrand32 +// CHECK: call { i32, i32 } @llvm.x86.rdrand.32 +// CHECK: store i32 +} + +int rdrand64(unsigned long long *p) { + return _rdrand64_step(p); +// CHECK: @rdrand64 +// CHECK: call { i64, i32 } @llvm.x86.rdrand.64 +// CHECK: store i64 +} diff --git a/test/CodeGen/regparm-flag.c b/test/CodeGen/regparm-flag.c index 8ecf53950805..1330663e4528 100644 --- a/test/CodeGen/regparm-flag.c +++ b/test/CodeGen/regparm-flag.c @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 4 %s -emit-llvm -o %t -// RUN: FileCheck < %t %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 4 %s -emit-llvm -o - | FileCheck %s void f1(int a, int b, int c, int d, int e, int f, int g, int h); diff --git a/test/CodeGen/regparm-struct.c b/test/CodeGen/regparm-struct.c new file mode 100644 index 000000000000..b31901266e6f --- /dev/null +++ b/test/CodeGen/regparm-struct.c @@ -0,0 +1,177 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s + +__attribute__((regparm(3))) void f1(int a, int b, int c, int d); +// CHECK: declare void @f1(i32 inreg, i32 inreg, i32 inreg, i32) +void g1() { + f1(41, 42, 43, 44); +} + +struct s1 { + int x1; +}; +__attribute__((regparm(3))) void f2(int a, int b, struct s1 c, int d); +// CHECK: declare void @f2(i32 inreg, i32 inreg, i32 inreg, i32) +void g2() { + struct s1 x = {43}; + f2(41, 42, x, 44); +} + +struct s2 { + int x1; + int x2; +}; +__attribute__((regparm(3))) void f3(int a, int b, struct s2 c, int d); +// CHECK: declare void @f3(i32 inreg, i32 inreg, i32, i32, i32) +void g3() { + struct s2 x = {43, 44}; + f3(41, 42, x, 45); +} +__attribute__((regparm(3))) void f4(int a, struct s2 b, int c); +// CHECK: declare void @f4(i32 inreg, i32 inreg, i32 inreg, i32) +void g4() { + struct s2 x = {42, 43}; + f4(41, x, 44); +} + +struct s3 { + int x1; + int x2; + int x3; +}; +__attribute__((regparm(3))) void f5(int a, struct s3 b, int c); +// CHECK: declare void @f5(i32 inreg, i32, i32, i32, i32) +void g5() { + struct s3 x = {42, 43, 44}; + f5(41, x, 45); +} +__attribute__((regparm(3))) void f6(struct s3 a, int b); +// CHECK: declare void @f6(i32 inreg, i32 inreg, i32 inreg, i32) +void g6() { + struct s3 x = {41, 42, 43}; + f6(x, 44); +} + +struct s4 { + int x1; + int x2; + int x3; + int x4; +}; +__attribute__((regparm(3))) void f7(struct s4 a, int b); +// CHECK: declare void @f7(i32, i32, i32, i32, i32) +void g7() { + struct s4 x = {41, 42, 43, 44}; + f7(x, 45); +} + +__attribute__((regparm(3))) void f8(float a, int b); +// CHECK: declare void @f8(float, i32 inreg) +void g8(void) { + f8(41, 42); +} + +struct s5 { + float x1; +}; +__attribute__((regparm(3))) void f9(struct s5 a, int b); +// CHECK: declare void @f9(float, i32 inreg) +void g9(void) { + struct s5 x = {41}; + f9(x, 42); +} + +struct s6 { + float x1; + int x2; +}; +__attribute__((regparm(3))) void f10(struct s6 a, int b); +// CHECK: declare void @f10(i32 inreg, i32 inreg, i32 inreg) +void g10(void) { + struct s6 x = {41, 42}; + f10(x, 43); +} + +struct s7 { + float x1; + int x2; + float x3; +}; +__attribute__((regparm(3))) void f11(struct s7 a, int b); +// CHECK: declare void @f11(i32 inreg, i32 inreg, i32 inreg, i32) +void g11(void) { + struct s7 x = {41, 42, 43}; + f11(x, 44); +} + +struct s8 { + float x1; + float x2; +}; +__attribute__((regparm(3))) void f12(struct s8 a, int b); +// CHECK: declare void @f12(i32 inreg, i32 inreg, i32 inreg) +void g12(void) { + struct s8 x = {41, 42}; + f12(x, 43); +} + +struct s9 { + float x1; + float x2; + float x3; +}; +__attribute__((regparm(3))) void f13(struct s9 a, int b); +// CHECK: declare void @f13(i32 inreg, i32 inreg, i32 inreg, i32) +void g13(void) { + struct s9 x = {41, 42, 43}; + f13(x, 44); +} + +struct s10 { + double x1; +}; +__attribute__((regparm(3))) void f14(struct s10 a, int b, int c); +// CHECK: declare void @f14(double, i32 inreg, i32 inreg) +void g14(void) { + struct s10 x = { 41 }; + f14(x, 42, 43); +} + +struct s11 { + double x1; + double x2; +}; +__attribute__((regparm(3))) void f15(struct s11 a, int b); +// CHECK: declare void @f15(double, double, i32) +void g15(void) { + struct s11 x = { 41, 42 }; + f15(x, 43); +} + +struct s12 { + double x1; + float x2; +}; +__attribute__((regparm(3))) void f16(struct s12 a, int b); +// CHECK: declare void @f16(i32 inreg, i32 inreg, i32 inreg, i32) +void g16(void) { + struct s12 x = { 41, 42 }; + f16(x, 43); +} + +__attribute__((regparm(3))) struct s12 f17(int a, int b, int c); +// CHECK: declare void @f17(%struct.s12* inreg sret, i32 inreg, i32 inreg, i32) +void g17(void) { + f17(41, 42, 43); +} + +struct s13 { + struct inner { + float x; + } y; +}; +__attribute__((regparm(3))) void f18(struct s13 a, int b, int c, int d); +// CHECK: declare void @f18(%struct.s13* byval align 4, i32 inreg, i32 inreg, i32 inreg) +void g18(void) { + struct s13 x = {{41}}; + f18(x, 42, 43, 44); +} diff --git a/test/CodeGen/sse-builtins.c b/test/CodeGen/sse-builtins.c index 2d5742515553..0e48560b0869 100644 --- a/test/CodeGen/sse-builtins.c +++ b/test/CodeGen/sse-builtins.c @@ -151,3 +151,9 @@ __m128d test_mm_round_sd(__m128d x, __m128d y) { // CHECK: @llvm.x86.sse41.round.sd return _mm_round_sd(x, y, 2); } + +void test_storel_epi64(__m128i x, void* y) { + // CHECK: define void @test_storel_epi64 + // CHECK: store {{.*}} i64* {{.*}}, align 1{{$}} + _mm_storel_epi64(y, x); +} diff --git a/test/CodeGen/sse4a-builtins.c b/test/CodeGen/sse4a-builtins.c new file mode 100644 index 000000000000..e1d7e8fb561b --- /dev/null +++ b/test/CodeGen/sse4a-builtins.c @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -ffreestanding -triple i386-apple-darwin9 -target-cpu pentium4 -target-feature +sse4a -g -emit-llvm %s -o - | FileCheck %s + +#include + +__m128i test_extracti_si64(__m128i x) { + return _mm_extracti_si64(x, 3, 2); +// CHECK: @test_extracti_si64 +// CHECK: @llvm.x86.sse4a.extrqi(<2 x i64> %{{[^,]+}}, i8 3, i8 2) +} + +__m128i test_extract_si64(__m128i x, __m128i y) { + return _mm_extract_si64(x, y); +// CHECK: @test_extract_si64 +// CHECK: @llvm.x86.sse4a.extrq(<2 x i64> %{{[^,]+}}, <16 x i8> %{{[^,]+}}) +} + +__m128i test_inserti_si64(__m128i x, __m128i y) { + return _mm_inserti_si64(x, y, 5, 6); +// CHECK: @test_inserti_si64 +// CHECK: @llvm.x86.sse4a.insertqi(<2 x i64> %{{[^,]+}}, <2 x i64> %{{[^,]+}}, i8 5, i8 6) +} + +__m128i test_insert_si64(__m128i x, __m128i y) { + return _mm_insert_si64(x, y); +// CHECK: @test_insert_si64 +// CHECK: @llvm.x86.sse4a.insertq(<2 x i64> %{{[^,]+}}, <2 x i64> %{{[^,]+}}) +} + +void test_stream_sd(double *p, __m128d a) { + _mm_stream_sd(p, a); +// CHECK: @test_stream_sd +// CHECK: @llvm.x86.sse4a.movnt.sd(i8* %{{[^,]+}}, <2 x double> %{{[^,]+}}) +} + +void test_stream_ss(float *p, __m128 a) { + _mm_stream_ss(p, a); +// CHECK: @test_stream_ss +// CHECK: @llvm.x86.sse4a.movnt.ss(i8* %{{[^,]+}}, <4 x float> %{{[^,]+}}) +} diff --git a/test/CodeGen/struct-init.c b/test/CodeGen/struct-init.c index 6247729c17b7..5273138e4e5e 100644 --- a/test/CodeGen/struct-init.c +++ b/test/CodeGen/struct-init.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -S -triple armv7-apple-darwin %s -emit-llvm -o - | FileCheck %s typedef struct _zend_ini_entry zend_ini_entry; diff --git a/test/CodeGen/struct-matching-constraint.c b/test/CodeGen/struct-matching-constraint.c index 40c444f2b40d..bdd11c8b9000 100644 --- a/test/CodeGen/struct-matching-constraint.c +++ b/test/CodeGen/struct-matching-constraint.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -S -emit-llvm -triple armv7a-apple-darwin %s -o /dev/null typedef unsigned short uint16_t; typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t; diff --git a/test/CodeGen/tbaa-for-vptr.cpp b/test/CodeGen/tbaa-for-vptr.cpp index 5ce6bf32edf3..b9a68fe0eae1 100644 --- a/test/CodeGen/tbaa-for-vptr.cpp +++ b/test/CodeGen/tbaa-for-vptr.cpp @@ -1,5 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm -o - -O0 -fthread-sanitizer %s | FileCheck %s // RUN: %clang_cc1 -emit-llvm -o - -O1 %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -O1 -relaxed-aliasing -fthread-sanitizer %s | FileCheck %s +// +// RUN: %clang_cc1 -emit-llvm -o - -O0 %s | FileCheck %s --check-prefix=NOTBAA +// RUN: %clang_cc1 -emit-llvm -o - -O2 -relaxed-aliasing %s | FileCheck %s --check-prefix=NOTBAA +// // Check that we generate TBAA for vtable pointer loads and stores. +// When -fthread-sanitizer is used TBAA should be generated at all opt levels +// even if -relaxed-aliasing is present. struct A { virtual int foo() const ; virtual ~A(); @@ -15,5 +23,5 @@ void CallFoo(A *a) { // CHECK: %{{.*}} = load {{.*}} !tbaa !0 // CHECK: store {{.*}} !tbaa !0 -// CHECK: !0 = metadata !{metadata !"vtable pointer", metadata !1} -// CHECK: !1 = metadata !{metadata !"Simple C/C++ TBAA"} +// CHECK: = metadata !{metadata !"vtable pointer", metadata !{{.*}}} +// NOTBAA-NOT: = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/test/CodeGen/thread-specifier.c b/test/CodeGen/thread-specifier.c index a1f3e168000e..a2d3e62c8c5d 100644 --- a/test/CodeGen/thread-specifier.c +++ b/test/CodeGen/thread-specifier.c @@ -3,7 +3,13 @@ // CHECK: @b = external thread_local global // CHECK: @d.e = internal thread_local global // CHECK: @d.f = internal thread_local global +// CHECK: @f.a = internal thread_local(initialexec) global // CHECK: @a = thread_local global +// CHECK: @g = thread_local global +// CHECK: @h = thread_local(localdynamic) global +// CHECK: @i = thread_local(initialexec) global +// CHECK: @j = thread_local(localexec) global + __thread int a; extern __thread int b; int c() { return *&b; } @@ -13,3 +19,12 @@ int d() { return 0; } +__thread int g __attribute__((tls_model("global-dynamic"))); +__thread int h __attribute__((tls_model("local-dynamic"))); +__thread int i __attribute__((tls_model("initial-exec"))); +__thread int j __attribute__((tls_model("local-exec"))); + +int f() { + __thread static int a __attribute__((tls_model("initial-exec"))); + return a++; +} diff --git a/test/CodeGen/tls-model.c b/test/CodeGen/tls-model.c new file mode 100644 index 000000000000..b5bae77e97f3 --- /dev/null +++ b/test/CodeGen/tls-model.c @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=local-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LD +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=initial-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-IE +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE + +int __thread x; +int f() { + static int __thread y; + return y++; +} +int __thread __attribute__((tls_model("initial-exec"))) z; + +// CHECK-GD: @f.y = internal thread_local global i32 0 +// CHECK-GD: @x = thread_local global i32 0 +// CHECK-GD: @z = thread_local(initialexec) global i32 0 + +// CHECK-LD: @f.y = internal thread_local(localdynamic) global i32 0 +// CHECK-LD: @x = thread_local(localdynamic) global i32 0 +// CHECK-LD: @z = thread_local(initialexec) global i32 0 + +// CHECK-IE: @f.y = internal thread_local(initialexec) global i32 0 +// CHECK-IE: @x = thread_local(initialexec) global i32 0 +// CHECK-IE: @z = thread_local(initialexec) global i32 0 + +// CHECK-LE: @f.y = internal thread_local(localexec) global i32 0 +// CHECK-LE: @x = thread_local(localexec) global i32 0 +// CHECK-LE: @z = thread_local(initialexec) global i32 0 diff --git a/test/CodeGen/varargs.c b/test/CodeGen/varargs.c index b3dba240b559..b6973d8337d8 100644 --- a/test/CodeGen/varargs.c +++ b/test/CodeGen/varargs.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s // PR6433 - Don't crash on va_arg(typedef). @@ -9,3 +9,9 @@ void focus_changed_cb () { mfloat = __builtin_va_arg((pa), gdouble); } +void vararg(int, ...); +void function_as_vararg() { + // CHECK: define {{.*}}function_as_vararg + // CHECK-NOT: llvm.trap + vararg(0, focus_changed_cb); +} diff --git a/test/CodeGen/vector-alignment.c b/test/CodeGen/vector-alignment.c new file mode 100644 index 000000000000..92d1ae73f9e2 --- /dev/null +++ b/test/CodeGen/vector-alignment.c @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -w -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s +// rdar://11759609 + +// At or below target max alignment with no aligned attribute should align based +// on the size of vector. +double __attribute__((vector_size(16))) v1; +// CHECK: @v1 {{.*}}, align 16 +double __attribute__((vector_size(32))) v2; +// CHECK: @v2 {{.*}}, align 32 + +// Alignment above target max alignment with no aligned attribute should align +// based on the target max. +double __attribute__((vector_size(64))) v3; +// CHECK: @v3 {{.*}}, align 32 +double __attribute__((vector_size(1024))) v4; +// CHECK: @v4 {{.*}}, align 32 + +// Aliged attribute should always override. +double __attribute__((vector_size(16), aligned(16))) v5; +// CHECK: @v5 {{.*}}, align 16 +double __attribute__((vector_size(16), aligned(64))) v6; +// CHECK: @v6 {{.*}}, align 64 +double __attribute__((vector_size(32), aligned(16))) v7; +// CHECK: @v7 {{.*}}, align 16 +double __attribute__((vector_size(32), aligned(64))) v8; +// CHECK: @v8 {{.*}}, align 64 + +// Check non-power of 2 widths. +double __attribute__((vector_size(24))) v9; +// CHECK: @v9 {{.*}}, align 32 +double __attribute__((vector_size(40))) v10; +// CHECK: @v10 {{.*}}, align 32 + +// Check non-power of 2 widths with aligned attribute. +double __attribute__((vector_size(24), aligned(64))) v11; +// CHECK: @v11 {{.*}}, align 64 +double __attribute__((vector_size(80), aligned(16))) v12; +// CHECK: @v12 {{.*}}, align 16 diff --git a/test/CodeGen/vla.c b/test/CodeGen/vla.c index 9e62da52e026..e15182762706 100644 --- a/test/CodeGen/vla.c +++ b/test/CodeGen/vla.c @@ -142,3 +142,52 @@ int test4(unsigned n, char (*p)[n][n+1][6]) { // CHECK-NEXT: ret i32 [[T7]] return p2 - p; } + +// rdar://11485774 +void test5(void) +{ + // CHECK: define void @test5( + int a[5], i = 0; + // CHECK: [[A:%.*]] = alloca [5 x i32], align 4 + // CHECK-NEXT: [[I:%.*]] = alloca i32, align 4 + // CHECK-NEXT: [[CL:%.*]] = alloca i32*, align 4 + // CHECK-NEXT: store i32 0, i32* [[I]], align 4 + + (typeof(++i, (int (*)[i])a)){&a} += 0; + // CHECK-NEXT: [[Z:%.*]] = load i32* [[I]], align 4 + // CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[Z]], 1 + // CHECK-NEXT: store i32 [[INC]], i32* [[I]], align 4 + // CHECK-NEXT: [[O:%.*]] = load i32* [[I]], align 4 + // CHECK-NEXT: [[AR:%.*]] = getelementptr inbounds [5 x i32]* [[A]], i32 0, i32 0 + // CHECK-NEXT: [[T:%.*]] = bitcast [5 x i32]* [[A]] to i32* + // CHECK-NEXT: store i32* [[T]], i32** [[CL]] + // CHECK-NEXT: [[TH:%.*]] = load i32** [[CL]] + // CHECK-NEXT: [[VLAIX:%.*]] = mul nsw i32 0, [[O]] + // CHECK-NEXT: [[ADDPTR:%.*]] = getelementptr inbounds i32* [[TH]], i32 [[VLAIX]] + // CHECK-NEXT: store i32* [[ADDPTR]], i32** [[CL]] +} + +void test6(void) +{ + // CHECK: define void @test6( + int n = 20, **a, i=0; + // CHECK: [[N:%.*]] = alloca i32, align 4 + // CHECK-NEXT: [[A:%.*]] = alloca i32**, align 4 + // CHECK-NEXT: [[I:%.*]] = alloca i32, align 4 + (int (**)[i]){&a}[0][1][5] = 0; + // CHECK-NEXT: [[CL:%.*]] = alloca i32**, align 4 + // CHECK-NEXT: store i32 20, i32* [[N]], align 4 + // CHECK-NEXT: store i32 0, i32* [[I]], align 4 + // CHECK-NEXT: [[Z:%.*]] = load i32* [[I]], align 4 + // CHECK-NEXT: [[O:%.*]] = bitcast i32*** [[A]] to i32** + // CHECK-NEXT: store i32** [[O]], i32*** [[CL]] + // CHECK-NEXT: [[T:%.*]] = load i32*** [[CL]] + // CHECK-NEXT: [[IX:%.*]] = getelementptr inbounds i32** [[T]], i32 0 + // CHECK-NEXT: [[TH:%.*]] = load i32** [[IX]], align 4 + // CHECK-NEXT: [[F:%.*]] = mul nsw i32 1, [[Z]] + // CHECK-NEXT: [[IX1:%.*]] = getelementptr inbounds i32* [[TH]], i32 [[F]] + // CHECK-NEXT: [[IX2:%.*]] = getelementptr inbounds i32* [[IX1]], i32 5 + // CHECK-NEXT: store i32 0, i32* [[IX2]], align 4 +} + + diff --git a/test/CodeGen/vld_dup.c b/test/CodeGen/vld_dup.c index e1d63cca2506..2bc251989b6a 100644 --- a/test/CodeGen/vld_dup.c +++ b/test/CodeGen/vld_dup.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7a-linux-gnueabi \ // RUN: -target-cpu cortex-a8 \ // RUN: -emit-llvm -O0 -o - %s | FileCheck %s diff --git a/test/CodeGen/x86_32-arguments-darwin.c b/test/CodeGen/x86_32-arguments-darwin.c index 0ac18b792f9f..5bbc80b9398b 100644 --- a/test/CodeGen/x86_32-arguments-darwin.c +++ b/test/CodeGen/x86_32-arguments-darwin.c @@ -324,3 +324,16 @@ void f64(struct s64 x) {} // CHECK: define float @f65() struct s65 { signed char a[0]; float b; }; struct s65 f65() { return (struct s65){{},2}; } + +// CHECK: define <2 x i64> @f66 +// CHECK: ptrtoint +// CHECK: and {{.*}}, -16 +// CHECK: inttoptr +typedef int T66 __attribute((vector_size(16))); +T66 f66(int i, ...) { + __builtin_va_list ap; + __builtin_va_start(ap, i); + T66 v = __builtin_va_arg(ap, T66); + __builtin_va_end(ap); + return v; +} diff --git a/test/CodeGen/xop-builtins.c b/test/CodeGen/xop-builtins.c new file mode 100644 index 000000000000..436deaa52134 --- /dev/null +++ b/test/CodeGen/xop-builtins.c @@ -0,0 +1,326 @@ +// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - | FileCheck %s + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include + +__m128i test_mm_maccs_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacssww + return _mm_maccs_epi16(a, b, c); +} + +__m128i test_mm_macc_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsww + return _mm_macc_epi16(a, b, c); +} + +__m128i test_mm_maccsd_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsswd + return _mm_maccsd_epi16(a, b, c); +} + +__m128i test_mm_maccd_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacswd + return _mm_maccd_epi16(a, b, c); +} + +__m128i test_mm_maccs_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacssdd + return _mm_maccs_epi32(a, b, c); +} + +__m128i test_mm_macc_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsdd + return _mm_macc_epi32(a, b, c); +} + +__m128i test_mm_maccslo_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacssdql + return _mm_maccslo_epi32(a, b, c); +} + +__m128i test_mm_macclo_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsdql + return _mm_macclo_epi32(a, b, c); +} + +__m128i test_mm_maccshi_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacssdqh + return _mm_maccshi_epi32(a, b, c); +} + +__m128i test_mm_macchi_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsdqh + return _mm_macchi_epi32(a, b, c); +} + +__m128i test_mm_maddsd_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmadcsswd + return _mm_maddsd_epi16(a, b, c); +} + +__m128i test_mm_maddd_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmadcswd + return _mm_maddd_epi16(a, b, c); +} + +__m128i test_mm_haddw_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddbw + return _mm_haddw_epi8(a); +} + +__m128i test_mm_haddd_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddbd + return _mm_haddd_epi8(a); +} + +__m128i test_mm_haddq_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddbq + return _mm_haddq_epi8(a); +} + +__m128i test_mm_haddd_epi16(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddwd + return _mm_haddd_epi16(a); +} + +__m128i test_mm_haddq_epi16(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddwq + return _mm_haddq_epi16(a); +} + +__m128i test_mm_haddq_epi32(__m128i a) { + // CHECK: @llvm.x86.xop.vphadddq + return _mm_haddq_epi32(a); +} + +__m128i test_mm_haddw_epu8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddubw + return _mm_haddw_epu8(a); +} + +__m128i test_mm_haddd_epu8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddubd + return _mm_haddd_epu8(a); +} + +__m128i test_mm_haddq_epu8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddubq + return _mm_haddq_epu8(a); +} + +__m128i test_mm_haddd_epu16(__m128i a) { + // CHECK: @llvm.x86.xop.vphadduwd + return _mm_haddd_epu16(a); +} + +__m128i test_mm_haddq_epu16(__m128i a) { + // CHECK: @llvm.x86.xop.vphadduwq + return _mm_haddq_epu16(a); +} + +__m128i test_mm_haddq_epu32(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddudq + return _mm_haddq_epu32(a); +} + +__m128i test_mm_hsubw_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vphsubbw + return _mm_hsubw_epi8(a); +} + +__m128i test_mm_hsubd_epi16(__m128i a) { + // CHECK: @llvm.x86.xop.vphsubwd + return _mm_hsubd_epi16(a); +} + +__m128i test_mm_hsubq_epi32(__m128i a) { + // CHECK: @llvm.x86.xop.vphsubdq + return _mm_hsubq_epi32(a); +} + +__m128i test_mm_cmov_si128(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpcmov + return _mm_cmov_si128(a, b, c); +} + +__m256i test_mm256_cmov_si256(__m256i a, __m256i b, __m256i c) { + // CHECK: @llvm.x86.xop.vpcmov.256 + return _mm256_cmov_si256(a, b, c); +} + +__m128i test_mm_perm_epi8(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpperm + return _mm_perm_epi8(a, b, c); +} + +__m128i test_mm_rot_epi8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vprotb + return _mm_rot_epi8(a, b); +} + +__m128i test_mm_rot_epi16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vprotw + return _mm_rot_epi16(a, b); +} + +__m128i test_mm_rot_epi32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vprotd + return _mm_rot_epi32(a, b); +} + +__m128i test_mm_rot_epi64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vprotq + return _mm_rot_epi64(a, b); +} + +__m128i test_mm_roti_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vprotbi + return _mm_roti_epi8(a, 1); +} + +__m128i test_mm_roti_epi16(__m128i a) { + // CHECK: @llvm.x86.xop.vprotwi + return _mm_roti_epi16(a, 50); +} + +__m128i test_mm_roti_epi32(__m128i a) { + // CHECK: @llvm.x86.xop.vprotdi + return _mm_roti_epi32(a, -30); +} + +__m128i test_mm_roti_epi64(__m128i a) { + // CHECK: @llvm.x86.xop.vprotqi + return _mm_roti_epi64(a, 100); +} + +__m128i test_mm_shl_epi8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshlb + return _mm_shl_epi8(a, b); +} + +__m128i test_mm_shl_epi16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshlw + return _mm_shl_epi16(a, b); +} + +__m128i test_mm_shl_epi32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshld + return _mm_shl_epi32(a, b); +} + +__m128i test_mm_shl_epi64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshlq + return _mm_shl_epi64(a, b); +} + +__m128i test_mm_sha_epi8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshab + return _mm_sha_epi8(a, b); +} + +__m128i test_mm_sha_epi16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshaw + return _mm_sha_epi16(a, b); +} + +__m128i test_mm_sha_epi32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshad + return _mm_sha_epi32(a, b); +} + +__m128i test_mm_sha_epi64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshaq + return _mm_sha_epi64(a, b); +} + +__m128i test_mm_com_epu8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomub + return _mm_com_epu8(a, b, 0); +} + +__m128i test_mm_com_epu16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomuw + return _mm_com_epu16(a, b, 0); +} + +__m128i test_mm_com_epu32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomud + return _mm_com_epu32(a, b, 0); +} + +__m128i test_mm_com_epu64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomuq + return _mm_com_epu64(a, b, 0); +} + +__m128i test_mm_com_epi8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomb + return _mm_com_epi8(a, b, 0); +} + +__m128i test_mm_com_epi16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomw + return _mm_com_epi16(a, b, 0); +} + +__m128i test_mm_com_epi32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomd + return _mm_com_epi32(a, b, 0); +} + +__m128i test_mm_com_epi64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomq + return _mm_com_epi64(a, b, 0); +} + +__m128d test_mm_permute2_pd(__m128d a, __m128d b, __m128i c) { + // CHECK: @llvm.x86.xop.vpermil2pd + return _mm_permute2_pd(a, b, c, 0); +} + +__m256d test_mm256_permute2_pd(__m256d a, __m256d b, __m256i c) { + // CHECK: @llvm.x86.xop.vpermil2pd.256 + return _mm256_permute2_pd(a, b, c, 0); +} + +__m128 test_mm_permute2_ps(__m128 a, __m128 b, __m128i c) { + // CHECK: @llvm.x86.xop.vpermil2ps + return _mm_permute2_ps(a, b, c, 0); +} + +__m256 test_mm256_permute2_ps(__m256 a, __m256 b, __m256i c) { + // CHECK: @llvm.x86.xop.vpermil2ps.256 + return _mm256_permute2_ps(a, b, c, 0); +} + +__m128 test_mm_frcz_ss(__m128 a) { + // CHECK: @llvm.x86.xop.vfrcz.ss + return _mm_frcz_ss(a); +} + +__m128d test_mm_frcz_sd(__m128d a) { + // CHECK: @llvm.x86.xop.vfrcz.sd + return _mm_frcz_sd(a); +} + +__m128 test_mm_frcz_ps(__m128 a) { + // CHECK: @llvm.x86.xop.vfrcz.ps + return _mm_frcz_ps(a); +} + +__m128d test_mm_frcz_pd(__m128d a) { + // CHECK: @llvm.x86.xop.vfrcz.pd + return _mm_frcz_pd(a); +} + +__m256 test_mm256_frcz_ps(__m256 a) { + // CHECK: @llvm.x86.xop.vfrcz.ps.256 + return _mm256_frcz_ps(a); +} + +__m256d test_mm256_frcz_pd(__m256d a) { + // CHECK: @llvm.x86.xop.vfrcz.pd.256 + return _mm256_frcz_pd(a); +} diff --git a/test/CodeGenCUDA/address-spaces.cu b/test/CodeGenCUDA/address-spaces.cu new file mode 100644 index 000000000000..61d4d6b6ba48 --- /dev/null +++ b/test/CodeGenCUDA/address-spaces.cu @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -fcuda-is-device -triple nvptx-unknown-unknown | FileCheck %s + +#include "../SemaCUDA/cuda.h" + +// CHECK: @i = addrspace(1) global +__device__ int i; + +// CHECK: @j = addrspace(4) global +__constant__ int j; + +// CHECK: @k = addrspace(3) global +__shared__ int k; + +__device__ void foo() { + // CHECK: load i32* bitcast (i32 addrspace(1)* @i to i32*) + i++; + + // CHECK: load i32* bitcast (i32 addrspace(4)* @j to i32*) + j++; + + // CHECK: load i32* bitcast (i32 addrspace(3)* @k to i32*) + k++; +} + diff --git a/test/CodeGenCUDA/ptx-kernels.cu b/test/CodeGenCUDA/ptx-kernels.cu index ecca8519af63..f0bf2952a126 100644 --- a/test/CodeGenCUDA/ptx-kernels.cu +++ b/test/CodeGenCUDA/ptx-kernels.cu @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s #include "../SemaCUDA/cuda.h" diff --git a/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/test/CodeGenCXX/anonymous-union-member-initializer.cpp index a12ae53f395f..8dc4f4721dd0 100644 --- a/test/CodeGenCXX/anonymous-union-member-initializer.cpp +++ b/test/CodeGenCXX/anonymous-union-member-initializer.cpp @@ -179,3 +179,13 @@ namespace PR9683 { }; QueueEntry QE; } + +namespace PR13154 { + struct IndirectReferenceField { + struct { + float &x; + }; + IndirectReferenceField(float &x); + }; + IndirectReferenceField::IndirectReferenceField(float &xx) : x(xx) {} +} diff --git a/test/CodeGenCXX/block-in-ctor-dtor.cpp b/test/CodeGenCXX/block-in-ctor-dtor.cpp index e4389a4eeec8..4ee6b1c10eb1 100644 --- a/test/CodeGenCXX/block-in-ctor-dtor.cpp +++ b/test/CodeGenCXX/block-in-ctor-dtor.cpp @@ -36,13 +36,13 @@ X::~X() { }; +// CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke // CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke_ -// CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke_ -// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_ +// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke // CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_ +// CHECK: define internal void @___ZN1XC1Ev_block_invoke // CHECK: define internal void @___ZN1XC1Ev_block_invoke_ -// CHECK: define internal void @___ZN1XC1Ev_block_invoke_ +// CHECK: define internal void @___ZN1XC2Ev_block_invoke // CHECK: define internal void @___ZN1XC2Ev_block_invoke_ -// CHECK: define internal void @___ZN1XC2Ev_block_invoke_ -// CHECK: define internal void @___ZN1XD2Ev_block_invoke_ +// CHECK: define internal void @___ZN1XD2Ev_block_invoke // CHECK: define internal void @___ZN1XD2Ev_block_invoke_ diff --git a/test/CodeGenCXX/blocks.cpp b/test/CodeGenCXX/blocks.cpp index eb544787da7e..1500c0d69835 100644 --- a/test/CodeGenCXX/blocks.cpp +++ b/test/CodeGenCXX/blocks.cpp @@ -2,8 +2,8 @@ namespace test0 { // CHECK: define void @_ZN5test04testEi( - // CHECK: define internal void @__test_block_invoke_{{.*}}( - // CHECK: define internal void @__block_global_{{.*}}( + // CHECK: define internal void @___ZN5test04testEi_block_invoke{{.*}}( + // CHECK: define internal void @___ZN5test04testEi_block_invoke_2{{.*}}( void test(int x) { ^{ ^{ (void) x; }; }; } @@ -119,7 +119,7 @@ namespace test4 { consume(^{ return foo(A()); }); } // CHECK: define void @_ZN5test44testEv() - // CHECK: define internal void @__test_block_invoke + // CHECK: define internal void @___ZN5test44testEv_block_invoke // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1 // CHECK-NEXT: bitcast i8* // CHECK-NEXT: call void @_ZN5test41AC1Ev([[A]]* [[TMP]]) diff --git a/test/CodeGenCXX/class-layout.cpp b/test/CodeGenCXX/class-layout.cpp index dac0a0ae5467..21e1a2b40f04 100644 --- a/test/CodeGenCXX/class-layout.cpp +++ b/test/CodeGenCXX/class-layout.cpp @@ -77,3 +77,17 @@ namespace Test6 { class E : public B {}; E *e; } + +// : Make sure this doesn't crash. (It's okay +// if we start rejecting it at some point.) +namespace Test7 { + #pragma pack (1) + class A {}; + // CHECK: %"class.Test7::B" = type <{ i32 (...)**, %"class.Test7::A" }> + class B { + virtual ~B(); + A a; + }; + B* b; + #pragma pack () +} diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp index 62a345a49564..db1bb412606b 100644 --- a/test/CodeGenCXX/const-init-cxx11.cpp +++ b/test/CodeGenCXX/const-init-cxx11.cpp @@ -49,6 +49,17 @@ namespace StructUnion { // CHECK: @_ZN11StructUnion1fE = global {{.*}} { i32 5 } D f; + + union E { + int a; + void *b = &f; + }; + + // CHECK: @_ZN11StructUnion1gE = global {{.*}} @_ZN11StructUnion1fE + E g; + + // CHECK: @_ZN11StructUnion1hE = global {{.*}} @_ZN11StructUnion1fE + E h = E(); } namespace BaseClass { @@ -110,6 +121,13 @@ namespace Array { }; // CHECK: @_ZN5Array1eE = constant {{.*}} { [4 x i8] c"foo\00", [4 x i8] c"x\00\00\00" } extern constexpr E e = E(); + + // PR13290 + struct F { constexpr F() : n(4) {} int n; }; + // CHECK: @_ZN5Array2f1E = global {{.*}} zeroinitializer + F f1[1][1][0] = { }; + // CHECK: @_ZN5Array2f2E = global {{.* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4}} + F f2[2][2][2] = { }; } namespace MemberPtr { @@ -298,6 +316,20 @@ namespace VirtualMembers { static nsMemoryImpl sGlobalMemory; } +namespace PR13273 { + struct U { + int t; + U() = default; + }; + + struct S : U { + S() = default; + }; + + // CHECK: @_ZN7PR132731sE = {{.*}} zeroinitializer + extern const S s {}; +} + // Constant initialization tests go before this point, // dynamic initialization tests go after. diff --git a/test/CodeGenCXX/constructor-init.cpp b/test/CodeGenCXX/constructor-init.cpp index 9f808f6680ed..b33184e3966e 100644 --- a/test/CodeGenCXX/constructor-init.cpp +++ b/test/CodeGenCXX/constructor-init.cpp @@ -131,6 +131,26 @@ namespace rdar9694300 { } } +// Check that we emit a zero initialization step for list-value-initialization +// which calls a trivial default constructor. +namespace PR13273 { + struct U { + int t; + U() = default; + }; + + struct S : U { + S() = default; + }; + + // CHECK: define {{.*}}@_ZN7PR132731fEv( + int f() { + // CHECK-NOT: } + // CHECK: llvm.memset{{.*}}i8 0 + return (new S{})->t; + } +} + template struct X { X(const X &); diff --git a/test/CodeGenCXX/cxx0x-delegating-ctors.cpp b/test/CodeGenCXX/cxx0x-delegating-ctors.cpp index f5684d93abd9..ad6492f5bfdc 100644 --- a/test/CodeGenCXX/cxx0x-delegating-ctors.cpp +++ b/test/CodeGenCXX/cxx0x-delegating-ctors.cpp @@ -54,3 +54,14 @@ delegator::delegator(char) delegator::delegator(int) : delegator() {} + +namespace PR12890 { + class X { + int x; + X() = default; + X(int); + }; + X::X(int) : X() {} +} +// CHECK: define {{.*}} @_ZN7PR128901XC1Ei(%"class.PR12890::X"* %this, i32) +// CHECK: call void @llvm.memset.p0i8.{{i32|i64}}(i8* {{.*}}, i8 0, {{i32|i64}} 4, i32 4, i1 false) diff --git a/test/CodeGenCXX/cxx0x-initializer-constructors.cpp b/test/CodeGenCXX/cxx0x-initializer-constructors.cpp new file mode 100644 index 000000000000..48fbe85d0d7a --- /dev/null +++ b/test/CodeGenCXX/cxx0x-initializer-constructors.cpp @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s + +struct S { + S(int x) { } + S(int x, double y, double z) { } +}; + +void fn1() { + // CHECK: define void @_Z3fn1v + S s { 1 }; + // CHECK: alloca %struct.S, align 1 + // CHECK: call void @_ZN1SC1Ei(%struct.S* %s, i32 1) +} + +void fn2() { + // CHECK: define void @_Z3fn2v + S s { 1, 2.0, 3.0 }; + // CHECK: alloca %struct.S, align 1 + // CHECK: call void @_ZN1SC1Eidd(%struct.S* %s, i32 1, double 2.000000e+00, double 3.000000e+00) +} + +void fn3() { + // CHECK: define void @_Z3fn3v + S sa[] { { 1 }, { 2 }, { 3 } }; + // CHECK: alloca [3 x %struct.S], align 1 + // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 1) + // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 2) + // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 3) +} + +void fn4() { + // CHECK: define void @_Z3fn4v + S sa[] { { 1, 2.0, 3.0 }, { 4, 5.0, 6.0 } }; + // CHECK: alloca [2 x %struct.S], align 1 + // CHECK: call void @_ZN1SC1Eidd(%struct.S* %{{.+}}, i32 1, double 2.000000e+00, double 3.000000e+00) + // CHECK: call void @_ZN1SC1Eidd(%struct.S* %{{.+}}, i32 4, double 5.000000e+00, double 6.000000e+00) +} diff --git a/test/CodeGenCXX/cxx0x-initializer-references.cpp b/test/CodeGenCXX/cxx0x-initializer-references.cpp index 4c847b8e583c..660b018460db 100644 --- a/test/CodeGenCXX/cxx0x-initializer-references.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-references.cpp @@ -28,6 +28,10 @@ namespace reference { // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % A &ra1a = {a}; + using T = A&; + // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % + A &ra1b = T{a}; + // CHECK-NEXT: ret } diff --git a/test/CodeGenCXX/cxx11-initializer-aggregate.cpp b/test/CodeGenCXX/cxx11-initializer-aggregate.cpp new file mode 100644 index 000000000000..acc77825ae84 --- /dev/null +++ b/test/CodeGenCXX/cxx11-initializer-aggregate.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s + +struct A { int a, b; int f(); }; + +// CHECK: define {{.*}}@_Z3fn1i( +int fn1(int x) { + // CHECK: %[[INITLIST:.*]] = alloca %struct.A + // CHECK: %[[A:.*]] = getelementptr inbounds %struct.A* %[[INITLIST]], i32 0, i32 0 + // CHECK: store i32 %{{.*}}, i32* %[[A]], align 4 + // CHECK: %[[B:.*]] = getelementptr inbounds %struct.A* %[[INITLIST]], i32 0, i32 1 + // CHECK: store i32 5, i32* %[[B]], align 4 + // CHECK: call i32 @_ZN1A1fEv(%struct.A* %[[INITLIST]]) + return A{x, 5}.f(); +} + +struct B { int &r; int &f() { return r; } }; + +// CHECK: define {{.*}}@_Z3fn2Ri( +int &fn2(int &v) { + // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8 + // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B* %[[INITLIST2:.*]], i32 0, i32 0 + // CHECK: store i32* %{{.*}}, i32** %[[R]], align 8 + // CHECK: call i32* @_ZN1B1fEv(%struct.B* %[[INITLIST2:.*]]) + return B{v}.f(); +} diff --git a/test/CodeGenCXX/cxx11-vtable-key-function.cpp b/test/CodeGenCXX/cxx11-vtable-key-function.cpp new file mode 100644 index 000000000000..cd2ab59506d4 --- /dev/null +++ b/test/CodeGenCXX/cxx11-vtable-key-function.cpp @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -std=c++11 | FileCheck %s +// PR13424 + +namespace Test1 { +struct X { + virtual ~X(); // Key function. + virtual void f(); // Not a key function. +}; + +X::~X() = default; + +// Verify that the vtable is emitted. +// CHECK: @_ZTVN5Test11XE = unnamed_addr constant +} + +namespace Test2 { +struct X { + virtual ~X() = default; // Not a key function. + virtual void f(); // Key function. +}; + +void X::f() {} + +// Verify that the vtable is emitted. +// CHECK: @_ZTVN5Test21XE = unnamed_addr constant +} + +namespace Test3 { +struct X { + virtual ~X() = delete; // Not a key function. + virtual void f(); // Key function. +}; + +void X::f() {} + +// Verify that the vtable is emitted. +// CHECK: @_ZTVN5Test31XE = unnamed_addr constant +} diff --git a/test/CodeGenCXX/debug-info-artificial-arg.cpp b/test/CodeGenCXX/debug-info-artificial-arg.cpp index 92d1b162f533..35e5f2775fd7 100644 --- a/test/CodeGenCXX/debug-info-artificial-arg.cpp +++ b/test/CodeGenCXX/debug-info-artificial-arg.cpp @@ -23,8 +23,8 @@ int main(int argc, char **argv) { } // FIXME: The numbers are truly awful. -// CHECK: !18 = metadata !{i32 {{.*}}, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !19} ; [ DW_TAG_pointer_type ] -// CHECK: !19 = metadata !{i32 {{.*}}, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, metadata !19, null} ; [ DW_TAG_class_type ] -// CHECK: metadata !19, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !45, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !47, i32 12} ; [ DW_TAG_subprogram ] -// CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !46, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] -// CHECK: !46 = metadata !{null, metadata !18, metadata !9, metadata !34} +// CHECK: !16 = metadata !{i32 {{.*}}, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !17} ; [ DW_TAG_pointer_type ] +// CHECK: !17 = metadata !{i32 {{.*}}, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !18, i32 0, metadata !17, null} ; [ DW_TAG_class_type ] +// CHECK: metadata !17, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !43, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !45, i32 12} ; [ DW_TAG_subprogram ] +// CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !44, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +// CHECK: !44 = metadata !{null, metadata !16, metadata !9, metadata !32} diff --git a/test/CodeGenCXX/debug-info-cxx0x.cpp b/test/CodeGenCXX/debug-info-cxx0x.cpp index 37ccdb01c5c0..9d303755be0e 100644 --- a/test/CodeGenCXX/debug-info-cxx0x.cpp +++ b/test/CodeGenCXX/debug-info-cxx0x.cpp @@ -6,3 +6,13 @@ namespace PR9414 { return x; } } + +// Don't crash. +namespace PR13570 { + template struct P {}; + template struct A { + template static P isa(U); + decltype(isa(int())) f() {} + }; + template struct A; +} diff --git a/test/CodeGenCXX/debug-info-determinism.cpp b/test/CodeGenCXX/debug-info-determinism.cpp new file mode 100644 index 000000000000..a96a14e9edcd --- /dev/null +++ b/test/CodeGenCXX/debug-info-determinism.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -S -emit-llvm -g -o %t1.ll %s +// RUN: %clang_cc1 -S -emit-llvm -g -o %t2.ll %s +// RUN: diff %t1.ll %t2.ll + +template struct C { + template int f() { + int arr[M] = {}; + return arr[M/2] + C().template f(); + } +}; +template <> template <> int C<0>::f<0>() { return 0; } +template <> template <> int C<0>::f<1>() { return 0; } +template <> template <> int C<1>::f<0>() { return 0; } +template <> template <> int C<1>::f<1>() { return 0; } + +int x = C<0>().f<64>(); diff --git a/test/CodeGenCXX/debug-info-enum-class.cpp b/test/CodeGenCXX/debug-info-enum-class.cpp new file mode 100644 index 000000000000..6f88439b1eed --- /dev/null +++ b/test/CodeGenCXX/debug-info-enum-class.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s + +enum class A { A1=1 }; // underlying type is int by default +enum class B: unsigned long { B1=1 }; // underlying type is unsigned long +enum C { C1 = 1 }; +enum D : short; // enum forward declaration +A a; +B b; +C c; +D d; + +// CHECK: metadata !{i32 {{.*}}, null, metadata !"A", metadata !4, i32 3, i64 32, i64 32, i32 0, i32 0, metadata !5, metadata !6, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"B", metadata !4, i32 4, i64 64, i64 64, i32 0, i32 0, metadata !9, metadata !10, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"C", metadata !4, i32 5, i64 32, i64 32, i32 0, i32 0, null, metadata !13, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"D", metadata !4, i32 6, i64 16, i64 16, i32 0, i32 4, null, metadata !16, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] diff --git a/test/CodeGenCXX/debug-info-flex-member.cpp b/test/CodeGenCXX/debug-info-flex-member.cpp new file mode 100644 index 000000000000..b6aa6dac6bce --- /dev/null +++ b/test/CodeGenCXX/debug-info-flex-member.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s + +// CHECK: metadata !{i32 {{.*}}, i64 1, i64 0} ; [ DW_TAG_subrange_type ] + +struct StructName { + int member[]; +}; + +struct StructName SN; diff --git a/test/CodeGenCXX/debug-info-fwd-ref.cpp b/test/CodeGenCXX/debug-info-fwd-ref.cpp index 5480c6b14fd9..e7f2ed19d79f 100644 --- a/test/CodeGenCXX/debug-info-fwd-ref.cpp +++ b/test/CodeGenCXX/debug-info-fwd-ref.cpp @@ -19,8 +19,8 @@ int main(int argc, char** argv) { // Make sure we have two DW_TAG_class_types for baz and bar and no forward // references. // FIXME: These should be struct types to match the declaration. -// CHECK: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !23, i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 9, i64 0, i64 0, i32 0, i32 4, i32 0, null, i32 0, i32 0} ; [ DW_TAG_class_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !18, i32 0, null, null} ; [ DW_TAG_class_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !21, i32 0, null, null} ; [ DW_TAG_class_type ] +// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 0, i64 0, i32 0, i32 4, i32 0, null, i32 0, i32 0} ; [ DW_TAG_class_type ] // CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null} ; [ DW_TAG_class_type ] diff --git a/test/CodeGenCXX/debug-info-gline-tables-only.cpp b/test/CodeGenCXX/debug-info-gline-tables-only.cpp new file mode 100644 index 000000000000..8d2e63d67778 --- /dev/null +++ b/test/CodeGenCXX/debug-info-gline-tables-only.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 %s -O0 -gline-tables-only -S -emit-llvm -o - | FileCheck %s +// Checks that clang with "-gline-tables-only" doesn't emit debug info +// for variables and types. + +// CHECK-NOT: DW_TAG_namespace +namespace NS { +// CHECK-NOT: DW_TAG_class_type +// CHECK-NOT: DW_TAG_friend +class C { friend class D; }; +class D {}; +// CHECK-NOT: DW_TAG_inheritance +class E : public C { + // CHECK-NOT: DW_TAG_reference type + void x(const D& d); +}; +} + +// CHECK-NOT: DW_TAG_variable +NS::C c; +NS::D d; +NS::E e; diff --git a/test/CodeGenCXX/debug-info-globalinit.cpp b/test/CodeGenCXX/debug-info-globalinit.cpp new file mode 100644 index 000000000000..ff50fac4cfa3 --- /dev/null +++ b/test/CodeGenCXX/debug-info-globalinit.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -std=c++11 -g | FileCheck %s + +void crash() { + volatile char *ptr = 0; + char x = *ptr; +} + +int test() { + crash(); + return 1; +} + +static int i = test(); +__attribute__((nodebug)) static int j = test(); + +int main(void) {} + +// CHECK: define internal void @__cxx_global_var_init() +// CHECK-NOT: __cxx_global_var_init +// CHECK: %[[C0:.+]] = call i32 @_Z4testv(), !dbg ![[LINE:.*]] +// CHECK-NOT: __cxx_global_var_init +// CHECK: store i32 %[[C0]], i32* @_ZL1i, align 4, !dbg +// +// CHECK: define internal void @__cxx_global_var_init1() +// CHECK-NOT: dbg +// CHECK: %[[C1:.+]] = call i32 @_Z4testv() +// CHECK-NOT: dbg +// CHECK: store i32 %[[C1]], i32* @_ZL1j, align 4 +// +// CHECK: ![[LINE]] = metadata !{i32 13, i32 16 diff --git a/test/CodeGenCXX/debug-info-nullptr.cpp b/test/CodeGenCXX/debug-info-nullptr.cpp index 5540a9217cbe..4cc7e546d889 100644 --- a/test/CodeGenCXX/debug-info-nullptr.cpp +++ b/test/CodeGenCXX/debug-info-nullptr.cpp @@ -4,4 +4,4 @@ void foo() { decltype(nullptr) t = 0; } -// CHECK: !13 = metadata !{i32 {{.*}}, null, metadata !"nullptr_t", null, i32 0, i64 0, i64 0, i64 0, i32 0, i32 0} ; [ DW_TAG_unspecified_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"nullptr_t", null, i32 0, i64 0, i64 0, i64 0, i32 0, i32 0} ; [ DW_TAG_unspecified_type ] diff --git a/test/CodeGenCXX/debug-info-rvalue-ref.cpp b/test/CodeGenCXX/debug-info-rvalue-ref.cpp new file mode 100644 index 000000000000..b633c5ceb507 --- /dev/null +++ b/test/CodeGenCXX/debug-info-rvalue-ref.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s + +extern "C" { +extern int printf(const char * format, ...); +} +void foo (int &&i) +{ + printf("%d\n", i); +} + +// CHECK: metadata !{i32 {{.*}}, null, null, null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !10} ; [ DW_TAG_rvalue_reference_type ] diff --git a/test/CodeGenCXX/debug-info-static-fns.cpp b/test/CodeGenCXX/debug-info-static-fns.cpp index 485d28aa7b7c..ee46f259a42e 100644 --- a/test/CodeGenCXX/debug-info-static-fns.cpp +++ b/test/CodeGenCXX/debug-info-static-fns.cpp @@ -7,4 +7,4 @@ namespace A { } // Verify that a is present and mangled. -// CHECK: metadata !{i32 786478, i32 0, metadata !6, metadata !"a", metadata !"a", metadata !"_ZN1AL1aEi", metadata !7, i32 4, metadata !8, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_ZN1AL1aEi, null, null, metadata !14, i32 4} ; [ DW_TAG_subprogram ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !6, metadata !"a", metadata !"a", metadata !"_ZN1AL1aEi", metadata !7, i32 4, metadata !8, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_ZN1AL1aEi, null, null, metadata !1, i32 4} ; [ DW_TAG_subprogram ] diff --git a/test/CodeGenCXX/debug-info-template-array.cpp b/test/CodeGenCXX/debug-info-template-array.cpp new file mode 100644 index 000000000000..305327bbe099 --- /dev/null +++ b/test/CodeGenCXX/debug-info-template-array.cpp @@ -0,0 +1,14 @@ +// RUN: %clang -emit-llvm -g -S %s -o - +// PR13531 +template +struct unique_ptr { + unique_ptr() {} +}; + +template +struct Vertex {}; + +void crash() // Asserts +{ + unique_ptr[]> v = unique_ptr[]>(); +} diff --git a/test/CodeGenCXX/debug-info-template-limit.cpp b/test/CodeGenCXX/debug-info-template-limit.cpp index 796a80fd627f..afad31b14efa 100644 --- a/test/CodeGenCXX/debug-info-template-limit.cpp +++ b/test/CodeGenCXX/debug-info-template-limit.cpp @@ -1,8 +1,8 @@ // RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s // Check that this pointer type is TC -// CHECK: !10} ; [ DW_TAG_pointer_type -// CHECK-NEXT: !10 ={{.*}}"TC" +// CHECK: ![[LINE:[0-9]+]]} ; [ DW_TAG_pointer_type ]{{.*}}[from TC] +// CHECK-NEXT: ![[LINE]] ={{.*}}"TC" template class TC { @@ -12,4 +12,3 @@ public: }; TC tci; - diff --git a/test/CodeGenCXX/debug-info-template-member.cpp b/test/CodeGenCXX/debug-info-template-member.cpp index 6208c80aeb61..f21718da5e67 100644 --- a/test/CodeGenCXX/debug-info-template-member.cpp +++ b/test/CodeGenCXX/debug-info-template-member.cpp @@ -17,5 +17,5 @@ private: MyClass m; // CHECK: metadata !{i32 {{.*}}, null, metadata !"MyClass", metadata {{.*}}, i32 {{.*}}, i64 8, i64 8, i32 0, i32 0, null, metadata [[C_MEM:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[C_MEM]] = metadata !{metadata {{.*}}, metadata [[C_TEMP:.*]], metadata {{.*}}} +// CHECK: [[C_MEM]] = metadata !{metadata {{.*}}, metadata [[C_TEMP:.*]]} // CHECK: [[C_TEMP]] = metadata !{i32 {{.*}}, i32 0, metadata {{.*}}, metadata !"add<2>", metadata !"add<2>", metadata !"_ZN7MyClass3addILi2EEEii", metadata {{.*}} diff --git a/test/CodeGenCXX/debug-info-template-quals.cpp b/test/CodeGenCXX/debug-info-template-quals.cpp new file mode 100644 index 000000000000..e5a9082c9c29 --- /dev/null +++ b/test/CodeGenCXX/debug-info-template-quals.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s + +template +struct basic_string { + + basic_string& + assign(const _CharT* __s) + { + return *this; + } +}; + +void foo (const char *c) { + basic_string str; + str.assign(c); +} + +// CHECK: [[P:.*]] = metadata !{i32 {{.*}}, metadata [[CON:.*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +// CHECK: [[CON]] = metadata !{i32 {{.*}}, metadata [[CH:.*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char] +// CHECK: [[CH]] = metadata !{i32 {{.*}}, metadata !"char", {{.*}}} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char] +// CHECK: metadata !{i32 {{.*}}, metadata !"_ZN12basic_stringIcE6assignEPKc", metadata !6, i32 7, metadata [[TYPE:.*]], i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, %struct.basic_string* (%struct.basic_string*, i8*)* @_ZN12basic_stringIcE6assignEPKc, null, metadata !18, metadata !1, i32 8} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [assign] +// CHECK: [[TYPE]] = metadata !{i32 {{.*}}, null, metadata [[ARGS:.*]], i32 0, i32 0} +// CHECK: [[ARGS]] = metadata !{metadata !15, metadata !23, metadata [[P]]} diff --git a/test/CodeGenCXX/debug-info-union.cpp b/test/CodeGenCXX/debug-info-union.cpp new file mode 100644 index 000000000000..588fa203367b --- /dev/null +++ b/test/CodeGenCXX/debug-info-union.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s + +union E { + int a; + float b; + int bb() { return a;} + float aa() { return b;} + E() { a = 0; } +}; + +E e; + +// CHECK: metadata !{i32 {{.*}}, null, metadata !"E", metadata !{{.*}}, i32 3, i64 32, i64 32, i64 0, i32 0, null, metadata !{{.*}}, i32 0, null} ; [ DW_TAG_union_type ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !{{.*}}, metadata !"bb", metadata !"bb", metadata !"_ZN1E2bbEv", metadata !{{.*}}, i32 6, metadata !{{.*}}, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !{{.*}}, i32 6} ; [ DW_TAG_subprogram ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !{{.*}}, metadata !"aa", metadata !"aa", metadata !"_ZN1E2aaEv", metadata !{{.*}}, i32 7, metadata !{{.*}}, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !{{.*}}, i32 7} ; [ DW_TAG_subprogram ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !{{.*}}, metadata !"E", metadata !"E", metadata !"", metadata !{{.*}}, i32 8, metadata !{{.*}}, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !{{.*}}, i32 8} ; [ DW_TAG_subprogram ] diff --git a/test/CodeGenCXX/debug-info-user-def.cpp b/test/CodeGenCXX/debug-info-user-def.cpp new file mode 100644 index 000000000000..ecd387870549 --- /dev/null +++ b/test/CodeGenCXX/debug-info-user-def.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s + +class A { +}; + +template class B { + T t; +}; + +A a; +B b; + +// Check that no subprograms are emitted into debug info. +// CHECK-NOT: [ DW_TAG_subprogram ] diff --git a/test/CodeGenCXX/debug-lambda-expressions.cpp b/test/CodeGenCXX/debug-lambda-expressions.cpp index 859a71b621ca..1c823990c1d9 100644 --- a/test/CodeGenCXX/debug-lambda-expressions.cpp +++ b/test/CodeGenCXX/debug-lambda-expressions.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -g | FileCheck %s auto var = [](int i) { return i+1; }; +void *use = &var; extern "C" auto cvar = []{}; @@ -13,59 +14,56 @@ int c(int x) { return [&x]{return x;}(); } struct D { D(); D(const D&); int x; }; int d(int x) { D y[10]; [x,y] { return y[x].x; }(); } - -// A: 5 -// CHECK: [[A_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE:.*]], metadata !"a", metadata !"a", metadata !"_Z1av", metadata {{.*}}, i32 [[A_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z1av, null, null, {{.*}} [ DW_TAG_subprogram ] - // Randomness for file. -- 6 -// CHECK: [[FILE]] = metadata !{i32 {{.*}}, metadata !{{.*}}debug-lambda-expressions.cpp{{.*}}; [ DW_TAG_file_type ] +// CHECK: [[FILE:.*]] = metadata !{i32 {{.*}}, metadata !{{.*}}debug-lambda-expressions.cpp{{.*}}; [ DW_TAG_file_type ] + +// A: 10 +// CHECK: [[A_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"a", metadata !"a", metadata !"_Z1av", metadata {{.*}}, i32 [[A_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z1av, null, null, {{.*}} [ DW_TAG_subprogram ] -// B: 12 +// B: 14 // CHECK: [[B_FUNC:.*]] = metadata !{i32 786478, i32 0, metadata [[FILE]], metadata !"b", metadata !"b", metadata !"_Z1bi", metadata [[FILE]], i32 [[B_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1bi, null, null, {{.*}} ; [ DW_TAG_subprogram ] // C: 17 // CHECK: [[C_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"c", metadata !"c", metadata !"_Z1ci", metadata [[FILE]], i32 [[C_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1ci, null, null, metadata {{.*}} ; [ DW_TAG_subprogram ] -// D: 20 +// D: 18 // CHECK: [[D_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"d", metadata !"d", metadata !"_Z1di", metadata [[FILE]], i32 [[D_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1di, null, null, metadata {{.*}} ; [ DW_TAG_subprogram ] -// Back to D. -- 120 +// Back to D. -- 24 // CHECK: [[LAM_D:.*]] = metadata !{i32 {{.*}}, metadata [[D_FUNC]], metadata !"", metadata [[FILE]], i32 [[D_LINE]], i64 352, i64 32, i32 0, i32 0, null, metadata [[LAM_D_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]], metadata [[DES_LAM_D:.*]]} -// CHECK: [[CAP_D_X]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"x", metadata [[FILE]], i32 14, i64 32, i64 32, i64 0, i32 1, metadata {{.*}} ; [ DW_TAG_member ] -// CHECK: [[CAP_D_Y]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"y", metadata [[FILE]], i32 14, i64 320, i64 32, i64 32, i32 1, metadata {{.*}} ; [ DW_TAG_member ] +// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]]} +// CHECK: [[CAP_D_X]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"x", metadata [[FILE]], i32 [[D_LINE]], i64 32, i64 32, i64 0, i32 1, metadata {{.*}} ; [ DW_TAG_member ] +// CHECK: [[CAP_D_Y]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"y", metadata [[FILE]], i32 [[D_LINE]], i64 320, i64 32, i64 32, i32 1, metadata {{.*}} ; [ DW_TAG_member ] // CHECK: [[CON_LAM_D]] = metadata {{.*}}[[LAM_D]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ] -// CHECK: [[DES_LAM_D]] = metadata {{.*}}[[LAM_D]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ] -// Back to C. -- 159 +// Back to C. -- 55 // CHECK: [[LAM_C:.*]] = metadata !{i32 {{.*}}, metadata [[C_FUNC]], metadata !"", metadata [[FILE]], i32 [[C_LINE]], i64 64, i64 64, i32 0, i32 0, null, metadata [[LAM_C_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]], metadata [[DES_LAM_C:.*]]} +// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]]} // Ignoring the member type for now. // CHECK: [[CAP_C]] = metadata !{i32 {{.*}}, metadata [[LAM_C]], metadata !"x", metadata [[FILE]], i32 [[C_LINE]], i64 64, i64 64, i64 0, i32 1, metadata {{.*}}} ; [ DW_TAG_member ] // CHECK: [[CON_LAM_C]] = metadata {{.*}}[[LAM_C]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ] -// CHECK: [[DES_LAM_C]] = metadata {{.*}}[[LAM_C]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ] -// Back to B. -- 179 +// Back to B. -- 67 // CHECK: [[LAM_B:.*]] = metadata !{i32 {{.*}}, metadata [[B_FUNC]], metadata !"", metadata [[FILE]], i32 [[B_LINE]], i64 32, i64 32, i32 0, i32 0, null, metadata [[LAM_B_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]], metadata [[DES_LAM_B:.*]]} +// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]]} // CHECK: [[CAP_B]] = metadata !{i32 {{.*}}, metadata [[LAM_B]], metadata !"x", metadata [[FILE]], i32 [[B_LINE]], i64 32, i64 32, i64 0, i32 1, metadata {{.*}}} ; [ DW_TAG_member ] // CHECK: [[CON_LAM_B]] = metadata {{.*}}[[LAM_B]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ] -// CHECK: [[DES_LAM_B]] = metadata {{.*}}[[LAM_B]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ] -// Back to A. -- 204 + +// Back to A. -- 78 // CHECK: [[LAM_A:.*]] = metadata !{i32 {{.*}}, metadata [[A_FUNC]], metadata !"", metadata [[FILE]], i32 [[A_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata [[LAM_A_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]], metadata [[DES_LAM_A:.*]]} +// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]]} // CHECK: [[CON_LAM_A]] = metadata {{.*}}[[LAM_A]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ] -// CHECK: [[DES_LAM_A]] = metadata {{.*}}[[LAM_A]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ] -// VAR: -// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"var", metadata !"var", metadata !"", metadata [[FILE]], i32 [[VAR_LINE:.*]], metadata ![[VAR_T:.*]], i32 1, i32 1, %class.anon* @var} ; [ DW_TAG_variable ] -// CHECK: [[VAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[VAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[VAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}} // CVAR: // CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"cvar", metadata !"cvar", metadata !"", metadata [[FILE]], i32 [[CVAR_LINE:.*]], metadata ![[CVAR_T:.*]], i32 0, i32 1, %class.anon.0* @cvar} ; [ DW_TAG_variable ] // CHECK: [[CVAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[CVAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[CVAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}} +// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}} + +// VAR: +// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"var", metadata !"var", metadata !"", metadata [[FILE]], i32 [[VAR_LINE:.*]], metadata ![[VAR_T:.*]], i32 1, i32 1, %class.anon* @var} ; [ DW_TAG_variable ] +// CHECK: [[VAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[VAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[VAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] +// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}} diff --git a/test/CodeGenCXX/derived-to-base-conv.cpp b/test/CodeGenCXX/derived-to-base-conv.cpp index 8c51809e0427..9b15c6804dfc 100644 --- a/test/CodeGenCXX/derived-to-base-conv.cpp +++ b/test/CodeGenCXX/derived-to-base-conv.cpp @@ -1,85 +1,86 @@ -// REQUIRES: x86-registered-target,x86-64-registered-target -// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s - -extern "C" int printf(...); -extern "C" void exit(int); +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | FileCheck %s struct A { - A (const A&) { printf("A::A(const A&)\n"); } - A() {}; - ~A() { printf("A::~A()\n"); } + A(const A&); + A(); + ~A(); }; struct B : public A { - B() {}; - B(const B& Other) : A(Other) { printf("B::B(const B&)\n"); } - ~B() { printf("B::~B()\n"); } + B(); + B(const B& Other); + ~B(); }; struct C : public B { - C() {}; - C(const C& Other) : B(Other) { printf("C::C(const C&)\n"); } - ~C() { printf("C::~C()\n"); } + C(); + C(const C& Other); + ~C(); }; struct X { - operator B&() {printf("X::operator B&()\n"); return b; } - operator C&() {printf("X::operator C&()\n"); return c; } - X (const X&) { printf("X::X(const X&)\n"); } - X () { printf("X::X()\n"); } - ~X () { printf("X::~X()\n"); } - B b; - C c; + operator B&(); + operator C&(); + X(const X&); + X(); + ~X(); + B b; + C c; }; -void f(A) { - printf("f(A)\n"); -} - - -void func(X x) -{ - f (x); -} - -int main() -{ - X x; - func(x); +void test0_helper(A); +void test0(X x) { + test0_helper(x); + // CHECK: define void @_Z5test01X( + // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align + // CHECK-NEXT: [[T0:%.*]] = call [[B:%.*]]* @_ZN1XcvR1BEv( + // CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]* [[T0]] to [[A]]* + // CHECK-NEXT: call void @_ZN1AC1ERKS_([[A]]* [[TMP]], [[A]]* [[T1]]) + // CHECK-NEXT: call void @_Z12test0_helper1A([[A]]* [[TMP]]) + // CHECK-NEXT: call void @_ZN1AD1Ev([[A]]* [[TMP]]) + // CHECK-NEXT: ret void } struct Base; struct Root { - operator Base&() { exit(1); } + operator Base&(); }; struct Derived; struct Base : Root { - Base(const Base&) { printf("Base::(const Base&)\n"); } - Base() { printf("Base::Base()\n"); } - operator Derived&() { exit(1); } + Base(const Base &); + Base(); + operator Derived &(); }; struct Derived : Base { }; -void foo(Base) {} - -void test(Derived bb) -{ - // CHECK-LP64-NOT: callq __ZN4BasecvR7DerivedEv - // CHECK-LP32-NOT: callq L__ZN4BasecvR7DerivedEv - foo(bb); +void test1_helper(Base); +void test1(Derived bb) { + // CHECK: define void @_Z5test17Derived( + // CHECK-NOT: call {{.*}} @_ZN4BasecvR7DerivedEv( + // CHECK: call void @_ZN4BaseC1ERKS_( + // CHECK-NOT: call {{.*}} @_ZN4BasecvR7DerivedEv( + // CHECK: call void @_Z12test1_helper4Base( + test1_helper(bb); } -// CHECK-LP64: callq __ZN1XcvR1BEv -// CHECK-LP64: callq __ZN1AC1ERKS_ - -// CHECK-LP32: calll L__ZN1XcvR1BEv -// CHECK-LP32: calll L__ZN1AC1ERKS_ - +// Don't crash after devirtualizing a derived-to-base conversion +// to an empty base allocated at offset zero. +// rdar://problem/11993704 +class Test2a {}; +class Test2b final : public virtual Test2a {}; +void test2(Test2b &x) { + Test2a &y = x; + // CHECK: define void @_Z5test2R6Test2b( + // CHECK: [[X:%.*]] = alloca [[B:%.*]]*, align 8 + // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]]*, align 8 + // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]], align 8 + // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]], align 8 + // CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]* [[T0]] to [[A]]* + // CHECK-NEXT: store [[A]]* [[T1]], [[A]]** [[Y]], align 8 + // CHECK-NEXT: ret void +} diff --git a/test/CodeGenCXX/destructor-debug-info.cpp b/test/CodeGenCXX/destructor-debug-info.cpp index 9e32275d3394..385c86d9be19 100644 --- a/test/CodeGenCXX/destructor-debug-info.cpp +++ b/test/CodeGenCXX/destructor-debug-info.cpp @@ -1,6 +1,5 @@ -// RUN: %clang_cc1 -g -S -emit-llvm -o %t %s -// RUN: grep "i32 20, i32 3, metadata" %t | count 1 -// Check there is a line number entry for line 20 where b1 is destructed. +// RUN: %clang_cc1 -g -S -emit-llvm %s -o - | FileCheck %s + class A { int a; }; class B { public: @@ -19,3 +18,5 @@ void foo() { fn (b1); } } +// Check there is a line number entry for line 19 where b1 is destructed. +// CHECK: i32 19, i32 3, metadata diff --git a/test/CodeGenCXX/destructor-exception-spec.cpp b/test/CodeGenCXX/destructor-exception-spec.cpp new file mode 100644 index 000000000000..579daef8541f --- /dev/null +++ b/test/CodeGenCXX/destructor-exception-spec.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -emit-llvm-only %s -std=c++11 + +// PR13479: don't crash with -fno-exceptions. +namespace { + struct SchedulePostRATDList { + virtual ~SchedulePostRATDList(); + }; + + SchedulePostRATDList::~SchedulePostRATDList() {} + + SchedulePostRATDList Scheduler; +} diff --git a/test/CodeGenCXX/destructors.cpp b/test/CodeGenCXX/destructors.cpp index d9962e615ec5..d665445f959e 100644 --- a/test/CodeGenCXX/destructors.cpp +++ b/test/CodeGenCXX/destructors.cpp @@ -350,6 +350,22 @@ namespace test8 { // CHECK: unreachable } +// PR12710 +namespace test9 { + struct ArgType { + ~ArgType(); + }; + template + void f1(const ArgType& = ArgType()); + void f2(); + void bar() { + f1(); + f2(); + } + // CHECK: call void @_ZN5test97ArgTypeD1Ev(%"struct.test9::ArgType"* % + // CHECK: call void @_ZN5test92f2Ev() +} + // Checks from test3: // CHECK: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::::D"* %this) unnamed_addr diff --git a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp index 3de75ed3db54..634bf84b416d 100644 --- a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp +++ b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - | FileCheck %s namespace Test1 { struct A { @@ -49,3 +49,140 @@ namespace Test3 { return static_cast(v)->f(); } } + +namespace Test4 { + struct A { + virtual void f(); + }; + + struct B final : A { + virtual void f(); + }; + + // CHECK: define void @_ZN5Test41fEPNS_1BE + void f(B* d) { + // CHECK: call void @_ZN5Test41B1fEv + static_cast(d)->f(); + } +} + +namespace Test5 { + struct A { + virtual void f(); + }; + + struct B : A { + virtual void f(); + }; + + struct C final : B { + }; + + // CHECK: define void @_ZN5Test51fEPNS_1CE + void f(C* d) { + // FIXME: It should be possible to devirtualize this case, but that is + // not implemented yet. + // CHECK: getelementptr + // CHECK-NEXT: %[[FUNC:.*]] = load + // CHECK-NEXT: call void %[[FUNC]] + static_cast(d)->f(); + } +} + +namespace Test6 { + struct A { + virtual ~A(); + }; + + struct B : public A { + virtual ~B(); + }; + + struct C { + virtual ~C(); + }; + + struct D final : public C, public B { + }; + + // CHECK: define void @_ZN5Test61fEPNS_1DE + void f(D* d) { + // CHECK: call void @_ZN5Test61DD1Ev + static_cast(d)->~A(); + } +} + +namespace Test7 { + struct foo { + virtual void g() {} + }; + + struct bar { + virtual int f() { return 0; } + }; + + struct zed final : public foo, public bar { + int z; + virtual int f() {return z;} + }; + + // CHECK: define i32 @_ZN5Test71fEPNS_3zedE + int f(zed *z) { + // CHECK: alloca + // CHECK-NEXT: store + // CHECK-NEXT: load + // CHECK-NEXT: bitcast + // CHECK-NEXT: call {{.*}} @_ZN5Test73zed1fEv + // CHECK-NEXT: ret + return static_cast(z)->f(); + } +} + +namespace Test8 { + struct A { virtual ~A() {} }; + struct B { + int b; + virtual int foo() { return b; } + }; + struct C final : A, B { }; + // CHECK: define i32 @_ZN5Test84testEPNS_1CE + int test(C *c) { + // CHECK: %[[THIS:.*]] = phi + // CHECK-NEXT: call i32 @_ZN5Test81B3fooEv(%"struct.Test8::B"* %[[THIS]]) + return static_cast(c)->foo(); + } +} + +namespace Test9 { + struct A { + int a; + }; + struct B { + int b; + }; + struct C : public B, public A { + }; + struct RA { + virtual A *f() { + return 0; + } + }; + struct RC final : public RA { + virtual C *f() { + C *x = new C(); + x->a = 1; + x->b = 2; + return x; + } + }; + // CHECK: define {{.*}} @_ZN5Test91fEPNS_2RCE + A *f(RC *x) { + // FIXME: It should be possible to devirtualize this case, but that is + // not implemented yet. + // CHECK: getelementptr + // CHECK-NEXT: %[[FUNC:.*]] = load + // CHECK-NEXT: bitcast + // CHECK-NEXT: = call {{.*}} %[[FUNC]] + return static_cast(x)->f(); + } +} diff --git a/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp b/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp index 5eede66cd7b4..c5a4094a53c3 100644 --- a/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp +++ b/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp @@ -53,3 +53,33 @@ void f() { B().h().f(); } +namespace test2 { + struct foo { + virtual void f(); + virtual ~foo(); + }; + + struct bar : public foo { + virtual void f(); + virtual ~bar(); + }; + + void f(bar *b) { + // CHECK: call void @_ZN5test23foo1fEv + // CHECK: call void @_ZN5test23fooD1Ev + b->foo::f(); + b->foo::~foo(); + } +} + +namespace test3 { + // Test that we don't crash in this case. + struct B { + }; + struct D : public B { + }; + void f(D d) { + // CHECK: define void @_ZN5test31fENS_1DE + d.B::~B(); + } +} diff --git a/test/CodeGenCXX/dynamic-cast-always-null.cpp b/test/CodeGenCXX/dynamic-cast-always-null.cpp index 2c3ea13d1957..836cb110da31 100644 --- a/test/CodeGenCXX/dynamic-cast-always-null.cpp +++ b/test/CodeGenCXX/dynamic-cast-always-null.cpp @@ -17,3 +17,8 @@ C &f(B& b) { // CHECK: ret %struct.C* undef return dynamic_cast(b); } + +void dont_crash() { + (void) dynamic_cast((A*)0); + (void) dynamic_cast((B*)0); +} diff --git a/test/CodeGenCXX/exceptions.cpp b/test/CodeGenCXX/exceptions.cpp index 079c1e5e725f..8c20c9e9ce21 100644 --- a/test/CodeGenCXX/exceptions.cpp +++ b/test/CodeGenCXX/exceptions.cpp @@ -414,3 +414,39 @@ namespace test9 { // CHECK: [[TEST9_NEW:%.*]] = call noalias i8* @_Znam // CHECK: call void @_ZdaPv(i8* [[TEST9_NEW]]) } + +// In a destructor with a function-try-block, a return statement in a +// catch handler behaves differently from running off the end of the +// catch handler. PR13102. +namespace test10 { + extern void cleanup(); + extern bool suppress; + + struct A { ~A(); }; + A::~A() try { cleanup(); } catch (...) { return; } + // CHECK: define void @_ZN6test101AD1Ev( + // CHECK: invoke void @_ZN6test107cleanupEv() + // CHECK-NOT: rethrow + // CHECK: ret void + + struct B { ~B(); }; + B::~B() try { cleanup(); } catch (...) {} + // CHECK: define void @_ZN6test101BD1Ev( + // CHECK: invoke void @_ZN6test107cleanupEv() + // CHECK: call i8* @__cxa_begin_catch + // CHECK-NEXT: invoke void @__cxa_rethrow() + // CHECK: unreachable + + struct C { ~C(); }; + C::~C() try { cleanup(); } catch (...) { if (suppress) return; } + // CHECK: define void @_ZN6test101CD1Ev( + // CHECK: invoke void @_ZN6test107cleanupEv() + // CHECK: call i8* @__cxa_begin_catch + // CHECK-NEXT: load i8* @_ZN6test108suppressE, align 1 + // CHECK-NEXT: trunc + // CHECK-NEXT: br i1 + // CHECK: call void @__cxa_end_catch() + // CHECK-NEXT: br label + // CHECK: invoke void @__cxa_rethrow() + // CHECK: unreachable +} diff --git a/test/CodeGenCXX/global-array-destruction.cpp b/test/CodeGenCXX/global-array-destruction.cpp index 5b5dfac0f228..076ef942201d 100644 --- a/test/CodeGenCXX/global-array-destruction.cpp +++ b/test/CodeGenCXX/global-array-destruction.cpp @@ -1,6 +1,4 @@ -// REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | FileCheck %s extern "C" int printf(...); @@ -24,11 +22,24 @@ static S sarr1[4]; S s2; S arr3[3]; -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit + +struct T { + double d; + int n; + ~T(); +}; +T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; + +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @t to %struct.T*), i64 6 +// CHECK: call void @_ZN1TD1Ev +// CHECK: icmp eq {{.*}} @t +// CHECK: br i1 {{.*}} diff --git a/test/CodeGenCXX/global-block-literal-helpers.cpp b/test/CodeGenCXX/global-block-literal-helpers.cpp new file mode 100644 index 000000000000..350ea548662c --- /dev/null +++ b/test/CodeGenCXX/global-block-literal-helpers.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 %s | FileCheck %s +// rdar://11343499 + +namespace N { + typedef void (^BL)(); + int func(BL, BL, BL); + +// CHECK: define internal void @_ZN1N8ArrBlockE_block_invoke( +// CHECK: define internal void @_ZN1N8ArrBlockE_block_invoke_2( +// CHECK: define internal void @_ZN1N8ArrBlockE_block_invoke_3 + BL ArrBlock [] = { ^{}, ^{}, ^{} }; + +// CHECK: define internal void @_ZN1N4ivalE_block_invoke_4( +// CHECK: define internal void @_ZN1N4ivalE_block_invoke_5( +// CHECK: define internal void @_ZN1N4ivalE_block_invoke_6( + int ival = func(^{}, ^{}, ^{}); + +// CHECK: define internal void @_ZN1N9gvarlobalE_block_invoke_7( + void (^gvarlobal)(void) = ^{}; + + struct S { + BL field = ^{}; + }; + +// CHECK: define internal void @_ZN1N3blfE_block_invoke_8( + S blf; +}; diff --git a/test/CodeGenCXX/global-init.cpp b/test/CodeGenCXX/global-init.cpp index 8e6ef775cad9..2a53ad9e3e77 100644 --- a/test/CodeGenCXX/global-init.cpp +++ b/test/CodeGenCXX/global-init.cpp @@ -70,17 +70,17 @@ namespace test3 { const char *test() { return var; } } -namespace test6 { +namespace test4 { struct A { A(); }; extern int foo(); // This needs an initialization function and guard variables. - // CHECK: load i8* bitcast (i64* @_ZGVN5test61xE - // CHECK: [[CALL:%.*]] = call i32 @_ZN5test63fooEv - // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test61xE - // CHECK-NEXT: store i64 1, i64* @_ZGVN5test61xE + // CHECK: load i8* bitcast (i64* @_ZGVN5test41xE + // CHECK: [[CALL:%.*]] = call i32 @_ZN5test43fooEv + // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE + // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE __attribute__((weak)) int x = foo(); } @@ -95,14 +95,6 @@ namespace PR5974 { A* a = &c; B* b = &c; } -// CHECK: define internal void [[TEST1_Z_INIT:@.*]]() -// CHECK: load i32* @_ZN5test1L1yE -// CHECK-NEXT: xor -// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1zE -// CHECK: define internal void [[TEST1_Y_INIT:@.*]]() -// CHECK: load i32* @_ZN5test1L1xE -// CHECK-NEXT: sub -// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1yE // PR9570: the indirect field shouldn't crash IR gen. namespace test5 { @@ -111,9 +103,98 @@ namespace test5 { }; } +namespace std { struct type_info; } + +namespace test6 { + struct A { virtual ~A(); }; + struct B : A {}; + extern A *p; + + // We must emit a dynamic initializer for 'q', because it could throw. + B *const q = &dynamic_cast(*p); + // CHECK: call void @__cxa_bad_cast() + // CHECK: store {{.*}} @_ZN5test6L1qE + + // We don't need to emit 'r' at all, because it has internal linkage, is + // unused, and its initialization has no side-effects. + B *const r = dynamic_cast(p); + // CHECK-NOT: call void @__cxa_bad_cast() + // CHECK-NOT: store {{.*}} @_ZN5test6L1rE + + // This can throw, so we need to emit it. + const std::type_info *const s = &typeid(*p); + // CHECK: store {{.*}} @_ZN5test6L1sE + + // This can't throw, so we don't. + const std::type_info *const t = &typeid(p); + // CHECK-NOT: @_ZN5test6L1tE + + extern B *volatile v; + // CHECK: store {{.*}} @_ZN5test6L1wE + B *const w = dynamic_cast(v); + + // CHECK: load volatile + // CHECK: store {{.*}} @_ZN5test6L1xE + const int x = *(volatile int*)0x1234; + + namespace { + int a = int(); + volatile int b = int(); + int c = a; + int d = b; + // CHECK-NOT: store {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1aE + // CHECK-NOT: store {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1bE + // CHECK-NOT: store {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1cE + // CHECK: load volatile {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1bE + // CHECK: store {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1dE + } +} + +namespace test7 { + struct A { A(); }; + struct B { ~B(); int n; }; + struct C { C() = default; C(const C&); int n; }; + struct D {}; + + // CHECK: call void @_ZN5test71AC1Ev({{.*}}@_ZN5test7L1aE) + const A a = A(); + + // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN5test71BD1Ev{{.*}} @_ZN5test7L2b1E + // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN5test71BD1Ev{{.*}} @_ZGRN5test72b2E + // CHECK: call void @_ZN5test71BD1Ev( + // CHECK: store {{.*}} @_ZN5test7L2b3E + const B b1 = B(); + const B &b2 = B(); + const int b3 = B().n; + + // CHECK-NOT: @_ZN5test7L2c1E + // CHECK: @_ZN5test7L2c2E + // CHECK-NOT: @_ZN5test7L2c3E + // CHECK: @_ZN5test7L2c4E + const C c1 = C(); + const C c2 = static_cast(C()); + const int c3 = C().n; + const int c4 = C(C()).n; + + // CHECK-NOT: @_ZN5test7L1dE + const D d = D(); + + // CHECK: store {{.*}} @_ZN5test71eE + int f(), e = f(); +} + // At the end of the file, we check that y is initialized before z. +// CHECK: define internal void [[TEST1_Z_INIT:@.*]]() +// CHECK: load i32* @_ZN5test1L1yE +// CHECK-NEXT: xor +// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1zE +// CHECK: define internal void [[TEST1_Y_INIT:@.*]]() +// CHECK: load i32* @_ZN5test1L1xE +// CHECK-NEXT: sub +// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1yE + // CHECK: define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" { // CHECK: call void [[TEST1_Y_INIT]] // CHECK: call void [[TEST1_Z_INIT]] diff --git a/test/CodeGenCXX/inline-functions.cpp b/test/CodeGenCXX/inline-functions.cpp index 69dfe0db98f0..8c011de28a02 100644 --- a/test/CodeGenCXX/inline-functions.cpp +++ b/test/CodeGenCXX/inline-functions.cpp @@ -53,3 +53,17 @@ namespace test1 { c.func(); } } + +// PR13252 +namespace test2 { + struct A; + void f(const A& a); + struct A { + friend void f(const A& a) { } + }; + void g() { + A a; + f(a); + } + // CHECK: define linkonce_odr void @_ZN5test21fERKNS_1AE +} diff --git a/test/CodeGenCXX/lambda-expressions.cpp b/test/CodeGenCXX/lambda-expressions.cpp index 797cbf43a787..e872cc494bc6 100644 --- a/test/CodeGenCXX/lambda-expressions.cpp +++ b/test/CodeGenCXX/lambda-expressions.cpp @@ -1,7 +1,11 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s -// CHECK: @var = internal global -auto var = [](int i) { return i+1; }; +// CHECK-NOT: @unused +auto unused = [](int i) { return i+1; }; + +// CHECK: @used = internal global +auto used = [](int i) { return i+1; }; +void *use = &used; // CHECK: @cvar = global extern "C" auto cvar = []{}; diff --git a/test/CodeGenCXX/mangle-lambdas.cpp b/test/CodeGenCXX/mangle-lambdas.cpp index cc53b0105750..16ddf4838ea7 100644 --- a/test/CodeGenCXX/mangle-lambdas.cpp +++ b/test/CodeGenCXX/mangle-lambdas.cpp @@ -1,5 +1,10 @@ // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s +// CHECK: @_ZZNK7PR12917IJiiEE1nMUlvE_clEvE1n = linkonce_odr global i32 0 +// CHECK: @_ZZN7PR12917IJicdEEC1EicdEd_N1nE = linkonce_odr global i32 0 +// CHECK: @_ZZN7PR12917IJicdEEC1EicdEd0_N1nE = linkonce_odr global i32 0 +// CHECK: @_ZZN7PR12917IJicdEEC1EicdEd1_N1nE = linkonce_odr global i32 0 + // CHECK: define linkonce_odr void @_Z11inline_funci inline void inline_func(int n) { // CHECK: call i32 @_ZZ11inline_funciENKUlvE_clEv @@ -78,10 +83,10 @@ struct ST { // CHECK: define void @_Z7test_ST2STIdE void test_ST(ST st) { - // CHECK: call double @_ZZN2ST1fET_S0_Ed0_NKUlvE_clEv - // CHECK-NEXT: call double @_ZZN2ST1fET_S0_Ed0_NKUlvE0_clEv + // CHECK: call double @_ZZN2STIdE1fEddEd0_NKUlvE_clEv + // CHECK-NEXT: call double @_ZZN2STIdE1fEddEd0_NKUlvE0_clEv // CHECK-NEXT: fadd double - // CHECK-NEXT: call double @_ZZN2ST1fET_S0_Ed_NKUlvE_clEv + // CHECK-NEXT: call double @_ZZN2STIdE1fEddEd_NKUlvE_clEv // CHECK-NEXT: call void @_ZN2STIdE1fEdd st.f(); @@ -89,11 +94,11 @@ void test_ST(ST st) { } // Check the linkage of the lambda call operators used in test_ST. -// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed0_NKUlvE_clEv +// CHECK: define linkonce_odr double @_ZZN2STIdE1fEddEd0_NKUlvE_clEv // CHECK: ret double 1 -// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed0_NKUlvE0_clEv +// CHECK: define linkonce_odr double @_ZZN2STIdE1fEddEd0_NKUlvE0_clEv // CHECK: ret double 2 -// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed_NKUlvE_clEv +// CHECK: define linkonce_odr double @_ZZN2STIdE1fEddEd_NKUlvE_clEv // CHECK: ret double 3 template @@ -150,6 +155,24 @@ void use_func_template() { func_template(); } + +template struct PR12917 { + PR12917(T ...t = []{ static int n = 0; return ++n; }()); + + static int n[3]; +}; +template int PR12917::n[3] = { + []{ static int n = 0; return ++n; }() +}; + +// CHECK: call i32 @_ZZN7PR12917IJicdEEC1EicdEd1_NKUlvE_clEv( +// CHECK: call i32 @_ZZN7PR12917IJicdEEC1EicdEd0_NKUlvE_clEv( +// CHECK: call i32 @_ZZN7PR12917IJicdEEC1EicdEd_NKUlvE_clEv( +// CHECK: call void @_ZN7PR12917IJicdEEC1Eicd( +PR12917 pr12917; +int *pr12917_p = PR12917::n; + + // CHECK: define linkonce_odr void @_Z1fIZZNK23TestNestedInstantiationclEvENKUlvE_clEvEUlvE_EvT_ struct Members { diff --git a/test/CodeGenCXX/mangle-ms-abi-examples.cpp b/test/CodeGenCXX/mangle-ms-abi-examples.cpp new file mode 100644 index 000000000000..d6726cab0d58 --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-abi-examples.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -fms-extensions -fno-rtti -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +// CHECK: @"\01??_7D@C@?1??foo@@YAXXZ@6B@" = +// CHECK: @"\01??_7B@?1??foo@A@@QAEXH@Z@6B@" = +// CHECK: define {{.*}} @"\01?baz@E@?3??bar@C@?1??foo@@YAXXZ@QAEXXZ@QAEXXZ"( + +// Microsoft Visual C++ ABI examples. +struct A { + void foo (int) { + struct B { virtual ~B() {} }; + B(); + } +}; +void foo () { + struct C { + struct D { virtual ~D() {} }; + void bar () { + struct E { + void baz() { } + }; + E().baz(); + } + }; + A().foo(0); + C::D(); + C().bar(); +} + diff --git a/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp b/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp new file mode 100644 index 000000000000..27b47689771d --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp @@ -0,0 +1,165 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +// FIXME: add tests for return types with complex templates when PR13389 is fixed. + +template +class A {}; +template +class B {}; +template +class C {}; + +void foo_abbb(A, B, B >) {} +// CHECK: "\01?foo_abbb@@YAXV?$A@V?$B@D@@V1@V1@@@@Z" +void foo_abb(A, B >) {} +// CHECK: "\01?foo_abb@@YAXV?$A@DV?$B@D@@V1@@@@Z" +void foo_abc(A, C >) {} +// CHECK: "\01?foo_abc@@YAXV?$A@DV?$B@D@@V?$C@D@@@@@Z" + +namespace N { +template +class A {}; +template +class B {}; +template +class C {}; +template +class D {}; +class Z {}; +} + +void foo_abbb(N::A, N::B, N::B >) {} +// CHECK: "\01?foo_abbb@@YAXV?$A@V?$B@D@N@@V12@V12@@N@@@Z" +void foo_abb(N::A, N::B >) {} +// CHECK: "\01?foo_abb@@YAXV?$A@DV?$B@D@N@@V12@@N@@@Z" +void foo_abc(N::A, N::C >) {} +// CHECK: "\01?foo_abc@@YAXV?$A@DV?$B@D@N@@V?$C@D@2@@N@@@Z" + +N::A, N::C > abc_foo() { +// CHECK: ?abc_foo@@YA?AV?$A@DV?$B@D@N@@V?$C@D@2@@N@@XZ + return N::A, N::C >(); +} + +N::Z z_foo(N::Z arg) { +// CHECK: ?z_foo@@YA?AVZ@N@@V12@@Z + return arg; +} + +N::B b_foo(N::B arg) { +// CHECK: ?b_foo@@YA?AV?$B@D@N@@V12@@Z + return arg; +} + +N::D d_foo(N::D arg) { +// CHECK: ?d_foo@@YA?AV?$D@DD@N@@V12@@Z + return arg; +} + +N::A, N::C > abc_foo_abc(N::A, N::C >) { +// CHECK: ?abc_foo_abc@@YA?AV?$A@DV?$B@D@N@@V?$C@D@2@@N@@V12@@Z + return N::A, N::C >(); +} + +namespace NA { +class X {}; +template class Y {}; +} + +namespace NB { +class X {}; +template class Y {}; +} + +void foo5(NA::Y > > > arg) {} +// CHECK: "\01?foo5@@YAXV?$Y@V?$Y@V?$Y@V?$Y@VX@NA@@@NB@@@NA@@@NB@@@NA@@@Z" + +void foo11(NA::Y, NB::Y) {} +// CHECK: "\01?foo11@@YAXV?$Y@VX@NA@@@NA@@V1NB@@@Z" + +void foo112(NA::Y, NB::Y) {} +// CHECK: "\01?foo112@@YAXV?$Y@VX@NA@@@NA@@V?$Y@VX@NB@@@NB@@@Z" + +void foo22(NA::Y >, NB::Y >) {} +// CHECK: "\01?foo22@@YAXV?$Y@V?$Y@VX@NA@@@NB@@@NA@@V?$Y@V?$Y@VX@NA@@@NA@@@NB@@@Z" + +namespace PR13207 { +class A {}; +class B {}; +class C {}; + +template +class F {}; +template +class I {}; +template +class J {}; +template +class K {}; + +class L { + public: + void foo(I x) {} +}; +// CHECK: "\01?foo@L@PR13207@@QAEXV?$I@VA@PR13207@@@2@@Z" + +void call_l_foo(L* l) { l->foo(I()); } + +void foo(I x) {} +// CHECK: "\01?foo@PR13207@@YAXV?$I@VA@PR13207@@@1@@Z" +void foo2(I x, I y) { } +// CHECK "\01?foo2@PR13207@@YAXV?$I@VA@PR13207@@@1@0@Z" +void bar(J x) {} +// CHECK: "\01?bar@PR13207@@YAXV?$J@VA@PR13207@@VB@2@@1@@Z" +void spam(K x) {} +// CHECK: "\01?spam@PR13207@@YAXV?$K@VA@PR13207@@VB@2@VC@2@@1@@Z" + +void baz(K, I >) {} +// CHECK: "\01?baz@PR13207@@YAXV?$K@DV?$F@D@PR13207@@V?$I@D@2@@1@@Z" +void qux(K, I >) {} +// CHECK: "\01?qux@PR13207@@YAXV?$K@DV?$I@D@PR13207@@V12@@1@@Z" + +namespace NA { +class X {}; +template class Y {}; +void foo(Y x) {} +// CHECK: "\01?foo@NA@PR13207@@YAXV?$Y@VX@NA@PR13207@@@12@@Z" +void foofoo(Y > x) {} +// CHECK: "\01?foofoo@NA@PR13207@@YAXV?$Y@V?$Y@VX@NA@PR13207@@@NA@PR13207@@@12@@Z" +} + +namespace NB { +class X {}; +template class Y {}; +void foo(Y x) {} +// CHECK: "\01?foo@NB@PR13207@@YAXV?$Y@VX@NA@PR13207@@@12@@Z" + +void bar(NA::Y x) {} +// CHECK: "\01?bar@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@NA@2@@Z" + +void spam(NA::Y x) {} +// CHECK: "\01?spam@NB@PR13207@@YAXV?$Y@VX@NA@PR13207@@@NA@2@@Z" + +void foobar(NA::Y > a, Y >) {} +// CHECK: "\01?foobar@NB@PR13207@@YAXV?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V312@@Z" + +void foobarspam(Y a, NA::Y > b, Y >) {} +// CHECK: "\01?foobarspam@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@@Z" + +void foobarbaz(Y a, NA::Y > b, Y >, Y > c) {} +// CHECK: "\01?foobarbaz@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@2@Z" + +void foobarbazqux(Y a, NA::Y > b, Y >, Y > c , NA::Y > > d) {} +// CHECK: "\01?foobarbazqux@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@2V?$Y@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NB@PR13207@@@52@@Z" +} + +namespace NC { +class X {}; +template class Y {}; + +void foo(Y x) {} +// CHECK: "\01?foo@NC@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@@Z" + +void foobar(NC::Y > > x) {} +// CHECK: "\01?foobar@NC@PR13207@@YAXV?$Y@V?$Y@V?$Y@VX@NA@PR13207@@@NA@PR13207@@@NB@PR13207@@@12@@Z" +} +} diff --git a/test/CodeGenCXX/mangle-ms-back-references.cpp b/test/CodeGenCXX/mangle-ms-back-references.cpp new file mode 100644 index 000000000000..5f93590cf2a2 --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-back-references.cpp @@ -0,0 +1,63 @@ +// RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +void f1(const char* a, const char* b) {} +// CHECK: "\01?f1@@YAXPBD0@Z" + +void f2(const char* a, char* b) {} +// CHECK: "\01?f2@@YAXPBDPAD@Z" + +void f3(int a, const char* b, const char* c) {} +// CHECK: "\01?f3@@YAXHPBD0@Z" + +const char *f4(const char* a, const char* b) { return 0; } +// CHECK: "\01?f4@@YAPBDPBD0@Z" + +void f5(char const* a, unsigned int b, char c, void const* d, char const* e, unsigned int f) {} +// CHECK: "\01?f5@@YAXPBDIDPBX0I@Z" + +void f6(bool a, bool b) {} +// CHECK: "\01?f6@@YAX_N0@Z" + +void f7(int a, int* b, int c, int* d, bool e, bool f, bool* g) {} +// CHECK: "\01?f7@@YAXHPAHH0_N1PA_N@Z" + +// FIXME: tests for more than 10 types? + +struct S { + void mbb(bool a, bool b) {} +}; + +void g1(struct S a) {} +// CHECK: "\01?g1@@YAXUS@@@Z" + +void g2(struct S a, struct S b) {} +// CHECK: "\01?g2@@YAXUS@@0@Z" + +void g3(struct S a, struct S b, struct S* c, struct S* d) {} +// CHECK: "\01?g3@@YAXUS@@0PAU1@1@Z" + +void g4(const char* a, struct S* b, const char* c, struct S* d) { +// CHECK: "\01?g4@@YAXPBDPAUS@@01@Z" + b->mbb(false, false); +// CHECK: "\01?mbb@S@@QAEX_N0@Z" +} + +// Make sure that different aliases of built-in types end up mangled as the +// built-ins. +typedef unsigned int uintptr_t; +typedef unsigned int size_t; +void *h(size_t a, uintptr_t b) { return 0; } +// CHECK: "\01?h@@YAPAXII@Z" + +// Function pointers might be mangled in a complex way. +typedef void (*VoidFunc)(); +typedef int* (*PInt3Func)(int* a, int* b); + +void h1(const char* a, const char* b, VoidFunc c, VoidFunc d) {} +// CHECK: "\01?h1@@YAXPBD0P6AXXZ1@Z" + +void h2(void (*f_ptr)(void *), void *arg) {} +// CHECK: "\01?h2@@YAXP6AXPAX@Z0@Z" + +PInt3Func h3(PInt3Func x, PInt3Func y, int* z) { return 0; } +// CHECK: "\01?h3@@YAP6APAHPAH0@ZP6APAH00@Z10@Z" diff --git a/test/CodeGenCXX/mangle-ms-cxx11.cpp b/test/CodeGenCXX/mangle-ms-cxx11.cpp new file mode 100644 index 000000000000..6947a53c4d1e --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-cxx11.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +// CHECK: "\01?LRef@@YAXAAH@Z" +void LRef(int& a) { } + +// CHECK: "\01?RRef@@YAH$$QAH@Z" +int RRef(int&& a) { return a; } + +// CHECK: "\01?Null@@YAX$$T@Z" +namespace std { typedef decltype(__nullptr) nullptr_t; } +void Null(std::nullptr_t) {} diff --git a/test/CodeGenCXX/mangle-ms-return-qualifiers.cpp b/test/CodeGenCXX/mangle-ms-return-qualifiers.cpp new file mode 100644 index 000000000000..a5d03b343526 --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-return-qualifiers.cpp @@ -0,0 +1,173 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +void a1() {} +// CHECK: "\01?a1@@YAXXZ" + +int a2() { return 0; } +// CHECK: "\01?a2@@YAHXZ" + +const int a3() { return 0; } +// CHECK: "\01?a3@@YA?BHXZ" + +volatile int a4() { return 0; } +// CHECK: "\01?a4@@YA?CHXZ" + +const volatile int a5() { return 0; } +// CHECK: "\01?a5@@YA?DHXZ" + +float a6() { return 0.0f; } +// CHECK: "\01?a6@@YAMXZ" + +int *b1() { return 0; } +// CHECK: "\01?b1@@YAPAHXZ" + +const char *b2() { return 0; } +// CHECK: "\01?b2@@YAPBDXZ" + +float *b3() { return 0; } +// CHECK: "\01?b3@@YAPAMXZ" + +const float *b4() { return 0; } +// CHECK: "\01?b4@@YAPBMXZ" + +volatile float *b5() { return 0; } +// CHECK: "\01?b5@@YAPCMXZ" + +const volatile float *b6() { return 0; } +// CHECK: "\01?b6@@YAPDMXZ" + +float &b7() { return *(float*)0; } +// CHECK: "\01?b7@@YAAAMXZ" + +const float &b8() { return *(float*)0; } +// CHECK: "\01?b8@@YAABMXZ" + +volatile float &b9() { return *(float*)0; } +// CHECK: "\01?b9@@YAACMXZ" + +const volatile float &b10() { return *(float*)0; } +// CHECK: "\01?b10@@YAADMXZ" + +const char** b11() { return 0; } +// CHECK: "\01?b11@@YAPAPBDXZ" + +class A {}; + +A c1() { return A(); } +// CHECK: "\01?c1@@YA?AVA@@XZ" + +const A c2() { return A(); } +// CHECK: "\01?c2@@YA?BVA@@XZ" + +volatile A c3() { return A(); } +// CHECK: "\01?c3@@YA?CVA@@XZ" + +const volatile A c4() { return A(); } +// CHECK: "\01?c4@@YA?DVA@@XZ" + +const A* c5() { return 0; } +// CHECK: "\01?c5@@YAPBVA@@XZ" + +volatile A* c6() { return 0; } +// CHECK: "\01?c6@@YAPCVA@@XZ" + +const volatile A* c7() { return 0; } +// CHECK: "\01?c7@@YAPDVA@@XZ" + +A &c8() { return *(A*)0; } +// CHECK: "\01?c8@@YAAAVA@@XZ" + +const A &c9() { return *(A*)0; } +// CHECK: "\01?c9@@YAABVA@@XZ" + +volatile A &c10() { return *(A*)0; } +// CHECK: "\01?c10@@YAACVA@@XZ" + +const volatile A &c11() { return *(A*)0; } +// CHECK: "\01?c11@@YAADVA@@XZ" + +template class B {}; + +B d1() { return B(); } +// CHECK: "\01?d1@@YA?AV?$B@H@@XZ" + +B d2() {return B(); } +// CHECK: "\01?d2@@YA?AV?$B@PBD@@XZ" + +B d3() {return B(); } +// CHECK: "\01?d3@@YA?AV?$B@VA@@@@XZ" + +B* d4() { return 0; } +// CHECK: "\01?d4@@YAPAV?$B@VA@@@@XZ" + +const B* d5() { return 0; } +// CHECK: "\01?d5@@YAPBV?$B@VA@@@@XZ" + +volatile B* d6() { return 0; } +// CHECK: "\01?d6@@YAPCV?$B@VA@@@@XZ" + +const volatile B* d7() { return 0; } +// CHECK: "\01?d7@@YAPDV?$B@VA@@@@XZ" + +B& d8() { return *(B*)0; } +// CHECK: "\01?d8@@YAAAV?$B@VA@@@@XZ" + +const B& d9() { return *(B*)0; } +// CHECK: "\01?d9@@YAABV?$B@VA@@@@XZ" + +volatile B& d10() { return *(B*)0; } +// CHECK: "\01?d10@@YAACV?$B@VA@@@@XZ" + +const volatile B& d11() { return *(B*)0; } +// CHECK: "\01?d11@@YAADV?$B@VA@@@@XZ" + +enum Enum { DEFAULT }; + +Enum e1() { return DEFAULT; } +// CHECK: "\01?e1@@YA?AW4Enum@@XZ" + +const Enum e2() { return DEFAULT; } +// CHECK: "\01?e2@@YA?BW4Enum@@XZ" + +Enum* e3() { return 0; } +// CHECK: "\01?e3@@YAPAW4Enum@@XZ" + +Enum& e4() { return *(Enum*)0; } +// CHECK: "\01?e4@@YAAAW4Enum@@XZ" + +struct S {}; + +struct S f1() { struct S s; return s; } +// CHECK: "\01?f1@@YA?AUS@@XZ" + +const struct S f2() { struct S s; return s; } +// CHECK: "\01?f2@@YA?BUS@@XZ" + +struct S* f3() { return 0; } +// CHECK: "\01?f3@@YAPAUS@@XZ" + +const struct S* f4() { return 0; } +// CHECK: "\01?f4@@YAPBUS@@XZ" + +const volatile struct S* f5() { return 0; } +// CHECK: "\01?f5@@YAPDUS@@XZ" + +struct S& f6() { return *(struct S*)0; } +// CHECK: "\01?f6@@YAAAUS@@XZ" + +typedef int (*function_pointer)(int); + +function_pointer g1() { return 0; } +// CHECK: "\01?g1@@YAP6AHH@ZXZ" + +const function_pointer g2() { return 0; } +// CHECK: "\01?g2@@YAQ6AHH@ZXZ" + +function_pointer* g3() { return 0; } +// CHECK: "\01?g3@@YAPAP6AHH@ZXZ" + +const function_pointer* g4() { return 0; } +// The mangling of g4 is currently "\01?g4@@YAPQ6AHH@ZXZ" which is wrong. +// This looks related to http://llvm.org/PR13444 +// FIXME: replace CHECK-NOT with CHECK once it is fixed. +// CHECK-NOT: "\01?g4@@YAPBQ6AHH@ZXZ" diff --git a/test/CodeGenCXX/mangle-ms-templates.cpp b/test/CodeGenCXX/mangle-ms-templates.cpp new file mode 100644 index 000000000000..977ef353dabc --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-templates.cpp @@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fms-extensions -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +template +class Class { + public: + void method() {} +}; + +class Typename { }; + +template +class Nested { }; + +template +class BoolTemplate { + public: + BoolTemplate() {} +}; + +template +class IntTemplate { + public: + IntTemplate() {} +}; + +template<> +class BoolTemplate { + public: + BoolTemplate() {} + template void Foo(T arg) {} +}; + +void template_mangling() { + Class c1; + c1.method(); +// CHECK: call {{.*}} @"\01?method@?$Class@VTypename@@@@QAEXXZ" + + Class > c2; + c2.method(); +// CHECK: call {{.*}} @"\01?method@?$Class@V?$Nested@VTypename@@@@@@QAEXXZ" + + BoolTemplate _false; +// CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ" + + BoolTemplate _true; + // PR13158 + _true.Foo(1); +// CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ" +// CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z" + + IntTemplate<5> five; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ" + + IntTemplate<11> eleven; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE@XZ" + + IntTemplate<65535> ffff; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ" +} + +namespace space { + template const T& foo(const T& l) { return l; } +} +// CHECK: "\01??$foo@H@space@@YAABHABH@Z" + +void use() { + space::foo(42); +} diff --git a/test/CodeGenCXX/mangle-ms.cpp b/test/CodeGenCXX/mangle-ms.cpp index fe5fde1a1b3b..f392c1701edd 100644 --- a/test/CodeGenCXX/mangle-ms.cpp +++ b/test/CodeGenCXX/mangle-ms.cpp @@ -12,6 +12,13 @@ // CHECK: @"\01?j@@3P6GHCE@ZA" // CHECK: @"\01?k@@3PTfoo@@DA" // CHECK: @"\01?l@@3P8foo@@AEHH@ZA" +// CHECK: @"\01?color1@@3PANA" + +// FIXME: The following three tests currently fail, see PR13182. +// Replace "CHECK-NOT" with "CHECK" when it is fixed. +// CHECK-NOT: @"\01?color2@@3QBNB" +// CHECK-NOT: @"\01?color3@@3QAY02$$CBNA" +// CHECK-NOT: @"\01?color4@@3QAY02$$CBNA" int a; @@ -39,8 +46,13 @@ public: foo(char *q){} //CHECK: @"\01??0foo@@QAE@PAD@Z" + + static foo* static_method() { return 0; } + }f,s1(1),s2((char*)0); +typedef foo (foo2); + struct bar { static int g; }; @@ -57,8 +69,17 @@ enum quux { qthree }; -int foo::operator+(int a) {return a;} -// CHECK: @"\01??Hfoo@@QAEHH@Z" +foo bar() { return foo(); } +//CHECK: @"\01?bar@@YA?AVfoo@@XZ" + +int foo::operator+(int a) { +//CHECK: @"\01??Hfoo@@QAEHH@Z" + + foo::static_method(); +//CHECK: @"\01?static_method@foo@@SAPAV1@XZ" + bar(); + return a; +} const short foo::d = 0; volatile long foo::e; @@ -72,9 +93,9 @@ int i[10][20]; int (__stdcall *j)(signed char, unsigned char); -const volatile char foo::*k; +const volatile char foo2::*k; -int (foo::*l)(int); +int (foo2::*l)(int); // Static functions are mangled, too. // Also make sure calling conventions, arglists, and throw specs work. @@ -99,7 +120,45 @@ void delta(int * const a, const long &) {} void epsilon(int a[][10][20]) {} // CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z" -// Blocks mangling (Clang extension). -void zeta(int (^)(int, int)) {} -// CHECK: @"\01?zeta@@YAXP_EAHHH@Z@Z" +void zeta(int (*)(int, int)) {} +// CHECK: @"\01?zeta@@YAXP6AHHH@Z@Z" + +// Blocks mangling (Clang extension). A block should be mangled slightly +// differently from a similar function pointer. +void eta(int (^)(int, int)) {} +// CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z" + +void operator_new_delete() { + char *ptr = new char; +// CHECK: @"\01??2@YAPAXI@Z" + + delete ptr; +// CHECK: @"\01??3@YAXPAX@Z" + + char *array = new char[42]; +// CHECK: @"\01??_U@YAPAXI@Z" + + delete [] array; +// CHECK: @"\01??_V@YAXPAX@Z" +} +// PR13022 +void (redundant_parens)(); +void redundant_parens_use() { redundant_parens(); } +// CHECK: @"\01?redundant_parens@@YAXXZ" + +// PR13182, PR13047 +typedef double RGB[3]; +RGB color1; +extern const RGB color2 = {}; +extern RGB const color3[5] = {}; +extern RGB const ((color4)[5]) = {}; + +// PR12603 +enum E {}; +// CHECK: "\01?fooE@@YA?AW4E@@XZ" +E fooE() { return E(); } + +class X {}; +// CHECK: "\01?fooX@@YA?AVX@@XZ" +X fooX() { return X(); } diff --git a/test/CodeGenCXX/mangle-ref-qualifiers.cpp b/test/CodeGenCXX/mangle-ref-qualifiers.cpp index 568cf9f24700..ce2af502e482 100644 --- a/test/CodeGenCXX/mangle-ref-qualifiers.cpp +++ b/test/CodeGenCXX/mangle-ref-qualifiers.cpp @@ -12,5 +12,11 @@ int X::g() && { return 0; } // CHECK: define i32 @_ZNKO1X1hEv int X::h() const && { return 0; } -// CHECK: define void @_Z1fM1XRFivEMS_OFivEMS_KOFivE +// CHECK: define void @_Z1fM1XFivREMS_FivOEMS_KFivOE void f(int (X::*)() &, int (X::*)() &&, int (X::*)() const&&) { } + +// CHECK: define void @_Z1g1AIFivEES_IFivREES_IFivOEES_IKFivEES_IKFivREES_IKFivOEES_IVKFivEES_IVKFivREES_IVKFivOEE() +template struct A {}; +void g(A, A, A, + A, A, A, + A, A, A) {} diff --git a/test/CodeGenCXX/member-data-pointers.cpp b/test/CodeGenCXX/member-data-pointers.cpp new file mode 100644 index 000000000000..d3473668a7f4 --- /dev/null +++ b/test/CodeGenCXX/member-data-pointers.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix GLOBAL-LP64 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s + +struct A; +typedef int A::*param_t; +struct { + const char *name; + param_t par; +} *ptr; +void test_ptr() { (void) ptr; } // forced use + +// GLOBAL-LP64: type { i8*, i64 } +// GLOBAL-LP32: type { i8*, i32 } diff --git a/test/CodeGenCXX/member-function-pointers.cpp b/test/CodeGenCXX/member-function-pointers.cpp index 2417aa41918b..84b54b67d315 100644 --- a/test/CodeGenCXX/member-function-pointers.cpp +++ b/test/CodeGenCXX/member-function-pointers.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin9 | FileCheck %s -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-apple-darwin9 | FileCheck -check-prefix LP32 %s -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix ARM %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix CODE-LP64 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-unknown-unknown | FileCheck -check-prefix CODE-LP32 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix GLOBAL-LP64 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-ARM %s struct A { int a; void f(); virtual void vf1(); virtual void vf2(); }; struct B { int b; virtual void g(); }; @@ -11,66 +13,56 @@ void (A::*volatile vpa)(); void (B::*pb)(); void (C::*pc)(); -// CHECK: @pa2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }, align 8 +// GLOBAL-LP64: @pa2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }, align 8 void (A::*pa2)() = &A::f; -// CHECK: @pa3 = global { i64, i64 } { i64 1, i64 0 }, align 8 -// CHECK-LP32: @pa3 = global { i32, i32 } { i32 1, i32 0 }, align 4 +// GLOBAL-LP64: @pa3 = global { i64, i64 } { i64 1, i64 0 }, align 8 +// GLOBAL-LP32: @pa3 = global { i32, i32 } { i32 1, i32 0 }, align 4 void (A::*pa3)() = &A::vf1; -// CHECK: @pa4 = global { i64, i64 } { i64 9, i64 0 }, align 8 -// CHECK-LP32: @pa4 = global { i32, i32 } { i32 5, i32 0 }, align 4 +// GLOBAL-LP64: @pa4 = global { i64, i64 } { i64 9, i64 0 }, align 8 +// GLOBAL-LP32: @pa4 = global { i32, i32 } { i32 5, i32 0 }, align 4 void (A::*pa4)() = &A::vf2; -// CHECK: @pc2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 16 }, align 8 +// GLOBAL-LP64: @pc2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 16 }, align 8 void (C::*pc2)() = &C::f; -// CHECK: @pc3 = global { i64, i64 } { i64 1, i64 0 }, align 8 +// GLOBAL-LP64: @pc3 = global { i64, i64 } { i64 1, i64 0 }, align 8 void (A::*pc3)() = &A::vf1; -// Tests for test10. -// CHECK: @_ZN6test101aE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 0 }, align 8 -// CHECK: @_ZN6test101bE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8 -// CHECK: @_ZN6test101cE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8 -// CHECK: @_ZN6test101dE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 16 }, align 8 -// CHECK-LP32: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4 -// CHECK-LP32: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4 -// CHECK-LP32: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4 -// CHECK-LP32: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 - void f() { - // CHECK: store { i64, i64 } zeroinitializer, { i64, i64 }* @pa + // CODE-LP64: store { i64, i64 } zeroinitializer, { i64, i64 }* @pa pa = 0; // Is this okay? What are LLVM's volatile semantics for structs? - // CHECK: store volatile { i64, i64 } zeroinitializer, { i64, i64 }* @vpa + // CODE-LP64: store volatile { i64, i64 } zeroinitializer, { i64, i64 }* @vpa vpa = 0; - // CHECK: [[TMP:%.*]] = load { i64, i64 }* @pa, align 8 - // CHECK: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1 - // CHECK: [[ADJ:%.*]] = add nsw i64 [[TMPADJ]], 16 - // CHECK: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1 - // CHECK: store { i64, i64 } [[RES]], { i64, i64 }* @pc, align 8 + // CODE-LP64: [[TMP:%.*]] = load { i64, i64 }* @pa, align 8 + // CODE-LP64: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1 + // CODE-LP64: [[ADJ:%.*]] = add nsw i64 [[TMPADJ]], 16 + // CODE-LP64: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1 + // CODE-LP64: store { i64, i64 } [[RES]], { i64, i64 }* @pc, align 8 pc = pa; - // CHECK: [[TMP:%.*]] = load { i64, i64 }* @pc, align 8 - // CHECK: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1 - // CHECK: [[ADJ:%.*]] = sub nsw i64 [[TMPADJ]], 16 - // CHECK: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1 - // CHECK: store { i64, i64 } [[RES]], { i64, i64 }* @pa, align 8 + // CODE-LP64: [[TMP:%.*]] = load { i64, i64 }* @pc, align 8 + // CODE-LP64: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1 + // CODE-LP64: [[ADJ:%.*]] = sub nsw i64 [[TMPADJ]], 16 + // CODE-LP64: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1 + // CODE-LP64: store { i64, i64 } [[RES]], { i64, i64 }* @pa, align 8 pa = static_cast(pc); } void f2() { - // CHECK: store { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 } + // CODE-LP64: store { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 } void (A::*pa2)() = &A::f; - // CHECK: store { i64, i64 } { i64 1, i64 0 } - // CHECK-LP32: store { i32, i32 } { i32 1, i32 0 } + // CODE-LP64: store { i64, i64 } { i64 1, i64 0 } + // CODE-LP32: store { i32, i32 } { i32 1, i32 0 } void (A::*pa3)() = &A::vf1; - // CHECK: store { i64, i64 } { i64 9, i64 0 } - // CHECK-LP32: store { i32, i32 } { i32 5, i32 0 } + // CODE-LP64: store { i64, i64 } { i64 9, i64 0 } + // CODE-LP32: store { i32, i32 } { i32 5, i32 0 } void (A::*pa4)() = &A::vf2; } @@ -195,12 +187,12 @@ namespace test7 { struct B { void foo(); virtual void vfoo(); }; struct C : A, B { void foo(); virtual void vfoo(); }; - // CHECK-ARM: @_ZN5test74ptr0E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71A3fooEv to i32), i32 0 } - // CHECK-ARM: @_ZN5test74ptr1E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71B3fooEv to i32), i32 8 } - // CHECK-ARM: @_ZN5test74ptr2E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71C3fooEv to i32), i32 0 } - // CHECK-ARM: @_ZN5test74ptr3E = global {{.*}} { i32 0, i32 1 } - // CHECK-ARM: @_ZN5test74ptr4E = global {{.*}} { i32 0, i32 9 } - // CHECK-ARM: @_ZN5test74ptr5E = global {{.*}} { i32 0, i32 1 } + // GLOBAL-ARM: @_ZN5test74ptr0E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71A3fooEv to i32), i32 0 } + // GLOBAL-ARM: @_ZN5test74ptr1E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71B3fooEv to i32), i32 8 } + // GLOBAL-ARM: @_ZN5test74ptr2E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71C3fooEv to i32), i32 0 } + // GLOBAL-ARM: @_ZN5test74ptr3E = global {{.*}} { i32 0, i32 1 } + // GLOBAL-ARM: @_ZN5test74ptr4E = global {{.*}} { i32 0, i32 9 } + // GLOBAL-ARM: @_ZN5test74ptr5E = global {{.*}} { i32 0, i32 1 } void (C::*ptr0)() = &A::foo; void (C::*ptr1)() = &B::foo; void (C::*ptr2)() = &C::foo; @@ -234,9 +226,9 @@ namespace test9 { fooptr p; }; - // CHECK: define void @_ZN5test94testEv( - // CHECK: alloca i32 - // CHECK-NEXT: ret void + // CODE-LP64: define void @_ZN5test94testEv( + // CODE-LP64: alloca i32 + // CODE-LP64-NEXT: ret void void test() { int x; static S array[] = { (fooptr) &B::foo }; @@ -261,14 +253,37 @@ namespace test10 { virtual void requireNonZeroAdjustment(); }; - // Non-ARM tests at top of file. + +// It's not that the offsets are doubled on ARM, it's that they're left-shifted by 1. + +// GLOBAL-LP64: @_ZN6test101aE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 0 }, align 8 +// GLOBAL-LP32: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4 +// GLOBAL-ARM: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4 void (A::*a)() = &A::foo; + +// GLOBAL-LP64: @_ZN6test101bE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8 +// GLOBAL-LP32: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4 +// GLOBAL-ARM: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 void (B::*b)() = (void (B::*)()) &A::foo; + +// GLOBAL-LP64: @_ZN6test101cE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8 +// GLOBAL-LP32: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4 +// GLOBAL-ARM: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 void (C::*c)() = (void (C::*)()) (void (B::*)()) &A::foo; + +// GLOBAL-LP64: @_ZN6test101dE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 16 }, align 8 +// GLOBAL-LP32: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 +// GLOBAL-ARM: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 16 }, align 4 void (D::*d)() = (void (C::*)()) (void (B::*)()) &A::foo; } -// It's not that the offsets are doubled on ARM, it's that they're left-shifted by 1. -// CHECK-ARM: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4 -// CHECK-ARM: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 -// CHECK-ARM: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 -// CHECK-ARM: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 16 }, align 4 + +namespace test11 { + struct A { virtual void a(); }; + struct B : A {}; + struct C : B { virtual void a(); }; + void (C::*x)() = &C::a; + + // GLOBAL-LP64: @_ZN6test111xE = global { i64, i64 } { i64 1, i64 0 } + // GLOBAL-LP32: @_ZN6test111xE = global { i32, i32 } { i32 1, i32 0 } + // GLOBAL-ARM: @_ZN6test111xE = global { i32, i32 } { i32 0, i32 1 } +} diff --git a/test/CodeGenCXX/member-init-anon-union.cpp b/test/CodeGenCXX/member-init-anon-union.cpp index 1ff7537387c2..4db31f0b83fd 100644 --- a/test/CodeGenCXX/member-init-anon-union.cpp +++ b/test/CodeGenCXX/member-init-anon-union.cpp @@ -2,8 +2,10 @@ // PR10531. +int make_a(); + static union { - int a = 42; + int a = make_a(); char *b; }; @@ -32,4 +34,4 @@ int g() { // CHECK: define {{.*}}@"[[CONSTRUCT_GLOBAL]]C2Ev" // CHECK-NOT: } -// CHECK: store i32 42 +// CHECK: call {{.*}}@_Z6make_a diff --git a/test/CodeGenCXX/member-init-ctor.cpp b/test/CodeGenCXX/member-init-ctor.cpp deleted file mode 100644 index 21723942571f..000000000000 --- a/test/CodeGenCXX/member-init-ctor.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s - -bool b(); -struct S { - int n = b() ? S().n + 1 : 0; -}; - -S s; - -// CHECK: define {{.*}} @_ZN1SC2Ev( -// CHECK-NOT } -// CHECK: call {{.*}} @_Z1bv() -// CHECK-NOT } -// CHECK: call {{.*}} @_ZN1SC1Ev( diff --git a/test/CodeGenCXX/member-pointer-type-convert.cpp b/test/CodeGenCXX/member-pointer-type-convert.cpp deleted file mode 100644 index 2970a2e39e3f..000000000000 --- a/test/CodeGenCXX/member-pointer-type-convert.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s - -struct A; -typedef int A::*param_t; -struct { - const char *name; - param_t par; -} *ptr; -void test_ptr() { (void) ptr; } // forced use - -// CHECK: type { i8*, {{i..}} } diff --git a/test/CodeGenCXX/microsoft-abi-array-cookies.cpp b/test/CodeGenCXX/microsoft-abi-array-cookies.cpp new file mode 100644 index 000000000000..e07b09744730 --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-array-cookies.cpp @@ -0,0 +1,59 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +struct ClassWithoutDtor { + char x; +}; + +void check_array_no_cookies() { +// CHECK: define void @"\01?check_array_no_cookies@@YAXXZ"() nounwind + +// CHECK: call noalias i8* @"\01??_U@YAPAXI@Z"(i32 42) + ClassWithoutDtor *array = new ClassWithoutDtor[42]; + +// CHECK: call void @"\01??_V@YAXPAX@Z"( + delete [] array; + +} + +struct ClassWithDtor { + char x; + ~ClassWithDtor() {} +}; + +void check_array_cookies_simple() { +// CHECK: define {{.*}} @"\01?check_array_cookies_simple@@YAXXZ"() + + ClassWithDtor *array = new ClassWithDtor[42]; +// CHECK: [[ALLOCATED:%.*]] = call noalias i8* @"\01??_U@YAPAXI@Z"(i32 46) +// 46 = 42 + size of cookie (4) +// CHECK: [[COOKIE:%.*]] = bitcast i8* [[ALLOCATED]] to i32* +// CHECK: store i32 42, i32* [[COOKIE]] +// CHECK: [[ARRAY:%.*]] = getelementptr inbounds i8* [[ALLOCATED]], i64 4 +// CHECK: bitcast i8* [[ARRAY]] to [[CLASS:%.*]]* + + delete [] array; +// CHECK: [[ARRAY_AS_CHAR:%.*]] = bitcast [[CLASS]]* {{%.*}} to i8* +// CHECK: getelementptr inbounds i8* [[ARRAY_AS_CHAR]], i64 -4 +} + +struct __attribute__((aligned(8))) ClassWithAlignment { + // FIXME: replace __attribute__((aligned(8))) with __declspec(align(8)) once + // http://llvm.org/bugs/show_bug.cgi?id=12631 is fixed. + int *x, *y; + ~ClassWithAlignment() {} +}; + +void check_array_cookies_aligned() { +// CHECK: define {{.*}} @"\01?check_array_cookies_aligned@@YAXXZ"() + ClassWithAlignment *array = new ClassWithAlignment[42]; +// CHECK: [[ALLOCATED:%.*]] = call noalias i8* @"\01??_U@YAPAXI@Z"(i32 344) +// 344 = 42*8 + size of cookie (8, due to alignment) +// CHECK: [[COOKIE:%.*]] = bitcast i8* [[ALLOCATED]] to i32* +// CHECK: store i32 42, i32* [[COOKIE]] +// CHECK: [[ARRAY:%.*]] = getelementptr inbounds i8* [[ALLOCATED]], i64 8 +// CHECK: bitcast i8* [[ARRAY]] to [[CLASS:%.*]]* + + delete [] array; +// CHECK: [[ARRAY_AS_CHAR:%.*]] = bitcast [[CLASS]]* +// CHECK: getelementptr inbounds i8* [[ARRAY_AS_CHAR]], i64 -8 +} diff --git a/test/CodeGenCXX/microsoft-abi-constructors.cpp b/test/CodeGenCXX/microsoft-abi-constructors.cpp new file mode 100644 index 000000000000..ac27f13308d8 --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-constructors.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +class A { + public: + A() { } + ~A() { } +}; + +void no_contstructor_destructor_infinite_recursion() { + A a; + +// Make sure that the constructor doesn't call itself: +// CHECK: define {{.*}} @"\01??0A@@QAE@XZ" +// CHECK-NOT: call void @"\01??0A@@QAE@XZ" +// CHECK: ret + +// Make sure that the destructor doesn't call itself: +// CHECK: define {{.*}} @"\01??1A@@QAE@XZ" +// CHECK-NOT: call void @"\01??1A@@QAE@XZ" +// CHECK: ret +} diff --git a/test/CodeGenCXX/microsoft-abi-methods.cpp b/test/CodeGenCXX/microsoft-abi-methods.cpp new file mode 100644 index 000000000000..6b7f00495d2b --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-methods.cpp @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +class C { + public: + void simple_method() {} + + void __cdecl cdecl_method() {} + + void vararg_method(const char *fmt, ...) {} + + static void static_method() {} + + int a; +}; + +void call_simple_method() { + C instance; + + instance.simple_method(); +// Make sure that the call uses the right calling convention: +// CHECK: call x86_thiscallcc void @"\01?simple_method@C@@QAEXXZ" +// CHECK: ret + +// Make sure that the definition uses the right calling convention: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01?simple_method@C@@QAEXXZ" +// CHECK: ret +} + +void call_cdecl_method() { + C instance; + instance.cdecl_method(); +// Make sure that the call uses the right calling convention: +// CHECK: call void @"\01?cdecl_method@C@@QAAXXZ" +// CHECK: ret + +// Make sure that the definition uses the right calling convention: +// CHECK: define linkonce_odr void @"\01?cdecl_method@C@@QAAXXZ" +// CHECK: ret +} + +void call_vararg_method() { + C instance; + instance.vararg_method("Hello"); +// Make sure that the call uses the right calling convention: +// CHECK: call void (%class.C*, i8*, ...)* @"\01?vararg_method@C@@QAAXPBDZZ" +// CHECK: ret + +// Make sure that the definition uses the right calling convention: +// CHECK: define linkonce_odr void @"\01?vararg_method@C@@QAAXPBDZZ" +} + +void call_static_method() { + C::static_method(); +// Make sure that the call uses the right calling convention: +// CHECK: call void @"\01?static_method@C@@SAXXZ" +// CHECK: ret + +// Make sure that the definition uses the right calling convention: +// CHECK: define linkonce_odr void @"\01?static_method@C@@SAXXZ" +} + +class Base { + public: + Base() {} + ~Base() {} +}; + +class Child: public Base { }; + +void constructors() { + Child c; +// Make sure that the Base constructor call in the Child constructor uses +// the right calling convention: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??0Child@@QAE@XZ" +// CHECK: call x86_thiscallcc void @"\01??0Base@@QAE@XZ" +// CHECK: ret + +// Make sure that the Base destructor call in the Child denstructor uses +// the right calling convention: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??1Child@@QAE@XZ" +// CHECK: call x86_thiscallcc void @"\01??1Base@@QAE@XZ" +// CHECK: ret + +// Make sure that the Base destructor definition uses the right CC: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??1Base@@QAE@XZ" + +// Make sure that the Base constructor definition uses the right CC: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??0Base@@QAE@XZ" +} diff --git a/test/CodeGenCXX/microsoft-abi-static-initializers.cpp b/test/CodeGenCXX/microsoft-abi-static-initializers.cpp new file mode 100644 index 000000000000..d8b789943a43 --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-static-initializers.cpp @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +struct S { + S() {} + ~S() {} +} s; + +// CHECK: define internal void [[INIT_s:@.*global_var.*]] nounwind +// CHECK: call x86_thiscallcc void @"\01??0S@@QAE@XZ" +// CHECK: call i32 @atexit(void ()* @"__dtor_\01?s@@3US@@A") +// CHECK: ret void + +// CHECK: define internal void @"__dtor_\01?s@@3US@@A"() nounwind { +// CHECK: call x86_thiscallcc void @"\01??1S@@QAE@XZ" +// CHECK: ret void + +// Force WeakODRLinkage by using templates +class A { + public: + A() {} + ~A() {} +}; + +template +class B { + public: + static A foo; +}; + +template A B::foo; + +void force_usage() { + (void)B::foo; // (void) - force usage +} + +// CHECK: define internal void [[INIT_foo:@.*global_var.*]] nounwind +// CHECK: call x86_thiscallcc void @"\01??0A@@QAE@XZ" +// CHECK: call i32 @atexit(void ()* [[FOO_DTOR:@"__dtor_.*foo@.*]]) +// CHECK: ret void + +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??0A@@QAE@XZ" + +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??1A@@QAE@XZ" + +// CHECK: define internal void [[FOO_DTOR]] +// CHECK: call x86_thiscallcc void @"\01??1A@@QAE@XZ"{{.*}}foo +// CHECK: ret void + +// CHECK: define internal void @_GLOBAL__I_a() nounwind { +// CHECK: call void [[INIT_s]] +// CHECK: call void [[INIT_foo]] +// CHECK: ret void diff --git a/test/CodeGenCXX/ms_wide_predefined_expr.cpp b/test/CodeGenCXX/ms_wide_predefined_expr.cpp new file mode 100644 index 000000000000..5f0bcdee8c05 --- /dev/null +++ b/test/CodeGenCXX/ms_wide_predefined_expr.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -fms-extensions -triple i686-pc-win32 -emit-llvm -o - | FileCheck %s + +// CHECK: @L__FUNCTION__._Z4funcv = private constant [5 x i16] [i16 102, i16 117, i16 110, i16 99, i16 0], align 2 + +void wprint(const wchar_t*); + +#define __STR2WSTR(str) L##str +#define _STR2WSTR(str) __STR2WSTR(str) +#define STR2WSTR(str) _STR2WSTR(str) + +void func() { + wprint(STR2WSTR(__FUNCTION__)); +} + +int main() { + func(); + + return 0; +} + diff --git a/test/CodeGenCXX/pointers-to-data-members.cpp b/test/CodeGenCXX/pointers-to-data-members.cpp index 90024e4dfed7..fe69cd5ddf78 100644 --- a/test/CodeGenCXX/pointers-to-data-members.cpp +++ b/test/CodeGenCXX/pointers-to-data-members.cpp @@ -240,3 +240,17 @@ namespace PR11487 { // CHECK-GLOBAL: @_ZN7PR114871xE = global %"union.PR11487::U" { i64 -1, [8 x i8] zeroinitializer }, align 8 } + +namespace PR13097 { + struct X { int x; X(const X&); }; + struct A { + int qq; + X x; + }; + A f(); + X g() { return f().*&A::x; } + // CHECK: define void @_ZN7PR130971gEv + // CHECK: call void @_ZN7PR130971fEv + // CHECK-NOT: memcpy + // CHECK: call void @_ZN7PR130971XC1ERKS0_ +} diff --git a/test/CodeGenCXX/pr13396.cpp b/test/CodeGenCXX/pr13396.cpp new file mode 100644 index 000000000000..7d4e2ce74f04 --- /dev/null +++ b/test/CodeGenCXX/pr13396.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -triple i686-pc-linux-gnu %s -emit-llvm -o - | FileCheck %s +struct foo { + template + __attribute__ ((regparm (3))) foo(T x) {} + __attribute__ ((regparm (3))) foo(); + __attribute__ ((regparm (3))) ~foo(); +}; + +foo::foo() { + // CHECK: define void @_ZN3fooC1Ev(%struct.foo* inreg %this) + // CHECK: define void @_ZN3fooC2Ev(%struct.foo* inreg %this) +} + +foo::~foo() { + // CHECK: define void @_ZN3fooD1Ev(%struct.foo* inreg %this) + // CHECK: define void @_ZN3fooD2Ev(%struct.foo* inreg %this) +} + +void dummy() { + // FIXME: how can we explicitly instantiate a template constructor? Gcc and + // older clangs accept: + // template foo::foo(int x); + foo x(10); + // CHECK: define linkonce_odr void @_ZN3fooC1IiEET_(%struct.foo* inreg %this, i32 inreg %x) + // CHECK: define linkonce_odr void @_ZN3fooC2IiEET_(%struct.foo* inreg %this, i32 inreg %x) +} diff --git a/test/CodeGenCXX/pragma-visibility.cpp b/test/CodeGenCXX/pragma-visibility.cpp index e54626ee2e11..11a38c1d5fb9 100644 --- a/test/CodeGenCXX/pragma-visibility.cpp +++ b/test/CodeGenCXX/pragma-visibility.cpp @@ -16,14 +16,6 @@ int x2::y = 10; // CHECK: @_ZN2x21yE = global #pragma GCC visibility pop -#pragma GCC visibility push(hidden) -struct x3 { - static int y; -} __attribute((visibility("default"))); -int x3::y = 10; -// CHECK: @_ZN2x31yE = global -#pragma GCC visibility pop - #pragma GCC visibility push(hidden) template struct x4 { static int y; @@ -60,3 +52,23 @@ namespace n __attribute((visibility("default"))) { // CHECK: define hidden void @_ZN1n1gEv #pragma GCC visibility pop } + +namespace test2 { +#pragma GCC visibility push(default) +#pragma GCC visibility push(hidden) + struct foo { // foo is hidden + }; +#pragma GCC visibility pop + struct foo; // declaration is ok, we ignore the default in the stack + template + struct bar { // bar is default + static void f(){} + }; +#pragma GCC visibility pop + void zed() { + bar::f(); + bar::f(); + } + // CHECK: define linkonce_odr hidden void @_ZN5test23barINS_3fooEE1fEv + // CHECK: define linkonce_odr void @_ZN5test23barIiE1fEv +} diff --git a/test/CodeGenCXX/rvalue-references.cpp b/test/CodeGenCXX/rvalue-references.cpp index 1c25543beabc..b8d47dcfbe2f 100644 --- a/test/CodeGenCXX/rvalue-references.cpp +++ b/test/CodeGenCXX/rvalue-references.cpp @@ -10,7 +10,7 @@ B &getB(); // CHECK: define %struct.A* @_Z4getAv() // CHECK: call %struct.B* @_Z4getBv() // CHECK-NEXT: bitcast %struct.B* -// CHECK-NEXT: getelementptr i8* +// CHECK-NEXT: getelementptr inbounds i8* // CHECK-NEXT: bitcast i8* {{.*}} to %struct.A* // CHECK-NEXT: ret %struct.A* A &&getA() { return static_cast(getB()); } diff --git a/test/CodeGenCXX/template-instantiation.cpp b/test/CodeGenCXX/template-instantiation.cpp index 09b3a4fcc544..b90716ba1ae6 100644 --- a/test/CodeGenCXX/template-instantiation.cpp +++ b/test/CodeGenCXX/template-instantiation.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -O1 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -O1 -disable-llvm-optzns -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s // CHECK: @_ZN7PR100011xE = global // CHECK-NOT: @_ZN7PR100014kBarE = external global i32 @@ -13,7 +13,7 @@ // CHECK-NOT: _ZTVN5test31SIiEE // CHECK-NOT: _ZTSN5test31SIiEE -// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(%"class.test2::C"* nocapture %this) unnamed_addr +// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr // CHECK: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_( // CHECK: define available_externally void @_ZN5test21CIiE6zedbarEd( diff --git a/test/CodeGenCXX/throw-expression-cleanup.cpp b/test/CodeGenCXX/throw-expression-cleanup.cpp new file mode 100644 index 000000000000..0c41bc65bc3c --- /dev/null +++ b/test/CodeGenCXX/throw-expression-cleanup.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 %s -emit-llvm -fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s +// PR13359 + +struct X { + ~X(); +}; +struct Error { + Error(const X&) noexcept; +}; + +void f() { + try { + throw Error(X()); + } catch (...) { } +} + +// CHECK: define void @_Z1fv +// CHECK: call void @_ZN5ErrorC1ERK1X +// CHECK: invoke void @__cxa_throw +// CHECK: landingpad +// CHECK: call void @_ZN1XD1Ev +// CHECK-NOT: __cxa_free_exception diff --git a/test/CodeGenCXX/virt-call-offsets.cpp b/test/CodeGenCXX/virt-call-offsets.cpp deleted file mode 100644 index 5eef6fea9e6f..000000000000 --- a/test/CodeGenCXX/virt-call-offsets.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s - -struct A { virtual void a(); }; -struct B : A {}; -struct C : B { virtual void a(); }; -void (C::*x)() = &C::a; - -// CHECK: @x = global { i{{[0-9]+}}, i{{[0-9]+}} } { i{{[0-9]+}} 1, i{{[0-9]+}} 0 } diff --git a/test/CodeGenCXX/virt-template-vtable.cpp b/test/CodeGenCXX/virt-template-vtable.cpp index 25736fd60309..a6067d62c61d 100644 --- a/test/CodeGenCXX/virt-template-vtable.cpp +++ b/test/CodeGenCXX/virt-template-vtable.cpp @@ -20,3 +20,13 @@ template class A; // CHECK: @_ZTV1AIlE = weak_odr unnamed_addr constant // CHECK: @_ZTV1AIsE = weak_odr unnamed_addr constant // CHECK: @_ZTV1AIiE = linkonce_odr unnamed_addr constant + +template struct C { + virtual void c() {} +}; +struct D : C { + virtual void d(); +}; +void D::d() {} + +// CHECK: define {{.*}}@_ZN1CIiE1cEv( diff --git a/test/CodeGenCXX/virtual-destructor-calls.cpp b/test/CodeGenCXX/virtual-destructor-calls.cpp index 1cc8bcc7753e..7ef50b23fa7c 100644 --- a/test/CodeGenCXX/virtual-destructor-calls.cpp +++ b/test/CodeGenCXX/virtual-destructor-calls.cpp @@ -46,3 +46,14 @@ C::~C() { } // CHECK: call void @_ZdlPv // Base dtor: just an alias to B's base dtor. + +namespace PR12798 { + // A qualified call to a base class destructor should not undergo virtual + // dispatch. Template instantiation used to lose the qualifier. + struct A { virtual ~A(); }; + template void f(T *p) { p->A::~A(); } + + // CHECK: define {{.*}} @_ZN7PR127981fINS_1AEEEvPT_( + // CHECK: call void @_ZN7PR127981AD1Ev( + template void f(A*); +} diff --git a/test/CodeGenCXX/visibility-inlines-hidden.cpp b/test/CodeGenCXX/visibility-inlines-hidden.cpp index d660b1b41051..2bb13485e922 100644 --- a/test/CodeGenCXX/visibility-inlines-hidden.cpp +++ b/test/CodeGenCXX/visibility-inlines-hidden.cpp @@ -108,3 +108,21 @@ namespace PR11642 { template class Foo; // CHECK: define weak_odr i32 @_ZN7PR116423FooIiE3fooEi } + +// Test that clang implements the new gcc behaviour for inline functions. +// GCC PR30066. +namespace test3 { + inline void foo(void) { + } + template + inline void zed() { + } + template void zed(); + void bar(void) { + foo(); + zed(); + } + // CHECK: define weak_odr void @_ZN5test33zedIfEEvv + // CHECK: define linkonce_odr hidden void @_ZN5test33fooEv + // CHECK: define linkonce_odr hidden void @_ZN5test33zedIiEEvv +} diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp index 59fd7c26f0d5..014503911a49 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -1,10 +1,24 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN +// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN #define HIDDEN __attribute__((visibility("hidden"))) #define PROTECTED __attribute__((visibility("protected"))) #define DEFAULT __attribute__((visibility("default"))) +namespace test30 { + // When H is hidden, it should make X hidden, even if the template argument + // is not. + struct H { + }; + template + struct X { + }; + H DEFAULT a; + X<&a> b; + // CHECK: _ZN6test301bE = global + // CHECK-HIDDEN: _ZN6test301bE = hidden global +} + namespace test25 { template struct X { @@ -28,6 +42,62 @@ namespace test28 { // CHECK-HIDDEN: @_ZN6test285myvecE = hidden global } +namespace test29 { +#pragma GCC visibility push(hidden) + struct RECT { + int top; + }; + __attribute__ ((visibility ("default"))) extern RECT data_rect; + RECT data_rect = { -1}; +#pragma GCC visibility pop + // CHECK: @_ZN6test299data_rectE = global + // CHECK-HIDDEN: @_ZN6test299data_rectE = global +} + +namespace test40 { + template + struct foo { + DEFAULT static int bar; + }; + template + int foo::bar; + template struct foo; + // CHECK: _ZN6test403fooIiE3barE = weak_odr global + // CHECK-HIDDEN: _ZN6test403fooIiE3barE = weak_odr global +} + +namespace test41 { + // Unlike gcc we propagate the information that foo not only is hidden, but + // has been explicitly marked as so. This lets us produce a hidden undefined + // reference to bar. + struct __attribute__((visibility("hidden"))) foo {}; + extern foo bar; + foo *zed() { + return &bar; + } + // CHECK: @_ZN6test413barE = external hidden global + // CHECK-HIDDEN: @_ZN6test413barE = external hidden global +} + +namespace test48 { + // Test that we use the visibility of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // a default symbol. + struct HIDDEN foo { + }; + DEFAULT foo x; + + struct bar { + template + struct zed { + }; + }; + + bar::zed<&x> y; + // CHECK: _ZN6test481yE = hidden global + // CHECK-HIDDEN: _ZN6test481yE = hidden global +} + // CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10 // CHECK: @_ZN5Test71aE = hidden global // CHECK: @_ZN5Test71bE = global @@ -510,6 +580,8 @@ namespace PR10113 { }; template class foo::bar; // CHECK: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv + + // FIXME: This should be hidden as zed is hidden. // CHECK-HIDDEN: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv } @@ -541,6 +613,8 @@ namespace PR11690_2 { }; template class foo::zed; // CHECK: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv + + // FIXME: This should be hidden as baz is hidden. // CHECK-HIDDEN: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv } @@ -605,3 +679,436 @@ namespace test26 { // CHECK: define void @_ZN6test261CIiE1fEv // CHECK-HIDDEN: define void @_ZN6test261CIiE1fEv } + +namespace test31 { + struct A { + struct HIDDEN B { + static void DEFAULT baz(); + }; + }; + void f() { + A::B::baz(); + } + // CHECK: declare void @_ZN6test311A1B3bazEv() + // CHECK-HIDDEN: declare void @_ZN6test311A1B3bazEv() +} + +namespace test32 { + struct HIDDEN A { + struct DEFAULT B { + void DEFAULT baz(); + }; + }; + void A::B::baz() { + } + // CHECK: define void @_ZN6test321A1B3bazEv + // CHECK-HIDDEN: define void @_ZN6test321A1B3bazEv +} + +namespace test33 { + template + class foo { + void bar() {} + }; + struct HIDDEN zed { + }; + template class DEFAULT foo; + // CHECK: define weak_odr void @_ZN6test333fooINS_3zedEE3barEv + // CHECK-HIDDEN: define weak_odr void @_ZN6test333fooINS_3zedEE3barEv +} + +namespace test34 { + struct foo { + }; + template + void bar() {} + template DEFAULT void bar(); + // CHECK: define weak_odr void @_ZN6test343barINS_3fooEEEvv + // CHECK-HIDDEN: define weak_odr void @_ZN6test343barINS_3fooEEEvv +} + +namespace test35 { + // This is a really ugly testcase. GCC propagates the DEFAULT in zed's + // definition. What we do instead is be conservative about merging + // implicit visibilities. + // FIXME: Maybe the best thing to do here is error? The test at least + // makes sure we don't produce a hidden symbol for foo::bar. + template + struct DEFAULT foo { + void bar() {} + }; + class zed; + template class foo; + class DEFAULT zed { + }; + // CHECK: define weak_odr void @_ZN6test353fooINS_3zedEE3barEv + // CHECK-HIDDEN: define weak_odr void @_ZN6test353fooINS_3zedEE3barEv +} + +namespace test36 { + template + class foo { + void bar() {} + }; + class DEFAULT S1 {}; + struct HIDDEN S2 {}; + template class foo; + // CHECK: define weak_odr hidden void @_ZN6test363fooINS_2S1ENS_2S2EE3barEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test363fooINS_2S1ENS_2S2EE3barEv +} + +namespace test37 { + struct HIDDEN foo { + }; + template + DEFAULT void bar() {} + template DEFAULT void bar(); + // CHECK: define weak_odr void @_ZN6test373barINS_3fooEEEvv + // CHECK-HIDDEN: define weak_odr void @_ZN6test373barINS_3fooEEEvv +} + +namespace test38 { + template + class DEFAULT foo { + void bar() {} + }; + struct HIDDEN zed { + }; + template class foo; + // CHECK: define weak_odr hidden void @_ZN6test383fooINS_3zedEE3barEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test383fooINS_3zedEE3barEv +} + +namespace test39 { + class DEFAULT default_t; + class HIDDEN hidden_t; + template class A { + template class B { + HIDDEN void hidden() {} + void noattr() {} + template void temp() {} + }; + }; + template class DEFAULT A; + template class DEFAULT A::B; + template void A::B::temp(); + template void A::B::temp(); + + // CHECK: define weak_odr hidden void @_ZN6test391AINS_8hidden_tEE1BIS1_E6hiddenEv + // CHECK: define weak_odr void @_ZN6test391AINS_8hidden_tEE1BIS1_E6noattrEv + // CHECK: define weak_odr void @_ZN6test391AINS_8hidden_tEE1BIS1_E4tempINS_9default_tEEEvv + + // GCC produces a default for this one. Why? + // CHECK: define weak_odr hidden void @_ZN6test391AINS_8hidden_tEE1BIS1_E4tempIS1_EEvv + + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test391AINS_8hidden_tEE1BIS1_E6hiddenEv + // CHECK-HIDDEN: define weak_odr void @_ZN6test391AINS_8hidden_tEE1BIS1_E6noattrEv + // CHECK-HIDDEN: define weak_odr void @_ZN6test391AINS_8hidden_tEE1BIS1_E4tempINS_9default_tEEEvv + + // GCC produces a default for this one. Why? + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test391AINS_8hidden_tEE1BIS1_E4tempIS1_EEvv +} + +namespace test42 { + struct HIDDEN foo { + }; + template + struct bar { + }; + template <> + struct HIDDEN bar { + DEFAULT static void zed(); + }; + void bar::zed() { + } + // CHECK: define hidden void @_ZN6test423barINS_3fooEE3zedEv + // CHECK-HIDDEN: define hidden void @_ZN6test423barINS_3fooEE3zedEv +} + +namespace test43 { + struct HIDDEN foo { + }; + template + void bar() { + } + template <> + DEFAULT void bar() { + } + // CHECK: define hidden void @_ZN6test433barINS_3fooEEEvv + // CHECK-HIDDEN: define hidden void @_ZN6test433barINS_3fooEEEvv +} + +namespace test44 { + template + struct foo { + foo() {} + }; + namespace { + struct bar; + } + template struct DEFAULT foo; + foo x; + // CHECK: define internal void @_ZN6test443fooINS_12_GLOBAL__N_13barEEC1Ev + // CHECK-HIDDEN: define internal void @_ZN6test443fooINS_12_GLOBAL__N_13barEEC1Ev +} + +namespace test45 { + template + struct foo { + template + struct bar { + bar() {}; + }; + }; + namespace { + struct zed; + } + template struct DEFAULT foo::bar; + foo::bar x; + // CHECK: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev + // CHECK-HIDDEN: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev +} + +namespace test46 { + template + void foo() { + } + namespace { + struct bar; + } + template DEFAULT void foo(); + void zed() { + foo(); + } + // CHECK: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv + // CHECK-HIDDEN: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv +} + +namespace test47 { + struct foo { + template + static void bar() { + } + }; + namespace { + struct zed; + } + template __attribute__((visibility("default"))) void foo::bar(); + void baz() { + foo::bar(); + } + // CHECK: define internal void @_ZN6test473foo3barINS_12_GLOBAL__N_13zedEEEvv + // CHECK-HIDDEN: define internal void @_ZN6test473foo3barINS_12_GLOBAL__N_13zedEEEvv +} + +namespace test49 { + // Test that we use the visibility of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // a default symbol. + + struct HIDDEN foo { + }; + + DEFAULT foo x; + + struct bar { + template + void zed() { + } + }; + + template void bar::zed<&x>(); + // CHECK: define weak_odr hidden void @_ZN6test493bar3zedIXadL_ZNS_1xEEEEEvv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test493bar3zedIXadL_ZNS_1xEEEEEvv +} + +namespace test50 { + // Test that we use the visibility of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // a default symbol. + + struct HIDDEN foo { + }; + DEFAULT foo x; + template + struct DEFAULT bar { + void zed() { + } + }; + template void bar<&x>::zed(); + // CHECK: define weak_odr hidden void @_ZN6test503barIXadL_ZNS_1xEEEE3zedEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test503barIXadL_ZNS_1xEEEE3zedEv +} + +namespace test51 { + // Test that we use the visibility of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // a default symbol. + + struct HIDDEN foo { + }; + DEFAULT foo x; + template + void DEFAULT zed() { + } + template void zed<&x>(); + // CHECK: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1xEEEEEvv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1xEEEEEvv +} + +namespace test52 { + // Test that we use the linkage of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // an external symbol. + + namespace { + struct foo { + }; + } + template + void zed() { + } + void f() { + zed(); + } + // CHECK: define internal void @_ZN6test523zedILPNS_12_GLOBAL__N_13fooE0EEEvv + // CHECK-HIDDEN: define internal void @_ZN6test523zedILPNS_12_GLOBAL__N_13fooE0EEEvv +} + +namespace test53 { + template struct vector { + static void _M_fill_insert(); + }; +#pragma GCC visibility push(hidden) + // GCC doesn't seem to use the visibility of enums at all, we do. + enum zed {v1}; + + // GCC fails to mark this specialization hidden, we mark it. + template<> + struct vector { + static void _M_fill_insert(); + }; + void foo() { + vector::_M_fill_insert(); + vector::_M_fill_insert(); + vector::_M_fill_insert(); + } +#pragma GCC visibility pop + // CHECK: declare void @_ZN6test536vectorIjE14_M_fill_insertEv + // CHECK-HIDDEN: declare void @_ZN6test536vectorIjE14_M_fill_insertEv + // CHECK: declare hidden void @_ZN6test536vectorIiE14_M_fill_insertEv + // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorIiE14_M_fill_insertEv + // CHECK: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv + // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv +} + +namespace test54 { + template + struct foo { + static void bar(); + }; +#pragma GCC visibility push(hidden) + class zed { + zed(const zed &); + }; + void bah() { + foo::bar(); + } +#pragma GCC visibility pop + // CHECK: declare hidden void @_ZN6test543fooINS_3zedEE3barEv + // CHECK-HIDDEN: declare hidden void @_ZN6test543fooINS_3zedEE3barEv +} + +namespace test55 { + template + struct __attribute__((visibility("hidden"))) foo { + static void bar(); + }; + template struct foo; + void foobar() { + foo::bar(); + } + // CHECK: declare hidden void @_ZN6test553fooIiE3barEv + // CHECK-HIDDEN: declare hidden void @_ZN6test553fooIiE3barEv +} + +namespace test56 { + template struct foo; + template + struct __attribute__((visibility("hidden"))) foo { + static void bar(); + }; + void foobar() { + foo::bar(); + } + // CHECK: declare hidden void @_ZN6test563fooIiE3barEv + // CHECK-HIDDEN: declare hidden void @_ZN6test563fooIiE3barEv +} + +namespace test57 { +#pragma GCC visibility push(hidden) + template + struct foo; + void bar(foo*); + template + struct foo { + static void zed(); + }; + void bah() { + foo::zed(); + } +#pragma GCC visibility pop + // CHECK: declare hidden void @_ZN6test573fooIiE3zedEv + // CHECK-HIDDEN: declare hidden void @_ZN6test573fooIiE3zedEv +} + +namespace test58 { +#pragma GCC visibility push(hidden) + struct foo; + template + struct __attribute__((visibility("default"))) bar { + static void zed() { + } + }; + void bah() { + bar::zed(); + } +#pragma GCC visibility pop + // CHECK: define linkonce_odr hidden void @_ZN6test583barINS_3fooEE3zedEv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test583barINS_3fooEE3zedEv +} + +namespace test59 { + DEFAULT int f(); + HIDDEN int g(); + typedef int (*foo)(); + template + void test() {} + void use() { + test<&g, &f>(); + // CHECK: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1gEvEEXadL_ZNS_1fEvEEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1gEvEEXadL_ZNS_1fEvEEEEvv + + test<&f, &g>(); + // CHECK: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1fEvEEXadL_ZNS_1gEvEEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1fEvEEXadL_ZNS_1gEvEEEEvv + } +} + +namespace test60 { + template + class __attribute__((visibility("hidden"))) a {}; + template + class __attribute__((visibility("default"))) b {}; + template class x, template class y> + void test() {} + void use() { + test(); + // CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv + + test(); + // CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv + } +} diff --git a/test/CodeGenObjC/2008-11-12-Metadata.m b/test/CodeGenObjC/2008-11-12-Metadata.m index afd7ce035aea..afd340a067c3 100644 --- a/test/CodeGenObjC/2008-11-12-Metadata.m +++ b/test/CodeGenObjC/2008-11-12-Metadata.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi %s -o /dev/null +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -o /dev/null @interface A @end diff --git a/test/CodeGenObjC/2008-11-24-ConstCFStrings.m b/test/CodeGenObjC/2008-11-24-ConstCFStrings.m index b37f66c29707..53eec2ab0500 100644 --- a/test/CodeGenObjC/2008-11-24-ConstCFStrings.m +++ b/test/CodeGenObjC/2008-11-24-ConstCFStrings.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -o - | FileCheck %s // CHECK: _unnamed_cfstring_ diff --git a/test/CodeGenObjC/2010-03-17-StructRef.m b/test/CodeGenObjC/2010-03-17-StructRef.m index fd0e6462ce2e..ce24c8da575b 100644 --- a/test/CodeGenObjC/2010-03-17-StructRef.m +++ b/test/CodeGenObjC/2010-03-17-StructRef.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi -o - | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -o - | FileCheck %s // Bitfield references must not touch memory outside of the enclosing // struct. Radar 7639995 typedef signed char BOOL; diff --git a/test/CodeGenObjC/arc-blocks.m b/test/CodeGenObjC/arc-blocks.m index 06acf01ce0f7..2326bce2be25 100644 --- a/test/CodeGenObjC/arc-blocks.m +++ b/test/CodeGenObjC/arc-blocks.m @@ -124,7 +124,7 @@ void test4(void) { // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]] // CHECK-NEXT: call void @objc_release(i8* [[T1]]) - // CHECK: define internal void @__test4_block_invoke_ + // CHECK: define internal void @__test4_block_invoke // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6 // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]], align 8 // CHECK-NEXT: store i8* null, i8** [[SLOT]], @@ -200,7 +200,7 @@ void test6(void) { // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6 // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) - // CHECK: define internal void @__test6_block_invoke_ + // CHECK: define internal void @__test6_block_invoke // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6 // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null) // CHECK-NEXT: ret void @@ -238,7 +238,7 @@ void test7(void) { // CHECK-NEXT: call void @objc_destroyWeak(i8** [[VAR]]) // CHECK-NEXT: ret void - // CHECK: define internal void @__test7_block_invoke_ + // CHECK: define internal void @__test7_block_invoke // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* {{%.*}}, i32 0, i32 5 // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[SLOT]]) // CHECK-NEXT: call void @test7_consume(i8* [[T0]]) @@ -521,3 +521,14 @@ void test15_helper(void (^block)(void), int x); void test15(int a) { test15_helper(^{ (void) a; }, ({ a; })); } + +// rdar://11016025 +void test16() { + void (^BLKVAR)(void) = ^{ BLKVAR(); }; + + // CHECK: define void @test16( + // CHECK: [[BLKVAR:%.*]] = alloca void ()*, align 8 + // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], + // CHECK-NEXT: [[SLOTREL:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 + // CHECK-NEXT: store void ()* null, void ()** [[BLKVAR]], align 8 +} diff --git a/test/CodeGenObjC/arc.m b/test/CodeGenObjC/arc.m index 2a98b10909bb..66a6a2f54b77 100644 --- a/test/CodeGenObjC/arc.m +++ b/test/CodeGenObjC/arc.m @@ -9,6 +9,9 @@ void test0(id x) { // CHECK-NEXT: [[TMP:%.*]] = load i8** [[X]] // CHECK-NEXT: call void @objc_release(i8* [[TMP]]) // CHECK-NEXT: ret void +// rdar://12040837 + // CHECK: declare extern_weak i8* @objc_retain(i8*) nonlazybind + // CHECK: declare extern_weak void @objc_release(i8*) nonlazybind } // CHECK: define i8* @test1(i8* diff --git a/test/CodeGenObjC/assign.m b/test/CodeGenObjC/assign.m index 82da800e7399..bdc99c635835 100644 --- a/test/CodeGenObjC/assign.m +++ b/test/CodeGenObjC/assign.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s struct s0 { int x; diff --git a/test/CodeGenObjC/autorelease.m b/test/CodeGenObjC/autorelease.m index 9260c3fafe8b..830929afb2e8 100644 --- a/test/CodeGenObjC/autorelease.m +++ b/test/CodeGenObjC/autorelease.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime-has-arc -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-runtime-has-arc -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime=macosx-10.7 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-runtime=macosx-10.7 -o - %s | FileCheck %s // rdar://8881826 // rdar://9412038 diff --git a/test/CodeGenObjC/bitfield-1.m b/test/CodeGenObjC/bitfield-1.m index 648ab2a374db..ad52d8f4789c 100644 --- a/test/CodeGenObjC/bitfield-1.m +++ b/test/CodeGenObjC/bitfield-1.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s -// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s @interface Object - (id) alloc; diff --git a/test/CodeGenObjC/bitfield-access.m b/test/CodeGenObjC/bitfield-access.m index 521d2e52a6fa..6d4c82a9b17c 100644 --- a/test/CodeGenObjC/bitfield-access.m +++ b/test/CodeGenObjC/bitfield-access.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o %t1 %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t1 %s // RUN: FileCheck -check-prefix=CHECK-I386 < %t1 %s -// RUN: %clang_cc1 -triple armv6-apple-darwin10 -fobjc-fragile-abi -target-abi apcs-gnu -emit-llvm -o %t2 %s +// RUN: %clang_cc1 -triple armv6-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -target-abi apcs-gnu -emit-llvm -o %t2 %s // RUN: FileCheck -check-prefix=CHECK-ARM < %t2 %s @interface I0 { diff --git a/test/CodeGenObjC/bitfield-gnu.m b/test/CodeGenObjC/bitfield-gnu.m index 7935bdaacf04..383907f15c51 100644 --- a/test/CodeGenObjC/bitfield-gnu.m +++ b/test/CodeGenObjC/bitfield-gnu.m @@ -1,4 +1,4 @@ -// RUN: %clang -S -emit-llvm -fgnu-runtime -o %t %s +// RUN: %clang -S -emit-llvm -fobjc-runtime=gcc -o %t %s typedef enum { A1, A2 } A; typedef struct { A a : 1; } B; @interface Obj { B *b; } @end diff --git a/test/CodeGenObjC/bitfield_encoding.m b/test/CodeGenObjC/bitfield_encoding.m index 17fd4a4108b7..1a516aaf8619 100644 --- a/test/CodeGenObjC/bitfield_encoding.m +++ b/test/CodeGenObjC/bitfield_encoding.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep "ib1b14" %t | count 1 -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -fgnu-runtime -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-runtime=gcc -emit-llvm -o %t %s // RUN: grep "ib32i1b33i14" %t | count 1 struct foo{ diff --git a/test/CodeGenObjC/block-6.m b/test/CodeGenObjC/block-6.m index 140fa8831937..57b9ea3fa6ea 100644 --- a/test/CodeGenObjC/block-6.m +++ b/test/CodeGenObjC/block-6.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 -fobjc-fragile-abi | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s // rdar://8893785 void MYFUNC() { diff --git a/test/CodeGenObjC/block-var-layout.m b/test/CodeGenObjC/block-var-layout.m index 1d0ce2d373ad..c8065be88c76 100644 --- a/test/CodeGenObjC/block-var-layout.m +++ b/test/CodeGenObjC/block-var-layout.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -emit-llvm %s -o %t-64.s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -O0 -emit-llvm %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s struct S { diff --git a/test/CodeGenObjC/blocks-1.m b/test/CodeGenObjC/blocks-1.m index 64da3594c271..99a11f91e4cd 100644 --- a/test/CodeGenObjC/blocks-1.m +++ b/test/CodeGenObjC/blocks-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-fragile-abi +// RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 // RUN: grep "_Block_object_dispose" %t | count 6 // RUN: grep "__copy_helper_block_" %t | count 4 // RUN: grep "__destroy_helper_block_" %t | count 4 @@ -8,7 +8,7 @@ // RUN: grep "_Block_object_assign" %t | count 4 // RUN: grep "objc_read_weak" %t | count 2 // RUN: grep "objc_assign_weak" %t | count 3 -// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-fragile-abi +// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 // RUN: grep "_Block_object_dispose" %t | count 6 // RUN: grep "__copy_helper_block_" %t | count 4 // RUN: grep "__destroy_helper_block_" %t | count 4 diff --git a/test/CodeGenObjC/blocks-2.m b/test/CodeGenObjC/blocks-2.m index 591d63bf37da..b04fa008b275 100644 --- a/test/CodeGenObjC/blocks-2.m +++ b/test/CodeGenObjC/blocks-2.m @@ -1,10 +1,10 @@ // We run this twice, once as Objective-C and once as Objective-C++. -// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi | FileCheck %s -// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi -x objective-c++ | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -x objective-c++ | FileCheck %s // CHECK: define i8* @{{.*}}test0 -// CHECK: define internal void @__test0_block_invoke_0( +// CHECK: define internal void @{{.*}}_block_invoke( // CHECK: call i8* @objc_assign_strongCast( // CHECK-NEXT: ret void id test0(id x) { diff --git a/test/CodeGenObjC/blocks-3.m b/test/CodeGenObjC/blocks-3.m index 55e215c7e6ab..a7edc1243cf5 100644 --- a/test/CodeGenObjC/blocks-3.m +++ b/test/CodeGenObjC/blocks-3.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fblocks -o %t %s // 1x for the declaration // 1x for the object-pointer byref copy helper diff --git a/test/CodeGenObjC/blocks-4.m b/test/CodeGenObjC/blocks-4.m index b3d099811cf0..f5af9bc39eb8 100644 --- a/test/CodeGenObjC/blocks-4.m +++ b/test/CodeGenObjC/blocks-4.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions -fblocks -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -fblocks -o %t %s // rdar://7590273 void EXIT(id e); diff --git a/test/CodeGenObjC/blocks-5.m b/test/CodeGenObjC/blocks-5.m index caa8d664455e..18adb0fed9b1 100644 --- a/test/CodeGenObjC/blocks-5.m +++ b/test/CodeGenObjC/blocks-5.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fblocks -o %t %s // rdar: // 8064140 diff --git a/test/CodeGenObjC/blocks.m b/test/CodeGenObjC/blocks.m index f478c07f78fb..6c85da9f895c 100644 --- a/test/CodeGenObjC/blocks.m +++ b/test/CodeGenObjC/blocks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fblocks -o - %s | FileCheck %s // test1. All of this is somehow testing rdar://6676764 struct S { @@ -18,7 +18,7 @@ void foo(T *P) { -(void) im0; @end -// CHECK: define internal i32 @"__8-[A im0]_block_invoke_0"( +// CHECK: define internal i32 @"__8-[A im0]_block_invoke"( @implementation A -(void) im0 { (void) ^{ return 1; }(); @@ -91,7 +91,7 @@ void test2(Test2 *x) { // rdar://problem/9124263 // In the test above, check that the use in the invocation function // doesn't require a read barrier. -// CHECK: define internal void @__test2_block_invoke_ +// CHECK: define internal void @__test2_block_invoke // CHECK: [[BLOCK:%.*]] = bitcast i8* {{%.*}} to [[BLOCK_T]]* // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]] diff --git a/test/CodeGenObjC/boxing.m b/test/CodeGenObjC/boxing.m new file mode 100644 index 000000000000..9664298154dc --- /dev/null +++ b/test/CodeGenObjC/boxing.m @@ -0,0 +1,95 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s + +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 + +@interface NSString : NSObject +@end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end + +// CHECK: [[WithIntMeth:@".*"]] = internal global [15 x i8] c"numberWithInt:\00" +// CHECK: [[WithIntSEL:@".*"]] = internal global i8* getelementptr inbounds ([15 x i8]* [[WithIntMeth]] +// CHECK: [[WithCharMeth:@".*"]] = internal global [16 x i8] c"numberWithChar:\00" +// CHECK: [[WithCharSEL:@".*"]] = internal global i8* getelementptr inbounds ([16 x i8]* [[WithCharMeth]] +// CHECK: [[WithBoolMeth:@".*"]] = internal global [16 x i8] c"numberWithBool:\00" +// CHECK: [[WithBoolSEL:@".*"]] = internal global i8* getelementptr inbounds ([16 x i8]* [[WithBoolMeth]] +// CHECK: [[WithIntegerMeth:@".*"]] = internal global [19 x i8] c"numberWithInteger:\00" +// CHECK: [[WithIntegerSEL:@".*"]] = internal global i8* getelementptr inbounds ([19 x i8]* [[WithIntegerMeth]] +// CHECK: [[WithUnsignedIntegerMeth:@".*"]] = internal global [27 x i8] c"numberWithUnsignedInteger:\00" +// CHECK: [[WithUnsignedIntegerSEL:@".*"]] = internal global i8* getelementptr inbounds ([27 x i8]* [[WithUnsignedIntegerMeth]] +// CHECK: [[stringWithUTF8StringMeth:@".*"]] = internal global [22 x i8] c"stringWithUTF8String:\00" +// CHECK: [[stringWithUTF8StringSEL:@".*"]] = internal global i8* getelementptr inbounds ([22 x i8]* [[stringWithUTF8StringMeth]] + +int main() { + // CHECK: load i8** [[WithIntSEL]] + int i; @(i); + // CHECK: load i8** [[WithCharSEL]] + signed char sc; @(sc); + // CHECK: load i8** [[WithBoolSEL]] + BOOL b; @(b); + // CHECK: load i8** [[WithBoolSEL]] + typeof(b) b2; @(b2); + // CHECK: load i8** [[WithBoolSEL]] + typedef const typeof(b) MyBOOL; MyBOOL b3; @(b3); + // CHECK: load i8** [[WithBoolSEL]] + @((BOOL)i); + // CHECK: load i8** [[WithIntegerSEL]] + @((NSInteger)i); + // CHECK: load i8** [[WithUnsignedIntegerSEL]] + @((NSUInteger)i); + // CHECK: load i8** [[stringWithUTF8StringSEL]] + const char *s; @(s); + + typedef enum : NSInteger { Red, Green, Blue } Color; + // CHECK: load i8** [[WithIntegerSEL]] + @(Red); + Color col = Red; + // CHECK: load i8** [[WithIntegerSEL]] + @(col); +} diff --git a/test/CodeGenObjC/builtins.m b/test/CodeGenObjC/builtins.m index cb2995da52a5..0c5744805e6d 100644 --- a/test/CodeGenObjC/builtins.m +++ b/test/CodeGenObjC/builtins.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s void test0(id receiver, SEL sel, const char *str) { short s = ((short (*)(id, SEL, const char*)) objc_msgSend)(receiver, sel, str); diff --git a/test/CodeGenObjC/category-class.m b/test/CodeGenObjC/category-class.m index 5a82c1425504..92fd36cbe406 100644 --- a/test/CodeGenObjC/category-class.m +++ b/test/CodeGenObjC/category-class.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // PR7431 // CHECK: module asm "\09.lazy_reference .objc_class_name_A" diff --git a/test/CodeGenObjC/class-type.m b/test/CodeGenObjC/class-type.m index 45aae254bd33..4eae1ae6eab6 100644 --- a/test/CodeGenObjC/class-type.m +++ b/test/CodeGenObjC/class-type.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s @interface I0 { diff --git a/test/CodeGenObjC/constant-string-class.m b/test/CodeGenObjC/constant-string-class.m index ea049a51e12b..adad6b012623 100644 --- a/test/CodeGenObjC/constant-string-class.m +++ b/test/CodeGenObjC/constant-string-class.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fno-constant-cfstrings -fconstant-string-class Foo -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fno-constant-cfstrings -fconstant-string-class Foo -emit-llvm -o %t %s // RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-constant-cfstrings -fconstant-string-class Foo -emit-llvm -o %t %s diff --git a/test/CodeGenObjC/constant-strings.m b/test/CodeGenObjC/constant-strings.m index c308d7a475dc..cad634a4b103 100644 --- a/test/CodeGenObjC/constant-strings.m +++ b/test/CodeGenObjC/constant-strings.m @@ -5,11 +5,11 @@ // // CHECK-NEXT: @.str = {{.*}}constant [13 x i8] c"Hello World!\00", align 1 -// RUN: %clang_cc1 -fgnu-runtime -emit-llvm -o %t %s +// RUN: %clang_cc1 -fobjc-runtime=gcc -emit-llvm -o %t %s // RUN: FileCheck --check-prefix=CHECK-GNU < %t %s // CHECK-GNU: NXConstantString -// RUN: %clang_cc1 -fgnu-runtime -fconstant-string-class NSConstantString -emit-llvm -o %t %s +// RUN: %clang_cc1 -fobjc-runtime=gcc -fconstant-string-class NSConstantString -emit-llvm -o %t %s // RUN: FileCheck --check-prefix=CHECK-GNU-WITH-CLASS < %t %s // CHECK-GNU-WITH-CLASS: NSConstantString id a = @"Hello World!"; diff --git a/test/CodeGenObjC/deadcode_strip_used_var.m b/test/CodeGenObjC/deadcode_strip_used_var.m index 3137ceb22298..b8a703487aa8 100644 --- a/test/CodeGenObjC/deadcode_strip_used_var.m +++ b/test/CodeGenObjC/deadcode_strip_used_var.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 %s -emit-llvm -o %t -triple i386-apple-darwin10 -fobjc-fragile-abi +// RUN: %clang_cc1 %s -emit-llvm -o %t -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 // RUN: grep "llvm.used" %t | count 1 -// RUN: %clang_cc1 %s -emit-llvm -o %t -triple x86_64-apple-darwin10 -fobjc-fragile-abi +// RUN: %clang_cc1 %s -emit-llvm -o %t -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 // RUN: grep "llvm.used" %t | count 1 diff --git a/test/CodeGenObjC/debug-info-block-helper.m b/test/CodeGenObjC/debug-info-block-helper.m index 83db0c97e5a8..cf8c2a2a9684 100644 --- a/test/CodeGenObjC/debug-info-block-helper.m +++ b/test/CodeGenObjC/debug-info-block-helper.m @@ -1,8 +1,8 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s -o - | FileCheck %s extern void foo(void(^)(void)); -// CHECK: metadata !{i32 786478, i32 0, metadata !27, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !27, i32 24, metadata !43, i1 true, i1 true, i32 0, i32 0, null, i32 0, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !45, i32 24} ; [ DW_TAG_subprogram ] +// CHECK: metadata !{i32 786478, i32 0, metadata !27, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !27, i32 24, metadata !37, i1 true, i1 true, i32 0, i32 0, null, i32 0, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !5, i32 24} ; [ DW_TAG_subprogram ] @interface NSObject { struct objc_object *isa; diff --git a/test/CodeGenObjC/debug-info-crash.m b/test/CodeGenObjC/debug-info-crash.m index 5504356d2e3a..abbe2eb651c6 100644 --- a/test/CodeGenObjC/debug-info-crash.m +++ b/test/CodeGenObjC/debug-info-crash.m @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -fblocks -g -S %s -o - +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fblocks -g -S %s -o - // rdar://7556129 @implementation test diff --git a/test/CodeGenObjC/debug-info-static-var.m b/test/CodeGenObjC/debug-info-static-var.m index c65e77c4d8d4..8602ffb78e46 100644 --- a/test/CodeGenObjC/debug-info-static-var.m +++ b/test/CodeGenObjC/debug-info-static-var.m @@ -1,5 +1,5 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi -S -masm-verbose -o - %s | FileCheck %s +// RUN: %clang_cc1 -g -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -S -masm-verbose -o - %s | FileCheck %s // Radar 8801045 // Do not emit AT_MIPS_linkage_name for static variable i diff --git a/test/CodeGenObjC/debug-info-synthesis.m b/test/CodeGenObjC/debug-info-synthesis.m index 7e263cf74c6e..bf8e6d104924 100644 --- a/test/CodeGenObjC/debug-info-synthesis.m +++ b/test/CodeGenObjC/debug-info-synthesis.m @@ -31,4 +31,4 @@ int main(int argc, char *argv[]) { } // CHECK: !7 = metadata !{i32 {{.*}}, metadata !"./foo.h" -// CHECK: !31 = metadata !{i32 {{.*}}, i32 0, metadata !7, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !7, i32 8, metadata !32, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !34, i32 8} ; [ DW_TAG_subprogram ] +// CHECK: !29 = metadata !{i32 {{.*}}, i32 0, metadata !7, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !7, i32 8, metadata !30, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !1, i32 8} ; [ DW_TAG_subprogram ] diff --git a/test/CodeGenObjC/encode-cstyle-method.m b/test/CodeGenObjC/encode-cstyle-method.m index ea630230b541..f3243a31487f 100644 --- a/test/CodeGenObjC/encode-cstyle-method.m +++ b/test/CodeGenObjC/encode-cstyle-method.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s // rdar: // 7445205 @interface Foo diff --git a/test/CodeGenObjC/encode-test-6.m b/test/CodeGenObjC/encode-test-6.m new file mode 100644 index 000000000000..10681dbcc592 --- /dev/null +++ b/test/CodeGenObjC/encode-test-6.m @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o %t %s +// RUN: FileCheck < %t %s +// rdar://11777609 + +typedef struct {} Z; + +@interface A +-(void)bar:(Z)a; +-(void)foo:(Z)a : (char*)b : (Z)c : (double) d; +@end + +@implementation A +-(void)bar:(Z)a {} +-(void)foo:(Z)a: (char*)b : (Z)c : (double) d {} +@end + +// CHECK: internal global [14 x i8] c"v16@0:8{?=}16 +// CHECK: internal global [26 x i8] c"v32@0:8{?=}16*16{?=}24d24 + diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m index 02af5daa2265..3780068e6178 100644 --- a/test/CodeGenObjC/encode-test.m +++ b/test/CodeGenObjC/encode-test.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: FileCheck < %t %s // // CHECK: @"\01L_OBJC_METH_VAR_TYPE_34" = internal global [16 x i8] c"v12@0:4[3[4@]]8\00" diff --git a/test/CodeGenObjC/exceptions.m b/test/CodeGenObjC/exceptions.m index 24fb6575e440..25780fd518fe 100644 --- a/test/CodeGenObjC/exceptions.m +++ b/test/CodeGenObjC/exceptions.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -O2 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fexceptions -fobjc-exceptions -O2 -o - %s | FileCheck %s // // [irgen] [eh] Exception code built with clang (x86_64) crashes diff --git a/test/CodeGenObjC/fp2ret.m b/test/CodeGenObjC/fp2ret.m index 9c956aec9b3f..2e65332ec974 100644 --- a/test/CodeGenObjC/fp2ret.m +++ b/test/CodeGenObjC/fp2ret.m @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-X86_32 %s // -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-X86_64 %s // -// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-fragile-abi -emit-llvm -target-abi apcs-gnu -o - %s | \ +// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -target-abi apcs-gnu -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-ARMV7 %s @interface A diff --git a/test/CodeGenObjC/fpret.m b/test/CodeGenObjC/fpret.m index bf111e001d04..cabef108df48 100644 --- a/test/CodeGenObjC/fpret.m +++ b/test/CodeGenObjC/fpret.m @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-X86_32 %s // -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-X86_64 %s // -// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-fragile-abi -emit-llvm -target-abi apcs-gnu -o - %s | \ +// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -target-abi apcs-gnu -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-ARMV7 %s @interface A diff --git a/test/CodeGenObjC/getter-property-mismatch.m b/test/CodeGenObjC/getter-property-mismatch.m new file mode 100644 index 000000000000..21ed6eea68e8 --- /dev/null +++ b/test/CodeGenObjC/getter-property-mismatch.m @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -o - | FileCheck %s +// rdar://11323676 + +@interface NSDictionary @end +@interface NSMutableDictionary : NSDictionary@end@interface CalDAVAddManagedAttachmentsTaskGroup { + NSMutableDictionary *_filenamesToServerLocation; +} +- (NSDictionary *)filenamesToServerLocation; +@property (readwrite, retain) NSMutableDictionary *filenamesToServerLocation; +@end + +@implementation CalDAVAddManagedAttachmentsTaskGroup +@synthesize filenamesToServerLocation=_filenamesToServerLocation; +@end + +// CHECK: [[CALL:%.*]] = call i8* @objc_getProperty +// CHECK: [[ONE:%.*]] = bitcast i8* [[CALL:%.*]] to [[T1:%.*]]* +// CHECK: [[TWO:%.*]] = bitcast [[T1]]* [[ONE]] to [[T2:%.*]]* +// CHECK: ret [[T2]]* [[TWO]] + diff --git a/test/CodeGenObjC/getter-property-type-mismatch.m b/test/CodeGenObjC/getter-property-type-mismatch.m new file mode 100644 index 000000000000..c7e1c1a96a42 --- /dev/null +++ b/test/CodeGenObjC/getter-property-type-mismatch.m @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s +// rdar://11515196 + +@interface NSArray @end + +@interface NSMutableArray : NSArray +- (void) addObject; +@end + +@interface BPXLAppDelegate + +- (NSArray *)arrayOfThings; + +@end + + +@interface BPXLAppDelegate () +@property (retain, nonatomic) NSMutableArray *arrayOfThings; +@end + +@implementation BPXLAppDelegate + +@synthesize arrayOfThings=_arrayOfThings; + +- (void)applicationDidFinishLaunching +{ + [self.arrayOfThings addObject]; +} + +@end + +// CHECK: define internal [[RET:%.*]]* @"\01-[BPXLAppDelegate arrayOfThings +// CHECK: [[THREE:%.*]] = bitcast [[OPQ:%.*]]* [[TWO:%.*]] to [[RET]]* +// CHECK: ret [[RET]]* [[THREE]] + diff --git a/test/CodeGenObjC/gnu-exceptions.m b/test/CodeGenObjC/gnu-exceptions.m index 8917bf3120da..141747ec8d3d 100644 --- a/test/CodeGenObjC/gnu-exceptions.m +++ b/test/CodeGenObjC/gnu-exceptions.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fgnu-runtime -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=gcc -o - %s | FileCheck %s void opaque(void); void log(int i); diff --git a/test/CodeGenObjC/id-isa-codegen.m b/test/CodeGenObjC/id-isa-codegen.m index 8cac750773c4..8717ce2d0abb 100644 --- a/test/CodeGenObjC/id-isa-codegen.m +++ b/test/CodeGenObjC/id-isa-codegen.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP32 %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix LP32 %s typedef struct objc_class *Class; diff --git a/test/CodeGenObjC/image-info.m b/test/CodeGenObjC/image-info.m index 613b272bdea2..030bcaed1a38 100644 --- a/test/CodeGenObjC/image-info.m +++ b/test/CodeGenObjC/image-info.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s diff --git a/test/CodeGenObjC/implicit-objc_msgSend.m b/test/CodeGenObjC/implicit-objc_msgSend.m index aff0fe45a009..6fc3d46d50d9 100644 --- a/test/CodeGenObjC/implicit-objc_msgSend.m +++ b/test/CodeGenObjC/implicit-objc_msgSend.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep -F 'declare i8* @objc_msgSend(i8*, i8*, ...)' %t typedef struct objc_selector *SEL; diff --git a/test/CodeGenObjC/interface-layout-64.m b/test/CodeGenObjC/interface-layout-64.m index 4fdda4559d14..16361a21b67e 100644 --- a/test/CodeGenObjC/interface-layout-64.m +++ b/test/CodeGenObjC/interface-layout-64.m @@ -1,33 +1,32 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s // RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s && -// RUN: grep '@"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I4._iv4" = global i64 13, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I5._iv5" = global i64 14, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I5._iv6_synth" = hidden global i64 16, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I5._iv7_synth" = hidden global i64 20, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I6.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I8.b" = global i64 8, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I9.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I10.iv1" = global i64 4, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I12.iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '_OBJC_CLASS_RO_$_I3" = internal global .* { i32 0, i32 8, i32 13, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I4" = internal global .* { i32 0, i32 13, i32 14, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I5" = internal global .* { i32 0, i32 14, i32 24, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I6" = internal global .* { i32 2, i32 0, i32 1, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I8" = internal global .* { i32 0, i32 8, i32 16, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I9" = internal global .* { i32 2, i32 0, i32 4, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I10" = internal global .* { i32 0, i32 4, i32 5, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I11" = internal global .* { i32 0, i32 5, i32 5, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I12" = internal global .* { i32 0, i32 8, i32 12, .*' %t - +// CHECK: @"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_ivar", align 8 +// CHECK: @"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I3" = internal global {{.*}} { i32 0, i32 8, i32 13 +// CHECK: @"OBJC_IVAR_$_I4._iv4" = global i64 13, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I4" = internal global {{.*}} { i32 0, i32 13, i32 14, {{.*}} +// CHECK: @"OBJC_IVAR_$_I5._iv6_synth" = hidden global i64 16, section "__DATA, __objc_ivar", align 8 +// CHECK: @"OBJC_IVAR_$_I5._iv7_synth" = hidden global i64 20, section "__DATA, __objc_ivar", align 8 +// CHECK: @"OBJC_IVAR_$_I5._iv5" = global i64 14, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I5" = internal global {{.*}} { i32 0, i32 14, i32 24, {{.*}} +// CHECK: @"OBJC_IVAR_$_I6.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I6" = internal global {{.*}} { i32 2, i32 0, i32 1, {{.*}} +// CHECK: @"OBJC_IVAR_$_I8.b" = global i64 8, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I8" = internal global {{.*}} { i32 0, i32 8, i32 16, {{.*}} +// CHECK: @"OBJC_IVAR_$_I9.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I9" = internal global {{.*}} { i32 2, i32 0, i32 4, {{.*}} +// CHECK: @"OBJC_IVAR_$_I10.iv1" = global i64 4, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I10" = internal global {{.*}} { i32 0, i32 4, i32 5, {{.*}} +// CHECK: _OBJC_CLASS_RO_$_I11" = internal global {{.*}} { i32 0, i32 5, i32 5, {{.*}} +// CHECK: @"OBJC_IVAR_$_I12.iv2" = global i64 8, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I12" = internal global {{.*}} { i32 0, i32 8, i32 12, {{.*}} /* Compare to: - gcc -m64 -S -o - interface-layout-64.m | grep '^_OBJC_IVAR_$_*.*' -A 1 + gcc -m64 -S -o - interface-layout-64.m | grep '^_OBJC_IVAR_$_*{{.*}}' -A 1 and - gcc -m64 -S -o - interface-layout-64.m | grep '^l.*_CLASS_RO_$_I[0-9]*' -A 3 + gcc -m64 -S -o - interface-layout-64.m | grep '^l{{.*}}_CLASS_RO_$_I[0-9]*' -A 3 */ struct s0 { diff --git a/test/CodeGenObjC/interface.m b/test/CodeGenObjC/interface.m index 0ca64ecd3ffc..4adc926141b2 100644 --- a/test/CodeGenObjC/interface.m +++ b/test/CodeGenObjC/interface.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -O3 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -O3 -emit-llvm -o %t %s // RUN: grep 'ret i32 385' %t void *alloca(); diff --git a/test/CodeGenObjC/ivar-layout-64-bitfields.m b/test/CodeGenObjC/ivar-layout-64-bitfields.m index acc734a575de..f2f05931d913 100644 --- a/test/CodeGenObjC/ivar-layout-64-bitfields.m +++ b/test/CodeGenObjC/ivar-layout-64-bitfields.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s #ifdef __cplusplus typedef bool _Bool; diff --git a/test/CodeGenObjC/ivar-layout-array0-struct.m b/test/CodeGenObjC/ivar-layout-array0-struct.m index 7ef32f634237..267f947f42b6 100644 --- a/test/CodeGenObjC/ivar-layout-array0-struct.m +++ b/test/CodeGenObjC/ivar-layout-array0-struct.m @@ -1,5 +1,5 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -O0 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s // rdar://8800513 diff --git a/test/CodeGenObjC/ivar-layout-no-optimize.m b/test/CodeGenObjC/ivar-layout-no-optimize.m index 85bba8abaaa9..46a7034a2249 100644 --- a/test/CodeGenObjC/ivar-layout-no-optimize.m +++ b/test/CodeGenObjC/ivar-layout-no-optimize.m @@ -1,7 +1,7 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -O0 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s +// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -O0 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s @interface NSObject { diff --git a/test/CodeGenObjC/ivars.m b/test/CodeGenObjC/ivars.m index 6c8a72d0f100..1ccfa36345c5 100644 --- a/test/CodeGenObjC/ivars.m +++ b/test/CodeGenObjC/ivars.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s // RUN: %clang_cc1 -fobjc-gc -emit-llvm -o - %s // rdar://6800926 diff --git a/test/CodeGenObjC/layout-bitfield-crash.m b/test/CodeGenObjC/layout-bitfield-crash.m new file mode 100644 index 000000000000..5d0e7bfd2e7f --- /dev/null +++ b/test/CodeGenObjC/layout-bitfield-crash.m @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-gc -emit-llvm -g -o - %s +// Check that this doesn't crash when compiled with debugging on. +@class Foo; +typedef struct Bar *BarRef; + +@interface Baz +@end + +@interface Foo +- (void) setFlag; +@end + +@implementation Baz + +- (void) a:(BarRef)b +{ + Foo* view = (Foo*)self; + [view setFlag]; +} + +@end + + +@implementation Foo +{ + int flag : 1; +} + +- (void) setFlag +{ + if (!flag) + flag = 1; +} + +@end diff --git a/test/CodeGenObjC/link-errors.m b/test/CodeGenObjC/link-errors.m index 0d19681ec109..f2d9ddba883b 100644 --- a/test/CodeGenObjC/link-errors.m +++ b/test/CodeGenObjC/link-errors.m @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep '.lazy_reference .objc_class_name_A' %t | count 1 // RUN: grep '.lazy_reference .objc_class_name_Unknown' %t | count 1 // RUN: grep '.lazy_reference .objc_class_name_Protocol' %t | count 1 -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -DWITH_IMPL -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -DWITH_IMPL -emit-llvm -o %t %s // RUN: grep '.lazy_reference .objc_class_name_Root' %t | count 1 @interface Root diff --git a/test/CodeGenObjC/local-static-block.m b/test/CodeGenObjC/local-static-block.m index 7a7b6f6e087b..deea8bac13ea 100644 --- a/test/CodeGenObjC/local-static-block.m +++ b/test/CodeGenObjC/local-static-block.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o %t-64.ll +// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o %t-64.ll // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.ll %s // rdar: // 8390455 diff --git a/test/CodeGenObjC/messages-2.m b/test/CodeGenObjC/messages-2.m index 7c9d81cc9d71..ce6624ad5a0a 100644 --- a/test/CodeGenObjC/messages-2.m +++ b/test/CodeGenObjC/messages-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NF // Most of this test is apparently just verifying that we don't crash. diff --git a/test/CodeGenObjC/messages.m b/test/CodeGenObjC/messages.m index 6f39602d9c96..a42677ef7849 100644 --- a/test/CodeGenObjC/messages.m +++ b/test/CodeGenObjC/messages.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC +// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC-NF -// RUN: %clang_cc1 -fobjc-fragile-abi -fgnu-runtime -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU -// RUN: %clang_cc1 -fgnu-runtime -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-GNU-NF +// RUN: %clang_cc1 -fobjc-runtime=gcc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU +// RUN: %clang_cc1 -fobjc-runtime=gnustep -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-GNU-NF typedef struct { int x; diff --git a/test/CodeGenObjC/metadata-symbols-32.m b/test/CodeGenObjC/metadata-symbols-32.m index a7bcf01926b2..1df1560d8fcc 100644 --- a/test/CodeGenObjC/metadata-symbols-32.m +++ b/test/CodeGenObjC/metadata-symbols-32.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUNX: llvm-gcc -m32 -emit-llvm -S -o %t %s && // RUN: grep '@"\\01L_OBJC_CATEGORY_A_Cat" = internal global .*section "__OBJC,__category,regular,no_dead_strip", align 4' %t diff --git a/test/CodeGenObjC/misc-atomic-property.m b/test/CodeGenObjC/misc-atomic-property.m index f2645dcaef84..4c8cc669705d 100644 --- a/test/CodeGenObjC/misc-atomic-property.m +++ b/test/CodeGenObjC/misc-atomic-property.m @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar: //8808439 typedef struct { diff --git a/test/CodeGenObjC/mrr-autorelease.m b/test/CodeGenObjC/mrr-autorelease.m index f7a13fd8dcf2..773fdbc96854 100644 --- a/test/CodeGenObjC/mrr-autorelease.m +++ b/test/CodeGenObjC/mrr-autorelease.m @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://8881826 // rdar://9423507 diff --git a/test/CodeGenObjC/nested-rethrow.m b/test/CodeGenObjC/nested-rethrow.m index 5576c1640d18..bff52c3b2494 100644 --- a/test/CodeGenObjC/nested-rethrow.m +++ b/test/CodeGenObjC/nested-rethrow.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions %s -o - | FileCheck %s extern int printf(const char*, ...); diff --git a/test/CodeGenObjC/next-objc-dispatch.m b/test/CodeGenObjC/next-objc-dispatch.m index 4288b2da0cb2..6afd658e03a7 100644 --- a/test/CodeGenObjC/next-objc-dispatch.m +++ b/test/CodeGenObjC/next-objc-dispatch.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s \ +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s \ // RUN: -fobjc-dispatch-method=legacy | \ // RUN: FileCheck -check-prefix CHECK-FRAGILE_LEGACY %s // diff --git a/test/CodeGenObjC/no-category-class.m b/test/CodeGenObjC/no-category-class.m index 3969f917e2f3..0c672f7894a6 100644 --- a/test/CodeGenObjC/no-category-class.m +++ b/test/CodeGenObjC/no-category-class.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s @interface NSObject @end diff --git a/test/CodeGenObjC/nonlazy-msgSend.m b/test/CodeGenObjC/nonlazy-msgSend.m index 73157c77c030..7c349b293807 100644 --- a/test/CodeGenObjC/nonlazy-msgSend.m +++ b/test/CodeGenObjC/nonlazy-msgSend.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep -F 'declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind' %t void f0(id x) { diff --git a/test/CodeGenObjC/ns-constant-strings.m b/test/CodeGenObjC/ns-constant-strings.m index d04793c8c239..ccaacaf53e76 100644 --- a/test/CodeGenObjC/ns-constant-strings.m +++ b/test/CodeGenObjC/ns-constant-strings.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fno-constant-cfstrings -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fno-constant-cfstrings -emit-llvm -o %t %s // RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-constant-cfstrings -emit-llvm -o %t %s diff --git a/test/CodeGenObjC/objc-align.m b/test/CodeGenObjC/objc-align.m index f3c586eeb214..324740c8aefc 100644 --- a/test/CodeGenObjC/objc-align.m +++ b/test/CodeGenObjC/objc-align.m @@ -1,7 +1,7 @@ // 32-bit // RUNX: llvm-gcc -m32 -emit-llvm -S -o %t %s && -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep '@"\\01L_OBJC_CATEGORY_A_Cat" = internal global .*, section "__OBJC,__category,regular,no_dead_strip", align 4' %t // RUN: grep '@"\\01L_OBJC_CLASS_A" = internal global .*, section "__OBJC,__class,regular,no_dead_strip", align 4' %t // RUN: grep '@"\\01L_OBJC_CLASS_C" = internal global .*, section "__OBJC,__class,regular,no_dead_strip", align 4' %t diff --git a/test/CodeGenObjC/objc-assign-ivar.m b/test/CodeGenObjC/objc-assign-ivar.m index d0a1a0fceefe..0dc9ec292d71 100644 --- a/test/CodeGenObjC/objc-assign-ivar.m +++ b/test/CodeGenObjC/objc-assign-ivar.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_ivar' %t | count 14 typedef struct { diff --git a/test/CodeGenObjC/objc-gc-aggr-assign.m b/test/CodeGenObjC/objc-gc-aggr-assign.m index dfdf02e2a5a6..6c2baac0504b 100644 --- a/test/CodeGenObjC/objc-gc-aggr-assign.m +++ b/test/CodeGenObjC/objc-gc-aggr-assign.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix C %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix CP %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix C %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix CP %s static int count; diff --git a/test/CodeGenObjC/objc-literal-debugger-test.m b/test/CodeGenObjC/objc-literal-debugger-test.m index 389ef2248a48..5f69fd5ba889 100644 --- a/test/CodeGenObjC/objc-literal-debugger-test.m +++ b/test/CodeGenObjC/objc-literal-debugger-test.m @@ -1,7 +1,29 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdebugger-objc-literal -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdebugger-objc-literal -emit-llvm -o - %s -DINCLUDE_INTERFACES=1 | FileCheck %s + +// We need two different RUN lines here because the first time a class/method is absent, +// it will be added for -fdebugger-objc-literal. + +#ifdef INCLUDE_INTERFACES +@interface NSObject +@end + +@interface NSNumber : NSObject +@end + +@interface NSArray : NSObject +@end + +@interface NSDictionary : NSObject +@end + +@interface NSString : NSObject +@end +#endif int main() { - id l = @'a'; + // object literals. + id l; l = @'a'; l = @42; l = @-42; @@ -11,6 +33,21 @@ int main() { l = @__objc_no; l = @{ @"name":@666 }; l = @[ @"foo", @"bar" ]; + +#if __has_feature(objc_boxed_expressions) + // boxed expressions. + id b; + b = @('a'); + b = @(42); + b = @(-42); + b = @(42u); + b = @(3.141592654f); + b = @(__objc_yes); + b = @(__objc_no); + b = @("hello"); +#else +#error "boxed expressions not supported" +#endif } // CHECK: declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind diff --git a/test/CodeGenObjC/objc-read-weak-byref.m b/test/CodeGenObjC/objc-read-weak-byref.m index 8fe1436567b1..94eca2899d9b 100644 --- a/test/CodeGenObjC/objc-read-weak-byref.m +++ b/test/CodeGenObjC/objc-read-weak-byref.m @@ -1,7 +1,7 @@ // REQUIRES: x86-registered-target,x86-64-registered-target -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -S %s -o %t-64.s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-fragile-abi -S %s -o %t-32.s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -S %s -o %t-32.s // RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s @interface NSObject diff --git a/test/CodeGenObjC/objc2-assign-global.m b/test/CodeGenObjC/objc2-assign-global.m index 36c95f792dae..147aa3d3e3f2 100644 --- a/test/CodeGenObjC/objc2-assign-global.m +++ b/test/CodeGenObjC/objc2-assign-global.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 26 @class NSObject; diff --git a/test/CodeGenObjC/objc2-new-gc-api-strongcast.m b/test/CodeGenObjC/objc2-new-gc-api-strongcast.m index 1044ba529857..5619ab3d3d49 100644 --- a/test/CodeGenObjC/objc2-new-gc-api-strongcast.m +++ b/test/CodeGenObjC/objc2-new-gc-api-strongcast.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fblocks -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fblocks -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_strongCast' %t | count 4 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fblocks -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fblocks -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_strongCast' %t | count 4 @interface DSATextSearch @end diff --git a/test/CodeGenObjC/objc2-no-write-barrier.m b/test/CodeGenObjC/objc2-no-write-barrier.m index d439368cc608..ece6b9d582b7 100644 --- a/test/CodeGenObjC/objc2-no-write-barrier.m +++ b/test/CodeGenObjC/objc2-no-write-barrier.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep 'objc_assign' %t | count 0 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep 'objc_assign' %t | count 0 typedef struct { diff --git a/test/CodeGenObjC/objc2-retain-codegen.m b/test/CodeGenObjC/objc2-retain-codegen.m index d5b473e33473..594e3dfcd06b 100644 --- a/test/CodeGenObjC/objc2-retain-codegen.m +++ b/test/CodeGenObjC/objc2-retain-codegen.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc-only -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc-only -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc-only -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc-only -emit-llvm -o %t %s @interface I0 { I0 *_f0; diff --git a/test/CodeGenObjC/objc2-strong-cast-1.m b/test/CodeGenObjC/objc2-strong-cast-1.m index 9bb750fd0523..4417084ebb9f 100644 --- a/test/CodeGenObjC/objc2-strong-cast-1.m +++ b/test/CodeGenObjC/objc2-strong-cast-1.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s @interface I { __attribute__((objc_gc(strong))) int *i_IdocumentIDs; diff --git a/test/CodeGenObjC/objc2-weak-assign.m b/test/CodeGenObjC/objc2-weak-assign.m index e5c67c58d64a..13ce3386c034 100644 --- a/test/CodeGenObjC/objc2-weak-assign.m +++ b/test/CodeGenObjC/objc2-weak-assign.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6 __weak id* x; diff --git a/test/CodeGenObjC/objc2-weak-block-call.m b/test/CodeGenObjC/objc2-weak-block-call.m index 94c54e7f3ba2..25434947d104 100644 --- a/test/CodeGenObjC/objc2-weak-block-call.m +++ b/test/CodeGenObjC/objc2-weak-block-call.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s @interface MyView - (void)MyView_sharedInit; diff --git a/test/CodeGenObjC/objc2-weak-compare.m b/test/CodeGenObjC/objc2-weak-compare.m index 75cf689737b4..d8d5459aee23 100644 --- a/test/CodeGenObjC/objc2-weak-compare.m +++ b/test/CodeGenObjC/objc2-weak-compare.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s @interface PBXTarget { diff --git a/test/CodeGenObjC/objc2-weak-ivar-debug.m b/test/CodeGenObjC/objc2-weak-ivar-debug.m index 83262a82a61b..8c323b75213e 100644 --- a/test/CodeGenObjC/objc2-weak-ivar-debug.m +++ b/test/CodeGenObjC/objc2-weak-ivar-debug.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s // rdar://7252252 @interface Loop { diff --git a/test/CodeGenObjC/objc2-weak-ivar.m b/test/CodeGenObjC/objc2-weak-ivar.m index 78ccdf8876cc..0c8503ed2ee4 100644 --- a/test/CodeGenObjC/objc2-weak-ivar.m +++ b/test/CodeGenObjC/objc2-weak-ivar.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s @class NSObject; @interface Foo { diff --git a/test/CodeGenObjC/objc2-write-barrier-2.m b/test/CodeGenObjC/objc2-write-barrier-2.m index eae2551aa074..6bc2f509083b 100644 --- a/test/CodeGenObjC/objc2-write-barrier-2.m +++ b/test/CodeGenObjC/objc2-write-barrier-2.m @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 7 // RUN: grep -F '@objc_assign_ivar' %t | count 5 // RUN: grep -F '@objc_assign_strongCast' %t | count 8 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 7 // RUN: grep -F '@objc_assign_ivar' %t | count 5 // RUN: grep -F '@objc_assign_strongCast' %t | count 8 diff --git a/test/CodeGenObjC/objc2-write-barrier-4.m b/test/CodeGenObjC/objc2-write-barrier-4.m index 4089920b0925..d01ed1934b39 100644 --- a/test/CodeGenObjC/objc2-write-barrier-4.m +++ b/test/CodeGenObjC/objc2-write-barrier-4.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_global %t | count 3 // RUN: grep objc_assign_strongCast %t | count 2 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_global %t | count 3 // RUN: grep objc_assign_strongCast %t | count 2 diff --git a/test/CodeGenObjC/objc2-write-barrier-5.m b/test/CodeGenObjC/objc2-write-barrier-5.m index 122fa9f3c0b7..65a71a5a1d35 100644 --- a/test/CodeGenObjC/objc2-write-barrier-5.m +++ b/test/CodeGenObjC/objc2-write-barrier-5.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_ivar %t | count 0 // RUN: grep objc_assign_strongCast %t | count 8 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_ivar %t | count 0 // RUN: grep objc_assign_strongCast %t | count 8 diff --git a/test/CodeGenObjC/objc2-write-barrier.m b/test/CodeGenObjC/objc2-write-barrier.m index bf2dfb9b14f9..7634dc97412a 100644 --- a/test/CodeGenObjC/objc2-write-barrier.m +++ b/test/CodeGenObjC/objc2-write-barrier.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 21 // RUN: grep -F '@objc_assign_ivar' %t | count 11 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 21 // RUN: grep -F '@objc_assign_ivar' %t | count 11 diff --git a/test/CodeGenObjC/object-incr-decr-1.m b/test/CodeGenObjC/object-incr-decr-1.m index 19c12cb315a2..c1181a21c720 100644 --- a/test/CodeGenObjC/object-incr-decr-1.m +++ b/test/CodeGenObjC/object-incr-decr-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o %t @interface Foo { diff --git a/test/CodeGenObjC/objfw.m b/test/CodeGenObjC/objfw.m new file mode 100644 index 000000000000..98e3fb02652d --- /dev/null +++ b/test/CodeGenObjC/objfw.m @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fobjc-runtime=objfw -emit-llvm -o - %s | FileCheck %s + +// Test the ObjFW runtime. + +@interface Test0 ++ (void) test; +@end +void test0(void) { + [Test0 test]; +} +// CHECK: define void @test0() +// CHECK: [[T0:%.*]] = call i8* (i8*, i8*, ...)* (i8*, i8*)* @objc_msg_lookup(i8* bitcast (i64* @_OBJC_CLASS_Test0 to i8*), +// CHECK-NEXT: [[T1:%.*]] = bitcast i8* (i8*, i8*, ...)* [[T0]] to void (i8*, i8*)* +// CHECK-NEXT: call void [[T1]](i8* bitcast (i64* @_OBJC_CLASS_Test0 to i8*), +// CHECK-NEXT: ret void diff --git a/test/CodeGenObjC/predefined-expr.m b/test/CodeGenObjC/predefined-expr.m index 009bbcdb013c..d5866bbdbed5 100644 --- a/test/CodeGenObjC/predefined-expr.m +++ b/test/CodeGenObjC/predefined-expr.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 %s -emit-llvm -o - | FileCheck %s // CHECK: @"__func__.-[Foo instanceTest1]" = private unnamed_addr constant [21 x i8] c"-[Foo instanceTest1]\00" // CHECK: @"__func__.-[Foo instanceTest2:]" = private unnamed_addr constant [22 x i8] c"-[Foo instanceTest2:]\00" diff --git a/test/CodeGenObjC/property-complex.m b/test/CodeGenObjC/property-complex.m index 3cdd2ecfd15d..027f6d632686 100644 --- a/test/CodeGenObjC/property-complex.m +++ b/test/CodeGenObjC/property-complex.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s @interface I0 { @public diff --git a/test/CodeGenObjC/property-ref-cast-to-void.m b/test/CodeGenObjC/property-ref-cast-to-void.m index ad1689fd6243..ae2a4583629b 100644 --- a/test/CodeGenObjC/property-ref-cast-to-void.m +++ b/test/CodeGenObjC/property-ref-cast-to-void.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar: // 8399655 @interface TestClass diff --git a/test/CodeGenObjC/protocol-in-extended-class.m b/test/CodeGenObjC/protocol-in-extended-class.m index a92408463deb..b919d5fd234a 100644 --- a/test/CodeGenObjC/protocol-in-extended-class.m +++ b/test/CodeGenObjC/protocol-in-extended-class.m @@ -1,7 +1,7 @@ // REQUIRES: x86-registered-target,x86-64-registered-target // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: %clang_cc1 -triple i386-apple-darwin -fobjc-fragile-abi -S %s -o %t-32.s +// RUN: %clang_cc1 -triple i386-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -S %s -o %t-32.s // RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s @protocol MyProtocol diff --git a/test/CodeGenObjC/protocols-lazy.m b/test/CodeGenObjC/protocols-lazy.m index 1c551fbeec11..877d4923f387 100644 --- a/test/CodeGenObjC/protocols-lazy.m +++ b/test/CodeGenObjC/protocols-lazy.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin8 -fobjc-fragile-abi -o %t %s +// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin8 -fobjc-runtime=macosx-fragile-10.5 -o %t %s // RUNX: llvm-gcc -S -emit-llvm -o %t %s && // No object generated diff --git a/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m b/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m index a93ca033c13c..fb808b3b771b 100644 --- a/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m +++ b/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions %s -o - +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions %s -o - void f0(id x) { @synchronized (x) { diff --git a/test/CodeGenObjC/super-message-fragileabi.m b/test/CodeGenObjC/super-message-fragileabi.m index 0135919b8946..b6c908624ef6 100644 --- a/test/CodeGenObjC/super-message-fragileabi.m +++ b/test/CodeGenObjC/super-message-fragileabi.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o - | FileCheck %s @class Some; diff --git a/test/CodeGenObjC/synchronized.m b/test/CodeGenObjC/synchronized.m index 4997bb77525e..1f012820f9ba 100644 --- a/test/CodeGenObjC/synchronized.m +++ b/test/CodeGenObjC/synchronized.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin9 -fobjc-fragile-abi -o - %s -O2 | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -o - %s -O2 | FileCheck %s @interface MyClass { diff --git a/test/CodeGenObjC/terminate.m b/test/CodeGenObjC/terminate.m index a86205839d45..8728ec4598bf 100644 --- a/test/CodeGenObjC/terminate.m +++ b/test/CodeGenObjC/terminate.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime-has-terminate -o - %s | FileCheck %s -check-prefix=CHECK-WITH -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITHOUT +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.8 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITH +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.7 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITHOUT void destroy(void**); diff --git a/test/CodeGenObjC/undefined-protocol.m b/test/CodeGenObjC/undefined-protocol.m index d87a5c999ee9..e5a72ab602f0 100644 --- a/test/CodeGenObjC/undefined-protocol.m +++ b/test/CodeGenObjC/undefined-protocol.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm-only -fgnu-runtime %s +// RUN: %clang_cc1 -emit-llvm-only -fobjc-runtime=gcc %s @protocol MadeUpProtocol; diff --git a/test/CodeGenObjC/variadic-sends.m b/test/CodeGenObjC/variadic-sends.m index 94d7bafba472..726b497b21b4 100644 --- a/test/CodeGenObjC/variadic-sends.m +++ b/test/CodeGenObjC/variadic-sends.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-32 %s -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-64 %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-32 %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-64 %s @interface A -(void) im0; diff --git a/test/CodeGenObjC/x86_64-struct-return-gc.m b/test/CodeGenObjC/x86_64-struct-return-gc.m index 76407d6654e0..dab5b15e284e 100644 --- a/test/CodeGenObjC/x86_64-struct-return-gc.m +++ b/test/CodeGenObjC/x86_64-struct-return-gc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o - %s | FileCheck %s struct Coerce { id a; }; diff --git a/test/CodeGenObjCXX/arc.mm b/test/CodeGenObjCXX/arc.mm index 45211a2c19ab..f31b993946e8 100644 --- a/test/CodeGenObjCXX/arc.mm +++ b/test/CodeGenObjCXX/arc.mm @@ -252,3 +252,19 @@ template class Test38 { }; // CHECK: define weak_odr void @_ZN6Test38IiE4testEi( template class Test38; + +// rdar://problem/11964832 +class Test39_base1 { + virtual void foo(); +}; +class Test39_base2 { + virtual id bar(); +}; +class Test39 : Test39_base1, Test39_base2 { // base2 is at non-zero offset + virtual id bar(); +}; +id Test39::bar() { return 0; } +// Note lack of autorelease. +// CHECK: define i8* @_ZThn8_N6Test393barEv( +// CHECK: call i8* @_ZN6Test393barEv( +// CHECK-NEXT: ret i8* diff --git a/test/CodeGenObjCXX/block-in-template-inst.mm b/test/CodeGenObjCXX/block-in-template-inst.mm index 93a0e4907d29..c280874dbb3f 100644 --- a/test/CodeGenObjCXX/block-in-template-inst.mm +++ b/test/CodeGenObjCXX/block-in-template-inst.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm-only -std=c++11 -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s +// RUN: %clang_cc1 -emit-llvm-only -std=c++11 -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s // rdar://9362021 @class DYFuture; diff --git a/test/CodeGenObjCXX/block-var-layout.mm b/test/CodeGenObjCXX/block-var-layout.mm index a8f8be0ea8a3..00dd2c00ef57 100644 --- a/test/CodeGenObjCXX/block-var-layout.mm +++ b/test/CodeGenObjCXX/block-var-layout.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o %t-64.ll +// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o %t-64.ll // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.ll %s // See commentary in test/CodeGenObjC/block-var-layout.m, from which diff --git a/test/CodeGenObjCXX/blocks.mm b/test/CodeGenObjCXX/blocks.mm index 126931d51fad..62ae428e5ec1 100644 --- a/test/CodeGenObjCXX/blocks.mm +++ b/test/CodeGenObjCXX/blocks.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-fragile-abi %s -verify -emit-llvm -o %t +// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -verify -std=c++11 -emit-llvm -o %t // rdar://8979379 @interface A @@ -30,7 +30,7 @@ void foo(id (^objectCreationBlock)(void)) { // Test4 struct S { - S *(^a)() = ^{ // expected-warning {{C++11}} + S *(^a)() = ^{ return this; }; }; @@ -40,7 +40,22 @@ S s; struct X { void f() { ^ { - struct Nested { Nested *ptr = this; }; // expected-warning {{C++11}} + struct Nested { Nested *ptr = this; }; } (); }; }; + +// Regression test for PR13314 +class FooClass { }; +void fun() { + FooClass foovar; + ^() { // expected-warning {{expression result unused}} + return foovar; + }; +} +void gun() { + FooClass foovar; + [=]() { // expected-warning {{expression result unused}} + return foovar; + }; +} diff --git a/test/CodeGenObjCXX/catch-id-type.mm b/test/CodeGenObjCXX/catch-id-type.mm index a5fa3e78fb59..2d6cccc0f129 100644 --- a/test/CodeGenObjCXX/catch-id-type.mm +++ b/test/CodeGenObjCXX/catch-id-type.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-macosx10.6.6 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions -fcxx-exceptions -fexceptions -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-macosx10.6.6 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -fcxx-exceptions -fexceptions -o - %s | FileCheck %s // rdar://8940528 @interface ns_array diff --git a/test/CodeGenObjCXX/copy.mm b/test/CodeGenObjCXX/copy.mm index 9382ee870a71..9e41bf026a76 100644 --- a/test/CodeGenObjCXX/copy.mm +++ b/test/CodeGenObjCXX/copy.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://problem/9158302 // This should not use a memmove_collectable in non-GC mode. diff --git a/test/CodeGenObjCXX/copyable-property-object.mm b/test/CodeGenObjCXX/copyable-property-object.mm index 03c0c06a41ee..b2ca85c4ca92 100644 --- a/test/CodeGenObjCXX/copyable-property-object.mm +++ b/test/CodeGenObjCXX/copyable-property-object.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s struct POD { int array[3][4]; diff --git a/test/CodeGenObjCXX/encode.mm b/test/CodeGenObjCXX/encode.mm index 8391c04b7da8..1b6a241fcffa 100644 --- a/test/CodeGenObjCXX/encode.mm +++ b/test/CodeGenObjCXX/encode.mm @@ -87,8 +87,8 @@ namespace rdar9357400 { typedef vector< float, fixed<4> > vector4f; - // CHECK: @_ZN11rdar9357400L2ggE = internal constant [49 x i8] c"{vector >=[4f]}\00" - const char gg[] = @encode(vector4f); + // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00" + extern const char gg[] = @encode(vector4f); } // rdar://9624314 @@ -97,12 +97,12 @@ namespace rdar9624314 { struct B3 {}; struct S : B2, B3 {}; - // CHECK: @_ZN11rdar9624314L2ggE = internal constant [6 x i8] c"{S=i}\00" - const char gg[] = @encode(S); + // CHECK: @_ZN11rdar96243142ggE = constant [6 x i8] c"{S=i}\00" + extern const char gg[] = @encode(S); struct S2 { unsigned : 0; int x; unsigned : 0; }; - // CHECK: @_ZN11rdar9624314L2g2E = internal constant [11 x i8] c"{S2=b0ib0}\00" - const char g2[] = @encode(S2); + // CHECK: @_ZN11rdar96243142g2E = constant [11 x i8] c"{S2=b0ib0}\00" + extern const char g2[] = @encode(S2); } namespace test { @@ -122,8 +122,8 @@ namespace test { int y; }; - // CHECK: @_ZN4testL3ecdE = internal constant [15 x i8] c"{Zoo=^^?ii^^?}\00" - const char ecd[] = @encode(Zoo); + // CHECK: @_ZN4test3ecdE = constant [15 x i8] c"{Zoo=^^?ii^^?}\00" + extern const char ecd[] = @encode(Zoo); } struct Base1 { @@ -143,17 +143,17 @@ struct Sub2 : public Sub_with_virt, public Base1, virtual DBase { float x; }; -// CHECK: @_ZL2g1 = internal constant [10 x i8] c"{Base1=c}\00" -const char g1[] = @encode(Base1); +// CHECK: @g1 = constant [10 x i8] c"{Base1=c}\00" +extern const char g1[] = @encode(Base1); -// CHECK: @_ZL2g2 = internal constant [14 x i8] c"{DBase=^^?cd}\00" -const char g2[] = @encode(DBase); +// CHECK: @g2 = constant [14 x i8] c"{DBase=^^?cd}\00" +extern const char g2[] = @encode(DBase); -// CHECK: @_ZL2g3 = internal constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00" -const char g3[] = @encode(Sub_with_virt); +// CHECK: @g3 = constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00" +extern const char g3[] = @encode(Sub_with_virt); -// CHECK: @_ZL2g4 = internal constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00" -const char g4[] = @encode(Sub2); +// CHECK: @g4 = constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00" +extern const char g4[] = @encode(Sub2); // http://llvm.org/PR9927 class allocator { @@ -165,8 +165,8 @@ char* _M_p; _Alloc_hider _M_dataplus; }; -// CHECK: @_ZL2g5 = internal constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00" -const char g5[] = @encode(basic_string); +// CHECK: @g5 = constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00" +extern const char g5[] = @encode(basic_string); // PR10990 @@ -175,8 +175,8 @@ class CefBase { }; class CefBrowser : public virtual CefBase {}; class CefBrowserImpl : public CefBrowser {}; -// CHECK: @_ZL2g6 = internal constant [21 x i8] c"{CefBrowserImpl=^^?}\00" -const char g6[] = @encode(CefBrowserImpl); +// CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00" +extern const char g6[] = @encode(CefBrowserImpl); // PR10990_2 class CefBase2 { @@ -185,5 +185,19 @@ class CefBase2 { }; class CefBrowser2 : public virtual CefBase2 {}; class CefBrowserImpl2 : public CefBrowser2 {}; -// CHECK: @_ZL2g7 = internal constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00" -const char g7[] = @encode(CefBrowserImpl2); +// CHECK: @g7 = constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00" +extern const char g7[] = @encode(CefBrowserImpl2); + +// +struct Empty {}; + +struct X : Empty { + int array[10]; +}; + +struct Y : Empty { + X vec; +}; + +// CHECK: @g8 = constant [14 x i8] c"{Y={X=[10i]}}\00" +extern const char g8[] = @encode(Y); diff --git a/test/CodeGenObjCXX/gc.mm b/test/CodeGenObjCXX/gc.mm index 1e9fe00fd060..a504892bcbdf 100644 --- a/test/CodeGenObjCXX/gc.mm +++ b/test/CodeGenObjCXX/gc.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s namespace test0 { extern id x; diff --git a/test/CodeGenObjCXX/implicit-copy-assign-operator.mm b/test/CodeGenObjCXX/implicit-copy-assign-operator.mm index 0a6e08e2ff62..29ec9acd381d 100644 --- a/test/CodeGenObjCXX/implicit-copy-assign-operator.mm +++ b/test/CodeGenObjCXX/implicit-copy-assign-operator.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -emit-llvm -triple x86_64-apple-darwin10.0.0 -fobjc-fragile-abi -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -emit-llvm -triple x86_64-apple-darwin10.0.0 -fobjc-runtime=macosx-fragile-10.5 -o - %s | FileCheck %s struct A { A &operator=(const A&); A &operator=(A&); diff --git a/test/CodeGenObjCXX/implicit-copy-constructor.mm b/test/CodeGenObjCXX/implicit-copy-constructor.mm index 63dd4f084cd8..5cd6f42a6c42 100644 --- a/test/CodeGenObjCXX/implicit-copy-constructor.mm +++ b/test/CodeGenObjCXX/implicit-copy-constructor.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s struct A { A(); diff --git a/test/CodeGenObjCXX/lambda-expressions.mm b/test/CodeGenObjCXX/lambda-expressions.mm index 858cb74aa2a5..ec3eb1fda50b 100644 --- a/test/CodeGenObjCXX/lambda-expressions.mm +++ b/test/CodeGenObjCXX/lambda-expressions.mm @@ -9,7 +9,7 @@ fp f() { auto x = []{ return 3; }; return x; } // MRC: define i32 ()* @_Z1fv( // MRC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv" // MRC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*) -// MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*) +// MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke" to i8*) // MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*) // MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*) // MRC: ret i32 ()* @@ -17,7 +17,7 @@ fp f() { auto x = []{ return 3; }; return x; } // ARC: define i32 ()* @_Z1fv( // ARC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv" // ARC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*) -// ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*) +// ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke" to i8*) // ARC: call i8* @objc_retainBlock // ARC: call i8* @objc_autoreleaseReturnValue @@ -26,14 +26,14 @@ fp global; void f2() { global = []{ return 3; }; } // MRC: define void @_Z2f2v() nounwind { -// MRC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*), +// MRC: store i8* bitcast (i32 (i8*)* @___Z2f2v_block_invoke to i8*), // MRC-NOT: call // MRC: ret void // ("global" contains a dangling pointer after this function runs.) // ARC: define void @_Z2f2v() nounwind { -// ARC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*), +// ARC: store i8* bitcast (i32 (i8*)* @___Z2f2v_block_invoke to i8*), // ARC: call i8* @objc_retainBlock // ARC: call void @objc_release -// ARC: define internal i32 @__f2_block_invoke_0 +// ARC: define internal i32 @___Z2f2v_block_invoke // ARC: call i32 @"_ZZ2f2vENK3$_1clEv diff --git a/test/CodeGenObjCXX/mangle-blocks.mm b/test/CodeGenObjCXX/mangle-blocks.mm index fcbc60860884..892c8afedebf 100644 --- a/test/CodeGenObjCXX/mangle-blocks.mm +++ b/test/CodeGenObjCXX/mangle-blocks.mm @@ -1,19 +1,19 @@ -// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s -// CHECK: @_ZGVN3foo20__foo_block_invoke_05valueE = internal global i64 0 +// CHECK: @_ZGVN3foo22___Z3foov_block_invoke5valueE = internal global i64 0 int f(); void foo() { - // CHECK: define internal i32 @__foo_block_invoke_0 - // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo20__foo_block_invoke_05value + // CHECK: define internal i32 @___Z3foov_block_invoke + // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo22___Z3foov_block_invoke5valueE (void)^(int x) { static int value = f(); return x + value; }; } -// CHECK: define internal i32 @__block_global_0 +// CHECK: define internal i32 @i_block_invoke int i = ^(int x) { return x;}(i); @interface A @@ -22,9 +22,9 @@ int i = ^(int x) { return x;}(i); @implementation A - (void)method { - // CHECK: define internal signext i8 @"__11-[A method]_block_invoke_0" + // CHECK: define internal signext i8 @"__11-[A method]_block_invoke" (void)^(int x) { - // CHECK: @"_ZN11-[A method]30__11-[A method]_block_invoke_04nameE" + // CHECK: @"_ZN11-[A method]28__11-[A method]_block_invoke4nameE" static const char *name = "hello"; return name[x]; }; @@ -39,10 +39,10 @@ void foo(int) { } namespace N { - // CHECK: define internal signext i8 @__bar_block_invoke_0 + // CHECK: define internal signext i8 @___Z3fooi_block_invoke void bar() { (void)^(int x) { - // CHECK: @_ZN1N3bar20__bar_block_invoke_04nameE + // CHECK: @_ZN1N3bar26___ZN1N3barEv_block_invoke4nameE static const char *name = "hello"; return name[x]; }; diff --git a/test/CodeGenObjCXX/message-reference.mm b/test/CodeGenObjCXX/message-reference.mm index fa41fef4c909..0d1bbc7bb0d4 100644 --- a/test/CodeGenObjCXX/message-reference.mm +++ b/test/CodeGenObjCXX/message-reference.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://8604515 @interface I {} diff --git a/test/CodeGenObjCXX/nrvo.mm b/test/CodeGenObjCXX/nrvo.mm index ef5052eea603..47460c2fb3db 100644 --- a/test/CodeGenObjCXX/nrvo.mm +++ b/test/CodeGenObjCXX/nrvo.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - -fblocks %s -O1 -triple x86_64-apple-darwin10.0.0 -fobjc-fragile-abi | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -fblocks %s -O1 -triple x86_64-apple-darwin10.0.0 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s // PR10835 / struct X { @@ -22,7 +22,7 @@ struct X { X blocksNRVO() { return ^{ - // CHECK: define internal void @__blocksNRVO_block_invoke_0 + // CHECK: define internal void @___Z10blocksNRVOv_block_invoke X x; // CHECK: tail call void @_ZN1XC1Ev // CHECK-NEXT: ret void diff --git a/test/CodeGenObjCXX/property-derived-to-base-conv.mm b/test/CodeGenObjCXX/property-derived-to-base-conv.mm index ddca857fbab0..5784f2be9cec 100644 --- a/test/CodeGenObjCXX/property-derived-to-base-conv.mm +++ b/test/CodeGenObjCXX/property-derived-to-base-conv.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s // rdar: // 7501812 struct A { diff --git a/test/CodeGenObjCXX/property-object-conditional-exp.mm b/test/CodeGenObjCXX/property-object-conditional-exp.mm index 281076e47f4d..899c2c80baee 100644 --- a/test/CodeGenObjCXX/property-object-conditional-exp.mm +++ b/test/CodeGenObjCXX/property-object-conditional-exp.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s struct CGRect { char* origin; diff --git a/test/CodeGenObjCXX/property-object-reference-2.mm b/test/CodeGenObjCXX/property-object-reference-2.mm index b150a3e3ea97..2a380385bc9d 100644 --- a/test/CodeGenObjCXX/property-object-reference-2.mm +++ b/test/CodeGenObjCXX/property-object-reference-2.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-10.7 -emit-llvm -o - | FileCheck %s // rdar://6137845 extern int DEFAULT(); diff --git a/test/CodeGenObjCXX/property-object-reference.mm b/test/CodeGenObjCXX/property-object-reference.mm index 0bd8fb8b9ff2..ec311f1956a4 100644 --- a/test/CodeGenObjCXX/property-object-reference.mm +++ b/test/CodeGenObjCXX/property-object-reference.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - | FileCheck %s // rdar://10188258 struct Foo {int i;}; diff --git a/test/CodeGenObjCXX/property-reference.mm b/test/CodeGenObjCXX/property-reference.mm index 4897f6d0e8f4..0e4897b74947 100644 --- a/test/CodeGenObjCXX/property-reference.mm +++ b/test/CodeGenObjCXX/property-reference.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - | FileCheck %s // rdar://9208606 struct MyStruct { diff --git a/test/CodeGenObjCXX/refence-assign-write-barrier.mm b/test/CodeGenObjCXX/refence-assign-write-barrier.mm index 206ecb0c29e3..ad277ef6d596 100644 --- a/test/CodeGenObjCXX/refence-assign-write-barrier.mm +++ b/test/CodeGenObjCXX/refence-assign-write-barrier.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://8681766 @interface NSArray diff --git a/test/CodeGenObjCXX/selector-expr-lvalue.mm b/test/CodeGenObjCXX/selector-expr-lvalue.mm index 3e3bf4ecf20e..508ea83f0d51 100644 --- a/test/CodeGenObjCXX/selector-expr-lvalue.mm +++ b/test/CodeGenObjCXX/selector-expr-lvalue.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s // PR7390 @interface NSObject {} diff --git a/test/CodeGenObjCXX/write-barrier-global-assign.mm b/test/CodeGenObjCXX/write-barrier-global-assign.mm index cb563f339565..539e21fcfbee 100644 --- a/test/CodeGenObjCXX/write-barrier-global-assign.mm +++ b/test/CodeGenObjCXX/write-barrier-global-assign.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://8761767 @class CPDestUser; diff --git a/test/CodeGenOpenCL/kernel-arg-info.cl b/test/CodeGenOpenCL/kernel-arg-info.cl new file mode 100644 index 000000000000..9d52736a76d8 --- /dev/null +++ b/test/CodeGenOpenCL/kernel-arg-info.cl @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 %s -cl-kernel-arg-info -emit-llvm -o - | FileCheck %s + +kernel void foo(int *X, int Y, int anotherArg) { + *X = Y + anotherArg; +} + +// CHECK: metadata !{metadata !"kernel_arg_name", metadata !"X", metadata !"Y", metadata !"anotherArg"} diff --git a/test/CodeGenOpenCL/kernel-attributes.cl b/test/CodeGenOpenCL/kernel-attributes.cl new file mode 100644 index 000000000000..de16a4145315 --- /dev/null +++ b/test/CodeGenOpenCL/kernel-attributes.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -emit-llvm -O0 -o - %s | FileCheck %s + +kernel __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {} + +kernel __attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {} + +// CHECK: opencl.kernels = !{[[MDNODE0:![0-9]+]], [[MDNODE3:![0-9]+]]} + +// CHECK: [[MDNODE0]] = metadata !{void (i32)* @kernel1, metadata [[MDNODE2:![0-9]+]]} +// CHECK: [[MDNODE2]] = metadata !{metadata !"reqd_work_group_size", i32 1, i32 2, i32 4} +// CHECK: [[MDNODE3]] = metadata !{void (i32)* @kernel2, metadata [[MDNODE5:![0-9]+]]} +// CHECK: [[MDNODE5]] = metadata !{metadata !"work_group_size_hint", i32 8, i32 16, i32 32} diff --git a/test/CodeGenOpenCL/ptx-calls.cl b/test/CodeGenOpenCL/ptx-calls.cl index 6f336405c301..34a21c6c1da9 100644 --- a/test/CodeGenOpenCL/ptx-calls.cl +++ b/test/CodeGenOpenCL/ptx-calls.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s void device_function() { } diff --git a/test/CodeGenOpenCL/ptx-kernels.cl b/test/CodeGenOpenCL/ptx-kernels.cl index 4d6fa1084d4b..1d7e497b7c01 100644 --- a/test/CodeGenOpenCL/ptx-kernels.cl +++ b/test/CodeGenOpenCL/ptx-kernels.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -emit-llvm -o - | FileCheck %s void device_function() { } diff --git a/test/Coverage/codegen-gnu.m b/test/Coverage/codegen-gnu.m index 432637c7e1ac..67f99064a6ab 100644 --- a/test/Coverage/codegen-gnu.m +++ b/test/Coverage/codegen-gnu.m @@ -1,3 +1,3 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-exceptions -fgnu-runtime -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-exceptions -fobjc-runtime=gcc -emit-llvm -o %t %s #include "objc-language-features.inc" diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_dynamic.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_dynamic.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_so.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_so.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_static.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_static.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_android.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_android.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_so.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_so.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/mips-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/mips-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/mipsel-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/mipsel-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mips-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mips-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mipsel-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mipsel-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/mips-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/mips-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/mipsel-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/mipsel-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/n32/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/n32/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/n32/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/n32/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mips-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mips-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mipsel-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mipsel-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/crtbegin.o b/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/crtbegin.o new file mode 100644 index 000000000000..26d251da3967 --- /dev/null +++ b/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/crtbegin.o @@ -0,0 +1 @@ +dummy file for gcc toolchain detection (crtbegin.o) diff --git a/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a b/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a new file mode 100644 index 000000000000..d7969288d9b2 --- /dev/null +++ b/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a @@ -0,0 +1 @@ +dummy file for gcc toolchain detection (libgcc.a) diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabi/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabi/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabihf/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabihf/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabi/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabi/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabihf/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabihf/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/Driver/altivec.cpp b/test/Driver/altivec.cpp index 6059ad09e7c5..a8936360a3db 100644 --- a/test/Driver/altivec.cpp +++ b/test/Driver/altivec.cpp @@ -1,7 +1,8 @@ // Check that we error when -faltivec is specified on non-ppc platforms. -// RUN: %clang -ccc-clang-archs powerpc -target powerpc-apple-darwin -faltivec -fsyntax-only %s +// RUN: %clang -ccc-clang-archs powerpc -target powerpc-unk-unk -faltivec -fsyntax-only %s // RUN: %clang -ccc-clang-archs powerpc64 -target powerpc64-linux-gnu -faltivec -fsyntax-only %s +// RUN: %clang -ccc-clang-archs powerpc64 -target powerpc64-linux-gnu -maltivec -fsyntax-only %s // RUN: %clang -target i386-pc-win32 -faltivec -fsyntax-only %s 2>&1 | FileCheck %s // RUN: %clang -target x86_64-unknown-freebsd -faltivec -fsyntax-only %s 2>&1 | FileCheck %s diff --git a/test/Driver/apple-kext-i386.cpp b/test/Driver/apple-kext-i386.cpp index c11a1361a1a3..eb9f9578e9cb 100644 --- a/test/Driver/apple-kext-i386.cpp +++ b/test/Driver/apple-kext-i386.cpp @@ -41,6 +41,11 @@ // CHECK-UNSUPPORTED2: cc1plus" // CHECK-UNSUPPORTED2-NOT: "-Wconstant-logical-operand" +// Check that -serialize-diagnostics does not cause an "argument unused" error. +// RUN: %clang -target i386-apple-darwin10 \ +// RUN: -Wall -fapple-kext -### -serialize-diagnostics %t.dia -c %s 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-UNUSED %s + // Check that --serialize-diagnostics does not cause an "argument unused" error. // RUN: %clang -target i386-apple-darwin10 \ // RUN: -Wall -fapple-kext -### --serialize-diagnostics %t.dia -c %s 2>&1 | \ diff --git a/test/Driver/arc.c b/test/Driver/arc.c index f2c1127116a0..5a5720c04aee 100644 --- a/test/Driver/arc.c +++ b/test/Driver/arc.c @@ -8,10 +8,10 @@ // Just to test clang is working. # foo -// CHECK: error: -fobjc-arc is not supported with fragile abi +// CHECK: error: -fobjc-arc is not supported with legacy abi // CHECK-NOT: invalid preprocessing directive -// NOTOBJC-NOT: error: -fobjc-arc is not supported with fragile abi +// NOTOBJC-NOT: error: -fobjc-arc is not supported with legacy abi // NOTOBJC: invalid preprocessing directive // UNSUPPORTED: error: -fobjc-arc is not supported on current deployment target diff --git a/test/Driver/arclite-link.c b/test/Driver/arclite-link.c index 9cf1efe987ca..3471bf6516a2 100644 --- a/test/Driver/arclite-link.c +++ b/test/Driver/arclite-link.c @@ -1,8 +1,17 @@ // RUN: touch %t.o -// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s +// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.8 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s +// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s +// CHECK-ARCLITE-OSX: -lfoo // CHECK-ARCLITE-OSX: libarclite_macosx.a +// CHECK-ARCLITE-OSX: -framework +// CHECK-ARCLITE-OSX: Foundation // CHECK-ARCLITE-OSX: -lobjc // CHECK-NOARCLITE-NOT: libarclite +// CHECK-NOSTDLIB-NOT: -lobjc + +// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -fobjc-arc -mmacosx-version-min=10.7 %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED %s + +// CHECK-UNUSED-NOT: warning: argument unused during compilation: '-fobjc-link-runtime' diff --git a/test/Driver/asan-ld.c b/test/Driver/asan-ld.c new file mode 100644 index 000000000000..daf046b53716 --- /dev/null +++ b/test/Driver/asan-ld.c @@ -0,0 +1,31 @@ +// Test AddressSanitizer ld flags. + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -faddress-sanitizer \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-LINUX %s +// CHECK-LINUX: "{{.*}}ld{{(.exe)?}}" +// CHECK-LINUX-NOT: "-lc" +// CHECK-LINUX: libclang_rt.asan-i386.a" +// CHECK-LINUX: "-lpthread" +// CHECK-LINUX: "-ldl" +// CHECK-LINUX: "-export-dynamic" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -faddress-sanitizer \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s +// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" +// CHECK-ANDROID-NOT: "-lc" +// CHECK-ANDROID: "-u" "__asan_preinit" "-lasan" +// CHECK-ANDROID: "-lasan_preload" "-ldl" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -faddress-sanitizer \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: -shared \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SHARED %s +// CHECK-ANDROID-SHARED: "{{.*}}ld{{(.exe)?}}" +// CHECK-ANDROID-SHARED-NOT: "-lc" +// CHECK-ANDROID-SHARED-NOT: "-lasan" +// CHECK-ANDROID-SHARED: "-lasan_preload" "-ldl" diff --git a/test/Driver/bounds-checking.c b/test/Driver/bounds-checking.c new file mode 100644 index 000000000000..95bb8afd0d8b --- /dev/null +++ b/test/Driver/bounds-checking.c @@ -0,0 +1,7 @@ +// RUN: %clang -target x86_64-apple-darwin10 -fbounds-checking -### -fsyntax-only %s 2> %t +// RUN: FileCheck < %t %s +// RUN: %clang -target x86_64-apple-darwin10 -fbounds-checking=3 -### -fsyntax-only %s 2> %t +// RUN: FileCheck -check-prefix=CHECK2 < %t %s + +// CHECK: "-fbounds-checking=1" +// CHECK2: "-fbounds-checking=3" diff --git a/test/Driver/ccc-as-cpp.c b/test/Driver/ccc-as-cpp.c new file mode 100644 index 000000000000..feead5191db1 --- /dev/null +++ b/test/Driver/ccc-as-cpp.c @@ -0,0 +1,6 @@ +// REQUIRES: shell +// RUN: ln -sf %clang %T/clang-cpp + +// PR13529: Don't crash. +// RUN: %T/clang-cpp -lfoo -M %s 2>&1 | FileCheck --check-prefix=CHECK-PR13529 %s +// CHECK-PR13529: warning: -lfoo: 'linker' input unused in cpp mode diff --git a/test/Driver/clang-translation.c b/test/Driver/clang-translation.c index 0e82de4af3e4..76196da9fc3d 100644 --- a/test/Driver/clang-translation.c +++ b/test/Driver/clang-translation.c @@ -44,3 +44,33 @@ // ARMV7_HARDFLOAT: "-mfloat-abi" "hard" // ARMV7_HARDFLOAT-NOT: "-msoft-float" // ARMV7_HARDFLOAT: "-x" "c" + +// RUN: %clang -target arm-linux -### -S %s 2> %t.log \ +// RUN: -march=armv5e +// RUN: FileCheck -check-prefix=ARMV5E %s < %t.log +// ARMV5E: clang +// ARMV5E: "-cc1" +// ARMV5E: "-target-cpu" "arm1022e" + +// RUN: %clang -ccc-clang-archs powerpc64 \ +// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log \ +// RUN: -mcpu=G5 +// RUN: FileCheck -check-prefix=PPCG5 %s < %t.log +// PPCG5: clang +// PPCG5: "-cc1" +// PPCG5: "-target-cpu" "g5" + +// RUN: %clang -ccc-clang-archs powerpc64 \ +// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log \ +// RUN: -mcpu=power7 +// RUN: FileCheck -check-prefix=PPCPWR7 %s < %t.log +// PPCPWR7: clang +// PPCPWR7: "-cc1" +// PPCPWR7: "-target-cpu" "pwr7" + +// RUN: %clang -ccc-clang-archs powerpc64 \ +// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log +// RUN: FileCheck -check-prefix=PPC64NS %s < %t.log +// PPC64NS: clang +// PPC64NS: "-cc1" +// PPC64NS: "-target-cpu" "ppc64" diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c index 4eed4aa06f3f..0ee7d2dabe70 100644 --- a/test/Driver/clang_f_opts.c +++ b/test/Driver/clang_f_opts.c @@ -29,3 +29,12 @@ // RUN: %clang -### -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s // DEPRECATED-ON-CHECK: -fdeprecated-macro // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro + +// RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s +// RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s +// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// FP-CONTRACT-FAST-CHECK: -ffp-contract=fast +// FP-CONTRACT-OFF-CHECK: -ffp-contract=off + +// RUN: %clang -fms-extensions -fenable-experimental-ms-inline-asm %s -### 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS3 %s +// CHECK-OPTIONS3: -fenable-experimental-ms-inline-asm diff --git a/test/Driver/clang_f_opts.h b/test/Driver/clang_f_opts.h new file mode 100644 index 000000000000..e48d0cfc7c13 --- /dev/null +++ b/test/Driver/clang_f_opts.h @@ -0,0 +1,2 @@ +// RUN: %clang -### -fsyntax-only %s 2>&1 | FileCheck %s +// CHECK: -fsyntax-only diff --git a/test/Driver/constructors.c b/test/Driver/constructors.c new file mode 100644 index 000000000000..ca2cac22934e --- /dev/null +++ b/test/Driver/constructors.c @@ -0,0 +1,14 @@ +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: --sysroot=%S/Inputs/fake_install_tree \ +// RUN: | FileCheck --check-prefix=CHECK-GCC-4-7 %s + +// CHECK-GCC-4-7: -fuse-init-array + +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-GCC-4-6 %s + + +// CHECK-GCC-4-6-NOT: -fuse-init-array diff --git a/test/Driver/crash-report.c b/test/Driver/crash-report.c new file mode 100644 index 000000000000..7adaf42a2c95 --- /dev/null +++ b/test/Driver/crash-report.c @@ -0,0 +1,27 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: env TMPDIR=%t TEMP=%t TMP=%t %clang -fsyntax-only %s \ +// RUN: -F/tmp/ -I /tmp/ -idirafter /tmp/ -iquote /tmp/ -isystem /tmp/ \ +// RUN: -iprefix /the/prefix -iwithprefix /tmp -iwithprefixbefore /tmp/ \ +// RUN: -internal-isystem /tmp/ -internal-externc-isystem /tmp/ \ +// RUN: -DFOO=BAR 2>&1 | FileCheck %s +// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s +// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s +// REQUIRES: crash-recovery + +#pragma clang __debug parser_crash +// CHECK: Preprocessed source(s) and associated run script(s) are located at: +// CHECK-NEXT: note: diagnostic msg: {{.*}}.c +FOO +// CHECKSRC: FOO +// CHECKSH: -D "FOO=BAR" +// CHECKSH-NOT: -F/tmp/ +// CHECKSH-NOT: -I /tmp/ +// CHECKSH-NOT: -idirafter /tmp/ +// CHECKSH-NOT: -iquote /tmp/ +// CHECKSH-NOT: -isystem /tmp/ +// CHECKSH-NOT: -iprefix /the/prefix +// CHECKSH-NOT: -iwithprefix /tmp/ +// CHECKSH-NOT: -iwithprefixbefore /tmp/ +// CHECKSH-NOT: -internal-isystem /tmp/ +// CHECKSH-NOT: -internal-externc-isystem /tmp/ diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c index 3206f654d5c0..4cda37f9b2e3 100644 --- a/test/Driver/darwin-ld.c +++ b/test/Driver/darwin-ld.c @@ -121,3 +121,8 @@ // RUN: %clang -target x86_64-apple-darwin12 -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=LINK_NO_CRT1 %s < %t.log // LINK_NO_CRT1-NOT: crt + +// RUN: %clang -target i386-apple-darwin12 -pg -### %t.o 2> %t.log +// RUN: FileCheck -check-prefix=LINK_PG %s < %t.log +// LINK_PG: -lgcrt1.o +// LINK_PG: -no_new_main diff --git a/test/Driver/darwin-objc-defaults.m b/test/Driver/darwin-objc-defaults.m index 49fe8f9b9f7c..6265cfb41f10 100644 --- a/test/Driver/darwin-objc-defaults.m +++ b/test/Driver/darwin-objc-defaults.m @@ -7,7 +7,7 @@ // RUN: FileCheck --check-prefix CHECK-I386_OSX10_5 < %t %s // CHECK-CHECK-I386_OSX10_5: "-cc1" -// CHECK-CHECK-I386_OSX10_5: -fobjc-fragile-abi +// CHECK-CHECK-I386_OSX10_5: -fobjc-runtime=macosx-fragile-10.5 // CHECK-CHECK-I386_OSX10_5-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_OSX10_5: darwin-objc-defaults @@ -16,7 +16,7 @@ // RUN: FileCheck --check-prefix CHECK-I386_OSX10_6 < %t %s // CHECK-CHECK-I386_OSX10_6: "-cc1" -// CHECK-CHECK-I386_OSX10_6: -fobjc-fragile-abi +// CHECK-CHECK-I386_OSX10_6: -fobjc-runtime=macosx-fragile-10.6 // CHECK-CHECK-I386_OSX10_6-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_OSX10_6: darwin-objc-defaults @@ -25,7 +25,7 @@ // RUN: FileCheck --check-prefix CHECK-I386_IPHONE3_0 < %t %s // CHECK-CHECK-I386_IPHONE3_0: "-cc1" -// CHECK-CHECK-I386_IPHONE3_0: -fobjc-fragile-abi +// CHECK-CHECK-I386_IPHONE3_0: -fobjc-runtime=ios-3.0 // CHECK-CHECK-I386_IPHONE3_0-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_IPHONE3_0: darwin-objc-defaults @@ -36,7 +36,7 @@ // RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_5 < %t %s // CHECK-CHECK-X86_64_OSX10_5: "-cc1" -// CHECK-CHECK-X86_64_OSX10_5-NOT: -fobjc-fragile-abi +// CHECK-CHECK-X86_64_OSX10_5: -fobjc-runtime=macosx-10.5 // CHECK-CHECK-X86_64_OSX10_5: -fobjc-dispatch-method=non-legacy // CHECK-CHECK-X86_64_OSX10_5: darwin-objc-defaults @@ -45,7 +45,7 @@ // RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_6 < %t %s // CHECK-CHECK-X86_64_OSX10_6: "-cc1" -// CHECK-CHECK-X86_64_OSX10_6-NOT: -fobjc-fragile-abi +// CHECK-CHECK-X86_64_OSX10_6: -fobjc-runtime=macosx-10.6 // CHECK-CHECK-X86_64_OSX10_6: -fobjc-dispatch-method=mixed // CHECK-CHECK-X86_64_OSX10_6: darwin-objc-defaults @@ -54,7 +54,7 @@ // RUN: FileCheck --check-prefix CHECK-X86_64_IPHONE3_0 < %t %s // CHECK-CHECK-X86_64_IPHONE3_0: "-cc1" -// CHECK-CHECK-X86_64_IPHONE3_0-NOT: -fobjc-fragile-abi +// CHECK-CHECK-X86_64_IPHONE3_0: -fobjc-runtime=ios-3.0 // CHECK-CHECK-X86_64_IPHONE3_0: -fobjc-dispatch-method=mixed // CHECK-CHECK-X86_64_IPHONE3_0: darwin-objc-defaults @@ -65,7 +65,7 @@ // RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_5 < %t %s // CHECK-CHECK-ARMV7_OSX10_5: "-cc1" -// CHECK-CHECK-ARMV7_OSX10_5-NOT: -fobjc-fragile-abi +// CHECK-CHECK-ARMV7_OSX10_5: -fobjc-runtime=macosx-10.5 // CHECK-CHECK-ARMV7_OSX10_5-NOT: -fobjc-dispatch-method // CHECK-CHECK-ARMV7_OSX10_5: darwin-objc-defaults @@ -74,7 +74,7 @@ // RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_6 < %t %s // CHECK-CHECK-ARMV7_OSX10_6: "-cc1" -// CHECK-CHECK-ARMV7_OSX10_6-NOT: -fobjc-fragile-abi +// CHECK-CHECK-ARMV7_OSX10_6: -fobjc-runtime=macosx-10.6 // CHECK-CHECK-ARMV7_OSX10_6-NOT: -fobjc-dispatch-method // CHECK-CHECK-ARMV7_OSX10_6: darwin-objc-defaults @@ -83,6 +83,6 @@ // RUN: FileCheck --check-prefix CHECK-ARMV7_IPHONE3_0 < %t %s // CHECK-CHECK-ARMV7_IPHONE3_0: "-cc1" -// CHECK-CHECK-ARMV7_IPHONE3_0-NOT: -fobjc-fragile-abi +// CHECK-CHECK-ARMV7_IPHONE3_0: -fobjc-runtime=ios-3.0 // CHECK-CHECK-ARMV7_IPHONE3_0-NOT: -fobjc-dispatch-method // CHECK-CHECK-ARMV7_IPHONE3_0: darwin-objc-defaults diff --git a/test/Driver/darwin-objc-options.m b/test/Driver/darwin-objc-options.m index 5b421d891ff4..77501ab1b914 100644 --- a/test/Driver/darwin-objc-options.m +++ b/test/Driver/darwin-objc-options.m @@ -5,7 +5,7 @@ // RUN: FileCheck --check-prefix CHECK-X86_64_ABI1 < %t %s // CHECK-CHECK-X86_64_ABI1: "-cc1" -// CHECK-CHECK-X86_64_ABI1: -fobjc-fragile-abi +// CHECK-CHECK-X86_64_ABI1: -fobjc-runtime=macosx-fragile-10.6.0 // CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-dispatch-method // CHECK-CHECK-X86_64_ABI1: darwin-objc-options @@ -14,8 +14,19 @@ // RUN: FileCheck --check-prefix CHECK-I386_ABI2 < %t %s // CHECK-CHECK-I386_ABI2: "-cc1" -// CHECK-CHECK-I386_ABI2-NOT: -fobjc-fragile-abi +// CHECK-CHECK-I386_ABI2: -fobjc-runtime=macosx-10.6.0 // CHECK-CHECK-I386_ABI2: -fobjc-exceptions // CHECK-CHECK-I386_ABI2: -fexceptions // CHECK-CHECK-I386_ABI2-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_ABI2: darwin-objc-options + +// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch i386 -fobjc-runtime=ios-5.0 2> %t +// RUN: FileCheck --check-prefix CHECK-I386_IOS < %t %s + +// CHECK-CHECK-I386_IOS: "-cc1" +// CHECK-CHECK-I386_IOS: -fobjc-runtime=ios-5.0 +// CHECK-CHECK-I386_IOS: -fobjc-exceptions +// CHECK-CHECK-I386_IOS: -fexceptions +// CHECK-CHECK-I386_IOS-NOT: -fobjc-dispatch-method +// CHECK-CHECK-I386_IOS: darwin-objc-options diff --git a/test/Driver/debug-options-as.c b/test/Driver/debug-options-as.c index a1dbe2e048df..57036e42db07 100644 --- a/test/Driver/debug-options-as.c +++ b/test/Driver/debug-options-as.c @@ -4,7 +4,8 @@ // Check to make sure clang is somewhat picky about -g options. // (Delived from debug-options.c) // rdar://10383444 -// RUN: %clang -### -c -save-temps -g %s 2>&1 | FileCheck -check-prefix=SAVE %s +// RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \ +// RUN: | FileCheck -check-prefix=SAVE %s // // SAVE: "-cc1as" // SAVE-NOT: "-g" @@ -12,7 +13,8 @@ // Check to make sure clang with -g on a .s file gets passed. // rdar://9275556 // RUN: touch %t.s -// RUN: %clang -### -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s +// RUN: %clang -### -c -integrated-as -g %t.s 2>&1 \ +// RUN: | FileCheck -check-prefix=S %s // // S: "-cc1as" // S: "-g" diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c index 5dad8e938249..ca77abf9fd30 100644 --- a/test/Driver/debug-options.c +++ b/test/Driver/debug-options.c @@ -2,26 +2,43 @@ // rdar://10383444 // RUN: %clang -### -c -g %s 2>&1 | FileCheck -check-prefix=G %s -// RUN: %clang -### -c -g2 %s 2>&1 | FileCheck -check-prefix=G2 %s -// RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G3 %s -// RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s -// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=GGDB %s -// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s +// RUN: %clang -### -c -g2 %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -ggdb1 %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -ggdb3 %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -gdwarf-2 %s 2>&1 | FileCheck -check-prefix=G %s +// +// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_NO %s +// RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s +// RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s +// +// RUN: %clang -### -c -gline-tables-only %s 2>&1 \ +// RUN: | FileCheck -check-prefix=GLTO_ONLY %s +// RUN: %clang -### -c -gline-tables-only -g %s 2>&1 \ +// RUN: | FileCheck -check-prefix=G_ONLY %s +// RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \ +// RUN: | FileCheck -check-prefix=GLTO_NO %s +// +// RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches \ +// RUN: -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \ +// RUN: | not grep "argument unused during compilation" // // G: "-cc1" // G: "-g" // -// G2: "-cc1" -// G2: "-g" -// -// G3: "-cc1" -// G3: "-g" +// G_NO: "-cc1" +// G_NO-NOT: "-g" // -// GANY: "-cc1" -// GANY-NOT: "-g" +// GLTO_ONLY: "-cc1" +// GLTO_ONLY-NOT: "-g" +// GLTO_ONLY: "-gline-tables-only" +// GLTO_ONLY-NOT: "-g" // -// GGDB: "-cc1" -// GGDB: "-g" +// G_ONLY: "-cc1" +// G_ONLY-NOT: "-gline-tables-only" +// G_ONLY: "-g" +// G_ONLY-NOT: "-gline-tables-only" // -// GFOO: "-cc1" -// GFOO-NOT: "-g" +// GLTO_NO: "-cc1" +// GLTO_NO-NOT: "-gline-tables-only" diff --git a/test/Driver/debug-unsupported.c b/test/Driver/debug-unsupported.c new file mode 100644 index 000000000000..acbd7673a321 --- /dev/null +++ b/test/Driver/debug-unsupported.c @@ -0,0 +1,13 @@ +// RUN: %clang -c -gstabs %s 2>&1 | FileCheck %s +// RUN: %clang -c -gstabs+ %s 2>&1 | FileCheck %s +// RUN: %clang -c -gcoff %s 2>&1 | FileCheck %s +// RUN: %clang -c -gxcoff %s 2>&1 | FileCheck %s +// RUN: %clang -c -gxcoff+ %s 2>&1 | FileCheck %s +// RUN: %clang -c -gvms %s 2>&1 | FileCheck %s +// RUN: %clang -c -gstabs1 %s 2>&1 | FileCheck %s +// RUN: %clang -c -gcoff2 %s 2>&1 | FileCheck %s +// RUN: %clang -c -gxcoff3 %s 2>&1 | FileCheck %s +// RUN: %clang -c -gvms0 %s 2>&1 | FileCheck %s +// RUN: %clang -c -gtoggle %s 2>&1 | FileCheck %s +// +// CHECK: error: unsupported option diff --git a/test/Driver/fast-math.c b/test/Driver/fast-math.c index aef7cc3624d0..8426f0950acf 100644 --- a/test/Driver/fast-math.c +++ b/test/Driver/fast-math.c @@ -4,6 +4,9 @@ // LLVM only supports three switches which is more coarse grained than GCC's // support. // +// Both of them use gcc driver for as. +// XFAIL: cygwin,mingw32 +// // RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s // CHECK-NO-INFS: "-cc1" @@ -19,8 +22,23 @@ // CHECK-MATH-ERRNO: "-cc1" // CHECK-MATH-ERRNO: "-fmath-errno" // -// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ -// RUN: -fno-trapping-math -c %s 2>&1 \ +// RUN: %clang -### -fmath-errno -fno-math-errno -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target i686-apple-darwin -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target x86_64-unknown-freebsd -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target x86_64-unknown-netbsd -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target x86_64-unknown-openbsd -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target x86_64-unknown-dragonfly -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// CHECK-NO-MATH-ERRNO: "-cc1" +// CHECK-NO-MATH-ERRNO-NOT: "-fmath-errno" +// +// RUN: %clang -### -fno-math-errno -fassociative-math -freciprocal-math \ +// RUN: -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s // CHECK-UNSAFE-MATH: "-cc1" // CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math" @@ -36,7 +54,7 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s // RUN: %clang -### -ffinite-math-only -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s -// RUN: %clang -### -funsafe-math-optimizations -c %s 2>&1 \ +// RUN: %clang -### -funsafe-math-optimizations -fno-math-errno -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s // // One umbrella flag is *really* weird and also changes the semantics of the diff --git a/test/Driver/flags.c b/test/Driver/flags.c index 7a885b699b15..698a54ecf78b 100644 --- a/test/Driver/flags.c +++ b/test/Driver/flags.c @@ -7,3 +7,5 @@ // RUN: %clang -target i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log // RUN: grep '"-no-implicit-float"' %t.log +// RUN: %clang -target armv7-apple-darwin10 -### -S -mno-implicit-float %s 2> %t.log +// RUN: grep '"-no-implicit-float"' %t.log | count 1 diff --git a/test/Driver/fpack-struct.c b/test/Driver/fpack-struct.c new file mode 100644 index 000000000000..cc75da5bc0f8 --- /dev/null +++ b/test/Driver/fpack-struct.c @@ -0,0 +1,10 @@ +// RUN: %clang -fpack-struct -### %s 2> %t +// RUN: FileCheck < %t %s +// RUN: %clang -fpack-struct=8 -### %s 2> %t +// RUN: FileCheck < %t %s --check-prefix=EQ + +// CHECK: "-cc1" +// CHECK: "-fpack-struct=1" + +// CHECK-EQ: "-cc1" +// CHECK-EQ: "-fpack-struct=8" diff --git a/test/Driver/freebsd.c b/test/Driver/freebsd.c index 1fb84a02ac68..642c60ce77b5 100644 --- a/test/Driver/freebsd.c +++ b/test/Driver/freebsd.c @@ -28,3 +28,19 @@ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32 +// +// Check that the new linker flags are passed to FreeBSD +// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \ +// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS8 %s +// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd9 -m32 %s \ +// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS9 %s +// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd10.0 -m32 %s \ +// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS9 %s +// CHECK-LDFLAGS8-NOT: --hash-style=both +// CHECK-LDFLAGS8: --enable-new-dtags +// CHECK-LDFLAGS9: --hash-style=both +// CHECK-LDFLAGS9: --enable-new-dtags + diff --git a/test/Driver/gnu-runtime.m b/test/Driver/gnu-runtime.m index 12426d950571..1d7a40ab2b86 100644 --- a/test/Driver/gnu-runtime.m +++ b/test/Driver/gnu-runtime.m @@ -1,5 +1,4 @@ // RUN: %clang -target i386-apple-darwin10 -### -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s // RUN: %clang -target i386-apple-darwin10 -### -x objective-c++ -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s -// CHECK: -fgnu-runtime -// CHECK: -fobjc-runtime-has-arc -// CHECK: -fobjc-runtime-has-weak +// CHECK: -fobjc-runtime=gcc +// CHECK-NOT: fragile diff --git a/test/Driver/ios-simulator-arcruntime.c b/test/Driver/ios-simulator-arcruntime.c index 9bf2091fed5d..33d34924ced1 100644 --- a/test/Driver/ios-simulator-arcruntime.c +++ b/test/Driver/ios-simulator-arcruntime.c @@ -1,6 +1,8 @@ // RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s -// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s +// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s // -// CHECK-OPTIONS1-NOT: -fobjc-runtime-has-weak -// CHECK-OPTIONS2: -fobjc-runtime-has-weak +// CHECK-OPTIONS1: i386-apple-macosx10.6.0 +// CHECK-OPTIONS1: -fobjc-runtime=ios-4.2.1 +// CHECK-OPTIONS2: i386-apple-macosx10.6.0 +// CHECK-OPTIONS2: -fobjc-runtime=ios-5.0.0 diff --git a/test/Driver/linker-opts.c b/test/Driver/linker-opts.c index d036dfd04fb5..85e180c4e210 100644 --- a/test/Driver/linker-opts.c +++ b/test/Driver/linker-opts.c @@ -2,4 +2,4 @@ // CHECK: "-L" "{{.*}}/test1" // GCC driver is used as linker on cygming. It should be aware of LIBRARY_PATH. -// XFAIL: cygwin,mingw32 +// XFAIL: cygwin,mingw32,win32 diff --git a/test/Driver/linux-as.c b/test/Driver/linux-as.c index 22eac0d2dd94..b3265da23478 100644 --- a/test/Driver/linux-as.c +++ b/test/Driver/linux-as.c @@ -3,29 +3,54 @@ // RUN: %clang -target arm-linux -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM %s -// CHECK-ARM: as{{(.exe)?}}" +// CHECK-ARM: as{{(.exe)?}}" "-mfloat-abi=soft" // // RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-MCPU %s -// CHECK-ARM-MCPU: as{{(.exe)?}}" "-mcpu=cortex-a8" +// CHECK-ARM-MCPU: as{{(.exe)?}}" "-mfloat-abi=soft" "-mcpu=cortex-a8" // // RUN: %clang -target arm-linux -mfpu=neon -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-MFPU %s -// CHECK-ARM-MFPU: as{{(.exe)?}}" "-mfpu=neon" +// CHECK-ARM-MFPU: as{{(.exe)?}}" "-mfloat-abi=soft" "-mfpu=neon" // // RUN: %clang -target arm-linux -march=armv7-a -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-MARCH %s -// CHECK-ARM-MARCH: as{{(.exe)?}}" "-march=armv7-a" +// CHECK-ARM-MARCH: as{{(.exe)?}}" "-mfloat-abi=soft" "-march=armv7-a" // // RUN: %clang -target arm-linux -mcpu=cortex-a8 -mfpu=neon -march=armv7-a -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-ALL %s -// CHECK-ARM-ALL: as{{(.exe)?}}" "-march=armv7-a" "-mcpu=cortex-a8" "-mfpu=neon" +// CHECK-ARM-ALL: as{{(.exe)?}}" "-mfloat-abi=soft" "-march=armv7-a" "-mcpu=cortex-a8" "-mfpu=neon" // // RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-TARGET %s -// CHECK-ARM-TARGET: as{{(.exe)?}}" "-mfpu=neon" "-mcpu=cortex-a8" +// CHECK-ARM-TARGET: as{{(.exe)?}}" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8" +// +// RUN: %clang -target arm-linux -mfloat-abi=hard -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=ARM-MFLOAT-ABI %s +// CHECK-ARM-MFLOAT-ABI: as{{(.exe)?}}" "-mfloat-abi=hard" +// +// RUN: %clang -target arm-linux-androideabi -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=ARM-ANDROID %s +// CHECK-ARM-ANDROID: as{{(.exe)?}}" "-mfloat-abi=soft" +// +// RUN: %clang -target arm-linux-androideabi -march=armv7-a -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=ARM-ANDROID-SOFTFP %s +// CHECK-ARM-ANDROID-SOFTFP: as{{(.exe)?}}" "-mfloat-abi=softfp" "-march=armv7-a" +// +// RUN: %clang -target arm-linux-eabi -mhard-float -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=ARM-HARDFP %s +// CHECK-ARM-HARDFP: as{{(.exe)?}}" "-mfloat-abi=hard" +// +// RUN: %clang -target ppc-linux -mcpu=invalid-cpu -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=PPC-NO-MCPU %s +// CHECK-PPC-NO-MCPU-NOT: as{{.*}} "-mcpu=invalid-cpu" diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index 9a35d5d386ec..a6831b62a904 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -174,6 +174,39 @@ // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/lib" // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib" // +// Check multi arch support on Ubuntu 12.04 LTS. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-unknown-linux-gnueabihf \ +// RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM-HF %s +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crt1.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crti.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/lib/arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../.." +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crtn.o" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-unknown-linux-gnueabi \ +// RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM %s +// CHECK-UBUNTU-12-04-ARM: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crt1.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crti.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/lib/arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../.." +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crtn.o" +// // Test the setup that shipped in SUSE 10.3 on ppc64. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target powerpc64-suse-linux \ @@ -186,6 +219,21 @@ // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/lib/../lib64" // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/../lib64" // +// Check dynamic-linker for different archs +// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-gnueabi \ +// RUN: | FileCheck --check-prefix=CHECK-ARM %s +// CHECK-ARM: "{{.*}}ld{{(.exe)?}}" +// CHECK-ARM: "-m" "armelf_linux_eabi" +// CHECK-ARM: "-dynamic-linker" "{{.*}}/lib/ld-linux.so.3" +// +// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-gnueabihf \ +// RUN: | FileCheck --check-prefix=CHECK-ARM-HF %s +// CHECK-ARM-HF: "{{.*}}ld{{(.exe)?}}" +// CHECK-ARM-HF: "-m" "armelf_linux_eabi" +// CHECK-ARM-HF: "-dynamic-linker" "{{.*}}/lib/ld-linux-armhf.so.3" +// // Check that we do not pass --hash-style=gnu and --hash-style=both to linker // and provide correct path to the dynamic linker and emulation mode when build // for MIPS platforms. @@ -267,4 +315,86 @@ // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../.." // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mips-linux-gnu \ +// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS %s +// CHECK-DEBIAN-MIPS: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-MIPS: "{{.*}}/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../../mips-linux-gnu" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/mips-linux-gnu" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../.." +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mipsel-linux-gnu \ +// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPSEL %s +// CHECK-DEBIAN-MIPSEL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-MIPSEL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../../mipsel-linux-gnu" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/mipsel-linux-gnu" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.." +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mips64-linux-gnu \ +// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64 %s +// CHECK-DEBIAN-MIPS64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-MIPS64: "{{.*}}/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o" +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/64" +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5" +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../.." +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mips64el-linux-gnu \ +// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64EL %s +// CHECK-DEBIAN-MIPS64EL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-MIPS64EL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o" +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/64" +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5" +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.." +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib" // +// Test linker invocation on Android. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s +// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ANDROID: "{{.*}}/crtbegin_dynamic.o" +// CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib" +// CHECK-ANDROID-NOT: "gcc_s" +// CHECK-ANDROID: "-lgcc" +// CHECK-ANDROID-NOT: "gcc_s" +// CHECK-ANDROID: "{{.*}}/crtend_android.o" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: -shared \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SO %s +// CHECK-ANDROID-SO: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ANDROID-SO: "{{.*}}/crtbegin_so.o" +// CHECK-ANDROID-SO: "-L[[SYSROOT]]/usr/lib" +// CHECK-ANDROID-SO-NOT: "gcc_s" +// CHECK-ANDROID-SO: "-lgcc" +// CHECK-ANDROID-SO-NOT: "gcc_s" +// CHECK-ANDROID-SO: "{{.*}}/crtend_so.o" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: -static \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s +// CHECK-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ANDROID-STATIC: "{{.*}}/crtbegin_static.o" +// CHECK-ANDROID-STATIC: "-L[[SYSROOT]]/usr/lib" +// CHECK-ANDROID-STATIC-NOT: "gcc_s" +// CHECK-ANDROID-STATIC: "-lgcc" +// CHECK-ANDROID-STATIC-NOT: "gcc_s" +// CHECK-ANDROID-STATIC: "{{.*}}/crtend_android.o" diff --git a/test/Driver/mips-as.c b/test/Driver/mips-as.c index 44b8d8d3c4d8..0ace4dd51c74 100644 --- a/test/Driver/mips-as.c +++ b/test/Driver/mips-as.c @@ -3,29 +3,36 @@ // RUN: %clang -target mips-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EB-AS %s -// CHECK-MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB" +// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB" +// MIPS32-EB-AS-NOT: "-KPIC" +// +// RUN: %clang -target mips-linux-gnu -### \ +// RUN: -no-integrated-as -fPIC -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS32-EB-PIC %s +// MIPS32-EB-PIC: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB" +// MIPS32-EB-PIC: "-KPIC" // // RUN: %clang -target mipsel-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s -// CHECK-MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" +// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" // // RUN: %clang -target mips64-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS64-EB-AS %s -// CHECK-MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB" +// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB" // // RUN: %clang -target mips64el-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s -// CHECK-MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" +// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" // // RUN: %clang -target mips-linux-gnu -mabi=eabi -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-EABI %s -// CHECK-MIPS-EABI: as{{(.exe)?}}" "-march" "mips32" "-mabi" "eabi" "-EB" +// MIPS-EABI: as{{(.exe)?}}" "-march" "mips32" "-mabi" "eabi" "-EB" // // RUN: %clang -target mips64-linux-gnu -mabi=n32 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-N32 %s -// CHECK-MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB" +// MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB" diff --git a/test/Driver/mips-features.c b/test/Driver/mips-features.c new file mode 100644 index 000000000000..5be268318886 --- /dev/null +++ b/test/Driver/mips-features.c @@ -0,0 +1,39 @@ +// REQUIRES: mips-registered-target +// +// Check handling MIPS specific features options. +// +// -mips16 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mno-mips16 -mips16 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS16 %s +// CHECK-MIPS16: "-target-feature" "+mips16" +// +// -mno-mips16 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mips16 -mno-mips16 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NOMIPS16 %s +// CHECK-NOMIPS16: "-target-feature" "-mips16" +// +// -mdsp +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mno-dsp -mdsp 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MDSP %s +// CHECK-MDSP: "-target-feature" "+dsp" +// +// -mno-dsp +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mdsp -mno-dsp 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NOMDSP %s +// CHECK-NOMDSP: "-target-feature" "-dsp" +// +// -mdspr2 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mno-dspr2 -mdspr2 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MDSPR2 %s +// CHECK-MDSPR2: "-target-feature" "+dspr2" +// +// -mno-dspr2 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mdspr2 -mno-dspr2 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NOMDSPR2 %s +// CHECK-NOMDSPR2: "-target-feature" "-dspr2" diff --git a/test/Driver/mips-float.c b/test/Driver/mips-float.c index c9e107f593ae..95eb0025cc09 100644 --- a/test/Driver/mips-float.c +++ b/test/Driver/mips-float.c @@ -1,3 +1,4 @@ +// REQUIRES: mips-registered-target // Check handling -mhard-float / -msoft-float / -mfloat-abi options // when build for MIPS platforms. // diff --git a/test/Driver/montavista-gcc-toolchain.c b/test/Driver/montavista-gcc-toolchain.c new file mode 100644 index 000000000000..b9ab729ef21c --- /dev/null +++ b/test/Driver/montavista-gcc-toolchain.c @@ -0,0 +1,9 @@ +// Test that the montavista gcc-toolchain is correctly detected +// +// RUN: %clang -print-libgcc-file-name 2>&1 \ +// RUN: -target i686-montavista-linux \ +// RUN: -gcc-toolchain %S/Inputs/montavista_i686_tree/usr \ +// RUN: | FileCheck %s + +// Test for header search toolchain detection. +// CHECK: montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a diff --git a/test/Driver/msvc_forward.c b/test/Driver/msvc_forward.c new file mode 100644 index 000000000000..fe0ae84790e0 --- /dev/null +++ b/test/Driver/msvc_forward.c @@ -0,0 +1,5 @@ +// RUN: %clang -target i686-pc-win32 -lkernel32.lib -luser32.lib -### %s 2>&1 | FileCheck %s +// CHECK-NOT: "-lkernel32.lib" +// CHECK-NOT: "-luser32.lib" +// CHECK: "kernel32.lib" +// CHECK: "user32.lib" diff --git a/test/Driver/nodefaultlib.c b/test/Driver/nodefaultlib.c new file mode 100644 index 000000000000..518928a8850a --- /dev/null +++ b/test/Driver/nodefaultlib.c @@ -0,0 +1,8 @@ +// RUN: %clang -target i686-pc-linux-gnu -### -nodefaultlibs %s 2> %t +// RUN: FileCheck < %t %s +// +// CHECK-NOT: start-group +// CHECK-NOT: -lgcc +// CHECK-NOT: -lc +// CHECK: crtbegin +// CHECK: crtend diff --git a/test/Driver/rewrite-legacy-objc.m b/test/Driver/rewrite-legacy-objc.m index af59ff672726..d243c7a15b39 100644 --- a/test/Driver/rewrite-legacy-objc.m +++ b/test/Driver/rewrite-legacy-objc.m @@ -3,7 +3,7 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-fragile-abi" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" // TEST0: rewrite-legacy-objc.m" // RUN: not %clang -ccc-no-clang -target unknown -rewrite-legacy-objc %s -o - -### 2>&1 | \ diff --git a/test/Driver/rewrite-objc.m b/test/Driver/rewrite-objc.m index 7b080fc35e86..669679772203 100644 --- a/test/Driver/rewrite-objc.m +++ b/test/Driver/rewrite-objc.m @@ -3,7 +3,7 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" // TEST0: rewrite-objc.m" // RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \ diff --git a/test/Driver/target-triple-deployment.c b/test/Driver/target-triple-deployment.c new file mode 100644 index 000000000000..8e4824a7fe95 --- /dev/null +++ b/test/Driver/target-triple-deployment.c @@ -0,0 +1,33 @@ +// RUN: touch %t.o +// RUN: %clang -target x86_64-apple-macosx -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log +// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log +// +// RUN: %clang -target armv7-apple-ios -### %t.o 2>> %t.log +// RUN: %clang -target armv7-apple-ios0.0 -### %t.o 2>> %t.log +// RUN: %clang -target armv7-apple-ios1.2.3 -### %t.o 2>> %t.log +// RUN: %clang -target armv7-apple-ios5.0 -### %t.o 2>> %t.log +// +// RUN: FileCheck %s < %t.log + +// CHECK: {{ld(.exe)?"}} +// CHECK: -macosx_version_min +// CHECK: 10.4.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -macosx_version_min +// CHECK: 10.5.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -macosx_version_min +// CHECK: 10.7.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -iphoneos_version_min +// CHECK: 3.0.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -iphoneos_version_min +// CHECK: 3.0.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -iphoneos_version_min +// CHECK: 1.2.3 +// CHECK: {{ld(.exe)?"}} +// CHECK: -iphoneos_version_min +// CHECK: 5.0.0 diff --git a/test/Driver/warning-options.cpp b/test/Driver/warning-options.cpp new file mode 100644 index 000000000000..ab0da42e4bfc --- /dev/null +++ b/test/Driver/warning-options.cpp @@ -0,0 +1,10 @@ +// RUN: %clang -### -Wlarge-by-value-copy %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_DEFAULT %s +// LARGE_VALUE_COPY_DEFAULT: -Wlarge-by-value-copy=64 +// RUN: %clang -### -Wlarge-by-value-copy=128 %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_JOINED %s +// LARGE_VALUE_COPY_JOINED: -Wlarge-by-value-copy=128 + +// RUN: %clang -### -c -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \ +// RUN: -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s +// CHECK: unknown warning option '-Wmonkey' +// CHECK: unknown warning option '-Wno-monkey' +// CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'? diff --git a/test/Driver/warning-options_pedantic.cpp b/test/Driver/warning-options_pedantic.cpp new file mode 100644 index 000000000000..c6d11be73d1f --- /dev/null +++ b/test/Driver/warning-options_pedantic.cpp @@ -0,0 +1,7 @@ +// RUN: %clang -### -pedantic -no-pedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC %s +// RUN: %clang -### -pedantic -Wno-pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC %s +// NO_PEDANTIC-NOT: -pedantic +// RUN: %clang -### -pedantic -pedantic -no-pedantic -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC %s +// RUN: %clang -### -pedantic -pedantic -no-pedantic -Wpedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC %s +// PEDANTIC: -pedantic +// XFAIL: cygwin,mingw32 diff --git a/test/FixIt/fixit-autoreleasepool.m b/test/FixIt/fixit-autoreleasepool.m new file mode 100644 index 000000000000..ba1ad130f22a --- /dev/null +++ b/test/FixIt/fixit-autoreleasepool.m @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// rdar://10723084 + +void f0() { + @autorelease { + } +} + +// CHECK: {5:4-5:15}:"autoreleasepool" diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp index b6cc2c08b031..0c837b4beb02 100644 --- a/test/FixIt/fixit-cxx0x.cpp +++ b/test/FixIt/fixit-cxx0x.cpp @@ -108,3 +108,17 @@ void func(); template struct IP { }; // expected-note{{declared here}} IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}} +namespace MissingSemi { + struct a // expected-error {{expected ';' after struct}} + struct b // expected-error {{expected ';' after struct}} + enum x : int { x1, x2, x3 } // expected-error {{expected ';' after enum}} + struct c // expected-error {{expected ';' after struct}} + enum x : int // expected-error {{expected ';' after enum}} + // FIXME: The following gives a poor diagnostic (we parse the 'int' and the + // 'struct' as part of the same enum-base. + // enum x : int + // struct y + namespace N { + struct d // expected-error {{expected ';' after struct}} + } +} diff --git a/test/FixIt/fixit-include.c b/test/FixIt/fixit-include.c new file mode 100644 index 000000000000..51bd9b0dfd50 --- /dev/null +++ b/test/FixIt/fixit-include.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -Wall -pedantic -verify %s +// RUN: cp %s %t +// RUN: cp %S/fixit-include.h %T +// RUN: not %clang_cc1 -fsyntax-only -fixit %t +// RUN: %clang_cc1 -Wall -pedantic %t + +#include // expected-error {{'fixit-include.h' file not found with include; use "quotes" instead}} + +#pragma does_not_exist // expected-warning {{unknown pragma ignored}} + +int main( void ) { + return 0; +} diff --git a/test/FixIt/fixit-include.h b/test/FixIt/fixit-include.h new file mode 100644 index 000000000000..6a22d2e88eb3 --- /dev/null +++ b/test/FixIt/fixit-include.h @@ -0,0 +1 @@ +// This file is purposefully left empty diff --git a/test/FixIt/fixit-interface-as-param.m b/test/FixIt/fixit-interface-as-param.m new file mode 100644 index 000000000000..3295c82c31a1 --- /dev/null +++ b/test/FixIt/fixit-interface-as-param.m @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// rdar://11311333 + +@interface NSView @end + +@interface INTF +- (void) drawRect : inView:(NSView)view; +@end + +// CHECK: {7:35-7:35}:"*" + diff --git a/test/FixIt/fixit-objc-message-comma-separator.m b/test/FixIt/fixit-objc-message-comma-separator.m new file mode 100644 index 000000000000..0caa33eb0ad2 --- /dev/null +++ b/test/FixIt/fixit-objc-message-comma-separator.m @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// rdar://11376372 + +@class NSObject; + +@interface TestObj { +} +-(void)aMethodWithArg1:(NSObject*)arg1 arg2:(NSObject*)arg2; +@end + +int main(int argc, char *argv[]) +{ + TestObj *obj; + [obj aMethodWithArg1:@"Arg 1 Good", arg2:@"Arg 2 Good"]; +} + +// CHECK: {14:39-14:40}:"" diff --git a/test/FixIt/fixit-unicode.c b/test/FixIt/fixit-unicode.c new file mode 100644 index 000000000000..2af5e08faa41 --- /dev/null +++ b/test/FixIt/fixit-unicode.c @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s + +struct Foo { + int bar; +}; + +// PR13312 +void test1() { + struct Foo foo; + (&foo)☃>bar = 42; +// CHECK: error: expected ';' after expression +// Make sure we emit the fixit right in front of the snowman. +// CHECK: {{^ \^}} +// CHECK: {{^ ;}} + +// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{11:9-11:9}:";" +} + + +int printf(const char *, ...); +void test2() { + printf("∆: %d", 1L); +// CHECK: warning: format specifies type 'int' but the argument has type 'long' +// Don't crash emitting a fixit after the delta. +// CHECK: printf(" +// CHECK: : %d", 1L); +// Unfortunately, we can't actually check the location of the printed fixit, +// because different systems will render the delta differently (either as a +// character, or as .) The fixit should line up with the %d regardless. + +// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{23:16-23:18}:"%ld" +} diff --git a/test/FixIt/fixit-vexing-parse.cpp b/test/FixIt/fixit-vexing-parse.cpp index 8450590c67f9..dd0f87304a53 100644 --- a/test/FixIt/fixit-vexing-parse.cpp +++ b/test/FixIt/fixit-vexing-parse.cpp @@ -7,6 +7,7 @@ struct S { struct T { T(); + T(S, S); int n; }; @@ -30,26 +31,44 @@ S F2(); namespace N { void test() { - // CHECK: fix-it:"{{.*}}":{34:9-34:11}:" = {}" + // CHECK: fix-it:"{{.*}}":{35:9-35:11}:" = {}" S s1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{38:9-38:10}:";" - // CHECK: fix-it:"{{.*}}":{39:7-39:9}:" = {}" + // CHECK: fix-it:"{{.*}}":{39:9-39:10}:";" + // CHECK: fix-it:"{{.*}}":{40:7-40:9}:" = {}" S s2, // expected-note {{change this ',' to a ';' to call 'F2'}} F2(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{43:9-43:11}:"" // CHECK: fix-it:"{{.*}}":{44:9-44:11}:"" + // CHECK: fix-it:"{{.*}}":{45:9-45:11}:"" T t1(), // expected-warning {{function declaration}} expected-note {{remove parentheses}} t2(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} - // CHECK: fix-it:"{{.*}}":{47:8-47:10}:" = {}" + // Suggest parentheses only around the first argument. + // CHECK: fix-it:"{{.*}}":{50:10-50:10}:"(" + // CHECK: fix-it:"{{.*}}":{50:13-50:13}:")" + T t3(S(), S()); // expected-warning {{disambiguated as a function declaration}} expected-note {{add a pair of parentheses}} + + // Check fixit position for pathological case + // CHECK: fix-it:"{{.*}}":{56:11-56:11}:"(" + // CHECK: fix-it:"{{.*}}":{56:20-56:20}:")" + float k[1]; + int l(int(k[0])); // expected-warning {{disambiguated as a function declaration}} expected-note {{add a pair of parentheses}} + + // Don't emit warning and fixit because this must be a function declaration due to void return type. + typedef void VO; + VO m(int (*p)[4]); + + // Don't emit warning and fixit because direct initializer is not permitted here. + if (int n(int())){} // expected-error {{function type is not allowed here}} expected-error {{condition must have an initializer}} + + // CHECK: fix-it:"{{.*}}":{66:8-66:10}:" = {}" U u(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{50:8-50:10}:"" + // CHECK: fix-it:"{{.*}}":{69:8-69:10}:"" V v(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} - // CHECK: fix-it:"{{.*}}":{53:8-53:10}:"" + // CHECK: fix-it:"{{.*}}":{72:8-72:10}:"" W w(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} // TODO: Removing the parens here would not initialize U::n. @@ -57,33 +76,33 @@ namespace N { // Maybe suggest removing the parens anyway? X x(); // expected-warning {{function declaration}} - // CHECK: fix-it:"{{.*}}":{61:11-61:13}:" = 0" + // CHECK: fix-it:"{{.*}}":{80:11-80:13}:" = 0" int n1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{65:11-65:12}:";" - // CHECK: fix-it:"{{.*}}":{66:7-66:9}:" = 0" + // CHECK: fix-it:"{{.*}}":{84:11-84:12}:";" + // CHECK: fix-it:"{{.*}}":{85:7-85:9}:" = 0" int n2, // expected-note {{change this ',' to a ';' to call 'F1'}} F1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{69:13-69:15}:" = 0.0" + // CHECK: fix-it:"{{.*}}":{88:13-88:15}:" = 0.0" double d(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} typedef void *Ptr; - // CHECK: fix-it:"{{.*}}":{74:10-74:12}:" = 0" + // CHECK: fix-it:"{{.*}}":{93:10-93:12}:" = 0" Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} #define NULL 0 - // CHECK: fix-it:"{{.*}}":{78:10-78:12}:" = NULL" + // CHECK: fix-it:"{{.*}}":{97:10-97:12}:" = NULL" Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{81:11-81:13}:" = false" + // CHECK: fix-it:"{{.*}}":{100:11-100:13}:" = false" bool b(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{84:11-84:13}:" = '\\0'" + // CHECK: fix-it:"{{.*}}":{103:11-103:13}:" = '\\0'" char c(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{87:15-87:17}:" = L'\\0'" + // CHECK: fix-it:"{{.*}}":{106:15-106:17}:" = L'\\0'" wchar_t wc(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} } } diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index 5e4947b8cdd6..ce6f1092df19 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -100,3 +100,11 @@ int noSemiAfterLabel(int n) { } return 1; } + +struct noSemiAfterStruct // expected-error {{expected ';' after struct}} +struct noSemiAfterStruct { + int n // expected-warning {{';'}} +} // expected-error {{expected ';' after struct}} +enum noSemiAfterEnum { + e1 +} // expected-error {{expected ';' after enum}} diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp index 7d531a537a35..3eac434a36bd 100644 --- a/test/FixIt/fixit.cpp +++ b/test/FixIt/fixit.cpp @@ -54,7 +54,7 @@ namespace rdar7853795 { } namespace rdar7796492 { - class A { int x, y; A(); }; + struct A { int x, y; A(); }; A::A() : x(1) y(2) { // expected-error{{missing ',' between base or member initializers}} @@ -204,3 +204,91 @@ template Foo, // expected-error {{template template parameter template typename Bar, // expected-error {{template template parameter requires 'class' after the parameter list}} template struct Baz> // expected-error {{template template parameter requires 'class' after the parameter list}} void func(); + +namespace ShadowedTagType { +class Foo { + public: + enum Bar { X, Y }; + void SetBar(Bar bar); + Bar Bar(); // expected-note 2 {{enum 'Bar' is hidden by a non-type declaration of 'Bar' here}} + private: + Bar bar_; // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}} +}; +void Foo::SetBar(Bar bar) { bar_ = bar; } // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}} +} + +#define NULL __null +char c = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}} +double dbl = NULL; // expected-warning {{implicit conversion of NULL constant to 'double'}} + +namespace arrow_suggest { + +template +class wrapped_ptr { + public: + wrapped_ptr(T* ptr) : ptr_(ptr) {} + T* operator->() { return ptr_; } + private: + T *ptr_; +}; + +class Worker { + public: + void DoSomething(); +}; + +void test() { + wrapped_ptr worker(new Worker); + worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr'; did you mean to use '->' instead of '.'?}} +} + +} // namespace arrow_suggest + +// Make sure fixing namespace-qualified identifiers functions properly with +// namespace-aware typo correction/ +namespace redecl_typo { +namespace Foo { + void BeEvil(); // expected-note {{'BeEvil' declared here}} +} +namespace Bar { + namespace Foo { + bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}} + void beEvil(); + } +} +bool Foo::isGood() { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}} + return true; +} +void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}} +} + +// Test behavior when a template-id is ended by a token which starts with '>'. +namespace greatergreater { + template struct S { S(); S(T); }; + void f(S=0); // expected-error {{a space is required between a right angle bracket and an equals sign (use '> =')}} + + // FIXME: The fix-its here overlap so -fixit mode can't apply the second one. + //void f(S>=S()); + + struct Shr { + template Shr(T); + template void operator >>=(T); + }; + + template> struct TemplateTemplateParam; // expected-error {{requires 'class'}} + + template void t(); + void g() { + void (*p)() = &t; + (void)(&t==p); // expected-error {{use '> ='}} + (void)(&t>=p); // expected-error {{use '> >'}} + (void)(&t>>=p); // expected-error {{use '> >'}} + (Shr)&t>>>=p; // expected-error {{use '> >'}} + + // FIXME: We correct this to '&t > >= p;' not '&t >>= p;' + //(Shr)&t>>=p; + + // FIXME: The fix-its here overlap. + //(void)(&t>==p); + } +} diff --git a/test/FixIt/format-no-fixit.m b/test/FixIt/format-no-fixit.m new file mode 100644 index 000000000000..36ecd3f26c01 --- /dev/null +++ b/test/FixIt/format-no-fixit.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -fsyntax-only %s 2>&1 | FileCheck %s + +// CHECK-NOT: fix-it: + +@class NSString; +extern void NSLog(NSString *format, ...); +int printf(const char * restrict, ...) ; + + +void test_object_correction (id x) { + printf("%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'id'}} + printf("%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'id'}} + printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'id'}} +} + + +// Old-style Core Foundation types do not have __attribute__((NSObject)). +// This is okay, but we won't suggest a fixit; arbitrary structure pointers may +// not be objects. +typedef const struct __CFString * CFStringRef; + +void test_cf_object_correction (CFStringRef x) { + NSLog(@"%@", x); // no-warning + + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'CFStringRef'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'CFStringRef'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'CFStringRef'}} +} + diff --git a/test/FixIt/format.m b/test/FixIt/format.m new file mode 100644 index 000000000000..c4747019b2df --- /dev/null +++ b/test/FixIt/format.m @@ -0,0 +1,95 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s +// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -fblocks %s 2>&1 | FileCheck %s + +@class NSString; +extern void NSLog(NSString *, ...); +int printf(const char * restrict, ...) ; + +void test_integer_correction (int x) { + printf("%d", x); // no-warning + printf("%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} + printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'int'}} + // CHECK: fix-it:"{{.*}}":{10:11-10:13}:"%d" + // CHECK: fix-it:"{{.*}}":{11:11-11:14}:"%d" + + NSLog(@"%d", x); // no-warning + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'int'}} + NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'int'}} + // CHECK: fix-it:"{{.*}}":{16:11-16:13}:"%d" + // CHECK: fix-it:"{{.*}}":{17:11-17:14}:"%d" + // CHECK: fix-it:"{{.*}}":{18:11-18:13}:"%d" +} + +void test_string_correction (char *x) { + printf("%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}} + printf("%s", x); // no-warning + printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'char *'}} + // CHECK: fix-it:"{{.*}}":{25:11-25:13}:"%s" + // CHECK: fix-it:"{{.*}}":{27:11-27:14}:"%s" + + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}} + NSLog(@"%s", x); // no-warning + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'char *'}} + NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'char *'}} + // CHECK: fix-it:"{{.*}}":{31:11-31:13}:"%s" + // CHECK: fix-it:"{{.*}}":{33:11-33:14}:"%s" + // CHECK: fix-it:"{{.*}}":{34:11-34:13}:"%s" +} + +void test_object_correction (id x) { + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'id'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'id'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'id'}} + NSLog(@"%@", x); // no-warning + // CHECK: fix-it:"{{.*}}":{41:11-41:13}:"%@" + // CHECK: fix-it:"{{.*}}":{42:11-42:13}:"%@" + // CHECK: fix-it:"{{.*}}":{43:11-43:14}:"%@" +} + +typedef const struct __CFString * __attribute__((NSObject)) CFStringRef; +void test_cf_object_correction (CFStringRef x) { + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'CFStringRef'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'CFStringRef'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'CFStringRef'}} + NSLog(@"%@", x); // no-warning + // CHECK: fix-it:"{{.*}}":{52:11-52:13}:"%@" + // CHECK: fix-it:"{{.*}}":{53:11-53:13}:"%@" + // CHECK: fix-it:"{{.*}}":{54:11-54:14}:"%@" +} + +typedef void (^block_t)(void); +void test_block_correction (block_t x) { + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'block_t'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'block_t'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'block_t'}} + NSLog(@"%@", x); // no-warning + // CHECK: fix-it:"{{.*}}":{63:11-63:13}:"%@" + // CHECK: fix-it:"{{.*}}":{64:11-64:13}:"%@" + // CHECK: fix-it:"{{.*}}":{65:11-65:14}:"%@" +} + +void test_class_correction (Class x) { + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'Class'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'Class'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'Class'}} + NSLog(@"%@", x); // no-warning + // CHECK: fix-it:"{{.*}}":{73:11-73:13}:"%@" + // CHECK: fix-it:"{{.*}}":{74:11-74:13}:"%@" + // CHECK: fix-it:"{{.*}}":{75:11-75:14}:"%@" +} + + +typedef enum : int { NSUTF8StringEncoding = 8 } NSStringEncoding; +void test_fixed_enum_correction(NSStringEncoding x) { + NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'NSStringEncoding'}} + // CHECK: fix-it:"{{.*}}":{85:11-85:13}:"%d" +} + +typedef __SIZE_TYPE__ size_t; +enum SomeSize : size_t { IntegerSize = sizeof(int) }; +void test_named_fixed_enum_correction(enum SomeSize x) { + NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'enum SomeSize'}} + // CHECK: fix-it:"{{.*}}":{92:11-92:13}:"%zu" +} + diff --git a/test/FixIt/messages.cpp b/test/FixIt/messages.cpp new file mode 100644 index 000000000000..b9391449ad16 --- /dev/null +++ b/test/FixIt/messages.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 2>&1 %s | FileCheck -strict-whitespace %s + +struct A { + unsigned int a; +}; + +// PR10696 +void testOverlappingInsertions(int b) { + A var = { b }; + // CHECK: A var = { b }; + // CHECK: ^ + // CHECK: static_cast( ) +} diff --git a/test/FixIt/objc-literals.m b/test/FixIt/objc-literals.m index 03d64b156496..549cfde20250 100644 --- a/test/FixIt/objc-literals.m +++ b/test/FixIt/objc-literals.m @@ -2,13 +2,13 @@ // RUN: cp %s %t // RUN: not %clang_cc1 -fsyntax-only -fixit -x objective-c %t // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c %t -// RUN: grep arrayWithObjects %t typedef unsigned char BOOL; -@interface NSNumber @end +@interface NSObject +@end -@interface NSNumber (NSNumberCreation) +@interface NSNumber : NSObject + (NSNumber *)numberWithChar:(char)value; + (NSNumber *)numberWithUnsignedChar:(unsigned char)value; + (NSNumber *)numberWithShort:(short)value; @@ -24,17 +24,17 @@ typedef unsigned char BOOL; + (NSNumber *)numberWithBool:(BOOL)value; @end -@interface NSArray -@end - -@interface NSArray (NSArrayCreation) +@interface NSArray : NSObject + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; @end -@interface NSDictionary +@interface NSDictionary : NSObject + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; @end +@interface NSString : NSObject +@end + void fixes() { id arr = @[ 17, // expected-error{{numeric literal must be prefixed by '@' in a collection}} diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h b/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h new file mode 100644 index 000000000000..0f3f0be3c764 --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h @@ -0,0 +1 @@ +#include "warn.h" diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h b/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h new file mode 100644 index 000000000000..def881aa137e --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h @@ -0,0 +1,2 @@ +#if BOOST +#endif diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h b/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h new file mode 100644 index 000000000000..0f3f0be3c764 --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h @@ -0,0 +1 @@ +#include "warn.h" diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h b/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h new file mode 100644 index 000000000000..6a0c102ea45d --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h @@ -0,0 +1,2 @@ +#if MYLIB +#endif diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/src/all.h b/test/Frontend/Inputs/SystemHeaderPrefix/src/all.h new file mode 100644 index 000000000000..ace9699f85b3 --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/src/all.h @@ -0,0 +1,6 @@ +#include "libs/boost/all.h" +#include "libs/mylib/all.h" + +#include "libs/boost/warn.h" +#include "libs/mylib/warn.h" +#include "src/warn.h" diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h b/test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h new file mode 100644 index 000000000000..91e2591855e9 --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h @@ -0,0 +1,2 @@ +#if SRC +#endif diff --git a/test/Frontend/Inputs/rewrite-includes1.h b/test/Frontend/Inputs/rewrite-includes1.h new file mode 100644 index 000000000000..1b6c80d5f435 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes1.h @@ -0,0 +1,3 @@ +#pragma clang system_header +included_line1 +#include "rewrite-includes2.h" diff --git a/test/Frontend/Inputs/rewrite-includes2.h b/test/Frontend/Inputs/rewrite-includes2.h new file mode 100644 index 000000000000..1114e51cc135 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes2.h @@ -0,0 +1 @@ +included_line2 diff --git a/test/Frontend/Inputs/rewrite-includes3.h b/test/Frontend/Inputs/rewrite-includes3.h new file mode 100644 index 000000000000..3757bc8b3416 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes3.h @@ -0,0 +1 @@ +included_line3 diff --git a/test/Frontend/Inputs/rewrite-includes4.h b/test/Frontend/Inputs/rewrite-includes4.h new file mode 100644 index 000000000000..b4e25d26f62d --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes4.h @@ -0,0 +1 @@ +included_line4 diff --git a/test/Frontend/Inputs/rewrite-includes5.h b/test/Frontend/Inputs/rewrite-includes5.h new file mode 100644 index 000000000000..934bf413e50f --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes5.h @@ -0,0 +1 @@ +included_line5 diff --git a/test/Frontend/Inputs/rewrite-includes6.h b/test/Frontend/Inputs/rewrite-includes6.h new file mode 100644 index 000000000000..c18e5013affc --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes6.h @@ -0,0 +1,2 @@ +#pragma once +included_line6 diff --git a/test/Frontend/Inputs/rewrite-includes7.h b/test/Frontend/Inputs/rewrite-includes7.h new file mode 100644 index 000000000000..da00d4fb97d8 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes7.h @@ -0,0 +1,4 @@ +#ifndef REWRITE_INCLUDES_7 +#define REWRITE_INCLUDES_7 +included_line7 +#endif diff --git a/test/Frontend/rewrite-includes-missing.c b/test/Frontend/rewrite-includes-missing.c new file mode 100644 index 000000000000..b79bbd9ca8b5 --- /dev/null +++ b/test/Frontend/rewrite-includes-missing.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -verify -E -frewrite-includes %s -o - | FileCheck -strict-whitespace %s + +#include "foobar.h" // expected-error {{'foobar.h' file not found}} +// CHECK: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "foobar.h" +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 4 "{{.*}}rewrite-includes-missing.c" 2{{$}} diff --git a/test/Frontend/rewrite-includes.c b/test/Frontend/rewrite-includes.c new file mode 100644 index 000000000000..546a2c44af2c --- /dev/null +++ b/test/Frontend/rewrite-includes.c @@ -0,0 +1,145 @@ +// RUN: %clang_cc1 -verify -E -frewrite-includes -DFIRST -I %S/Inputs %s -o - | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -verify -E -frewrite-includes -P -DFIRST -I %S/Inputs %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s +// STARTCOMPARE +#define A(a,b) a ## b +A(1,2) +#include "rewrite-includes1.h" +#ifdef FIRST +#define HEADER "rewrite-includes3.h" +#include HEADER +#else +#include "rewrite-includes4.h" +#endif +#/**/include /**/ "rewrite-includes5.h" /**/ \ + +#include "rewrite-includes6.h" // comment + +#include "rewrite-includes6.h" /* comment + continues */ +#include "rewrite-includes7.h" +#include "rewrite-includes7.h" +// ENDCOMPARE +// CHECK: {{^}}// STARTCOMPARE{{$}} +// CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}} +// CHECK-NEXT: {{^}}A(1,2){{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes1.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#pragma clang system_header{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 3{{$}} +// CHECK-NEXT: {{^}}included_line1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes2.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes2.h" 1 3{{$}} +// CHECK-NEXT: {{^}}included_line2{{$}} +// CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 2 3{{$}} +// CHECK-NEXT: {{^}}# 7 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#ifdef FIRST{{$}} +// CHECK-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include HEADER{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes3.h" 1{{$}} +// CHECK-NEXT: {{^}}included_line3{{$}} +// CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#else{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes4.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}#endif{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}} +// CHECK-NEXT: {{^}} {{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes5.h" 1{{$}} +// CHECK-NEXT: {{^}}included_line5{{$}} +// CHECK-NEXT: {{^}}# 15 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes6.h" 1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#pragma once{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs[/\\]}}rewrite-includes6.h"{{$}} +// CHECK-NEXT: {{^}}included_line6{{$}} +// CHECK-NEXT: {{^}}# 16 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}} {{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}} +// CHECK-NEXT: {{^}} continues */{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 19 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes7.h" 1{{$}} +// CHECK-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}} +// CHECK-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}} +// CHECK-NEXT: {{^}}included_line7{{$}} +// CHECK-NEXT: {{^}}#endif{{$}} +// CHECK-NEXT: {{^}}# 20 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 21 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}// ENDCOMPARE{{$}} + +// CHECKNL: {{^}}// STARTCOMPARE{{$}} +// CHECKNL-NEXT: {{^}}#define A(a,b) a ## b{{$}} +// CHECKNL-NEXT: {{^}}A(1,2){{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes1.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#pragma clang system_header{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line1{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes2.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line2{{$}} +// CHECKNL-NEXT: {{^}}#ifdef FIRST{{$}} +// CHECKNL-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include HEADER{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line3{{$}} +// CHECKNL-NEXT: {{^}}#else{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes4.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#endif{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}} +// CHECKNL-NEXT: {{^}} {{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line5{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#pragma once{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line6{{$}} +// CHECKNL-NEXT: {{^}} {{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}} +// CHECKNL-NEXT: {{^}} continues */{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}} +// CHECKNL-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}} +// CHECKNL-NEXT: {{^}}included_line7{{$}} +// CHECKNL-NEXT: {{^}}#endif{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}// ENDCOMPARE{{$}} diff --git a/test/Frontend/system-header-prefix.c b/test/Frontend/system-header-prefix.c new file mode 100644 index 000000000000..31194d96e58c --- /dev/null +++ b/test/Frontend/system-header-prefix.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -isystem-prefix libs/ -ino-system-prefix libs/mylib/ -I%S/Inputs/SystemHeaderPrefix -Wundef -E %s 2>&1 | FileCheck %s + +#include "src/all.h" + +// CHECK-NOT: BOOST +// CHECK: libs/mylib/warn.h:1:5: warning: 'MYLIB' is not defined, evaluates to 0 +// CHECK-NOT: BOOST +// CHECK: libs/mylib/warn.h:1:5: warning: 'MYLIB' is not defined, evaluates to 0 +// CHECK-NOT: BOOST +// CHECK: src/warn.h:1:5: warning: 'SRC' is not defined, evaluates to 0 +// CHECK-NOT: BOOST diff --git a/test/Frontend/verify-directive.h b/test/Frontend/verify-directive.h new file mode 100644 index 000000000000..cb405869b050 --- /dev/null +++ b/test/Frontend/verify-directive.h @@ -0,0 +1,2 @@ +// Check that directives inside includes are included! +// expected-error@1 {{include file test}} diff --git a/test/Frontend/verify-fatal.c b/test/Frontend/verify-fatal.c new file mode 100644 index 000000000000..0e74032a3afe --- /dev/null +++ b/test/Frontend/verify-fatal.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -Wfatal-errors -verify %s 2>&1 | FileCheck %s + +#error first fatal +// expected-error@-1 {{first fatal}} + +#error second fatal +// expected-error@-1 {{second fatal}} + + +// CHECK: error: 'error' diagnostics expected but not seen: +// CHECK-NEXT: Line 6 (directive at {{.*}}verify-fatal.c:7): second fatal +// CHECK-NEXT: 1 error generated. diff --git a/test/Frontend/verify.c b/test/Frontend/verify.c new file mode 100644 index 000000000000..f8d0f4282b4a --- /dev/null +++ b/test/Frontend/verify.c @@ -0,0 +1,125 @@ +// RUN: %clang_cc1 -DTEST1 -verify %s +// RUN: %clang_cc1 -DTEST2 -verify %s 2>&1 | FileCheck -check-prefix=CHECK2 %s +// RUN: %clang_cc1 -DTEST3 -verify %s 2>&1 | FileCheck -check-prefix=CHECK3 %s +// RUN: %clang_cc1 -DTEST4 -verify %s 2>&1 | FileCheck -check-prefix=CHECK4 %s +// RUN: %clang_cc1 -DTEST5 -verify %s 2>&1 | FileCheck -check-prefix=CHECK5 %s + +// expected-warning@ malformed +// expected-error@7 1 {{missing or invalid line number}} + +// expected-warning@0 malformed +// expected-error@10 {{missing or invalid line number}} + +// expected-warning@-50 malformed +// expected-error@13 {{missing or invalid line number}} + +// expected-warning malformed +// expected-error@16 {{cannot find start}} + +// expected-error 0+ {{should also be ignored}} + +#ifdef TEST1 +#if 0 +// expected-error {{should be ignored}} +#endif + +#error should not be ignored +// expected-error@-1 1+ {{should not be ignored}} + +#line 90 +unexpected a; // expected-error@+0 + {{unknown type}} + +#line 60 +unexpected b; // expected-error@33 1-1 {{unknown type}} + +// expected-error@+2 {{file not found}} check that multi-line handled correctly: \ + +#include "missing_header_file.include" +#endif + +#ifdef TEST2 +#define MACRO some_value // expected-error {{define_error}} +#undef MACRO extra_token // expected-warning {{undef_error}} +#line -2 // expected-error {{line_error}} +#error AAA // expected-error {{BBB}} <- this shall be part of diagnostic +#warning CCC // expected-warning {{DDD}} <- this shall be part of diagnostic + +#if 0 +// This is encapsulated in "#if 0" so that the expected-* checks below +// are not inadvertently included in the diagnostic checking! + +// CHECK2: error: 'error' diagnostics expected but not seen: +// CHECK2-NEXT: Line 41: define_error +// CHECK2-NEXT: Line 43: line_error +// CHECK2-NEXT: error: 'error' diagnostics seen but not expected: +// CHECK2-NEXT: Line 43: #line directive requires a positive integer argument +// CHECK2-NEXT: Line 44: AAA // expected-error {{[{][{]BBB[}][}]}} <- this shall be part of diagnostic +// CHECK2-NEXT: error: 'warning' diagnostics expected but not seen: +// CHECK2-NEXT: Line 42: undef_error +// CHECK2-NEXT: error: 'warning' diagnostics seen but not expected: +// CHECK2-NEXT: Line 42: extra tokens at end of #undef directive +// CHECK2-NEXT: Line 45: CCC // expected-warning {{[{][{]DDD[}][}]}} <- this shall be part of diagnostic +// CHECK2-NEXT: 7 errors generated. +#endif +#endif + +#ifdef TEST3 +#ifndef TEST3 // expected-note {{line_67}} + // expected-note {{line_68_ignored}} +# ifdef UNDEFINED // expected-note {{line_69_ignored}} +# endif // expected-note {{line_70_ignored}} +#elif defined(TEST3) // expected-note {{line_71}} +# if 1 // expected-note {{line_72}} + // expected-note {{line_73}} +# else // expected-note {{line_74}} + // expected-note {{line_75_ignored}} +# ifndef TEST3 // expected-note {{line_76_ignored}} +# endif // expected-note {{line_77_ignored}} +# endif // expected-note {{line_78}} +#endif + +// CHECK3: error: 'note' diagnostics expected but not seen: +// CHECK3-NEXT: Line 67: line_67 +// CHECK3-NEXT: Line 71: line_71 +// CHECK3-NEXT: Line 72: line_72 +// CHECK3-NEXT: Line 73: line_73 +// CHECK3-NEXT: Line 74: line_74 +// CHECK3-NEXT: Line 78: line_78 +// CHECK3-NEXT: 6 errors generated. +#endif + +#ifdef TEST4 +#include "missing_header_file.include" // expected-error {{include_error}} + +// CHECK4: error: 'error' diagnostics expected but not seen: +// CHECK4-NEXT: Line 92: include_error +// CHECK4-NEXT: error: 'error' diagnostics seen but not expected: +// CHECK4-NEXT: Line 92: 'missing_header_file.include' file not found +// CHECK4-NEXT: 2 errors generated. +#endif + +#ifdef TEST5 +#include "verify-directive.h" +// expected-error@50 {{source file test}} + +// CHECK5: error: 'error' diagnostics expected but not seen: +// CHECK5-NEXT: Line 1 (directive at {{.*}}verify-directive.h:2): include file test +// CHECK5-NEXT: Line 50 (directive at {{.*}}verify.c:103): source file test +// CHECK5-NEXT: 2 errors generated. +#endif + +#if 0 +// RUN: %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s + +// CHECK6: error: 'error' diagnostics seen but not expected: +// CHECK6-NEXT: (frontend): error reading '{{.*}}verify.c.tmp.invalid' +// CHECK6-NEXT: 1 error generated. + +// RUN: echo -e '//expected-error@2{{1}}\n#error 2' | %clang_cc1 -verify 2>&1 | FileCheck -check-prefix=CHECK7 %s + +// CHECK7: error: 'error' diagnostics expected but not seen: +// CHECK7-NEXT: Line 2 (directive at :1): 1 +// CHECK7-NEXT: error: 'error' diagnostics seen but not expected: +// CHECK7-NEXT: Line 2: 2 +// CHECK7-NEXT: 2 errors generated. +#endif diff --git a/test/Frontend/verify2.c b/test/Frontend/verify2.c new file mode 100644 index 000000000000..a1c797581ed9 --- /dev/null +++ b/test/Frontend/verify2.c @@ -0,0 +1,19 @@ +#if 0 +// RUN: %clang_cc1 -verify %s 2>&1 | FileCheck %s + +// Please note that all comments are inside "#if 0" blocks so that +// VerifyDiagnosticConsumer sees no comments while processing this +// test-case. +#endif + +#include "verify2.h" +#error source + +#if 0 +// expected-error {{should be ignored}} + +// CHECK: error: 'error' diagnostics seen but not expected: +// CHECK-NEXT: Line 1: header +// CHECK-NEXT: Line 10: source +// CHECK-NEXT: 2 errors generated. +#endif diff --git a/test/Frontend/verify2.h b/test/Frontend/verify2.h new file mode 100644 index 000000000000..8acbf6efdfe2 --- /dev/null +++ b/test/Frontend/verify2.h @@ -0,0 +1,5 @@ +#error header + +#if 0 +// expected-error {{should be ignored}} +#endif diff --git a/test/Headers/ms-null-ms-header-vs-stddef.cpp b/test/Headers/ms-null-ms-header-vs-stddef.cpp new file mode 100644 index 000000000000..7efa871da90e --- /dev/null +++ b/test/Headers/ms-null-ms-header-vs-stddef.cpp @@ -0,0 +1,16 @@ +// RUN: %clang -fsyntax-only -target i686-pc-win32 %s +// RUN: %clang -fsyntax-only -target i386-mingw32 %s + +// Something in MSVC's headers (pulled in e.g. by ) defines __null +// to something, mimick that. +#define __null + +#include + +// __null is used as a type annotation in MS headers, with __null defined to +// nothing in regular builds. This should continue to work even with stddef.h +// included. +void f(__null void* p) { } + +// NULL should work fine even with __null defined to nothing. +void* p = NULL; diff --git a/test/Index/Inputs/CommentXML/invalid-function-01.xml b/test/Index/Inputs/CommentXML/invalid-function-01.xml new file mode 100644 index 000000000000..85f06695a0ce --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-01.xml @@ -0,0 +1,7 @@ + + +aaa +Aaa. + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-02.xml b/test/Index/Inputs/CommentXML/invalid-function-02.xml new file mode 100644 index 000000000000..700711b0a08e --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-02.xml @@ -0,0 +1,9 @@ + + +aaa +Aaa. + + + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-03.xml b/test/Index/Inputs/CommentXML/invalid-function-03.xml new file mode 100644 index 000000000000..0c4618f1efec --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-03.xml @@ -0,0 +1,11 @@ + + +aaa +Aaa. + + + + Bbb. + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-04.xml b/test/Index/Inputs/CommentXML/invalid-function-04.xml new file mode 100644 index 000000000000..88dd5a851c0a --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-04.xml @@ -0,0 +1,11 @@ + + +aaa +Aaa. + + + + Bbb. + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-05.xml b/test/Index/Inputs/CommentXML/invalid-function-05.xml new file mode 100644 index 000000000000..ce96b7d05fe6 --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-05.xml @@ -0,0 +1,10 @@ + + +aaa +Aaa. + + + x1 + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-06.xml b/test/Index/Inputs/CommentXML/invalid-function-06.xml new file mode 100644 index 000000000000..5419c677aa0b --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-06.xml @@ -0,0 +1,5 @@ + + +aaa +Aaa . + diff --git a/test/Index/Inputs/CommentXML/invalid-function-07.xml b/test/Index/Inputs/CommentXML/invalid-function-07.xml new file mode 100644 index 000000000000..ce7eccec1e4f --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-07.xml @@ -0,0 +1,13 @@ + + +aaa +Aaa. + + + x1 + -1 + in + Bbb + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-08.xml b/test/Index/Inputs/CommentXML/invalid-function-08.xml new file mode 100644 index 000000000000..66e69e817223 --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-08.xml @@ -0,0 +1,13 @@ + + +aaa +Aaa. + + + x1 + 0 + in + Bbb + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-09.xml b/test/Index/Inputs/CommentXML/invalid-function-09.xml new file mode 100644 index 000000000000..39617b6a875d --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-09.xml @@ -0,0 +1,13 @@ + + +aaa +Aaa. + + + x1 + 0 + aaa + Bbb + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-10.xml b/test/Index/Inputs/CommentXML/invalid-function-10.xml new file mode 100644 index 000000000000..ccce4bbe56b9 --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-10.xml @@ -0,0 +1,11 @@ + + +aaa +Aaa. + + + x1 + + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-11.xml b/test/Index/Inputs/CommentXML/invalid-function-11.xml new file mode 100644 index 000000000000..167911e9e7dc --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-11.xml @@ -0,0 +1,13 @@ + + +aaa +Aaa. + + + x1 + aaa + Bbb + + + + diff --git a/test/Index/Inputs/CommentXML/invalid-function-12.xml b/test/Index/Inputs/CommentXML/invalid-function-12.xml new file mode 100644 index 000000000000..f5b5e03e33b9 --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-12.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. + + diff --git a/test/Index/Inputs/CommentXML/valid-class-01.xml b/test/Index/Inputs/CommentXML/valid-class-01.xml new file mode 100644 index 000000000000..bd893e62d59c --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-class-01.xml @@ -0,0 +1,5 @@ + + +aaa +Aaa. + diff --git a/test/Index/Inputs/CommentXML/valid-class-02.xml b/test/Index/Inputs/CommentXML/valid-class-02.xml new file mode 100644 index 000000000000..2e20a921f7bc --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-class-02.xml @@ -0,0 +1,5 @@ + + +aaa +Aaa. + diff --git a/test/Index/Inputs/CommentXML/valid-class-03.xml b/test/Index/Inputs/CommentXML/valid-class-03.xml new file mode 100644 index 000000000000..2ce1a2c98dd8 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-class-03.xml @@ -0,0 +1,5 @@ + + +aaa +Aaa. + diff --git a/test/Index/Inputs/CommentXML/valid-class-04.xml b/test/Index/Inputs/CommentXML/valid-class-04.xml new file mode 100644 index 000000000000..da1522d85aab --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-class-04.xml @@ -0,0 +1,5 @@ + + +aaa +Aaa. + diff --git a/test/Index/Inputs/CommentXML/valid-enum-01.xml b/test/Index/Inputs/CommentXML/valid-enum-01.xml new file mode 100644 index 000000000000..e346d738eb69 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-enum-01.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. + + diff --git a/test/Index/Inputs/CommentXML/valid-function-01.xml b/test/Index/Inputs/CommentXML/valid-function-01.xml new file mode 100644 index 000000000000..02060e7fb7b2 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-01.xml @@ -0,0 +1,5 @@ + + +aaa +Aaa. + diff --git a/test/Index/Inputs/CommentXML/valid-function-02.xml b/test/Index/Inputs/CommentXML/valid-function-02.xml new file mode 100644 index 000000000000..989d6a7c143d --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-02.xml @@ -0,0 +1,5 @@ + + +aaa +Aaa bbb ccc ddd. + diff --git a/test/Index/Inputs/CommentXML/valid-function-03.xml b/test/Index/Inputs/CommentXML/valid-function-03.xml new file mode 100644 index 000000000000..891211d81c81 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-03.xml @@ -0,0 +1,12 @@ + + +aaa +Aaa. + + + x1 + in + Bbb + + + diff --git a/test/Index/Inputs/CommentXML/valid-function-04.xml b/test/Index/Inputs/CommentXML/valid-function-04.xml new file mode 100644 index 000000000000..b65b3e92ff62 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-04.xml @@ -0,0 +1,13 @@ + + +aaa +Aaa. + + + x1 + 0 + in + Bbb + + + diff --git a/test/Index/Inputs/CommentXML/valid-function-05.xml b/test/Index/Inputs/CommentXML/valid-function-05.xml new file mode 100644 index 000000000000..2dddbd7be227 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-05.xml @@ -0,0 +1,8 @@ + + +aaa +Aaa. + + Ccc + + diff --git a/test/Index/Inputs/CommentXML/valid-function-06.xml b/test/Index/Inputs/CommentXML/valid-function-06.xml new file mode 100644 index 000000000000..1df3aa42b8e0 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-06.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. +Ccc. + diff --git a/test/Index/Inputs/CommentXML/valid-function-07.xml b/test/Index/Inputs/CommentXML/valid-function-07.xml new file mode 100644 index 000000000000..89b8a0ca6fc8 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-07.xml @@ -0,0 +1,30 @@ + + +aaa +Aaa. + + + x2 + 0 + in + Bbb + + + x3 + 2 + out + Ccc + + + x1 + in,out + Ddd + + +Eee. + + Fff + Ggg + + + diff --git a/test/Index/Inputs/CommentXML/valid-function-08.xml b/test/Index/Inputs/CommentXML/valid-function-08.xml new file mode 100644 index 000000000000..481a6c06589a --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-08.xml @@ -0,0 +1,17 @@ + + +aaa +Aaa. + + + x1 + 0 + Bbb + + + x2 + Ccc + + + + diff --git a/test/Index/Inputs/CommentXML/valid-function-09.xml b/test/Index/Inputs/CommentXML/valid-function-09.xml new file mode 100644 index 000000000000..cf4cc8fbd7cf --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-09.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. + + diff --git a/test/Index/Inputs/CommentXML/valid-function-10.xml b/test/Index/Inputs/CommentXML/valid-function-10.xml new file mode 100644 index 000000000000..4fadf30e6fb1 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-10.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. + + diff --git a/test/Index/Inputs/CommentXML/valid-namespace-01.xml b/test/Index/Inputs/CommentXML/valid-namespace-01.xml new file mode 100644 index 000000000000..a73aad5548f6 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-namespace-01.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. + + diff --git a/test/Index/Inputs/CommentXML/valid-other-01.xml b/test/Index/Inputs/CommentXML/valid-other-01.xml new file mode 100644 index 000000000000..46b8a4676f78 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-other-01.xml @@ -0,0 +1,5 @@ + + +aaa +Aaa. + diff --git a/test/Index/Inputs/CommentXML/valid-typedef-01.xml b/test/Index/Inputs/CommentXML/valid-typedef-01.xml new file mode 100644 index 000000000000..1b7da8d83bbf --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-typedef-01.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. + + diff --git a/test/Index/Inputs/CommentXML/valid-typedef-02.xml b/test/Index/Inputs/CommentXML/valid-typedef-02.xml new file mode 100644 index 000000000000..2a3218906b2d --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-typedef-02.xml @@ -0,0 +1,25 @@ + + +aaa +Aaa. + + + x1 + 0 + Bbb + + + + + x1 + 0 + in + Ccc + + +Ddd. + + Eee. + + + diff --git a/test/Index/Inputs/CommentXML/valid-variable-01.xml b/test/Index/Inputs/CommentXML/valid-variable-01.xml new file mode 100644 index 000000000000..e17da91da34d --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-variable-01.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. + + diff --git a/test/Index/Inputs/annotate-comments-preprocessor.h b/test/Index/Inputs/annotate-comments-preprocessor.h new file mode 100644 index 000000000000..220f36ede4bf --- /dev/null +++ b/test/Index/Inputs/annotate-comments-preprocessor.h @@ -0,0 +1,2 @@ +/* Meow */ + diff --git a/test/Index/annotate-comments-preprocessor.c b/test/Index/annotate-comments-preprocessor.c new file mode 100644 index 000000000000..202847ff9c91 --- /dev/null +++ b/test/Index/annotate-comments-preprocessor.c @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs %s + +// As long as none of this crashes, we don't care about comments in +// preprocessor directives. + +#include "annotate-comments-preprocessor.h" /* Aaa. */ /* Bbb. */ +#include "annotate-comments-preprocessor.h" /* Aaa. */ +#include "annotate-comments-preprocessor.h" /** Aaa. */ +#include "annotate-comments-preprocessor.h" /**< Aaa. */ +#include "annotate-comments-preprocessor.h" // Aaa. +#include "annotate-comments-preprocessor.h" /// Aaa. +#include "annotate-comments-preprocessor.h" ///< Aaa. + +#define A0 0 +#define A1 1 /* Aaa. */ +#define A2 1 /** Aaa. */ +#define A3 1 /**< Aaa. */ +#define A4 1 // Aaa. +#define A5 1 /// Aaa. +#define A6 1 ///< Aaa. + +int A[] = { A0, A1, A2, A3, A4, A5, A6 }; + +#if A0 /** Aaa. */ +int f(int a1[A1], int a2[A2], int a3[A3], int a4[A4], int a5[A5], int a6[A6]); +#endif /** Aaa. */ + +#if A1 /** Aaa. */ +int g(int a1[A1], int a2[A2], int a3[A3], int a4[A4], int a5[A5], int a6[A6]); +#endif /* Aaa. */ + +#pragma once /** Aaa. */ + +#define FOO \ + do { \ + /* Aaa. */ \ + /** Aaa. */ \ + /**< Aaa. */ \ + ; \ + } while(0) + +void h(void) { + FOO; +} + diff --git a/test/Index/annotate-comments-unterminated.c b/test/Index/annotate-comments-unterminated.c new file mode 100644 index 000000000000..6bba911aac93 --- /dev/null +++ b/test/Index/annotate-comments-unterminated.c @@ -0,0 +1,13 @@ +// RUN: c-index-test -test-load-source all %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=ERR %s + +// CHECK: annotate-comments-unterminated.c:9:5: VarDecl=x:{{.*}} RawComment=[/** Aaa. */]{{.*}} BriefComment=[Aaa.] +// CHECK: annotate-comments-unterminated.c:11:5: VarDecl=y:{{.*}} RawComment=[/**< Bbb. */]{{.*}} BriefComment=[Bbb.] +// CHECK-ERR: error: unterminated + +/** Aaa. */ +int x; + +int y; /**< Bbb. */ +/**< Ccc. + * Ddd. diff --git a/test/Index/annotate-comments.cpp b/test/Index/annotate-comments.cpp new file mode 100644 index 000000000000..22724d0b68d7 --- /dev/null +++ b/test/Index/annotate-comments.cpp @@ -0,0 +1,926 @@ +// Run lines are sensitive to line numbers and come below the code. + +#ifndef HEADER +#define HEADER + +// Not a Doxygen comment. NOT_DOXYGEN +void notdoxy1(void); + +/* Not a Doxygen comment. NOT_DOXYGEN */ +void notdoxy2(void); + +/*/ Not a Doxygen comment. NOT_DOXYGEN */ +void notdoxy3(void); + +/** Doxygen comment. isdoxy4 IS_DOXYGEN_SINGLE */ +void isdoxy4(void); + +/** + * Doxygen comment. isdoxy5 IS_DOXYGEN_SINGLE */ +void isdoxy5(void); + +/** + * Doxygen comment. + * isdoxy6 IS_DOXYGEN_SINGLE */ +void isdoxy6(void); + +/** + * Doxygen comment. + * isdoxy7 IS_DOXYGEN_SINGLE + */ +void isdoxy7(void); + +/*! Doxygen comment. isdoxy8 IS_DOXYGEN_SINGLE */ +void isdoxy8(void); + +/// Doxygen comment. isdoxy9 IS_DOXYGEN_SINGLE +void isdoxy9(void); + +// Not a Doxygen comment. NOT_DOXYGEN +/// Doxygen comment. isdoxy10 IS_DOXYGEN_SINGLE +void isdoxy10(void); + +/// Doxygen comment. isdoxy11 IS_DOXYGEN_SINGLE +// Not a Doxygen comment. NOT_DOXYGEN +void isdoxy11(void); + +/** Doxygen comment. isdoxy12 IS_DOXYGEN_SINGLE */ +/* Not a Doxygen comment. NOT_DOXYGEN */ +void isdoxy12(void); + +/// Doxygen comment. isdoxy13 IS_DOXYGEN_START +/// Doxygen comment. IS_DOXYGEN_END +void isdoxy13(void); + +/// Doxygen comment. isdoxy14 IS_DOXYGEN_START +/// Blah-blah-blah. +/// Doxygen comment. IS_DOXYGEN_END +void isdoxy14(void); + +/// Doxygen comment. isdoxy15 IS_DOXYGEN_START +/** Blah-blah-blah */ +/// Doxygen comment. IS_DOXYGEN_END +void isdoxy15(void); + +/** Blah-blah-blah. isdoxy16 IS_DOXYGEN_START *//** Blah */ +/// Doxygen comment. IS_DOXYGEN_END +void isdoxy16(void); + +/// isdoxy17 IS_DOXYGEN_START +// Not a Doxygen comment, but still picked up. +/// IS_DOXYGEN_END +void isdoxy17(void); + +unsigned +// NOT_DOXYGEN +/// isdoxy18 IS_DOXYGEN_START +// Not a Doxygen comment, but still picked up. +/// IS_DOXYGEN_END +// NOT_DOXYGEN +int isdoxy18(void); + +//! It all starts here. isdoxy19 IS_DOXYGEN_START +/*! It's a little odd to continue line this, + * + * but we need more multi-line comments. */ +/// This comment comes before my other comments +/** This is a block comment that is associated with the function f. It + * runs for three lines. IS_DOXYGEN_END + */ +void isdoxy19(int, int); + +// NOT IN THE COMMENT NOT_DOXYGEN +/// This is a BCPL comment. isdoxy20 IS_DOXYGEN_START +/// It has only two lines. +/** But there are other blocks that are part of the comment, too. IS_DOXYGEN_END */ +void isdoxy20(int); + +void notdoxy21(int); ///< This is a member comment. isdoxy21 IS_DOXYGEN_NOT_ATTACHED + +void notdoxy22(int); /*!< This is a member comment. isdoxy22 IS_DOXYGEN_NOT_ATTACHED */ + +void notdoxy23(int); /**< This is a member comment. isdoxy23 IS_DOXYGEN_NOT_ATTACHED */ + +void notdoxy24(int); // NOT_DOXYGEN + +/// IS_DOXYGEN_SINGLE +struct isdoxy25 { +}; + +struct test26 { + /// IS_DOXYGEN_SINGLE + int isdoxy26; +}; + +struct test27 { + int isdoxy27; ///< IS_DOXYGEN_SINGLE +}; + +struct notdoxy28 { +}; ///< IS_DOXYGEN_NOT_ATTACHED + +/// IS_DOXYGEN_SINGLE +enum isdoxy29 { +}; + +enum notdoxy30 { +}; ///< IS_DOXYGEN_NOT_ATTACHED + +/// IS_DOXYGEN_SINGLE +namespace isdoxy31 { +}; + +namespace notdoxy32 { +}; ///< IS_DOXYGEN_NOT_ATTACHED + +class test33 { + ///< IS_DOXYGEN_NOT_ATTACHED + int isdoxy33; ///< isdoxy33 IS_DOXYGEN_SINGLE + int isdoxy34; ///< isdoxy34 IS_DOXYGEN_SINGLE + + ///< IS_DOXYGEN_NOT_ATTACHED + int isdoxy35, ///< isdoxy35 IS_DOXYGEN_SINGLE + isdoxy36; ///< isdoxy36 IS_DOXYGEN_SINGLE + + ///< IS_DOXYGEN_NOT_ATTACHED + int isdoxy37 ///< isdoxy37 IS_DOXYGEN_SINGLE + , isdoxy38 ///< isdoxy38 IS_DOXYGEN_SINGLE + , isdoxy39; ///< isdoxy39 IS_DOXYGEN_SINGLE +}; + +// Verified that Doxygen attaches these. + +/// isdoxy40 IS_DOXYGEN_SINGLE +// NOT_DOXYGEN +void isdoxy40(int); + +unsigned +/// isdoxy41 IS_DOXYGEN_SINGLE +// NOT_DOXYGEN +int isdoxy41(int); + +class test42 { + int isdoxy42; /* NOT_DOXYGEN */ ///< isdoxy42 IS_DOXYGEN_SINGLE +}; + +/// IS_DOXYGEN_START +/// It is fine to have a command at the end of comment. +///\brief +/// +/// Some malformed command. +/* \*/ +/** + * \brief Aaa aaaaaaa aaaa. + * IS_DOXYGEN_END + */ +void isdoxy43(void); + +/// IS_DOXYGEN_START Aaa bbb +/// ccc. +/// +/// Ddd eee. +/// Fff. +/// +/// Ggg. IS_DOXYGEN_END +void isdoxy44(void); + +/// IS_DOXYGEN_START Aaa bbb +/// ccc. +/// +/// \brief +/// Ddd eee. +/// Fff. +/// +/// Ggg. IS_DOXYGEN_END +void isdoxy45(void); + +/// IS_DOXYGEN_START Aaa bbb +/// ccc. +/// +/// \short +/// Ddd eee. +/// Fff. +/// +/// Ggg. IS_DOXYGEN_END +void isdoxy46(void); + +/// IS_DOXYGEN_NOT_ATTACHED +#define FOO +void notdoxy47(void); + +/// IS_DOXYGEN_START Aaa bbb +/// \param ccc +/// \returns ddd IS_DOXYGEN_END +void isdoxy48(int); + +/// \brief IS_DOXYGEN_START Aaa +/// \returns bbb IS_DOXYGEN_END +void isdoxy49(void); + +/// \param ccc IS_DOXYGEN_START +/// \returns ddd IS_DOXYGEN_END +void isdoxy50(int); + +/// Aaa. +void comment_to_html_conversion_1(); + +/// \brief Aaa. +void comment_to_html_conversion_2(); + +/// \short Aaa. +void comment_to_html_conversion_3(); + +/// Aaa. +/// +/// \brief Bbb. +void comment_to_html_conversion_4(); + +/// Aaa. +/// +/// \brief Bbb. +/// +/// Ccc. +void comment_to_html_conversion_5(); + +/// \brief Aaa. +/// \brief Bbb. +void comment_to_html_conversion_6(); + +/// Aaa. +/// +/// \return Bbb. +void comment_to_html_conversion_7(); + +/// Aaa. +/// +/// \returns Bbb. +void comment_to_html_conversion_8(); + +/// Aaa. +/// +/// \result Bbb. +void comment_to_html_conversion_9(); + +/// \returns Aaa. +/// \returns Bbb. +void comment_to_html_conversion_10(); + +/// Aaa. +/// +/// Bbb. +/// +/// \returns Ccc. +void comment_to_html_conversion_11(); + +/// \param +void comment_to_html_conversion_12(int x1); + +/// \param x1 Aaa. +void comment_to_html_conversion_13(int x1); + +/// \param zzz Aaa. +void comment_to_html_conversion_14(int x1); + +/// \param x2 Bbb. +/// \param x1 Aaa. +void comment_to_html_conversion_15(int x1, int x2); + +/// \param x2 Bbb. +/// \param zzz Aaa. +/// \param x1 Aaa. +void comment_to_html_conversion_16(int x1, int x2); + +/// \tparam +/// \param aaa Blah blah +template +void comment_to_html_conversion_17(T aaa); + +/// \tparam T +/// \param aaa Blah blah +template +void comment_to_html_conversion_18(T aaa); + +/// \tparam T2 Bbb +/// \tparam T1 Aaa +template +void comment_to_html_conversion_19(T1 aaa, T2 bbb); + +/// \tparam T2 Bbb +/// \tparam U Zzz +/// \tparam V Ccc +/// \tparam T1 Aaa +template +void comment_to_html_conversion_20(T1 aaa, T2 bbb); + +/// \tparam TTT Ddd +/// \tparam C Ccc +/// \tparam T Aaa +/// \tparam TT Bbb +template class TT, class C> class TTT> +void comment_to_html_conversion_21(); + +/// \brief Aaa. +/// +/// Bbb. +/// +/// \param x2 Ddd. +/// \param x1 Ccc. +/// \returns Eee. +void comment_to_html_conversion_22(int x1, int x2); + +///
Aaa +void comment_to_html_conversion_23(); + +/// \verbatim +/// Aaa +/// Aaa +/// \endverbatim +void comment_to_html_conversion_24(); + +/// \function foo +/// \class foo +/// \method foo +/// \interface foo +/// Blah blah. +void comment_to_html_conversion_25(); + +/// \b Aaa +void comment_to_html_conversion_26(); + +/// \c Aaa \p Bbb +void comment_to_html_conversion_27(); + +/// \a Aaa \e Bbb \em Ccc +void comment_to_html_conversion_28(); + +/// \a 1<2 \e 3<4 \em 5<6 \param 7<8 aaa \tparam 9<10 bbb +void comment_to_html_conversion_29(); + +/// \\ \@ \& \$ \# \< \> \% \" \. \:: +void comment_to_html_conversion_30(); + +/// & < > " +void comment_to_html_conversion_31(); + +/// 0<i +void comment_to_html_conversion_32(); + +/// Aaa. +class comment_to_xml_conversion_01 { + /// \param aaa Blah blah. + comment_to_xml_conversion_01(int aaa); + + /// Aaa. + ~comment_to_xml_conversion_01(); + + /// \param aaa Blah blah. + int comment_to_xml_conversion_02(int aaa); + + /// \param aaa Blah blah. + static int comment_to_xml_conversion_03(int aaa); + + /// Aaa. + int comment_to_xml_conversion_04; + + /// Aaa. + static int comment_to_xml_conversion_05; + + /// \param aaa Blah blah. + void operator()(int aaa); + + /// Aaa. + operator bool(); + + /// Aaa. + typedef int comment_to_xml_conversion_06; + + /// Aaa. + using comment_to_xml_conversion_07 = int; + + template + class comment_to_xml_conversion_08 { }; + + /// Aaa. + template + using comment_to_xml_conversion_09 = comment_to_xml_conversion_08; +}; + +/// Aaa. +template +void comment_to_xml_conversion_10(T aaa, U bbb); + +/// Aaa. +template<> +void comment_to_xml_conversion_10(int aaa, int bbb); + +/// Aaa. +template +class comment_to_xml_conversion_11 { }; + +/// Aaa. +template +class comment_to_xml_conversion_11 { }; + +/// Aaa. +template<> +class comment_to_xml_conversion_11 { }; + +/// Aaa. +int comment_to_xml_conversion_12; + +/// Aaa. +namespace comment_to_xml_conversion_13 { + /// Aaa. + namespace comment_to_xml_conversion_14 { + } +} + +/// Aaa. +enum comment_to_xml_conversion_15 { + /// Aaa. + comment_to_xml_conversion_16 +}; + +/// Aaa. +enum class comment_to_xml_conversion_17 { + /// Aaa. + comment_to_xml_conversion_18 +}; + +#endif + +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t/out.pch %s +// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t/out.pch -fsyntax-only %s + +// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -std=c++11 > %t/out.c-index-direct +// RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch + +// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct +// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-pch + +// Declarations without Doxygen comments should not pick up some Doxygen comments. +// WRONG-NOT: notdoxy{{.*}}Comment= +// WRONG-NOT: test{{.*}}Comment= + +// Non-Doxygen comments should not be attached to anything. +// WRONG-NOT: NOT_DOXYGEN + +// Some Doxygen comments are not attached to anything. +// WRONG-NOT: IS_DOXYGEN_NOT_ATTACHED + +// Ensure we don't pick up extra comments. +// WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START{{.*}}BriefComment= +// WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END{{.*}}BriefComment= +// +// Ensure that XML is not invalid +// WRONG-NOT: CommentXMLInvalid + +// RUN: FileCheck %s < %t/out.c-index-direct +// RUN: FileCheck %s < %t/out.c-index-pch + +// CHECK: annotate-comments.cpp:16:6: FunctionDecl=isdoxy4:{{.*}} isdoxy4 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:20:6: FunctionDecl=isdoxy5:{{.*}} isdoxy5 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:25:6: FunctionDecl=isdoxy6:{{.*}} isdoxy6 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:31:6: FunctionDecl=isdoxy7:{{.*}} isdoxy7 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:34:6: FunctionDecl=isdoxy8:{{.*}} isdoxy8 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:37:6: FunctionDecl=isdoxy9:{{.*}} isdoxy9 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:41:6: FunctionDecl=isdoxy10:{{.*}} isdoxy10 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:53:6: FunctionDecl=isdoxy13:{{.*}} isdoxy13 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:58:6: FunctionDecl=isdoxy14:{{.*}} isdoxy14 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:63:6: FunctionDecl=isdoxy15:{{.*}} isdoxy15 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:67:6: FunctionDecl=isdoxy16:{{.*}} isdoxy16 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:72:6: FunctionDecl=isdoxy17:{{.*}} isdoxy17 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:80:5: FunctionDecl=isdoxy18:{{.*}} isdoxy18 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:90:6: FunctionDecl=isdoxy19:{{.*}} isdoxy19 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:96:6: FunctionDecl=isdoxy20:{{.*}} isdoxy20 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:107:8: StructDecl=isdoxy25:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:112:7: FieldDecl=isdoxy26:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:116:7: FieldDecl=isdoxy27:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:123:6: EnumDecl=isdoxy29:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:130:11: Namespace=isdoxy31:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:138:7: FieldDecl=isdoxy33:{{.*}} isdoxy33 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:139:7: FieldDecl=isdoxy34:{{.*}} isdoxy34 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:142:7: FieldDecl=isdoxy35:{{.*}} isdoxy35 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:143:7: FieldDecl=isdoxy36:{{.*}} isdoxy36 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:146:7: FieldDecl=isdoxy37:{{.*}} isdoxy37 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:147:7: FieldDecl=isdoxy38:{{.*}} isdoxy38 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:148:7: FieldDecl=isdoxy39:{{.*}} isdoxy39 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:155:6: FunctionDecl=isdoxy40:{{.*}} isdoxy40 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:160:5: FunctionDecl=isdoxy41:{{.*}} isdoxy41 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:163:7: FieldDecl=isdoxy42:{{.*}} isdoxy42 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:176:6: FunctionDecl=isdoxy43:{{.*}} IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END + +// CHECK: annotate-comments.cpp:185:6: FunctionDecl=isdoxy44:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb ccc.] +// CHECK: annotate-comments.cpp:195:6: FunctionDecl=isdoxy45:{{.*}} BriefComment=[Ddd eee. Fff.] +// CHECK: annotate-comments.cpp:205:6: FunctionDecl=isdoxy46:{{.*}} BriefComment=[Ddd eee. Fff.] +// CHECK: annotate-comments.cpp:214:6: FunctionDecl=isdoxy48:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb] +// CHECK: annotate-comments.cpp:218:6: FunctionDecl=isdoxy49:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa] +// CHECK: annotate-comments.cpp:222:6: FunctionDecl=isdoxy50:{{.*}} BriefComment=[Returns ddd IS_DOXYGEN_END] + +// CHECK: annotate-comments.cpp:225:6: FunctionDecl=comment_to_html_conversion_1:{{.*}} FullCommentAsHTML=[

Aaa.

] FullCommentAsXML=[comment_to_html_conversion_1c:@F@comment_to_html_conversion_1# Aaa.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])))] +// CHECK: annotate-comments.cpp:228:6: FunctionDecl=comment_to_html_conversion_2:{{.*}} FullCommentAsHTML=[

Aaa.

] FullCommentAsXML=[comment_to_html_conversion_2c:@F@comment_to_html_conversion_2# Aaa.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:231:6: FunctionDecl=comment_to_html_conversion_3:{{.*}} FullCommentAsHTML=[

Aaa.

] FullCommentAsXML=[comment_to_html_conversion_3c:@F@comment_to_html_conversion_3# Aaa.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[short] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:236:6: FunctionDecl=comment_to_html_conversion_4:{{.*}} FullCommentAsHTML=[

Bbb.

Aaa.

] FullCommentAsXML=[comment_to_html_conversion_4c:@F@comment_to_html_conversion_4# Bbb. Aaa.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:243:6: FunctionDecl=comment_to_html_conversion_5:{{.*}} FullCommentAsHTML=[

Bbb.

Aaa.

Ccc.

] FullCommentAsXML=[comment_to_html_conversion_5c:@F@comment_to_html_conversion_5# Bbb. Aaa. Ccc.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))) +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc.])))] +// CHECK: annotate-comments.cpp:247:6: FunctionDecl=comment_to_html_conversion_6:{{.*}} FullCommentAsHTML=[

Aaa.

Bbb.

] FullCommentAsXML=[comment_to_html_conversion_6c:@F@comment_to_html_conversion_6# Aaa. Bbb.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:252:6: FunctionDecl=comment_to_html_conversion_7:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_7c:@F@comment_to_html_conversion_7# Aaa. Bbb.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[return] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:257:6: FunctionDecl=comment_to_html_conversion_8:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_8c:@F@comment_to_html_conversion_8# Aaa. Bbb.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:262:6: FunctionDecl=comment_to_html_conversion_9:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_9c:@F@comment_to_html_conversion_9# Aaa. Bbb.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[result] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:266:6: FunctionDecl=comment_to_html_conversion_10:{{.*}} FullCommentAsHTML=[

Returns Bbb.

Returns Aaa.

] FullCommentAsXML=[comment_to_html_conversion_10c:@F@comment_to_html_conversion_10# Aaa. Bbb.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:273:6: FunctionDecl=comment_to_html_conversion_11:{{.*}} FullCommentAsHTML=[

Aaa.

Bbb.

Returns Ccc.

] FullCommentAsXML=[comment_to_html_conversion_11c:@F@comment_to_html_conversion_11# Aaa. Ccc. Bbb.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc.]))))] +// CHECK: annotate-comments.cpp:276:6: FunctionDecl=comment_to_html_conversion_12:{{.*}} FullCommentAsHTML=[] FullCommentAsXML=[comment_to_html_conversion_12c:@F@comment_to_html_conversion_12#I#] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[] ParamIndex=Invalid +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace)))] +// CHECK: annotate-comments.cpp:279:6: FunctionDecl=comment_to_html_conversion_13:{{.*}} FullCommentAsHTML=[
x1
Aaa.
] FullCommentAsXML=[comment_to_html_conversion_13c:@F@comment_to_html_conversion_13#I#x10in Aaa.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x1] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:282:6: FunctionDecl=comment_to_html_conversion_14:{{.*}} FullCommentAsHTML=[
zzz
Aaa.
] FullCommentAsXML=[comment_to_html_conversion_14c:@F@comment_to_html_conversion_14#I#zzzin Aaa.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[zzz] ParamIndex=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:286:6: FunctionDecl=comment_to_html_conversion_15:{{.*}} FullCommentAsHTML=[
x1
Aaa.
x2
Bbb.
] FullCommentAsXML=[comment_to_html_conversion_15c:@F@comment_to_html_conversion_15#I#I#x10in Aaa.x21in Bbb. ] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x2] ParamIndex=1 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x1] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:291:6: FunctionDecl=comment_to_html_conversion_16:{{.*}} FullCommentAsHTML=[
x1
Aaa.
x2
Bbb.
zzz
Aaa.
] FullCommentAsXML=[comment_to_html_conversion_16c:@F@comment_to_html_conversion_16#I#I#x10in Aaa.x21in Bbb. zzzin Aaa. ] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x2] ParamIndex=1 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[zzz] ParamIndex=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x1] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:296:6: FunctionTemplate=comment_to_html_conversion_17:{{.*}} FullCommentAsHTML=[
aaa
Blah blah
] FullCommentAsXML=[comment_to_html_conversion_17c:@FT@>1#Tcomment_to_html_conversion_17#t0.0#aaa0in Blah blah] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[] ParamPosition=Invalid +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[aaa] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Blah blah]))))] +// CHECK: annotate-comments.cpp:301:6: FunctionTemplate=comment_to_html_conversion_18:{{.*}} FullCommentAsHTML=[
aaa
Blah blah
] FullCommentAsXML=[comment_to_html_conversion_18c:@FT@>1#Tcomment_to_html_conversion_18#t0.0#aaa0in Blah blah] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T] ParamPosition={0} +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[aaa] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Blah blah]))))] +// CHECK: annotate-comments.cpp:306:6: FunctionTemplate=comment_to_html_conversion_19:{{.*}} FullCommentAsHTML=[
T1
Aaa
T2
Bbb
] FullCommentAsXML=[comment_to_html_conversion_19c:@FT@>2#T#Tcomment_to_html_conversion_19#t0.0#t0.1#T10 AaaT21 Bbb ] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T2] ParamPosition={1} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T1] ParamPosition={0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa]))))] +// CHECK: annotate-comments.cpp:313:6: FunctionTemplate=comment_to_html_conversion_20:{{.*}} FullCommentAsHTML=[
T1
Aaa
T2
Bbb
V
Ccc
U
Zzz
] FullCommentAsXML=[comment_to_html_conversion_20c:@FT@>3#T#T#NIcomment_to_html_conversion_20#t0.0#t0.1#T10 AaaT21 Bbb V2 Ccc U Zzz ] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T2] ParamPosition={1} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[U] ParamPosition=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Zzz] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[V] ParamPosition={2} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T1] ParamPosition={0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa]))))] +// CHECK: annotate-comments.cpp:320:6: FunctionTemplate=comment_to_html_conversion_21:{{.*}} FullCommentAsHTML=[
TTT
Ddd
C
Ccc
T
Aaa
TT
Bbb
] FullCommentAsXML=[comment_to_html_conversion_21c:@FT@>1#t>2#t>1#T#Tcomment_to_html_conversion_21#TTT0 Ddd C Ccc T Aaa TT Bbb] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[TTT] ParamPosition={0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ddd] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[C] ParamPosition={0, 1} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T] ParamPosition={0, 0, 0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[TT] ParamPosition={0, 0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb]))))] +// CHECK: annotate-comments.cpp:329:6: FunctionDecl=comment_to_html_conversion_22:{{.*}} FullCommentAsHTML=[

Aaa.

Bbb.

x1
Ccc.
x2
Ddd.

Returns Eee.

] FullCommentAsXML=[comment_to_html_conversion_22c:@F@comment_to_html_conversion_22#I#I# Aaa.x10in Ccc. x21in Ddd. Eee. Bbb.] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))) +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x2] ParamIndex=1 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ddd.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x1] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Eee.]))))] +// CHECK: annotate-comments.cpp:332:6: FunctionDecl=comment_to_html_conversion_23:{{.*}} FullCommentAsHTML=[


Aaa

] FullCommentAsXML=[comment_to_html_conversion_23c:@F@comment_to_html_conversion_23# ]]>]]>Aaa</a>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_HTMLStartTag Name=[br]) +// CHECK-NEXT: (CXComment_HTMLStartTag Name=[a] Attrs: href=http://example.com/) +// CHECK-NEXT: (CXComment_Text Text=[Aaa]) +// CHECK-NEXT: (CXComment_HTMLEndTag Name=[a])))] +// CHECK: annotate-comments.cpp:338:6: FunctionDecl=comment_to_html_conversion_24:{{.*}} FullCommentAsHTML=[
 <a href="http://example.com/">Aaa</a>\n <a href='http://example.com/'>Aaa</a>
] FullCommentAsXML=[comment_to_html_conversion_24c:@F@comment_to_html_conversion_24# <a href="http://example.com/">Aaa</a>\n <a href='http://example.com/'>Aaa</a>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_VerbatimBlockCommand CommandName=[verbatim] +// CHECK-NEXT: (CXComment_VerbatimBlockLine Text=[ Aaa]) +// CHECK-NEXT: (CXComment_VerbatimBlockLine Text=[ Aaa])))] +// CHECK: annotate-comments.cpp:345:6: FunctionDecl=comment_to_html_conversion_25:{{.*}} FullCommentAsHTML=[

Blah blah.

] FullCommentAsXML=[comment_to_html_conversion_25c:@F@comment_to_html_conversion_25# Blah blah.] +// CHECK: CommentAST=[ +// CHECK: (CXComment_FullComment +// CHECK: (CXComment_Paragraph IsWhitespace +// CHECK: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK: (CXComment_VerbatimLine Text=[ foo]) +// CHECK: (CXComment_Paragraph IsWhitespace +// CHECK: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK: (CXComment_VerbatimLine Text=[ foo]) +// CHECK: (CXComment_Paragraph IsWhitespace +// CHECK: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK: (CXComment_VerbatimLine Text=[ foo]) +// CHECK: (CXComment_Paragraph IsWhitespace +// CHECK: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK: (CXComment_VerbatimLine Text=[ foo]) +// CHECK: (CXComment_Paragraph +// CHECK: (CXComment_Text Text=[ Blah blah.])))] +// CHECK: annotate-comments.cpp:348:6: FunctionDecl=comment_to_html_conversion_26:{{.*}} FullCommentAsHTML=[

Aaa

] FullCommentAsXML=[comment_to_html_conversion_26c:@F@comment_to_html_conversion_26# Aaa] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[b] RenderBold Arg[0]=Aaa)))] +// CHECK: annotate-comments.cpp:351:6: FunctionDecl=comment_to_html_conversion_27:{{.*}} FullCommentAsHTML=[

Aaa Bbb

] FullCommentAsXML=[comment_to_html_conversion_27c:@F@comment_to_html_conversion_27# Aaa Bbb] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[c] RenderMonospaced Arg[0]=Aaa) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[p] RenderMonospaced Arg[0]=Bbb)))] +// CHECK: annotate-comments.cpp:354:6: FunctionDecl=comment_to_html_conversion_28:{{.*}} FullCommentAsHTML=[

Aaa Bbb Ccc

] FullCommentAsXML=[comment_to_html_conversion_28c:@F@comment_to_html_conversion_28# Aaa Bbb Ccc] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[a] RenderEmphasized Arg[0]=Aaa) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[e] RenderEmphasized Arg[0]=Bbb) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[em] RenderEmphasized Arg[0]=Ccc)))] +// CHECK: annotate-comments.cpp:357:6: FunctionDecl=comment_to_html_conversion_29:{{.*}} FullCommentAsHTML=[

1<2 3<4 5<6

9<10
bbb
7<8
aaa
] FullCommentAsXML=[comment_to_html_conversion_29c:@F@comment_to_html_conversion_29# 1<2 3<4 5<6 9<10 bbb7<8in aaa ] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[a] RenderEmphasized Arg[0]=1<2) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[e] RenderEmphasized Arg[0]=3<4) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[em] RenderEmphasized Arg[0]=5<6) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[7<8] ParamIndex=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ aaa ]))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[9<10] ParamPosition=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ bbb]))))] +// CHECK: annotate-comments.cpp:360:6: FunctionDecl=comment_to_html_conversion_30:{{.*}} FullCommentAsHTML=[

\ @ & $ # < > % " . ::

] FullCommentAsXML=[comment_to_html_conversion_30c:@F@comment_to_html_conversion_30# \ @ & $ # < > % " . ::] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[\]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[@]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[&]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[$]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[#]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[<]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[>]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[%]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=["]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[.]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[::])))] +// CHECK: annotate-comments.cpp:363:6: FunctionDecl=comment_to_html_conversion_31:{{.*}} FullCommentAsHTML=[

& < > "

] FullCommentAsXML=[comment_to_html_conversion_31c:@F@comment_to_html_conversion_31# & < > "] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[&]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[<]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[>]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=["])))] +// CHECK: annotate-comments.cpp:366:6: FunctionDecl=comment_to_html_conversion_32:{{.*}} FullCommentAsHTML=[

0<i

] FullCommentAsXML=[comment_to_html_conversion_32c:@F@comment_to_html_conversion_32# ]]>0<i</em>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_HTMLStartTag Name=[em]) +// CHECK-NEXT: (CXComment_Text Text=[0]) +// CHECK-NEXT: (CXComment_Text Text=[<]) +// CHECK-NEXT: (CXComment_Text Text=[i]) +// CHECK-NEXT: (CXComment_HTMLEndTag Name=[em])))] + +// CHECK: annotate-comments.cpp:369:7: ClassDecl=comment_to_xml_conversion_01:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_01c:@C@comment_to_xml_conversion_01 Aaa.] +// CHECK: annotate-comments.cpp:371:3: CXXConstructor=comment_to_xml_conversion_01:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_01c:@C@comment_to_xml_conversion_01@F@comment_to_xml_conversion_01#I#aaa0in Blah blah.] +// CHECK: annotate-comments.cpp:374:3: CXXDestructor=~comment_to_xml_conversion_01:{{.*}} FullCommentAsXML=[~comment_to_xml_conversion_01c:@C@comment_to_xml_conversion_01@F@~comment_to_xml_conversion_01# Aaa.] +// CHECK: annotate-comments.cpp:377:7: CXXMethod=comment_to_xml_conversion_02:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_02c:@C@comment_to_xml_conversion_01@F@comment_to_xml_conversion_02#I#aaa0in Blah blah.] +// CHECK: annotate-comments.cpp:380:14: CXXMethod=comment_to_xml_conversion_03:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_03c:@C@comment_to_xml_conversion_01@F@comment_to_xml_conversion_03#I#Saaa0in Blah blah.] +// CHECK: annotate-comments.cpp:383:7: FieldDecl=comment_to_xml_conversion_04:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_04c:@C@comment_to_xml_conversion_01@FI@comment_to_xml_conversion_04 Aaa.] +// CHECK: annotate-comments.cpp:386:14: VarDecl=comment_to_xml_conversion_05:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_05c:@C@comment_to_xml_conversion_01@comment_to_xml_conversion_05 Aaa.] +// CHECK: annotate-comments.cpp:389:8: CXXMethod=operator():{{.*}} FullCommentAsXML=[operator()c:@C@comment_to_xml_conversion_01@F@operator()#I#aaa0in Blah blah.] +// CHECK: annotate-comments.cpp:392:3: CXXConversion=operator _Bool:{{.*}} FullCommentAsXML=[operator _Boolc:@C@comment_to_xml_conversion_01@F@operator _Bool# Aaa.] +// CHECK: annotate-comments.cpp:395:15: TypedefDecl=comment_to_xml_conversion_06:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_06c:annotate-comments.cpp@8055@C@comment_to_xml_conversion_01@T@comment_to_xml_conversion_06 Aaa.] +// CHECK: annotate-comments.cpp:398:9: TypeAliasDecl=comment_to_xml_conversion_07:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_07c:@C@comment_to_xml_conversion_01@comment_to_xml_conversion_07 Aaa.] +// CHECK: annotate-comments.cpp:405:3: UnexposedDecl=comment_to_xml_conversion_09:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_09c:@C@comment_to_xml_conversion_01@comment_to_xml_conversion_09 Aaa.] +// CHECK: annotate-comments.cpp:410:6: FunctionTemplate=comment_to_xml_conversion_10:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_10c:@FT@>2#T#Tcomment_to_xml_conversion_10#t0.0#t0.1# Aaa.] +// CHECK: annotate-comments.cpp:414:6: FunctionDecl=comment_to_xml_conversion_10:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_10c:@F@comment_to_xml_conversion_10<#I#I>#I#I# Aaa.] +// CHECK: annotate-comments.cpp:418:7: ClassTemplate=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_11c:@CT>2#T#T@comment_to_xml_conversion_11 Aaa.] +// CHECK: annotate-comments.cpp:422:7: ClassTemplatePartialSpecialization=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_11c:@CP>1#T@comment_to_xml_conversion_11>#t0.0#I Aaa.] +// CHECK: annotate-comments.cpp:426:7: ClassDecl=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_11c:@C@comment_to_xml_conversion_11>#I#I Aaa.] +// CHECK: annotate-comments.cpp:429:5: VarDecl=comment_to_xml_conversion_12:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_12c:@comment_to_xml_conversion_12 Aaa.] +// CHECK: annotate-comments.cpp:432:11: Namespace=comment_to_xml_conversion_13:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_13c:@N@comment_to_xml_conversion_13 Aaa.] +// CHECK: annotate-comments.cpp:434:13: Namespace=comment_to_xml_conversion_14:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_14c:@N@comment_to_xml_conversion_13@N@comment_to_xml_conversion_14 Aaa.] +// CHECK: annotate-comments.cpp:439:6: EnumDecl=comment_to_xml_conversion_15:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_15c:@E@comment_to_xml_conversion_15 Aaa.] +// CHECK: annotate-comments.cpp:441:3: EnumConstantDecl=comment_to_xml_conversion_16:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_16c:@E@comment_to_xml_conversion_15@comment_to_xml_conversion_16 Aaa.] +// CHECK: annotate-comments.cpp:445:12: EnumDecl=comment_to_xml_conversion_17:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_17c:@E@comment_to_xml_conversion_17 Aaa.] +// CHECK: annotate-comments.cpp:447:3: EnumConstantDecl=comment_to_xml_conversion_18:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_18c:@E@comment_to_xml_conversion_17@comment_to_xml_conversion_18 Aaa.] diff --git a/test/Index/availability.c b/test/Index/availability.c new file mode 100644 index 000000000000..e6b1273acafb --- /dev/null +++ b/test/Index/availability.c @@ -0,0 +1,10 @@ +// Run lines below; this test is line- and column-sensitive. + +void foo(void) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7), availability(ios,introduced=3.2,deprecated=4.1))); + +// RUN: c-index-test -test-load-source all %s > %t +// RUN: FileCheck -check-prefix=CHECK-1 %s < %t +// RUN: FileCheck -check-prefix=CHECK-2 %s < %t +// CHECK-1: (ios, introduced=3.2, deprecated=4.1) +// CHECK-2: (macosx, introduced=10.4, deprecated=10.5, obsoleted=10.7) + diff --git a/test/Index/boxed-exprs.h b/test/Index/boxed-exprs.h new file mode 100644 index 000000000000..bdb80383d7ea --- /dev/null +++ b/test/Index/boxed-exprs.h @@ -0,0 +1,10 @@ + +@interface NSString @end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end + +static inline void infoo(const char *cs) { + NSString *s = @(cs); +} diff --git a/test/Index/boxed-exprs.m b/test/Index/boxed-exprs.m new file mode 100644 index 000000000000..0a63b3f6099e --- /dev/null +++ b/test/Index/boxed-exprs.m @@ -0,0 +1,19 @@ + +#include "boxed-exprs.h" + +const char *glob_str; + +void foo() { + NSString *s = @(glob_str); +} + +// RUN: c-index-test -index-file -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-INDEX %s +// CHECK-INDEX: [indexEntityReference]: kind: variable | name: glob_str | {{.*}} | loc: 7:19 + +// RUN: c-index-test -cursor-at=%s:7:24 -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-CURSOR %s +// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:7:24 -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-CURSOR %s +// CHECK-CURSOR: 7:19 DeclRefExpr=glob_str:4:13 Extent=[7:19 - 7:27] Spelling=glob_str ([7:19 - 7:27]) + +// RUN: c-index-test -cursor-at=%S/boxed-exprs.h:9:19 -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-CURSOR2 %s +// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%S/boxed-exprs.h:9:19 -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-CURSOR2 %s +// CHECK-CURSOR2: 9:19 DeclRefExpr=cs:8:38 Extent=[9:19 - 9:21] Spelling=cs ([9:19 - 9:21]) diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m index 251d73b3f819..7520330bce2e 100644 --- a/test/Index/c-index-api-loadTU-test.m +++ b/test/Index/c-index-api-loadTU-test.m @@ -83,7 +83,7 @@ struct X0 {}; // CHECK: :0:0: attribute(ibaction)= // CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53] // CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49] -// CHECK: c-index-api-loadTU-test.m:9:3: ObjCInstanceMethodDecl=foo:9:3 (deprecated) Extent=[9:1 - 9:35] +// CHECK: c-index-api-loadTU-test.m:9:3: ObjCInstanceMethodDecl=foo:9:3 (deprecated) (always deprecated: "") Extent=[9:1 - 9:35] // CHECK: c-index-api-loadTU-test.m:10:3: ObjCClassMethodDecl=fooC:10:3 Extent=[10:1 - 10:8] // CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5] // CHECK: c-index-api-loadTU-test.m:14:18: ObjCSuperClassRef=Foo:4:12 Extent=[14:18 - 14:21] diff --git a/test/Index/comment-xml-schema.c b/test/Index/comment-xml-schema.c new file mode 100644 index 000000000000..1166e78f577e --- /dev/null +++ b/test/Index/comment-xml-schema.c @@ -0,0 +1,43 @@ +// REQUIRES: xmllint + +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-other-01.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-01.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-02.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-03.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-04.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-05.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-06.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-07.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-08.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-09.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-01.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-02.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-03.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-04.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-variable-01.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-namespace-01.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-typedef-01.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-typedef-02.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-enum-01.xml + +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-01.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-02.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-03.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-04.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-05.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-06.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-07.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-08.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-09.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-10.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-11.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-12.xml 2>&1 | FileCheck %s -check-prefix=INVALID + +// CHECK-INVALID: fails to validate + diff --git a/test/Index/compile_commands.json b/test/Index/compile_commands.json new file mode 100644 index 000000000000..89d9f0dd52d8 --- /dev/null +++ b/test/Index/compile_commands.json @@ -0,0 +1,27 @@ +[ +{ + "directory": "/home/john.doe/MyProject", + "command": "clang++ -o project.o -c /home/john.doe/MyProject/project.cpp", + "file": "/home/john.doe/MyProject/project.cpp" +}, +{ + "directory": "/home/john.doe/MyProjectA", + "command": "clang++ -o project2.o -c /home/john.doe/MyProject/project2.cpp", + "file": "/home/john.doe/MyProject/project2.cpp" +}, +{ + "directory": "/home/john.doe/MyProjectB", + "command": "clang++ -DFEATURE=1 -o project2-feature.o -c /home/john.doe/MyProject/project2.cpp", + "file": "/home/john.doe/MyProject/project2.cpp" +} +] +# RUN: c-index-test -compilation-db %s +# RUN: c-index-test -compilation-db lookup file_does_not_exists.cpp %s | FileCheck -check-prefix=FILE-NOT-FOUND %s +# FILE-NOT-FOUND: file file_does_not_exists.cpp not found in compilation db + +# RUN: c-index-test -compilation-db lookup /home/john.doe/MyProject/project.cpp %s | FileCheck -check-prefix=FILE-1-CMD %s +# FILE-1-CMD: workdir:'/home/john.doe/MyProject' cmdline:'clang++ -o project.o -c /home/john.doe/MyProject/project.cpp' + +# RUN: c-index-test -compilation-db lookup /home/john.doe/MyProject/project2.cpp %s | FileCheck -check-prefix=FILE-2-CMD %s +# FILE-2-CMD: workdir:'/home/john.doe/MyProjectA' cmdline:'clang++ -o project2.o -c /home/john.doe/MyProject/project2.cpp' +# FILE-2-CMD: workdir:'/home/john.doe/MyProjectB' cmdline:'clang++ -DFEATURE=1 -o project2-feature.o -c /home/john.doe/MyProject/project2.cpp' diff --git a/test/Index/complete-documentation.cpp b/test/Index/complete-documentation.cpp new file mode 100644 index 000000000000..a64e62f239de --- /dev/null +++ b/test/Index/complete-documentation.cpp @@ -0,0 +1,51 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +/// Aaa. +void T1(float x, float y); + +/// Bbb. +class T2 { +public: + /// Ccc. + void T3(); + + int T4; ///< Ddd. +}; + +/// Eee. +namespace T5 { +} + +struct T6 { + /// \brief Fff. + void T7(); + + /// \brief Ggg. + void T8(); +}; + +void T6::T7() { +} + +void test1() { + + T2 t2; + t2.T4; + + T6 t6; + t6.T8(); +} + +// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:32:1 %s | FileCheck -check-prefix=CC1 %s +// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText T1}{{.*}}(brief comment: Aaa.) +// CHECK-CC1: ClassDecl:{TypedText T2}{{.*}}(brief comment: Bbb.) +// CHECK-CC1: Namespace:{TypedText T5}{{.*}}(brief comment: Eee.) + +// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:34:6 %s | FileCheck -check-prefix=CC2 %s +// CHECK-CC2: CXXMethod:{ResultType void}{TypedText T3}{{.*}}(brief comment: Ccc.) +// CHECK-CC2: FieldDecl:{ResultType int}{TypedText T4}{{.*}}(brief comment: Ddd.) + +// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:37:6 %s | FileCheck -check-prefix=CC3 %s +// CHECK-CC3: CXXMethod:{ResultType void}{TypedText T7}{LeftParen (}{RightParen )} (34) (parent: StructDecl 'T6')(brief comment: Fff.) +// CHECK-CC3: CXXMethod:{ResultType void}{TypedText T8}{LeftParen (}{RightParen )} (34) (parent: StructDecl 'T6')(brief comment: Ggg.) diff --git a/test/Index/complete-exprs.m b/test/Index/complete-exprs.m index c3ff63bdbda6..3fb1540351d5 100644 --- a/test/Index/complete-exprs.m +++ b/test/Index/complete-exprs.m @@ -18,8 +18,10 @@ __strong id global; @end // RUN: c-index-test -code-completion-at=%s:13:2 %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40) -// CHECK-CC1: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40) +// CHECK-CC1: NotImplemented:{ResultType NSString *}{TypedText @"}{Placeholder string}{Text "} (40) +// CHECK-CC1: NotImplemented:{ResultType id}{TypedText @(}{Placeholder expression}{RightParen )} (40) +// CHECK-CC1: NotImplemented:{ResultType NSArray *}{TypedText @[}{Placeholder objects, ...}{RightBracket ]} (40) +// CHECK-CC1: NotImplemented:{ResultType NSDictionary *}{TypedText @{}{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{RightBrace }} (40) // CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80) // CHECK-CC1: TypedefDecl:{TypedText BOOL} (50) // CHECK-CC1: macro definition:{TypedText bool} (51) @@ -40,8 +42,8 @@ __strong id global; // RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC4 %s // RUN: c-index-test -code-completion-at=%s:16:5 %s | FileCheck -check-prefix=CHECK-CC4 %s // RUN: c-index-test -code-completion-at=%s:16:14 %s | FileCheck -check-prefix=CHECK-CC4 %s -// CHECK-CC4: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40) -// CHECK-CC4: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40) +// CHECK-CC4: NotImplemented:{ResultType NSArray *}{TypedText @[}{Placeholder objects, ...}{RightBracket ]} (40) +// CHECK-CC4: NotImplemented:{ResultType NSDictionary *}{TypedText @{}{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{RightBrace }} (40) // CHECK-CC4: NotImplemented:{ResultType SEL}{TypedText _cmd} (80) // CHECK-CC4: macro definition:{TypedText bool} (51) // CHECK-CC4: macro definition:{TypedText NO} (65) diff --git a/test/Index/complete-lambdas.mm b/test/Index/complete-lambdas.mm new file mode 100644 index 000000000000..3f77dd206922 --- /dev/null +++ b/test/Index/complete-lambdas.mm @@ -0,0 +1,51 @@ +// This test is line- and column-sensitive. See below for run lines. + + +@interface A +- instanceMethod:(int)value withOther:(int)other; ++ classMethod; +@end + +@interface B : A +@end + +@implementation B +- someMethod:(A*)a { + [a classMethod]; + [A classMethod]; + [a instanceMethod:0 withOther:1]; + [self someMethod:a]; + [super instanceMethod]; + [&,a ]{}; + [a,self instanceMethod:0 withOther:1]{}; +} + +@end + +// RUN: c-index-test -code-completion-at=%s:14:6 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod:}{Placeholder (int)}{HorizontalSpace }{TypedText withOther:}{Placeholder (int)} (35) (parent: ObjCInterfaceDecl 'A') + +// RUN: c-index-test -code-completion-at=%s:15:6 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: ObjCClassMethodDecl:{ResultType id}{TypedText classMethod} (35) (parent: ObjCInterfaceDecl 'A') + +// RUN: c-index-test -code-completion-at=%s:16:4 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: ObjCInterfaceDecl:{TypedText A} (50) (parent: TranslationUnit '(null)') +// CHECK-CC3: ParmDecl:{ResultType A *}{TypedText a} (34) +// CHECK-CC3: ObjCInterfaceDecl:{TypedText B} (50) (parent: TranslationUnit '(null)') +// CHECK-CC3: TypedefDecl:{TypedText Class} (50) (parent: TranslationUnit '(null)') + + +// RUN: c-index-test -code-completion-at=%s:16:21 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: NotImplemented:{ResultType B *}{TypedText self} (34) +// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText super} (40) + +// RUN: c-index-test -code-completion-at=%s:18:10 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s + +// RUN: c-index-test -code-completion-at=%s:19:8 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC5 %s +// CHECK-CC5: NotImplemented:{ResultType SEL}{TypedText _cmd} (80) +// CHECK-CC5-NEXT: NotImplemented:{ResultType B *}{TypedText self} (34) + +// RUN: c-index-test -code-completion-at=%s:20:11 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC6 %s +// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod:}{Placeholder (int)}{HorizontalSpace }{TypedText withOther:}{Placeholder (int)} (37) (parent: ObjCInterfaceDecl 'A') +// CHECK-CC6-NEXT: ObjCInstanceMethodDecl:{ResultType id}{TypedText someMethod:}{Placeholder (A *)} (32) (parent: ObjCImplementationDecl 'B') + diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m index becb7de6eb8b..ce4824637092 100644 --- a/test/Index/complete-method-decls.m +++ b/test/Index/complete-method-decls.m @@ -8,7 +8,7 @@ - (int)getInt; - (id)getSelf; @end - +@protocol P1; @protocol P2 + (id)alloc; @end diff --git a/test/Index/complete-properties.m b/test/Index/complete-properties.m index ce1870e6511b..a4450563698e 100644 --- a/test/Index/complete-properties.m +++ b/test/Index/complete-properties.m @@ -45,6 +45,17 @@ id test(I3 *i3) { @synthesize Prop2 = Prop2_; @end +@protocol P1 +@property int Prop5; +@end + +@class P1; + +@interface I5 +@end +@implementation I5 +@synthesize Prop5; +@end // RUN: c-index-test -code-completion-at=%s:20:13 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText Prop0} // CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText Prop1} @@ -80,3 +91,6 @@ id test(I3 *i3) { // CHECK-CC7-NOT: ObjCIvarDecl:{ResultType id}{TypedText _Prop2} // CHECK-CC7: ObjCIvarDecl:{ResultType I4 *}{TypedText Prop1} (17) // CHECK-CC7: ObjCIvarDecl:{ResultType id}{TypedText Prop2_} (7) + +// RUN: c-index-test -code-completion-at=%s:57:13 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC8 %s +// CHECK-CC8: ObjCPropertyDecl:{ResultType int}{TypedText Prop5} (35) diff --git a/test/Index/create-tu-fail.c b/test/Index/create-tu-fail.c new file mode 100644 index 000000000000..f259cca50ff4 --- /dev/null +++ b/test/Index/create-tu-fail.c @@ -0,0 +1,10 @@ +// RUN: rm -f %t.c +// RUN: touch %t.c +// RUN: c-index-test -write-pch %t.pch %t.c +// RUN: cp %s %t.c +// RUN: c-index-test -test-load-tu %t.pch local 2>&1 | FileCheck %s + +// rdar://11558355 +// Unfortunately this would crash reliably only via valgrind. + +// CHECK: Unable to load translation unit diff --git a/test/Index/cursor-dynamic-call.mm b/test/Index/cursor-dynamic-call.mm new file mode 100644 index 000000000000..f9d6a8716d16 --- /dev/null +++ b/test/Index/cursor-dynamic-call.mm @@ -0,0 +1,59 @@ + +struct SB { + virtual void meth(); +}; + +struct SS : public SB { + void submeth() { + this->meth(); + SB::meth(); + } +}; + +@interface IB +-(void)meth; ++(void)ClsMeth; +@end + +@interface IS : IB +-(void)submeth; ++(void)ClsMeth; +@end + +@implementation IS +-(void)submeth { + [self meth]; + [super meth]; +} ++(void)ClsMeth { + [super ClsMeth]; +} +@end + +void foo(SS *ss, IS* is, Class cls) { + ss->meth(); + [is meth]; + [IB ClsMeth]; + [cls ClsMeth]; +} + +// RUN: c-index-test -cursor-at=%s:8:11 \ +// RUN: -cursor-at=%s:9:11 \ +// RUN: -cursor-at=%s:25:11 \ +// RUN: -cursor-at=%s:26:11 \ +// RUN: -cursor-at=%s:29:11 \ +// RUN: -cursor-at=%s:34:9 \ +// RUN: -cursor-at=%s:35:9 \ +// RUN: -cursor-at=%s:36:9 \ +// RUN: -cursor-at=%s:37:9 \ +// RUN: %s | FileCheck %s + +// CHECK: 8:11 MemberRefExpr=meth:3:16 {{.*}} Dynamic-call +// CHECK-NOT: 9:9 {{.*}} Dynamic-call +// CHECK: 25:3 ObjCMessageExpr=meth:14:8 {{.*}} Dynamic-call +// CHECK-NOT: 26:3 {{.*}} Dynamic-call +// CHECK-NOT: 29:3 {{.*}} Dynamic-call +// CHECK: 34:7 MemberRefExpr=meth:3:16 {{.*}} Dynamic-call +// CHECK: 35:3 ObjCMessageExpr=meth:14:8 {{.*}} Dynamic-call +// CHECK-NOT: 36:3 {{.*}} Dynamic-call +// CHECK: 37:3 ObjCMessageExpr=ClsMeth:15:8 {{.*}} Dynamic-call diff --git a/test/Index/get-cursor.c b/test/Index/get-cursor.c index 23a4b5cb5370..c0614af5dd34 100644 --- a/test/Index/get-cursor.c +++ b/test/Index/get-cursor.c @@ -4,11 +4,17 @@ struct _MyS { struct _MyS ww; +int x, y; + // RUN: c-index-test -cursor-at=%s:1:9 \ // RUN: -cursor-at=%s:2:9 \ // RUN: -cursor-at=%s:5:9 \ +// RUN: -cursor-at=%s:7:5 \ +// RUN: -cursor-at=%s:7:8 \ // RUN: %s | FileCheck %s // CHECK: StructDecl=_MyS:1:8 (Definition) // CHECK: FieldDecl=foo:2:7 (Definition) // CHECK: TypeRef=struct _MyS:1:8 +// CHECK: VarDecl=x:7:5 +// CHECK: VarDecl=y:7:8 diff --git a/test/Index/get-cursor.cpp b/test/Index/get-cursor.cpp index e1e6835becad..8b70216dd165 100644 --- a/test/Index/get-cursor.cpp +++ b/test/Index/get-cursor.cpp @@ -38,6 +38,13 @@ void test() { } catch (X e) { X x; } + + struct LocalS { + void meth() { + int x; + ++x; + } + }; } // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s @@ -93,3 +100,6 @@ void test() { // RUN: c-index-test -test-load-source-usrs local %s | FileCheck -check-prefix=CHECK-USR %s // CHECK-USR: get-cursor.cpp c:get-cursor.cpp@472@F@test#@e Extent=[38:12 - 38:15] // CHECK-USR: get-cursor.cpp c:get-cursor.cpp@483@F@test#@x Extent=[39:5 - 39:8] + +// RUN: c-index-test -cursor-at=%s:45:9 %s | FileCheck -check-prefix=CHECK-LOCALCLASS %s +// CHECK-LOCALCLASS: 45:9 DeclRefExpr=x:44:11 Extent=[45:9 - 45:10] Spelling=x ([45:9 - 45:10]) diff --git a/test/Index/get-cursor.m b/test/Index/get-cursor.m index 5ac337598816..d3da9ec19726 100644 --- a/test/Index/get-cursor.m +++ b/test/Index/get-cursor.m @@ -69,6 +69,28 @@ void foo3(Test3 *test3) { @class Forw1, Forw2, Forw3; +@interface Test5 { + id prop1; + id prop2; +} +@property (assign) id prop1; +@property (assign) id prop2; +@property (assign) id prop3; +@property (assign) id prop4; +@end + +@implementation Test5 +@synthesize prop1, prop2; +@dynamic prop3, prop4; + +-(id)meth1 { + return 0; +} +-(id)meth2{ + return 0; +} +@end + // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s // CHECK-PROP: ObjCPropertyDecl=foo1:4:26 // CHECK-PROP: ObjCPropertyDecl=foo2:5:27 @@ -102,3 +124,14 @@ void foo3(Test3 *test3) { // CHECK-SPELLRANGE: 70:8 ObjCClassRef=Forw1:70:8 Extent=[70:8 - 70:13] Spelling=Forw1 ([70:8 - 70:13]) // CHECK-SPELLRANGE: 70:15 ObjCClassRef=Forw2:70:15 Extent=[70:15 - 70:20] Spelling=Forw2 ([70:15 - 70:20]) // CHECK-SPELLRANGE: 70:22 ObjCClassRef=Forw3:70:22 Extent=[70:22 - 70:27] Spelling=Forw3 ([70:22 - 70:27]) + +// RUN: c-index-test -cursor-at=%s:83:15 -cursor-at=%s:83:21 \ +// RUN: -cursor-at=%s:84:12 -cursor-at=%s:84:20 %s | FileCheck -check-prefix=CHECK-MULTISYNTH %s +// CHECK-MULTISYNTH: 83:13 ObjCSynthesizeDecl=prop1:76:23 (Definition) Extent=[83:1 - 83:18] Spelling=prop1 ([83:13 - 83:18]) +// CHECK-MULTISYNTH: 83:20 ObjCSynthesizeDecl=prop2:77:23 (Definition) Extent=[83:1 - 83:25] Spelling=prop2 ([83:20 - 83:25]) +// CHECK-MULTISYNTH: 84:10 ObjCDynamicDecl=prop3:78:23 (Definition) Extent=[84:1 - 84:15] Spelling=prop3 ([84:10 - 84:15]) +// CHECK-MULTISYNTH: 84:17 ObjCDynamicDecl=prop4:79:23 (Definition) Extent=[84:1 - 84:22] Spelling=prop4 ([84:17 - 84:22]) + +// RUN: c-index-test -cursor-at=%s:86:7 -cursor-at=%s:89:7 %s | FileCheck -check-prefix=CHECK-SELECTORLOC %s +// CHECK-SELECTORLOC: 86:6 ObjCInstanceMethodDecl=meth1:86:6 (Definition) Extent=[86:1 - 88:2] Spelling=meth1 ([86:6 - 86:11]) Selector index=0 +// CHECK-SELECTORLOC: 89:6 ObjCInstanceMethodDecl=meth2:89:6 (Definition) Extent=[89:1 - 91:2] Spelling=meth2 ([89:6 - 89:11]) Selector index=0 diff --git a/test/Index/index-decls.m b/test/Index/index-decls.m index 9e4e620497fe..46d37c4345a4 100644 --- a/test/Index/index-decls.m +++ b/test/Index/index-decls.m @@ -11,12 +11,22 @@ @synthesize prop = _prop; @end -rdar://11015325 +// rdar://11015325 @interface I1 __attribute__((something)) @interface I2 @end @end -// RUN: c-index-test -index-file %s > %t +@interface I3 +@property (assign,readwrite) id auto_prop; +@end + +@implementation I3 +-(void)meth { + _auto_prop = 0; +} +@end + +// RUN: c-index-test -index-file %s -target x86_64-apple-macosx10.7 > %t // RUN: FileCheck %s -input-file=%t // CHECK: [indexDeclaration]: kind: objc-class | name: I | {{.*}} | loc: 1:12 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2 @@ -28,3 +38,6 @@ __attribute__((something)) @interface I2 @end // CHECK: [indexDeclaration]: kind: objc-ivar | name: _prop | {{.*}} | loc: 11:20 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17] // CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17] + +// CHECK: [indexDeclaration]: kind: objc-ivar | name: _auto_prop | {{.*}} | loc: 20:33 +// CHECK: [indexEntityReference]: kind: objc-ivar | name: _auto_prop | {{.*}} | loc: 25:3 diff --git a/test/Index/index-kernel-invocation.cpp b/test/Index/index-kernel-invocation.cpp new file mode 100644 index 000000000000..dba8e6b91a08 --- /dev/null +++ b/test/Index/index-kernel-invocation.cpp @@ -0,0 +1,4 @@ +// RUN: c-index-test -index-file -arch i386 -mkernel %s | FileCheck %s + +// CHECK: [indexDeclaration]: kind: function | name: foobar +void foobar(void); diff --git a/test/Index/index-many-call-ops.cpp b/test/Index/index-many-call-ops.cpp new file mode 100644 index 000000000000..e732b5f188ae --- /dev/null +++ b/test/Index/index-many-call-ops.cpp @@ -0,0 +1,47 @@ +// RUN: c-index-test -index-file %s | FileCheck %s + +// rdar://11289247 +// Check that we don't get stack overflow trying to index a huge number of +// call operators. + +struct S { + S &operator()(); +}; + +// CHECK: [indexDeclaration]: kind: function | name: foo +void foo() { + S s; + s()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ; +} + +// CHECK: [indexDeclaration]: kind: function | name: bar +void bar(); diff --git a/test/Index/index-refs.m b/test/Index/index-refs.m new file mode 100644 index 000000000000..b82345f9c685 --- /dev/null +++ b/test/Index/index-refs.m @@ -0,0 +1,18 @@ + +@class Protocol; + +@protocol Prot +@end + +struct FooS { + int x; +}; + +void foo() { + Protocol *p = @protocol(Prot); + @encode(struct FooS); +} + +// RUN: c-index-test -index-file %s | FileCheck %s +// CHECK: [indexEntityReference]: kind: objc-protocol | name: Prot | {{.*}} | loc: 12:27 +// CHECK: [indexEntityReference]: kind: struct | name: FooS | {{.*}} | loc: 13:18 diff --git a/test/Index/overrides.m b/test/Index/overrides.m index 690875456371..d0447b74739d 100644 --- a/test/Index/overrides.m +++ b/test/Index/overrides.m @@ -50,6 +50,52 @@ -(void)meth { } @end +@protocol P5 +-(void)kol; +-(void)kol; +@end + +@protocol P6 +@property (readonly) id prop1; +@property (readonly) id prop2; +-(void)meth; +@end + +@interface I3 +@property (readwrite) id prop1; +@property (readonly) id bar; +@end + +@interface I3() +@property (readwrite) id prop2; +@property (readwrite) id bar; +-(void)meth; +@end + +@interface B4 +-(id)prop; +-(void)setProp:(id)prop; +@end + +@interface I4 : B4 +@property (assign) id prop; +@end + +@interface B5 +@end + +@interface I5 : B5 +-(void)meth; +@end + +@interface B5(cat) +-(void)meth; +@end + +@implementation I5 +-(void)meth{} +@end + // RUN: c-index-test -test-load-source local %s | FileCheck %s // CHECK: overrides.m:12:9: ObjCInstanceMethodDecl=protoMethod:12:9 [Overrides @3:9] // CHECK: overrides.m:22:9: ObjCInstanceMethodDecl=method:22:9 [Overrides @16:9] @@ -59,3 +105,15 @@ // CHECK: overrides.m:32:9: ObjCInstanceMethodDecl=protoMethod:32:9 [Overrides @8:9] // CHECK: overrides.m:36:9: ObjCInstanceMethodDecl=protoMethod:36:9 [Overrides @12:9, @8:9, @32:9, @17:9] // CHECK: overrides.m:50:8: ObjCInstanceMethodDecl=meth:50:8 (Definition) [Overrides @43:8] +// CHECK: overrides.m:55:8: ObjCInstanceMethodDecl=kol:55:8 Extent=[55:1 - 55:12] +// CHECK: overrides.m:65:26: ObjCInstanceMethodDecl=prop1:65:26 [Overrides @59:25] Extent=[65:26 - 65:31] +// CHECK: overrides.m:65:26: ObjCInstanceMethodDecl=setProp1::65:26 Extent=[65:26 - 65:31] +// CHECK: overrides.m:70:26: ObjCInstanceMethodDecl=prop2:70:26 [Overrides @60:25] Extent=[70:26 - 70:31] +// CHECK: overrides.m:70:26: ObjCInstanceMethodDecl=setProp2::70:26 Extent=[70:26 - 70:31] +// CHECK: overrides.m:71:26: ObjCInstanceMethodDecl=setBar::71:26 Extent=[71:26 - 71:29] +// CHECK: overrides.m:72:8: ObjCInstanceMethodDecl=meth:72:8 [Overrides @61:8] Extent=[72:1 - 72:13] +// CHECK: overrides.m:81:23: ObjCInstanceMethodDecl=prop:81:23 [Overrides @76:6] Extent=[81:23 - 81:27] +// CHECK: overrides.m:81:23: ObjCInstanceMethodDecl=setProp::81:23 [Overrides @77:8] Extent=[81:23 - 81:27] +// CHECK: overrides.m:92:8: ObjCInstanceMethodDecl=meth:92:8 Extent=[92:1 - 92:13] +// CHECK: overrides.m:95:17: ObjCImplementationDecl=I5:95:17 (Definition) Extent=[95:1 - 97:2] +// CHECK: overrides.m:96:8: ObjCInstanceMethodDecl=meth:96:8 (Definition) [Overrides @92:8] Extent=[96:1 - 96:14] diff --git a/test/Index/pch-with-errors.c b/test/Index/pch-with-errors.c index be8728eb723b..2d396134e5f2 100644 --- a/test/Index/pch-with-errors.c +++ b/test/Index/pch-with-errors.c @@ -38,5 +38,7 @@ void foo(void) { // CHECK-INDEX: [indexEntityReference]: kind: function | name: erroneous // RUN: %clang -fsyntax-only %s -include %t.h 2>&1 | FileCheck -check-prefix=PCH-ERR %s - // PCH-ERR: error: PCH file contains compiler errors + +// RUN: c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck -check-prefix=NONEXISTENT %s +// NONEXISTENT: Unable to load translation unit diff --git a/test/Index/print-typekind.m b/test/Index/print-typekind.m index 9db192938f44..565c5e38c4ce 100644 --- a/test/Index/print-typekind.m +++ b/test/Index/print-typekind.m @@ -1,10 +1,10 @@ @interface Foo @property (readonly) id x; -(int) mymethod; --(int) mymethod2:(int)x blah:(float)y; +-(const id) mymethod2:(id)x blah:(Class)y boo:(SEL)z; @end // RUN: c-index-test -test-print-typekind %s | FileCheck %s -// CHECK: ObjCPropertyDecl=x:2:25 typekind=Typedef [canonical=ObjCObjectPointer] +// CHECK: ObjCPropertyDecl=x:2:25 typekind=ObjCId [canonical=ObjCObjectPointer] // CHECK: ObjCInstanceMethodDecl=mymethod:3:8 typekind=Invalid [result=Int] -// CHECK: ObjCInstanceMethodDecl=mymethod2:blah::4:8 typekind=Invalid [result=Int] [args= Int Float] +// CHECK: ObjCInstanceMethodDecl=mymethod2:blah:boo::4:13 typekind=Invalid [result=ObjCId] [args= ObjCId ObjCClass ObjCSel] diff --git a/test/Index/recursive-cxx-member-calls.cpp b/test/Index/recursive-cxx-member-calls.cpp index b80cbf40e87c..9b93872ee01b 100644 --- a/test/Index/recursive-cxx-member-calls.cpp +++ b/test/Index/recursive-cxx-member-calls.cpp @@ -961,7 +961,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK-tokens: Punctuation: ">" [105:51 - 105:52] CallExpr=StringSwitch:87:12 // CHECK-tokens: Punctuation: "(" [105:53 - 105:54] CallExpr=StringSwitch:87:12 // CHECK-tokens: Identifier: "AttrName" [105:54 - 105:62] DeclRefExpr=AttrName:101:19 -// CHECK-tokens: Punctuation: ")" [105:62 - 105:63] CXXFunctionalCastExpr= +// CHECK-tokens: Punctuation: ")" [105:62 - 105:63] CallExpr=StringSwitch:87:12 // CHECK-tokens: Punctuation: "." [106:5 - 106:6] MemberRefExpr=Case:88:42 // CHECK-tokens: Identifier: "Case" [106:6 - 106:10] MemberRefExpr=Case:88:42 // CHECK-tokens: Punctuation: "(" [106:10 - 106:11] CallExpr=Case:88:42 @@ -2081,7 +2081,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK: 106:6: MemberRefExpr=Case:88:42 SingleRefName=[106:6 - 106:10] RefName=[106:6 - 106:10] Extent=[105:10 - 106:10] // CHECK: 105:10: CXXFunctionalCastExpr= Extent=[105:10 - 105:63] // CHECK: 105:16: TemplateRef=StringSwitch:83:47 Extent=[105:16 - 105:28] -// CHECK: 105:10: CallExpr=StringSwitch:87:12 Extent=[105:10 - 105:62] +// CHECK: 105:10: CallExpr=StringSwitch:87:12 Extent=[105:10 - 105:63] // CHECK: 105:54: CallExpr=StringRef:38:7 Extent=[105:54 - 105:62] // CHECK: 105:54: UnexposedExpr=AttrName:101:19 Extent=[105:54 - 105:62] // CHECK: 105:54: DeclRefExpr=AttrName:101:19 Extent=[105:54 - 105:62] @@ -2240,4 +2240,3 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK: 183:25: DeclRefExpr=AT_thiscall:27:44 Extent=[183:25 - 183:36] // CHECK: 184:11: StringLiteral= Extent=[184:11 - 184:21] // CHECK: 184:23: DeclRefExpr=AT_pascal:26:38 Extent=[184:23 - 184:32] - diff --git a/test/Lexer/bcpl-escaped-newline.c b/test/Lexer/bcpl-escaped-newline.c index 4d4a7b5e89eb..d87ee9b83aed 100644 --- a/test/Lexer/bcpl-escaped-newline.c +++ b/test/Lexer/bcpl-escaped-newline.c @@ -5,7 +5,8 @@ #error bar //??/ -#error qux // expected-error {{qux}} +#error qux +// expected-error@-1 {{qux}} // Trailing whitespace! //\ diff --git a/test/Lexer/c90.c b/test/Lexer/c90.c index d91057257dfb..7142c09ac486 100644 --- a/test/Lexer/c90.c +++ b/test/Lexer/c90.c @@ -32,3 +32,10 @@ void test3() { (void)L"\u1234"; // expected-error {{unicode escape sequences are only valid in C99 or C++}} (void)L'\u1234'; // expected-error {{unicode escape sequences are only valid in C99 or C++}} } + +#define PREFIX(x) foo ## x +int test4() { + int PREFIX(0p) = 0; + int *p = &PREFIX(0p+1); + return p[-1]; +} diff --git a/test/Lexer/char-literal.cpp b/test/Lexer/char-literal.cpp index 5dc53608f8f8..8556d468cba6 100644 --- a/test/Lexer/char-literal.cpp +++ b/test/Lexer/char-literal.cpp @@ -22,3 +22,6 @@ char m = '👿'; // expected-error {{character too large for enclosing character char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}} char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}} + +char16_t p[2] = u"\U0000FFFF"; +char16_t q[2] = u"\U00010000"; // expected-error {{too long}} diff --git a/test/Lexer/hexfloat.cpp b/test/Lexer/hexfloat.cpp index 656693399fa1..9bd8f830f030 100644 --- a/test/Lexer/hexfloat.cpp +++ b/test/Lexer/hexfloat.cpp @@ -5,3 +5,11 @@ double e = 0x.p0; //expected-error{{hexadecimal floating constants require a sig double d = 0x.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} float g = 0x1.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} double h = 0x1.p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} + +// PR12717: In order to minimally diverge from the C++ standard, we do not lex +// 'p[+-]' as part of a pp-number unless the token starts 0x and doesn't contain +// an underscore. +double i = 0p+3; // expected-error{{invalid suffix 'p' on integer constant}} +#define PREFIX(x) foo ## x +double foo0p = 1, j = PREFIX(0p+3); // ok +double k = 0x42_amp+3; // expected-error-re{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator "" _amp'}} diff --git a/test/Lexer/newline-eof.c b/test/Lexer/newline-eof.c index 825a266a0a36..a4a18835cf5f 100644 --- a/test/Lexer/newline-eof.c +++ b/test/Lexer/newline-eof.c @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -Wnewline-eof -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wnewline-eof %s 2>&1 | FileCheck %s // rdar://9133072 +// Make sure the diagnostic shows up properly at the end of the last line. +// CHECK: newline-eof.c:9:63 + // The following line isn't terminated, don't fix it. void foo() {} // expected-warning{{no newline at end of file}} \ No newline at end of file diff --git a/test/Lexer/pragma-operators.cpp b/test/Lexer/pragma-operators.cpp index d1645adbc252..a76e0b2f97e2 100644 --- a/test/Lexer/pragma-operators.cpp +++ b/test/Lexer/pragma-operators.cpp @@ -9,7 +9,6 @@ // CHECK: #line // CHECK: #pragma warning(push) // CHECK: int foo() { return 0; } } -// CHECK: #line // CHECK: #pragma warning(pop) #define A(X) extern "C" { __pragma(warning(push)) \ int X() { return 0; } \ diff --git a/test/Lexer/wchar-signedness.c b/test/Lexer/wchar-signedness.c new file mode 100644 index 000000000000..fea0ecac64f5 --- /dev/null +++ b/test/Lexer/wchar-signedness.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | FileCheck %s --check-prefix=X86 +// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck %s --check-prefix=ARM + +// CHECK-X86-NOT: #define __WCHAR_UNSIGNED__ +// CHECK-X86: #define __WINT_UNSIGNED__ 1 + +// CHECK-ARM: #define __WCHAR_UNSIGNED__ 1 +// CHECK-ARM-NOT: #define __WINT_UNSIGNED__ 1 diff --git a/test/Misc/ast-dump-wchar.cpp b/test/Misc/ast-dump-wchar.cpp new file mode 100644 index 000000000000..87d962fec870 --- /dev/null +++ b/test/Misc/ast-dump-wchar.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++11 -ast-dump %s -triple x86_64-linux-gnu | FileCheck %s + +char c8[] = u8"test\0\\\"\t\a\b\234"; +// CHECK: char c8[12] = (StringLiteral {{.*}} lvalue u8"test\000\\\"\t\a\b\234") + +char16_t c16[] = u"test\0\\\"\t\a\b\234\u1234"; +// CHECK: char16_t c16[13] = (StringLiteral {{.*}} lvalue u"test\000\\\"\t\a\b\234\u1234") + +char32_t c32[] = U"test\0\\\"\t\a\b\234\u1234\U0010ffff"; // \ +// CHECK: char32_t c32[14] = (StringLiteral {{.*}} lvalue U"test\000\\\"\t\a\b\234\u1234\U0010FFFF") + +wchar_t wc[] = L"test\0\\\"\t\a\b\234\u1234\xffffffff"; // \ +// CHECK: wchar_t wc[14] = (StringLiteral {{.*}} lvalue L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF") diff --git a/test/Misc/diag-aka-types.cpp b/test/Misc/diag-aka-types.cpp index 4c9a7312cdaf..3a00b7122e83 100644 --- a/test/Misc/diag-aka-types.cpp +++ b/test/Misc/diag-aka-types.cpp @@ -30,27 +30,6 @@ void test(Foo::foo* x) { bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *'}} } -// PR9548 - "no known conversion from 'vector' to 'vector'" -// vector refers to two different types here. Make sure the message -// gives a way to tell them apart. -class versa_string; -typedef versa_string string; - -namespace std {template class vector;} -using std::vector; - -void f(vector v); // expected-note {{candidate function not viable: no known conversion from 'vector' (aka 'std::vector') to 'vector' (aka 'std::vector') for 1st argument}} - -namespace std { - class basic_string; - typedef basic_string string; - template class vector {}; - void g() { - vector v; - f(v); // expected-error{{no matching function for call to 'f'}} - } -} - namespace ns { struct str { static void method(struct data *) {} @@ -61,7 +40,7 @@ struct data { int i; }; typedef void (*callback)(struct data *); -void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument;}} +void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument}} void test() { helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}} diff --git a/test/Misc/diag-template-diffing-color.cpp b/test/Misc/diag-template-diffing-color.cpp new file mode 100644 index 000000000000..6903e848d3df --- /dev/null +++ b/test/Misc/diag-template-diffing-color.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -fcolor-diagnostics %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fcolor-diagnostics -fdiagnostics-show-template-tree %s 2>&1 | FileCheck %s -check-prefix=TREE +// REQUIRES: ansi-escape-sequences +template struct foo {}; +void func(foo); +int main() { + func(foo()); +} +// CHECK: {{.*}}candidate function not viable: no known conversion from 'foo<{{.}}[0;1;36mdouble{{.}}[0m>' to 'foo<{{.}}[0;1;36mint{{.}}[0m>' for 1st argument{{.}}[0m +// TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// TREE: foo< +// TREE: [{{.}}[0;1;36mdouble{{.}}[0m != {{.}}[0;1;36mint{{.}}[0m]>{{.}}[0m + +foo A; +foo &B = A; +// CHECK: {{.*}}non-const lvalue reference to type 'foo<{{.}}[0;1;36mdouble{{.}}[0m{{.}}[1m>' cannot bind to a value of unrelated type 'foo<{{.}}[0;1;36mint{{.}}[0m{{.}}[1m>'{{.}}[0m +// TREE: non-const lvalue reference cannot bind to a value of unrelated type +// TREE: foo< +// TREE: [{{.}}[0;1;36mdouble{{.}}[0m{{.}}[1m != {{.}}[0;1;36mint{{.}}[0m{{.}}[1m]>{{.}}[0m diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp new file mode 100644 index 000000000000..9addcc50aec6 --- /dev/null +++ b/test/Misc/diag-template-diffing.cpp @@ -0,0 +1,433 @@ +// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-ELIDE-NOTREE +// RUN: %clang_cc1 -fsyntax-only %s -fno-elide-type -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-NOELIDE-NOTREE +// RUN: %clang_cc1 -fsyntax-only %s -fdiagnostics-show-template-tree -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-ELIDE-TREE +// RUN: %clang_cc1 -fsyntax-only %s -fno-elide-type -fdiagnostics-show-template-tree -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-NOELIDE-TREE + +// PR9548 - "no known conversion from 'vector' to 'vector'" +// vector refers to two different types here. Make sure the message +// gives a way to tell them apart. +class versa_string; +typedef versa_string string; + +namespace std {template class vector;} +using std::vector; + +void f(vector v); + +namespace std { + class basic_string; + typedef basic_string string; + template class vector {}; + void g() { + vector v; + f(v); + } +} // end namespace std +// CHECK-ELIDE-NOTREE: no matching function for call to 'f' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector' to 'vector' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'f' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector' to 'vector' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'f' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: vector< +// CHECK-ELIDE-TREE: [class std::basic_string != class versa_string]> +// CHECK-NOELIDE-TREE: no matching function for call to 'f' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: vector< +// CHECK-NOELIDE-TREE: [class std::basic_string != class versa_string]> + +template +class I1{}; +void set1(I1<1,2,3,4,2,3,4,3>) {}; +void test1() { + set1(I1<1,2,3,4,2,2,4,3,7>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set1' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I1<[5 * ...], 2, [2 * ...], 7>' to 'I1<[5 * ...], 3, [2 * ...], (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set1' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I1<1, 2, 3, 4, 2, 2, 4, 3, 7>' to 'I1<1, 2, 3, 4, 2, 3, 4, 3, (no argument)>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set1' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: I1< +// CHECK-ELIDE-TREE: [5 * ...], +// CHECK-ELIDE-TREE: [2 != 3], +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [7 != (no argument)]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set1' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: I1< +// CHECK-NOELIDE-TREE: 1, +// CHECK-NOELIDE-TREE: 2, +// CHECK-NOELIDE-TREE: 3, +// CHECK-NOELIDE-TREE: 4, +// CHECK-NOELIDE-TREE: 2, +// CHECK-NOELIDE-TREE: [2 != 3], +// CHECK-NOELIDE-TREE: 4, +// CHECK-NOELIDE-TREE: 3, +// CHECK-NOELIDE-TREE: [7 != (no argument)]> + +template +class I2{}; +void set2(I2) {}; +void test2() { + set2(I2()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set2' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I2' to 'I2' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set2' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I2' to 'I2' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set2' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: I2< +// CHECK-ELIDE-TREE: [double != int], +// CHECK-ELIDE-TREE: [...], +// CHECK-ELIDE-TREE: [int != (default) void]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set2' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: I2< +// CHECK-NOELIDE-TREE: [double != int], +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: [int != (default) void]> + +int V1, V2, V3; +template +class I3{}; +void set3(I3<&V1, &V2>) {}; +void test3() { + set3(I3<&V3, &V2>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set3' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I3<&V3, [...]>' to 'I3<&V1, [...]>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set3' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I3<&V3, &V2>' to 'I3<&V1, &V2>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set3' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: I3< +// CHECK-ELIDE-TREE: [&V3 != &V1] +// CHECK-ELIDE-TREE: [...]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set3' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: I3< +// CHECK-NOELIDE-TREE: [&V3 != &V1] +// CHECK-NOELIDE-TREE: &V2> + +template +class Alpha{}; +template +class Beta{}; +template +class Gamma{}; +template +class Delta{}; + +void set4(Alpha); +void test4() { + set4(Beta()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set4' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Beta' to 'Alpha' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set4' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Beta' to 'Alpha' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set4' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from 'Beta' to 'Alpha' for 1st argument +// CHECK-NOELIDE-TREE: no matching function for call to 'set4' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from 'Beta' to 'Alpha' for 1st argument + +void set5(Alpha, int>, int>, int>); +void test5() { + set5(Alpha, double>, double>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set5' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha, double>, double>' to 'Alpha, int>, int>, int>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set5' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha, double>, double>' to 'Alpha, int>, int>, int>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set5' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: Alpha< +// CHECK-ELIDE-TREE: Beta< +// CHECK-ELIDE-TREE: Gamma< +// CHECK-ELIDE-TREE: [void != Delta], +// CHECK-ELIDE-TREE: [void != int]> +// CHECK-ELIDE-TREE: [double != int]> +// CHECK-ELIDE-TREE: [double != int]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set5' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: Alpha< +// CHECK-NOELIDE-TREE: Beta< +// CHECK-NOELIDE-TREE: Gamma< +// CHECK-NOELIDE-TREE: [void != Delta], +// CHECK-NOELIDE-TREE: [void != int]> +// CHECK-NOELIDE-TREE: [double != int]> +// CHECK-NOELIDE-TREE: [double != int]> + +void test6() { + set5(Alpha, int>, int>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set5' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha, [...]>, [...]>' to 'Alpha, int>, [...]>, [...]>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set5' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha, int>, int>' to 'Alpha, int>, int>, int>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set5' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: Alpha< +// CHECK-ELIDE-TREE: Beta< +// CHECK-ELIDE-TREE: [Delta != Gamma, int>], +// CHECK-ELIDE-TREE: [...]> +// CHECK-ELIDE-TREE: [...]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set5' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: Alpha< +// CHECK-NOELIDE-TREE: Beta< +// CHECK-NOELIDE-TREE: [Delta != Gamma, int>], +// CHECK-NOELIDE-TREE: int> +// CHECK-NOELIDE-TREE: int> + +int a7, b7; +int c7[] = {1,2,3}; +template +class class7 {}; +void set7(class7<&a7> A) {} +void test7() { + set7(class7<&a7>()); + set7(class7<&b7>()); + set7(class7()); + set7(class7()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<&b7>' to 'class7<&a7>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7' to 'class7<&a7>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7' to 'class7<&a7>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<&b7>' to 'class7<&a7>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7' to 'class7<&a7>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7' to 'class7<&a7>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set7' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class7< +// CHECK-ELIDE-TREE: [&b7 != &a7]> +// CHECK-ELIDE-TREE: no matching function for call to 'set7' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class7< +// CHECK-ELIDE-TREE: [c7 != &a7]> +// CHECK-ELIDE-TREE: no matching function for call to 'set7' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class7< +// CHECK-ELIDE-TREE: [nullptr != &a7]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set7' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class7< +// CHECK-NOELIDE-TREE: [&b7 != &a7]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set7' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class7< +// CHECK-NOELIDE-TREE: [c7 != &a7]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set7' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class7< +// CHECK-NOELIDE-TREE: [nullptr != &a7]> + +template struct S8 {}; +template using U8 = S8; +int f8(S8); +int k8 = f8(U8()); +// CHECK-ELIDE-NOTREE: no matching function for call to 'f8' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S8<[2 * ...], char>' to 'S8<[2 * ...], double>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'f8' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S8' to 'S8' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'f8' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: S8< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [char != double]> +// CHECK-NOELIDE-TREE: no matching function for call to 'f8' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: S8< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: [char != double]> + +template struct S9 {}; +template using U9 = S9; +template using V9 = U9>; +int f9(S9>); +int k9 = f9(V9()); + +// CHECK-ELIDE-NOTREE: no matching function for call to 'f9' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<[2 * ...], S9<[2 * ...], double>>' to 'S9<[2 * ...], S9<[2 * ...], const double>>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'f9' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S9>' to 'S9>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'f9' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: S9< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: S9< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [double != const double]>> +// CHECK-NOELIDE-TREE: no matching function for call to 'f9' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: S9< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: S9< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: [double != const double]>> + +template class class_types {}; +void set10(class_types) {} +void test10() { + set10(class_types()); + set10(class_types()); +} + +// CHECK-ELIDE-NOTREE: no matching function for call to 'set10' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<[...], (no argument)>' to 'class_types<[...], int>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set10' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<[2 * ...], int>' to 'class_types<[2 * ...], (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set10' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types' to 'class_types' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set10' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types' to 'class_types' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set10' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_types< +// CHECK-ELIDE-TREE: [...], +// CHECK-ELIDE-TREE: [(no argument) != int]> +// CHECK-ELIDE-TREE: no matching function for call to 'set10' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_types< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [int != (no argument)]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set10' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_types< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: [(no argument) != int]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set10' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_types< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: [int != (no argument)]> + +template class class_ints {}; +void set11(class_ints<2, 3>) {} +void test11() { + set11(class_ints<1>()); + set11(class_ints<0, 3, 6>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set11' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<1, (no argument)>' to 'class_ints<2, 3>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set11' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<0, [...], 6>' to 'class_ints<2, [...], (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set11' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<1, (no argument)>' to 'class_ints<2, 3>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set11' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<0, 3, 6>' to 'class_ints<2, 3, (no argument)>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set11' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_ints< +// CHECK-ELIDE-TREE: [1 != 2], +// CHECK-ELIDE-TREE: [(no argument) != 3]> +// CHECK-ELIDE-TREE: no matching function for call to 'set11' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_ints< +// CHECK-ELIDE-TREE: [0 != 2], +// CHECK-ELIDE-TREE: [...], +// CHECK-ELIDE-TREE: [6 != (no argument)]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set11' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_ints< +// CHECK-NOELIDE-TREE: [1 != 2], +// CHECK-NOELIDE-TREE: [(no argument) != 3]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set11' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_ints< +// CHECK-NOELIDE-TREE: [0 != 2], +// CHECK-NOELIDE-TREE: 3, +// CHECK-NOELIDE-TREE: [6 != (no argument)]> + +template class ...A> class class_template_templates {}; +template class tt1 {}; +template class tt2 {}; +void set12(class_template_templates) {} +void test12() { + set12(class_template_templates()); + set12(class_template_templates()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set12' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates