From 952eddef9aff85b1e92626e89baaf7a360e2ac85 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 22 Dec 2013 00:07:40 +0000 Subject: Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3): https://llvm.org/svn/llvm-project/cfe/branches/release_34@197841 --- .../2004-11-27-FriendDefaultArgCrash.cpp | 2 +- test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp | 12 - test/CodeGenCXX/2007-05-03-VectorInit.cpp | 2 +- test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp | 2 +- test/CodeGenCXX/DynArrayInit.cpp | 2 +- test/CodeGenCXX/PR5050-constructor-conversion.cpp | 4 +- test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp | 85 +++ test/CodeGenCXX/aarch64-neon.cpp | 13 + test/CodeGenCXX/abstract-class-ctors-dtors.cpp | 8 +- test/CodeGenCXX/address-of-fntemplate.cpp | 4 +- test/CodeGenCXX/alloca-align.cpp | 6 +- test/CodeGenCXX/anonymous-namespaces.cpp | 21 +- .../anonymous-union-member-initializer.cpp | 12 +- .../apple-kext-indirect-virtual-dtor-call.cpp | 4 +- test/CodeGenCXX/apple-kext-linkage.C | 12 +- test/CodeGenCXX/arm-vaarg.cpp | 27 + test/CodeGenCXX/arm.cpp | 52 +- test/CodeGenCXX/array-construction.cpp | 4 +- test/CodeGenCXX/array-operator-delete-call.cpp | 4 +- test/CodeGenCXX/atomic.cpp | 2 +- test/CodeGenCXX/atomicinit.cpp | 6 +- test/CodeGenCXX/attr-cleanup.cpp | 11 + test/CodeGenCXX/attr.cpp | 2 +- test/CodeGenCXX/bitfield-layout.cpp | 4 +- test/CodeGenCXX/bitfield.cpp | 84 +-- test/CodeGenCXX/block-byref-cxx-objc.cpp | 8 +- test/CodeGenCXX/block-in-ctor-dtor.cpp | 20 +- test/CodeGenCXX/blocks-cxx11.cpp | 4 +- test/CodeGenCXX/blocks.cpp | 28 +- test/CodeGenCXX/bool-bitfield.cpp | 4 +- test/CodeGenCXX/builtins.cpp | 21 +- test/CodeGenCXX/c-linkage.cpp | 6 +- test/CodeGenCXX/c99-variable-length-array.cpp | 2 +- test/CodeGenCXX/call-arg-zero-temp.cpp | 4 +- test/CodeGenCXX/captured-statements.cpp | 189 +++++++ test/CodeGenCXX/cast-conversion.cpp | 4 +- test/CodeGenCXX/catch-undef-behavior.cpp | 158 +++++- test/CodeGenCXX/catch-undef-behavior2.cpp | 9 + test/CodeGenCXX/compound-literals.cpp | 4 +- test/CodeGenCXX/condition.cpp | 8 +- test/CodeGenCXX/conditional-gnu-ext.cpp | 8 +- test/CodeGenCXX/conditional-temporaries.cpp | 6 +- test/CodeGenCXX/const-init-cxx11.cpp | 110 +++- test/CodeGenCXX/const-init-cxx1y.cpp | 48 ++ test/CodeGenCXX/const-init.cpp | 2 +- test/CodeGenCXX/constructor-attr.cpp | 2 +- test/CodeGenCXX/constructor-conversion.cpp | 4 +- test/CodeGenCXX/constructor-default-arg.cpp | 4 +- .../constructor-destructor-return-this.cpp | 138 +++-- test/CodeGenCXX/constructor-for-array-members.cpp | 4 +- test/CodeGenCXX/constructor-init.cpp | 16 +- test/CodeGenCXX/constructor-template.cpp | 4 +- test/CodeGenCXX/constructors.cpp | 22 +- test/CodeGenCXX/conversion-function.cpp | 4 +- test/CodeGenCXX/convert-to-fptr.cpp | 4 +- test/CodeGenCXX/copy-assign-synthesis-1.cpp | 16 +- test/CodeGenCXX/copy-assign-synthesis-2.cpp | 2 +- test/CodeGenCXX/copy-assign-synthesis.cpp | 2 +- test/CodeGenCXX/copy-constructor-elim-2.cpp | 6 +- test/CodeGenCXX/copy-constructor-elim.cpp | 4 +- test/CodeGenCXX/copy-constructor-synthesis-2.cpp | 2 +- test/CodeGenCXX/copy-constructor-synthesis.cpp | 45 +- test/CodeGenCXX/copy-initialization.cpp | 2 +- test/CodeGenCXX/crash.cpp | 35 ++ test/CodeGenCXX/ctor-dtor-alias.cpp | 163 ++++++ test/CodeGenCXX/cxx-block-objects.cpp | 4 +- test/CodeGenCXX/cxx0x-delegating-ctors.cpp | 2 +- test/CodeGenCXX/cxx0x-initializer-array.cpp | 12 +- test/CodeGenCXX/cxx0x-initializer-constructors.cpp | 24 +- ...xx0x-initializer-stdinitializerlist-pr12086.cpp | 107 +++- ...x0x-initializer-stdinitializerlist-startend.cpp | 10 +- .../cxx0x-initializer-stdinitializerlist.cpp | 202 ++++++- test/CodeGenCXX/cxx11-exception-spec.cpp | 2 +- test/CodeGenCXX/cxx11-initializer-array-new.cpp | 106 ++++ test/CodeGenCXX/cxx11-thread-local-reference.cpp | 4 +- test/CodeGenCXX/cxx11-thread-local.cpp | 21 +- test/CodeGenCXX/cxx1y-deduced-return-type.cpp | 32 ++ test/CodeGenCXX/cxx1y-init-captures.cpp | 102 ++++ test/CodeGenCXX/cxx1y-initializer-aggregate.cpp | 17 +- test/CodeGenCXX/cxx1y-sized-deallocation.cpp | 110 ++++ test/CodeGenCXX/cxx1y-variable-template.cpp | 24 + test/CodeGenCXX/debug-info-artificial-arg.cpp | 8 +- test/CodeGenCXX/debug-info-class-limited.cpp | 52 ++ test/CodeGenCXX/debug-info-class-nolimit.cpp | 30 ++ test/CodeGenCXX/debug-info-class.cpp | 87 +++- test/CodeGenCXX/debug-info-cxx1y.cpp | 7 + test/CodeGenCXX/debug-info-decl-nested.cpp | 61 +++ test/CodeGenCXX/debug-info-enum-class.cpp | 8 +- test/CodeGenCXX/debug-info-enum.cpp | 40 +- test/CodeGenCXX/debug-info-friend.cpp | 19 +- test/CodeGenCXX/debug-info-function-context.cpp | 36 ++ test/CodeGenCXX/debug-info-gline-tables-only.cpp | 10 +- test/CodeGenCXX/debug-info-global-ctor-dtor.cpp | 6 +- test/CodeGenCXX/debug-info-globalinit.cpp | 12 +- test/CodeGenCXX/debug-info-limit-type.cpp | 24 - test/CodeGenCXX/debug-info-limit.cpp | 14 - test/CodeGenCXX/debug-info-limited.cpp | 33 ++ test/CodeGenCXX/debug-info-method.cpp | 5 +- test/CodeGenCXX/debug-info-namespace.cpp | 66 ++- test/CodeGenCXX/debug-info-nullptr.cpp | 2 +- test/CodeGenCXX/debug-info-pubtypes.cpp | 5 +- test/CodeGenCXX/debug-info-same-line.cpp | 25 + test/CodeGenCXX/debug-info-scope.cpp | 32 ++ test/CodeGenCXX/debug-info-static-member.cpp | 14 +- test/CodeGenCXX/debug-info-template-limit.cpp | 4 +- test/CodeGenCXX/debug-info-template-member.cpp | 89 +++- test/CodeGenCXX/debug-info-template-quals.cpp | 12 +- test/CodeGenCXX/debug-info-template.cpp | 138 +++-- test/CodeGenCXX/debug-info-thunk.cpp | 2 +- test/CodeGenCXX/debug-info-union-template.cpp | 2 +- test/CodeGenCXX/debug-info-uuid.cpp | 19 + test/CodeGenCXX/debug-info-zero-length-arrays.cpp | 2 +- test/CodeGenCXX/debug-info.cpp | 53 +- test/CodeGenCXX/debug-lambda-expressions.cpp | 30 +- test/CodeGenCXX/decl-ref-init.cpp | 4 +- test/CodeGenCXX/default-arg-temps.cpp | 6 +- test/CodeGenCXX/default-arguments.cpp | 8 +- .../CodeGenCXX/default-constructor-for-members.cpp | 4 +- .../default-constructor-template-member.cpp | 3 +- test/CodeGenCXX/deferred-global-init.cpp | 4 +- test/CodeGenCXX/delayed-template-parsing.cpp | 18 + test/CodeGenCXX/delete-two-arg.cpp | 8 +- test/CodeGenCXX/delete.cpp | 18 +- test/CodeGenCXX/derived-to-base-conv.cpp | 6 +- .../derived-to-virtual-base-class-calls-final.cpp | 2 +- test/CodeGenCXX/destructor-exception-spec.cpp | 2 + test/CodeGenCXX/destructors.cpp | 114 ++-- .../devirtualize-virtual-function-calls-final.cpp | 20 +- .../devirtualize-virtual-function-calls.cpp | 2 +- test/CodeGenCXX/dynamic_cast-no-rtti.cpp | 26 + test/CodeGenCXX/eh.cpp | 30 +- test/CodeGenCXX/empty-classes.cpp | 2 +- test/CodeGenCXX/empty-nontrivially-copyable.cpp | 25 + test/CodeGenCXX/exceptions.cpp | 12 +- test/CodeGenCXX/explicit-instantiation.cpp | 8 +- test/CodeGenCXX/fastcall.cpp | 4 +- test/CodeGenCXX/for-range.cpp | 8 +- test/CodeGenCXX/forward-enum.cpp | 2 +- test/CodeGenCXX/fp16-mangle.cpp | 4 +- .../function-template-explicit-specialization.cpp | 4 +- test/CodeGenCXX/global-array-destruction.cpp | 2 +- test/CodeGenCXX/global-block-literal-helpers.cpp | 16 +- test/CodeGenCXX/global-dtor-no-atexit.cpp | 2 +- test/CodeGenCXX/global-init.cpp | 4 +- test/CodeGenCXX/goto.cpp | 2 +- test/CodeGenCXX/implicit-copy-assign-operator.cpp | 2 +- test/CodeGenCXX/implicit-copy-constructor.cpp | 2 +- test/CodeGenCXX/implicit-instantiation-1.cpp | 2 +- test/CodeGenCXX/inheriting-constructor.cpp | 14 +- test/CodeGenCXX/init-invariant.cpp | 4 +- test/CodeGenCXX/inline-functions.cpp | 10 +- test/CodeGenCXX/instantiate-temporaries.cpp | 4 +- test/CodeGenCXX/invalid.cpp | 11 + .../lambda-expressions-inside-auto-functions.cpp | 77 +++ .../lambda-expressions-nested-linkage.cpp | 50 ++ test/CodeGenCXX/lambda-expressions.cpp | 28 +- test/CodeGenCXX/linetable-cleanup.cpp | 36 +- test/CodeGenCXX/linkage.cpp | 222 ++++++++ test/CodeGenCXX/lpad-linetable.cpp | 69 +++ test/CodeGenCXX/lvalue-bitcasts.cpp | 6 +- test/CodeGenCXX/mangle-98.cpp | 6 +- test/CodeGenCXX/mangle-address-space.cpp | 6 +- test/CodeGenCXX/mangle-alias-template.cpp | 2 +- test/CodeGenCXX/mangle-exprs.cpp | 22 +- test/CodeGenCXX/mangle-extreme.cpp | 2 +- test/CodeGenCXX/mangle-lambdas.cpp | 83 +-- test/CodeGenCXX/mangle-local-class-names.cpp | 30 ++ test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp | 117 +++++ .../mangle-ms-back-references-pr13207.cpp | 30 +- test/CodeGenCXX/mangle-ms-back-references.cpp | 5 + test/CodeGenCXX/mangle-ms-templates.cpp | 155 +++++- test/CodeGenCXX/mangle-ms.cpp | 273 ++++++++-- test/CodeGenCXX/mangle-neon-vectors.cpp | 17 +- test/CodeGenCXX/mangle-nullptr-arg.cpp | 6 +- test/CodeGenCXX/mangle-ref-qualifiers.cpp | 10 +- test/CodeGenCXX/mangle-subst-std.cpp | 12 +- test/CodeGenCXX/mangle-subst.cpp | 12 +- test/CodeGenCXX/mangle-system-header.cpp | 4 +- test/CodeGenCXX/mangle-template.cpp | 12 +- test/CodeGenCXX/mangle-unnamed.cpp | 4 +- test/CodeGenCXX/mangle-valist.cpp | 10 +- test/CodeGenCXX/mangle-variadic-templates.cpp | 30 +- test/CodeGenCXX/mangle-windows.cpp | 42 ++ test/CodeGenCXX/mangle.cpp | 252 +++++---- test/CodeGenCXX/member-expressions.cpp | 2 +- test/CodeGenCXX/member-function-pointer-calls.cpp | 4 +- test/CodeGenCXX/member-function-pointers.cpp | 5 +- test/CodeGenCXX/member-functions.cpp | 14 +- test/CodeGenCXX/member-init-anon-union.cpp | 2 +- test/CodeGenCXX/member-initializers.cpp | 2 +- test/CodeGenCXX/member-templates.cpp | 4 +- test/CodeGenCXX/microsoft-abi-alignment-fail.cpp | 10 + .../microsoft-abi-constexpr-vs-inheritance.cpp | 23 + test/CodeGenCXX/microsoft-abi-default-cc.cpp | 12 +- test/CodeGenCXX/microsoft-abi-exceptions.cpp | 157 ++++++ test/CodeGenCXX/microsoft-abi-member-pointers.cpp | 210 +++++++- ...crosoft-abi-multiple-nonvirtual-inheritance.cpp | 201 +++++++ test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp | 90 +++- .../microsoft-abi-static-initializers.cpp | 124 ++++- test/CodeGenCXX/microsoft-abi-structors-alias.cpp | 9 + test/CodeGenCXX/microsoft-abi-structors.cpp | 168 ++++-- test/CodeGenCXX/microsoft-abi-thunks.cpp | 154 ++++++ test/CodeGenCXX/microsoft-abi-vbtables.cpp | 479 +++++++++++++++++ ...microsoft-abi-virtual-inheritance-vtordisps.cpp | 83 +++ .../microsoft-abi-virtual-inheritance.cpp | 314 +++++++++++ .../microsoft-abi-virtual-member-pointers.cpp | 108 ++++ ...abi-vtables-multiple-nonvirtual-inheritance.cpp | 579 +++++++++++++++++++++ .../microsoft-abi-vtables-single-inheritance.cpp | 191 ++++++- ...t-abi-vtables-virtual-inheritance-vtordisps.cpp | 324 ++++++++++++ .../microsoft-abi-vtables-virtual-inheritance.cpp | 575 ++++++++++++++++++++ test/CodeGenCXX/microsoft-interface.cpp | 16 +- test/CodeGenCXX/microsoft-new.cpp | 39 ++ .../microsoft-uuidof-unsupported-target.cpp | 13 - test/CodeGenCXX/microsoft-uuidof.cpp | 94 +++- test/CodeGenCXX/move-assignment.cpp | 26 + test/CodeGenCXX/ms-integer-static-data-members.cpp | 35 ++ test/CodeGenCXX/new-alias.cpp | 13 + test/CodeGenCXX/new-array-init-exceptions.cpp | 4 +- test/CodeGenCXX/new-array-init.cpp | 8 +- test/CodeGenCXX/new.cpp | 106 +++- test/CodeGenCXX/no-opt-volatile-memcpy.cpp | 8 +- test/CodeGenCXX/noexcept.cpp | 49 ++ test/CodeGenCXX/nrvo.cpp | 18 +- test/CodeGenCXX/override-layout.cpp | 6 +- test/CodeGenCXX/partial-destruction.cpp | 6 +- test/CodeGenCXX/pod-member-memcpys.cpp | 152 +++--- test/CodeGenCXX/pointers-to-data-members.cpp | 6 +- test/CodeGenCXX/pr11676.cpp | 17 - test/CodeGenCXX/pr11797.cpp | 2 +- test/CodeGenCXX/pr12251.cpp | 78 +-- test/CodeGenCXX/pr13396.cpp | 12 +- test/CodeGenCXX/pr9130.cpp | 2 +- test/CodeGenCXX/pr9965.cpp | 2 +- test/CodeGenCXX/pragma-visibility.cpp | 14 +- test/CodeGenCXX/pragma-weak.cpp | 10 +- test/CodeGenCXX/predefined-expr.cpp | 22 + test/CodeGenCXX/ptr-to-member-function.cpp | 4 +- test/CodeGenCXX/reference-cast.cpp | 20 +- test/CodeGenCXX/references.cpp | 18 +- test/CodeGenCXX/return.cpp | 2 +- test/CodeGenCXX/rtti-layout.cpp | 2 +- test/CodeGenCXX/runtimecc.cpp | 6 +- test/CodeGenCXX/rvalue-references.cpp | 14 +- test/CodeGenCXX/scoped-enums.cpp | 9 +- .../skip-vtable-pointer-initialization.cpp | 16 +- test/CodeGenCXX/static-data-member.cpp | 6 +- test/CodeGenCXX/static-init-1.cpp | 8 +- test/CodeGenCXX/static-init-4.cpp | 7 + test/CodeGenCXX/static-init-pnacl.cpp | 14 + test/CodeGenCXX/static-init.cpp | 16 +- ...tic-member-variable-explicit-specialization.cpp | 89 +++- test/CodeGenCXX/stmtexpr.cpp | 7 + test/CodeGenCXX/template-anonymous-types.cpp | 12 +- .../template-dependent-bind-temporary.cpp | 2 +- .../template-inner-struct-visibility-hidden.cpp | 4 +- test/CodeGenCXX/template-instantiation.cpp | 20 +- test/CodeGenCXX/template-linkage.cpp | 12 +- test/CodeGenCXX/temporaries.cpp | 243 ++++++++- test/CodeGenCXX/thiscall-struct-return.cpp | 4 +- test/CodeGenCXX/threadsafe-statics-exceptions.cpp | 2 +- test/CodeGenCXX/throw-expression-cleanup.cpp | 2 +- test/CodeGenCXX/throw-expressions.cpp | 26 +- test/CodeGenCXX/thunks-available-externally.cpp | 11 +- test/CodeGenCXX/thunks.cpp | 44 +- test/CodeGenCXX/type_visibility.cpp | 36 +- test/CodeGenCXX/typeid.cpp | 5 +- test/CodeGenCXX/unknown-anytype.cpp | 62 ++- test/CodeGenCXX/value-init.cpp | 20 +- test/CodeGenCXX/vararg-conversion-ctor.cpp | 2 +- test/CodeGenCXX/vararg-non-pod.cpp | 2 +- test/CodeGenCXX/varargs.cpp | 4 +- test/CodeGenCXX/variadic-templates.cpp | 4 +- test/CodeGenCXX/virt-dtor-gen.cpp | 2 +- test/CodeGenCXX/virtual-base-cast.cpp | 54 ++ test/CodeGenCXX/virtual-base-destructor-call.cpp | 22 +- test/CodeGenCXX/virtual-bases.cpp | 12 +- test/CodeGenCXX/virtual-destructor-calls.cpp | 8 +- .../virtual-functions-incomplete-types.cpp | 2 +- .../visibility-hidden-extern-templates.cpp | 6 +- test/CodeGenCXX/visibility-inlines-hidden.cpp | 38 +- test/CodeGenCXX/visibility-ms-compat.cpp | 12 +- test/CodeGenCXX/visibility.cpp | 258 +++++---- test/CodeGenCXX/vla.cpp | 2 +- test/CodeGenCXX/volatile.cpp | 4 +- test/CodeGenCXX/vtable-available-externally.cpp | 26 +- test/CodeGenCXX/vtable-layout.cpp | 188 ++++++- test/CodeGenCXX/vtable-linkage.cpp | 139 ++--- test/CodeGenCXX/vtable-pointer-initialization.cpp | 10 +- test/CodeGenCXX/x86_32-arguments.cpp | 30 +- test/CodeGenCXX/x86_64-arguments.cpp | 18 +- 290 files changed, 9650 insertions(+), 1820 deletions(-) delete mode 100644 test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp create mode 100644 test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp create mode 100644 test/CodeGenCXX/aarch64-neon.cpp create mode 100644 test/CodeGenCXX/arm-vaarg.cpp create mode 100644 test/CodeGenCXX/attr-cleanup.cpp create mode 100644 test/CodeGenCXX/captured-statements.cpp create mode 100644 test/CodeGenCXX/catch-undef-behavior2.cpp create mode 100644 test/CodeGenCXX/const-init-cxx1y.cpp create mode 100644 test/CodeGenCXX/crash.cpp create mode 100644 test/CodeGenCXX/ctor-dtor-alias.cpp create mode 100644 test/CodeGenCXX/cxx11-initializer-array-new.cpp create mode 100644 test/CodeGenCXX/cxx1y-deduced-return-type.cpp create mode 100644 test/CodeGenCXX/cxx1y-init-captures.cpp create mode 100644 test/CodeGenCXX/cxx1y-sized-deallocation.cpp create mode 100644 test/CodeGenCXX/cxx1y-variable-template.cpp create mode 100644 test/CodeGenCXX/debug-info-class-limited.cpp create mode 100644 test/CodeGenCXX/debug-info-class-nolimit.cpp create mode 100644 test/CodeGenCXX/debug-info-cxx1y.cpp create mode 100644 test/CodeGenCXX/debug-info-decl-nested.cpp create mode 100644 test/CodeGenCXX/debug-info-function-context.cpp delete mode 100644 test/CodeGenCXX/debug-info-limit-type.cpp delete mode 100644 test/CodeGenCXX/debug-info-limit.cpp create mode 100644 test/CodeGenCXX/debug-info-limited.cpp create mode 100644 test/CodeGenCXX/debug-info-scope.cpp create mode 100644 test/CodeGenCXX/debug-info-uuid.cpp create mode 100644 test/CodeGenCXX/delayed-template-parsing.cpp create mode 100644 test/CodeGenCXX/dynamic_cast-no-rtti.cpp create mode 100644 test/CodeGenCXX/empty-nontrivially-copyable.cpp create mode 100644 test/CodeGenCXX/invalid.cpp create mode 100644 test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp create mode 100644 test/CodeGenCXX/lambda-expressions-nested-linkage.cpp create mode 100644 test/CodeGenCXX/linkage.cpp create mode 100644 test/CodeGenCXX/lpad-linetable.cpp create mode 100644 test/CodeGenCXX/mangle-windows.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-alignment-fail.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-constexpr-vs-inheritance.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-exceptions.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-structors-alias.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-thunks.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-vbtables.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp create mode 100644 test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp create mode 100644 test/CodeGenCXX/microsoft-new.cpp delete mode 100644 test/CodeGenCXX/microsoft-uuidof-unsupported-target.cpp create mode 100644 test/CodeGenCXX/move-assignment.cpp create mode 100644 test/CodeGenCXX/ms-integer-static-data-members.cpp create mode 100644 test/CodeGenCXX/new-alias.cpp create mode 100644 test/CodeGenCXX/noexcept.cpp delete mode 100644 test/CodeGenCXX/pr11676.cpp create mode 100644 test/CodeGenCXX/static-init-4.cpp create mode 100644 test/CodeGenCXX/static-init-pnacl.cpp (limited to 'test/CodeGenCXX') diff --git a/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp b/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp index 3bfecd5..c478e7d 100644 --- a/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp +++ b/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp @@ -4,6 +4,6 @@ namespace nm { struct str { - friend int foo(int arg = 0); + friend void foo(int arg = 0) {}; }; } diff --git a/test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp b/test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp deleted file mode 100644 index c37f5dc..0000000 --- a/test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s - -// CHECK-NOT: i32 6 -struct QVectorTypedData { - int size; - unsigned int sharable : 1; - unsigned short array[1]; -}; - -void foo(QVectorTypedData *X) { - X->array[0] = 123; -} diff --git a/test/CodeGenCXX/2007-05-03-VectorInit.cpp b/test/CodeGenCXX/2007-05-03-VectorInit.cpp index 5bc196f..b22b52a 100644 --- a/test/CodeGenCXX/2007-05-03-VectorInit.cpp +++ b/test/CodeGenCXX/2007-05-03-VectorInit.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -O0 -o - +// RUN: %clang_cc1 -emit-llvm %s -o - // PR1378 typedef float v4sf __attribute__((vector_size(16))); diff --git a/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp b/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp index 7c05535..802f4c3 100644 --- a/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp +++ b/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -O0 -g %s -o /dev/null +// RUN: %clang_cc1 -emit-llvm -g %s -o /dev/null // PR 7104 struct A { diff --git a/test/CodeGenCXX/DynArrayInit.cpp b/test/CodeGenCXX/DynArrayInit.cpp index 4b4c2ec..fb865e3 100644 --- a/test/CodeGenCXX/DynArrayInit.cpp +++ b/test/CodeGenCXX/DynArrayInit.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -O3 -emit-llvm -o - %s | FileCheck %s // PR7490 -// CHECK: define signext i8 @_Z2f0v +// CHECK-LABEL: define signext i8 @_Z2f0v // CHECK: ret i8 0 // CHECK: } inline void* operator new[](unsigned long, void* __p) { return __p; } diff --git a/test/CodeGenCXX/PR5050-constructor-conversion.cpp b/test/CodeGenCXX/PR5050-constructor-conversion.cpp index c50dafb..a1b05eb 100644 --- a/test/CodeGenCXX/PR5050-constructor-conversion.cpp +++ b/test/CodeGenCXX/PR5050-constructor-conversion.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s struct A { A(const A&, int i1 = 1); }; diff --git a/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp b/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp new file mode 100644 index 0000000..2514704 --- /dev/null +++ b/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp @@ -0,0 +1,85 @@ +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon %s -emit-llvm -o - | FileCheck %s + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +typedef unsigned char poly8_t; +typedef unsigned short poly16_t; +typedef __fp16 float16_t; +typedef float float32_t; +typedef double float64_t; + +typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t; +typedef __attribute__((neon_vector_type(16))) int8_t int8x16_t; +typedef __attribute__((neon_vector_type(4))) int16_t int16x4_t; +typedef __attribute__((neon_vector_type(8))) int16_t int16x8_t; +typedef __attribute__((neon_vector_type(2))) int int32x2_t; +typedef __attribute__((neon_vector_type(4))) int int32x4_t; +typedef __attribute__((neon_vector_type(2))) int64_t int64x2_t; +typedef __attribute__((neon_vector_type(8))) uint8_t uint8x8_t; +typedef __attribute__((neon_vector_type(16))) uint8_t uint8x16_t; +typedef __attribute__((neon_vector_type(4))) uint16_t uint16x4_t; +typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t; +typedef __attribute__((neon_vector_type(2))) unsigned int uint32x2_t; +typedef __attribute__((neon_vector_type(4))) unsigned int uint32x4_t; +typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t; +typedef __attribute__((neon_vector_type(4))) float16_t float16x4_t; +typedef __attribute__((neon_vector_type(8))) float16_t float16x8_t; +typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t; +typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t; +typedef __attribute__((neon_vector_type(2))) float64_t float64x2_t; +typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t; +typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t; +typedef __attribute__((neon_polyvector_type(4))) poly16_t poly16x4_t; +typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t; + +// CHECK: 10__Int8x8_t +void f1(int8x8_t) {} +// CHECK: 11__Int16x4_t +void f2(int16x4_t) {} +// CHECK: 11__Int32x2_t +void f3(int32x2_t) {} +// CHECK: 11__Uint8x8_t +void f4(uint8x8_t) {} +// CHECK: 12__Uint16x4_t +void f5(uint16x4_t) {} +// CHECK: 13__Float16x4_t +void f6(float16x4_t) {} +// CHECK: 13__Float16x8_t +void f7(float16x8_t) {} +// CHECK: 12__Uint32x2_t +void f8(uint32x2_t) {} +// CHECK: 13__Float32x2_t +void f9(float32x2_t) {} +// CHECK: 13__Float32x4_t +void f10(float32x4_t) {} +// CHECK: 11__Poly8x8_t +void f11(poly8x8_t v) {} +// CHECK: 12__Poly16x4_t +void f12(poly16x4_t v) {} +// CHECK:12__Poly8x16_t +void f13(poly8x16_t v) {} +// CHECK:12__Poly16x8_t +void f14(poly16x8_t v) {} +// CHECK: 11__Int8x16_t +void f15(int8x16_t) {} +// CHECK: 11__Int16x8_t +void f16(int16x8_t) {} +// CHECK:11__Int32x4_t +void f17(int32x4_t) {} +// CHECK: 12__Uint8x16_t +void f18(uint8x16_t) {} +// CHECK: 12__Uint16x8_t +void f19(uint16x8_t) {} +// CHECK: 12__Uint32x4_t +void f20(uint32x4_t) {} +// CHECK: 11__Int64x2_t +void f21(int64x2_t) {} +// CHECK: 12__Uint64x2_t +void f22(uint64x2_t) {} +// CHECK: 13__Float64x2_t +void f23(float64x2_t) {} diff --git a/test/CodeGenCXX/aarch64-neon.cpp b/test/CodeGenCXX/aarch64-neon.cpp new file mode 100644 index 0000000..5d2a00b --- /dev/null +++ b/test/CodeGenCXX/aarch64-neon.cpp @@ -0,0 +1,13 @@ +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon \ +// RUN: -ffp-contract=fast -S -O3 -o - %s | FileCheck %s + +// Test whether arm_neon.h can be used in .cpp file. + +#include "arm_neon.h" + +poly64x1_t test_vld1_p64(poly64_t const * ptr) { + // CHECK: test_vld1_p64 + return vld1_p64(ptr); + // CHECK: ld1 {{{v[0-9]+}}.1d}, [{{x[0-9]+|sp}}] +} diff --git a/test/CodeGenCXX/abstract-class-ctors-dtors.cpp b/test/CodeGenCXX/abstract-class-ctors-dtors.cpp index 012c223..793bbde 100644 --- a/test/CodeGenCXX/abstract-class-ctors-dtors.cpp +++ b/test/CodeGenCXX/abstract-class-ctors-dtors.cpp @@ -7,10 +7,10 @@ struct A { ~A(); }; -// CHECK-NOT: define void @_ZN1AC1Ev -// CHECK: define void @_ZN1AC2Ev -// CHECK: define void @_ZN1AD1Ev -// CHECK: define void @_ZN1AD2Ev +// CHECK-NOT-LABEL: define void @_ZN1AC1Ev +// CHECK-LABEL: define void @_ZN1AC2Ev +// CHECK-LABEL: define void @_ZN1AD1Ev +// CHECK-LABEL: define void @_ZN1AD2Ev A::A() { } A::~A() { } diff --git a/test/CodeGenCXX/address-of-fntemplate.cpp b/test/CodeGenCXX/address-of-fntemplate.cpp index 162c6e5..7179452 100644 --- a/test/CodeGenCXX/address-of-fntemplate.cpp +++ b/test/CodeGenCXX/address-of-fntemplate.cpp @@ -9,8 +9,8 @@ void test() { // CHECK: @_Z1fIiEvv void (*p2)() = f; } -// CHECK: define linkonce_odr void @_Z1fIiEvT_ -// CHECK: define linkonce_odr void @_Z1fIiEvv +// CHECK-LABEL: define linkonce_odr void @_Z1fIiEvT_ +// CHECK-LABEL: define linkonce_odr void @_Z1fIiEvv namespace PR6973 { template diff --git a/test/CodeGenCXX/alloca-align.cpp b/test/CodeGenCXX/alloca-align.cpp index 99d6ab5..079b55d 100644 --- a/test/CodeGenCXX/alloca-align.cpp +++ b/test/CodeGenCXX/alloca-align.cpp @@ -6,19 +6,19 @@ struct s0 { int TheStores __attribute__((aligned(16))); }; -// CHECK: define void @f0 +// CHECK-LABEL: define void @f0 // CHECK: alloca %struct.s0, align 16 extern "C" void f0() { (void) s0(); } -// CHECK: define void @f1 +// CHECK-LABEL: define void @f1 // CHECK: alloca %struct.s0, align 16 extern "C" void f1() { (void) (struct s0) { 0, 0, 0, 0 }; } -// CHECK: define i32 @f2 +// CHECK-LABEL: define i32 @f2 // CHECK: alloca %struct.s1, align 2 struct s1 { short x; short y; }; extern "C" struct s1 f2(int a, struct s1 *x, struct s1 *y) { diff --git a/test/CodeGenCXX/anonymous-namespaces.cpp b/test/CodeGenCXX/anonymous-namespaces.cpp index 32e17a3..abc700f 100644 --- a/test/CodeGenCXX/anonymous-namespaces.cpp +++ b/test/CodeGenCXX/anonymous-namespaces.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-llvm %s -o - > %t -// RUN: FileCheck %s -check-prefix=1 < %t -// RUN: FileCheck %s -check-prefix=2 < %t +// RUN: FileCheck %s -check-prefix=CHECK-1 < %t +// RUN: FileCheck %s -check-prefix=CHECK-2 < %t int f(); @@ -28,12 +28,12 @@ namespace { struct E : public virtual EBase { virtual ~E() {} }; }; - // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_13fooEv() + // CHECK-1-LABEL: define internal i32 @_ZN12_GLOBAL__N_13fooEv() int foo() { return 32; } - // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_11A3fooEv() + // CHECK-1-LABEL: define internal i32 @_ZN12_GLOBAL__N_11A3fooEv() namespace A { int foo() { return 45; @@ -58,11 +58,20 @@ namespace test2 { struct C; } - // CHECK-2: define void @_ZN5test24testEv() + // CHECK-2-LABEL: define void @_ZN5test24testEv() // CHECK-2: call void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() void test() { A::B::foo(); } - // CHECK-2: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() + // CHECK-2-LABEL: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() } + +namespace { + +int bar() { + extern int a; + return a; +} + +} // namespace diff --git a/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/test/CodeGenCXX/anonymous-union-member-initializer.cpp index 8dc4f47..98e982d 100644 --- a/test/CodeGenCXX/anonymous-union-member-initializer.cpp +++ b/test/CodeGenCXX/anonymous-union-member-initializer.cpp @@ -31,7 +31,7 @@ namespace PR7021 { union { long l; }; }; - // CHECK: define void @_ZN6PR70211fENS_1XES0_ + // CHECK-LABEL: define void @_ZN6PR70211fENS_1XES0_ void f(X x, X z) { X x1; @@ -61,7 +61,7 @@ namespace test2 { }; A::A() : b(10) { } - // CHECK: define void @_ZN5test21AC2Ev( + // CHECK-LABEL: define void @_ZN5test21AC2Ev( // CHECK-NOT: } // CHECK: store i32 10 // CHECK: } @@ -79,14 +79,14 @@ namespace PR10512 { }; }; - // CHECK: define void @_ZN7PR105121AC2Ev + // CHECK-LABEL: define void @_ZN7PR105121AC2Ev // CHECK: [[THISADDR:%[a-zA-z0-9.]+]] = alloca [[A:%"struct[A-Za-z0-9:.]+"]] // CHECK-NEXT: store [[A]]* [[THIS:%[a-zA-z0-9.]+]], [[A]]** [[THISADDR]] // CHECK-NEXT: [[THIS1:%[a-zA-z0-9.]+]] = load [[A]]** [[THISADDR]] // CHECK-NEXT: ret void A::A() {} - // CHECK: define void @_ZN7PR105121AC2Ei + // CHECK-LABEL: define void @_ZN7PR105121AC2Ei // CHECK: [[THISADDR:%[a-zA-z0-9.]+]] = alloca [[A:%"struct[A-Za-z0-9:.]+"]] // CHECK-NEXT: [[XADDR:%[a-zA-z0-9.]+]] = alloca i32 // CHECK-NEXT: store [[A]]* [[THIS:%[a-zA-z0-9.]+]], [[A]]** [[THISADDR]] @@ -100,7 +100,7 @@ namespace PR10512 { // CHECK-NEXT: ret void A::A(int x) : x(x) { } - // CHECK: define void @_ZN7PR105121AC2El + // CHECK-LABEL: define void @_ZN7PR105121AC2El // CHECK: [[THISADDR:%[a-zA-z0-9.]+]] = alloca [[A:%"struct[A-Za-z0-9:.]+"]] // CHECK-NEXT: [[XADDR:%[a-zA-z0-9.]+]] = alloca i64 // CHECK-NEXT: store [[A]]* [[THIS:%[a-zA-z0-9.]+]], [[A]]** [[THISADDR]] @@ -130,7 +130,7 @@ namespace test3 { }; A::A() : callback(0), callback_value(0) {} - // CHECK: define void @_ZN5test31AC2Ev( + // CHECK-LABEL: define void @_ZN5test31AC2Ev( // CHECK: [[THIS:%.*]] = load // CHECK-NEXT: [[UNION:%.*]] = getelementptr inbounds {{.*}} [[THIS]], i32 0, i32 0 // CHECK-NEXT: [[STRUCT:%.*]] = bitcast {{.*}}* [[UNION]] to diff --git a/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp b/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp index bd275f1..7ac5b58 100644 --- a/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp +++ b/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp @@ -1,9 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -fno-rtti -emit-llvm -o - %s | FileCheck %s -// CHECK: define void @_ZN2B1D0Ev +// CHECK-LABEL: define void @_ZN2B1D0Ev // CHECK: [[T1:%.*]] = load void (%struct.B1*)** getelementptr inbounds (void (%struct.B1*)** bitcast ([5 x i8*]* @_ZTV2B1 to void (%struct.B1*)**), i64 2) // CHECK-NEXT: call void [[T1]](%struct.B1* [[T2:%.*]]) -// CHECK: define void @_Z6DELETEP2B1 +// CHECK-LABEL: define void @_Z6DELETEP2B1 // CHECK: [[T3:%.*]] = load void (%struct.B1*)** getelementptr inbounds (void (%struct.B1*)** bitcast ([5 x i8*]* @_ZTV2B1 to void (%struct.B1*)**), i64 2) // CHECK-NEXT: call void [[T3]](%struct.B1* [[T4:%.*]]) diff --git a/test/CodeGenCXX/apple-kext-linkage.C b/test/CodeGenCXX/apple-kext-linkage.C index 59d228e..e66b038 100644 --- a/test/CodeGenCXX/apple-kext-linkage.C +++ b/test/CodeGenCXX/apple-kext-linkage.C @@ -13,21 +13,21 @@ void foo() { Derived d1; // ok } -// CHECK: define internal i32 @_Z1fj( +// CHECK-LABEL: define internal i32 @_Z1fj( inline unsigned f(unsigned n) { return n == 0 ? 0 : n + f(n-1); } unsigned g(unsigned n) { return f(n); } // rdar://problem/10133200: give explicit instantiations external linkage in kernel mode -// CHECK: define void @_Z3barIiEvv() +// CHECK-LABEL: define void @_Z3barIiEvv() template void bar() {} template void bar(); -// CHECK: define internal i32 @_Z5identIiET_S0_( +// CHECK-LABEL: define internal i32 @_Z5identIiET_S0_( template X ident(X x) { return x; } int foo(int n) { return ident(n); } -// CHECK: define internal void @_ZN7DerivedD1Ev( -// CHECK: define internal void @_ZN7DerivedD0Ev( -// CHECK: define internal void @_ZN7DeriveddlEPv( +// CHECK-LABEL: define internal void @_ZN7DerivedD1Ev( +// CHECK-LABEL: define internal void @_ZN7DerivedD0Ev( +// CHECK-LABEL: define internal void @_ZN7DeriveddlEPv( diff --git a/test/CodeGenCXX/arm-vaarg.cpp b/test/CodeGenCXX/arm-vaarg.cpp new file mode 100644 index 0000000..9850fb3 --- /dev/null +++ b/test/CodeGenCXX/arm-vaarg.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -triple armv7-apple-ios -emit-llvm -o - %s | FileCheck %s +struct Empty {}; + +Empty emptyvar; + +int take_args(int a, ...) { + __builtin_va_list l; + __builtin_va_start(l, a); +// CHECK: call void @llvm.va_start + + emptyvar = __builtin_va_arg(l, Empty); +// CHECK: load i8** +// CHECK-NOT: getelementptr +// CHECK: [[EMPTY_PTR:%[a-zA-Z0-9._]+]] = bitcast i8* {{%[a-zA-Z0-9._]+}} to %struct.Empty* + + // It's conceivable that EMPTY_PTR may not actually be a valid pointer + // (e.g. it's at the very bottom of the stack and the next page is + // invalid). This doesn't matter provided it's never loaded (there's no + // well-defined way to tell), but it becomes a problem if we do try to use it. +// CHECK-NOT: load %struct.Empty* [[EMPTY_PTR]] + + int i = __builtin_va_arg(l, int); +// CHECK: load i32* + + __builtin_va_end(l); + return i; +} diff --git a/test/CodeGenCXX/arm.cpp b/test/CodeGenCXX/arm.cpp index 48f2f00..2fb9c49 100644 --- a/test/CodeGenCXX/arm.cpp +++ b/test/CodeGenCXX/arm.cpp @@ -28,7 +28,7 @@ bar baz; // CHECK: call [[BAR:%.*]]* @_ZN3barC1Ev( // CHECK-NEXT: call i32 @atexit(void ()* @__dtor_baz) -// CHECK: define internal void @__dtor_baz() +// CHECK-LABEL: define internal void @__dtor_baz() // CHECK: call [[BAR]]* @_ZN3barD1Ev([[BAR]]* @baz) // Destructors and constructors must return this. @@ -41,7 +41,7 @@ namespace test1 { void bar() { foo(); } }; - // CHECK: define void @_ZN5test14testEv() + // CHECK-LABEL: define void @_ZN5test14testEv() void test() { // CHECK: [[AV:%.*]] = alloca [[A:%.*]], align 1 // CHECK: call [[A]]* @_ZN5test11AC1Ei([[A]]* [[AV]], i32 10) @@ -52,19 +52,19 @@ namespace test1 { a.bar(); } - // CHECK: define linkonce_odr [[A]]* @_ZN5test11AC1Ei([[A]]* %this, i32 %i) unnamed_addr + // CHECK: define linkonce_odr [[A]]* @_ZN5test11AC1Ei([[A]]* returned %this, i32 %i) unnamed_addr // CHECK: [[THIS:%.*]] = alloca [[A]]*, align 4 // CHECK: store [[A]]* {{.*}}, [[A]]** [[THIS]] // CHECK: [[THIS1:%.*]] = load [[A]]** [[THIS]] - // CHECK: [[THIS2:%.*]] = call [[A]]* @_ZN5test11AC2Ei( - // CHECK: ret [[A]]* [[THIS2]] + // CHECK: {{%.*}} = call [[A]]* @_ZN5test11AC2Ei( + // CHECK: ret [[A]]* [[THIS1]] - // CHECK: define linkonce_odr [[A]]* @_ZN5test11AD1Ev([[A]]* %this) unnamed_addr + // CHECK: define linkonce_odr [[A]]* @_ZN5test11AD1Ev([[A]]* returned %this) unnamed_addr // CHECK: [[THIS:%.*]] = alloca [[A]]*, align 4 // CHECK: store [[A]]* {{.*}}, [[A]]** [[THIS]] // CHECK: [[THIS1:%.*]] = load [[A]]** [[THIS]] - // CHECK: [[THIS2:%.*]] = call [[A]]* @_ZN5test11AD2Ev( - // CHECK: ret [[A]]* [[THIS2]] + // CHECK: {{%.*}} = call [[A]]* @_ZN5test11AD2Ev( + // CHECK: ret [[A]]* [[THIS1]] } // Awkward virtual cases. @@ -107,7 +107,7 @@ namespace test3 { }; void a() { - // CHECK: define void @_ZN5test31aEv() + // CHECK-LABEL: define void @_ZN5test31aEv() // CHECK: call noalias i8* @_Znam(i32 48) // CHECK: store i32 4 // CHECK: store i32 10 @@ -115,7 +115,7 @@ namespace test3 { } void b(int n) { - // CHECK: define void @_ZN5test31bEi( + // CHECK-LABEL: define void @_ZN5test31bEi( // CHECK: [[N:%.*]] = load i32* // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 4) // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8) @@ -128,7 +128,7 @@ namespace test3 { } void c() { - // CHECK: define void @_ZN5test31cEv() + // CHECK-LABEL: define void @_ZN5test31cEv() // CHECK: call noalias i8* @_Znam(i32 808) // CHECK: store i32 4 // CHECK: store i32 200 @@ -136,7 +136,7 @@ namespace test3 { } void d(int n) { - // CHECK: define void @_ZN5test31dEi( + // CHECK-LABEL: define void @_ZN5test31dEi( // CHECK: [[N:%.*]] = load i32* // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 80) // CHECK: [[NE:%.*]] = mul i32 [[N]], 20 @@ -149,7 +149,7 @@ namespace test3 { } void e(A *x) { - // CHECK: define void @_ZN5test31eEPNS_1AE( + // CHECK-LABEL: define void @_ZN5test31eEPNS_1AE( // CHECK: icmp eq {{.*}}, null // CHECK: getelementptr {{.*}}, i64 -8 // CHECK: getelementptr {{.*}}, i64 4 @@ -161,7 +161,7 @@ namespace test3 { } void f(A (*x)[20]) { - // CHECK: define void @_ZN5test31fEPA20_NS_1AE( + // CHECK-LABEL: define void @_ZN5test31fEPA20_NS_1AE( // CHECK: icmp eq {{.*}}, null // CHECK: getelementptr {{.*}}, i64 -8 // CHECK: getelementptr {{.*}}, i64 4 @@ -180,7 +180,7 @@ namespace test4 { }; void a() { - // CHECK: define void @_ZN5test41aEv() + // CHECK-LABEL: define void @_ZN5test41aEv() // CHECK: call noalias i8* @_Znam(i32 48) // CHECK: store i32 4 // CHECK: store i32 10 @@ -188,7 +188,7 @@ namespace test4 { } void b(int n) { - // CHECK: define void @_ZN5test41bEi( + // CHECK-LABEL: define void @_ZN5test41bEi( // CHECK: [[N:%.*]] = load i32* // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 4) // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8) @@ -200,7 +200,7 @@ namespace test4 { } void c() { - // CHECK: define void @_ZN5test41cEv() + // CHECK-LABEL: define void @_ZN5test41cEv() // CHECK: call noalias i8* @_Znam(i32 808) // CHECK: store i32 4 // CHECK: store i32 200 @@ -208,7 +208,7 @@ namespace test4 { } void d(int n) { - // CHECK: define void @_ZN5test41dEi( + // CHECK-LABEL: define void @_ZN5test41dEi( // CHECK: [[N:%.*]] = load i32* // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 80) // CHECK: [[NE:%.*]] = mul i32 [[N]], 20 @@ -221,7 +221,7 @@ namespace test4 { } void e(A *x) { - // CHECK: define void @_ZN5test41eEPNS_1AE( + // CHECK-LABEL: define void @_ZN5test41eEPNS_1AE( // CHECK: [[ALLOC:%.*]] = getelementptr inbounds {{.*}}, i64 -8 // CHECK: getelementptr inbounds {{.*}}, i64 4 // CHECK: bitcast @@ -233,7 +233,7 @@ namespace test4 { } void f(A (*x)[20]) { - // CHECK: define void @_ZN5test41fEPA20_NS_1AE( + // CHECK-LABEL: define void @_ZN5test41fEPA20_NS_1AE( // CHECK: [[ALLOC:%.*]] = getelementptr inbounds {{.*}}, i64 -8 // CHECK: getelementptr inbounds {{.*}}, i64 4 // CHECK: bitcast @@ -251,7 +251,7 @@ namespace test5 { ~A(); }; - // CHECK: define void @_ZN5test54testEPNS_1AE + // CHECK-LABEL: define void @_ZN5test54testEPNS_1AE void test(A *a) { // CHECK: [[PTR:%.*]] = alloca [[A:%.*]]*, align 4 // CHECK-NEXT: store [[A]]* {{.*}}, [[A]]** [[PTR]], align 4 @@ -267,7 +267,7 @@ namespace test6 { virtual ~A(); }; - // CHECK: define void @_ZN5test64testEPNS_1AE + // CHECK-LABEL: define void @_ZN5test64testEPNS_1AE void test(A *a) { // CHECK: [[AVAR:%.*]] = alloca [[A:%.*]]*, align 4 // CHECK-NEXT: store [[A]]* {{.*}}, [[A]]** [[AVAR]], align 4 @@ -290,7 +290,7 @@ namespace test7 { // Static and guard tested at top of file - // CHECK: define void @_ZN5test74testEv() + // CHECK-LABEL: define void @_ZN5test74testEv() void test() { // CHECK: [[T0:%.*]] = load i32* @_ZGVZN5test74testEvE1x // CHECK-NEXT: [[T1:%.*]] = and i32 [[T0]], 1 @@ -325,7 +325,7 @@ namespace test8 { // Static and guard tested at top of file - // CHECK: define void @_ZN5test84testEv() + // CHECK-LABEL: define void @_ZN5test84testEv() void test() { // CHECK: [[T0:%.*]] = load i32* @_ZGVZN5test84testEvE1x // CHECK-NEXT: [[T1:%.*]] = and i32 [[T0]], 1 @@ -394,7 +394,7 @@ namespace test9 { void testDelete(A *array) { delete[] array; } -// CHECK: define void @_ZN5test910testDeleteEPNS_1AE( +// CHECK-LABEL: define void @_ZN5test910testDeleteEPNS_1AE( // CHECK: [[BEGIN:%.*]] = load [[TEST9]]** // CHECK-NEXT: [[T0:%.*]] = icmp eq [[TEST9]]* [[BEGIN]], null // CHECK-NEXT: br i1 [[T0]], @@ -413,7 +413,7 @@ namespace test9 { // CHECK: call [[C]]* @_ZN5test21CD1Ev( // CHECK: ret [[C]]* undef - // CHECK: define linkonce_odr void @_ZTv0_n12_N5test21CD0Ev( + // CHECK-LABEL: define linkonce_odr void @_ZTv0_n12_N5test21CD0Ev( // CHECK: call void @_ZN5test21CD0Ev( // CHECK: ret void diff --git a/test/CodeGenCXX/array-construction.cpp b/test/CodeGenCXX/array-construction.cpp index 7b565a4..645ad1d 100644 --- a/test/CodeGenCXX/array-construction.cpp +++ b/test/CodeGenCXX/array-construction.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/array-operator-delete-call.cpp b/test/CodeGenCXX/array-operator-delete-call.cpp index 1b23c4d..8d6f50f 100644 --- a/test/CodeGenCXX/array-operator-delete-call.cpp +++ b/test/CodeGenCXX/array-operator-delete-call.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/atomic.cpp b/test/CodeGenCXX/atomic.cpp index 36bb4ef..653f16d 100644 --- a/test/CodeGenCXX/atomic.cpp +++ b/test/CodeGenCXX/atomic.cpp @@ -5,7 +5,7 @@ namespace PR11411 { void f(); }; - // CHECK: define linkonce_odr void @_ZN7PR114113PtrIiE1fEv + // CHECK-LABEL: define linkonce_odr void @_ZN7PR114113PtrIiE1fEv // CHECK-NOT: ret template inline void Ptr<_Tp>::f() { int* _refcount; diff --git a/test/CodeGenCXX/atomicinit.cpp b/test/CodeGenCXX/atomicinit.cpp index 38d012e..ee2e9e4 100644 --- a/test/CodeGenCXX/atomicinit.cpp +++ b/test/CodeGenCXX/atomicinit.cpp @@ -18,7 +18,7 @@ struct B { _Atomic(B) b; -// CHECK: define void @_Z11atomic_initR1Ai +// CHECK-LABEL: define void @_Z11atomic_initR1Ai void atomic_init(A& a, int i) { // CHECK-NOT: atomic // CHECK: tail call void @_ZN1BC1Ei @@ -26,7 +26,7 @@ void atomic_init(A& a, int i) { // CHECK-NEXT: ret void } -// CHECK: define void @_Z16atomic_init_boolPU7_Atomicbb +// CHECK-LABEL: define void @_Z16atomic_init_boolPU7_Atomicbb void atomic_init_bool(_Atomic(bool) *ab, bool b) { // CHECK-NOT: atomic // CHECK: {{zext i1.*to i8}} @@ -40,7 +40,7 @@ struct AtomicBoolMember { AtomicBoolMember(bool b); }; -// CHECK: define void @_ZN16AtomicBoolMemberC2Eb +// CHECK-LABEL: define void @_ZN16AtomicBoolMemberC2Eb // CHECK: {{zext i1.*to i8}} // CHECK-NEXT: store i8 // CHECK-NEXT: ret void diff --git a/test/CodeGenCXX/attr-cleanup.cpp b/test/CodeGenCXX/attr-cleanup.cpp new file mode 100644 index 0000000..ff15b03 --- /dev/null +++ b/test/CodeGenCXX/attr-cleanup.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s + +namespace N { + void free(void *i) {} +} + +int main(void) { + // CHECK: call void @_ZN1N4freeEPv + void *fp __attribute__((cleanup(N::free))); + return 0; +} diff --git a/test/CodeGenCXX/attr.cpp b/test/CodeGenCXX/attr.cpp index 4748cda..8bcff36 100644 --- a/test/CodeGenCXX/attr.cpp +++ b/test/CodeGenCXX/attr.cpp @@ -26,7 +26,7 @@ void C::bar3() { } void C::bar4() { } // PR6635 -// CHECK: define i32 @_Z5test1v() +// CHECK-LABEL: define i32 @_Z5test1v() int test1() { return 10; } // CHECK at top of file extern "C" int test2() __attribute__((alias("_Z5test1v"))); diff --git a/test/CodeGenCXX/bitfield-layout.cpp b/test/CodeGenCXX/bitfield-layout.cpp index 15f33d2..646300a 100644 --- a/test/CodeGenCXX/bitfield-layout.cpp +++ b/test/CodeGenCXX/bitfield-layout.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix LP64 %s -// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix LP32 %s +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-LP64 %s +// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-LP32 %s // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] } union Test1 { diff --git a/test/CodeGenCXX/bitfield.cpp b/test/CodeGenCXX/bitfield.cpp index 1814aa2..2c454b0 100644 --- a/test/CodeGenCXX/bitfield.cpp +++ b/test/CodeGenCXX/bitfield.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -verify -emit-llvm -o - %s \ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s \ // RUN: | FileCheck -check-prefix=CHECK-X86-64 %s -// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -verify -emit-llvm -o - %s \ +// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm -o - %s \ // RUN: | FileCheck -check-prefix=CHECK-PPC64 %s // // Tests for bitfield access patterns in C++ with special attention to @@ -20,13 +20,13 @@ namespace N0 { unsigned b71 : 2; }; unsigned read00(S* s) { - // CHECK-X86-64: define i32 @_ZN2N06read00 + // CHECK-X86-64-LABEL: define i32 @_ZN2N06read00 // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-X86-64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-X86-64: %[[and:.*]] = and i64 %[[val]], 16383 // CHECK-X86-64: %[[trunc:.*]] = trunc i64 %[[and]] to i32 // CHECK-X86-64: ret i32 %[[trunc]] - // CHECK-PPC64: define zeroext i32 @_ZN2N06read00 + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N06read00 // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-PPC64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i64 %[[val]], 50 @@ -35,14 +35,14 @@ namespace N0 { return s->b00; } unsigned read01(S* s) { - // CHECK-X86-64: define i32 @_ZN2N06read01 + // CHECK-X86-64-LABEL: define i32 @_ZN2N06read01 // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-X86-64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-X86-64: %[[shr:.*]] = lshr i64 %[[val]], 14 // CHECK-X86-64: %[[and:.*]] = and i64 %[[shr]], 3 // CHECK-X86-64: %[[trunc:.*]] = trunc i64 %[[and]] to i32 // CHECK-X86-64: ret i32 %[[trunc]] - // CHECK-PPC64: define zeroext i32 @_ZN2N06read01 + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N06read01 // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-PPC64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i64 %[[val]], 48 @@ -52,14 +52,14 @@ namespace N0 { return s->b01; } unsigned read20(S* s) { - // CHECK-X86-64: define i32 @_ZN2N06read20 + // CHECK-X86-64-LABEL: define i32 @_ZN2N06read20 // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-X86-64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-X86-64: %[[shr:.*]] = lshr i64 %[[val]], 16 // CHECK-X86-64: %[[and:.*]] = and i64 %[[shr]], 63 // CHECK-X86-64: %[[trunc:.*]] = trunc i64 %[[and]] to i32 // CHECK-X86-64: ret i32 %[[trunc]] - // CHECK-PPC64: define zeroext i32 @_ZN2N06read20 + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N06read20 // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-PPC64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i64 %[[val]], 42 @@ -69,14 +69,14 @@ namespace N0 { return s->b20; } unsigned read21(S* s) { - // CHECK-X86-64: define i32 @_ZN2N06read21 + // CHECK-X86-64-LABEL: define i32 @_ZN2N06read21 // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-X86-64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-X86-64: %[[shr:.*]] = lshr i64 %[[val]], 22 // CHECK-X86-64: %[[and:.*]] = and i64 %[[shr]], 3 // CHECK-X86-64: %[[trunc:.*]] = trunc i64 %[[and]] to i32 // CHECK-X86-64: ret i32 %[[trunc]] - // CHECK-PPC64: define zeroext i32 @_ZN2N06read21 + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N06read21 // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-PPC64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i64 %[[val]], 40 @@ -86,14 +86,14 @@ namespace N0 { return s->b21; } unsigned read30(S* s) { - // CHECK-X86-64: define i32 @_ZN2N06read30 + // CHECK-X86-64-LABEL: define i32 @_ZN2N06read30 // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-X86-64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-X86-64: %[[shr:.*]] = lshr i64 %[[val]], 24 // CHECK-X86-64: %[[and:.*]] = and i64 %[[shr]], 1073741823 // CHECK-X86-64: %[[trunc:.*]] = trunc i64 %[[and]] to i32 // CHECK-X86-64: ret i32 %[[trunc]] - // CHECK-PPC64: define zeroext i32 @_ZN2N06read30 + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N06read30 // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-PPC64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i64 %[[val]], 10 @@ -103,14 +103,14 @@ namespace N0 { return s->b30; } unsigned read31(S* s) { - // CHECK-X86-64: define i32 @_ZN2N06read31 + // CHECK-X86-64-LABEL: define i32 @_ZN2N06read31 // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-X86-64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-X86-64: %[[shr:.*]] = lshr i64 %[[val]], 54 // CHECK-X86-64: %[[and:.*]] = and i64 %[[shr]], 3 // CHECK-X86-64: %[[trunc:.*]] = trunc i64 %[[and]] to i32 // CHECK-X86-64: ret i32 %[[trunc]] - // CHECK-PPC64: define zeroext i32 @_ZN2N06read31 + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N06read31 // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-PPC64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i64 %[[val]], 8 @@ -120,14 +120,14 @@ namespace N0 { return s->b31; } unsigned read70(S* s) { - // CHECK-X86-64: define i32 @_ZN2N06read70 + // CHECK-X86-64-LABEL: define i32 @_ZN2N06read70 // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-X86-64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-X86-64: %[[shr:.*]] = lshr i64 %[[val]], 56 // CHECK-X86-64: %[[and:.*]] = and i64 %[[shr]], 63 // CHECK-X86-64: %[[trunc:.*]] = trunc i64 %[[and]] to i32 // CHECK-X86-64: ret i32 %[[trunc]] - // CHECK-PPC64: define zeroext i32 @_ZN2N06read70 + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N06read70 // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-PPC64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i64 %[[val]], 2 @@ -137,13 +137,13 @@ namespace N0 { return s->b70; } unsigned read71(S* s) { - // CHECK-X86-64: define i32 @_ZN2N06read71 + // CHECK-X86-64-LABEL: define i32 @_ZN2N06read71 // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-X86-64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-X86-64: %[[shr:.*]] = lshr i64 %[[val]], 62 // CHECK-X86-64: %[[trunc:.*]] = trunc i64 %[[shr]] to i32 // CHECK-X86-64: ret i32 %[[trunc]] - // CHECK-PPC64: define zeroext i32 @_ZN2N06read71 + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N06read71 // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i64* // CHECK-PPC64: %[[val:.*]] = load i64* %[[ptr]] // CHECK-PPC64: %[[and:.*]] = and i64 %[[val]], 3 @@ -166,13 +166,13 @@ namespace N1 { char c; }; unsigned read(S* s) { - // CHECK-X86-64: define i32 @_ZN2N14read + // CHECK-X86-64-LABEL: define i32 @_ZN2N14read // CHECK-X86-64: %[[ptr:.*]] = getelementptr inbounds %{{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-X86-64: %[[val:.*]] = load i8* %[[ptr]] // CHECK-X86-64: %[[and:.*]] = and i8 %[[val]], 1 // CHECK-X86-64: %[[ext:.*]] = zext i8 %[[and]] to i32 // CHECK-X86-64: ret i32 %[[ext]] - // CHECK-PPC64: define zeroext i32 @_ZN2N14read + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N14read // CHECK-PPC64: %[[ptr:.*]] = getelementptr inbounds %{{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-PPC64: %[[val:.*]] = load i8* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i8 %[[val]], 7 @@ -181,7 +181,7 @@ namespace N1 { return s->b; } void write(S* s, unsigned x) { - // CHECK-X86-64: define void @_ZN2N15write + // CHECK-X86-64-LABEL: define void @_ZN2N15write // CHECK-X86-64: %[[ptr:.*]] = getelementptr inbounds %{{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-X86-64: %[[x_trunc:.*]] = trunc i32 %{{.*}} to i8 // CHECK-X86-64: %[[old:.*]] = load i8* %[[ptr]] @@ -189,7 +189,7 @@ namespace N1 { // CHECK-X86-64: %[[old_and:.*]] = and i8 %[[old]], -2 // CHECK-X86-64: %[[new:.*]] = or i8 %[[old_and]], %[[x_and]] // CHECK-X86-64: store i8 %[[new]], i8* %[[ptr]] - // CHECK-PPC64: define void @_ZN2N15write + // CHECK-PPC64-LABEL: define void @_ZN2N15write // CHECK-PPC64: %[[ptr:.*]] = getelementptr inbounds %{{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-PPC64: %[[x_trunc:.*]] = trunc i32 %{{.*}} to i8 // CHECK-PPC64: %[[old:.*]] = load i8* %[[ptr]] @@ -210,12 +210,12 @@ namespace N2 { void *p; }; unsigned read(S* s) { - // CHECK-X86-64: define i32 @_ZN2N24read + // CHECK-X86-64-LABEL: define i32 @_ZN2N24read // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-X86-64: %[[val:.*]] = load i32* %[[ptr]] // CHECK-X86-64: %[[and:.*]] = and i32 %[[val]], 16777215 // CHECK-X86-64: ret i32 %[[and]] - // CHECK-PPC64: define zeroext i32 @_ZN2N24read + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N24read // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-PPC64: %[[val:.*]] = load i32* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i32 %[[val]], 8 @@ -223,14 +223,14 @@ namespace N2 { return s->b; } void write(S* s, unsigned x) { - // CHECK-X86-64: define void @_ZN2N25write + // CHECK-X86-64-LABEL: define void @_ZN2N25write // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-X86-64: %[[old:.*]] = load i32* %[[ptr]] // CHECK-X86-64: %[[x_and:.*]] = and i32 %{{.*}}, 16777215 // CHECK-X86-64: %[[old_and:.*]] = and i32 %[[old]], -16777216 // CHECK-X86-64: %[[new:.*]] = or i32 %[[old_and]], %[[x_and]] // CHECK-X86-64: store i32 %[[new]], i32* %[[ptr]] - // CHECK-PPC64: define void @_ZN2N25write + // CHECK-PPC64-LABEL: define void @_ZN2N25write // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-PPC64: %[[old:.*]] = load i32* %[[ptr]] // CHECK-PPC64: %[[x_and:.*]] = and i32 %{{.*}}, 16777215 @@ -249,12 +249,12 @@ namespace N3 { unsigned b : 24; }; unsigned read(S* s) { - // CHECK-X86-64: define i32 @_ZN2N34read + // CHECK-X86-64-LABEL: define i32 @_ZN2N34read // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-X86-64: %[[val:.*]] = load i32* %[[ptr]] // CHECK-X86-64: %[[and:.*]] = and i32 %[[val]], 16777215 // CHECK-X86-64: ret i32 %[[and]] - // CHECK-PPC64: define zeroext i32 @_ZN2N34read + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N34read // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-PPC64: %[[val:.*]] = load i32* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i32 %[[val]], 8 @@ -262,14 +262,14 @@ namespace N3 { return s->b; } void write(S* s, unsigned x) { - // CHECK-X86-64: define void @_ZN2N35write + // CHECK-X86-64-LABEL: define void @_ZN2N35write // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-X86-64: %[[old:.*]] = load i32* %[[ptr]] // CHECK-X86-64: %[[x_and:.*]] = and i32 %{{.*}}, 16777215 // CHECK-X86-64: %[[old_and:.*]] = and i32 %[[old]], -16777216 // CHECK-X86-64: %[[new:.*]] = or i32 %[[old_and]], %[[x_and]] // CHECK-X86-64: store i32 %[[new]], i32* %[[ptr]] - // CHECK-PPC64: define void @_ZN2N35write + // CHECK-PPC64-LABEL: define void @_ZN2N35write // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-PPC64: %[[old:.*]] = load i32* %[[ptr]] // CHECK-PPC64: %[[x_and:.*]] = and i32 %{{.*}}, 16777215 @@ -300,13 +300,13 @@ namespace N4 { // FIXME: We should widen this load as long as the function isn't being // instrumented by thread-sanitizer. // - // CHECK-X86-64: define i32 @_ZN2N44read + // CHECK-X86-64-LABEL: define i32 @_ZN2N44read // CHECK-X86-64: %[[gep:.*]] = getelementptr inbounds {{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-X86-64: %[[ptr:.*]] = bitcast [3 x i8]* %[[gep]] to i24* // CHECK-X86-64: %[[val:.*]] = load i24* %[[ptr]] // CHECK-X86-64: %[[ext:.*]] = zext i24 %[[val]] to i32 // CHECK-X86-64: ret i32 %[[ext]] - // CHECK-PPC64: define zeroext i32 @_ZN2N44read + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N44read // CHECK-PPC64: %[[gep:.*]] = getelementptr inbounds {{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-PPC64: %[[ptr:.*]] = bitcast [3 x i8]* %[[gep]] to i24* // CHECK-PPC64: %[[val:.*]] = load i24* %[[ptr]] @@ -315,12 +315,12 @@ namespace N4 { return s->b; } void write(Base* s, unsigned x) { - // CHECK-X86-64: define void @_ZN2N45write + // CHECK-X86-64-LABEL: define void @_ZN2N45write // CHECK-X86-64: %[[gep:.*]] = getelementptr inbounds {{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-X86-64: %[[ptr:.*]] = bitcast [3 x i8]* %[[gep]] to i24* // CHECK-X86-64: %[[new:.*]] = trunc i32 %{{.*}} to i24 // CHECK-X86-64: store i24 %[[new]], i24* %[[ptr]] - // CHECK-PPC64: define void @_ZN2N45write + // CHECK-PPC64-LABEL: define void @_ZN2N45write // CHECK-PPC64: %[[gep:.*]] = getelementptr inbounds {{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-PPC64: %[[ptr:.*]] = bitcast [3 x i8]* %[[gep]] to i24* // CHECK-PPC64: %[[new:.*]] = trunc i32 %{{.*}} to i24 @@ -342,12 +342,12 @@ namespace N5 { struct Y { unsigned b : 24; } y; }; unsigned read(U* u) { - // CHECK-X86-64: define i32 @_ZN2N54read + // CHECK-X86-64-LABEL: define i32 @_ZN2N54read // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-X86-64: %[[val:.*]] = load i32* %[[ptr]] // CHECK-X86-64: %[[and:.*]] = and i32 %[[val]], 16777215 // CHECK-X86-64: ret i32 %[[and]] - // CHECK-PPC64: define zeroext i32 @_ZN2N54read + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N54read // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-PPC64: %[[val:.*]] = load i32* %[[ptr]] // CHECK-PPC64: %[[shr:.*]] = lshr i32 %[[val]], 8 @@ -355,14 +355,14 @@ namespace N5 { return u->y.b; } void write(U* u, unsigned x) { - // CHECK-X86-64: define void @_ZN2N55write + // CHECK-X86-64-LABEL: define void @_ZN2N55write // CHECK-X86-64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-X86-64: %[[old:.*]] = load i32* %[[ptr]] // CHECK-X86-64: %[[x_and:.*]] = and i32 %{{.*}}, 16777215 // CHECK-X86-64: %[[old_and:.*]] = and i32 %[[old]], -16777216 // CHECK-X86-64: %[[new:.*]] = or i32 %[[old_and]], %[[x_and]] // CHECK-X86-64: store i32 %[[new]], i32* %[[ptr]] - // CHECK-PPC64: define void @_ZN2N55write + // CHECK-PPC64-LABEL: define void @_ZN2N55write // CHECK-PPC64: %[[ptr:.*]] = bitcast %{{.*}}* %{{.*}} to i32* // CHECK-PPC64: %[[old:.*]] = load i32* %[[ptr]] // CHECK-PPC64: %[[x_and:.*]] = and i32 %{{.*}}, 16777215 @@ -387,7 +387,7 @@ namespace N6 { unsigned char b2 : 8; }; unsigned read(S* s) { - // CHECK-X86-64: define i32 @_ZN2N64read + // CHECK-X86-64-LABEL: define i32 @_ZN2N64read // CHECK-X86-64: %[[ptr1:.*]] = bitcast {{.*}}* %{{.*}} to i24* // CHECK-X86-64: %[[val1:.*]] = load i24* %[[ptr1]] // CHECK-X86-64: %[[ext1:.*]] = zext i24 %[[val1]] to i32 @@ -396,7 +396,7 @@ namespace N6 { // CHECK-X86-64: %[[ext2:.*]] = zext i8 %[[val2]] to i32 // CHECK-X86-64: %[[add:.*]] = add nsw i32 %[[ext1]], %[[ext2]] // CHECK-X86-64: ret i32 %[[add]] - // CHECK-PPC64: define zeroext i32 @_ZN2N64read + // CHECK-PPC64-LABEL: define zeroext i32 @_ZN2N64read // CHECK-PPC64: %[[ptr1:.*]] = bitcast {{.*}}* %{{.*}} to i24* // CHECK-PPC64: %[[val1:.*]] = load i24* %[[ptr1]] // CHECK-PPC64: %[[ext1:.*]] = zext i24 %[[val1]] to i32 @@ -408,14 +408,14 @@ namespace N6 { return s->b1 + s->b2; } void write(S* s, unsigned x) { - // CHECK-X86-64: define void @_ZN2N65write + // CHECK-X86-64-LABEL: define void @_ZN2N65write // CHECK-X86-64: %[[ptr1:.*]] = bitcast {{.*}}* %{{.*}} to i24* // CHECK-X86-64: %[[new1:.*]] = trunc i32 %{{.*}} to i24 // CHECK-X86-64: store i24 %[[new1]], i24* %[[ptr1]] // CHECK-X86-64: %[[new2:.*]] = trunc i32 %{{.*}} to i8 // CHECK-X86-64: %[[ptr2:.*]] = getelementptr inbounds {{.*}}* %{{.*}}, i32 0, i32 1 // CHECK-X86-64: store i8 %[[new2]], i8* %[[ptr2]] - // CHECK-PPC64: define void @_ZN2N65write + // CHECK-PPC64-LABEL: define void @_ZN2N65write // CHECK-PPC64: %[[ptr1:.*]] = bitcast {{.*}}* %{{.*}} to i24* // CHECK-PPC64: %[[new1:.*]] = trunc i32 %{{.*}} to i24 // CHECK-PPC64: store i24 %[[new1]], i24* %[[ptr1]] diff --git a/test/CodeGenCXX/block-byref-cxx-objc.cpp b/test/CodeGenCXX/block-byref-cxx-objc.cpp index 30f1f07..616fd67 100644 --- a/test/CodeGenCXX/block-byref-cxx-objc.cpp +++ b/test/CodeGenCXX/block-byref-cxx-objc.cpp @@ -15,13 +15,13 @@ int main() return 0; } -// CHECK: define internal void @__Block_byref_object_copy_ +// CHECK-LABEL: define internal void @__Block_byref_object_copy_ // CHECK: call {{.*}} @_ZN1AC1ERKS_ -// CHECK: define internal void @__Block_byref_object_dispose_ +// CHECK-LABEL: define internal void @__Block_byref_object_dispose_ // CHECK: call {{.*}} @_ZN1AD1Ev -// CHECK: define internal void @__copy_helper_block_ +// CHECK-LABEL: define internal void @__copy_helper_block_ // CHECK: call void @_Block_object_assign -// CHECK: define internal void @__destroy_helper_block_ +// CHECK-LABEL: define internal void @__destroy_helper_block_ // CHECK: call void @_Block_object_dispose // rdar://problem/11135650 diff --git a/test/CodeGenCXX/block-in-ctor-dtor.cpp b/test/CodeGenCXX/block-in-ctor-dtor.cpp index 4ee6b1c..bd37d44 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 @___ZN4ZoneD2Ev_block_invoke -// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_ -// CHECK: define internal void @___ZN1XC1Ev_block_invoke -// CHECK: define internal void @___ZN1XC1Ev_block_invoke_ -// CHECK: define internal void @___ZN1XC2Ev_block_invoke -// CHECK: define internal void @___ZN1XC2Ev_block_invoke_ -// CHECK: define internal void @___ZN1XD2Ev_block_invoke -// CHECK: define internal void @___ZN1XD2Ev_block_invoke_ +// CHECK-LABEL: define internal void @___ZN4ZoneC2Ev_block_invoke +// CHECK-LABEL: define internal void @___ZN4ZoneC2Ev_block_invoke_ +// CHECK-LABEL: define internal void @___ZN4ZoneD2Ev_block_invoke +// CHECK-LABEL: define internal void @___ZN4ZoneD2Ev_block_invoke_ +// CHECK-LABEL: define internal void @___ZN1XC1Ev_block_invoke +// CHECK-LABEL: define internal void @___ZN1XC1Ev_block_invoke_ +// CHECK-LABEL: define internal void @___ZN1XC2Ev_block_invoke +// CHECK-LABEL: define internal void @___ZN1XC2Ev_block_invoke_ +// CHECK-LABEL: define internal void @___ZN1XD2Ev_block_invoke +// CHECK-LABEL: define internal void @___ZN1XD2Ev_block_invoke_ diff --git a/test/CodeGenCXX/blocks-cxx11.cpp b/test/CodeGenCXX/blocks-cxx11.cpp index 3f0380a..9ff5826 100644 --- a/test/CodeGenCXX/blocks-cxx11.cpp +++ b/test/CodeGenCXX/blocks-cxx11.cpp @@ -46,7 +46,7 @@ namespace test_complex_int { void test() { constexpr _Complex int x = 500; takeABlock(^{ takeItByValue(x); }); - // CHECK: store i32 500, + // CHECK: store { i32, i32 } { i32 500, i32 0 }, // CHECK: store i32 500, // CHECK-NEXT: store i32 0, @@ -100,7 +100,7 @@ namespace test_block_in_lambda { }; lambda(); // make sure we emit the invocation function } - // CHECK: define internal void @"_ZZN20test_block_in_lambda4testENS_1AEENK3$_0clEv"( + // CHECK-LABEL: define internal void @"_ZZN20test_block_in_lambda4testENS_1AEENK3$_0clEv"( // CHECK: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], align 8 // CHECK: [[THIS:%.*]] = load [[LAMBDA_T:%.*]]** // CHECK: [[TO_DESTROY:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 diff --git a/test/CodeGenCXX/blocks.cpp b/test/CodeGenCXX/blocks.cpp index 81eef0e..8a6fdac 100644 --- a/test/CodeGenCXX/blocks.cpp +++ b/test/CodeGenCXX/blocks.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s namespace test0 { - // CHECK: define void @_ZN5test04testEi( + // CHECK-LABEL: define void @_ZN5test04testEi( // CHECK: define internal void @___ZN5test04testEi_block_invoke{{.*}}( // CHECK: define internal void @___ZN5test04testEi_block_invoke_2{{.*}}( void test(int x) { @@ -13,7 +13,7 @@ extern void (^out)(); namespace test1 { // Capturing const objects doesn't require a local block. - // CHECK: define void @_ZN5test15test1Ev() + // CHECK-LABEL: define void @_ZN5test15test1Ev() // CHECK: store void ()* bitcast ({{.*}} @__block_literal_global{{.*}} to void ()*), void ()** @out void test1() { const int NumHorsemen = 4; @@ -21,7 +21,7 @@ namespace test1 { } // That applies to structs too... - // CHECK: define void @_ZN5test15test2Ev() + // CHECK-LABEL: define void @_ZN5test15test2Ev() // CHECK: store void ()* bitcast ({{.*}} @__block_literal_global{{.*}} to void ()*), void ()** @out struct loc { double x, y; }; void test2() { @@ -30,7 +30,7 @@ namespace test1 { } // ...unless they have mutable fields... - // CHECK: define void @_ZN5test15test3Ev() + // CHECK-LABEL: define void @_ZN5test15test3Ev() // CHECK: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()* // CHECK: store void ()* [[T0]], void ()** @out @@ -41,7 +41,7 @@ namespace test1 { } // ...or non-trivial destructors... - // CHECK: define void @_ZN5test15test4Ev() + // CHECK-LABEL: define void @_ZN5test15test4Ev() // CHECK: [[OBJ:%.*]] = alloca // CHECK: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()* @@ -69,22 +69,22 @@ namespace test2 { ~B(); }; - // CHECK: define void @_ZN5test24testEv() + // CHECK-LABEL: define void @_ZN5test24testEv() void test() { __block A a; __block B b; } - // CHECK: define internal void @__Block_byref_object_copy + // CHECK-LABEL: define internal void @__Block_byref_object_copy // CHECK: call void @_ZN5test21AC1ERKS0_( - // CHECK: define internal void @__Block_byref_object_dispose + // CHECK-LABEL: define internal void @__Block_byref_object_dispose // CHECK: call void @_ZN5test21AD1Ev( - // CHECK: define internal void @__Block_byref_object_copy + // CHECK-LABEL: define internal void @__Block_byref_object_copy // CHECK: call void @_ZN5test21BC1ERKS0_( - // CHECK: define internal void @__Block_byref_object_dispose + // CHECK-LABEL: define internal void @__Block_byref_object_dispose // CHECK: call void @_ZN5test21BD1Ev( } @@ -118,8 +118,8 @@ namespace test4 { extern void consume(void(^)()); consume(^{ return foo(A()); }); } - // CHECK: define void @_ZN5test44testEv() - // CHECK: define internal void @___ZN5test44testEv_block_invoke + // CHECK-LABEL: define void @_ZN5test44testEv() + // CHECK-LABEL: define internal void @___ZN5test44testEv_block_invoke // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1 // CHECK-NEXT: store i8* [[BLOCKDESC:%.*]], i8** {{.*}}, align 8 // CHECK-NEXT: load i8* @@ -147,7 +147,7 @@ namespace test5 { doWithBlock(b); } - // CHECK: define void @_ZN5test54testEb( + // CHECK-LABEL: define void @_ZN5test54testEb( // CHECK: [[COND:%.*]] = alloca i8 // CHECK-NEXT: [[X:%.*]] = alloca [[A:%.*]], align 4 // CHECK-NEXT: [[B:%.*]] = alloca void ()*, align 8 @@ -197,7 +197,7 @@ namespace test6 { bar(); } - // CHECK: define void @_ZN5test64testEv() + // CHECK-LABEL: define void @_ZN5test64testEv() // CHECK: [[TEMP:%.*]] = alloca [[A:%.*]], align 1 // CHECK-NEXT: call void @_ZN5test61AC1Ev([[A]]* [[TEMP]]) // CHECK-NEXT: call void @_ZN5test63fooERKNS_1AEU13block_pointerFvvE( diff --git a/test/CodeGenCXX/bool-bitfield.cpp b/test/CodeGenCXX/bool-bitfield.cpp index 06bdf2b..a5a344f 100644 --- a/test/CodeGenCXX/bool-bitfield.cpp +++ b/test/CodeGenCXX/bool-bitfield.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -verify -emit-llvm -o - %s \ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s \ // RUN: | FileCheck %s // PR14638; make sure this doesn't crash. @@ -9,6 +9,6 @@ void func1(bool b, A& a1) { if ((a1.m_sorted = b)) {} } -// CHECK: define void @_Z5func1bR1A +// CHECK-LABEL: define void @_Z5func1bR1A // CHECK: br i1 // CHECK: ret void diff --git a/test/CodeGenCXX/builtins.cpp b/test/CodeGenCXX/builtins.cpp index c9b0bff..98e2d1a 100644 --- a/test/CodeGenCXX/builtins.cpp +++ b/test/CodeGenCXX/builtins.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple=x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s // PR8839 extern "C" char memmove(); @@ -7,3 +7,22 @@ int main() { // CHECK: call {{signext i8|i8}} @memmove() return memmove(); } + +struct S; +// CHECK: define {{.*}} @_Z9addressofbR1SS0_( +S *addressof(bool b, S &s, S &t) { + // CHECK: %[[LVALUE:.*]] = phi + // CHECK: ret {{.*}}* %[[LVALUE]] + return __builtin_addressof(b ? s : t); +} + +extern "C" int __builtin_abs(int); // #1 +long __builtin_abs(long); // #2 +extern "C" int __builtin_abs(int); // #3 + +int x = __builtin_abs(-2); +// CHECK: store i32 2, i32* @x, align 4 + +long y = __builtin_abs(-2l); +// CHECK: [[Y:%.+]] = call i64 @_Z13__builtin_absl(i64 -2) +// CHECK: store i64 [[Y]], i64* @y, align 8 diff --git a/test/CodeGenCXX/c-linkage.cpp b/test/CodeGenCXX/c-linkage.cpp index f6e64d9..1607623 100644 --- a/test/CodeGenCXX/c-linkage.cpp +++ b/test/CodeGenCXX/c-linkage.cpp @@ -10,15 +10,15 @@ extern "C" { } } -// CHECK: define void @_ZN1N1X1fEv +// CHECK-LABEL: define void @_ZN1N1X1fEv extern "C" { static void test2_f() { } - // CHECK: define internal void @_Z7test2_fv + // CHECK-LABEL: define internal void @_Z7test2_fv static void test2_f(int x) { } - // CHECK: define internal void @_Z7test2_fi + // CHECK-LABEL: define internal void @_Z7test2_fi void test2_use() { test2_f(); test2_f(42); diff --git a/test/CodeGenCXX/c99-variable-length-array.cpp b/test/CodeGenCXX/c99-variable-length-array.cpp index d486f9b..2cd8e11 100644 --- a/test/CodeGenCXX/c99-variable-length-array.cpp +++ b/test/CodeGenCXX/c99-variable-length-array.cpp @@ -9,7 +9,7 @@ struct Y { ~Y(); }; -// CHECK: define void @_Z1fiPPKc( +// CHECK-LABEL: define void @_Z1fiPPKc( void f(int argc, const char* argv[]) { // CHECK: call void @_ZN1XC1Ev X x; diff --git a/test/CodeGenCXX/call-arg-zero-temp.cpp b/test/CodeGenCXX/call-arg-zero-temp.cpp index 101e81f..14238f2 100644 --- a/test/CodeGenCXX/call-arg-zero-temp.cpp +++ b/test/CodeGenCXX/call-arg-zero-temp.cpp @@ -1,8 +1,8 @@ // REQUIRES: x86-registered-target,x86-64-registered-target // RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s // RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/captured-statements.cpp b/test/CodeGenCXX/captured-statements.cpp new file mode 100644 index 0000000..2843c2b --- /dev/null +++ b/test/CodeGenCXX/captured-statements.cpp @@ -0,0 +1,189 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o %t +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-4 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-5 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-6 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-7 + +struct Foo { + int x; + float y; + ~Foo() {} +}; + +struct TestClass { + int x; + + TestClass() : x(0) {}; + void MemberFunc() { + Foo f; + #pragma clang __debug captured + { + f.y = x; + } + } +}; + +void test1() { + TestClass c; + c.MemberFunc(); + // CHECK-1: %[[Capture:struct\.anon[\.0-9]*]] = type { %struct.Foo*, %struct.TestClass* } + + // CHECK-1: define {{.*}} void @_ZN9TestClass10MemberFuncEv + // CHECK-1: alloca %struct.anon + // CHECK-1: getelementptr inbounds %[[Capture]]* %{{[^,]*}}, i32 0, i32 0 + // CHECK-1: store %struct.Foo* %f, %struct.Foo** + // CHECK-1: getelementptr inbounds %[[Capture]]* %{{[^,]*}}, i32 0, i32 1 + // CHECK-1: call void @[[HelperName:[A-Za-z0-9_]+]](%[[Capture]]* + // CHECK-1: call {{.*}}FooD1Ev + // CHECK-1: ret +} + +// CHECK-1: define internal void @[[HelperName]] +// CHECK-1: getelementptr inbounds %[[Capture]]* {{[^,]*}}, i32 0, i32 1 +// CHECK-1: getelementptr inbounds %struct.TestClass* {{[^,]*}}, i32 0, i32 0 +// CHECK-1: getelementptr inbounds %[[Capture]]* {{[^,]*}}, i32 0, i32 0 + +void test2(int x) { + int y = [&]() { + #pragma clang __debug captured + { + x++; + } + return x; + }(); + + // CHECK-2-LABEL: define void @_Z5test2i + // CHECK-2: call {{.*}} @[[Lambda:["$\w]+]] + // + // CHECK-2: define internal {{.*}} @[[Lambda]] + // CHECK-2: call void @[[HelperName:["$_A-Za-z0-9]+]](%[[Capture:.*]]* + // + // CHECK-2: define internal void @[[HelperName]] + // CHECK-2: getelementptr inbounds %[[Capture]]* + // CHECK-2: load i32** + // CHECK-2: load i32* +} + +void test3(int x) { + #pragma clang __debug captured + { + x = [=]() { return x + 1; } (); + } + + // CHECK-3: %[[Capture:struct\.anon[\.0-9]*]] = type { i32* } + + // CHECK-3-LABEL: define void @_Z5test3i + // CHECK-3: store i32* + // CHECK-3: call void @{{.*}}__captured_stmt + // CHECK-3: ret void +} + +void test4() { + #pragma clang __debug captured + { + Foo f; + f.x = 5; + } + // CHECK-4-LABEL: define void @_Z5test4v + // CHECK-4: call void @[[HelperName:["$_A-Za-z0-9]+]](%[[Capture:.*]]* + // CHECK-4: ret void + // + // CHECK-4: define internal void @[[HelperName]] + // CHECK-4: store i32 5, i32* + // CHECK-4: call {{.*}}FooD1Ev +} + +template +void touch(const T &) {} + +template +void template_capture_var() { + T x; + #pragma clang __debug captured + { + touch(x); + } +} + +template +class Val { + T v; +public: + void set() { + #pragma clang __debug captured + { + touch(v); + } + } + + template + void foo(U u) { + #pragma clang __debug captured + { + touch(u); + } + } +}; + +void test_capture_var() { + // CHECK-5: define {{.*}} void @_Z20template_capture_varIiLj201EEvv + // CHECK-5-NOT: } + // CHECK-5: store i32* + // CHECK-5: call void @__captured_stmt + // CHECK-5-NEXT: ret void + template_capture_var(); + + // CHECK-5: define {{.*}} void @_ZN3ValIfLi202EE3setEv + // CHECK-5-NOT: } + // CHECK-5: store %class.Val* + // CHECK-5: call void @__captured_stmt + // CHECK-5-NEXT: ret void + Val Obj; + Obj.set(); + + // CHECK-5: define {{.*}} void @_ZN3ValIfLi202EE3fooIdLi203EEEvT_ + // CHECK-5-NOT: } + // CHECK-5: store %class.Val* + // CHECK-5: store double + // CHECK-5: call void @__captured_stmt + // CHECK-5-NEXT: ret void + Obj.foo(1.0); +} + +template +void template_capture_lambda() { + T x, y; + [=, &y]() { + #pragma clang __debug captured + { + y += x; + } + }(); +} + +void test_capture_lambda() { + // CHECK-6: define {{.*}} void @_ZZ23template_capture_lambdaIiEvvENKUlvE_clEv + // CHECK-6-NOT: } + // CHECK-6: store i32* + // CHECK-6: store i32* + // CHECK-6: call void @__captured_stmt + // CHECK-6-NEXT: ret void + template_capture_lambda(); +} + +inline int test_captured_linkage() { + // CHECK-7: @_ZZ21test_captured_linkagevE1i = linkonce_odr global i32 0 + int j; + #pragma clang __debug captured + { + static int i = 0; + j = ++i; + } + return j; +} +void call_test_captured_linkage() { + test_captured_linkage(); +} diff --git a/test/CodeGenCXX/cast-conversion.cpp b/test/CodeGenCXX/cast-conversion.cpp index d023b9a..5565f65 100644 --- a/test/CodeGenCXX/cast-conversion.cpp +++ b/test/CodeGenCXX/cast-conversion.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s struct A { A(int); diff --git a/test/CodeGenCXX/catch-undef-behavior.cpp b/test/CodeGenCXX/catch-undef-behavior.cpp index d6d0edfa..338da57 100644 --- a/test/CodeGenCXX/catch-undef-behavior.cpp +++ b/test/CodeGenCXX/catch-undef-behavior.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsanitize=signed-integer-overflow,integer-divide-by-zero,float-divide-by-zero,shift,unreachable,return,vla-bound,alignment,null,vptr,object-size,float-cast-overflow,bool,enum,bounds -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fsanitize=signed-integer-overflow,integer-divide-by-zero,float-divide-by-zero,shift,unreachable,return,vla-bound,alignment,null,vptr,object-size,float-cast-overflow,bool,enum,array-bounds,function -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s struct S { double d; @@ -186,7 +186,7 @@ void bad_downcast_pointer(S *p) { // CHECK: %[[NONNULL:.*]] = icmp ne {{.*}}, null // CHECK: br i1 %[[NONNULL]], - // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64( + // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8( // CHECK: %[[E1:.*]] = icmp uge i64 %[[SIZE]], 24 // CHECK: %[[MISALIGN:.*]] = and i64 %{{.*}}, 7 // CHECK: %[[E2:.*]] = icmp eq i64 %[[MISALIGN]], 0 @@ -207,7 +207,7 @@ void bad_downcast_pointer(S *p) { void bad_downcast_reference(S &p) { // CHECK: %[[E1:.*]] = icmp ne {{.*}}, null // CHECK-NOT: br i1 - // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64( + // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8( // CHECK: %[[E2:.*]] = icmp uge i64 %[[SIZE]], 24 // CHECK: %[[E12:.*]] = and i1 %[[E1]], %[[E2]] // CHECK: %[[MISALIGN:.*]] = and i64 %{{.*}}, 7 @@ -321,4 +321,156 @@ char string_index(int n) { return "Hello"[n]; } +class A // align=4 +{ + int a1, a2, a3; +}; + +class B // align=8 +{ + long b1, b2; +}; + +class C : public A, public B // align=16 +{ + alignas(16) int c1; +}; + +// Make sure we check the alignment of the pointer after subtracting any +// offset. The pointer before subtraction doesn't need to be aligned for +// the destination type. + +// CHECK-LABEL: define void @_Z16downcast_pointerP1B(%class.B* %b) +void downcast_pointer(B *b) { + (void) static_cast(b); + // Alignment check from EmitTypeCheck(TCK_DowncastPointer, ...) + // CHECK: [[SUB:%[.a-z0-9]*]] = getelementptr i8* {{.*}}, i64 -16 + // CHECK-NEXT: [[C:%[0-9]*]] = bitcast i8* [[SUB]] to %class.C* + // null check goes here + // CHECK: [[FROM_PHI:%[0-9]*]] = phi %class.C* [ [[C]], {{.*}} ], {{.*}} + // Objectsize check goes here + // CHECK: [[C_INT:%[0-9]*]] = ptrtoint %class.C* [[FROM_PHI]] to i64 + // CHECK-NEXT: [[MASKED:%[0-9]*]] = and i64 [[C_INT]], 15 + // CHECK-NEXT: [[TEST:%[0-9]*]] = icmp eq i64 [[MASKED]], 0 + // AND the alignment test with the objectsize test. + // CHECK-NEXT: [[AND:%[0-9]*]] = and i1 {{.*}}, [[TEST]] + // CHECK-NEXT: br i1 [[AND]] +} + +// CHECK-LABEL: define void @_Z18downcast_referenceR1B(%class.B* %b) +void downcast_reference(B &b) { + (void) static_cast(b); + // Alignment check from EmitTypeCheck(TCK_DowncastReference, ...) + // CHECK: [[SUB:%[.a-z0-9]*]] = getelementptr i8* {{.*}}, i64 -16 + // CHECK-NEXT: [[C:%[0-9]*]] = bitcast i8* [[SUB]] to %class.C* + // Objectsize check goes here + // CHECK: [[C_INT:%[0-9]*]] = ptrtoint %class.C* [[C]] to i64 + // CHECK-NEXT: [[MASKED:%[0-9]*]] = and i64 [[C_INT]], 15 + // CHECK-NEXT: [[TEST:%[0-9]*]] = icmp eq i64 [[MASKED]], 0 + // AND the alignment test with the objectsize test. + // CHECK-NEXT: [[AND:%[0-9]*]] = and i1 {{.*}}, [[TEST]] + // CHECK-NEXT: br i1 [[AND]] +} + +// CHECK-LABEL: @_Z22indirect_function_callPFviE({{.*}} prefix <{ i32, i8* }> <{ i32 1413876459, i8* bitcast ({ i8*, i8* }* @_ZTIFvPFviEE to i8*) }> +void indirect_function_call(void (*p)(int)) { + // CHECK: [[PTR:%[0-9]*]] = bitcast void (i32)* {{.*}} to <{ i32, i8* }>* + + // Signature check + // CHECK-NEXT: [[SIGPTR:%[0-9]*]] = getelementptr <{ i32, i8* }>* [[PTR]], i32 0, i32 0 + // CHECK-NEXT: [[SIG:%[0-9]*]] = load i32* [[SIGPTR]] + // CHECK-NEXT: [[SIGCMP:%[0-9]*]] = icmp eq i32 [[SIG]], 1413876459 + // CHECK-NEXT: br i1 [[SIGCMP]] + + // RTTI pointer check + // CHECK: [[RTTIPTR:%[0-9]*]] = getelementptr <{ i32, i8* }>* [[PTR]], i32 0, i32 1 + // CHECK-NEXT: [[RTTI:%[0-9]*]] = load i8** [[RTTIPTR]] + // CHECK-NEXT: [[RTTICMP:%[0-9]*]] = icmp eq i8* [[RTTI]], bitcast ({ i8*, i8* }* @_ZTIFviE to i8*) + // CHECK-NEXT: br i1 [[RTTICMP]] + p(42); +} + +namespace CopyValueRepresentation { + // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S3aSERKS0_ + // CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_value + // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S4aSEOS0_ + // CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_value + // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S5C2ERKS0_ + // CHECK-NOT: call {{.*}} __ubsan_handle_load_invalid_value + // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S2C2ERKS0_ + // CHECK: __ubsan_handle_load_invalid_value + // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S1C2ERKS0_ + // CHECK-NOT: call {{.*}} __ubsan_handle_load_invalid_value + + struct CustomCopy { CustomCopy(); CustomCopy(const CustomCopy&); }; + struct S1 { + CustomCopy CC; + bool b; + }; + void callee1(S1); + void test1() { + S1 s11; + callee1(s11); + S1 s12; + s12 = s11; + } + + static bool some_global_bool; + struct ExprCopy { + ExprCopy(); + ExprCopy(const ExprCopy&, bool b = some_global_bool); + }; + struct S2 { + ExprCopy EC; + bool b; + }; + void callee2(S2); + void test2(void) { + S2 s21; + callee2(s21); + S2 s22; + s22 = s21; + } + + struct CustomAssign { CustomAssign &operator=(const CustomAssign&); }; + struct S3 { + CustomAssign CA; + bool b; + }; + void test3() { + S3 x, y; + x = y; + } + + struct CustomMove { + CustomMove(); + CustomMove(const CustomMove&&); + CustomMove &operator=(const CustomMove&&); + }; + struct S4 { + CustomMove CM; + bool b; + }; + void test4() { + S4 x, y; + x = static_cast(y); + } + + struct EnumCustomCopy { + EnumCustomCopy(); + EnumCustomCopy(const EnumCustomCopy&); + }; + struct S5 { + EnumCustomCopy ECC; + bool b; + }; + void callee5(S5); + void test5() { + S5 s51; + callee5(s51); + S5 s52; + s52 = s51; + } +} + // CHECK: attributes [[NR_NUW]] = { noreturn nounwind } diff --git a/test/CodeGenCXX/catch-undef-behavior2.cpp b/test/CodeGenCXX/catch-undef-behavior2.cpp new file mode 100644 index 0000000..b8b31ca --- /dev/null +++ b/test/CodeGenCXX/catch-undef-behavior2.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -std=c++11 -fsanitize=signed-integer-overflow,integer-divide-by-zero,float-divide-by-zero,shift,unreachable,return,vla-bound,alignment,null,vptr,object-size,float-cast-overflow,bool,enum,array-bounds,function -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s + +bool GetOptionalBool(bool *value); +bool GetBool(bool default_value) { + // CHECK-LABEL: @_Z7GetBoolb + // CHECK-NOT: select + bool value; + return GetOptionalBool(&value) ? value : default_value; +} diff --git a/test/CodeGenCXX/compound-literals.cpp b/test/CodeGenCXX/compound-literals.cpp index 5df0ea5..f1d8802 100644 --- a/test/CodeGenCXX/compound-literals.cpp +++ b/test/CodeGenCXX/compound-literals.cpp @@ -12,7 +12,7 @@ struct Y { X x; }; -// CHECK: define i32 @_Z1fv() +// CHECK-LABEL: define i32 @_Z1fv() int f() { // CHECK: [[LVALUE:%[a-z0-9.]+]] = alloca // CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}}* [[LVALUE]], i32 0, i32 0 @@ -26,7 +26,7 @@ int f() { return ((Y){17, "seventeen"}).i; } -// CHECK: define i32 @_Z1gv() +// CHECK-LABEL: define i32 @_Z1gv() int g() { // CHECK: store [2 x i32]* %{{[a-z0-9.]+}}, [2 x i32]** [[V:%[a-z0-9.]+]] const int (&v)[2] = (int [2]) {1,2}; diff --git a/test/CodeGenCXX/condition.cpp b/test/CodeGenCXX/condition.cpp index cc2eaf5..452f1c3 100644 --- a/test/CodeGenCXX/condition.cpp +++ b/test/CodeGenCXX/condition.cpp @@ -26,7 +26,7 @@ struct Y { X getX(); -// CHECK: define void @_Z11if_destructi( +// CHECK-LABEL: define void @_Z11if_destructi( void if_destruct(int z) { // Verify that the condition variable is destroyed at the end of the // "if" statement. @@ -95,7 +95,7 @@ void switch_destruct(int z) { int foo(); -// CHECK: define void @_Z14while_destructi +// CHECK-LABEL: define void @_Z14while_destructi void while_destruct(int z) { // CHECK: [[Z:%.*]] = alloca i32 // CHECK: [[CLEANUPDEST:%.*]] = alloca i32 @@ -135,7 +135,7 @@ void while_destruct(int z) { // CHECK: ret } -// CHECK: define void @_Z12for_destructi( +// CHECK-LABEL: define void @_Z12for_destructi( void for_destruct(int z) { // CHECK: [[Z:%.*]] = alloca i32 // CHECK: [[CLEANUPDEST:%.*]] = alloca i32 @@ -224,7 +224,7 @@ void for_destruct(int z) { } void do_destruct(int z) { - // CHECK: define void @_Z11do_destruct + // CHECK-LABEL: define void @_Z11do_destruct do { // CHECK: store i32 77 z = 77; diff --git a/test/CodeGenCXX/conditional-gnu-ext.cpp b/test/CodeGenCXX/conditional-gnu-ext.cpp index 104a91d..44ebf98 100644 --- a/test/CodeGenCXX/conditional-gnu-ext.cpp +++ b/test/CodeGenCXX/conditional-gnu-ext.cpp @@ -77,7 +77,7 @@ namespace test3 { }; B test0(B &x) { - // CHECK: define void @_ZN5test35test0ERNS_1BE( + // CHECK-LABEL: define void @_ZN5test35test0ERNS_1BE( // CHECK: [[X:%.*]] = alloca [[B:%.*]]*, // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]] // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]] @@ -92,7 +92,7 @@ namespace test3 { } B test1() { - // CHECK: define void @_ZN5test35test1Ev( + // CHECK-LABEL: define void @_ZN5test35test1Ev( // CHECK: [[TEMP:%.*]] = alloca [[B]], // CHECK-NEXT: call void @_ZN5test312test1_helperEv([[B]]* sret [[TEMP]]) // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[TEMP]]) @@ -109,7 +109,7 @@ namespace test3 { A test2(B &x) { - // CHECK: define void @_ZN5test35test2ERNS_1BE( + // CHECK-LABEL: define void @_ZN5test35test2ERNS_1BE( // CHECK: [[X:%.*]] = alloca [[B]]*, // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]] // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]] @@ -124,7 +124,7 @@ namespace test3 { } A test3() { - // CHECK: define void @_ZN5test35test3Ev( + // CHECK-LABEL: define void @_ZN5test35test3Ev( // CHECK: [[TEMP:%.*]] = alloca [[B]], // CHECK-NEXT: call void @_ZN5test312test3_helperEv([[B]]* sret [[TEMP]]) // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[TEMP]]) diff --git a/test/CodeGenCXX/conditional-temporaries.cpp b/test/CodeGenCXX/conditional-temporaries.cpp index d538287..a3cc2fe 100644 --- a/test/CodeGenCXX/conditional-temporaries.cpp +++ b/test/CodeGenCXX/conditional-temporaries.cpp @@ -36,19 +36,19 @@ Checker c; } -// CHECK: define i32 @_Z12getCtorCallsv() +// CHECK-LABEL: define i32 @_Z12getCtorCallsv() int getCtorCalls() { // CHECK: ret i32 5 return ctorcalls; } -// CHECK: define i32 @_Z12getDtorCallsv() +// CHECK-LABEL: define i32 @_Z12getDtorCallsv() int getDtorCalls() { // CHECK: ret i32 5 return dtorcalls; } -// CHECK: define zeroext i1 @_Z7successv() +// CHECK-LABEL: define zeroext i1 @_Z7successv() bool success() { // CHECK: ret i1 true return ctorcalls == dtorcalls; diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp index 833adba..d21e911 100644 --- a/test/CodeGenCXX/const-init-cxx11.cpp +++ b/test/CodeGenCXX/const-init-cxx11.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++11 | FileCheck %s +// RUN: not %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++11 | FileCheck %s // FIXME: The padding in all these objects should be zero-initialized. namespace StructUnion { @@ -224,12 +224,50 @@ namespace LiteralReference { constexpr Lit() : n(5) {} int n; }; - // FIXME: This should have static initialization, but we do not implement - // that yet. For now, just check that we don't set the (pointer) value of - // the reference to 5! - // - // CHECK: @_ZN16LiteralReference3litE = global {{.*}} null + + // This creates a non-const temporary and binds a reference to it. + // CHECK: @[[TEMP:.*]] = private global {{.*}} { i32 5 }, align 4 + // CHECK: @_ZN16LiteralReference3litE = constant {{.*}} @[[TEMP]], align 8 const Lit &lit = Lit(); + + // This creates a const temporary as part of the reference initialization. + // CHECK: @[[TEMP:.*]] = private constant {{.*}} { i32 5 }, align 4 + // CHECK: @_ZN16LiteralReference4lit2E = constant {{.*}} @[[TEMP]], align 8 + const Lit &lit2 = {}; + + struct A { int &&r1; const int &&r2; }; + struct B { A &&a1; const A &&a2; }; + B b = { { 0, 1 }, { 2, 3 } }; + // CHECK: @[[TEMP0:.*]] = private global i32 0, align 4 + // CHECK: @[[TEMP1:.*]] = private constant i32 1, align 4 + // CHECK: @[[TEMPA1:.*]] = private global {{.*}} { i32* @[[TEMP0]], i32* @[[TEMP1]] }, align 8 + // CHECK: @[[TEMP2:.*]] = private global i32 2, align 4 + // CHECK: @[[TEMP3:.*]] = private constant i32 3, align 4 + // CHECK: @[[TEMPA2:.*]] = private constant {{.*}} { i32* @[[TEMP2]], i32* @[[TEMP3]] }, align 8 + // CHECK: @_ZN16LiteralReference1bE = global {{.*}} { {{.*}}* @[[TEMPA1]], {{.*}}* @[[TEMPA2]] }, align 8 + + struct Subobj { + int a, b, c; + }; + // CHECK: @[[TEMP:.*]] = private global {{.*}} { i32 1, i32 2, i32 3 }, align 4 + // CHECK: @_ZN16LiteralReference2soE = constant {{.*}} (i8* getelementptr {{.*}} @[[TEMP]]{{.*}}, i64 4) + constexpr int &&so = Subobj{ 1, 2, 3 }.b; + + struct Dummy { int padding; }; + struct Derived : Dummy, Subobj { + constexpr Derived() : Dummy{200}, Subobj{4, 5, 6} {} + }; + using ConstDerived = const Derived; + // CHECK: @[[TEMPCOMMA:.*]] = private constant {{.*}} { i32 200, i32 4, i32 5, i32 6 } + // CHECK: @_ZN16LiteralReference5commaE = constant {{.*}} getelementptr {{.*}} @[[TEMPCOMMA]]{{.*}}, i64 8) + constexpr const int &comma = (1, (2, ConstDerived{}).b); + + // CHECK: @[[TEMPDERIVED:.*]] = private global {{.*}} { i32 200, i32 4, i32 5, i32 6 } + // CHECK: @_ZN16LiteralReference4baseE = constant {{.*}} getelementptr {{.*}} @[[TEMPDERIVED]]{{.*}}, i64 4) + constexpr Subobj &&base = Derived{}; + + // CHECK: @_ZN16LiteralReference7derivedE = constant {{.*}} @[[TEMPDERIVED]] + constexpr Derived &derived = static_cast(base); } namespace NonLiteralConstexpr { @@ -330,6 +368,32 @@ namespace PR13273 { extern const S s {}; } +namespace ArrayTemporary { + struct A { const int (&x)[3]; }; + struct B { const A (&x)[2]; }; + // CHECK: @[[A1:_ZGRN14ArrayTemporary1bE.*]] = private constant [3 x i32] [i32 1, i32 2, i32 3] + // CHECK: @[[A2:_ZGRN14ArrayTemporary1bE.*]] = private constant [3 x i32] [i32 4, i32 5, i32 6] + // CHECK: @[[ARR:_ZGRN14ArrayTemporary1bE.*]] = private constant [2 x {{.*}}] [{{.*}} { [3 x i32]* @[[A1]] }, {{.*}} { [3 x i32]* @[[A2]] }] + // CHECK: @[[B:_ZGRN14ArrayTemporary1bE.*]] = private global {{.*}} { [2 x {{.*}}]* @[[ARR]] } + // CHECK: @_ZN14ArrayTemporary1bE = constant {{.*}}* @[[B]] + B &&b = { { { { 1, 2, 3 } }, { { 4, 5, 6 } } } }; +} + +namespace UnemittedTemporaryDecl { + constexpr int &&ref = 0; + extern constexpr int &ref2 = ref; + // CHECK: @_ZGRN22UnemittedTemporaryDecl3refE = private global i32 0 + + // FIXME: This declaration should not be emitted -- it isn't odr-used. + // CHECK: @_ZN22UnemittedTemporaryDecl3refE + + // CHECK: @_ZN22UnemittedTemporaryDecl4ref2E = constant i32* @_ZGRN22UnemittedTemporaryDecl3refE +} + +// CHECK: @_ZZN12LocalVarInit3aggEvE1a = internal constant {{.*}} i32 101 +// CHECK: @_ZZN12LocalVarInit4ctorEvE1a = internal constant {{.*}} i32 102 +// CHECK: @_ZZN12LocalVarInit8mutable_EvE1a = private unnamed_addr constant {{.*}} i32 103 + // Constant initialization tests go before this point, // dynamic initialization tests go after. @@ -356,6 +420,40 @@ namespace PR13273 { // CHECK-NOT: } // CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr4BothD1Ev +// PR12848: Don't emit dynamic initializers for local constexpr variables. +namespace LocalVarInit { + constexpr int f(int n) { return n; } + struct Agg { int k; }; + struct Ctor { constexpr Ctor(int n) : k(n) {} int k; }; + struct Mutable { constexpr Mutable(int n) : k(n) {} mutable int k; }; + + // CHECK: define {{.*}} @_ZN12LocalVarInit6scalarEv + // CHECK-NOT: call + // CHECK: store i32 100, + // CHECK-NOT: call + // CHECK: ret i32 100 + int scalar() { constexpr int a = { f(100) }; return a; } + + // CHECK: define {{.*}} @_ZN12LocalVarInit3aggEv + // CHECK-NOT: call + // CHECK: ret i32 101 + int agg() { constexpr Agg a = { f(101) }; return a.k; } + + // CHECK: define {{.*}} @_ZN12LocalVarInit4ctorEv + // CHECK-NOT: call + // CHECK: ret i32 102 + int ctor() { constexpr Ctor a = { f(102) }; return a.k; } + + // CHECK: define {{.*}} @_ZN12LocalVarInit8mutable_Ev + // CHECK-NOT: call + // CHECK: call {{.*}}memcpy{{.*}} @_ZZN12LocalVarInit8mutable_EvE1a + // CHECK-NOT: call + // Can't fold return value due to 'mutable'. + // CHECK-NOT: ret i32 103 + // CHECK: } + int mutable_() { constexpr Mutable a = { f(103) }; return a.k; } +} + namespace CrossFuncLabelDiff { // Make sure we refuse to constant-fold the variable b. constexpr long a(bool x) { return x ? 0 : (long)&&lbl + (0 && ({lbl: 0;})); } diff --git a/test/CodeGenCXX/const-init-cxx1y.cpp b/test/CodeGenCXX/const-init-cxx1y.cpp new file mode 100644 index 0000000..978c428 --- /dev/null +++ b/test/CodeGenCXX/const-init-cxx1y.cpp @@ -0,0 +1,48 @@ +// RUN: not %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++1y | FileCheck %s + +struct A { + constexpr A() : n(1) {} + ~A(); + int n; +}; +struct B : A { + A a[3]; + constexpr B() { + ++a[0].n; + a[1].n += 2; + a[2].n = n + a[1].n; + } +}; +B b; + +// CHECK: @b = global {{.*}} i32 1, {{.*}} { i32 2 }, {{.*}} { i32 3 }, {{.*}} { i32 4 } +// CHECK-NOT: _ZN1BC + +namespace ModifyStaticTemporary { + struct A { int &&temporary; int x; }; + constexpr int f(int &r) { r *= 9; return r - 12; } + A a = { 6, f(a.temporary) }; + // CHECK: @_ZGRN21ModifyStaticTemporary1aE = private global i32 54 + // CHECK: @_ZN21ModifyStaticTemporary1aE = global {{.*}} i32* @_ZGRN21ModifyStaticTemporary1aE, i32 42 + + A b = { 7, ++b.temporary }; + // CHECK: @_ZGRN21ModifyStaticTemporary1bE = private global i32 8 + // CHECK: @_ZN21ModifyStaticTemporary1bE = global {{.*}} i32* @_ZGRN21ModifyStaticTemporary1bE, i32 8 + + // Can't emit all of 'c' as a constant here, so emit the initial value of + // 'c.temporary', not the value as modified by the partial evaluation within + // the initialization of 'c.x'. + A c = { 10, (++c.temporary, b.x) }; + // CHECK: @_ZGRN21ModifyStaticTemporary1cE = private global i32 10 + // CHECK: @_ZN21ModifyStaticTemporary1cE = global {{.*}} zeroinitializer +} + +// CHECK: __cxa_atexit({{.*}} @_ZN1BD1Ev {{.*}} @b + +// CHECK: define +// CHECK-NOT: @_ZGRN21ModifyStaticTemporary1cE +// CHECK: store {{.*}} @_ZGRN21ModifyStaticTemporary1cE, {{.*}} @_ZN21ModifyStaticTemporary1cE +// CHECK: add +// CHECK: store +// CHECK: load {{.*}} @_ZN21ModifyStaticTemporary1bE +// CHECK: store {{.*}} @_ZN21ModifyStaticTemporary1cE diff --git a/test/CodeGenCXX/const-init.cpp b/test/CodeGenCXX/const-init.cpp index 201ce8f..05896ff 100644 --- a/test/CodeGenCXX/const-init.cpp +++ b/test/CodeGenCXX/const-init.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s +// RUN: not %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s // CHECK: @a = global i32 10 int a = 10; diff --git a/test/CodeGenCXX/constructor-attr.cpp b/test/CodeGenCXX/constructor-attr.cpp index 691795f..4f6d635 100644 --- a/test/CodeGenCXX/constructor-attr.cpp +++ b/test/CodeGenCXX/constructor-attr.cpp @@ -5,7 +5,7 @@ // PR6521 void bar(); struct Foo { - // CHECK: define linkonce_odr void @_ZN3Foo3fooEv + // CHECK-LABEL: define linkonce_odr void @_ZN3Foo3fooEv static void foo() __attribute__((constructor)) { bar(); } diff --git a/test/CodeGenCXX/constructor-conversion.cpp b/test/CodeGenCXX/constructor-conversion.cpp index f503463..ebb414d 100644 --- a/test/CodeGenCXX/constructor-conversion.cpp +++ b/test/CodeGenCXX/constructor-conversion.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/constructor-default-arg.cpp b/test/CodeGenCXX/constructor-default-arg.cpp index 32086c1..c2cf44c 100644 --- a/test/CodeGenCXX/constructor-default-arg.cpp +++ b/test/CodeGenCXX/constructor-default-arg.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/constructor-destructor-return-this.cpp b/test/CodeGenCXX/constructor-destructor-return-this.cpp index 1ff922d..ea2ea45 100644 --- a/test/CodeGenCXX/constructor-destructor-return-this.cpp +++ b/test/CodeGenCXX/constructor-destructor-return-this.cpp @@ -1,60 +1,116 @@ -//RUN: %clang_cc1 %s -emit-llvm -o - -triple=thumbv7-apple-ios3.0 -target-abi apcs-gnu | FileCheck %s +//RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-unknown-linux | FileCheck --check-prefix=CHECKGEN %s +//RUN: %clang_cc1 %s -emit-llvm -o - -triple=thumbv7-apple-ios3.0 -target-abi apcs-gnu | FileCheck --check-prefix=CHECKARM %s +//RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-pc-win32 -cxx-abi microsoft -fno-rtti | FileCheck --check-prefix=CHECKMS %s +// FIXME: these tests crash on the bots when run with -triple=x86_64-pc-win32 -// For constructors/desctructors that return 'this', if there exists a callsite -// that returns 'this' and is immediately before the return instruction, make -// sure we are using the return value from the callsite. -// rdar://12818789 +// Make sure we attach the 'returned' attribute to the 'this' parameter of +// constructors and destructors which return this (and only these cases) -// CHECK: define linkonce_odr [[A:%.*]] @_ZN11ObjectCacheC1Ev([[A]] %this) unnamed_addr -// CHECK: [[THIS1:%.*]] = call [[A]] @_ZN11ObjectCacheC2Ev( -// CHECK-NEXT: ret [[A]] [[THIS1]] +class A { +public: + A(); + ~A(); -// CHECK: define linkonce_odr [[A:%.*]] @_ZN5TimerI11ObjectCacheEC1EPS0_MS0_FvPS1_E([[A]] %this -// CHECK: [[THIS1:%.*]] = call [[A]] @_ZN5TimerI11ObjectCacheEC2EPS0_MS0_FvPS1_E( -// CHECK-NEXT: ret [[A]] [[THIS1]] +private: + int x_; +}; -// CHECK: define linkonce_odr [[A:%.*]] @_ZN5TimerI11ObjectCacheED1Ev([[A]] %this) unnamed_addr -// CHECK: [[THIS1:%.*]] = call [[A]] @_ZN5TimerI11ObjectCacheED2Ev( -// CHECK-NEXT: ret [[A]] [[THIS1]] +class B : public A { +public: + B(int *i); + ~B(); + +private: + int *i_; +}; -// CHECK: define linkonce_odr [[A:%.*]] @_ZN5TimerI11ObjectCacheED2Ev([[A]] %this) unnamed_addr -// CHECK: [[THIS1:%.*]] = call [[B:%.*]] @_ZN9TimerBaseD2Ev( -// CHECK-NEXT: [[THIS2:%.*]] = bitcast [[B]] [[THIS1]] to [[A]] -// CHECK-NEXT: ret [[A]] [[THIS2]] +B::B(int *i) : i_(i) { } +B::~B() { } -class TimerBase { +// CHECKGEN-LABEL: define void @_ZN1BC1EPi(%class.B* %this, i32* %i) +// CHECKGEN-LABEL: define void @_ZN1BC2EPi(%class.B* %this, i32* %i) +// CHECKGEN-LABEL: define void @_ZN1BD1Ev(%class.B* %this) +// CHECKGEN-LABEL: define void @_ZN1BD2Ev(%class.B* %this) + +// CHECKARM-LABEL: define %class.B* @_ZN1BC1EPi(%class.B* returned %this, i32* %i) +// CHECKARM-LABEL: define %class.B* @_ZN1BC2EPi(%class.B* returned %this, i32* %i) +// CHECKARM-LABEL: define %class.B* @_ZN1BD1Ev(%class.B* returned %this) +// CHECKARM-LABEL: define %class.B* @_ZN1BD2Ev(%class.B* returned %this) + +// CHECKMS-LABEL: define x86_thiscallcc %class.B* @"\01??0B@@QAE@PAH@Z"(%class.B* returned %this, i32* %i) +// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1B@@QAE@XZ"(%class.B* %this) + +class C : public A, public B { public: - TimerBase(); - virtual ~TimerBase(); + C(int *i, char *c); + virtual ~C(); +private: + char *c_; }; -template class Timer : public TimerBase { -public: - typedef void (TimerFiredClass::*TimerFiredFunction)(Timer*); +C::C(int *i, char *c) : B(i), c_(c) { } +C::~C() { } - Timer(TimerFiredClass* o, TimerFiredFunction f) - : m_object(o), m_function(f) { } +// CHECKGEN-LABEL: define void @_ZN1CC1EPiPc(%class.C* %this, i32* %i, i8* %c) +// CHECKGEN-LABEL: define void @_ZN1CC2EPiPc(%class.C* %this, i32* %i, i8* %c) +// CHECKGEN-LABEL: define void @_ZN1CD0Ev(%class.C* %this) +// CHECKGEN-LABEL: define void @_ZN1CD1Ev(%class.C* %this) +// CHECKGEN-LABEL: define void @_ZN1CD2Ev(%class.C* %this) -private: - virtual void fired() { (m_object->*m_function)(this); } +// CHECKARM-LABEL: define %class.C* @_ZN1CC1EPiPc(%class.C* returned %this, i32* %i, i8* %c) +// CHECKARM-LABEL: define %class.C* @_ZN1CC2EPiPc(%class.C* returned %this, i32* %i, i8* %c) +// CHECKARM-LABEL: define void @_ZN1CD0Ev(%class.C* %this) +// CHECKARM-LABEL: define %class.C* @_ZN1CD1Ev(%class.C* returned %this) +// CHECKARM-LABEL: define %class.C* @_ZN1CD2Ev(%class.C* returned %this) - TimerFiredClass* m_object; - TimerFiredFunction m_function; -}; +// CHECKMS-LABEL: define x86_thiscallcc %class.C* @"\01??0C@@QAE@PAHPAD@Z"(%class.C* returned %this, i32* %i, i8* %c) +// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1C@@UAE@XZ"(%class.C* %this) -class ObjectCache { +class D : public virtual A { public: - explicit ObjectCache(); - ~ObjectCache(); + D(); + ~D(); +}; -private: - Timer m_notificationPostTimer; +D::D() { } +D::~D() { } + +// CHECKGEN-LABEL: define void @_ZN1DC1Ev(%class.D* %this) +// CHECKGEN-LABEL: define void @_ZN1DC2Ev(%class.D* %this, i8** %vtt) +// CHECKGEN-LABEL: define void @_ZN1DD1Ev(%class.D* %this) +// CHECKGEN-LABEL: define void @_ZN1DD2Ev(%class.D* %this, i8** %vtt) + +// CHECKARM-LABEL: define %class.D* @_ZN1DC1Ev(%class.D* returned %this) +// CHECKARM-LABEL: define %class.D* @_ZN1DC2Ev(%class.D* returned %this, i8** %vtt) +// CHECKARM-LABEL: define %class.D* @_ZN1DD1Ev(%class.D* returned %this) +// CHECKARM-LABEL: define %class.D* @_ZN1DD2Ev(%class.D* returned %this, i8** %vtt) + +// CHECKMS-LABEL: define x86_thiscallcc %class.D* @"\01??0D@@QAE@XZ"(%class.D* returned %this, i32 %is_most_derived) +// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1D@@QAE@XZ"(%class.D* %this) + +class E { +public: + E(); + virtual ~E(); }; -inline ObjectCache::ObjectCache() : m_notificationPostTimer(this, 0) { } -inline ObjectCache::~ObjectCache() { } +E* gete(); -ObjectCache *test() { - ObjectCache *dd = new ObjectCache(); - return dd; +void test_destructor() { + const E& e1 = E(); + E* e2 = gete(); + e2->~E(); } + +// CHECKARM-LABEL: define void @_Z15test_destructorv() + +// Verify that virtual calls to destructors are not marked with a 'returned' +// this parameter at the call site... +// CHECKARM: [[VFN:%.*]] = getelementptr inbounds %class.E* (%class.E*)** +// CHECKARM: [[THUNK:%.*]] = load %class.E* (%class.E*)** [[VFN]] +// CHECKARM: call %class.E* [[THUNK]](%class.E* % + +// ...but static calls create declarations with 'returned' this +// CHECKARM: {{%.*}} = call %class.E* @_ZN1ED1Ev(%class.E* % + +// CHECKARM: declare %class.E* @_ZN1ED1Ev(%class.E* returned) diff --git a/test/CodeGenCXX/constructor-for-array-members.cpp b/test/CodeGenCXX/constructor-for-array-members.cpp index 7a365cd..7842d9c 100644 --- a/test/CodeGenCXX/constructor-for-array-members.cpp +++ b/test/CodeGenCXX/constructor-for-array-members.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/constructor-init.cpp b/test/CodeGenCXX/constructor-init.cpp index b33184e..477a439 100644 --- a/test/CodeGenCXX/constructor-init.cpp +++ b/test/CodeGenCXX/constructor-init.cpp @@ -70,7 +70,7 @@ template struct A { operator int() {return 0;} }; -// CHECK: define void @_Z1fv() +// CHECK-LABEL: define void @_Z1fv() void f() { // CHECK: call void @_ZN1AIsEC1Ei A a4 = 97; @@ -93,7 +93,7 @@ namespace InitVTable { B(int); }; - // CHECK: define void @_ZN10InitVTable1BC2Ev(%"struct.InitVTable::B"* %this) unnamed_addr + // CHECK-LABEL: define void @_ZN10InitVTable1BC2Ev(%"struct.InitVTable::B"* %this) unnamed_addr // CHECK: [[T0:%.*]] = bitcast [[B:%.*]]* [[THIS:%.*]] to i8*** // CHECK-NEXT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN10InitVTable1BE, i64 0, i64 2), i8*** [[T0]] // CHECK: [[VTBL:%.*]] = load i32 ([[B]]*)*** {{%.*}} @@ -106,7 +106,7 @@ namespace InitVTable { // CHECK-NEXT: ret void B::B() : A(foo()) {} - // CHECK: define void @_ZN10InitVTable1BC2Ei(%"struct.InitVTable::B"* %this, i32 %x) unnamed_addr + // CHECK-LABEL: define void @_ZN10InitVTable1BC2Ei(%"struct.InitVTable::B"* %this, i32 %x) unnamed_addr // CHECK: [[ARG:%.*]] = add nsw i32 {{%.*}}, 5 // CHECK-NEXT: call void @_ZN10InitVTable1AC2Ei({{.*}}* {{%.*}}, i32 [[ARG]]) // CHECK-NEXT: [[T0:%.*]] = bitcast [[B]]* {{%.*}} to i8*** @@ -120,7 +120,7 @@ namespace rdar9694300 { int x; }; - // CHECK: define void @_ZN11rdar96943001fEv + // CHECK-LABEL: define void @_ZN11rdar96943001fEv void f() { // CHECK: alloca X x; @@ -163,7 +163,7 @@ template struct X; // Make sure that the instantiated constructor initializes start and // end properly. -// CHECK: define linkonce_odr void @_ZN1XIiEC2ERKS0_(%struct.X* %this, %struct.X* %other) unnamed_addr +// CHECK-LABEL: define linkonce_odr void @_ZN1XIiEC2ERKS0_(%struct.X* %this, %struct.X* %other) unnamed_addr // CHECK: {{store.*null}} // CHECK: {{store.*null}} // CHECK: ret @@ -200,7 +200,7 @@ namespace PR10720 { // CHECK-PR10720: ret pair2 &operator=(pair2&&) = default; - // CHECK-PR10720: define linkonce_odr void @_ZN7PR107205pair2C2EOS0_ + // CHECK-PR10720-LABEL: define linkonce_odr void @_ZN7PR107205pair2C2EOS0_ // CHECK-PR10720-NOT: ret // CHECK-PR10720: load // CHECK-PR10720: icmp ult @@ -210,7 +210,7 @@ namespace PR10720 { // CHECK-PR10720: ret void pair2(pair2&&) = default; - // CHECK-PR10720: define linkonce_odr void @_ZN7PR107205pair2C2ERKS0_ + // CHECK-PR10720-LABEL: define linkonce_odr void @_ZN7PR107205pair2C2ERKS0_ // CHECK-PR10720-NOT: ret // CHECK-PR10720: load // CHECK-PR10720: icmp ult @@ -223,7 +223,7 @@ namespace PR10720 { struct pair : X { // Make the copy constructor non-trivial, so we actually generate it. int second[4]; - // CHECK-PR10720: define linkonce_odr void @_ZN7PR107204pairC2ERKS0_ + // CHECK-PR10720-LABEL: define linkonce_odr void @_ZN7PR107204pairC2ERKS0_ // CHECK-PR10720-NOT: ret // CHECK-PR10720: call void @llvm.memcpy // CHECK-PR10720-NEXT: ret void diff --git a/test/CodeGenCXX/constructor-template.cpp b/test/CodeGenCXX/constructor-template.cpp index fe4687c..0d38d10 100644 --- a/test/CodeGenCXX/constructor-template.cpp +++ b/test/CodeGenCXX/constructor-template.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s // PR4826 struct A { diff --git a/test/CodeGenCXX/constructors.cpp b/test/CodeGenCXX/constructors.cpp index 9e2da31..f730b9e 100644 --- a/test/CodeGenCXX/constructors.cpp +++ b/test/CodeGenCXX/constructors.cpp @@ -21,18 +21,18 @@ struct A { A::A(struct Undeclared &ref) : mem(0) {} // Check that delegation works. -// CHECK: define void @_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr +// CHECK-LABEL: define void @_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr // CHECK: call void @_ZN1AC2ER10Undeclared( -// CHECK: define void @_ZN1AC2ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr +// CHECK-LABEL: define void @_ZN1AC2ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr // CHECK: call void @_ZN6MemberC1Ei( A::A(ValueClass v) : mem(v.y - v.x) {} -// CHECK: define void @_ZN1AC1E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr +// CHECK-LABEL: define void @_ZN1AC1E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr // CHECK: call void @_ZN1AC2E10ValueClass( -// CHECK: define void @_ZN1AC2E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr +// CHECK-LABEL: define void @_ZN1AC2E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr // CHECK: call void @_ZN6MemberC1Ei( @@ -44,10 +44,10 @@ struct B : A { B::B(struct Undeclared &ref) : A(ref), mem(1) {} -// CHECK: define void @_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr +// CHECK-LABEL: define void @_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr // CHECK: call void @_ZN1BC2ER10Undeclared( -// CHECK: define void @_ZN1BC2ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr +// CHECK-LABEL: define void @_ZN1BC2ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr // CHECK: call void @_ZN1AC2ER10Undeclared( // CHECK: call void @_ZN6MemberC1Ei( @@ -64,12 +64,12 @@ struct C : virtual A { }; C::C(int x) : A(ValueClass(x, x+1)), mem(x * x) {} -// CHECK: define void @_ZN1CC1Ei(%struct.C* %this, i32 %x) unnamed_addr +// CHECK-LABEL: define void @_ZN1CC1Ei(%struct.C* %this, i32 %x) unnamed_addr // CHECK: call void @_ZN10ValueClassC1Eii( // CHECK: call void @_ZN1AC2E10ValueClass( // CHECK: call void @_ZN6MemberC1Ei( -// CHECK: define void @_ZN1CC2Ei(%struct.C* %this, i8** %vtt, i32 %x) unnamed_addr +// CHECK-LABEL: define void @_ZN1CC2Ei(%struct.C* %this, i8** %vtt, i32 %x) unnamed_addr // CHECK: call void @_ZN6MemberC1Ei( @@ -83,12 +83,12 @@ struct D : A { D::D(int x, ...) : A(ValueClass(x, x+1)), mem(x*x) {} -// CHECK: define void @_ZN1DC1Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr +// CHECK-LABEL: define void @_ZN1DC1Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr // CHECK: call void @_ZN10ValueClassC1Eii( // CHECK: call void @_ZN1AC2E10ValueClass( // CHECK: call void @_ZN6MemberC1Ei( -// CHECK: define void @_ZN1DC2Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr +// CHECK-LABEL: define void @_ZN1DC2Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr // CHECK: call void @_ZN10ValueClassC1Eii( // CHECK: call void @_ZN1AC2E10ValueClass( // CHECK: call void @_ZN6MemberC1Ei( @@ -109,7 +109,7 @@ namespace test1 { struct A { A(); void *ptr; }; struct B { B(); int x; A a[0]; }; B::B() {} - // CHECK: define void @_ZN5test11BC2Ev( + // CHECK-LABEL: define void @_ZN5test11BC2Ev( // CHECK: [[THIS:%.*]] = load [[B:%.*]]** // CHECK-NEXT: ret void } diff --git a/test/CodeGenCXX/conversion-function.cpp b/test/CodeGenCXX/conversion-function.cpp index 76d9e02..ec098d0 100644 --- a/test/CodeGenCXX/conversion-function.cpp +++ b/test/CodeGenCXX/conversion-function.cpp @@ -1,7 +1,7 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s // XFAIL: * extern "C" int printf(...); struct S { diff --git a/test/CodeGenCXX/convert-to-fptr.cpp b/test/CodeGenCXX/convert-to-fptr.cpp index 425f79d..e497acf 100644 --- a/test/CodeGenCXX/convert-to-fptr.cpp +++ b/test/CodeGenCXX/convert-to-fptr.cpp @@ -1,8 +1,8 @@ // 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: FileCheck -check-prefix CHECK-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 +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/copy-assign-synthesis-1.cpp b/test/CodeGenCXX/copy-assign-synthesis-1.cpp index 5d09b54..2ffc7bc 100644 --- a/test/CodeGenCXX/copy-assign-synthesis-1.cpp +++ b/test/CodeGenCXX/copy-assign-synthesis-1.cpp @@ -1,8 +1,8 @@ // 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 +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | \ +// RUN: FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -emit-llvm %s -o - | \ +// RUN: FileCheck %s extern "C" int printf(...); @@ -93,11 +93,5 @@ int main() { dstY.pr(); } -// CHECK-LP64: .globl __ZN1XaSERKS_ -// CHECK-LP64: .weak_definition __ZN1XaSERKS_ -// CHECK-LP64: __ZN1XaSERKS_: - -// CHECK-LP32: .globl __ZN1XaSERKS_ -// CHECK-LP32: .weak_definition __ZN1XaSERKS_ -// CHECK-LP32: __ZN1XaSERKS_: +// CHECK: define linkonce_odr %struct.X* @_ZN1XaSERKS_ diff --git a/test/CodeGenCXX/copy-assign-synthesis-2.cpp b/test/CodeGenCXX/copy-assign-synthesis-2.cpp index c25e046..18e92f9 100644 --- a/test/CodeGenCXX/copy-assign-synthesis-2.cpp +++ b/test/CodeGenCXX/copy-assign-synthesis-2.cpp @@ -1,4 +1,4 @@ // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s struct A {}; A& (A::*x)(const A&) = &A::operator=; -// CHECK: define linkonce_odr %struct.A* @_ZN1AaSERKS_ +// CHECK-LABEL: define linkonce_odr %struct.A* @_ZN1AaSERKS_ diff --git a/test/CodeGenCXX/copy-assign-synthesis.cpp b/test/CodeGenCXX/copy-assign-synthesis.cpp index e9fc0c3..9c8ae88 100644 --- a/test/CodeGenCXX/copy-assign-synthesis.cpp +++ b/test/CodeGenCXX/copy-assign-synthesis.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -emit-llvm -o %t %s -// RUN: grep "_ZN1XaSERK1X" %t | count 0 +// RUN: not grep "_ZN1XaSERK1X" %t extern "C" int printf(...); diff --git a/test/CodeGenCXX/copy-constructor-elim-2.cpp b/test/CodeGenCXX/copy-constructor-elim-2.cpp index 4ff8775..727af1b 100644 --- a/test/CodeGenCXX/copy-constructor-elim-2.cpp +++ b/test/CodeGenCXX/copy-constructor-elim-2.cpp @@ -2,7 +2,7 @@ struct A { int x; A(int); ~A(); }; A f() { return A(0); } -// CHECK: define void @_Z1fv +// CHECK-LABEL: define void @_Z1fv // CHECK: call {{.*}} @_ZN1AC1Ei // CHECK-NEXT: ret void @@ -21,7 +21,7 @@ namespace no_elide_base { Derived(const Other &O); }; - // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* %this, %"struct.no_elide_base::Other"* %O) unnamed_addr + // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* returned %this, %"struct.no_elide_base::Other"* %O) unnamed_addr Derived::Derived(const Other &O) // CHECK: call {{.*}} @_ZNK13no_elide_base5OthercvNS_4BaseEEv // CHECK: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_ @@ -63,7 +63,7 @@ namespace PR12139 { static A makeA() { A a; a.value = 2; return a; } }; - // CHECK: define i32 @_ZN7PR121394testEv + // CHECK-LABEL: define i32 @_ZN7PR121394testEv int test() { // CHECK: call void @_ZN7PR121391A5makeAEv // CHECK-NEXT: call %"struct.PR12139::A"* @_ZN7PR121391AC1ERKS0_i diff --git a/test/CodeGenCXX/copy-constructor-elim.cpp b/test/CodeGenCXX/copy-constructor-elim.cpp index c883584..ad3a87b 100644 --- a/test/CodeGenCXX/copy-constructor-elim.cpp +++ b/test/CodeGenCXX/copy-constructor-elim.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -emit-llvm -o %t %s -// RUN: grep "_ZN1CC1ERK1C" %t | count 0 -// RUN: grep "_ZN1SC1ERK1S" %t | count 0 +// RUN: not grep "_ZN1CC1ERK1C" %t +// RUN: not grep "_ZN1SC1ERK1S" %t extern "C" int printf(...); diff --git a/test/CodeGenCXX/copy-constructor-synthesis-2.cpp b/test/CodeGenCXX/copy-constructor-synthesis-2.cpp index d028a28..03c6633 100644 --- a/test/CodeGenCXX/copy-constructor-synthesis-2.cpp +++ b/test/CodeGenCXX/copy-constructor-synthesis-2.cpp @@ -3,5 +3,5 @@ struct A { virtual void a(); }; A x(A& y) { return y; } -// CHECK: define linkonce_odr {{.*}} @_ZN1AC1ERKS_(%struct.A* %this, %struct.A*) unnamed_addr +// CHECK: define linkonce_odr {{.*}} @_ZN1AC1ERKS_(%struct.A* {{.*}}%this, %struct.A*) unnamed_addr // CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1A, i64 0, i64 2) diff --git a/test/CodeGenCXX/copy-constructor-synthesis.cpp b/test/CodeGenCXX/copy-constructor-synthesis.cpp index 68f6805..c8b265c 100644 --- a/test/CodeGenCXX/copy-constructor-synthesis.cpp +++ b/test/CodeGenCXX/copy-constructor-synthesis.cpp @@ -21,7 +21,7 @@ struct P { }; -// CHECK: define linkonce_odr void @_ZN1XC1ERKS_(%struct.X* %this, %struct.X*) unnamed_addr +// CHECK-LABEL: define linkonce_odr void @_ZN1XC1ERKS_(%struct.X* %this, %struct.X*) unnamed_addr struct X : M, N, P { // ... X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd), au_i1(1234), au1_4("MASKED") {} @@ -136,7 +136,33 @@ void f(B b1) { B b2 = b1; } -// CHECK: define linkonce_odr void @_ZN6PR66281BC2ERKS0_(%"struct.PR6628::B"* %this, %"struct.PR6628::B"*) unnamed_addr +// CHECK: define linkonce_odr [[A:%.*]]* @_ZN12rdar138169401AaSERKS0_( +// CHECK: [[THIS:%.*]] = load [[A]]** +// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[A]]* [[THIS]], i32 0, i32 1 +// CHECK-NEXT: [[T1:%.*]] = bitcast [2 x i8]* [[T0]] to i16* +// CHECK-NEXT: [[OTHER:%.*]] = load [[A]]** +// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A]]* [[OTHER]], i32 0, i32 1 +// CHECK-NEXT: [[T3:%.*]] = bitcast [2 x i8]* [[T2]] to i16* +// CHECK-NEXT: [[T4:%.*]] = bitcast i16* [[T1]] to i8* +// CHECK-NEXT: [[T5:%.*]] = bitcast i16* [[T3]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T4]], i8* [[T5]], i64 8, i32 8, i1 false) +// CHECK-NEXT: ret [[A]]* [[THIS]] + +// CHECK-LABEL: define linkonce_odr void @_ZN12rdar138169401AC2ERKS0_( +// CHECK: [[THIS:%.*]] = load [[A]]** +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[THIS]] to i8*** +// CHECK-NEXT: store i8** getelementptr inbounds ([4 x i8*]* @_ZTVN12rdar138169401AE, i64 0, i64 2), i8*** [[T0]] +// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[A]]* [[THIS]], i32 0, i32 1 +// CHECK-NEXT: [[T1:%.*]] = bitcast [2 x i8]* [[T0]] to i16* +// CHECK-NEXT: [[OTHER:%.*]] = load [[A]]** +// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A]]* [[OTHER]], i32 0, i32 1 +// CHECK-NEXT: [[T3:%.*]] = bitcast [2 x i8]* [[T2]] to i16* +// CHECK-NEXT: [[T4:%.*]] = bitcast i16* [[T1]] to i8* +// CHECK-NEXT: [[T5:%.*]] = bitcast i16* [[T3]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T4]], i8* [[T5]], i64 8, i32 8, i1 false) +// CHECK-NEXT: ret void + +// CHECK-LABEL: define linkonce_odr void @_ZN6PR66281BC2ERKS0_(%"struct.PR6628::B"* %this, %"struct.PR6628::B"*) unnamed_addr // CHECK: call void @_ZN6PR66281TC1Ev // CHECK: call void @_ZN6PR66281TC1Ev // CHECK: call void @_ZN6PR66281AC2ERKS0_RKNS_1TES5_ @@ -154,3 +180,18 @@ void f(B b1) { // CHECK: call void @_ZN6PR66281TD1Ev } +// rdar://13816940 +// Test above because things get weirdly re-ordered. +namespace rdar13816940 { + struct A { + virtual ~A(); + unsigned short a : 1; + unsigned short : 15; + unsigned other; + }; + + void test(A &a) { + A x = a; // force copy constructor into existence + x = a; // also force the copy assignment operator + } +} diff --git a/test/CodeGenCXX/copy-initialization.cpp b/test/CodeGenCXX/copy-initialization.cpp index aecd64e..1a16013 100644 --- a/test/CodeGenCXX/copy-initialization.cpp +++ b/test/CodeGenCXX/copy-initialization.cpp @@ -12,7 +12,7 @@ struct Bar { void f(Foo); -// CHECK: define void @_Z1g3Foo(%struct.Foo* %foo) +// CHECK-LABEL: define void @_Z1g3Foo(%struct.Foo* %foo) void g(Foo foo) { // CHECK: call void @_ZN3BarC1Ev // CHECK: @_ZNK3BarcvRK3FooEv diff --git a/test/CodeGenCXX/crash.cpp b/test/CodeGenCXX/crash.cpp new file mode 100644 index 0000000..073542d --- /dev/null +++ b/test/CodeGenCXX/crash.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 %s -std=c++11 -emit-llvm-only +// CHECK that we don't crash. + +// PR11676's example is ill-formed: +/* +union _XEvent { +}; +void ProcessEvent() { + _XEvent pluginEvent = _XEvent(); +} +*/ + +// Example from PR11665: +void f() { + union U { int field; } u = U(); + (void)U().field; +} + +namespace PR17476 { +struct string { + string(const char *__s); + string &operator+=(const string &__str); +}; + +template void finalizeDefaultAtomValues() { + auto startEnd = [&](const char * sym)->void { + string start("__"); + start += sym; + } + ; + startEnd("preinit_array"); +} + +void f() { finalizeDefaultAtomValues(); } +} diff --git a/test/CodeGenCXX/ctor-dtor-alias.cpp b/test/CodeGenCXX/ctor-dtor-alias.cpp new file mode 100644 index 0000000..235d165 --- /dev/null +++ b/test/CodeGenCXX/ctor-dtor-alias.cpp @@ -0,0 +1,163 @@ +// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s + +// RUN: %clang_cc1 -cc1 -triple x86_64--netbsd -emit-llvm \ +// RUN: -mconstructor-aliases -O2 %s -o - | FileCheck --check-prefix=CHECK-RAUW %s + +namespace test1 { +// test that we don't produce an alias when the destructor is weak_odr. The +// reason to avoid it that another TU might have no explicit template +// instantiation definition or declaration, causing it to to output only +// one of the destructors as linkonce_odr, producing a different comdat. + +// CHECK-DAG: define weak_odr void @_ZN5test16foobarIvEC2Ev +// CHECK-DAG: define weak_odr void @_ZN5test16foobarIvEC1Ev + +template struct foobar { + foobar() {} +}; + +template struct foobar; +} + +namespace test2 { +// test that when the destrucor is linkonce_odr we just replace every use of +// C1 with C2. + +// CHECK-DAG: define linkonce_odr void @_ZN5test26foobarIvEC2Ev( +// CHECK-DAG: call void @_ZN5test26foobarIvEC2Ev +void g(); +template struct foobar { + foobar() { g(); } +}; +foobar x; +} + +namespace test3 { +// test that instead of an internal alias we just use the other destructor +// directly. + +// CHECK-DAG: define internal void @_ZN5test312_GLOBAL__N_11AD2Ev( +// CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test312_GLOBAL__N_11AD2Ev +namespace { +struct A { + ~A() {} +}; + +struct B : public A {}; +} + +B x; +} + +namespace test4 { + // Test that we don't produce aliases from B to A. We cannot because we cannot + // guarantee that they will be present in every TU. Instead, we just call + // A's destructor directly. + + // CHECK-DAG: define linkonce_odr void @_ZN5test41AD2Ev( + // CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev + + // test that we don't do this optimization at -O0 so that the debugger can + // see both destructors. + // NOOPT-DAG: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD2Ev + // NOOOPT-DAG: define linkonce_odr void @_ZN5test41BD2Ev + struct A { + virtual ~A() {} + }; + struct B : public A{ + ~B() {} + }; + B X; +} + +namespace test5 { + // similar to test4, but with an internal B. + + // CHECK-DAG: define linkonce_odr void @_ZN5test51AD2Ev( + // CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test51AD2Ev + struct A { + virtual ~A() {} + }; + namespace { + struct B : public A{ + ~B() {} + }; + } + B X; +} + +namespace test6 { + // Test that we use ~A directly, even when ~A is not defined. The symbol for + // ~B would have been internal and still contain a reference to ~A. + struct A { + virtual ~A(); + }; + namespace { + struct B : public A { + ~B() {} + }; + } + B X; + // CHECK-DAG: call i32 @__cxa_atexit({{.*}}@_ZN5test61AD2Ev +} + +namespace test7 { + // Test that we don't produce an alias from ~B to ~A (or crash figuring + // out if we should). + // pr17875. + // CHECK-DAG: define void @_ZN5test71BD2Ev + template struct A { + ~A() {} + }; + class B : A { + ~B(); + }; + template class A; + B::~B() {} +} + +namespace test8 { + // Test that we replace ~zed with ~bar which is an alias to ~foo. + // CHECK-DAG: call i32 @__cxa_atexit({{.*}}@_ZN5test83barD2Ev + // CHECK-DAG: @_ZN5test83barD2Ev = alias {{.*}} @_ZN5test83fooD2Ev + struct foo { + ~foo(); + }; + foo::~foo() {} + struct bar : public foo { + ~bar(); + }; + bar::~bar() {} + struct zed : public bar {}; + zed foo; +} + +// CHECK-RAUW: @_ZTV1C = linkonce_odr unnamed_addr constant [4 x i8*] [{{[^@]*}}@_ZTI1C {{[^@]*}}@_ZN1CD2Ev {{[^@]*}}@_ZN1CD0Ev {{[^@]*}}] +// r194296 replaced C::~C with B::~B without emitting the later. + +class A { +public: + A(int); + virtual ~A(); +}; + +template +class B : A { +public: + B() + : A(0) { + } + __attribute__((always_inline)) ~B() { + } +}; + +extern template class B; + +class C : B { +}; + +void +fn1() { + new C; +} diff --git a/test/CodeGenCXX/cxx-block-objects.cpp b/test/CodeGenCXX/cxx-block-objects.cpp index b989065..ff868fc 100644 --- a/test/CodeGenCXX/cxx-block-objects.cpp +++ b/test/CodeGenCXX/cxx-block-objects.cpp @@ -25,9 +25,9 @@ main() return 0; } -// CHECK: define internal void @__copy_helper_block_ +// CHECK-LABEL: define internal void @__copy_helper_block_ // CHECK: call void @_ZN1AC1ERKS_ -// CHECK:define internal void @__destroy_helper_block_ +// CHECK-LABEL:define internal void @__destroy_helper_block_ // CHECK: call void @_ZN1AD1Ev diff --git a/test/CodeGenCXX/cxx0x-delegating-ctors.cpp b/test/CodeGenCXX/cxx0x-delegating-ctors.cpp index e909f03..c48e61f 100644 --- a/test/CodeGenCXX/cxx0x-delegating-ctors.cpp +++ b/test/CodeGenCXX/cxx0x-delegating-ctors.cpp @@ -87,7 +87,7 @@ namespace PR14588 { virtual void squawk() { other(); } }; - // CHECK: define void @_ZN7PR145883FooC1Ev(%"class.PR14588::Foo"* + // CHECK-LABEL: define void @_ZN7PR145883FooC1Ev(%"class.PR14588::Foo"* // CHECK: call void @_ZN7PR145883FooC1EPKv( // CHECK: invoke void @_ZN7PR145885otherEv() // CHECK: call void @_ZN7PR145883FooD1Ev diff --git a/test/CodeGenCXX/cxx0x-initializer-array.cpp b/test/CodeGenCXX/cxx0x-initializer-array.cpp index 3144e94..49bc86f 100644 --- a/test/CodeGenCXX/cxx0x-initializer-array.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-array.cpp @@ -6,7 +6,7 @@ struct A { int a[1]; }; typedef A x[]; int f() { x{{{1}}}; - // CHECK: define i32 @_Z1fv + // CHECK-LABEL: define i32 @_Z1fv // CHECK: store i32 1 // (It's okay if the output changes here, as long as we don't crash.) return 0; @@ -33,7 +33,7 @@ namespace ValueInitArrayOfMemPtr { S1(); }; - // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1fEi + // CHECK-LABEL: define void @_ZN22ValueInitArrayOfMemPtr1fEi void f(int n) { Agg1 a = { n }; // CHECK: store i32 -1, @@ -42,7 +42,7 @@ namespace ValueInitArrayOfMemPtr { // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* bitcast ([3 x i32]* @[[THREE_NULL_MEMPTRS]] to i8*), i32 12, i32 4, i1 false) } - // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1gEv + // CHECK-LABEL: define void @_ZN22ValueInitArrayOfMemPtr1gEv void g() { // CHECK: store i32 -1, f(a{}); @@ -54,7 +54,7 @@ namespace array_dtor { using T = S[3]; void f(const T &); void f(T *); - // CHECK: define void @_ZN10array_dtor1gEv( + // CHECK-LABEL: define void @_ZN10array_dtor1gEv( void g() { // CHECK: %[[ARRAY:.*]] = alloca [3 x // CHECK: br @@ -73,7 +73,7 @@ namespace array_dtor { // CHECK: ret void } - // CHECK: define void @_ZN10array_dtor1hEv( + // CHECK-LABEL: define void @_ZN10array_dtor1hEv( void h() { // CHECK: %[[ARRAY:.*]] = alloca [3 x // CHECK: br @@ -91,7 +91,7 @@ namespace array_dtor { // CHECK: ret void } - // CHECK: define void @_ZN10array_dtor1iEv( + // CHECK-LABEL: define void @_ZN10array_dtor1iEv( void i() { // CHECK: %[[ARRAY:.*]] = alloca [3 x // CHECK: br diff --git a/test/CodeGenCXX/cxx0x-initializer-constructors.cpp b/test/CodeGenCXX/cxx0x-initializer-constructors.cpp index be5b44d..f60536e 100644 --- a/test/CodeGenCXX/cxx0x-initializer-constructors.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-constructors.cpp @@ -6,21 +6,21 @@ struct S { }; void fn1() { - // CHECK: define void @_Z3fn1v + // CHECK-LABEL: 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 + // CHECK-LABEL: 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 + // CHECK-LABEL: define void @_Z3fn3v S sa[] { { 1 }, { 2 }, { 3 } }; // CHECK: alloca [3 x %struct.S], align 1 // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 1) @@ -29,9 +29,25 @@ void fn3() { } void fn4() { - // CHECK: define void @_Z3fn4v + // CHECK-LABEL: 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) } + +namespace TreeTransformBracedInit { + struct S {}; + struct T { T(const S &); T(const T&); ~T(); }; + void x(const T &); + template void foo(const S &s) { + // Instantiation of this expression used to lose the CXXBindTemporaryExpr + // node and thus not destroy the temporary. + x({s}); + } + template void foo(const S&); + // CHECK: define {{.*}} void @_ZN23TreeTransformBracedInit3fooIvEEvRKNS_1SE( + // CHECK: call void @_ZN23TreeTransformBracedInit1TC1ERKNS_1SE( + // CHECK-NEXT: call void @_ZN23TreeTransformBracedInit1xERKNS_1TE( + // CHECK-NEXT: call void @_ZN23TreeTransformBracedInit1TD1Ev( +} diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp index 14d2f77..091d7b7 100644 --- a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp @@ -1,18 +1,28 @@ -// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - -verify %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-STATIC-BL +// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -Dconstexpr= | FileCheck %s --check-prefix=CHECK-DYNAMIC-BL +// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -DUSE_END | FileCheck %s --check-prefix=CHECK-STATIC-BE +// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -DUSE_END -Dconstexpr= | FileCheck %s --check-prefix=CHECK-DYNAMIC-BE namespace std { typedef decltype(sizeof(int)) size_t; - // libc++'s implementation template class initializer_list { const _E* __begin_; +#ifdef USE_END + const _E* __end_; +#else size_t __size_; +#endif - initializer_list(const _E* __b, size_t __s) + constexpr initializer_list(const _E* __b, size_t __s) : __begin_(__b), +#ifdef USE_END + __end_(__b + __s) +#else __size_(__s) +#endif {} public: @@ -24,14 +34,99 @@ namespace std { typedef const _E* iterator; typedef const _E* const_iterator; - initializer_list() : __begin_(nullptr), __size_(0) {} +#ifdef USE_END + constexpr initializer_list() : __begin_(nullptr), __end_(nullptr) {} + + size_t size() const {return __end_ - __begin_;} + const _E* begin() const {return __begin_;} + const _E* end() const {return __end_;} +#else + constexpr initializer_list() : __begin_(nullptr), __size_(0) {} size_t size() const {return __size_;} const _E* begin() const {return __begin_;} const _E* end() const {return __begin_ + __size_;} +#endif }; } -std::initializer_list> pleasefail = { - {1, 2}, {3, 4}, {5, 6} // expected-error {{cannot compile}} +constexpr int a = 2, b = 4, c = 6; +std::initializer_list> nested = { + {1, a}, {3, b}, {5, c} }; + +// CHECK-STATIC-BL: @_ZGR6nested = private constant [2 x i32] [i32 1, i32 2], align 4 +// CHECK-STATIC-BL: @_ZGR6nested1 = private constant [2 x i32] [i32 3, i32 4], align 4 +// CHECK-STATIC-BL: @_ZGR6nested2 = private constant [2 x i32] [i32 5, i32 6], align 4 +// CHECK-STATIC-BL: @_ZGR6nested3 = private constant [3 x {{.*}}] [ +// CHECK-STATIC-BL: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested, i32 0, i32 0), i64 2 }, +// CHECK-STATIC-BL: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i32 0, i32 0), i64 2 }, +// CHECK-STATIC-BL: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i32 0, i32 0), i64 2 } +// CHECK-STATIC-BL: ], align 8 +// CHECK-STATIC-BL: @nested = global {{.*}} { {{.*}} getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested3, i32 0, i32 0), i64 3 }, align 8 + +// CHECK-DYNAMIC-BL: @nested = global +// CHECK-DYNAMIC-BL: @_ZGR6nested = private global [3 x +// CHECK-DYNAMIC-BL: @_ZGR6nested1 = private global [2 x i32] zeroinitializer +// CHECK-DYNAMIC-BL: @_ZGR6nested2 = private global [2 x i32] zeroinitializer +// CHECK-DYNAMIC-BL: @_ZGR6nested3 = private global [2 x i32] zeroinitializer +// CHECK-DYNAMIC-BL: store i32 1, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i64 0, i64 0) +// CHECK-DYNAMIC-BL: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i64 0, i64 1) +// CHECK-DYNAMIC-BL: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i64 0, i64 0), +// CHECK-DYMAMIC-BL: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 0, i32 0), align 8 +// CHECK-DYNAMIC-BL: store i64 2, i64* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 0, i32 1), align 8 +// CHECK-DYNAMIC-BL: store i32 3, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i64 0, i64 0) +// CHECK-DYNAMIC-BL: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i64 0, i64 1) +// CHECK-DYNAMIC-BL: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i64 0, i64 0), +// CHECK-DYNAMIC-BL: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 1, i32 0), align 8 +// CHECK-DYNAMIC-BL: store i64 2, i64* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 1, i32 1), align 8 +// CHECK-DYNAMIC-BL: store i32 5, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested3, i64 0, i64 0) +// CHECK-DYNAMIC-BL: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested3, i64 0, i64 1) +// CHECK-DYNAMIC-BL: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested3, i64 0, i64 0), +// CHECK-DYNAMIC-BL: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 2, i32 0), align 8 +// CHECK-DYNAMIC-BL: store i64 2, i64* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 2, i32 1), align 8 +// CHECK-DYNAMIC-BL: store {{.*}}* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 0), +// CHECK-DYNAMIC-BL: {{.*}}** getelementptr inbounds ({{.*}}* @nested, i32 0, i32 0), align 8 +// CHECK-DYNAMIC-BL: store i64 3, i64* getelementptr inbounds ({{.*}}* @nested, i32 0, i32 1), align 8 + +// CHECK-STATIC-BE: @_ZGR6nested = private constant [2 x i32] [i32 1, i32 2], align 4 +// CHECK-STATIC-BE: @_ZGR6nested1 = private constant [2 x i32] [i32 3, i32 4], align 4 +// CHECK-STATIC-BE: @_ZGR6nested2 = private constant [2 x i32] [i32 5, i32 6], align 4 +// CHECK-STATIC-BE: @_ZGR6nested3 = private constant [3 x {{.*}}] [ +// CHECK-STATIC-BE: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested, i32 0, i32 0), +// CHECK-STATIC-BE: i32* bitcast (i8* getelementptr (i8* bitcast ([2 x i32]* @_ZGR6nested to i8*), i64 8) to i32*) } +// CHECK-STATIC-BE: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i32 0, i32 0), +// CHECK-STATIC-BE: i32* bitcast (i8* getelementptr (i8* bitcast ([2 x i32]* @_ZGR6nested1 to i8*), i64 8) to i32*) } +// CHECK-STATIC-BE: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i32 0, i32 0), +// CHECK-STATIC-BE: i32* bitcast (i8* getelementptr (i8* bitcast ([2 x i32]* @_ZGR6nested2 to i8*), i64 8) to i32*) } +// CHECK-STATIC-BE: ], align 8 +// CHECK-STATIC-BE: @nested = global {{.*}} { {{.*}} getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested3, i32 0, i32 0), +// CHECK-STATIC-BE: {{.*}} bitcast ({{.*}}* getelementptr (i8* bitcast ([3 x {{.*}}]* @_ZGR6nested3 to i8*), i64 48) to {{.*}}*) } + +// CHECK-DYNAMIC-BE: @nested = global +// CHECK-DYNAMIC-BE: @_ZGR6nested = private global [3 x +// CHECK-DYNAMIC-BE: @_ZGR6nested1 = private global [2 x i32] zeroinitializer +// CHECK-DYNAMIC-BE: @_ZGR6nested2 = private global [2 x i32] zeroinitializer +// CHECK-DYNAMIC-BE: @_ZGR6nested3 = private global [2 x i32] zeroinitializer +// CHECK-DYNAMIC-BE: store i32 1, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i64 0, i64 0) +// CHECK-DYNAMIC-BE: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i64 0, i64 1) +// CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i64 0, i64 0), +// CHECK-DYMAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 0, i32 0), align 8 +// CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1, i64 1, i64 0), +// CHECK-DYMAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 0, i32 1), align 8 +// CHECK-DYNAMIC-BE: store i32 3, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i64 0, i64 0) +// CHECK-DYNAMIC-BE: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i64 0, i64 1) +// CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i64 0, i64 0), +// CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 1, i32 0), align 8 +// CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2, i64 1, i64 0), +// CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 1, i32 1), align 8 +// CHECK-DYNAMIC-BE: store i32 5, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested3, i64 0, i64 0) +// CHECK-DYNAMIC-BE: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested3, i64 0, i64 1) +// CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested3, i64 0, i64 0), +// CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 2, i32 0), align 8 +// CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested3, i64 1, i64 0), +// CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 2, i32 1), align 8 +// CHECK-DYNAMIC-BE: store {{.*}}* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 0, i64 0), +// CHECK-DYNAMIC-BE: {{.*}}** getelementptr inbounds ({{.*}}* @nested, i32 0, i32 0), align 8 +// CHECK-DYNAMIC-BE: store {{.*}}* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested, i64 1, i64 0), +// CHECK-DYNAMIC-BE: {{.*}}** getelementptr inbounds ({{.*}}* @nested, i32 0, i32 1), align 8 diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp index 209ee65..8e0d161 100644 --- a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp @@ -32,12 +32,12 @@ namespace std { }; } -// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3] -// CHECK: @globalInitList1 = global {{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, {{[^)]*}}), i32* +// CHECK: @_ZGR15globalInitList1 = private constant [3 x i32] [i32 1, i32 2, i32 3] +// CHECK: @globalInitList1 = global {{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZGR15globalInitList1, {{[^)]*}}), i32* std::initializer_list globalInitList1 = {1, 2, 3}; void fn1(int i) { - // CHECK: define void @_Z3fn1i + // CHECK-LABEL: define void @_Z3fn1i // temporary array // CHECK: [[array:%[^ ]+]] = alloca [3 x i32] // CHECK: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0 @@ -66,7 +66,7 @@ struct destroyme2 { void fn2() { - // CHECK: define void @_Z3fn2v + // CHECK-LABEL: define void @_Z3fn2v void target(std::initializer_list); // objects should be destroyed before dm2, after call returns target({ destroyme1(), destroyme1() }); @@ -76,7 +76,7 @@ void fn2() { } void fn3() { - // CHECK: define void @_Z3fn3v + // CHECK-LABEL: define void @_Z3fn3v // objects should be destroyed after dm2 auto list = { destroyme1(), destroyme1() }; destroyme2 dm2; diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp index d683493..164cbce 100644 --- a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -47,23 +47,48 @@ struct wantslist1 { ~wantslist1(); }; -// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3] -// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, i32 0, i32 0), i{{32|64}} 3 } +// CHECK: @_ZGR15globalInitList1 = private constant [3 x i32] [i32 1, i32 2, i32 3] +// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZGR15globalInitList1, i32 0, i32 0), i{{32|64}} 3 } std::initializer_list globalInitList1 = {1, 2, 3}; namespace thread_local_global_array { - // CHECK: @_ZN25thread_local_global_arrayL11x__initlistE = internal thread_local global [4 x i32] [i32 1, i32 2, i32 3, i32 4] - // CHECK: @_ZN25thread_local_global_array1xE = thread_local global {{.*}} @_ZN25thread_local_global_arrayL11x__initlistE, {{.*}} i64 4 + // FIXME: We should be able to constant-evaluate this even though the + // initializer is not a constant expression (pointers to thread_local + // objects aren't really a problem). + // + // CHECK: @_ZN25thread_local_global_array1xE = thread_local global + // CHECK: @_ZGRN25thread_local_global_array1xE = private thread_local constant [4 x i32] [i32 1, i32 2, i32 3, i32 4] std::initializer_list thread_local x = { 1, 2, 3, 4 }; } -// CHECK: @_ZL25globalInitList2__initlist = internal global [2 x %{{[^ ]*}}] zeroinitializer -// CHECK: @globalInitList2 = global %{{[^ ]+}} { %[[WITHARG:[^ *]+]]* getelementptr inbounds ([2 x +// CHECK: @globalInitList2 = global %{{[^ ]+}} zeroinitializer +// CHECK: @_ZGR15globalInitList2 = private global [2 x %[[WITHARG:[^ ]*]]] zeroinitializer + +// CHECK: @_ZN15partly_constant1kE = global i32 0, align 4 +// CHECK: @_ZN15partly_constant2ilE = global {{.*}} null, align 8 +// CHECK: @[[PARTLY_CONSTANT_OUTER:_ZGRN15partly_constant2ilE.*]] = private global {{.*}} zeroinitializer, align 8 +// CHECK: @[[PARTLY_CONSTANT_INNER:_ZGRN15partly_constant2ilE.*]] = private global [3 x {{.*}}] zeroinitializer, align 8 +// CHECK: @[[PARTLY_CONSTANT_FIRST:_ZGRN15partly_constant2ilE.*]] = private constant [3 x i32] [i32 1, i32 2, i32 3], align 4 +// CHECK: @[[PARTLY_CONSTANT_SECOND:_ZGRN15partly_constant2ilE.*]] = private global [2 x i32] zeroinitializer, align 4 +// CHECK: @[[PARTLY_CONSTANT_THIRD:_ZGRN15partly_constant2ilE.*]] = private constant [4 x i32] [i32 5, i32 6, i32 7, i32 8], align 4 + // CHECK: appending global -// CHECK: define internal void -// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 0 -// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 1 + + +// thread_local initializer: +// CHECK-LABEL: define internal void +// CHECK: store i32* getelementptr inbounds ([4 x i32]* @_ZGRN25thread_local_global_array1xE, i64 0, i64 0), +// CHECK: i32** getelementptr inbounds ({{.*}}* @_ZN25thread_local_global_array1xE, i32 0, i32 0), align 8 +// CHECK: store i64 4, i64* getelementptr inbounds ({{.*}}* @_ZN25thread_local_global_array1xE, i32 0, i32 1), align 8 + + +// CHECK-LABEL: define internal void +// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZGR15globalInitList2, i{{32|64}} 0, i{{32|64}} 0 +// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZGR15globalInitList2, i{{32|64}} 0, i{{32|64}} 1 // CHECK: __cxa_atexit +// CHECK: store %[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZGR15globalInitList2, i64 0, i64 0), +// CHECK: %[[WITHARG]]** getelementptr inbounds (%{{.*}}* @globalInitList2, i32 0, i32 0), align 8 +// CHECK: store i64 2, i64* getelementptr inbounds (%{{.*}}* @globalInitList2, i32 0, i32 1), align 8 // CHECK: call void @_ZN10destroyme1D1Ev // CHECK: call void @_ZN10destroyme1D1Ev std::initializer_list globalInitList2 = { @@ -71,7 +96,7 @@ std::initializer_list globalInitList2 = { }; void fn1(int i) { - // CHECK: define void @_Z3fn1i + // CHECK-LABEL: define void @_Z3fn1i // temporary array // CHECK: [[array:%[^ ]+]] = alloca [3 x i32] // CHECK: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0 @@ -91,7 +116,7 @@ void fn1(int i) { } void fn2() { - // CHECK: define void @_Z3fn2v + // CHECK-LABEL: define void @_Z3fn2v void target(std::initializer_list); // objects should be destroyed before dm2, after call returns // CHECK: call void @_Z6targetSt16initializer_listI10destroyme1E @@ -102,7 +127,7 @@ void fn2() { } void fn3() { - // CHECK: define void @_Z3fn3v + // CHECK-LABEL: define void @_Z3fn3v // objects should be destroyed after dm2 auto list = { destroyme1(), destroyme1() }; destroyme2 dm2; @@ -111,7 +136,7 @@ void fn3() { } void fn4() { - // CHECK: define void @_Z3fn4v + // CHECK-LABEL: define void @_Z3fn4v void target(std::initializer_list); // objects should be destroyed before dm2, after call returns // CHECK: call void @_ZN8witharg1C1ERK10destroyme1 @@ -124,7 +149,7 @@ void fn4() { } void fn5() { - // CHECK: define void @_Z3fn5v + // CHECK-LABEL: define void @_Z3fn5v // temps should be destroyed before dm2 // objects should be destroyed after dm2 // CHECK: call void @_ZN8witharg1C1ERK10destroyme1 @@ -136,7 +161,7 @@ void fn5() { } void fn6() { - // CHECK: define void @_Z3fn6v + // CHECK-LABEL: define void @_Z3fn6v void target(const wantslist1&); // objects should be destroyed before dm2, after call returns // CHECK: call void @_ZN10wantslist1C1ESt16initializer_listI10destroyme1E @@ -149,7 +174,7 @@ void fn6() { } void fn7() { - // CHECK: define void @_Z3fn7v + // CHECK-LABEL: define void @_Z3fn7v // temps should be destroyed before dm2 // object should be destroyed after dm2 // CHECK: call void @_ZN10wantslist1C1ESt16initializer_listI10destroyme1E @@ -161,7 +186,7 @@ void fn7() { } void fn8() { - // CHECK: define void @_Z3fn8v + // CHECK-LABEL: define void @_Z3fn8v void target(std::initializer_list>); // objects should be destroyed before dm2, after call returns // CHECK: call void @_Z6targetSt16initializer_listIS_I10destroyme1EE @@ -175,7 +200,7 @@ void fn8() { } void fn9() { - // CHECK: define void @_Z3fn9v + // CHECK-LABEL: define void @_Z3fn9v // objects should be destroyed after dm2 std::initializer_list inner; std::initializer_list> list = @@ -193,7 +218,7 @@ struct haslist1 { haslist1(); }; -// CHECK: define void @_ZN8haslist1C2Ev +// CHECK-LABEL: define void @_ZN8haslist1C2Ev haslist1::haslist1() // CHECK: alloca [3 x i32] // CHECK: store i32 1 @@ -210,7 +235,7 @@ struct haslist2 { haslist2(); }; -// CHECK: define void @_ZN8haslist2C2Ev +// CHECK-LABEL: define void @_ZN8haslist2C2Ev haslist2::haslist2() : il{destroyme1(), destroyme1()} { @@ -220,7 +245,7 @@ haslist2::haslist2() } void fn10() { - // CHECK: define void @_Z4fn10v + // CHECK-LABEL: define void @_Z4fn10v // CHECK: alloca [3 x i32] // CHECK: call noalias i8* @_Znw{{[jm]}} // CHECK: store i32 1 @@ -232,7 +257,7 @@ void fn10() { } void fn11() { - // CHECK: define void @_Z4fn11v + // CHECK-LABEL: define void @_Z4fn11v (void) new std::initializer_list {destroyme1(), destroyme1()}; // CHECK: call void @_ZN10destroyme1D1Ev destroyme2 dm2; @@ -260,7 +285,7 @@ namespace PR12178 { namespace rdar13325066 { struct X { ~X(); }; - // CHECK: define void @_ZN12rdar133250664loopERNS_1XES1_ + // CHECK-LABEL: define void @_ZN12rdar133250664loopERNS_1XES1_ void loop(X &x1, X &x2) { // CHECK: br label // CHECK: br i1 @@ -275,3 +300,134 @@ namespace rdar13325066 { for (X x : { x1, x2 }) { } } } + +namespace dtors { + struct S { + S(); + ~S(); + }; + void z(); + + // CHECK-LABEL: define void @_ZN5dtors1fEv( + void f() { + // CHECK: call void @_ZN5dtors1SC1Ev( + // CHECK: call void @_ZN5dtors1SC1Ev( + std::initializer_list{ S(), S() }; + + // Destruction loop for underlying array. + // CHECK: br label + // CHECK: call void @_ZN5dtors1SD1Ev( + // CHECK: br i1 + + // CHECK: call void @_ZN5dtors1zEv( + z(); + + // CHECK-NOT: call void @_ZN5dtors1SD1Ev( + } + + // CHECK-LABEL: define void @_ZN5dtors1gEv( + void g() { + // CHECK: call void @_ZN5dtors1SC1Ev( + // CHECK: call void @_ZN5dtors1SC1Ev( + auto x = std::initializer_list{ S(), S() }; + + // Destruction loop for underlying array. + // CHECK: br label + // CHECK: call void @_ZN5dtors1SD1Ev( + // CHECK: br i1 + + // CHECK: call void @_ZN5dtors1zEv( + z(); + + // CHECK-NOT: call void @_ZN5dtors1SD1Ev( + } + + // CHECK-LABEL: define void @_ZN5dtors1hEv( + void h() { + // CHECK: call void @_ZN5dtors1SC1Ev( + // CHECK: call void @_ZN5dtors1SC1Ev( + std::initializer_list x = { S(), S() }; + + // CHECK-NOT: call void @_ZN5dtors1SD1Ev( + + // CHECK: call void @_ZN5dtors1zEv( + z(); + + // Destruction loop for underlying array. + // CHECK: br label + // CHECK: call void @_ZN5dtors1SD1Ev( + // CHECK: br i1 + } +} + +namespace partly_constant { + int k; + std::initializer_list> &&il = { { 1, 2, 3 }, { 4, k }, { 5, 6, 7, 8 } }; + // First init list. + // CHECK-NOT: @[[PARTLY_CONSTANT_FIRST]], + // CHECK: store i32* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_FIRST]], i64 0, i64 0), + // CHECK: i32** getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_INNER]], i64 0, i64 0, i32 0) + // CHECK: store i64 3, i64* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_INNER]], i64 0, i64 0, i32 1) + // CHECK-NOT: @[[PARTLY_CONSTANT_FIRST]], + // + // Second init list array (non-constant). + // CHECK: store i32 4, i32* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_SECOND]], i64 0, i64 0) + // CHECK: load i32* @_ZN15partly_constant1kE + // CHECK: store i32 {{.*}}, i32* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_SECOND]], i64 0, i64 1) + // + // Second init list. + // CHECK: store i32* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_SECOND]], i64 0, i64 0), + // CHECK: i32** getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_INNER]], i64 0, i64 1, i32 0) + // CHECK: store i64 2, i64* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_INNER]], i64 0, i64 1, i32 1) + // + // Third init list. + // CHECK-NOT: @[[PARTLY_CONSTANT_THIRD]], + // CHECK: store i32* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_THIRD]], i64 0, i64 0), + // CHECK: i32** getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_INNER]], i64 0, i64 2, i32 0) + // CHECK: store i64 4, i64* getelementptr inbounds ({{.*}}* @_ZGRN15partly_constant2ilE4, i64 0, i64 2, i32 1) + // CHECK-NOT: @[[PARTLY_CONSTANT_THIRD]], + // + // Outer init list. + // CHECK: store {{.*}}* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_INNER]], i64 0, i64 0), + // CHECK: {{.*}}** getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_OUTER]], i32 0, i32 0) + // CHECK: store i64 3, i64* getelementptr inbounds ({{.*}}* @[[PARTLY_CONSTANT_OUTER]], i32 0, i32 1) + // + // 'il' reference. + // CHECK: store {{.*}}* @[[PARTLY_CONSTANT_OUTER]], {{.*}}** @_ZN15partly_constant2ilE, align 8 +} + +namespace nested { + struct A { A(); ~A(); }; + struct B { const A &a; ~B(); }; + struct C { std::initializer_list b; ~C(); }; + void f(); + // CHECK-LABEL: define void @_ZN6nested1gEv( + void g() { + // CHECK: call void @_ZN6nested1AC1Ev( + // CHECK-NOT: call + // CHECK: call void @_ZN6nested1AC1Ev( + // CHECK-NOT: call + const C &c { { { A() }, { A() } } }; + + // CHECK: call void @_ZN6nested1fEv( + // CHECK-NOT: call + f(); + + // CHECK: call void @_ZN6nested1CD1Ev( + // CHECK-NOT: call + + // Destroy B[2] array. + // FIXME: This isn't technically correct: reverse construction order would + // destroy the second B then the second A then the first B then the first A. + // CHECK: call void @_ZN6nested1BD1Ev( + // CHECK-NOT: call + // CHECK: br + + // CHECK-NOT: call + // CHECK: call void @_ZN6nested1AD1Ev( + // CHECK-NOT: call + // CHECK: call void @_ZN6nested1AD1Ev( + // CHECK-NOT: call + // CHECK: } + } +} diff --git a/test/CodeGenCXX/cxx11-exception-spec.cpp b/test/CodeGenCXX/cxx11-exception-spec.cpp index 49ca861..96ea1d7 100644 --- a/test/CodeGenCXX/cxx11-exception-spec.cpp +++ b/test/CodeGenCXX/cxx11-exception-spec.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s +// RUN: not %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s void h(); diff --git a/test/CodeGenCXX/cxx11-initializer-array-new.cpp b/test/CodeGenCXX/cxx11-initializer-array-new.cpp new file mode 100644 index 0000000..23577be --- /dev/null +++ b/test/CodeGenCXX/cxx11-initializer-array-new.cpp @@ -0,0 +1,106 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 %s -emit-llvm -o - | FileCheck %s + +// PR10878 + +struct S { S(); S(int); ~S(); int n; }; + +void *p = new S[2][3]{ { 1, 2, 3 }, { 4, 5, 6 } }; + +// CHECK-LABEL: define +// CHECK: %[[ALLOC:.*]] = call noalias i8* @_Znam(i64 32) +// CHECK: %[[COOKIE:.*]] = bitcast i8* %[[ALLOC]] to i64* +// CHECK: store i64 6, i64* %[[COOKIE]] +// CHECK: %[[START_AS_i8:.*]] = getelementptr inbounds i8* %[[ALLOC]], i64 8 +// CHECK: %[[START_AS_S:.*]] = bitcast i8* %[[START_AS_i8]] to %[[S:.*]]* +// +// Explicit initializers: +// +// { 1, 2, 3 } +// +// CHECK: %[[S_0:.*]] = bitcast %[[S]]* %[[START_AS_S]] to [3 x %[[S]]]* +// +// CHECK: %[[S_0_0:.*]] = getelementptr inbounds [3 x %[[S]]]* %[[S_0]], i64 0, i64 0 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_0_0]], i32 1) +// CHECK: %[[S_0_1:.*]] = getelementptr inbounds %[[S]]* %[[S_0_0]], i64 1 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_0_1]], i32 2) +// CHECK: %[[S_0_2:.*]] = getelementptr inbounds %[[S]]* %[[S_0_1]], i64 1 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_0_2]], i32 3) +// +// { 4, 5, 6 } +// +// CHECK: %[[S_1:.*]] = getelementptr [3 x %[[S]]]* %[[S_0]], i32 1 +// +// CHECK: %[[S_1_0:.*]] = getelementptr inbounds [3 x %[[S]]]* %[[S_1]], i64 0, i64 0 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_1_0]], i32 4) +// CHECK: %[[S_1_1:.*]] = getelementptr inbounds %[[S]]* %[[S_1_0]], i64 1 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_1_1]], i32 5) +// CHECK: %[[S_1_2:.*]] = getelementptr inbounds %[[S]]* %[[S_1_1]], i64 1 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_1_2]], i32 6) +// +// CHECK-NOT: br i1 +// CHECK-NOT: call +// CHECK: } + +int n; +void *q = new S[n][3]{ { 1, 2, 3 }, { 4, 5, 6 } }; + +// CHECK-LABEL: define +// +// CHECK: load i32* @n +// CHECK: call {{.*}} @llvm.umul.with.overflow.i64(i64 %[[N:.*]], i64 12) +// CHECK: %[[ELTS:.*]] = mul i64 %[[N]], 3 +// CHECK: call {{.*}} @llvm.uadd.with.overflow.i64(i64 %{{.*}}, i64 8) +// CHECK: %[[ALLOC:.*]] = call noalias i8* @_Znam(i64 %{{.*}}) +// +// CHECK: %[[COOKIE:.*]] = bitcast i8* %[[ALLOC]] to i64* +// CHECK: store i64 %[[ELTS]], i64* %[[COOKIE]] +// CHECK: %[[START_AS_i8:.*]] = getelementptr inbounds i8* %[[ALLOC]], i64 8 +// CHECK: %[[START_AS_S:.*]] = bitcast i8* %[[START_AS_i8]] to %[[S]]* +// CHECK: %[[END_AS_S:.*]] = getelementptr inbounds %[[S]]* %[[START_AS_S]], i64 %[[ELTS]] +// +// Explicit initializers: +// +// { 1, 2, 3 } +// +// CHECK: %[[S_0:.*]] = bitcast %[[S]]* %[[START_AS_S]] to [3 x %[[S]]]* +// +// CHECK: %[[S_0_0:.*]] = getelementptr inbounds [3 x %[[S]]]* %[[S_0]], i64 0, i64 0 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_0_0]], i32 1) +// CHECK: %[[S_0_1:.*]] = getelementptr inbounds %[[S]]* %[[S_0_0]], i64 1 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_0_1]], i32 2) +// CHECK: %[[S_0_2:.*]] = getelementptr inbounds %[[S]]* %[[S_0_1]], i64 1 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_0_2]], i32 3) +// +// { 4, 5, 6 } +// +// CHECK: %[[S_1:.*]] = getelementptr [3 x %[[S]]]* %[[S_0]], i32 1 +// +// CHECK: %[[S_1_0:.*]] = getelementptr inbounds [3 x %[[S]]]* %[[S_1]], i64 0, i64 0 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_1_0]], i32 4) +// CHECK: %[[S_1_1:.*]] = getelementptr inbounds %[[S]]* %[[S_1_0]], i64 1 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_1_1]], i32 5) +// CHECK: %[[S_1_2:.*]] = getelementptr inbounds %[[S]]* %[[S_1_1]], i64 1 +// CHECK: call void @_ZN1SC1Ei(%[[S]]* %[[S_1_2]], i32 6) +// +// CHECK: %[[S_2:.*]] = getelementptr [3 x %[[S]]]* %[[S_1]], i32 1 +// CHECK: %[[S_2_AS_S:.*]] = bitcast [3 x %[[S]]]* %[[S_2]] to %[[S]]* +// CHECK: icmp eq %[[S]]* %[[S_2_AS_S]], %[[END_AS_S]] +// CHECK: br i1 +// +// S[n-2][3] initialization loop: +// +// CHECK: %[[END_INNER:.*]] = getelementptr inbounds %[[S]]* %{{.*}}, i64 3 +// CHECK: br label +// +// S[3] initialization loop: +// +// CHECK: call void @_ZN1SC1Ev(%[[S]]* +// CHECK: %[[NEXT_INNER:.*]] = getelementptr inbounds %[[S]]* %{{.*}}, i64 1 +// CHECK: icmp eq %[[S]]* %[[NEXT_INNER]], %[[END_INNER]] +// CHECK: br i1 +// +// CHECK: %[[NEXT_OUTER:.*]] = getelementptr %[[S]]* %{{.*}}, i32 1 +// CHECK: icmp eq %[[S]]* %[[NEXT_OUTER]], %[[END_AS_S]] +// CHECK: br i1 +// +// CHECK: } diff --git a/test/CodeGenCXX/cxx11-thread-local-reference.cpp b/test/CodeGenCXX/cxx11-thread-local-reference.cpp index 2ea9acd..7759d41 100644 --- a/test/CodeGenCXX/cxx11-thread-local-reference.cpp +++ b/test/CodeGenCXX/cxx11-thread-local-reference.cpp @@ -13,7 +13,7 @@ int &g() { return r; } // CHECK: call i32* @_Z1fv() // CHECK: store i32* %{{.*}}, i32** @r, align 8 -// CHECK: define i32* @_Z1gv() +// CHECK-LABEL: define i32* @_Z1gv() // CHECK: call i32* @_ZTW1r() // CHECK: ret i32* %{{.*}} @@ -22,5 +22,5 @@ int &g() { return r; } // CHECK: load i32** @r, align 8 // CHECK: ret i32* %{{.*}} -// CHECK: define internal void @__tls_init() +// CHECK-LABEL: define internal void @__tls_init() // CHECK: call void @[[R_INIT]]() diff --git a/test/CodeGenCXX/cxx11-thread-local.cpp b/test/CodeGenCXX/cxx11-thread-local.cpp index a7141d1..509562d 100644 --- a/test/CodeGenCXX/cxx11-thread-local.cpp +++ b/test/CodeGenCXX/cxx11-thread-local.cpp @@ -35,7 +35,7 @@ int e = V::m; // CHECK: @_ZZ8tls_dtorvE1u = internal thread_local global // CHECK: @_ZGVZ8tls_dtorvE1u = internal thread_local global i8 0 -// CHECK: @_ZGRZ8tls_dtorvE1u = internal thread_local global +// CHECK: @_ZGRZ8tls_dtorvE1u = private thread_local global // CHECK: @_ZGVN1VIiE1mE = weak_odr thread_local global i64 0 @@ -55,7 +55,7 @@ int e = V::m; // CHECK: call i32 @_Z1fv() // CHECK-NEXT: store i32 {{.*}}, i32* @a, align 4 -// CHECK: define i32 @_Z1fv() +// CHECK-LABEL: define i32 @_Z1fv() int f() { // CHECK: %[[GUARD:.*]] = load i8* @_ZGVZ1fvE1n, align 1 // CHECK: %[[NEED_INIT:.*]] = icmp eq i8 %[[GUARD]], 0 @@ -76,7 +76,7 @@ int f() { // CHECK-NEXT: load i32* %{{.*}}, align 4 // CHECK-NEXT: store i32 %{{.*}}, i32* @c, align 4 -// CHECK: define weak_odr hidden i32* @_ZTW1b() +// CHECK-LABEL: define weak_odr hidden i32* @_ZTW1b() // CHECK: br i1 icmp ne (void ()* @_ZTH1b, void ()* null), // not null: // CHECK: call void @_ZTH1b() @@ -97,7 +97,7 @@ int f() { // CHECK-NEXT: load i32* %{{.*}}, align 4 // CHECK-NEXT: store i32 %{{.*}}, i32* @e, align 4 -// CHECK: define weak_odr hidden i32* @_ZTWN1VIiE1mE() +// CHECK-LABEL: define weak_odr hidden i32* @_ZTWN1VIiE1mE() // CHECK: call void @_ZTHN1VIiE1mE() // CHECK: ret i32* @_ZN1VIiE1mE @@ -105,7 +105,7 @@ int f() { struct S { S(); ~S(); }; struct T { ~T(); }; -// CHECK: define void @_Z8tls_dtorv() +// CHECK-LABEL: define void @_Z8tls_dtorv() void tls_dtor() { // CHECK: load i8* @_ZGVZ8tls_dtorvE1s // CHECK: call void @_ZN1SC1Ev(%struct.S* @_ZZ8tls_dtorvE1s) @@ -128,6 +128,13 @@ void tls_dtor() { // CHECK: declare i32 @__cxa_thread_atexit(void (i8*)*, i8*, i8*) +// CHECK: define {{.*}} @_Z7PR15991v( +int PR15991() { + thread_local int n; + auto l = [] { return n; }; + return l(); +} + // CHECK: define {{.*}} @[[V_M_INIT:.*]]() // CHECK: load i8* bitcast (i64* @_ZGVN1VIiE1mE to i8*) // CHECK: %[[V_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0 @@ -164,10 +171,10 @@ void tls_dtor() { // CHECK: declare extern_weak void @_ZTH1b() -// CHECK: define internal hidden i32* @_ZTWL1d() +// CHECK-LABEL: define internal hidden i32* @_ZTWL1d() // CHECK: call void @_ZTHL1d() // CHECK: ret i32* @_ZL1d -// CHECK: define weak_odr hidden i32* @_ZTWN1U1mE() +// CHECK-LABEL: define weak_odr hidden i32* @_ZTWN1U1mE() // CHECK: call void @_ZTHN1U1mE() // CHECK: ret i32* @_ZN1U1mE diff --git a/test/CodeGenCXX/cxx1y-deduced-return-type.cpp b/test/CodeGenCXX/cxx1y-deduced-return-type.cpp new file mode 100644 index 0000000..6d15a22 --- /dev/null +++ b/test/CodeGenCXX/cxx1y-deduced-return-type.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -std=c++1y -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s + +// CHECK: @x = global {{.*}} zeroinitializer + +// CHECK: define {{.*}} @_Z1fv +inline auto f() { + int n = 0; + // CHECK: load i32 + // CHECK: store i32 + // CHECK: ret + return [=] () mutable { return ++n; }; +} + +auto x = f(); + +template auto *g(T t) { return t; } +template decltype(auto) h(T t) { return t; } + +// CHECK: define {{.*}} @_Z1zv +void z() { + // CHECK: call {{.*}} @_Z1gIPZ1fvEUlvE_EPDaT_( + // CHECK: call {{.*}} @_Z1hIPZ1fvEUlvE_EDcT_( + g(&x); + h(&x); +} + +auto i() { return [] {}; } +// CHECK: define {{.*}} @_Z1jv +auto j() { + // CHECK: call {{.*}} @"_Z1hIZ1ivE3$_0EDcT_"() + h(i()); +} diff --git a/test/CodeGenCXX/cxx1y-init-captures.cpp b/test/CodeGenCXX/cxx1y-init-captures.cpp new file mode 100644 index 0000000..a60269f --- /dev/null +++ b/test/CodeGenCXX/cxx1y-init-captures.cpp @@ -0,0 +1,102 @@ +// RUN: %clang_cc1 -std=c++1y -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s + +struct S { + S(); + S(S &&); + ~S(); +}; + +void f() { + (void) [s(S{})] {}; +} + +// CHECK-LABEL: define void @_Z1fv( +// CHECK: call void @_ZN1SC1Ev( +// CHECK: call void @"_ZZ1fvEN3$_0D1Ev"( + +// CHECK-LABEL: define internal void @"_ZZ1fvEN3$_0D1Ev"( +// CHECK: @"_ZZ1fvEN3$_0D2Ev"( + +// D2 at end of file. + +void g() { + [a(1), b(2)] { return a + b; } (); +} + +// CHECK-LABEL: define void @_Z1gv( +// CHECK: getelementptr inbounds {{.*}}, i32 0, i32 0 +// CHECK: store i32 1, i32* +// CHECK: getelementptr inbounds {{.*}}, i32 0, i32 1 +// CHECK: store i32 2, i32* +// CHECK: call i32 @"_ZZ1gvENK3$_1clEv"( + +// CHECK-LABEL: define internal i32 @"_ZZ1gvENK3$_1clEv"( +// CHECK: getelementptr inbounds {{.*}}, i32 0, i32 0 +// CHECK: load i32* +// CHECK: getelementptr inbounds {{.*}}, i32 0, i32 1 +// CHECK: load i32* +// CHECK: add nsw i32 + +int h(int a) { + // CHECK-LABEL: define i32 @_Z1hi( + // CHECK: %[[A_ADDR:.*]] = alloca i32, + // CHECK: %[[OUTER:.*]] = alloca + // CHECK: store i32 {{.*}}, i32* %[[A_ADDR]], + // + // Initialize init-capture 'b(a)' by reference. + // CHECK: getelementptr inbounds {{.*}}* %[[OUTER]], i32 0, i32 0 + // CHECK: store i32* %[[A_ADDR]], i32** {{.*}}, + // + // Initialize init-capture 'c(a)' by copy. + // CHECK: getelementptr inbounds {{.*}}* %[[OUTER]], i32 0, i32 1 + // CHECK: load i32* %[[A_ADDR]], + // CHECK: store i32 + // + // CHECK: call i32 @"_ZZ1hiENK3$_2clEv"({{.*}}* %[[OUTER]]) + return [&b(a), c(a)] { + // CHECK-LABEL: define internal i32 @"_ZZ1hiENK3$_2clEv"( + // CHECK: %[[OUTER_ADDR:.*]] = alloca + // CHECK: %[[INNER:.*]] = alloca + // CHECK: store {{.*}}, {{.*}}** %[[OUTER_ADDR]], + // + // Capture outer 'c' by reference. + // CHECK: %[[OUTER:.*]] = load {{.*}}** %[[OUTER_ADDR]] + // CHECK: getelementptr inbounds {{.*}}* %[[INNER]], i32 0, i32 0 + // CHECK-NEXT: getelementptr inbounds {{.*}}* %[[OUTER]], i32 0, i32 1 + // CHECK-NEXT: store i32* % + // + // Capture outer 'b' by copy. + // CHECK: getelementptr inbounds {{.*}}* %[[INNER]], i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds {{.*}}* %[[OUTER]], i32 0, i32 0 + // CHECK-NEXT: load i32** % + // CHECK-NEXT: load i32* % + // CHECK-NEXT: store i32 + // + // CHECK: call i32 @"_ZZZ1hiENK3$_2clEvENKUlvE_clEv"({{.*}}* %[[INNER]]) + return [=, &c] { + // CHECK-LABEL: define internal i32 @"_ZZZ1hiENK3$_2clEvENKUlvE_clEv"( + // CHECK: %[[INNER_ADDR:.*]] = alloca + // CHECK: store {{.*}}, {{.*}}** %[[INNER_ADDR]], + // CHECK: %[[INNER:.*]] = load {{.*}}** %[[INNER_ADDR]] + // + // Load capture of 'b' + // CHECK: getelementptr inbounds {{.*}}* %[[INNER]], i32 0, i32 1 + // CHECK: load i32* % + // + // Load capture of 'c' + // CHECK: getelementptr inbounds {{.*}}* %[[INNER]], i32 0, i32 0 + // CHECK: load i32** % + // CHECK: load i32* % + // + // CHECK: add nsw i32 + return b + c; + } (); + } (); +} + +// Ensure we can emit code for init-captures in global lambdas too. +auto global_lambda = [a = 0] () mutable { return ++a; }; +int get_incremented() { return global_lambda(); } + +// CHECK-LABEL: define internal void @"_ZZ1fvEN3$_0D2Ev"( +// CHECK: call void @_ZN1SD1Ev( diff --git a/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp b/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp index ef78c43..ae49a04 100644 --- a/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp +++ b/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp @@ -25,7 +25,11 @@ A b { 4, "bazquux", .x = 42, .c = 9 }; A c { 1, 0, 'A', f(), { 3 } }; // CHECK: @[[STR_A:.*]] = {{.*}} [7 x i8] c"foobar\00" +// CHECK: @a = global {{.*}} zeroinitializer + +// @b has a constant initializer // CHECK: @[[STR_B:.*]] = {{.*}} [8 x i8] c"bazquux\00" +// CHECK: @b = global {{.*}} i32 4, {{.*}} @[[STR_B]], {{.*}} i8 117, i32 42, {{.*}} i8 9 B x; B y {}; @@ -44,18 +48,9 @@ B z { 1 }; // CHECK: store i32 %{{.*}}, i32* getelementptr inbounds ({{.*}}* @a, i32 0, i32 3) // CHECK: call void @{{.*}}C1Ev({{.*}} getelementptr inbounds (%struct.A* @a, i32 0, i32 4)) -// Initialization of 'b': +// No dynamic initialization of 'b': -// CHECK: store i32 4, i32* getelementptr inbounds ({{.*}} @b, i32 0, i32 0) -// CHECK: store i8* {{.*}} @[[STR_B]]{{.*}}, i8** getelementptr inbounds ({{.*}} @b, i32 0, i32 1) -// CHECK: load i32* getelementptr inbounds ({{.*}} @b, i32 0, i32 0) -// CHECK: load i8** getelementptr inbounds ({{.*}} @b, i32 0, i32 1) -// CHECK: getelementptr inbounds i8* %{{.*}}, {{.*}} %{{.*}} -// CHECK: store i8 %{{.*}}, i8* getelementptr inbounds ({{.*}} @b, i32 0, i32 2) -// CHECK-NOT: @_ZN1A1fEv -// CHECK: store i32 42, i32* getelementptr inbounds ({{.*}}* @b, i32 0, i32 3) -// CHECK-NOT: C1Ev -// CHECK: store i8 9, i8* {{.*}} @b, i32 0, i32 4) +// CHECK-NOT: @b // Initialization of 'c': diff --git a/test/CodeGenCXX/cxx1y-sized-deallocation.cpp b/test/CodeGenCXX/cxx1y-sized-deallocation.cpp new file mode 100644 index 0000000..7fd3ece --- /dev/null +++ b/test/CodeGenCXX/cxx1y-sized-deallocation.cpp @@ -0,0 +1,110 @@ +// RUN: %clang_cc1 -std=c++1y %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED + +// CHECK-UNSIZED-NOT: _ZdlPvm +// CHECK-UNSIZED-NOT: _ZdaPvm + +typedef decltype(sizeof(0)) size_t; + +typedef int A; +struct B { int n; }; +struct C { ~C() {} }; +struct D { D(); virtual ~D() {} }; +struct E { + void *operator new(size_t); + void *operator new[](size_t); + void operator delete(void *) noexcept; + void operator delete[](void *) noexcept; +}; +struct F { + void *operator new(size_t); + void *operator new[](size_t); + void operator delete(void *, size_t) noexcept; + void operator delete[](void *, size_t) noexcept; +}; + +template T get(); + +template +void del() { + ::delete get(); + ::delete[] get(); + delete get(); + delete[] get(); +} + +template void del(); +template void del(); +template void del(); +template void del(); +template void del(); +template void del(); + +D::D() {} + +// CHECK-LABEL: define weak_odr void @_Z3delIiEvv() +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4) +// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}}) +// +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4) +// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}}) + +// CHECK-LABEL: define linkonce void @_ZdlPvm(i8* +// CHECK: call void @_ZdlPv(i8* %0) + +// CHECK-LABEL: define weak_odr void @_Z3delI1BEvv() +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4) +// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}}) +// +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4) +// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}}) + +// CHECK-LABEL: define weak_odr void @_Z3delI1CEvv() +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1) +// CHECK: mul i64 1, %{{[^ ]*}} +// CHECK: add i64 %{{[^ ]*}}, 8 +// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}}) +// +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1) +// CHECK: mul i64 1, %{{[^ ]*}} +// CHECK: add i64 %{{[^ ]*}}, 8 +// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}}) + +// CHECK-LABEL: define linkonce void @_ZdaPvm(i8* +// CHECK: call void @_ZdaPv(i8* %0) + +// CHECK-LABEL: define weak_odr void @_Z3delI1DEvv() +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 8) +// CHECK: mul i64 8, %{{[^ ]*}} +// CHECK: add i64 %{{[^ ]*}}, 8 +// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}}) +// +// CHECK-NOT: Zdl +// CHECK: call void %{{.*}} +// CHECK-NOT: Zdl +// CHECK: mul i64 8, %{{[^ ]*}} +// CHECK: add i64 %{{[^ ]*}}, 8 +// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}}) + +// CHECK-LABEL: define weak_odr void @_Z3delI1EEvv() +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1) +// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}}) +// +// CHECK: call void @_ZN1EdlEPv(i8* %{{[^ ]*}}) +// CHECK: call void @_ZN1EdaEPv(i8* %{{[^ ]*}}) + +// CHECK-LABEL: define weak_odr void @_Z3delI1FEvv() +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1) +// CHECK: mul i64 1, %{{[^ ]*}} +// CHECK: add i64 %{{[^ ]*}}, 8 +// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}}) +// +// CHECK: call void @_ZN1FdlEPvm(i8* %{{[^ ]*}}, i64 1) +// CHECK: mul i64 1, %{{[^ ]*}} +// CHECK: add i64 %{{[^ ]*}}, 8 +// CHECK: call void @_ZN1FdaEPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}}) + + +// CHECK-LABEL: define linkonce_odr void @_ZN1DD0Ev(%{{[^ ]*}}* %this) +// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 8) diff --git a/test/CodeGenCXX/cxx1y-variable-template.cpp b/test/CodeGenCXX/cxx1y-variable-template.cpp new file mode 100644 index 0000000..d1e7060 --- /dev/null +++ b/test/CodeGenCXX/cxx1y-variable-template.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -std=c++1y -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s + +// Check that we keep the 'extern' when we instantiate the definition of this +// variable template specialization. +template extern const int extern_redecl; +template const int extern_redecl = 5; +template const int extern_redecl; + +// CHECK: @_Z13extern_redeclIiE = weak_odr constant + +template struct Outer { + template struct Inner { + template static int arr[]; + }; +}; +Outer outer_int; +int init_arr(); +template template template int Outer::Inner::arr[sizeof(T) + sizeof(U) + sizeof(V)] = { init_arr() }; +int *p = Outer::Inner::arr; + +// CHECK: @_ZN5OuterIA100_cE5InnerIA20_cE3arrIA3_cEE = weak_odr global [123 x i32] zeroinitializer +// CHECK: @_ZGVN5OuterIA100_cE5InnerIA20_cE3arrIA3_cEE = weak_odr global + +// CHECK: call {{.*}}@_Z8init_arrv diff --git a/test/CodeGenCXX/debug-info-artificial-arg.cpp b/test/CodeGenCXX/debug-info-artificial-arg.cpp index ff0f663..84f496f 100644 --- a/test/CodeGenCXX/debug-info-artificial-arg.cpp +++ b/test/CodeGenCXX/debug-info-artificial-arg.cpp @@ -22,8 +22,8 @@ int main(int argc, char **argv) { A reallyA (500); } -// CHECK: ![[ARTARG:.*]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from A] -// CHECK: ![[CLASSTYPE:.*]] = {{.*}} ; [ DW_TAG_class_type ] [A] -// CHECK: metadata ![[CLASSTYPE]], {{.*}} ; [ DW_TAG_subprogram ] [line 12] [A] -// CHECK: metadata [[FUNCTYPE:![0-9]*]], i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +// CHECK: ![[CLASSTYPE:.*]] = {{.*}}, metadata !"_ZTS1A"} ; [ DW_TAG_class_type ] [A] +// CHECK: ![[ARTARG:.*]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A] +// CHECK: metadata !"_ZTS1A", {{.*}} ; [ DW_TAG_subprogram ] [line 12] [A] +// CHECK: metadata [[FUNCTYPE:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] // CHECK: [[FUNCTYPE]] = metadata !{null, metadata ![[ARTARG]], metadata !{{.*}}, metadata !{{.*}}} diff --git a/test/CodeGenCXX/debug-info-class-limited.cpp b/test/CodeGenCXX/debug-info-class-limited.cpp new file mode 100644 index 0000000..a4b9f46 --- /dev/null +++ b/test/CodeGenCXX/debug-info-class-limited.cpp @@ -0,0 +1,52 @@ +// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s + +namespace PR16214_1 { +// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def] +struct foo { + int i; +}; + +typedef foo bar; + +bar *a; +bar b; +} + +namespace PR14467 { +// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def] +struct foo { +}; + +foo *bar(foo *a) { + foo *b = new foo(*a); + return b; +} +} + +namespace test1 { +// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [decl] +struct foo { +}; + +extern int bar(foo *a); +int baz(foo *a) { + return bar(a); +} +} + +namespace test2 { +// FIXME: if we were a bit fancier, we could realize that the 'foo' type is only +// required because of the 'bar' type which is not required at all (or might +// only be required to be declared) +// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def] +struct foo { +}; + +struct bar { + foo f; +}; + +void func() { + foo *f; +} +} diff --git a/test/CodeGenCXX/debug-info-class-nolimit.cpp b/test/CodeGenCXX/debug-info-class-nolimit.cpp new file mode 100644 index 0000000..ce72bd3 --- /dev/null +++ b/test/CodeGenCXX/debug-info-class-nolimit.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple x86_64-unk-unk -fno-limit-debug-info -o - -emit-llvm -g %s | FileCheck %s + +namespace rdar14101097_1 { // see also PR16214 +// Check that we emit debug info for the definition of a struct if the +// definition is available, even if it's used via a pointer wrapped in a +// typedef. +// CHECK: [ DW_TAG_structure_type ] [foo] {{.*}}[def] +struct foo { +}; + +typedef foo *foop; + +void bar() { + foop f; +} +} + +namespace rdar14101097_2 { +// As above, except trickier because we first encounter only a declaration of +// the type and no debug-info related use after we see the definition of the +// type. +// CHECK: [ DW_TAG_structure_type ] [foo] {{.*}}[def] +struct foo; +void bar() { + foo *f; +} +struct foo { +}; +} + diff --git a/test/CodeGenCXX/debug-info-class.cpp b/test/CodeGenCXX/debug-info-class.cpp index df24926..e1402c9 100644 --- a/test/CodeGenCXX/debug-info-class.cpp +++ b/test/CodeGenCXX/debug-info-class.cpp @@ -12,6 +12,51 @@ class B { public: virtual ~B(); }; + +B::~B() { +} + +struct C { + static int s; + virtual ~C(); +}; + +C::~C() { +} + +struct D { + D(); + virtual ~D(); + void func() { + } +}; + +struct E { + E(); + virtual ~E(); + virtual void func() { + } +}; + +struct F { + struct inner { + }; + static const int i = 2; + virtual ~F(); +}; + +struct G { + virtual void func(); + struct inner { + int j; + }; +}; + +struct H {}; +struct I : virtual H {}; +struct J : I {}; +J j; + struct A { int one; static const int HdrSize = 52; @@ -21,9 +66,17 @@ struct A { } }; +void f1() { + D x; + x.func(); + E y; + int i = F::i; + F::inner z; +} int main(int argc, char **argv) { B b; + G::inner c_i; if (argc) { A a; } @@ -40,9 +93,33 @@ int main(int argc, char **argv) { // CHECK: DW_TAG_structure_type ] [foo] // CHECK: DW_TAG_class_type ] [bar] // CHECK: DW_TAG_union_type ] [baz] -// CHECK: DW_TAG_structure_type ] [A] -// CHECK: HdrSize -// CHECK: DW_TAG_class_type ] [B] +// CHECK: DW_TAG_class_type ] [B] {{.*}} [def] // CHECK: metadata !"_vptr$B", {{.*}}, i32 64, metadata !{{.*}}} ; [ DW_TAG_member ] -// CHECK: ![[EXCEPTLOC]] = metadata !{i32 31, -// CHECK: ![[RETLOC]] = metadata !{i32 30, + +// CHECK: [[C:![0-9]*]] = {{.*}} metadata [[C_MEM:![0-9]*]], i32 0, metadata !"_ZTS1C", null, metadata !"_ZTS1C"} ; [ DW_TAG_structure_type ] [C] {{.*}} [def] +// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_S:![0-9]*]], metadata [[C_DTOR:![0-9]*]]} +// CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$C] {{.*}} [artificial] +// CHECK: [[C_S]] = {{.*}} ; [ DW_TAG_member ] [s] {{.*}} [static] [from int] +// CHECK: [[C_DTOR]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [~C] + +// CHECK: metadata [[D_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS1D"} ; [ DW_TAG_structure_type ] [D] {{.*}} [decl] +// CHECK: [[D_MEM]] = metadata !{metadata [[D_FUNC:![0-9]*]]} +// CHECK: [[D_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func] +// CHECK: null, i32 0, null, null, metadata !"_ZTS1E"} ; [ DW_TAG_structure_type ] [E] {{.*}} [decl] +// CHECK: [[F:![0-9]*]] = {{.*}} metadata [[F_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS1F"} ; [ DW_TAG_structure_type ] [F] {{.*}} [decl] +// CHECK: [[F_MEM]] = metadata !{metadata [[F_I:![0-9]*]]} +// CHECK: [[F_I]] = {{.*}} ; [ DW_TAG_member ] [i] + +// CHECK: null, i32 0, null, null, metadata !"_ZTS1G"} ; [ DW_TAG_structure_type ] [G] {{.*}} [decl] +// CHECK: metadata [[G_INNER_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTSN1G5innerE"} ; [ DW_TAG_structure_type ] [inner] [line 50, {{.*}} [def] +// CHECK: [[G_INNER_MEM]] = metadata !{metadata [[G_INNER_I:![0-9]*]]} +// CHECK: [[G_INNER_I]] = {{.*}} ; [ DW_TAG_member ] [j] {{.*}} [from int] + +// CHECK: ; [ DW_TAG_structure_type ] [A] +// CHECK: HdrSize +// CHECK: ; [ DW_TAG_structure_type ] [I] {{.*}} [def] + +// CHECK: [[F_I_DEF:![0-9]*]] = {{.*}}, metadata [[F_I]]} ; [ DW_TAG_variable ] [i] + +// CHECK: ![[EXCEPTLOC]] = metadata !{i32 84, +// CHECK: ![[RETLOC]] = metadata !{i32 83, diff --git a/test/CodeGenCXX/debug-info-cxx1y.cpp b/test/CodeGenCXX/debug-info-cxx1y.cpp new file mode 100644 index 0000000..3cb7e45 --- /dev/null +++ b/test/CodeGenCXX/debug-info-cxx1y.cpp @@ -0,0 +1,7 @@ +// RUN: not %clang_cc1 -emit-llvm-only -std=c++1y -g %s 2>&1 | FileCheck %s + +struct foo { + auto func(); // CHECK: error: debug information for auto is not yet supported +}; + +foo f; diff --git a/test/CodeGenCXX/debug-info-decl-nested.cpp b/test/CodeGenCXX/debug-info-decl-nested.cpp new file mode 100644 index 0000000..f79a8e9 --- /dev/null +++ b/test/CodeGenCXX/debug-info-decl-nested.cpp @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -std=c++11 -g -emit-llvm -g -triple x86_64-apple-darwin %s -o %t +// RUN: cat %t | FileCheck %s -check-prefix=CHECK0 +// RUN: cat %t | FileCheck %s -check-prefix=CHECK1 +// RUN: cat %t | FileCheck %s -check-prefix=CHECK2 +// +// This test ensures that we associate a declaration with the +// definition of the constructor for OuterClass. The declaration is +// necessary so the backend can emit the DW_AT_specification attribute +// for the definition. +// +// rdar://problem/13116508 + +class Foo; +class OuterClass +{ + static class InnerClass { + public: + InnerClass(); // Here createContextChain() generates a limited type for OuterClass. + } theInnerClass; +// CHECK0: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [private] [OuterClass] + OuterClass(const Foo *); // line 10 +}; +OuterClass::InnerClass OuterClass::theInnerClass; // This toplevel decl causes InnerClass to be generated. +// CHECK0: metadata {{.*}}, metadata ![[DECL]], metadata {{.*}}, i32 [[@LINE+1]]} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [OuterClass] +OuterClass::OuterClass(const Foo *meta) { } // line 13 + + + + + +class Foo1; +class OuterClass1 +{ + static class InnerClass1 { + public: + InnerClass1(); + } theInnerClass1; +// CHECK1: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+2]]] [private] [Bar] +// CHECK1: metadata {{.*}}, metadata ![[DECL]], metadata {{.*}}, i32 [[@LINE+4]]} ; [ DW_TAG_subprogram ] [line [[@LINE+4]]] [def] [Bar] + void Bar(const Foo1 *); +}; +OuterClass1::InnerClass1 OuterClass1::theInnerClass1; +void OuterClass1::Bar(const Foo1 *meta) { } + + + + + +class Foo2; +class OuterClass2 +{ + static class InnerClass2 { + public: + InnerClass2(); + } theInnerClass2; +// CHECK2: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [private] [~OuterClass2] + ~OuterClass2(); // line 10 +}; +OuterClass2::InnerClass2 OuterClass2::theInnerClass2; +// CHECK2: metadata {{.*}}, metadata ![[DECL]], metadata {{.*}}, i32 [[@LINE+1]]} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [~OuterClass2] +OuterClass2::~OuterClass2() { } diff --git a/test/CodeGenCXX/debug-info-enum-class.cpp b/test/CodeGenCXX/debug-info-enum-class.cpp index 929327b..0f4b09a 100644 --- a/test/CodeGenCXX/debug-info-enum-class.cpp +++ b/test/CodeGenCXX/debug-info-enum-class.cpp @@ -9,10 +9,10 @@ B b; C c; D d; -// CHECK: ; [ DW_TAG_enumeration_type ] [A] [line 3, size 32, align 32, offset 0] [from int] -// CHECK: ; [ DW_TAG_enumeration_type ] [B] [line 4, size 64, align 64, offset 0] [from long unsigned int] -// CHECK: ; [ DW_TAG_enumeration_type ] [C] [line 5, size 32, align 32, offset 0] [from ] -// CHECK: ; [ DW_TAG_enumeration_type ] [D] [line 6, size 16, align 16, offset 0] [fwd] [from ] +// CHECK: ; [ DW_TAG_enumeration_type ] [A] [line 3, size 32, align 32, offset 0] [def] [from int] +// CHECK: ; [ DW_TAG_enumeration_type ] [B] [line 4, size 64, align 64, offset 0] [def] [from long unsigned int] +// CHECK: ; [ DW_TAG_enumeration_type ] [C] [line 5, size 32, align 32, offset 0] [def] [from ] +// CHECK: ; [ DW_TAG_enumeration_type ] [D] [line 6, size 16, align 16, offset 0] [decl] [from ] namespace PR14029 { // Make sure this doesn't crash/assert. diff --git a/test/CodeGenCXX/debug-info-enum.cpp b/test/CodeGenCXX/debug-info-enum.cpp index c08fc35..f0e2608 100644 --- a/test/CodeGenCXX/debug-info-enum.cpp +++ b/test/CodeGenCXX/debug-info-enum.cpp @@ -1,8 +1,36 @@ -// RUN: %clang -fverbose-asm -S -g %s -o - | grep DW_TAG_enumeration_type +// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s -int v; -enum index { MAX }; -void foo(void) -{ - v = MAX; +// CHECK: [[ENUMS:![0-9]*]], {{[^,]*}}, {{[^,]*}}, {{[^,]*}}, {{[^,]*}}, {{[^,]*}}} ; [ DW_TAG_compile_unit ] +// CHECK: [[ENUMS]] = metadata !{metadata [[E1:![0-9]*]], metadata [[E2:![0-9]*]], metadata [[E3:![0-9]*]]} + +namespace test1 { +// CHECK: [[E1]] = metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST1:![0-9]*]], {{.*}}, metadata [[TEST1_ENUMS:![0-9]*]], {{[^,]*}}, null, null, metadata !"_ZTSN5test11eE"} ; [ DW_TAG_enumeration_type ] [e] +// CHECK: [[TEST1]] = {{.*}} ; [ DW_TAG_namespace ] [test1] +// CHECK: [[TEST1_ENUMS]] = metadata !{metadata [[TEST1_E:![0-9]*]]} +// CHECK: [[TEST1_E]] = {{.*}}, metadata !"E", i64 0} ; [ DW_TAG_enumerator ] [E :: 0] +enum e { E }; +void foo() { + int v = E; +} +} + +namespace test2 { +// rdar://8195980 +// CHECK: [[E2]] = metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST2:![0-9]*]], {{.*}}, metadata [[TEST1_ENUMS]], {{[^,]*}}, null, null, metadata !"_ZTSN5test21eE"} ; [ DW_TAG_enumeration_type ] [e] +// CHECK: [[TEST2]] = {{.*}} ; [ DW_TAG_namespace ] [test2] +enum e { E }; +bool func(int i) { + return i == E; +} +} + +namespace test3 { +// CHECK: [[E3]] = metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST3:![0-9]*]], {{.*}}, metadata [[TEST3_ENUMS:![0-9]*]], {{[^,]*}}, null, null, metadata !"_ZTSN5test31eE"} ; [ DW_TAG_enumeration_type ] [e] +// CHECK: [[TEST3]] = {{.*}} ; [ DW_TAG_namespace ] [test3] +// CHECK: [[TEST3_ENUMS]] = metadata !{metadata [[TEST3_E:![0-9]*]]} +// CHECK: [[TEST3_E]] = {{.*}}, metadata !"E", i64 -1} ; [ DW_TAG_enumerator ] [E :: -1] +enum e { E = -1 }; +void func() { + e x; +} } diff --git a/test/CodeGenCXX/debug-info-friend.cpp b/test/CodeGenCXX/debug-info-friend.cpp index c50f281..b103b14 100644 --- a/test/CodeGenCXX/debug-info-friend.cpp +++ b/test/CodeGenCXX/debug-info-friend.cpp @@ -1,11 +1,20 @@ -// RUN: %clang -fverbose-asm -S -g %s -o - | grep DW_TAG_friend +// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s class MyFriend; -class SomeClass -{ - friend class MyFriend; +class SomeClass { + friend class MyFriend; + typedef int SomeType; }; -SomeClass sc; +SomeClass *x; +struct MyFriend { + static void func(SomeClass::SomeType) { + } +}; + +// Emitting debug info for friends unnecessarily bloats debug info without any +// known benefit or debugger feature that requires it. Re-enable this is a +// use-case appears. +// CHECK-NOT: DW_TAG_friend diff --git a/test/CodeGenCXX/debug-info-function-context.cpp b/test/CodeGenCXX/debug-info-function-context.cpp new file mode 100644 index 0000000..4ca1c8d --- /dev/null +++ b/test/CodeGenCXX/debug-info-function-context.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-pc-linux-gnu %s -o - | FileCheck %s + +struct C { + void member_function(); + static int static_member_function(); + static int static_member_variable; +}; + +int C::static_member_variable = 0; + +void C::member_function() { static_member_variable = 0; } + +int C::static_member_function() { return static_member_variable; } + +C global_variable; + +int global_function() { return -1; } + +namespace ns { +void global_namespace_function() { global_variable.member_function(); } +int global_namespace_variable = 1; +} + +// Check that the functions that belong to C have C as a context and the +// functions that belong to the namespace have it as a context, and the global +// function has the file as a context. + +// CHECK: metadata !"_ZTS1C", metadata !"member_function"{{.*}} [ DW_TAG_subprogram ] [line 11] [def] [member_function] + +// CHECK: metadata !"_ZTS1C", metadata !"static_member_function"{{.*}} [ DW_TAG_subprogram ] [line 13] [def] [static_member_function] + +// CHECK: metadata !22, metadata !"global_function"{{.*}} [ DW_TAG_subprogram ] [line 17] [def] [global_function] +// CHECK: !22 = {{.*}} [ DW_TAG_file_type ] + +// CHECK: metadata !24, metadata !"global_namespace_function"{{.*}} [ DW_TAG_subprogram ] [line 20] [def] [global_namespace_function] +// CHECK: !24 = {{.*}} [ DW_TAG_namespace ] [ns] [line 19] diff --git a/test/CodeGenCXX/debug-info-gline-tables-only.cpp b/test/CodeGenCXX/debug-info-gline-tables-only.cpp index 8d2e63d..7ecdeb2 100644 --- a/test/CodeGenCXX/debug-info-gline-tables-only.cpp +++ b/test/CodeGenCXX/debug-info-gline-tables-only.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -O0 -gline-tables-only -S -emit-llvm -o - | FileCheck %s +// 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. @@ -13,9 +13,17 @@ class E : public C { // CHECK-NOT: DW_TAG_reference type void x(const D& d); }; +struct F { + enum X { }; + void func(X); + virtual ~F(); +}; +F::~F() { +} } // CHECK-NOT: DW_TAG_variable NS::C c; NS::D d; NS::E e; +NS::F f; diff --git a/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp b/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp index bdaf58c..afa7707 100644 --- a/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp +++ b/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp @@ -20,8 +20,8 @@ void foo() { // CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 12] [local] [def] [__dtor_glob] // CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 13] [local] [def] [__cxx_global_var_init1] // CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 13] [local] [def] [__cxx_global_array_dtor] -// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 13] [local] [def] [__dtor_] +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 13] [local] [def] [__dtor_array] // CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 16] [local] [def] [__dtor__ZZ3foovE4stat] -// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line {{.*}}] [local] [def] [_GLOBAL__I_a] +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line {{.*}}] [local] [def]{{$}} -// CHECK-KEXT: [ DW_TAG_subprogram ] [line {{.*}}] [local] [def] [_GLOBAL__D_a] +// CHECK-KEXT: [ DW_TAG_subprogram ] [line {{.*}}] [local] [def]{{$}} diff --git a/test/CodeGenCXX/debug-info-globalinit.cpp b/test/CodeGenCXX/debug-info-globalinit.cpp index b3891c1..30c8bfc 100644 --- a/test/CodeGenCXX/debug-info-globalinit.cpp +++ b/test/CodeGenCXX/debug-info-globalinit.cpp @@ -12,19 +12,27 @@ int test() { static int i = test(); __attribute__((nodebug)) static int j = test(); +static int k = test(); int main(void) {} -// CHECK: define internal void @__cxx_global_var_init() +// CHECK-LABEL: 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-LABEL: 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-LABEL: define internal void @__cxx_global_var_init2() +// CHECK-NOT: __cxx_global_var_init +// CHECK: %[[C2:.+]] = call i32 @_Z4testv(), !dbg ![[LINE2:.*]] +// CHECK-NOT: __cxx_global_var_init +// CHECK: store i32 %[[C2]], i32* @_ZL1k, align 4, !dbg // // CHECK: ![[LINE]] = metadata !{i32 13, i32 +// CHECK: ![[LINE2]] = metadata !{i32 15, i32 diff --git a/test/CodeGenCXX/debug-info-limit-type.cpp b/test/CodeGenCXX/debug-info-limit-type.cpp deleted file mode 100644 index e03024f..0000000 --- a/test/CodeGenCXX/debug-info-limit-type.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s -// XFAIL: * - -class B { -public: - int bb; - void fn2() {} -}; - -class A { -public: - int aa; - void fn1(B b) { b.fn2(); } -}; - -void foo(A *aptr) { -} - -void bar() { - A a; -} - -// B should only be emitted as a forward reference (i32 4). -// CHECK: metadata !"B", metadata !6, i32 3, i32 0, i32 0, i32 0, i32 4} ; [ DW_TAG_class_type ] diff --git a/test/CodeGenCXX/debug-info-limit.cpp b/test/CodeGenCXX/debug-info-limit.cpp deleted file mode 100644 index bca887b..0000000 --- a/test/CodeGenCXX/debug-info-limit.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s - -// TAG_member is used to encode debug info for class constructor. -// CHECK: TAG_member -class A { -public: - int z; -}; - -A *foo (A* x) { - A *a = new A(*x); - return a; -} - diff --git a/test/CodeGenCXX/debug-info-limited.cpp b/test/CodeGenCXX/debug-info-limited.cpp new file mode 100644 index 0000000..54a2424 --- /dev/null +++ b/test/CodeGenCXX/debug-info-limited.cpp @@ -0,0 +1,33 @@ +// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s + +// CHECK: ; [ DW_TAG_class_type ] [A] {{.*}} [def] +class A { +public: + int z; +}; + +A *foo (A* x) { + A *a = new A(*x); + return a; +} + +// Verify that we're not emitting a full definition of B in limit debug mode. +// CHECK: ; [ DW_TAG_class_type ] [B] {{.*}} [decl] + +class B { +public: + int y; +}; + +extern int bar(B *b); +int baz(B *b) { + return bar(b); +} + + +// CHECK: ; [ DW_TAG_structure_type ] [C] {{.*}} [decl] + +struct C { +}; + +C (*x)(C); diff --git a/test/CodeGenCXX/debug-info-method.cpp b/test/CodeGenCXX/debug-info-method.cpp index 3ee4d9b..50b3f66 100644 --- a/test/CodeGenCXX/debug-info-method.cpp +++ b/test/CodeGenCXX/debug-info-method.cpp @@ -1,9 +1,10 @@ // RUN: %clang_cc1 -emit-llvm -std=c++11 -g %s -o - | FileCheck %s -// CHECK: ![[THISTYPE:[0-9]+]] = {{.*}} ; [ DW_TAG_pointer_type ] {{.*}} [artificial] [from A] +// CHECK: metadata !"_ZTS1A"} ; [ DW_TAG_class_type ] [A] // CHECK: metadata !"_ZN1A3fooEiS_3$_0", {{.*}} [protected] +// CHECK: ![[THISTYPE:[0-9]+]] = {{.*}} ; [ DW_TAG_pointer_type ] {{.*}} [artificial] [from _ZTS1A] // CHECK: DW_TAG_ptr_to_member_type // CHECK: {{.*}}metadata ![[MEMFUNTYPE:[0-9]+]], metadata !{{.*}}} ; [ DW_TAG_ptr_to_member_type ] {{.*}} [from ] -// CHECK: ![[MEMFUNTYPE]] = {{.*}}metadata ![[MEMFUNARGS:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_subroutine_type ] {{.*}} [from ] +// CHECK: ![[MEMFUNTYPE]] = {{.*}}metadata ![[MEMFUNARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] {{.*}} [from ] // CHECK: ![[MEMFUNARGS]] = {{.*}}, metadata ![[THISTYPE]], // CHECK: ""{{.*}}DW_TAG_arg_variable // CHECK: ""{{.*}}DW_TAG_arg_variable diff --git a/test/CodeGenCXX/debug-info-namespace.cpp b/test/CodeGenCXX/debug-info-namespace.cpp index 13a7914..a2d7ede 100644 --- a/test/CodeGenCXX/debug-info-namespace.cpp +++ b/test/CodeGenCXX/debug-info-namespace.cpp @@ -1,14 +1,24 @@ -// RUN: %clang -g -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -g -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -g -gline-tables-only -S -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-GMLT %s +// RUN: %clang -g -fno-limit-debug-info -S -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-NOLIMIT %s namespace A { #line 1 "foo.cpp" namespace B { int i; +void f1() { } +void f1(int) { } +struct foo; +struct bar { }; +typedef bar baz; } +} +namespace A { using namespace B; } using namespace A; +namespace E = A; int func(bool b) { if (b) { @@ -16,22 +26,52 @@ int func(bool b) { return i; } using namespace A; - return B::i; + using B::foo; + using B::bar; + using B::f1; + using B::i; + using B::baz; + namespace X = A; + namespace Y = X; + return i + X::B::i + Y::B::i; } +// This should work even if 'i' and 'func' were declarations & not definitions, +// but it doesn't yet. + // CHECK: [[CU:![0-9]*]] = {{.*}}[[MODULES:![0-9]*]], metadata !""} ; [ DW_TAG_compile_unit ] // CHECK: [[FILE:![0-9]*]] {{.*}}debug-info-namespace.cpp" -// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] [line 9] [def] [func] -// CHECK: [[FILE2:![0-9]*]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp] -// CHECK: [[VAR:![0-9]*]] = {{.*}}, metadata [[NS:![0-9]*]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i] -// CHECK: [[NS]] = {{.*}}, metadata [[FILE2]], metadata [[CTXT:![0-9]*]], {{.*}} ; [ DW_TAG_namespace ] [B] [line 1] -// CHECK: [[CTXT]] = {{.*}}, metadata [[FILE]], null, {{.*}} ; [ DW_TAG_namespace ] [A] [line 3] -// CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]], metadata [[M4:![0-9]*]]} -// CHECK: [[M1]] = metadata !{i32 {{[0-9]*}}, metadata [[CTXT]], metadata [[NS]], i32 4} ; [ DW_TAG_imported_module ] -// CHECK: [[M2]] = metadata !{i32 {{[0-9]*}}, metadata [[CU]], metadata [[CTXT]], i32 7} ; [ DW_TAG_imported_module ] -// CHECK: [[M3]] = metadata !{i32 {{[0-9]*}}, metadata [[LEX:![0-9]*]], metadata [[NS]], i32 11} ; [ DW_TAG_imported_module ] -// CHECK: [[LEX]] = metadata !{i32 {{[0-9]*}}, metadata [[FILE2]], metadata [[FUNC]], i32 10, i32 0, i32 0} ; [ DW_TAG_lexical_block ] -// CHECK: [[M4]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[CTXT]], i32 14} ; [ DW_TAG_imported_module ] +// CHECK: [[FOO:![0-9]*]] {{.*}} ; [ DW_TAG_structure_type ] [foo] [line 5, size 0, align 0, offset 0] [decl] [from ] +// CHECK: [[FOOCPP:![0-9]*]] = metadata !{metadata !"foo.cpp", {{.*}} +// CHECK: [[NS:![0-9]*]] = {{.*}}, metadata [[FILE2:![0-9]*]], metadata [[CTXT:![0-9]*]], {{.*}} ; [ DW_TAG_namespace ] [B] [line 1] +// CHECK: [[CTXT]] = {{.*}}, metadata [[FILE]], null, {{.*}} ; [ DW_TAG_namespace ] [A] [line 5] +// CHECK: [[BAR:![0-9]*]] {{.*}} ; [ DW_TAG_structure_type ] [bar] [line 6, {{.*}}] [decl] [from ] +// CHECK: [[F1:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] [line 4] [def] [f1] +// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func] +// CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp] +// CHECK: [[I:![0-9]*]] = {{.*}}, metadata [[NS]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i] +// CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]], metadata [[M4:![0-9]*]], metadata [[M5:![0-9]*]], metadata [[M6:![0-9]*]], metadata [[M7:![0-9]*]], metadata [[M8:![0-9]*]], metadata [[M9:![0-9]*]], metadata [[M10:![0-9]*]], metadata [[M11:![0-9]*]], metadata [[M12:![0-9]*]]} +// CHECK: [[M1]] = metadata !{i32 {{[0-9]*}}, metadata [[CTXT]], metadata [[NS]], i32 11} ; [ DW_TAG_imported_module ] +// CHECK: [[M2]] = metadata !{i32 {{[0-9]*}}, metadata [[CU]], metadata [[CTXT]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_module ] +// CHECK: [[M3]] = metadata !{i32 {{[0-9]*}}, metadata [[CU]], metadata [[CTXT]], i32 15, metadata !"E"} ; [ DW_TAG_imported_module ] +// CHECK: [[M4]] = metadata !{i32 {{[0-9]*}}, metadata [[LEX2:![0-9]*]], metadata [[NS]], i32 19} ; [ DW_TAG_imported_module ] +// CHECK: [[LEX2]] = metadata !{i32 {{[0-9]*}}, metadata [[FILE2]], metadata [[LEX1:![0-9]+]], i32 {{[0-9]*}}, i32 0, i32 {{.*}}} ; [ DW_TAG_lexical_block ] +// CHECK: [[LEX1]] = metadata !{i32 {{[0-9]*}}, metadata [[FILE2]], metadata [[FUNC]], i32 {{[0-9]*}}, i32 0, i32 {{.*}}} ; [ DW_TAG_lexical_block ] +// CHECK: [[M5]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[CTXT]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_module ] +// CHECK: [[M6]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[FOO:![0-9]*]], i32 23} ; [ DW_TAG_imported_declaration ] +// CHECK: [[M7]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[BAR:![0-9]*]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ] +// CHECK: [[M8]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[F1]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ] +// CHECK: [[M9]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[I]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ] +// CHECK: [[M10]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[BAZ:![0-9]*]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ] +// CHECK: [[BAZ]] = metadata !{i32 {{[0-9]*}}, metadata [[FOOCPP]], metadata [[NS]], {{.*}}, metadata !"_ZTSN1A1B3barE"} ; [ DW_TAG_typedef ] [baz] {{.*}} [from _ZTSN1A1B3barE] +// CHECK: [[M11]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[CTXT]], i32 {{[0-9]*}}, metadata !"X"} ; [ DW_TAG_imported_module ] +// CHECK: [[M12]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[M11]], i32 {{[0-9]*}}, metadata !"Y"} ; [ DW_TAG_imported_module ] + +// CHECK-GMLT: [[CU:![0-9]*]] = {{.*}}[[MODULES:![0-9]*]], metadata !""} ; [ DW_TAG_compile_unit ] +// CHECK-GMLT: [[MODULES]] = metadata !{i32 0} + +// CHECK-NOLIMIT: ; [ DW_TAG_structure_type ] [bar] [line 6, {{.*}}] [def] [from ] // FIXME: It is confused on win32 to generate file entry when dosish filename is given. // REQUIRES: shell +// REQUIRES: shell-preserves-root diff --git a/test/CodeGenCXX/debug-info-nullptr.cpp b/test/CodeGenCXX/debug-info-nullptr.cpp index 42e9741..ef9b618 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: [ DW_TAG_unspecified_type ] [nullptr_t] +// CHECK: [ DW_TAG_unspecified_type ] [decltype(nullptr)] diff --git a/test/CodeGenCXX/debug-info-pubtypes.cpp b/test/CodeGenCXX/debug-info-pubtypes.cpp index 6ca3da8..6393cdd 100644 --- a/test/CodeGenCXX/debug-info-pubtypes.cpp +++ b/test/CodeGenCXX/debug-info-pubtypes.cpp @@ -1,6 +1,5 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -fno-limit-debug-info -S %s -o %t -// RUN: FileCheck %s < %t +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -fno-limit-debug-info -S -mllvm -generate-dwarf-pub-sections=Enable %s -o - | FileCheck %s // FIXME: This testcase shouldn't rely on assembly emission. //CHECK: Lpubtypes_begin[[SECNUM:[0-9]:]] @@ -10,7 +9,7 @@ class G { public: - void foo(); + void foo(); }; void G::foo() { diff --git a/test/CodeGenCXX/debug-info-same-line.cpp b/test/CodeGenCXX/debug-info-same-line.cpp index ad24503..519e9ee 100644 --- a/test/CodeGenCXX/debug-info-same-line.cpp +++ b/test/CodeGenCXX/debug-info-same-line.cpp @@ -83,6 +83,21 @@ main(int argc, char const *argv[]) // result // CHECK: call void @llvm.dbg.declare +// We want to see a distinct !dbg node. +// CHECK-NOT: call void @llvm.dbg.declare(metadata !{i32* %{{.*}}}, metadata ![[A_MD]]), !dbg ![[A_DI]] +// CHECK: call void @llvm.dbg.declare(metadata !{i32* %{{.*}}}, metadata ![[A_MD]]), !dbg !{{.*}} +// CHECK-NOT: call void @llvm.dbg.declare(metadata !{i32* %{{.*}}}, metadata ![[B_MD]]), !dbg ![[B_DI]] +// CHECK: call void @llvm.dbg.declare(metadata !{i32* %{{.*}}}, metadata ![[B_MD]]), !dbg !{{.*}} +// result +// CHECK: call void @llvm.dbg.declare + +// Again: we want to see a distinct !dbg node. +// CHECK: call void @llvm.dbg.declare(metadata !{i32* %{{.*}}}, metadata ![[X_MD:[0-9]+]]), !dbg ![[X_DI:[0-9]+]] +// CHECK: call void @llvm.dbg.declare(metadata !{i32* %{{.*}}}, metadata ![[Y_MD:[0-9]+]]), !dbg ![[Y_DI:[0-9]+]] +// result +// CHECK: call void @llvm.dbg.declare + + // CHECK: define {{.*}} @main // CHECK: call {{.*}} @_Z3fooii // CHECK: call {{.*}} @_Z3fooii @@ -96,3 +111,13 @@ main(int argc, char const *argv[]) // CHECK: load {{.*}} !dbg ![[DBG]] // CHECK: call {{.*}} @_Z11strange_maxii(i32 {{.*}}, i32 {{.*}}), !dbg ![[DBG]] // CHECK: call {{.*}} @_Z11strange_maxii(i32 {{.*}}, i32 {{.*}}), !dbg ![[DBG]] + + +// Verify that product() has its own inlined_at location at column 15. +// CHECK-DAG: ![[A_MD]] = metadata{{.*}}[ DW_TAG_arg_variable ] [a] +// CHECK-DAG: ![[B_MD]] = metadata{{.*}}[ DW_TAG_arg_variable ] [b] +// CHECK-DAG: ![[X_MD]] = metadata{{.*}}[ DW_TAG_arg_variable ] [x] +// CHECK-DAG: ![[Y_MD]] = metadata{{.*}}[ DW_TAG_arg_variable ] [y] +// CHECK-DAG: ![[X_DI]] = metadata !{i32 {{[0-9]+}}, i32 {{[0-9]+}}, metadata !{{[0-9]+}}, metadata ![[PRODUCT:[0-9]+]]} +// CHECK-DAG: [[PRODUCT]] = metadata !{i32 {{.*}}, i32 16, metadata !{{.*}}, null} +// CHECK-DAG: ![[Y_DI]] = metadata !{i32 {{[0-9]+}}, i32 {{[0-9]+}}, metadata !{{[0-9]+}}, metadata ![[PRODUCT]]} diff --git a/test/CodeGenCXX/debug-info-scope.cpp b/test/CodeGenCXX/debug-info-scope.cpp new file mode 100644 index 0000000..557ee31 --- /dev/null +++ b/test/CodeGenCXX/debug-info-scope.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -g -emit-llvm %s -o -| FileCheck %s +// +// Two variables with the same name in subsequent if staments need to be in separate scopes. +// +// rdar://problem/14024005 +// + +int printf(const char*, ...); + +char *return_char (int input) +{ + if (input%2 == 0) + return "I am even.\n"; + else + return "I am odd.\n"; +} + +int main2() { +// CHECK: [ DW_TAG_auto_variable ] [ptr] [line [[@LINE+2]]] +// CHECK metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ] + if (char *ptr = return_char(1)) { + printf ("%s", ptr); + } +// CHECK: [ DW_TAG_auto_variable ] [ptr] [line [[@LINE+2]]] +// CHECK metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ] + if (char *ptr = return_char(2)) { + printf ("%s", ptr); + } + else printf ("%s", ptr); + + return 0; +} diff --git a/test/CodeGenCXX/debug-info-static-member.cpp b/test/CodeGenCXX/debug-info-static-member.cpp index 774f7b1..1ac235c 100644 --- a/test/CodeGenCXX/debug-info-static-member.cpp +++ b/test/CodeGenCXX/debug-info-static-member.cpp @@ -1,7 +1,9 @@ -// RUN: %clangxx -target x86_64-unknown-unknown -g -O0 %s -emit-llvm -S -o - | FileCheck %s +// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | FileCheck %s // PR14471 - +enum X { + Y +}; class C { static int a; @@ -13,6 +15,7 @@ public: static int c; const static int const_c = 18; int d; + static X x_a; }; int C::a = 4; @@ -30,12 +33,15 @@ int main() // why the definition of "a" comes before the declarations while // "b" and "c" come after. -// CHECK: metadata !"a", {{.*}} @_ZN1C1aE, metadata ![[DECL_A:[0-9]+]]} ; [ DW_TAG_variable ] [a] {{.*}} [def] -// CHECK: ![[DECL_A]] = metadata {{.*}} [ DW_TAG_member ] [a] [line {{.*}}, size 0, align 0, offset 0] [private] [static] +// CHECK: metadata !"_ZTS1X"} ; [ DW_TAG_enumeration_type ] [X] +// CHECK: metadata !"_ZTS1C"} ; [ DW_TAG_class_type ] [C] +// CHECK: ![[DECL_A:[0-9]+]] = metadata {{.*}} [ DW_TAG_member ] [a] [line {{.*}}, size 0, align 0, offset 0] [private] [static] // CHECK: metadata !"const_a", {{.*}}, i1 true} ; [ DW_TAG_member ] [const_a] [line {{.*}}, size 0, align 0, offset 0] [private] [static] // CHECK: ![[DECL_B:[0-9]+]] {{.*}} metadata !"b", {{.*}} [ DW_TAG_member ] [b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static] // CHECK: metadata !"const_b", {{.*}}, float 0x{{.*}}} ; [ DW_TAG_member ] [const_b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static] // CHECK: ![[DECL_C:[0-9]+]] {{.*}} metadata !"c", {{.*}} [ DW_TAG_member ] [c] [line {{.*}}, size 0, align 0, offset 0] [static] // CHECK: metadata !"const_c", {{.*}} [ DW_TAG_member ] [const_c] [line {{.*}}, size 0, align 0, offset 0] [static] +// CHECK: metadata !"x_a", {{.*}} [ DW_TAG_member ] [x_a] {{.*}} [static] +// CHECK: metadata !"a", {{.*}} @_ZN1C1aE, metadata ![[DECL_A]]} ; [ DW_TAG_variable ] [a] {{.*}} [def] // CHECK: metadata !"b", {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def] // CHECK: metadata !"c", {{.*}} @_ZN1C1cE, metadata ![[DECL_C]]} ; [ DW_TAG_variable ] [c] {{.*}} [def] diff --git a/test/CodeGenCXX/debug-info-template-limit.cpp b/test/CodeGenCXX/debug-info-template-limit.cpp index afad31b..c3e241e 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: ![[LINE:[0-9]+]]} ; [ DW_TAG_pointer_type ]{{.*}}[from TC] -// CHECK-NEXT: ![[LINE]] ={{.*}}"TC" +// CHECK: ![[LINE:[0-9]+]] = {{.*}}"TC", {{.*}} metadata !"_ZTS2TCIiE"} ; [ DW_TAG_class_type ] +// CHECK: metadata !"_ZTS2TCIiE"} ; [ DW_TAG_pointer_type ]{{.*}}[from _ZTS2TCIiE] template class TC { diff --git a/test/CodeGenCXX/debug-info-template-member.cpp b/test/CodeGenCXX/debug-info-template-member.cpp index 6be7f9b..9ac1bef 100644 --- a/test/CodeGenCXX/debug-info-template-member.cpp +++ b/test/CodeGenCXX/debug-info-template-member.cpp @@ -1,21 +1,78 @@ // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s -class MyClass -{ -public: - int add2(int j) - { - return add<2>(j); - } -private: - template int add(int j) - { - return i + j; - } +struct MyClass { + template int add(int j) { + return i + j; + } + virtual void func() { + } }; -MyClass m; +int add2(int x) { + return MyClass().add<2>(x); +} + +inline int add3(int x) { + return MyClass().add<3>(x); // even though add<3> is ODR used, don't emit it since we don't codegen it +} + +// CHECK: [[FOO_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS3foo"} ; [ DW_TAG_structure_type ] [foo] +// CHECK: [[FOO_MEM]] = metadata !{metadata [[FOO_FUNC:![0-9]*]]} +// CHECK: [[FOO_FUNC]] = {{.*}}, metadata !"_ZN3foo4funcEN5outerIS_E5innerE", i32 {{[0-9]*}}, metadata [[FOO_FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func] +// CHECK: [[FOO_FUNC_TYPE]] = {{.*}}, metadata [[FOO_FUNC_PARAMS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] +// CHECK: [[FOO_FUNC_PARAMS]] = metadata !{null, metadata !{{[0-9]*}}, metadata [[OUTER_FOO_INNER:![0-9]*]]} +// CHECK: [[OUTER_FOO_INNER]] = {{.*}} ; [ DW_TAG_structure_type ] [inner] + +// CHECK: metadata [[VIRT_MEM:![0-9]*]], i32 0, metadata !"_ZTS4virtI4elemE", metadata [[VIRT_TEMP_PARAM:![0-9]*]], metadata !"_ZTS4virtI4elemE"} ; [ DW_TAG_structure_type ] [virt] {{.*}} [def] +// CHECK: [[VIRT_TEMP_PARAM]] = metadata !{metadata [[VIRT_T:![0-9]*]]} +// CHECK: [[VIRT_T]] = {{.*}}, metadata !"T", metadata !"_ZTS4elem", {{.*}} ; [ DW_TAG_template_type_parameter ] + +// CHECK: [[C:![0-9]*]] = {{.*}}, metadata [[C_MEM:![0-9]*]], i32 0, metadata !"_ZTS7MyClass", null, metadata !"_ZTS7MyClass"} ; [ DW_TAG_structure_type ] [MyClass] +// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_ADD:![0-9]*]], metadata [[C_FUNC:![0-9]*]], metadata [[C_CTOR:![0-9]*]]} +// CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$MyClass] + +// CHECK: [[C_ADD]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>] +// CHECK: [[C_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] [line 7] [func] +// CHECK: [[C_CTOR]] = {{.*}} ; [ DW_TAG_subprogram ] [line 0] [MyClass] + +// CHECK: [[ELEM:![0-9]*]] = {{.*}}, metadata [[ELEM_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS4elem"} ; [ DW_TAG_structure_type ] [elem] {{.*}} [def] +// CHECK: [[ELEM_MEM]] = metadata !{metadata [[ELEM_X:![0-9]*]]} +// CHECK: [[ELEM_X]] = {{.*}} ; [ DW_TAG_member ] [x] {{.*}} [static] [from _ZTS4virtI4elemE] + +template +struct outer { + struct inner { + int i; + }; +}; + +struct foo { + void func(outer::inner); +}; + +inline void func() { + // require 'foo' to be complete before the emission of 'inner' so that, when + // constructing the context chain for 'x' we emit the full definition of + // 'foo', which requires the definition of 'inner' again + foo f; +} + +outer::inner x; + +// CHECK: metadata [[OUTER_FOO_INNER]], i32 {{[0-9]*}}, i32 {{[0-9]*}}, %"struct.outer::inner"* @x, {{.*}} ; [ DW_TAG_variable ] [x] + +template +struct virt { + T* values; + virtual ~virt(); +}; +struct elem { + static virt x; // ensure that completing 'elem' will require/completing 'virt' +}; +inline void f1() { + elem e; // ensure 'elem' is required to be complete when it is emitted as a template argument for 'virt' +}; +void f2() { + virt d; // emit 'virt' +} -// CHECK: metadata [[C_MEM:![0-9]*]], i32 0, null, null} ; [ DW_TAG_class_type ] [MyClass] -// CHECK: [[C_MEM]] = metadata !{metadata {{.*}}, metadata [[C_TEMP:![0-9]*]], metadata {{.*}}} -// CHECK: [[C_TEMP]] = {{.*}} ; [ DW_TAG_subprogram ] [line 11] [private] [add<2>] diff --git a/test/CodeGenCXX/debug-info-template-quals.cpp b/test/CodeGenCXX/debug-info-template-quals.cpp index 335c8ab..740f7bf 100644 --- a/test/CodeGenCXX/debug-info-template-quals.cpp +++ b/test/CodeGenCXX/debug-info-template-quals.cpp @@ -15,13 +15,13 @@ void foo (const char *c) { str.assign(c, str); } -// CHECK: [[P:.*]] = {{.*}}, metadata [[CON:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +// CHECK: [[BS:.*]] = {{.*}} ; [ DW_TAG_structure_type ] [basic_string] [line 4, size 8, align 8, offset 0] [def] [from ] +// CHECK: [[TYPE:![0-9]*]] = metadata !{i32 {{.*}}, metadata [[ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] +// CHECK: [[ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata [[P:![0-9]*]], metadata [[R:.*]]} +// CHECK: [[P]] = {{.*}}, metadata [[CON:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] // CHECK: [[CON]] = {{.*}}, metadata [[CH:![0-9]*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char] // CHECK: [[CH]] = {{.*}} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char] -// CHECK: {{.*}} metadata [[TYPE:![0-9]*]], {{.*}}, metadata !{{[0-9]*}}, metadata !{{[0-9]*}}, i32 8} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [assign] -// CHECK: [[TYPE]] = metadata !{i32 {{.*}}, metadata [[ARGS:.*]], i32 0, i32 0} ; [ DW_TAG_subroutine_type ] -// CHECK: [[ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata [[P]], metadata [[R:.*]]} -// CHECK: [[BS:.*]] = {{.*}} ; [ DW_TAG_structure_type ] [basic_string] [line 4, size 8, align 8, offset 0] [from ] // CHECK: [[R]] = {{.*}}, metadata [[CON2:![0-9]*]]} ; [ DW_TAG_reference_type ] [line 0, size 0, align 0, offset 0] [from ] -// CHECK: [[CON2]] = {{.*}}, metadata [[BS]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from basic_string] +// CHECK: [[CON2]] = {{.*}}, metadata !"_ZTS12basic_stringIcE"} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from _ZTS12basic_stringIcE] +// CHECK: {{.*}} metadata [[TYPE]], {{.*}}, metadata !{{[0-9]*}}, metadata !{{[0-9]*}}, i32 8} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [assign] diff --git a/test/CodeGenCXX/debug-info-template.cpp b/test/CodeGenCXX/debug-info-template.cpp index 9d52159..f58973b 100644 --- a/test/CodeGenCXX/debug-info-template.cpp +++ b/test/CodeGenCXX/debug-info-template.cpp @@ -1,46 +1,116 @@ -// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++11 | FileCheck %s -//CHECK: TC -//CHECK: DW_TAG_template_type_parameter +// CHECK: {{.*}}, i1 false, metadata !"", i32 0, metadata !{{[0-9]]*}}, metadata [[RETAIN:![0-9]*]], {{.*}} ; [ DW_TAG_compile_unit ] +// CHECK: [[EMPTY:![0-9]*]] = metadata !{i32 0} +// CHECK: [[RETAIN]] = metadata !{metadata !{{[0-9]]*}}, metadata [[FOO:![0-9]*]], -template -class TC { -public: - TC(const TC &) {} - TC() {} -}; -TC tci; +// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]], metadata !"{{.*}}"} ; [ DW_TAG_structure_type ] [TC] +// CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]], metadata [[TCARG3:![0-9]*]], metadata [[TCARG4:![0-9]*]], metadata [[TCARG5:![0-9]*]], metadata [[TCARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]], metadata [[TCARG8:![0-9]*]]} +// +// We seem to be missing file/line/col info on template value parameters - +// metadata supports it but it's not populated. GCC doesn't emit it either, +// perhaps we should just drop it from the metadata. +// +// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[UINT:![0-9]*]], {{.*}} ; [ DW_TAG_template_type_parameter ] +// CHECK: [[UINT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [unsigned int] +// CHECK: [[TCARG2]] = {{.*}}metadata !"", metadata [[UINT]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[TCARG3]] = {{.*}}metadata !"x", metadata [[INTPTR:![0-9]*]], i32* @glb, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[INTPTR]] = {{.*}}, metadata [[INT:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] +// CHECK: [[INT]] = {{.*}} ; [ DW_TAG_base_type ] [int] +// CHECK: [[TCARG4]] = {{.*}}metadata !"a", metadata [[MEMINTPTR:![0-9]*]], i64 8, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[MEMINTPTR]] = {{.*}}, metadata !"_ZTS3foo"} ; [ DW_TAG_ptr_to_member_type ] {{.*}}[from int] +// +// Currently Clang emits the pointer-to-member-function value, but LLVM doesn't +// use it (GCC doesn't emit a value for pointers to member functions either - so +// it's not clear what, if any, format would be acceptable to GDB) +// +// CHECK: [[TCARG5]] = {{.*}}metadata !"b", metadata [[MEMFUNPTR:![0-9]*]], { i64, i64 } { i64 ptrtoint (void (%struct.foo*)* @_ZN3foo1fEv to i64), i64 0 }, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[MEMFUNPTR]] = {{.*}}, metadata [[FTYPE:![0-9]*]], metadata !"_ZTS3foo"} ; [ DW_TAG_ptr_to_member_type ] +// CHECK: [[FTYPE]] = {{.*}}, metadata [[FARGS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] +// CHECK: [[FARGS]] = metadata !{null, metadata [[FARG1:![0-9]*]]} +// CHECK: [[FARG1]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS3foo] +// +// CHECK: [[TCARG6]] = {{.*}}metadata !"f", metadata [[FUNPTR:![0-9]*]], void ()* @_Z4funcv, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[FUNPTR]] = {{.*}}, metadata [[FUNTYPE:![0-9]*]]} ; [ DW_TAG_pointer_type ] +// CHECK: [[FUNTYPE]] = {{.*}}, metadata [[FUNARGS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] +// CHECK: [[FUNARGS]] = metadata !{null} +// CHECK: [[TCARG7]] = {{.*}}metadata !"tmpl", null, metadata !"tmpl_impl", {{.*}} ; [ DW_TAG_GNU_template_template_param ] +// CHECK: [[TCARG8]] = {{.*}}metadata !"Is", null, metadata [[TCARG8_VALS:![0-9]*]], {{.*}} ; [ DW_TAG_GNU_template_parameter_pack ] +// CHECK: [[TCARG8_VALS]] = metadata !{metadata [[TCARG8_1:![0-9]*]], metadata [[TCARG8_2:![0-9]*]], metadata [[TCARG8_3:![0-9]*]]} +// CHECK: [[TCARG8_1]] = {{.*}}metadata !"", metadata [[INT]], i32 1, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[TCARG8_2]] = {{.*}}metadata !"", metadata [[INT]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[TCARG8_3]] = {{.*}}metadata !"", metadata [[INT]], i32 3, {{.*}} ; [ DW_TAG_template_value_parameter ] +// +// We could just emit a declaration of 'foo' here, rather than the entire +// definition (same goes for any time we emit a member (function or data) +// pointer type) +// CHECK: [[FOO]] = {{.*}}, metadata !"_ZTS3foo"} ; [ DW_TAG_structure_type ] [foo] +// CHECK: metadata !"f", metadata !"_ZN3foo1fEv", i32 {{[0-9]*}}, metadata [[FTYPE:![0-9]*]], +// + + +// CHECK: [[TCNESTED:![0-9]*]] = metadata !{i32 {{[0-9]*}}, metadata !{{[0-9]*}}, metadata !"_ZTS2TCIjLj2EXadL_Z3glbEEXadL_ZN3foo1eEEEXadL_ZNS0_1fEvEEXadL_Z4funcvEE9tmpl_implJLi1ELi2ELi3EEE", {{.*}} ; [ DW_TAG_structure_type ] [nested] +// CHECK: [[TCNT:![0-9]*]] = {{.*}}, metadata [[TCNARGS:![0-9]*]], metadata !"{{.*}}"} ; [ DW_TAG_structure_type ] [TC] +// CHECK: [[TCNARGS]] = metadata !{metadata [[TCNARG1:![0-9]*]], metadata [[TCNARG2:![0-9]*]], metadata [[TCNARG3:![0-9]*]], metadata [[TCNARG4:![0-9]*]], metadata [[TCNARG5:![0-9]*]], metadata [[TCNARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]], metadata [[TCNARG8:![0-9]*]]} +// CHECK: [[TCNARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ] +// CHECK: [[TCNARG2]] = {{.*}}metadata !"", metadata [[INT]], i32 -3, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[TCNARG3]] = {{.*}}metadata !"x", metadata [[INTPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ] + +// The interesting null pointer: -1 for member data pointers (since they are +// just an offset in an object, they can be zero and non-null for the first +// member) + +// CHECK: [[TCNARG4]] = {{.*}}metadata !"a", metadata [[MEMINTPTR]], i64 -1, {{.*}} ; [ DW_TAG_template_value_parameter ] +// +// In some future iteration we could possibly emit the value of a null member +// function pointer as '{ i64, i64 } zeroinitializer' as it may be handled +// naturally from the LLVM CodeGen side once we decide how to handle non-null +// member function pointers. For now, it's simpler just to emit the 'i8 0'. +// +// CHECK: [[TCNARG5]] = {{.*}}metadata !"b", metadata [[MEMFUNPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[TCNARG6]] = {{.*}}metadata !"f", metadata [[FUNPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[TCNARG8]] = {{.*}}metadata !"Is", null, metadata [[EMPTY]], {{.*}} ; [ DW_TAG_GNU_template_parameter_pack ] + +// CHECK: metadata [[PTOARGS:![0-9]*]], metadata !"{{.*}}"} ; [ DW_TAG_structure_type ] [PaddingAtEndTemplate<&PaddedObj>] +// CHECK: [[PTOARGS]] = metadata !{metadata [[PTOARG1:![0-9]*]]} +// CHECK: [[PTOARG1]] = {{.*}}metadata !"", metadata [[CONST_PADDINGATEND_PTR:![0-9]*]], { i32, i8, [3 x i8] }* @PaddedObj, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[CONST_PADDINGATEND_PTR]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS12PaddingAtEnd] -//CHECK: TU<2> -//CHECK: DW_TAG_template_value_parameter -template -class TU { - int b; +// CHECK: metadata [[TCNESTED]], i32 0, i32 1, %"struct.TC::nested"* @tci, null} ; [ DW_TAG_variable ] [tci] + +// CHECK: metadata [[TCNT:![0-9]*]], i32 0, i32 1, %struct.TC* @tcn, null} ; [ DW_TAG_variable ] [tcn] +struct foo { + char pad[8]; // make the member pointer to 'e' a bit more interesting (nonzero) + int e; + void f(); +}; + +template class tmpl, int ...Is> +struct TC { + struct nested { + }; }; -TU<2> u2; +int glb; +void func(); -// PR9600 -template class vector {}; -class Foo; -typedef vector FooVector[3]; -struct Test { - virtual void foo(FooVector *); +template +struct tmpl_impl { }; -static Test test; -// PR9608 -template struct TheTemplate { - struct Empty2 {}; - typedef const Empty2 DependentType[i]; - TheTemplate() {} -}; +TC::nested tci; +TC tcn; -class TheTemplateTest : public TheTemplate<42> { - TheTemplateTest(); - void method(const TheTemplate<42>::DependentType *) {} -}; +struct PaddingAtEnd { + int i; + char c; +}; + +PaddingAtEnd PaddedObj = {}; -TheTemplateTest::TheTemplateTest() : TheTemplate<42>() {} +template +struct PaddingAtEndTemplate { +}; +PaddingAtEndTemplate<&PaddedObj> PaddedTemplateObj; diff --git a/test/CodeGenCXX/debug-info-thunk.cpp b/test/CodeGenCXX/debug-info-thunk.cpp index 394ebd8..2a50895 100644 --- a/test/CodeGenCXX/debug-info-thunk.cpp +++ b/test/CodeGenCXX/debug-info-thunk.cpp @@ -14,4 +14,4 @@ struct C : A, B { void C::f() { } -// CHECK: [ DW_TAG_subprogram ] [line 15] [def] [_ZThn{{4|8}}_N1C1fEv] +// CHECK: metadata !"_ZThn{{4|8}}_N1C1fEv", i32 15, {{.*}} ; [ DW_TAG_subprogram ] [line 15] [def]{{$}} diff --git a/test/CodeGenCXX/debug-info-union-template.cpp b/test/CodeGenCXX/debug-info-union-template.cpp index f5e6e14..570520d 100644 --- a/test/CodeGenCXX/debug-info-union-template.cpp +++ b/test/CodeGenCXX/debug-info-union-template.cpp @@ -10,6 +10,6 @@ namespace PR15637 { Value f; } -// CHECK: {{.*}}, metadata !"Value", {{.*}}, null, metadata [[TTPARAM:.*]]} ; [ DW_TAG_union_type ] [Value] +// CHECK: {{.*}}, metadata !"Value", {{.*}}, null, metadata [[TTPARAM:.*]], metadata !"_ZTSN7PR156375ValueIfEE"} ; [ DW_TAG_union_type ] [Value] // CHECK: [[TTPARAM]] = metadata !{metadata [[PARAMS:.*]]} // CHECK: [[PARAMS]] = metadata !{{{.*}}metadata !"T",{{.*}}} ; [ DW_TAG_template_type_parameter ] diff --git a/test/CodeGenCXX/debug-info-uuid.cpp b/test/CodeGenCXX/debug-info-uuid.cpp new file mode 100644 index 0000000..a57e2f0 --- /dev/null +++ b/test/CodeGenCXX/debug-info-uuid.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -emit-llvm -fms-extensions -triple=x86_64-pc-win32 -cxx-abi microsoft -g %s -o - -std=c++11 | FileCheck %s +// RUN: not %clang_cc1 -emit-llvm -fms-extensions -triple=x86_64-unknown-unknown -g %s -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=CHECK-ITANIUM + +// CHECK: metadata [[TGIARGS:![0-9]*]], null} ; [ DW_TAG_structure_type ] [tmpl_guid<&__uuidof(uuid)>] +// CHECK: [[TGIARGS]] = metadata !{metadata [[TGIARG1:![0-9]*]]} +// CHECK: [[TGIARG1]] = {{.*}}metadata !"", metadata [[CONST_GUID_PTR:![0-9]*]], { i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[CONST_GUID_PTR]] = {{.*}}, metadata [[CONST_GUID:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +// CHECK: [[CONST_GUID]] = {{.*}}, metadata [[GUID:![0-9]*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from _GUID] +// CHECK: [[GUID]] = {{.*}} ; [ DW_TAG_structure_type ] [_GUID] + +// CHECK-ITANIUM: error: cannot yet mangle expression type CXXUuidofExpr + +struct _GUID; +template +struct tmpl_guid { +}; + +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890ab}")) uuid; +tmpl_guid<&__uuidof(uuid)> tgi; diff --git a/test/CodeGenCXX/debug-info-zero-length-arrays.cpp b/test/CodeGenCXX/debug-info-zero-length-arrays.cpp index fb47022..1017965 100644 --- a/test/CodeGenCXX/debug-info-zero-length-arrays.cpp +++ b/test/CodeGenCXX/debug-info-zero-length-arrays.cpp @@ -7,6 +7,6 @@ class A { A a; // CHECK: metadata [[ARRAY_TYPE:![0-9]*]]} ; [ DW_TAG_member ] [x] -// CHECK: metadata [[ELEM_TYPE:![0-9]*]], i32 0, i32 0} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from int] +// CHECK: metadata [[ELEM_TYPE:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from int] // CHECK: [[ELEM_TYPE]] = metadata !{metadata [[SUBRANGE:.*]]} // CHECK: [[SUBRANGE]] = metadata !{i32 786465, i64 0, i64 -1} ; [ DW_TAG_subrange_type ] [unbounded] diff --git a/test/CodeGenCXX/debug-info.cpp b/test/CodeGenCXX/debug-info.cpp index 33b5278..93a4fe3 100644 --- a/test/CodeGenCXX/debug-info.cpp +++ b/test/CodeGenCXX/debug-info.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm-only -g %s +// RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -g %s -o - | FileCheck %s template struct Identity { typedef T Type; }; @@ -67,3 +67,54 @@ class Cls { Cls obj; } + +namespace pr14763 { +struct foo { + foo(const foo&); +}; + +foo func(foo f) { + return f; // reference 'f' for now because otherwise we hit another bug +} + +// CHECK: [[FOO:![0-9]*]] = metadata !{i32 {{[0-9]*}}, metadata !{{[0-9]*}}, metadata [[PR14763:![0-9]*]], {{.*}} ; [ DW_TAG_structure_type ] [foo] +// CHECK: [[PR14763]] = {{.*}} ; [ DW_TAG_namespace ] [pr14763] +// CHECK: [[INCTYPE:![0-9]*]] = {{.*}} ; [ DW_TAG_structure_type ] [incomplete]{{.*}} [decl] +// CHECK: metadata [[A_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTSN7pr162141aE"} ; [ DW_TAG_structure_type ] [a] +// CHECK: [[A_MEM]] = metadata !{metadata [[A_I:![0-9]*]]} +// CHECK: [[A_I]] = {{.*}} ; [ DW_TAG_member ] [i] {{.*}} [from int] +// CHECK: ; [ DW_TAG_structure_type ] [b] {{.*}}[decl] + +// CHECK: [[FUNC:![0-9]*]] = {{.*}} metadata !"_ZN7pr147634funcENS_3fooE", i32 {{[0-9]*}}, metadata [[FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func] +} + +namespace pr9608 { // also pr9600 +struct incomplete; +incomplete (*x)[3]; +// CHECK: metadata [[INCARRAYPTR:![0-9]*]], i32 0, i32 1, [3 x i8]** @_ZN6pr96081xE, null} ; [ DW_TAG_variable ] [x] +// CHECK: [[INCARRAYPTR]] = {{.*}}metadata [[INCARRAY:![0-9]*]]} ; [ DW_TAG_pointer_type ] +// CHECK: [[INCARRAY]] = {{.*}}metadata !"_ZTSN6pr960810incompleteE", metadata {{![0-9]*}}, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 0, offset 0] [from _ZTSN6pr960810incompleteE] +} + +// For some reason the argument for PR14763 ended up all the way down here +// CHECK: = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], {{.*}}, metadata [[FOO]], i32 8192, i32 0} ; [ DW_TAG_arg_variable ] [f] + +namespace pr16214 { +struct a { + int i; +}; + +typedef a at; + +struct b { +}; + +typedef b bt; + +void func() { + at a_inst; + bt *b_ptr_inst; + const bt *b_cnst_ptr_inst; +} + +} diff --git a/test/CodeGenCXX/debug-lambda-expressions.cpp b/test/CodeGenCXX/debug-lambda-expressions.cpp index 39c9a44..0b087360 100644 --- a/test/CodeGenCXX/debug-lambda-expressions.cpp +++ b/test/CodeGenCXX/debug-lambda-expressions.cpp @@ -12,7 +12,7 @@ int b(int x) { return [x]{return x;}(); } int c(int x) { return [&x]{return x;}(); } struct D { D(); D(const D&); int x; }; -int d(int x) { D y[10]; [x,y] { return y[x].x; }(); } +int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); } // Randomness for file. -- 6 // CHECK: [[FILE:.*]] = {{.*}} [ DW_TAG_file_type ] [{{.*}}debug-lambda-expressions.cpp] @@ -30,42 +30,38 @@ int d(int x) { D y[10]; [x,y] { return y[x].x; }(); } // CHECK: [[D_FUNC:.*]] = {{.*}} [ DW_TAG_subprogram ] [line [[D_LINE:.*]]] [def] [d] // Back to D. -- 24 -// CHECK: [[LAM_D:.*]] = {{.*}}, metadata [[D_FUNC]], {{.*}}, metadata [[LAM_D_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[D_LINE]], -// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]], metadata [[DES_LAM_D:.*]]} +// CHECK: [[LAM_D:.*]] = {{.*}}, metadata [[D_FUNC]], {{.*}}, metadata [[LAM_D_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[D_LINE]], +// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]]} // CHECK: [[CAP_D_X]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_member ] [x] [line [[D_LINE]], // CHECK: [[CAP_D_Y]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_member ] [y] [line [[D_LINE]], // CHECK: [[CON_LAM_D]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_subprogram ] [line [[D_LINE]]] [operator()] -// CHECK: [[DES_LAM_D]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_subprogram ] [line [[D_LINE]]] [~] // Back to C. -- 55 -// CHECK: [[LAM_C:.*]] = {{.*}}, metadata [[C_FUNC]], {{.*}}, metadata [[LAM_C_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[C_LINE]], -// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]], metadata [[DES_LAM_C:.*]]} +// CHECK: [[LAM_C:.*]] = {{.*}}, metadata [[C_FUNC]], {{.*}}, metadata [[LAM_C_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[C_LINE]], +// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]]} // Ignoring the member type for now. // CHECK: [[CAP_C]] = {{.*}}, metadata [[LAM_C]], {{.*}}} ; [ DW_TAG_member ] [x] [line [[C_LINE]], // CHECK: [[CON_LAM_C]] = {{.*}}, metadata [[LAM_C]], {{.*}} [ DW_TAG_subprogram ] [line [[C_LINE]]] [operator()] -// CHECK: [[DES_LAM_C]] = {{.*}}, metadata [[LAM_C]], {{.*}} [ DW_TAG_subprogram ] [line [[C_LINE]]] [~] // Back to B. -- 67 -// CHECK: [[LAM_B:.*]] = {{.*}}, metadata [[B_FUNC]], {{.*}}, metadata [[LAM_B_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[B_LINE]], -// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]], metadata [[DES_LAM_B:.*]]} +// CHECK: [[LAM_B:.*]] = {{.*}}, metadata [[B_FUNC]], {{.*}}, metadata [[LAM_B_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[B_LINE]], +// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]]} // CHECK: [[CAP_B]] = {{.*}}, metadata [[LAM_B]], {{.*}}} ; [ DW_TAG_member ] [x] [line [[B_LINE]], // CHECK: [[CON_LAM_B]] = {{.*}}, metadata [[LAM_B]], {{.*}} [ DW_TAG_subprogram ] [line [[B_LINE]]] [operator()] -// CHECK: [[DES_LAM_B]] = {{.*}}, metadata [[LAM_B]], {{.*}} [ DW_TAG_subprogram ] [line [[B_LINE]]] [~] // Back to A. -- 78 -// CHECK: [[LAM_A:.*]] = {{.*}}, metadata [[A_FUNC]], {{.*}}, metadata [[LAM_A_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[A_LINE]], -// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]], metadata [[DES_LAM_A:.*]]} +// CHECK: [[LAM_A:.*]] = {{.*}}, metadata [[A_FUNC]], {{.*}}, metadata [[LAM_A_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[A_LINE]], +// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]]} // CHECK: [[CON_LAM_A]] = {{.*}}, metadata [[LAM_A]], {{.*}} [ DW_TAG_subprogram ] [line [[A_LINE]]] [operator()] -// CHECK: [[DES_LAM_A]] = {{.*}}, metadata [[LAM_A]], {{.*}} [ DW_TAG_subprogram ] [line [[A_LINE]]] [~] // CVAR: // CHECK: {{.*}} metadata [[CVAR_T:![0-9]*]], {{.*}} ; [ DW_TAG_variable ] [cvar] [line [[CVAR_LINE:[0-9]*]]] -// CHECK: [[CVAR_T]] = {{.*}}, metadata ![[CVAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[CVAR_LINE]], -// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}} +// CHECK: [[CVAR_T]] = {{.*}}, metadata ![[CVAR_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[CVAR_LINE]], +// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}} // VAR: // CHECK: {{.*}} metadata [[VAR_T:![0-9]*]], {{.*}} ; [ DW_TAG_variable ] [var] [line [[VAR_LINE:[0-9]*]]] -// CHECK: [[VAR_T]] = {{.*}}, metadata [[VAR_ARGS:![0-9]*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[VAR_LINE]], -// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}} +// CHECK: [[VAR_T]] = {{.*}}, metadata [[VAR_ARGS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[VAR_LINE]], +// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}} diff --git a/test/CodeGenCXX/decl-ref-init.cpp b/test/CodeGenCXX/decl-ref-init.cpp index a066fbb..1a82ee2 100644 --- a/test/CodeGenCXX/decl-ref-init.cpp +++ b/test/CodeGenCXX/decl-ref-init.cpp @@ -1,8 +1,8 @@ // REQUIRES: x86-registered-target,x86-64-registered-target // RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s // RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s struct A {}; diff --git a/test/CodeGenCXX/default-arg-temps.cpp b/test/CodeGenCXX/default-arg-temps.cpp index 3d741d5..4375600 100644 --- a/test/CodeGenCXX/default-arg-temps.cpp +++ b/test/CodeGenCXX/default-arg-temps.cpp @@ -13,7 +13,7 @@ public: X(const X&, const T& t = T()); }; -// CHECK: define void @_Z1gv() +// CHECK-LABEL: define void @_Z1gv() void g() { // CHECK: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG1:%.*]]) // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG1]]) @@ -41,7 +41,7 @@ void g() { class obj{ int a; float b; double d; }; -// CHECK: define void @_Z1hv() +// CHECK-LABEL: define void @_Z1hv() void h() { // CHECK: call void @llvm.memset.p0i8.i64( obj o = obj(); @@ -61,7 +61,7 @@ namespace test1 { C c; A a; - // CHECK: define linkonce_odr void @_ZN5test11DC2Ev(%"struct.test1::D"* %this) unnamed_addr + // CHECK-LABEL: define linkonce_odr void @_ZN5test11DC2Ev(%"struct.test1::D"* %this) unnamed_addr // CHECK: call void @_ZN5test11BC1Ev( // CHECK-NEXT: call void @_ZN5test11CC1ERKNS_1BE( // CHECK-NEXT: call void @_ZN5test11BD1Ev( diff --git a/test/CodeGenCXX/default-arguments.cpp b/test/CodeGenCXX/default-arguments.cpp index 206d4d6..83cae3a 100644 --- a/test/CodeGenCXX/default-arguments.cpp +++ b/test/CodeGenCXX/default-arguments.cpp @@ -26,7 +26,7 @@ struct B { B(const A1& = A1(), const A2& = A2()); }; -// CHECK: define void @_Z2f1v() +// CHECK-LABEL: define void @_Z2f1v() void f1() { // CHECK: call void @_ZN2A1C1Ev( @@ -42,10 +42,10 @@ struct C { C(); }; -// CHECK: define void @_ZN1CC1Ev(%struct.C* %this) unnamed_addr +// CHECK-LABEL: define void @_ZN1CC1Ev(%struct.C* %this) unnamed_addr // CHECK: call void @_ZN1CC2Ev( -// CHECK: define void @_ZN1CC2Ev(%struct.C* %this) unnamed_addr +// CHECK-LABEL: define void @_ZN1CC2Ev(%struct.C* %this) unnamed_addr // CHECK: call void @_ZN2A1C1Ev( // CHECK: call void @_ZN2A2C1Ev( // CHECK: call void @_ZN1BC1ERK2A1RK2A2( @@ -53,7 +53,7 @@ struct C { // CHECK: call void @_ZN2A1D1Ev C::C() { } -// CHECK: define void @_Z2f3v() +// CHECK-LABEL: define void @_Z2f3v() void f3() { // CHECK: call void @_ZN2A1C1Ev( // CHECK: call void @_ZN2A2C1Ev( diff --git a/test/CodeGenCXX/default-constructor-for-members.cpp b/test/CodeGenCXX/default-constructor-for-members.cpp index 714811f..6065b49 100644 --- a/test/CodeGenCXX/default-constructor-for-members.cpp +++ b/test/CodeGenCXX/default-constructor-for-members.cpp @@ -1,8 +1,8 @@ // REQUIRES: x86-registered-target,x86-64-registered-target // RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s // RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s +// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/default-constructor-template-member.cpp b/test/CodeGenCXX/default-constructor-template-member.cpp index 0dd64df..2156964 100644 --- a/test/CodeGenCXX/default-constructor-template-member.cpp +++ b/test/CodeGenCXX/default-constructor-template-member.cpp @@ -5,6 +5,7 @@ struct B { A x; }; void a() { B b; } + // CHECK: call {{.*}} @_ZN1BC1Ev -// CHECK: define linkonce_odr {{.*}} @_ZN1BC1Ev(%struct.B* %this) unnamed_addr +// CHECK: define linkonce_odr {{.*}} @_ZN1BC1Ev(%struct.B* {{.*}}%this) unnamed_addr // CHECK: call {{.*}} @_ZN1AIiEC1Ev diff --git a/test/CodeGenCXX/deferred-global-init.cpp b/test/CodeGenCXX/deferred-global-init.cpp index 24c8c67..deb458f 100644 --- a/test/CodeGenCXX/deferred-global-init.cpp +++ b/test/CodeGenCXX/deferred-global-init.cpp @@ -7,10 +7,10 @@ void* bar() { return a; } // CHECK: @_ZL1a = internal global i8* null -// CHECK: define internal void @__cxx_global_var_init +// CHECK-LABEL: define internal void @__cxx_global_var_init // CHECK: load i8** @foo // CHECK: ret void -// CHECK: define internal void @_GLOBAL__I_a +// CHECK-LABEL: define internal void @_GLOBAL__I_a // CHECK: call void @__cxx_global_var_init() // CHECK: ret void diff --git a/test/CodeGenCXX/delayed-template-parsing.cpp b/test/CodeGenCXX/delayed-template-parsing.cpp new file mode 100644 index 0000000..fa177d4 --- /dev/null +++ b/test/CodeGenCXX/delayed-template-parsing.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -cxx-abi microsoft -fms-extensions -fdelayed-template-parsing -triple=i386-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -cxx-abi microsoft -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s + +namespace ClassScopeSpecialization { + struct Type { + template + void Foo() {} + template <> + void Foo<0>() {} + }; + + void call() { + Type T; +// CHECK: call {{.*}} @"\01??$Foo@$0A@@Type@ClassScopeSpecialization@@QAEXXZ" +// X64: call {{.*}} @"\01??$Foo@$0A@@Type@ClassScopeSpecialization@@QEAAXXZ" + T.Foo<0>(); + } +} diff --git a/test/CodeGenCXX/delete-two-arg.cpp b/test/CodeGenCXX/delete-two-arg.cpp index b82e9ba..f8e6bff 100644 --- a/test/CodeGenCXX/delete-two-arg.cpp +++ b/test/CodeGenCXX/delete-two-arg.cpp @@ -1,11 +1,11 @@ -// RUN: %clang_cc1 -triple i686-pc-linux-gnu %s -o - -emit-llvm -verify | FileCheck %s +// RUN: not %clang_cc1 -triple i686-pc-linux-gnu %s -o - -emit-llvm -verify | FileCheck %s typedef __typeof(sizeof(int)) size_t; namespace test1 { struct A { void operator delete(void*,size_t); int x; }; - // CHECK: define void @_ZN5test11aEPNS_1AE( + // CHECK-LABEL: define void @_ZN5test11aEPNS_1AE( void a(A *x) { // CHECK: load // CHECK-NEXT: icmp eq {{.*}}, null @@ -35,7 +35,7 @@ namespace test2 { return ::new A[10]; } - // CHECK: define void @_ZN5test24testEPNS_1AE( + // CHECK-LABEL: define void @_ZN5test24testEPNS_1AE( void test(A *p) { // CHECK: [[P:%.*]] = alloca [[A]]*, align 4 // CHECK-NEXT: store [[A]]* {{%.*}}, [[A]]** [[P]], align 4 @@ -60,7 +60,7 @@ namespace test3 { }; struct B : A {}; - // CHECK: define void @_ZN5test34testEv() + // CHECK-LABEL: define void @_ZN5test34testEv() void test() { // CHECK: call noalias i8* @_Znaj(i32 24) // CHECK-NEXT: bitcast diff --git a/test/CodeGenCXX/delete.cpp b/test/CodeGenCXX/delete.cpp index 1299b29..cdd5a89 100644 --- a/test/CodeGenCXX/delete.cpp +++ b/test/CodeGenCXX/delete.cpp @@ -19,7 +19,7 @@ struct T { int a; }; -// CHECK: define void @_Z2t4P1T +// CHECK-LABEL: define void @_Z2t4P1T void t4(T *t) { // CHECK: call void @_ZN1TD1Ev // CHECK-NEXT: bitcast @@ -46,7 +46,7 @@ namespace test0 { ~A() {} }; - // CHECK: define void @_ZN5test04testEPNS_1AE( + // CHECK-LABEL: define void @_ZN5test04testEPNS_1AE( void test(A *a) { // CHECK: call void @_ZN5test01AD1Ev // CHECK-NEXT: bitcast @@ -54,8 +54,8 @@ namespace test0 { delete a; } - // CHECK: define linkonce_odr void @_ZN5test01AD1Ev(%"struct.test0::A"* %this) unnamed_addr - // CHECK: define linkonce_odr void @_ZN5test01AdlEPv + // CHECK-LABEL: define linkonce_odr void @_ZN5test01AD1Ev(%"struct.test0::A"* %this) unnamed_addr + // CHECK-LABEL: define linkonce_odr void @_ZN5test01AdlEPv } namespace test1 { @@ -64,7 +64,7 @@ namespace test1 { ~A(); }; - // CHECK: define void @_ZN5test14testEPA10_A20_NS_1AE( + // CHECK-LABEL: define void @_ZN5test14testEPA10_A20_NS_1AE( void test(A (*arr)[10][20]) { delete [] arr; // CHECK: icmp eq [10 x [20 x [[A:%.*]]]]* [[PTR:%.*]], null @@ -88,7 +88,7 @@ namespace test1 { } namespace test2 { - // CHECK: define void @_ZN5test21fEPb + // CHECK-LABEL: define void @_ZN5test21fEPb void f(bool *b) { // CHECK: call void @_ZdlPv(i8* delete b; @@ -111,7 +111,7 @@ namespace test4 { void operator delete (void *); }; - // CHECK: define void @_ZN5test421global_delete_virtualEPNS_1XE + // CHECK-LABEL: define void @_ZN5test421global_delete_virtualEPNS_1XE void global_delete_virtual(X *xp) { // Load the offset-to-top from the vtable and apply it. // This has to be done first because the dtor can mess it up. @@ -136,7 +136,7 @@ namespace test4 { namespace test5 { struct Incomplete; - // CHECK: define void @_ZN5test523array_delete_incompleteEPNS_10IncompleteES1_ + // CHECK-LABEL: define void @_ZN5test523array_delete_incompleteEPNS_10IncompleteES1_ void array_delete_incomplete(Incomplete *p1, Incomplete *p2) { // CHECK: call void @_ZdlPv delete p1; @@ -145,4 +145,4 @@ namespace test5 { } } -// CHECK: attributes [[NUW]] = { nounwind{{.*}} } +// CHECK: attributes [[NUW]] = {{[{].*}} nounwind {{.*[}]}} diff --git a/test/CodeGenCXX/derived-to-base-conv.cpp b/test/CodeGenCXX/derived-to-base-conv.cpp index 9b15c68..675c50c 100644 --- a/test/CodeGenCXX/derived-to-base-conv.cpp +++ b/test/CodeGenCXX/derived-to-base-conv.cpp @@ -31,7 +31,7 @@ struct X { void test0_helper(A); void test0(X x) { test0_helper(x); - // CHECK: define void @_Z5test01X( + // CHECK-LABEL: define void @_Z5test01X( // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align // CHECK-NEXT: [[T0:%.*]] = call [[B:%.*]]* @_ZN1XcvR1BEv( // CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]* [[T0]] to [[A]]* @@ -60,7 +60,7 @@ struct Derived : Base { void test1_helper(Base); void test1(Derived bb) { - // CHECK: define void @_Z5test17Derived( + // CHECK-LABEL: define void @_Z5test17Derived( // CHECK-NOT: call {{.*}} @_ZN4BasecvR7DerivedEv( // CHECK: call void @_ZN4BaseC1ERKS_( // CHECK-NOT: call {{.*}} @_ZN4BasecvR7DerivedEv( @@ -75,7 +75,7 @@ class Test2a {}; class Test2b final : public virtual Test2a {}; void test2(Test2b &x) { Test2a &y = x; - // CHECK: define void @_Z5test2R6Test2b( + // CHECK-LABEL: define void @_Z5test2R6Test2b( // CHECK: [[X:%.*]] = alloca [[B:%.*]]*, align 8 // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]]*, align 8 // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]], align 8 diff --git a/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp b/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp index 0e15302..f2ecfc1 100644 --- a/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp +++ b/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp @@ -9,7 +9,7 @@ struct D final : virtual C { virtual void f(); }; -// CHECK: define %struct.B* @_Z1fR1D +// CHECK-LABEL: define %struct.B* @_Z1fR1D B &f(D &d) { // CHECK-NOT: load i8** return d; diff --git a/test/CodeGenCXX/destructor-exception-spec.cpp b/test/CodeGenCXX/destructor-exception-spec.cpp index 579daef..e111ba0 100644 --- a/test/CodeGenCXX/destructor-exception-spec.cpp +++ b/test/CodeGenCXX/destructor-exception-spec.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -emit-llvm-only %s -std=c++11 +// RUN: %clang_cc1 -emit-llvm-only -fno-use-cxa-atexit %s -std=c++11 +// RUN: %clang_cc1 -cxx-abi microsoft -fno-rtti -emit-llvm-only %s -std=c++11 // PR13479: don't crash with -fno-exceptions. namespace { diff --git a/test/CodeGenCXX/destructors.cpp b/test/CodeGenCXX/destructors.cpp index 7dc188b..799cca2 100644 --- a/test/CodeGenCXX/destructors.cpp +++ b/test/CodeGenCXX/destructors.cpp @@ -1,14 +1,10 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -mconstructor-aliases -fcxx-exceptions -fexceptions | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns | FileCheck %s -// CHECK: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev -// CHECK: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev -// CHECK: @_ZN5test11ND2Ev = alias {{.*}} @_ZN5test11AD2Ev -// CHECK: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev -// CHECK: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev - -// CHECK: @_ZN5test312_GLOBAL__N_11DD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11DD2Ev -// CHECK: @_ZN5test312_GLOBAL__N_11DD2Ev = alias internal bitcast {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev -// CHECK: @_ZN5test312_GLOBAL__N_11CD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev +// CHECK-DAG: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev +// CHECK-DAG: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev +// CHECK-DAG: @_ZN5test11ND2Ev = alias {{.*}} @_ZN5test11AD2Ev +// CHECK-DAG: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev +// CHECK-DAG: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev struct A { int a; @@ -40,13 +36,13 @@ namespace PR7526 { struct allocator_derived : allocator { }; - // CHECK: define void @_ZN6PR75269allocatorD2Ev(%"struct.PR7526::allocator"* %this) unnamed_addr + // CHECK-LABEL: define void @_ZN6PR75263fooEv() + // CHECK: call void {{.*}} @_ZN6PR75269allocatorD2Ev + + // CHECK-LABEL: define void @_ZN6PR75269allocatorD2Ev(%"struct.PR7526::allocator"* %this) unnamed_addr // CHECK: call void @__cxa_call_unexpected allocator::~allocator() throw() { foo(); } - // CHECK: define linkonce_odr void @_ZN6PR752617allocator_derivedD1Ev(%"struct.PR7526::allocator_derived"* %this) unnamed_addr - // CHECK-NOT: call void @__cxa_call_unexpected - // CHECK: } void foo() { allocator_derived ad; } @@ -93,7 +89,7 @@ namespace test0 { // complete destructor alias tested above -// CHECK: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) unnamed_addr +// CHECK-LABEL: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) unnamed_addr // CHECK: invoke void @_ZN5test06MemberD1Ev // CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]] // CHECK: invoke void @_ZN5test04BaseD2Ev @@ -106,7 +102,7 @@ namespace test0 { B::~B() try { } catch (int i) {} // It will suppress the delegation optimization here, though. -// CHECK: define void @_ZN5test01BD1Ev(%"struct.test0::B"* %this) unnamed_addr +// CHECK-LABEL: define void @_ZN5test01BD1Ev(%"struct.test0::B"* %this) unnamed_addr // CHECK: invoke void @_ZN5test06MemberD1Ev // CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]] // CHECK: invoke void @_ZN5test04BaseD2Ev @@ -114,7 +110,7 @@ namespace test0 { // CHECK: invoke void @_ZN5test05VBaseD2Ev // CHECK: unwind label [[VBASE_UNWIND:%[a-zA-Z0-9.]+]] -// CHECK: define void @_ZN5test01BD2Ev(%"struct.test0::B"* %this, i8** %vtt) unnamed_addr +// CHECK-LABEL: define void @_ZN5test01BD2Ev(%"struct.test0::B"* %this, i8** %vtt) unnamed_addr // CHECK: invoke void @_ZN5test06MemberD1Ev // CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]] // CHECK: invoke void @_ZN5test04BaseD2Ev @@ -142,24 +138,24 @@ namespace test1 { O::~O() {} // alias tested above struct P : NonEmpty, A { ~P(); }; - P::~P() {} // CHECK: define void @_ZN5test11PD2Ev(%"struct.test1::P"* %this) unnamed_addr + P::~P() {} // CHECK-LABEL: define void @_ZN5test11PD2Ev(%"struct.test1::P"* %this) unnamed_addr struct Q : A, B { ~Q(); }; - Q::~Q() {} // CHECK: define void @_ZN5test11QD2Ev(%"struct.test1::Q"* %this) unnamed_addr + Q::~Q() {} // CHECK-LABEL: define void @_ZN5test11QD2Ev(%"struct.test1::Q"* %this) unnamed_addr struct R : A { ~R(); }; - R::~R() { A a; } // CHECK: define void @_ZN5test11RD2Ev(%"struct.test1::R"* %this) unnamed_addr + R::~R() { A a; } // CHECK-LABEL: define void @_ZN5test11RD2Ev(%"struct.test1::R"* %this) unnamed_addr struct S : A { ~S(); int x; }; S::~S() {} // alias tested above struct T : A { ~T(); B x; }; - T::~T() {} // CHECK: define void @_ZN5test11TD2Ev(%"struct.test1::T"* %this) unnamed_addr + T::~T() {} // CHECK-LABEL: define void @_ZN5test11TD2Ev(%"struct.test1::T"* %this) unnamed_addr // The VTT parameter prevents this. We could still make this work // for calling conventions that are safe against extra parameters. struct U : A, virtual B { ~U(); }; - U::~U() {} // CHECK: define void @_ZN5test11UD2Ev(%"struct.test1::U"* %this, i8** %vtt) unnamed_addr + U::~U() {} // CHECK-LABEL: define void @_ZN5test11UD2Ev(%"struct.test1::U"* %this, i8** %vtt) unnamed_addr } // PR6471 @@ -168,7 +164,7 @@ namespace test2 { struct B : A { ~B(); }; B::~B() {} - // CHECK: define void @_ZN5test21BD2Ev(%"struct.test2::B"* %this) unnamed_addr + // CHECK-LABEL: define void @_ZN5test21BD2Ev(%"struct.test2::B"* %this) unnamed_addr // CHECK: call void @_ZN5test21AD2Ev } @@ -184,18 +180,12 @@ namespace test3 { void test() { new D; // Force emission of D's vtable } - - // Checked at top of file: - // @_ZN5test312_GLOBAL__N_11CD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev - - // More checks at end of file. - } namespace test4 { struct A { ~A(); }; - // CHECK: define void @_ZN5test43fooEv() + // CHECK-LABEL: define void @_ZN5test43fooEv() // CHECK: call void @_ZN5test41AD1Ev // CHECK: ret void void foo() { @@ -208,7 +198,7 @@ namespace test4 { return; } - // CHECK: define void @_ZN5test43barEi( + // CHECK-LABEL: define void @_ZN5test43barEi( // CHECK: [[X:%.*]] = alloca i32 // CHECK-NEXT: [[A:%.*]] = alloca // CHECK: br label @@ -233,7 +223,7 @@ namespace test4 { namespace test5 { struct A { ~A(); }; - // CHECK: define void @_ZN5test53fooEv() + // CHECK-LABEL: define void @_ZN5test53fooEv() // CHECK: [[ELEMS:%.*]] = alloca [5 x [[A:%.*]]], align // CHECK-NEXT: [[EXN:%.*]] = alloca i8* // CHECK-NEXT: [[SEL:%.*]] = alloca i32 @@ -272,7 +262,7 @@ namespace test6 { }; C::C() { opaque(); } - // CHECK: define void @_ZN5test61CC1Ev(%"struct.test6::C"* %this) unnamed_addr + // CHECK-LABEL: define void @_ZN5test61CC1Ev(%"struct.test6::C"* %this) unnamed_addr // CHECK: call void @_ZN5test61BILj2EEC2Ev // CHECK: invoke void @_ZN5test61BILj3EEC2Ev // CHECK: invoke void @_ZN5test61BILj0EEC2Ev @@ -282,7 +272,7 @@ namespace test6 { // FIXME: way too much EH cleanup code follows C::~C() { opaque(); } - // CHECK: define void @_ZN5test61CD1Ev(%"struct.test6::C"* %this) unnamed_addr + // CHECK-LABEL: define void @_ZN5test61CD1Ev(%"struct.test6::C"* %this) unnamed_addr // CHECK: invoke void @_ZN5test61CD2Ev // CHECK: invoke void @_ZN5test61BILj3EED2Ev // CHECK: call void @_ZN5test61BILj2EED2Ev @@ -290,7 +280,7 @@ namespace test6 { // CHECK: invoke void @_ZN5test61BILj3EED2Ev // CHECK: invoke void @_ZN5test61BILj2EED2Ev - // CHECK: define void @_ZN5test61CD2Ev(%"struct.test6::C"* %this, i8** %vtt) unnamed_addr + // CHECK-LABEL: define void @_ZN5test61CD2Ev(%"struct.test6::C"* %this, i8** %vtt) unnamed_addr // CHECK: invoke void @_ZN5test66opaqueEv // CHECK: invoke void @_ZN5test61AD1Ev // CHECK: invoke void @_ZN5test61AD1Ev @@ -318,7 +308,7 @@ namespace test7 { }; // Verify that this doesn't get emitted as an alias - // CHECK: define void @_ZN5test71BD2Ev( + // CHECK-LABEL: define void @_ZN5test71BD2Ev( // CHECK: invoke void @_ZN5test71DD1Ev( // CHECK: call void @_ZN5test71AD2Ev( B::~B() {} @@ -338,7 +328,7 @@ namespace test8 { l: die(); } - // CHECK: define void @_ZN5test84testEv() + // CHECK-LABEL: define void @_ZN5test84testEv() // CHECK: [[X:%.*]] = alloca [[A:%.*]], align 1 // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]], align 1 // CHECK: call void @_ZN5test81AC1Ev([[A]]* [[X]]) @@ -366,10 +356,26 @@ namespace test9 { // CHECK: call void @_ZN5test92f2Ev() } +namespace test10 { + // We used to crash trying to replace _ZN6test106OptionD1Ev with + // _ZN6test106OptionD2Ev twice. + struct Option { + virtual ~Option() {} + }; + template class opt : public Option {}; + template class opt; + // CHECK-LABEL: define zeroext i1 @_ZN6test1016handleOccurrenceEv( + bool handleOccurrence() { + // CHECK: call void @_ZN6test106OptionD2Ev( + Option x; + return true; + } +} + // Checks from test3: - // CHECK: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::::D"* %this) unnamed_addr - // CHECK: invoke void @_ZN5test312_GLOBAL__N_11DD1Ev( + // CHECK-LABEL: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::::D"* %this) unnamed_addr + // CHECK: invoke void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev // CHECK: call void @_ZdlPv({{.*}}) [[NUW:#[0-9]+]] // CHECK: ret void // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) @@ -377,21 +383,22 @@ namespace test9 { // CHECK: call void @_ZdlPv({{.*}}) [[NUW]] // CHECK: resume { i8*, i32 } - // Checked at top of file: - // @_ZN5test312_GLOBAL__N_11DD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11DD2Ev - // @_ZN5test312_GLOBAL__N_11DD2Ev = alias internal bitcast {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev - - // CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD1Ev( + // CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD1Ev( // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8 - // CHECK: call void @_ZN5test312_GLOBAL__N_11DD1Ev( + // CHECK: call void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev // CHECK: ret void - // CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD0Ev( + // CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD0Ev( // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8 // CHECK: call void @_ZN5test312_GLOBAL__N_11DD0Ev( // CHECK: ret void - // CHECK: define internal void @_ZN5test312_GLOBAL__N_11CD2Ev(%"struct.test3::::C"* %this) unnamed_addr + // CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD1Ev( + // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8 + // CHECK: call void @_ZN5test312_GLOBAL__N_11CD2Ev( + // CHECK: ret void + + // CHECK-LABEL: define internal void @_ZN5test312_GLOBAL__N_11CD2Ev(%"struct.test3::::C"* %this) unnamed_addr // CHECK: invoke void @_ZN5test31BD2Ev( // CHECK: call void @_ZN5test31AD2Ev( // CHECK: ret void @@ -399,8 +406,8 @@ namespace test9 { // CHECK: declare void @_ZN5test31BD2Ev( // CHECK: declare void @_ZN5test31AD2Ev( - // CHECK: define internal void @_ZN5test312_GLOBAL__N_11CD0Ev(%"struct.test3::::C"* %this) unnamed_addr - // CHECK: invoke void @_ZN5test312_GLOBAL__N_11CD1Ev( + // CHECK-LABEL: define internal void @_ZN5test312_GLOBAL__N_11CD0Ev(%"struct.test3::::C"* %this) unnamed_addr + // CHECK: invoke void @_ZN5test312_GLOBAL__N_11CD2Ev( // CHECK: call void @_ZdlPv({{.*}}) [[NUW]] // CHECK: ret void // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) @@ -408,14 +415,9 @@ namespace test9 { // CHECK: call void @_ZdlPv({{.*}}) [[NUW]] // CHECK: resume { i8*, i32 } - // CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD1Ev( - // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8 - // CHECK: call void @_ZN5test312_GLOBAL__N_11CD1Ev( - // CHECK: ret void - - // CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD0Ev( + // CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD0Ev( // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8 // CHECK: call void @_ZN5test312_GLOBAL__N_11CD0Ev( // CHECK: ret void - // CHECK: attributes [[NUW]] = { nounwind{{.*}} } + // CHECK: attributes [[NUW]] = {{[{].*}} nounwind {{.*[}]}} diff --git a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp index 40f3cad..11026e8 100644 --- a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp +++ b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp @@ -5,7 +5,7 @@ namespace Test1 { virtual int f() final; }; - // CHECK: define i32 @_ZN5Test11fEPNS_1AE + // CHECK-LABEL: define i32 @_ZN5Test11fEPNS_1AE int f(A *a) { // CHECK: call i32 @_ZN5Test11A1fEv return a->f(); @@ -17,7 +17,7 @@ namespace Test2 { virtual int f(); }; - // CHECK: define i32 @_ZN5Test21fEPNS_1AE + // CHECK-LABEL: define i32 @_ZN5Test21fEPNS_1AE int f(A *a) { // CHECK: call i32 @_ZN5Test21A1fEv return a->f(); @@ -31,19 +31,19 @@ namespace Test3 { struct B final : A { }; - // CHECK: define i32 @_ZN5Test31fEPNS_1BE + // CHECK-LABEL: define i32 @_ZN5Test31fEPNS_1BE int f(B *b) { // CHECK: call i32 @_ZN5Test31A1fEv return b->f(); } - // CHECK: define i32 @_ZN5Test31fERNS_1BE + // CHECK-LABEL: define i32 @_ZN5Test31fERNS_1BE int f(B &b) { // CHECK: call i32 @_ZN5Test31A1fEv return b.f(); } - // CHECK: define i32 @_ZN5Test31fEPv + // CHECK-LABEL: define i32 @_ZN5Test31fEPv int f(void *v) { // CHECK: call i32 @_ZN5Test31A1fEv return static_cast(v)->f(); @@ -59,7 +59,7 @@ namespace Test4 { virtual void f(); }; - // CHECK: define void @_ZN5Test41fEPNS_1BE + // CHECK-LABEL: define void @_ZN5Test41fEPNS_1BE void f(B* d) { // CHECK: call void @_ZN5Test41B1fEv static_cast(d)->f(); @@ -78,7 +78,7 @@ namespace Test5 { struct C final : B { }; - // CHECK: define void @_ZN5Test51fEPNS_1CE + // CHECK-LABEL: define void @_ZN5Test51fEPNS_1CE void f(C* d) { // FIXME: It should be possible to devirtualize this case, but that is // not implemented yet. @@ -105,7 +105,7 @@ namespace Test6 { struct D final : public C, public B { }; - // CHECK: define void @_ZN5Test61fEPNS_1DE + // CHECK-LABEL: define void @_ZN5Test61fEPNS_1DE void f(D* d) { // CHECK: call void @_ZN5Test61DD1Ev static_cast(d)->~A(); @@ -126,7 +126,7 @@ namespace Test7 { virtual int f() {return z;} }; - // CHECK: define i32 @_ZN5Test71fEPNS_3zedE + // CHECK-LABEL: define i32 @_ZN5Test71fEPNS_3zedE int f(zed *z) { // CHECK: alloca // CHECK-NEXT: store @@ -144,7 +144,7 @@ namespace Test8 { virtual int foo() { return b; } }; struct C final : A, B { }; - // CHECK: define i32 @_ZN5Test84testEPNS_1CE + // CHECK-LABEL: define i32 @_ZN5Test84testEPNS_1CE int test(C *c) { // CHECK: %[[THIS:.*]] = phi // CHECK-NEXT: call i32 @_ZN5Test81B3fooEv(%"struct.Test8::B"* %[[THIS]]) diff --git a/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp b/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp index 52f1cd3..911ddee 100644 --- a/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp +++ b/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp @@ -79,7 +79,7 @@ namespace test3 { struct D : public B { }; void f(D d) { - // CHECK: define void @_ZN5test31fENS_1DE + // CHECK-LABEL: define void @_ZN5test31fENS_1DE d.B::~B(); } } diff --git a/test/CodeGenCXX/dynamic_cast-no-rtti.cpp b/test/CodeGenCXX/dynamic_cast-no-rtti.cpp new file mode 100644 index 0000000..0e26de5 --- /dev/null +++ b/test/CodeGenCXX/dynamic_cast-no-rtti.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -emit-llvm %s -verify -fno-rtti -o - | FileCheck %s +// expected-no-diagnostics + +struct A { + virtual ~A(){}; +}; + +struct B : public A { + B() : A() {} +}; + +// An upcast can be resolved statically and can be used with -fno-rtti, iff it +// does not use runtime support. +A *upcast(B *b) { + return dynamic_cast(b); +// CHECK-LABEL: define %struct.A* @_Z6upcastP1B +// CHECK-NOT: call i8* @__dynamic_cast +} + +// A NoOp dynamic_cast can be used with -fno-rtti iff it does not use +// runtime support. +B *samecast(B *b) { + return dynamic_cast(b); +// CHECK-LABEL: define %struct.B* @_Z8samecastP1B +// CHECK-NOT: call i8* @__dynamic_cast +} diff --git a/test/CodeGenCXX/eh.cpp b/test/CodeGenCXX/eh.cpp index 70887f7..2a61e61 100644 --- a/test/CodeGenCXX/eh.cpp +++ b/test/CodeGenCXX/eh.cpp @@ -9,7 +9,7 @@ void test1() { throw d1; } -// CHECK: define void @_Z5test1v() +// CHECK-LABEL: define void @_Z5test1v() // CHECK: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8) // CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]] // CHECK-NEXT: [[EXN2:%.*]] = bitcast [[DSTAR]] [[EXN]] to i8* @@ -29,7 +29,7 @@ void test2() { throw d2; } -// CHECK: define void @_Z5test2v() +// CHECK-LABEL: define void @_Z5test2v() // CHECK: [[EXNVAR:%.*]] = alloca i8* // CHECK-NEXT: [[SELECTORVAR:%.*]] = alloca i32 // CHECK-NEXT: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 16) @@ -51,7 +51,7 @@ void test3() { throw (volatile test3_D *)0; } -// CHECK: define void @_Z5test3v() +// CHECK-LABEL: define void @_Z5test3v() // CHECK: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8) // CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[D:%[^*]+]]** // CHECK-NEXT: store [[D]]* null, [[D]]** [[EXN]] @@ -63,7 +63,7 @@ void test4() { throw; } -// CHECK: define void @_Z5test4v() +// CHECK-LABEL: define void @_Z5test4v() // CHECK: call void @__cxa_rethrow() [[NR]] // CHECK-NEXT: unreachable @@ -79,7 +79,7 @@ namespace test5 { void test() { try { throw A(); } catch (A &x) {} } -// CHECK: define void @_ZN5test54testEv() +// CHECK-LABEL: define void @_ZN5test54testEv() // CHECK: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 1) // CHECK: [[EXNCAST:%.*]] = bitcast i8* [[EXNOBJ]] to [[A:%[^*]*]]* // CHECK-NEXT: invoke void @_ZN5test51AC1Ev([[A]]* [[EXNCAST]]) @@ -101,7 +101,7 @@ namespace test6 { // PR7127 namespace test7 { -// CHECK: define i32 @_ZN5test73fooEv() +// CHECK-LABEL: define i32 @_ZN5test73fooEv() int foo() { // CHECK: [[CAUGHTEXNVAR:%.*]] = alloca i8* // CHECK-NEXT: [[SELECTORVAR:%.*]] = alloca i32 @@ -160,7 +160,7 @@ namespace test8 { struct A { A(const A&); ~A(); }; void bar(); - // CHECK: define void @_ZN5test83fooEv() + // CHECK-LABEL: define void @_ZN5test83fooEv() void foo() { try { // CHECK: invoke void @_ZN5test83barEv() @@ -184,11 +184,11 @@ namespace test9 { struct A { A(); }; - // CHECK: define void @_ZN5test91AC1Ev(%"struct.test9::A"* %this) unnamed_addr + // CHECK-LABEL: define void @_ZN5test91AC1Ev(%"struct.test9::A"* %this) unnamed_addr // CHECK: call void @_ZN5test91AC2Ev // CHECK-NEXT: ret void - // CHECK: define void @_ZN5test91AC2Ev(%"struct.test9::A"* %this) unnamed_addr + // CHECK-LABEL: define void @_ZN5test91AC2Ev(%"struct.test9::A"* %this) unnamed_addr A::A() try { // CHECK: invoke void @_ZN5test96opaqueEv() opaque(); @@ -210,7 +210,7 @@ namespace test10 { struct A { ~A(); }; struct B { int x; }; - // CHECK: define void @_ZN6test103fooEv() + // CHECK-LABEL: define void @_ZN6test103fooEv() void foo() { A a; // force a cleanup context @@ -244,7 +244,7 @@ namespace test10 { namespace test11 { void opaque(); - // CHECK: define void @_ZN6test113fooEv() + // CHECK-LABEL: define void @_ZN6test113fooEv() void foo() { try { // CHECK: invoke void @_ZN6test116opaqueEv() @@ -261,7 +261,7 @@ namespace test11 { struct A {}; - // CHECK: define void @_ZN6test113barEv() + // CHECK-LABEL: define void @_ZN6test113barEv() void bar() { try { // CHECK: [[EXNSLOT:%.*]] = alloca i8* @@ -286,7 +286,7 @@ namespace test12 { struct A { ~A() noexcept(false); }; bool opaque(const A&); - // CHECK: define void @_ZN6test124testEv() + // CHECK-LABEL: define void @_ZN6test124testEv() void test() { // CHECK: [[X:%.*]] = alloca [[A:%.*]], // CHECK: [[EHCLEANUPDEST:%.*]] = alloca i32 @@ -371,7 +371,7 @@ namespace test15 { bool opaque(int); - // CHECK: define void @_ZN6test153fooEv() + // CHECK-LABEL: define void @_ZN6test153fooEv() void foo() { A a; @@ -405,7 +405,7 @@ namespace test16 { void foo(); bool cond(); - // CHECK: define void @_ZN6test163barEv() + // CHECK-LABEL: define void @_ZN6test163barEv() void bar() { // CHECK: [[EXN_SAVE:%.*]] = alloca i8* // CHECK-NEXT: [[EXN_ACTIVE:%.*]] = alloca i1 diff --git a/test/CodeGenCXX/empty-classes.cpp b/test/CodeGenCXX/empty-classes.cpp index 1ce1dad..8491480 100644 --- a/test/CodeGenCXX/empty-classes.cpp +++ b/test/CodeGenCXX/empty-classes.cpp @@ -29,7 +29,7 @@ struct D : A, Empty { #define CHECK(x) if (!(x)) return __LINE__ // PR7012 -// CHECK: define i32 @_Z1fv() +// CHECK-LABEL: define i32 @_Z1fv() int f() { B b1; diff --git a/test/CodeGenCXX/empty-nontrivially-copyable.cpp b/test/CodeGenCXX/empty-nontrivially-copyable.cpp new file mode 100644 index 0000000..9ee3281 --- /dev/null +++ b/test/CodeGenCXX/empty-nontrivially-copyable.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple armv7-apple-ios -x c++ -emit-llvm -o - %s | FileCheck %s + +// According to the Itanium ABI (3.1.1), types with non-trivial copy +// constructors passed by value should be passed indirectly, with the caller +// creating a temporary. + +struct Empty; + +struct Empty { + Empty(const Empty &e); + bool check(); +}; + +bool foo(Empty e) { +// CHECK: @_Z3foo5Empty(%struct.Empty* %e) +// CHECK: call {{.*}} @_ZN5Empty5checkEv(%struct.Empty* %e) + return e.check(); +} + +void caller(Empty &e) { +// CHECK: @_Z6callerR5Empty(%struct.Empty* %e) +// CHECK: call {{.*}} @_ZN5EmptyC1ERKS_(%struct.Empty* [[NEWTMP:%.*]], %struct.Empty* +// CHECK: call {{.*}} @_Z3foo5Empty(%struct.Empty* [[NEWTMP]]) + foo(e); +} diff --git a/test/CodeGenCXX/exceptions.cpp b/test/CodeGenCXX/exceptions.cpp index f6f5079..d37e610 100644 --- a/test/CodeGenCXX/exceptions.cpp +++ b/test/CodeGenCXX/exceptions.cpp @@ -269,7 +269,7 @@ namespace test5 { void foo(); - // CHECK: define void @_ZN5test54testEv() + // CHECK-LABEL: define void @_ZN5test54testEv() // CHECK: [[EXNSLOT:%.*]] = alloca i8* // CHECK-NEXT: [[SELECTORSLOT:%.*]] = alloca i32 // CHECK-NEXT: [[A:%.*]] = alloca [[A_T:%.*]], align 1 @@ -403,7 +403,7 @@ namespace test8 { void test() { throw makeA(); } - // CHECK: define void @_ZN5test84testEv + // CHECK-LABEL: define void @_ZN5test84testEv } // Make sure we generate the correct code for the delete[] call which @@ -432,14 +432,14 @@ namespace test10 { struct A { ~A(); }; A::~A() try { cleanup(); } catch (...) { return; } - // CHECK: define void @_ZN6test101AD1Ev( + // CHECK-LABEL: 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-LABEL: define void @_ZN6test101BD1Ev( // CHECK: invoke void @_ZN6test107cleanupEv() // CHECK: call i8* @__cxa_begin_catch // CHECK-NEXT: invoke void @__cxa_rethrow() @@ -447,7 +447,7 @@ namespace test10 { struct C { ~C(); }; C::~C() try { cleanup(); } catch (...) { if (suppress) return; } - // CHECK: define void @_ZN6test101CD1Ev( + // CHECK-LABEL: define void @_ZN6test101CD1Ev( // CHECK: invoke void @_ZN6test107cleanupEv() // CHECK: call i8* @__cxa_begin_catch // CHECK-NEXT: load i8* @_ZN6test108suppressE, align 1 @@ -477,7 +477,7 @@ namespace test11 { C::C() { throw 0; } - // CHECK: define void @_ZN6test111CC2Ev( + // CHECK-LABEL: define void @_ZN6test111CC2Ev( // CHECK: [[THIS:%.*]] = load [[C:%.*]]** {{%.*}} // Construct single. // CHECK-NEXT: [[SINGLE:%.*]] = getelementptr inbounds [[C]]* [[THIS]], i32 0, i32 0 diff --git a/test/CodeGenCXX/explicit-instantiation.cpp b/test/CodeGenCXX/explicit-instantiation.cpp index 8daf3c6..6a4fd82 100644 --- a/test/CodeGenCXX/explicit-instantiation.cpp +++ b/test/CodeGenCXX/explicit-instantiation.cpp @@ -13,7 +13,7 @@ Result plus::operator()(const T& t, const U& u) const { return t + u; } -// CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl +// CHECK-LABEL: define weak_odr i32 @_ZNK4plusIillEclERKiRKl template struct plus; // Check that we emit definitions from explicit instantiations even when they @@ -27,16 +27,16 @@ template struct S { }; }; -// CHECK: define weak_odr void @_ZN1SIiE1fEv +// CHECK-LABEL: define weak_odr void @_ZN1SIiE1fEv template void S::f(); -// CHECK: define weak_odr void @_ZN1SIiE1gEv +// CHECK-LABEL: define weak_odr void @_ZN1SIiE1gEv template void S::g(); // See the check line at the top of the file. template int S::i; -// CHECK: define weak_odr void @_ZN1SIiE2S21hEv +// CHECK-LABEL: define weak_odr void @_ZN1SIiE2S21hEv template void S::S2::h(); template void S::f() {} diff --git a/test/CodeGenCXX/fastcall.cpp b/test/CodeGenCXX/fastcall.cpp index c0a9106..0326ce5 100644 --- a/test/CodeGenCXX/fastcall.cpp +++ b/test/CodeGenCXX/fastcall.cpp @@ -2,7 +2,7 @@ void __attribute__((fastcall)) foo1(int &y); void bar1(int &y) { - // CHECK: define void @_Z4bar1Ri + // CHECK-LABEL: define void @_Z4bar1Ri // CHECK: call x86_fastcallcc void @_Z4foo1Ri(i32* inreg % foo1(y); } @@ -14,7 +14,7 @@ struct S1 { void __attribute__((fastcall)) foo2(S1 a, int b); void bar2(S1 a, int b) { - // CHECK: define void @_Z4bar22S1i + // CHECK-LABEL: define void @_Z4bar22S1i // CHECK: call x86_fastcallcc void @_Z4foo22S1i(%struct.S1* inreg %{{.*}}, i32 inreg % foo2(a, b); } diff --git a/test/CodeGenCXX/for-range.cpp b/test/CodeGenCXX/for-range.cpp index 926fe44..8124129 100644 --- a/test/CodeGenCXX/for-range.cpp +++ b/test/CodeGenCXX/for-range.cpp @@ -32,7 +32,7 @@ B *end(C&); extern B array[5]; -// CHECK: define void @_Z9for_arrayv( +// CHECK-LABEL: define void @_Z9for_arrayv( void for_array() { // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) A a; @@ -40,7 +40,7 @@ void for_array() { // CHECK-NOT: 5begin // CHECK-NOT: 3end // CHECK: getelementptr {{.*}}, i32 0 - // CHECK: getelementptr {{.*}}, i64 1, i64 0 + // CHECK: getelementptr {{.*}}, i64 5 // CHECK: br label %[[COND:.*]] // CHECK: [[COND]]: @@ -61,7 +61,7 @@ void for_array() { // CHECK: ret void } -// CHECK: define void @_Z9for_rangev( +// CHECK-LABEL: define void @_Z9for_rangev( void for_range() { // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) A a; @@ -93,7 +93,7 @@ void for_range() { // CHECK: ret void } -// CHECK: define void @_Z16for_member_rangev( +// CHECK-LABEL: define void @_Z16for_member_rangev( void for_member_range() { // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) A a; diff --git a/test/CodeGenCXX/forward-enum.cpp b/test/CodeGenCXX/forward-enum.cpp index c1169e0..685e4f3 100644 --- a/test/CodeGenCXX/forward-enum.cpp +++ b/test/CodeGenCXX/forward-enum.cpp @@ -3,7 +3,7 @@ enum MyEnum : char; void bar(MyEnum value) { } -// CHECK: define void @_Z3foo6MyEnum +// CHECK-LABEL: define void @_Z3foo6MyEnum void foo(MyEnum value) { // CHECK: call void @_Z3bar6MyEnum(i8 signext diff --git a/test/CodeGenCXX/fp16-mangle.cpp b/test/CodeGenCXX/fp16-mangle.cpp index 4a056d6..bd5a319 100644 --- a/test/CodeGenCXX/fp16-mangle.cpp +++ b/test/CodeGenCXX/fp16-mangle.cpp @@ -4,9 +4,9 @@ template struct S { static int i; }; template <> int S<__fp16, __fp16>::i = 3; -// CHECK: define void @_Z1fPDh(i16* %x) +// CHECK-LABEL: define void @_Z1fPDh(i16* %x) void f (__fp16 *x) { } -// CHECK: define void @_Z1gPDhS_(i16* %x, i16* %y) +// CHECK-LABEL: define void @_Z1gPDhS_(i16* %x, i16* %y) void g (__fp16 *x, __fp16 *y) { } diff --git a/test/CodeGenCXX/function-template-explicit-specialization.cpp b/test/CodeGenCXX/function-template-explicit-specialization.cpp index 21f0127..5d26dcd 100644 --- a/test/CodeGenCXX/function-template-explicit-specialization.cpp +++ b/test/CodeGenCXX/function-template-explicit-specialization.cpp @@ -3,11 +3,11 @@ template void a(T); template<> void a(int) {} -// CHECK: define void @_Z1aIiEvT_ +// CHECK-LABEL: define void @_Z1aIiEvT_ namespace X { template void b(T); template<> void b(int) {} } -// CHECK: define void @_ZN1X1bIiEEvT_ +// CHECK-LABEL: define void @_ZN1X1bIiEEvT_ diff --git a/test/CodeGenCXX/global-array-destruction.cpp b/test/CodeGenCXX/global-array-destruction.cpp index 087d655..6ebc139 100644 --- a/test/CodeGenCXX/global-array-destruction.cpp +++ b/test/CodeGenCXX/global-array-destruction.cpp @@ -56,7 +56,7 @@ using U = T[2][3]; U &&u = U{ {{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 ([2 x [3 x {{.*}}]]* @_ZGR1u, i64 1, i64 0, i64 0) +// CHECK: getelementptr inbounds ({{.*}}* getelementptr inbounds ([2 x [3 x {{.*}}]]* @_ZGR1u, i32 0, i32 0, i32 0), i64 6) // CHECK: call void @_ZN1TD1Ev // CHECK: icmp eq {{.*}} @_ZGR1u // CHECK: br i1 {{.*}} diff --git a/test/CodeGenCXX/global-block-literal-helpers.cpp b/test/CodeGenCXX/global-block-literal-helpers.cpp index 350ea54..762b5d9 100644 --- a/test/CodeGenCXX/global-block-literal-helpers.cpp +++ b/test/CodeGenCXX/global-block-literal-helpers.cpp @@ -5,23 +5,23 @@ 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 +// CHECK-LABEL: define internal void @_ZN1N8ArrBlockE_block_invoke( +// CHECK-LABEL: define internal void @_ZN1N8ArrBlockE_block_invoke_2( +// CHECK-LABEL: 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( +// CHECK-LABEL: define internal void @_ZN1N4ivalE_block_invoke_4( +// CHECK-LABEL: define internal void @_ZN1N4ivalE_block_invoke_5( +// CHECK-LABEL: define internal void @_ZN1N4ivalE_block_invoke_6( int ival = func(^{}, ^{}, ^{}); -// CHECK: define internal void @_ZN1N9gvarlobalE_block_invoke_7( +// CHECK-LABEL: define internal void @_ZN1N9gvarlobalE_block_invoke_7( void (^gvarlobal)(void) = ^{}; struct S { BL field = ^{}; }; -// CHECK: define internal void @_ZN1N3blfE_block_invoke_8( +// CHECK-LABEL: define internal void @_ZN1N3blfE_block_invoke_8( S blf; }; diff --git a/test/CodeGenCXX/global-dtor-no-atexit.cpp b/test/CodeGenCXX/global-dtor-no-atexit.cpp index 7c4b6aa..9d35e84 100644 --- a/test/CodeGenCXX/global-dtor-no-atexit.cpp +++ b/test/CodeGenCXX/global-dtor-no-atexit.cpp @@ -22,7 +22,7 @@ public: A a, b; // PR9593 -// CHECK: define void @_Z4funcv() +// CHECK-LABEL: define void @_Z4funcv() // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a1) // CHECK: call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a1) // CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a1) diff --git a/test/CodeGenCXX/global-init.cpp b/test/CodeGenCXX/global-init.cpp index 426cf9c..69631c2 100644 --- a/test/CodeGenCXX/global-init.cpp +++ b/test/CodeGenCXX/global-init.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -fexceptions %s -o - |FileCheck %s -// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck -check-prefix NOEXC %s +// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck -check-prefix CHECK-NOEXC %s struct A { A(); @@ -45,7 +45,7 @@ namespace test1 { const int y = x - 1; // This gets deferred. const int z = ~y; // This also gets deferred, but gets "undeferred" before y. int test() { return z; } -// CHECK: define i32 @_ZN5test14testEv() +// CHECK-LABEL: define i32 @_ZN5test14testEv() // All of these initializers end up delayed, so we check them later. } diff --git a/test/CodeGenCXX/goto.cpp b/test/CodeGenCXX/goto.cpp index 77b6166..904f95f 100644 --- a/test/CodeGenCXX/goto.cpp +++ b/test/CodeGenCXX/goto.cpp @@ -5,7 +5,7 @@ namespace test0 { struct A { A(); ~A(); }; struct V { V(const A &a = A()); ~V(); }; - // CHECK: define linkonce_odr i32 @_ZN5test04testILi0EEEii + // CHECK-LABEL: define linkonce_odr i32 @_ZN5test04testILi0EEEii template int test(int x) { // CHECK: [[RET:%.*]] = alloca i32 // CHECK-NEXT: [[X:%.*]] = alloca i32 diff --git a/test/CodeGenCXX/implicit-copy-assign-operator.cpp b/test/CodeGenCXX/implicit-copy-assign-operator.cpp index 79586fb..2674021 100644 --- a/test/CodeGenCXX/implicit-copy-assign-operator.cpp +++ b/test/CodeGenCXX/implicit-copy-assign-operator.cpp @@ -40,7 +40,7 @@ void test_D(D d1, D d2) { d1 = d2; } -// CHECK: define linkonce_odr %struct.D* @_ZN1DaSERS_ +// CHECK-LABEL: define linkonce_odr %struct.D* @_ZN1DaSERS_ // CHECK: {{call.*_ZN1AaSERS_}} // CHECK: {{call.*_ZN1BaSERS_}} // CHECK: {{call.*_ZN1CaSERKS_}} diff --git a/test/CodeGenCXX/implicit-copy-constructor.cpp b/test/CodeGenCXX/implicit-copy-constructor.cpp index 24e84d5..bb04318 100644 --- a/test/CodeGenCXX/implicit-copy-constructor.cpp +++ b/test/CodeGenCXX/implicit-copy-constructor.cpp @@ -40,7 +40,7 @@ void f(D d) { D d2(d); } -// CHECK: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* %this, %struct.D*) unnamed_addr +// CHECK-LABEL: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* %this, %struct.D*) unnamed_addr // CHECK: call void @_ZN1AC1Ev // CHECK: call void @_ZN1CC2ERS_1A // CHECK: call void @_ZN1AD1Ev diff --git a/test/CodeGenCXX/implicit-instantiation-1.cpp b/test/CodeGenCXX/implicit-instantiation-1.cpp index 0c826e4..bf6a141 100644 --- a/test/CodeGenCXX/implicit-instantiation-1.cpp +++ b/test/CodeGenCXX/implicit-instantiation-1.cpp @@ -20,7 +20,7 @@ void foo(X &xi, X *xfp, int i, float f) { // RUN: grep "linkonce_odr.*_ZN1XIfE1fEf" %t | count 1 xfp->f(f); - // RUN: grep "linkonce_odr.*_ZN1XIfE1hEf" %t | count 0 + // RUN: not grep "linkonce_odr.*_ZN1XIfE1hEf" %t } diff --git a/test/CodeGenCXX/inheriting-constructor.cpp b/test/CodeGenCXX/inheriting-constructor.cpp index 0f39784..c99a20c 100644 --- a/test/CodeGenCXX/inheriting-constructor.cpp +++ b/test/CodeGenCXX/inheriting-constructor.cpp @@ -11,18 +11,18 @@ struct C { template C(T); }; struct D : C { using C::C; }; D d(123); -// CHECK: define void @_ZN1BD0Ev -// CHECK: define void @_ZN1BD1Ev -// CHECK: define void @_ZN1BD2Ev +// CHECK-LABEL: define void @_ZN1BD0Ev +// CHECK-LABEL: define void @_ZN1BD1Ev +// CHECK-LABEL: define void @_ZN1BD2Ev -// CHECK: define linkonce_odr void @_ZN1BC1Ei( +// CHECK-LABEL: define linkonce_odr void @_ZN1BC1Ei( // CHECK: call void @_ZN1BC2Ei( -// CHECK: define linkonce_odr void @_ZN1DC1IiEET_( +// CHECK-LABEL: define linkonce_odr void @_ZN1DC1IiEET_( // CHECK: call void @_ZN1DC2IiEET_( -// CHECK: define linkonce_odr void @_ZN1DC2IiEET_( +// CHECK-LABEL: define linkonce_odr void @_ZN1DC2IiEET_( // CHECK: call void @_ZN1CC2IiEET_( -// CHECK: define linkonce_odr void @_ZN1BC2Ei( +// CHECK-LABEL: define linkonce_odr void @_ZN1BC2Ei( // CHECK: call void @_ZN1AC2Ei( diff --git a/test/CodeGenCXX/init-invariant.cpp b/test/CodeGenCXX/init-invariant.cpp index 9eb1989..45816b2 100644 --- a/test/CodeGenCXX/init-invariant.cpp +++ b/test/CodeGenCXX/init-invariant.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -O0 -o - | FileCheck %s --check-prefix=CHECK-O0 +// RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-O0 // RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -O1 -o - | FileCheck %s // Check that we add an llvm.invariant.start to mark when a global becomes @@ -54,7 +54,7 @@ void e() { // CHECK: store {{.*}}, i32* @d // CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @d to i8*)) -// CHECK: define void @_Z1ev( +// CHECK-LABEL: define void @_Z1ev( // CHECK: call void @_ZN1AC1Ev(%struct.A* @_ZZ1evE1a) // CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @_ZZ1evE1a to i8*)) // CHECK-NOT: llvm.invariant.end diff --git a/test/CodeGenCXX/inline-functions.cpp b/test/CodeGenCXX/inline-functions.cpp index 8c011de..9f8e536 100644 --- a/test/CodeGenCXX/inline-functions.cpp +++ b/test/CodeGenCXX/inline-functions.cpp @@ -5,7 +5,7 @@ struct A { inline void f(); }; -// CHECK-NOT: define void @_ZN1A1fEv +// CHECK-NOT-LABEL: define void @_ZN1A1fEv void A::f() { } template struct B { }; @@ -19,13 +19,13 @@ void B::f() { } // We need a final CHECK line here. -// CHECK: define void @_Z1fv +// CHECK-LABEL: define void @_Z1fv void f() { } // inline void f1(int); -// CHECK: define linkonce_odr void @_Z2f1i +// CHECK-LABEL: define linkonce_odr void @_Z2f1i void f1(int) { } void test_f1() { f1(17); } @@ -38,7 +38,7 @@ namespace test1 { void g() {} }; - // CHECK: define linkonce_odr void @_ZN5test11C4funcEv( + // CHECK-LABEL: define linkonce_odr void @_ZN5test11C4funcEv( class C { public: @@ -65,5 +65,5 @@ namespace test2 { A a; f(a); } - // CHECK: define linkonce_odr void @_ZN5test21fERKNS_1AE + // CHECK-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE } diff --git a/test/CodeGenCXX/instantiate-temporaries.cpp b/test/CodeGenCXX/instantiate-temporaries.cpp index 29cfc07..c08ea78 100644 --- a/test/CodeGenCXX/instantiate-temporaries.cpp +++ b/test/CodeGenCXX/instantiate-temporaries.cpp @@ -18,7 +18,7 @@ void call() { Y().get(); } -// CHECK: define weak_odr void @_Z4callIiEvv +// CHECK-LABEL: define weak_odr void @_Z4callIiEvv // CHECK: call void @_ZN1Y3getEv // CHECK-NEXT: call void @_ZN1XD1Ev // CHECK-NEXT: ret void @@ -29,7 +29,7 @@ void compound_literal() { (X2){}; } -// CHECK: define weak_odr void @_Z16compound_literalIiEvv +// CHECK-LABEL: define weak_odr void @_Z16compound_literalIiEvv // CHECK: call void @_ZN1XC1Ev // CHECK-NEXT: call void @_ZN2X2D1Ev // CHECK-NEXT: ret void diff --git a/test/CodeGenCXX/invalid.cpp b/test/CodeGenCXX/invalid.cpp new file mode 100644 index 0000000..d346246 --- /dev/null +++ b/test/CodeGenCXX/invalid.cpp @@ -0,0 +1,11 @@ +// RUN: not %clang_cc1 -g -emit-llvm %s + +// Don't attempt to codegen invalid code that would lead to a crash + +// PR16933 +struct A; +A *x; +struct A { + B y; +}; +A y; diff --git a/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp b/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp new file mode 100644 index 0000000..0083f08 --- /dev/null +++ b/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp @@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++1y | FileCheck %s + +// CHECK-LABEL: define void @_ZN19non_inline_function3fooEv +// CHECK-LABEL: define internal void @"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon +// CHECK-LABEL: define internal signext i8 @"_ZZZN19non_inline_function3fooEvENK3$_0clEiENKUlcE_clEc"(%class.anon +// CHECK-LABEL: define linkonce_odr void @_ZN19non_inline_function4foo2IiEEDav() +namespace non_inline_function { +auto foo() { + auto L = [](int a) { + return [](char b) { + return b; + }; + }; + L(3)('a'); + return L; +} + +template +auto foo2() { + return [](const T&) { return 42; }; +} + +auto use = foo2(); + +} +//CHECK-LABEL: define linkonce_odr void @_ZN22inline_member_function1X3fooEv(%"struct.inline_member_function::X"* %this) +//CHECK-LABEL: define linkonce_odr void @_ZZN22inline_member_function1X3fooEvENKUliE_clEi(%class.anon +//CHECK-LABEL: define linkonce_odr signext i8 @_ZZZN22inline_member_function1X3fooEvENKUliE_clEiENKUlcE_clEc(%class.anon + +namespace inline_member_function { +struct X { +auto foo() { + auto L = [](int a) { + return [](char b) { + return b; + }; + }; + return L; +} +}; + +auto run1 = X{}.foo()(3)('a'); + +template +struct A { + template static auto default_lambda() { + return [](const T&) { return 42; }; + } + + template())> + U func(U u = default_lambda()) { return u; } + + template auto foo() { return [](const T&) { return 42; }; } +}; +//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES5_(%class.anon +int run2 = A{}.func()(3.14); + +//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES5_(%class.anon +int run3 = A{}.func()('a'); +} // end inline_member_function + + +// CHECK-LABEL: define linkonce_odr void @_ZN15inline_function3fooEv() +// CHECK: define linkonce_odr void @_ZZN15inline_function3fooEvENKUliE_clEi(%class.anon +// CHECK: define linkonce_odr signext i8 @_ZZZN15inline_function3fooEvENKUliE_clEiENKUlcE_clEc(%class.anon +namespace inline_function { +inline auto foo() { + auto L = [](int a) { + return [](char b) { + return b; + }; + }; + return L; +} +auto use = foo()(3)('a'); +} + diff --git a/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp b/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp new file mode 100644 index 0000000..accc5d2 --- /dev/null +++ b/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s + +// CHECK-LABEL: define void @_ZN19non_inline_function3fooEv() +// CHECK-LABEL: define internal void @"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon +// CHECK-LABEL: define internal signext i8 @"_ZZZN19non_inline_function3fooEvENK3$_0clEiENKUlcE_clEc"(%class.anon +namespace non_inline_function { +void foo() { + auto L = [](int a) { + return [](char b) { + return b; + }; + }; + L(3)('a'); +} +} + +namespace non_template { + struct L { + int t = ([](int a) { return [](int b) { return b; };})(2)(3); + }; + L l; +} + +namespace lambdas_in_NSDMIs_template_class { +template +struct L { + T t2 = ([](int a) { return [](int b) { return b; };})(T{})(T{}); +}; +L l; +} + +// CHECK-LABEL: define linkonce_odr i32 @_ZN15inline_function3fooEv +// CHECK: define linkonce_odr void @_ZZN15inline_function3fooEvENKUliE_clEi +// CHECK: define linkonce_odr signext i8 @_ZZZN15inline_function3fooEvENKUliE_clEiENKUlcE_clEc +namespace inline_function { +inline int foo() { + auto L = [](int a) { + return [](char b) { + return b; + }; + }; + L(3)('a'); +} +int use = foo(); +} +// CHECK: define linkonce_odr void @_ZNK32lambdas_in_NSDMIs_template_class1LIiEUliE_clEi(%class.anon +// CHECK: define linkonce_odr i32 @_ZZNK32lambdas_in_NSDMIs_template_class1LIiEUliE_clEiENKUliE_clEi(%class.anon + +// CHECK: define linkonce_odr void @_ZNK12non_template1L1tMUliE_clEi(%class.anon +// CHECK: define linkonce_odr i32 @_ZZNK12non_template1L1tMUliE_clEiENKUliE_clEi(%class.anon diff --git a/test/CodeGenCXX/lambda-expressions.cpp b/test/CodeGenCXX/lambda-expressions.cpp index 68ae68f..2f9a4f2 100644 --- a/test/CodeGenCXX/lambda-expressions.cpp +++ b/test/CodeGenCXX/lambda-expressions.cpp @@ -11,27 +11,27 @@ void *use = &used; extern "C" auto cvar = []{}; int a() { return []{ return 1; }(); } -// CHECK: define i32 @_Z1av +// CHECK-LABEL: define i32 @_Z1av // CHECK: call i32 @"_ZZ1avENK3$_0clEv" -// CHECK: define internal i32 @"_ZZ1avENK3$_0clEv" +// CHECK-LABEL: define internal i32 @"_ZZ1avENK3$_0clEv" // CHECK: ret i32 1 int b(int x) { return [x]{return x;}(); } -// CHECK: define i32 @_Z1bi +// CHECK-LABEL: define i32 @_Z1bi // CHECK: store i32 // CHECK: load i32* // CHECK: store i32 // CHECK: call i32 @"_ZZ1biENK3$_1clEv" -// CHECK: define internal i32 @"_ZZ1biENK3$_1clEv" +// CHECK-LABEL: define internal i32 @"_ZZ1biENK3$_1clEv" // CHECK: load i32* // CHECK: ret i32 int c(int x) { return [&x]{return x;}(); } -// CHECK: define i32 @_Z1ci +// CHECK-LABEL: define i32 @_Z1ci // CHECK: store i32 // CHECK: store i32* // CHECK: call i32 @"_ZZ1ciENK3$_2clEv" -// CHECK: define internal i32 @"_ZZ1ciENK3$_2clEv" +// CHECK-LABEL: define internal i32 @"_ZZ1ciENK3$_2clEv" // CHECK: load i32** // CHECK: load i32* // CHECK: ret i32 @@ -39,32 +39,32 @@ 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; }(); } -// CHECK: define i32 @_Z1di +// CHECK-LABEL: define i32 @_Z1di // CHECK: call void @_ZN1DC1Ev // CHECK: icmp ult i64 %{{.*}}, 10 // CHECK: call void @_ZN1DC1ERKS_ // CHECK: call i32 @"_ZZ1diENK3$_3clEv" -// CHECK: define internal i32 @"_ZZ1diENK3$_3clEv" +// CHECK-LABEL: define internal i32 @"_ZZ1diENK3$_3clEv" // CHECK: load i32* // CHECK: load i32* // CHECK: ret i32 struct E { E(); E(const E&); ~E(); int x; }; int e(E a, E b, bool cond) { [a,b,cond](){ return (cond ? a : b).x; }(); } -// CHECK: define i32 @_Z1e1ES_b +// CHECK-LABEL: define i32 @_Z1e1ES_b // CHECK: call void @_ZN1EC1ERKS_ // CHECK: invoke void @_ZN1EC1ERKS_ // CHECK: invoke i32 @"_ZZ1e1ES_bENK3$_4clEv" // CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev" // CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev" -// CHECK: define internal i32 @"_ZZ1e1ES_bENK3$_4clEv" +// CHECK-LABEL: define internal i32 @"_ZZ1e1ES_bENK3$_4clEv" // CHECK: trunc i8 // CHECK: load i32* // CHECK: ret i32 void f() { - // CHECK: define void @_Z1fv() + // CHECK-LABEL: define void @_Z1fv() // CHECK: @"_ZZ1fvENK3$_5cvPFiiiEEv" // CHECK-NEXT: store i32 (i32, i32)* // CHECK-NEXT: ret void @@ -74,7 +74,7 @@ void f() { static int k; int g() { int &r = k; - // CHECK: define internal i32 @"_ZZ1gvENK3$_6clEv"( + // CHECK-LABEL: define internal i32 @"_ZZ1gvENK3$_6clEv"( // CHECK-NOT: } // CHECK: load i32* @_ZL1k, return [] { return r; } (); @@ -100,7 +100,7 @@ void h() { A (*h)() = [] { return A(); }; } -// CHECK: define internal i32 @"_ZZ1fvEN3$_58__invokeEii" +// CHECK-LABEL: define internal i32 @"_ZZ1fvEN3$_58__invokeEii" // CHECK: store i32 // CHECK-NEXT: store i32 // CHECK-NEXT: load i32* @@ -108,7 +108,7 @@ void h() { // CHECK-NEXT: call i32 @"_ZZ1fvENK3$_5clEii" // CHECK-NEXT: ret i32 -// CHECK: define internal void @"_ZZ1e1ES_bEN3$_4D2Ev" +// CHECK-LABEL: define internal void @"_ZZ1e1ES_bEN3$_4D2Ev" // struct XXX {}; diff --git a/test/CodeGenCXX/linetable-cleanup.cpp b/test/CodeGenCXX/linetable-cleanup.cpp index 4077af6..96b8572 100644 --- a/test/CodeGenCXX/linetable-cleanup.cpp +++ b/test/CodeGenCXX/linetable-cleanup.cpp @@ -1,12 +1,18 @@ // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s -// Check the line numbers for cleanup code with EH in combinatin with +// Check the line numbers for cleanup code with EH in combination with // simple return expressions. // CHECK: define {{.*}}foo // CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[CLEANUP:[0-9]+]] // CHECK: ret i32 0, !dbg ![[RET:[0-9]+]] +// CHECK: define {{.*}}bar +// CHECK: ret void, !dbg ![[RETBAR:[0-9]+]] + +// CHECK: define {{.*}}baz +// CHECK: ret void, !dbg ![[RETBAZ:[0-9]+]] + class C { public: ~C() {} @@ -22,3 +28,31 @@ int foo() return 0; // CHECK: ![[RET]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} } + +void bar() +{ + if (!foo()) + // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + return; + + if (foo()) { + C c; + c.i = foo(); + } + // Clang creates only a single ret instruction. Make sure it is at a useful line. + // CHECK: ![[RETBAR]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} +} + +void baz() +{ + if (!foo()) + // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + return; + + if (foo()) { + // no cleanup + // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + return; + } + // CHECK: ![[RETBAZ]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} +} diff --git a/test/CodeGenCXX/linkage.cpp b/test/CodeGenCXX/linkage.cpp new file mode 100644 index 0000000..19f1b20 --- /dev/null +++ b/test/CodeGenCXX/linkage.cpp @@ -0,0 +1,222 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -O1 -disable-llvm-optzns %s -o - | FileCheck %s + +namespace test1 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN5test11fIZNS_1gEvE1SEEvT_( + template void f(T) {} + inline void *g() { + struct S { + } s; + return reinterpret_cast(f); + } + void *h() { return g(); } +} + +namespace test2 { + // CHECK-DAG-LABEL: define internal void @_ZN5test21fIZNS_L1gEvE1SEEvT_( + template void f(T) {} + static inline void *g() { + struct S { + } s; + return reinterpret_cast(f); + } + void *h() { return g(); } +} + +namespace test3 { + // CHECK-DAG-LABEL: define internal void @_ZN5test31fIZNS_1gEvE1SEEvT_( + template void f(T) {} + void *g() { + struct S { + } s; + return reinterpret_cast(f); + } + void *h() { return g(); } +} + +namespace test4 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN5test41fIZNS_1gILi1EEEPvvE1SEEvT_( + template void f(T) {} + template inline void *g() { + struct S { + } s; + return reinterpret_cast(f); + } + extern template void *g<1>(); + template void *g<1>(); +} + +namespace test5 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN5test51fIZNS_1gILi1EEEPvvE1SEEvT_( + template void f(T) {} + template inline void *g() { + struct S { + } s; + return reinterpret_cast(f); + } + extern template void *g<1>(); + void *h() { return g<1>(); } +} + +namespace test6 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN5test61fIZZNS_1gEvEN1S1hEvE1TEEvv( + template void f() {} + + inline void *g() { + struct S { + void *h() { + struct T { + }; + return (void *)f; + } + } s; + return s.h(); + } + + void *h() { return g(); } +} + +namespace test7 { + // CHECK-DAG-LABEL: define internal void @_ZN5test71fIZZNS_1gEvEN1S1hEvE1TEEvv( + template void f() {} + + void *g() { + struct S { + void *h() { + struct T { + }; + return (void *)f; + } + } s; + return s.h(); + } + + void *h() { return g(); } +} + +namespace test8 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN5test81fIZNS_1gEvE1SEEvT_( + template void f(T) {} + inline void *g() { + enum S { + }; + return reinterpret_cast(f); + } + void *h() { return g(); } +} + +namespace test9 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN5test91fIPZNS_1gEvE1SEEvT_( + template void f(T) {} + inline void *g() { + struct S { + } s; + return reinterpret_cast(f); + } + void *h() { return g(); } +} + +namespace test10 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN6test101fIPFZNS_1gEvE1SvEEEvT_( + template void f(T) {} + inline void *g() { + struct S { + } s; + typedef S(*ftype)(); + return reinterpret_cast(f); + } + void *h() { return g(); } +} + +namespace test11 { + // CHECK-DAG-LABEL: define internal void @_ZN6test111fIPFZNS_1gEvE1SPNS_12_GLOBAL__N_11IEEEEvT_( + namespace { + struct I { + }; + } + + template void f(T) {} + inline void *g() { + struct S { + }; + typedef S(*ftype)(I * x); + return reinterpret_cast(f); + } + void *h() { return g(); } +} + +namespace test12 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN6test123fooIZNS_3barIZNS_3zedEvE2S2EEPvvE2S1EEvv + template void foo() {} + template inline void *bar() { + enum S1 { + }; + return reinterpret_cast(foo); + } + inline void *zed() { + enum S2 { + }; + return reinterpret_cast(bar); + } + void *h() { return zed(); } +} + +namespace test13 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZZN6test133fooEvEN1S3barEv( + inline void *foo() { + struct S { + static void bar() {} + }; + return (void *)S::bar; + } + void *zed() { return foo(); } +} + +namespace test14 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN6test143fooIZNS_1fEvE1SE3barILPS1_0EEEvv( + template struct foo { + template static void bar() {} + static void *g() { return (void *)bar; } + }; + inline void *f() { + struct S { + }; + return foo::g(); + } + void h() { f(); } +} + +namespace test15 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN6test153zedIZNS_3fooIiEEPvvE3barEEvv( + template void zed() {} + template void *foo() { + class bar { + }; + return reinterpret_cast(zed); + } + void test() { foo(); } +} + +namespace test16 { + // CHECK-DAG-LABEL: define linkonce_odr void @_ZN6test163zedIZNS_3fooIiE3barEvE1SEEvv( + template void zed() {} + template struct foo { + static void *bar(); + }; + template void *foo::bar() { + class S { + }; + return reinterpret_cast(zed); + } + void *test() { return foo::bar(); } +} + +namespace test17 { + // CHECK-DAG: @_ZZN6test173fooILi42EEEPivE3bar = linkonce_odr + // CHECK-DAG-LABEL: define weak_odr i32* @_ZN6test173fooILi42EEEPiv( + template + int *foo() { + static int bar; + return &bar; + } + template int *foo<42>(); +} diff --git a/test/CodeGenCXX/lpad-linetable.cpp b/test/CodeGenCXX/lpad-linetable.cpp new file mode 100644 index 0000000..dba2ad6 --- /dev/null +++ b/test/CodeGenCXX/lpad-linetable.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// The landing pad should have the line number of the closing brace of the function. +// rdar://problem/13888152 +// CHECK: ret i32 +// CHECK: landingpad {{.*}} +// CHECK-NEXT: !dbg ![[LPAD:[0-9]+]] +// CHECK: ![[LPAD]] = metadata !{i32 24, i32 0, metadata !{{.*}}, null} + +# 1 "/usr/include/c++/4.2.1/vector" 1 3 +typedef long unsigned int __darwin_size_t; +typedef __darwin_size_t size_t; +namespace std { + template + class allocator + { + public: + template + struct rebind + { typedef allocator<_Tp1> other; }; + ~allocator() throw() { } + }; + template + struct _Vector_base + { + typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; + struct _Vector_impl + { + _Vector_impl(_Tp_alloc_type const& __a) { } + }; + typedef _Alloc allocator_type; + _Vector_base(const allocator_type& __a) + : _M_impl(__a) + { } + ~_Vector_base() { } + _Vector_impl _M_impl; + }; + template > + class vector + : protected _Vector_base<_Tp, _Alloc> + { + typedef _Vector_base<_Tp, _Alloc> _Base; + public: + typedef _Tp value_type; + typedef size_t size_type; + typedef _Alloc allocator_type; + vector(const allocator_type& __a = allocator_type()) + : _Base(__a) + { } + size_type + push_back(const value_type& __x) + {} + }; +} +# 10 "main.cpp" 2 + + + + +int main (int argc, char const *argv[], char const *envp[]) +{ // 15 + std::vector longs; + std::vector shorts; + for (int i=0; i<12; i++) + { + longs.push_back(i); + shorts.push_back(i); + } + return 0; // 23 +} // 24 diff --git a/test/CodeGenCXX/lvalue-bitcasts.cpp b/test/CodeGenCXX/lvalue-bitcasts.cpp index 8c5fa4a..86355b2 100644 --- a/test/CodeGenCXX/lvalue-bitcasts.cpp +++ b/test/CodeGenCXX/lvalue-bitcasts.cpp @@ -3,7 +3,7 @@ struct X { int i; float f; }; struct Y { X x; }; -// CHECK: define void @_Z21reinterpret_cast_testRiRfR1X +// CHECK-LABEL: define void @_Z21reinterpret_cast_testRiRfR1X void reinterpret_cast_test(int &ir, float &fr, X &xr) { // CHECK: load float** // CHECK: bitcast float* @@ -48,7 +48,7 @@ void reinterpret_cast_test(int &ir, float &fr, X &xr) { // CHECK: ret void } -// CHECK: define void @_Z6c_castRiRfR1X +// CHECK-LABEL: define void @_Z6c_castRiRfR1X void c_cast(int &ir, float &fr, X &xr) { // CHECK: load float** // CHECK: bitcast float* @@ -93,7 +93,7 @@ void c_cast(int &ir, float &fr, X &xr) { // CHECK: ret void } -// CHECK: define void @_Z15functional_castRiRfR1X +// CHECK-LABEL: define void @_Z15functional_castRiRfR1X void functional_cast(int &ir, float &fr, X &xr) { typedef int &intref; typedef float &floatref; diff --git a/test/CodeGenCXX/mangle-98.cpp b/test/CodeGenCXX/mangle-98.cpp index a9ab6ca..a329caf 100644 --- a/test/CodeGenCXX/mangle-98.cpp +++ b/test/CodeGenCXX/mangle-98.cpp @@ -2,11 +2,11 @@ template struct S3 {}; -// CHECK: define void @_Z1f2S3ILb1EE +// CHECK-LABEL: define void @_Z1f2S3ILb1EE void f(S3) {} -// CHECK: define void @_Z1f2S3ILb0EE +// CHECK-LABEL: define void @_Z1f2S3ILb0EE void f(S3) {} -// CHECK: define void @_Z2f22S3ILb1EE +// CHECK-LABEL: define void @_Z2f22S3ILb1EE void f2(S3<100>) {} diff --git a/test/CodeGenCXX/mangle-address-space.cpp b/test/CodeGenCXX/mangle-address-space.cpp index ff23c20..4a4a1f3 100644 --- a/test/CodeGenCXX/mangle-address-space.cpp +++ b/test/CodeGenCXX/mangle-address-space.cpp @@ -1,12 +1,12 @@ // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s -// CHECK: define void @_Z2f0Pc +// CHECK-LABEL: define void @_Z2f0Pc void f0(char *p) { } -// CHECK: define void @_Z2f0PU3AS1c +// CHECK-LABEL: define void @_Z2f0PU3AS1c void f0(char __attribute__((address_space(1))) *p) { } struct OpaqueType; typedef OpaqueType __attribute__((address_space(100))) * OpaqueTypePtr; -// CHECK: define void @_Z2f0PU5AS10010OpaqueType +// CHECK-LABEL: define void @_Z2f0PU5AS10010OpaqueType void f0(OpaqueTypePtr) { } diff --git a/test/CodeGenCXX/mangle-alias-template.cpp b/test/CodeGenCXX/mangle-alias-template.cpp index 5ace0b0..b6719c5 100644 --- a/test/CodeGenCXX/mangle-alias-template.cpp +++ b/test/CodeGenCXX/mangle-alias-template.cpp @@ -15,7 +15,7 @@ template struct S {}; template using U = S; template void h(U, Ts...); -// CHECK: define void @_Z1zv( +// CHECK-LABEL: define void @_Z1zv( void z() { vector VI; f(VI); diff --git a/test/CodeGenCXX/mangle-exprs.cpp b/test/CodeGenCXX/mangle-exprs.cpp index 2d7a883..e935f51 100644 --- a/test/CodeGenCXX/mangle-exprs.cpp +++ b/test/CodeGenCXX/mangle-exprs.cpp @@ -70,22 +70,22 @@ namespace Casts { template T f() { return T(); } - // CHECK: define weak_odr void @_ZN5Casts8implicitILj4EEEvPN9enable_ifIXleT_Li4EEvE4typeE + // CHECK-LABEL: define weak_odr void @_ZN5Casts8implicitILj4EEEvPN9enable_ifIXleT_Li4EEvE4typeE template void implicit<4>(void*); - // CHECK: define weak_odr void @_ZN5Casts6cstyleILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE + // CHECK-LABEL: define weak_odr void @_ZN5Casts6cstyleILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE template void cstyle<4>(void*); - // CHECK: define weak_odr void @_ZN5Casts10functionalILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE + // CHECK-LABEL: define weak_odr void @_ZN5Casts10functionalILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE template void functional<4>(void*); - // CHECK: define weak_odr void @_ZN5Casts7static_ILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE + // CHECK-LABEL: define weak_odr void @_ZN5Casts7static_ILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE template void static_<4>(void*); - // CHECK: define weak_odr void @_ZN5Casts1fILi6EEENS_1TIXT_EEEv + // CHECK-LABEL: define weak_odr void @_ZN5Casts1fILi6EEENS_1TIXT_EEEv template T<6> f<6>(); - // CHECK: define weak_odr void @_ZN5Casts5auto_IiEEvDTnw_DapicvT__EEE( + // CHECK-LABEL: define weak_odr void @_ZN5Casts5auto_IiEEvDTnw_DapicvT__EEE( template void auto_(int*); - // CHECK: define weak_odr void @_ZN5Casts7scalar_IiEEvDTcmcvT__Ecvi_EE( + // CHECK-LABEL: define weak_odr void @_ZN5Casts7scalar_IiEEvDTcmcvT__Ecvi_EE( template void scalar_(int); } @@ -93,10 +93,10 @@ namespace test1 { short foo(short); int foo(int); - // CHECK: define linkonce_odr signext i16 @_ZN5test11aIsEEDTcl3foocvT__EEES1_( + // CHECK-LABEL: define linkonce_odr signext i16 @_ZN5test11aIsEEDTcl3foocvT__EEES1_( template auto a(T t) -> decltype(foo(T())) { return foo(t); } - // CHECK: define linkonce_odr signext i16 @_ZN5test11bIsEEDTcp3foocvT__EEES1_( + // CHECK-LABEL: define linkonce_odr signext i16 @_ZN5test11bIsEEDTcp3foocvT__EEES1_( template auto b(T t) -> decltype((foo)(T())) { return (foo)(t); } void test(short s) { @@ -124,7 +124,7 @@ namespace test2 { float baz(float(*)()); void fred(float(*)(), float); - // CHECK: define void @_ZN5test211instantiateEv + // CHECK-LABEL: define void @_ZN5test211instantiateEv void instantiate() { // CHECK: call void @_ZN5test21aIPFfvEEEvT_DTclfL0p_EE( a(foo, 0.0f); @@ -156,7 +156,7 @@ namespace test3 { int *member; }; - // CHECK: define void @_ZN5test311instantiateEv + // CHECK-LABEL: define void @_ZN5test311instantiateEv void instantiate() { X x; int *ip; diff --git a/test/CodeGenCXX/mangle-extreme.cpp b/test/CodeGenCXX/mangle-extreme.cpp index ef2d466..9fa678a 100644 --- a/test/CodeGenCXX/mangle-extreme.cpp +++ b/test/CodeGenCXX/mangle-extreme.cpp @@ -2,7 +2,7 @@ struct X { }; -// CHECK: define void @_Z1fPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP1XS13_S12_S11_S10_SZ_SY_SX_SW_SV_SU_ST_SS_SR_SQ_SP_SO_SN_SM_SL_SK_SJ_SI_SH_SG_SF_SE_SD_SC_SB_SA_S9_S8_S7_S6_S5_S4_S3_S2_S1_S0_S_( +// CHECK-LABEL: define void @_Z1fPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP1XS13_S12_S11_S10_SZ_SY_SX_SW_SV_SU_ST_SS_SR_SQ_SP_SO_SN_SM_SL_SK_SJ_SI_SH_SG_SF_SE_SD_SC_SB_SA_S9_S8_S7_S6_S5_S4_S3_S2_S1_S0_S_( void f(X****************************************, X****************************************, X***************************************, diff --git a/test/CodeGenCXX/mangle-lambdas.cpp b/test/CodeGenCXX/mangle-lambdas.cpp index 0bd5ad2..659b437 100644 --- a/test/CodeGenCXX/mangle-lambdas.cpp +++ b/test/CodeGenCXX/mangle-lambdas.cpp @@ -1,11 +1,11 @@ // 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: @_ZZZN7PR12917IJicdEEC1EicdEd_NKUlvE_clEvE1n = linkonce_odr global i32 0 +// CHECK: @_ZZZN7PR12917IJicdEEC1EicdEd0_NKUlvE_clEvE1n = linkonce_odr global i32 0 +// CHECK: @_ZZZN7PR12917IJicdEEC1EicdEd1_NKUlvE_clEvE1n = linkonce_odr global i32 0 -// CHECK: define linkonce_odr void @_Z11inline_funci +// CHECK-LABEL: define linkonce_odr void @_Z11inline_funci inline void inline_func(int n) { // CHECK: call i32 @_ZZ11inline_funciENKUlvE_clEv int i = []{ return 1; }(); @@ -41,7 +41,7 @@ struct S { void S::g(int i = []{return 1;}(), int j = []{return 2; }()) {} -// CHECK: define void @_Z6test_S1S +// CHECK-LABEL: define void @_Z6test_S1S void test_S(S s) { // CHECK: call i32 @_ZZN1S1fEiiEd0_NKUlvE_clEv // CHECK-NEXT: call i32 @_ZZN1S1fEiiEd0_NKUlvE0_clEv @@ -63,15 +63,15 @@ void test_S(S s) { } // Check the linkage of the lambda call operators used in test_S. -// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd0_NKUlvE_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZZN1S1fEiiEd0_NKUlvE_clEv // CHECK: ret i32 1 -// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd0_NKUlvE0_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZZN1S1fEiiEd0_NKUlvE0_clEv // CHECK: ret i32 2 -// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd_NKUlvE_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZZN1S1fEiiEd_NKUlvE_clEv // CHECK: ret i32 3 -// CHECK: define internal i32 @"_ZNK1S3$_0clEv" +// CHECK-LABEL: define internal i32 @"_ZNK1S3$_0clEv" // CHECK: ret i32 1 -// CHECK: define internal i32 @"_ZNK1S3$_1clEv" +// CHECK-LABEL: define internal i32 @"_ZNK1S3$_1clEv" // CHECK: ret i32 2 template @@ -81,7 +81,7 @@ struct ST { T = []{return T(3);}()); }; -// CHECK: define void @_Z7test_ST2STIdE +// CHECK-LABEL: define void @_Z7test_ST2STIdE void test_ST(ST st) { // CHECK: call double @_ZZN2STIdE1fEddEd0_NKUlvE_clEv // CHECK-NEXT: call double @_ZZN2STIdE1fEddEd0_NKUlvE0_clEv @@ -94,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 @_ZZN2STIdE1fEddEd0_NKUlvE_clEv +// CHECK-LABEL: define linkonce_odr double @_ZZN2STIdE1fEddEd0_NKUlvE_clEv // CHECK: ret double 1 -// CHECK: define linkonce_odr double @_ZZN2STIdE1fEddEd0_NKUlvE0_clEv +// CHECK-LABEL: define linkonce_odr double @_ZZN2STIdE1fEddEd0_NKUlvE0_clEv // CHECK: ret double 2 -// CHECK: define linkonce_odr double @_ZZN2STIdE1fEddEd_NKUlvE_clEv +// CHECK-LABEL: define linkonce_odr double @_ZZN2STIdE1fEddEd_NKUlvE_clEv // CHECK: ret double 3 template @@ -106,6 +106,7 @@ struct StaticMembers { static T x; static T y; static T z; + static int (*f)(); }; template int accept_lambda(T); @@ -119,39 +120,47 @@ T StaticMembers::y = []{return 3;}(); template T StaticMembers::z = accept_lambda([]{return 4;}); -// CHECK: define internal void @__cxx_global_var_init() +template +int (*StaticMembers::f)() = []{return 5;}; + +// CHECK-LABEL: define internal void @__cxx_global_var_init() // CHECK: call i32 @_ZNK13StaticMembersIfE1xMUlvE_clEv // CHECK-NEXT: call i32 @_ZNK13StaticMembersIfE1xMUlvE0_clEv // CHECK-NEXT: add nsw -// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1xMUlvE_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZNK13StaticMembersIfE1xMUlvE_clEv // CHECK: ret i32 1 -// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1xMUlvE0_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZNK13StaticMembersIfE1xMUlvE0_clEv // CHECK: ret i32 2 template float StaticMembers::x; -// CHECK: define internal void @__cxx_global_var_init1() +// CHECK-LABEL: define internal void @__cxx_global_var_init1() // CHECK: call i32 @_ZNK13StaticMembersIfE1yMUlvE_clEv -// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1yMUlvE_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZNK13StaticMembersIfE1yMUlvE_clEv // CHECK: ret i32 3 template float StaticMembers::y; -// CHECK: define internal void @__cxx_global_var_init2() +// CHECK-LABEL: define internal void @__cxx_global_var_init2() // CHECK: call i32 @_Z13accept_lambdaIN13StaticMembersIfE1zMUlvE_EEiT_ // CHECK: declare i32 @_Z13accept_lambdaIN13StaticMembersIfE1zMUlvE_EEiT_() template float StaticMembers::z; -// CHECK: define internal void @__cxx_global_var_init3 +// CHECK-LABEL: define internal void @__cxx_global_var_init3() +// CHECK: call {{.*}} @_ZNK13StaticMembersIfE1fMUlvE_cvPFivEEv +// CHECK-LABEL: define linkonce_odr i32 ()* @_ZNK13StaticMembersIfE1fMUlvE_cvPFivEEv +template int (*StaticMembers::f)(); + +// CHECK-LABEL: define internal void @__cxx_global_var_init4 // CHECK: call i32 @"_ZNK13StaticMembersIdE3$_2clEv" -// CHECK: define internal i32 @"_ZNK13StaticMembersIdE3$_2clEv" +// CHECK-LABEL: define internal i32 @"_ZNK13StaticMembersIdE3$_2clEv" // CHECK: ret i32 42 template<> double StaticMembers::z = []{return 42; }(); template void func_template(T = []{ return T(); }()); -// CHECK: define void @_Z17use_func_templatev() +// CHECK-LABEL: define void @_Z17use_func_templatev() void use_func_template() { - // CHECK: call i32 @"_ZZ13func_templateIiEvT_ENKS_IiE3$_3clEv" + // CHECK: call i32 @"_ZZ13func_templateIiEvT_ENK3$_3clEv" func_template(); } @@ -183,7 +192,7 @@ namespace PR12123 { }; void B::h() { f(); } } -// CHECK: define linkonce_odr %"struct.PR12123::A"* @_ZZN7PR121231B1fERKSt9type_infoEd_NKUlvE_clEv +// CHECK-LABEL: define linkonce_odr %"struct.PR12123::A"* @_ZZN7PR121231B1fERKSt9type_infoEd_NKUlvE_clEv namespace PR12808 { template struct B { @@ -196,11 +205,11 @@ namespace PR12808 { void f() { b(1); } - // CHECK: define linkonce_odr void @_ZZN7PR128081bIiEEviENKS0_IiEUlvE_clEv - // CHECK: define linkonce_odr i32 @_ZZZN7PR128081bIiEEviENKS0_IiEUlvE_clEvENKUlvE_clEv + // CHECK-LABEL: define linkonce_odr void @_ZZN7PR128081bIiEEviENKUlvE_clEv + // CHECK-LABEL: define linkonce_odr i32 @_ZZZN7PR128081bIiEEviENKUlvE_clEvENKUlvE_clEv } -// CHECK: define linkonce_odr void @_Z1fIZZNK23TestNestedInstantiationclEvENKUlvE_clEvEUlvE_EvT_ +// CHECK-LABEL: define linkonce_odr void @_Z1fIZZNK23TestNestedInstantiationclEvENKUlvE_clEvEUlvE_EvT_ struct Members { int x = [] { return 1; }() + [] { return 2; }(); @@ -208,7 +217,7 @@ struct Members { }; void test_Members() { - // CHECK: define linkonce_odr void @_ZN7MembersC2Ev + // CHECK-LABEL: define linkonce_odr void @_ZN7MembersC2Ev // CHECK: call i32 @_ZNK7Members1xMUlvE_clEv // CHECK-NEXT: call i32 @_ZNK7Members1xMUlvE0_clE // CHECK-NEXT: add nsw i32 @@ -232,21 +241,21 @@ void test_NestedInstantiation() { } // Check the linkage of the lambdas used in test_Members. -// CHECK: define linkonce_odr i32 @_ZNK7Members1xMUlvE_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZNK7Members1xMUlvE_clEv // CHECK: ret i32 1 -// CHECK: define linkonce_odr i32 @_ZNK7Members1xMUlvE0_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZNK7Members1xMUlvE0_clEv // CHECK: ret i32 2 -// CHECK: define linkonce_odr i32 @_ZNK7Members1yMUlvE_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZNK7Members1yMUlvE_clEv // CHECK: ret i32 3 // Check linkage of the various lambdas. -// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE_clEv // CHECK: ret i32 1 -// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE0_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE0_clEv // CHECK: ret i32 -// CHECK: define linkonce_odr double @_ZZ11inline_funciENKUlvE1_clEv +// CHECK-LABEL: define linkonce_odr double @_ZZ11inline_funciENKUlvE1_clEv // CHECK: ret double -// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUliE_clEi +// CHECK-LABEL: define linkonce_odr i32 @_ZZ11inline_funciENKUliE_clEi // CHECK: ret i32 -// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE2_clEv +// CHECK-LABEL: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE2_clEv // CHECK: ret i32 17 diff --git a/test/CodeGenCXX/mangle-local-class-names.cpp b/test/CodeGenCXX/mangle-local-class-names.cpp index 3321460..8b950fc 100644 --- a/test/CodeGenCXX/mangle-local-class-names.cpp +++ b/test/CodeGenCXX/mangle-local-class-names.cpp @@ -55,3 +55,33 @@ void GORF (float IVAR1) } } +// CHECK: @_ZZ12OmittingCodefEN4SSSSC1E_0RKf +inline void OmittingCode(float x) { + if (0) { + struct SSSS { + float bv; + SSSS(const float& from): bv(from) { } + }; + + SSSS VAR1(x); + } + + struct SSSS { + float bv; + SSSS(const float& from): bv(from) { } + }; + + SSSS VAR2(x); +} +void CallOmittingCode() { OmittingCode(1); } + +// CHECK: @_ZZ15LocalAnonStructvENUt0_1gEv +inline void LocalAnonStruct() { + if (0) { + struct { void f() {} } x; + x.f(); + } + struct { void g() {} } y; + y.g(); +} +void CallLocalAnonStruct() { LocalAnonStruct(); } diff --git a/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp b/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp index d03ba52..50a2383 100644 --- a/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp +++ b/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp @@ -1,123 +1,240 @@ // RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 | FileCheck -check-prefix=X64 %s void foo(const unsigned int) {} // CHECK: "\01?foo@@YAXI@Z" +// X64: "\01?foo@@YAXI@Z" void foo(const double) {} // CHECK: "\01?foo@@YAXN@Z" +// X64: "\01?foo@@YAXN@Z" void bar(const volatile double) {} // CHECK: "\01?bar@@YAXN@Z" +// X64: "\01?bar@@YAXN@Z" void foo_pad(char * x) {} // CHECK: "\01?foo_pad@@YAXPAD@Z" +// X64: "\01?foo_pad@@YAXPEAD@Z" void foo_pbd(const char * x) {} // CHECK: "\01?foo_pbd@@YAXPBD@Z" +// X64: "\01?foo_pbd@@YAXPEBD@Z" void foo_pcd(volatile char * x) {} // CHECK: "\01?foo_pcd@@YAXPCD@Z" +// X64: "\01?foo_pcd@@YAXPECD@Z" void foo_qad(char * const x) {} // CHECK: "\01?foo_qad@@YAXQAD@Z" +// X64: "\01?foo_qad@@YAXQEAD@Z" void foo_rad(char * volatile x) {} // CHECK: "\01?foo_rad@@YAXRAD@Z" +// X64: "\01?foo_rad@@YAXREAD@Z" void foo_sad(char * const volatile x) {} // CHECK: "\01?foo_sad@@YAXSAD@Z" +// X64: "\01?foo_sad@@YAXSEAD@Z" void foo_papad(char ** x) {} // CHECK: "\01?foo_papad@@YAXPAPAD@Z" +// X64: "\01?foo_papad@@YAXPEAPEAD@Z" void foo_papbd(char const ** x) {} // CHECK: "\01?foo_papbd@@YAXPAPBD@Z" +// X64: "\01?foo_papbd@@YAXPEAPEBD@Z" void foo_papcd(char volatile ** x) {} // CHECK: "\01?foo_papcd@@YAXPAPCD@Z" +// X64: "\01?foo_papcd@@YAXPEAPECD@Z" void foo_pbqad(char * const* x) {} // CHECK: "\01?foo_pbqad@@YAXPBQAD@Z" +// X64: "\01?foo_pbqad@@YAXPEBQEAD@Z" void foo_pcrad(char * volatile* x) {} // CHECK: "\01?foo_pcrad@@YAXPCRAD@Z" +// X64: "\01?foo_pcrad@@YAXPECREAD@Z" void foo_qapad(char ** const x) {} // CHECK: "\01?foo_qapad@@YAXQAPAD@Z" +// X64: "\01?foo_qapad@@YAXQEAPEAD@Z" void foo_rapad(char ** volatile x) {} // CHECK: "\01?foo_rapad@@YAXRAPAD@Z" +// X64: "\01?foo_rapad@@YAXREAPEAD@Z" void foo_pbqbd(const char * const* x) {} // CHECK: "\01?foo_pbqbd@@YAXPBQBD@Z" +// X64: "\01?foo_pbqbd@@YAXPEBQEBD@Z" void foo_pbqcd(volatile char * const* x) {} // CHECK: "\01?foo_pbqcd@@YAXPBQCD@Z" +// X64: "\01?foo_pbqcd@@YAXPEBQECD@Z" void foo_pcrbd(const char * volatile* x) {} // CHECK: "\01?foo_pcrbd@@YAXPCRBD@Z" +// X64: "\01?foo_pcrbd@@YAXPECREBD@Z" void foo_pcrcd(volatile char * volatile* x) {} // CHECK: "\01?foo_pcrcd@@YAXPCRCD@Z" +// X64: "\01?foo_pcrcd@@YAXPECRECD@Z" void foo_aad(char &x) {} // CHECK: "\01?foo_aad@@YAXAAD@Z" +// X64: "\01?foo_aad@@YAXAEAD@Z" void foo_abd(const char &x) {} // CHECK: "\01?foo_abd@@YAXABD@Z" +// X64: "\01?foo_abd@@YAXAEBD@Z" void foo_aapad(char *&x) {} // CHECK: "\01?foo_aapad@@YAXAAPAD@Z" +// X64: "\01?foo_aapad@@YAXAEAPEAD@Z" void foo_aapbd(const char *&x) {} // CHECK: "\01?foo_aapbd@@YAXAAPBD@Z" +// X64: "\01?foo_aapbd@@YAXAEAPEBD@Z" void foo_abqad(char * const &x) {} // CHECK: "\01?foo_abqad@@YAXABQAD@Z" +// X64: "\01?foo_abqad@@YAXAEBQEAD@Z" void foo_abqbd(const char * const &x) {} // CHECK: "\01?foo_abqbd@@YAXABQBD@Z" +// X64: "\01?foo_abqbd@@YAXAEBQEBD@Z" void foo_aay144h(int (&x)[5][5]) {} // CHECK: "\01?foo_aay144h@@YAXAAY144H@Z" +// X64: "\01?foo_aay144h@@YAXAEAY144H@Z" void foo_aay144cbh(const int (&x)[5][5]) {} // CHECK: "\01?foo_aay144cbh@@YAXAAY144$$CBH@Z" +// X64: "\01?foo_aay144cbh@@YAXAEAY144$$CBH@Z" void foo_qay144h(int (&&x)[5][5]) {} // CHECK: "\01?foo_qay144h@@YAX$$QAY144H@Z" +// X64: "\01?foo_qay144h@@YAX$$QEAY144H@Z" void foo_qay144cbh(const int (&&x)[5][5]) {} // CHECK: "\01?foo_qay144cbh@@YAX$$QAY144$$CBH@Z" +// X64: "\01?foo_qay144cbh@@YAX$$QEAY144$$CBH@Z" void foo_p6ahxz(int x()) {} // CHECK: "\01?foo_p6ahxz@@YAXP6AHXZ@Z" +// X64: "\01?foo_p6ahxz@@YAXP6AHXZ@Z" void foo_a6ahxz(int (&x)()) {} // CHECK: "\01?foo_a6ahxz@@YAXA6AHXZ@Z" +// X64: "\01?foo_a6ahxz@@YAXA6AHXZ@Z" void foo_q6ahxz(int (&&x)()) {} // CHECK: "\01?foo_q6ahxz@@YAX$$Q6AHXZ@Z" +// X64: "\01?foo_q6ahxz@@YAX$$Q6AHXZ@Z" void foo_qay04h(int x[5][5]) {} // CHECK: "\01?foo_qay04h@@YAXQAY04H@Z" +// X64: "\01?foo_qay04h@@YAXQEAY04H@Z" void foo_qay04cbh(const int x[5][5]) {} // CHECK: "\01?foo_qay04cbh@@YAXQAY04$$CBH@Z" +// X64: "\01?foo_qay04cbh@@YAXQEAY04$$CBH@Z" typedef double Vector[3]; void foo(Vector*) {} // CHECK: "\01?foo@@YAXPAY02N@Z" +// X64: "\01?foo@@YAXPEAY02N@Z" void foo(Vector) {} // CHECK: "\01?foo@@YAXQAN@Z" +// X64: "\01?foo@@YAXQEAN@Z" void foo_const(const Vector) {} // CHECK: "\01?foo_const@@YAXQBN@Z" +// X64: "\01?foo_const@@YAXQEBN@Z" void foo_volatile(volatile Vector) {} // CHECK: "\01?foo_volatile@@YAXQCN@Z" +// X64: "\01?foo_volatile@@YAXQECN@Z" void foo(Vector*, const Vector, const double) {} // CHECK: "\01?foo@@YAXPAY02NQBNN@Z" +// X64: "\01?foo@@YAXPEAY02NQEBNN@Z" + +typedef void (*ConstFunPtr)(int *const d); +void foo_fnptrconst(ConstFunPtr f) { } +// CHECK: "\01?foo_fnptrconst@@YAXP6AXQAH@Z@Z" +// X64: "\01?foo_fnptrconst@@YAXP6AXQEAH@Z@Z" + +typedef void (*ArrayFunPtr)(int d[1]); +void foo_fnptrarray(ArrayFunPtr f) { } +// CHECK: "\01?foo_fnptrarray@@YAXP6AXQAH@Z@Z" +// X64: "\01?foo_fnptrarray@@YAXP6AXQEAH@Z@Z" + +void foo_fnptrbackref1(ArrayFunPtr f1, ArrayFunPtr f2) { } +// CHECK: "\01?foo_fnptrbackref1@@YAXP6AXQAH@Z1@Z" +// X64: "\01?foo_fnptrbackref1@@YAXP6AXQEAH@Z1@Z" + +void foo_fnptrbackref2(ArrayFunPtr f1, ConstFunPtr f2) { } +// CHECK: "\01?foo_fnptrbackref2@@YAXP6AXQAH@Z1@Z" +// X64: "\01?foo_fnptrbackref2@@YAXP6AXQEAH@Z1@Z" + +typedef void (*NormalFunPtr)(int *d); +void foo_fnptrbackref3(ArrayFunPtr f1, NormalFunPtr f2) { } +// CHECK: "\01?foo_fnptrbackref3@@YAXP6AXQAH@Z1@Z" +// X64: "\01?foo_fnptrbackref3@@YAXP6AXQEAH@Z1@Z" + +void foo_fnptrbackref4(NormalFunPtr f1, ArrayFunPtr f2) { } +// CHECK: "\01?foo_fnptrbackref4@@YAXP6AXPAH@Z1@Z" +// X64: "\01?foo_fnptrbackref4@@YAXP6AXPEAH@Z1@Z" + +ArrayFunPtr ret_fnptrarray() { return 0; } +// CHECK: "\01?ret_fnptrarray@@YAP6AXQAH@ZXZ" +// X64: "\01?ret_fnptrarray@@YAP6AXQEAH@ZXZ" + +// Test that we mangle the forward decl when we have a redeclaration with a +// slightly different type. +void mangle_fwd(char * const x); +void mangle_fwd(char * x) {} +// CHECK: "\01?mangle_fwd@@YAXQAD@Z" +// X64: "\01?mangle_fwd@@YAXQEAD@Z" + +void mangle_no_fwd(char * x) {} +// CHECK: "\01?mangle_no_fwd@@YAXPAD@Z" +// X64: "\01?mangle_no_fwd@@YAXPEAD@Z" + +// The first argument gets mangled as-if it were written "int *const" +// The second arg should not form a backref because it isn't qualified +void mangle_no_backref0(int[], int *) {} +// CHECK: "\01?mangle_no_backref0@@YAXQAHPAH@Z" +// X64: "\01?mangle_no_backref0@@YAXQEAHPEAH@Z" + +void mangle_no_backref1(int[], int *const) {} +// CHECK: "\01?mangle_no_backref1@@YAXQAHQAH@Z" +// X64: "\01?mangle_no_backref1@@YAXQEAHQEAH@Z" + +typedef void fun_type(void); +typedef void (*ptr_to_fun_type)(void); + +// Pointer to function types don't backref with function types +void mangle_no_backref2(fun_type, ptr_to_fun_type) {} +// CHECK: "\01?mangle_no_backref2@@YAXP6AXXZP6AXXZ@Z" +// X64: "\01?mangle_no_backref2@@YAXP6AXXZP6AXXZ@Z" + +void mangle_yes_backref0(int[], int []) {} +// CHECK: "\01?mangle_yes_backref0@@YAXQAH0@Z" +// X64: "\01?mangle_yes_backref0@@YAXQEAH0@Z" + +void mangle_yes_backref1(int *const, int *const) {} +// CHECK: "\01?mangle_yes_backref1@@YAXQAH0@Z" +// X64: "\01?mangle_yes_backref1@@YAXQEAH0@Z" + +void mangle_yes_backref2(fun_type *const[], ptr_to_fun_type const[]) {} +// CHECK: "\01?mangle_yes_backref2@@YAXQBQ6AXXZ0@Z" +// X64: "\01?mangle_yes_backref2@@YAXQEBQ6AXXZ0@Z" + +void mangle_yes_backref3(ptr_to_fun_type *const, void (**const)(void)) {} +// CHECK: "\01?mangle_yes_backref3@@YAXQAP6AXXZ0@Z" +// X64: "\01?mangle_yes_backref3@@YAXQEAP6AXXZ0@Z" diff --git a/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp b/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp index fbc6492..e10cc8e 100644 --- a/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp +++ b/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp @@ -107,7 +107,7 @@ 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" +// 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) {} @@ -163,3 +163,31 @@ 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" } } + +// Function template names are not considered for backreferencing, but normal +// function names are. +namespace fn_space { +struct RetVal { int hash; }; +template +RetVal fun_tmpl(const T &t) { return RetVal(); } +RetVal fun_normal(int t) { return RetVal(); } +void fun_instantiate() { + fun_normal(1); + fun_tmpl(1); +} +// CHECK: "\01?fun_normal@fn_space@@YA?AURetVal@1@H@Z" +// CHECK: "\01??$fun_tmpl@H@fn_space@@YA?AURetVal@0@ABH@Z" + +template +RetVal fun_tmpl_recurse(T t) { + if (!t) + return RetVal(); + return F(t - 1); +} +RetVal ident(int x) { return RetVal(); } +void fun_instantiate2() { + fun_tmpl_recurse >(10); +} +// CHECK: "\01??$fun_tmpl_recurse@H$1??$fun_tmpl_recurse@H$1?ident@fn_space@@YA?AURetVal@2@H@Z@fn_space@@YA?AURetVal@1@H@Z@fn_space@@YA?AURetVal@0@H@Z" +// CHECK: "\01??$fun_tmpl_recurse@H$1?ident@fn_space@@YA?AURetVal@2@H@Z@fn_space@@YA?AURetVal@0@H@Z" +} diff --git a/test/CodeGenCXX/mangle-ms-back-references.cpp b/test/CodeGenCXX/mangle-ms-back-references.cpp index 5f93590..4f17326 100644 --- a/test/CodeGenCXX/mangle-ms-back-references.cpp +++ b/test/CodeGenCXX/mangle-ms-back-references.cpp @@ -61,3 +61,8 @@ void h2(void (*f_ptr)(void *), void *arg) {} PInt3Func h3(PInt3Func x, PInt3Func y, int* z) { return 0; } // CHECK: "\01?h3@@YAP6APAHPAH0@ZP6APAH00@Z10@Z" + +namespace foo { +void foo() { } +// CHECK: "\01?foo@0@YAXXZ" +} diff --git a/test/CodeGenCXX/mangle-ms-templates.cpp b/test/CodeGenCXX/mangle-ms-templates.cpp index 10e6824..514f573 100644 --- a/test/CodeGenCXX/mangle-ms-templates.cpp +++ b/test/CodeGenCXX/mangle-ms-templates.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -fms-extensions -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -cxx-abi microsoft -fms-extensions -fdelayed-template-parsing -triple=i386-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -cxx-abi microsoft -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s template class Class { @@ -23,6 +24,18 @@ class IntTemplate { IntTemplate() {} }; +template +class LongLongTemplate { + public: + LongLongTemplate() {} +}; + +template +class UnsignedLongLongTemplate { + public: + UnsignedLongLongTemplate() {} +}; + template<> class BoolTemplate { public: @@ -33,65 +46,113 @@ class BoolTemplate { void template_mangling() { Class c1; // CHECK: call {{.*}} @"\01??0?$Class@VTypename@@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@VTypename@@@@QEAA@XZ" Class c1_const; // CHECK: call {{.*}} @"\01??0?$Class@$$CBVTypename@@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@$$CBVTypename@@@@QEAA@XZ" Class c1_volatile; // CHECK: call {{.*}} @"\01??0?$Class@$$CCVTypename@@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@$$CCVTypename@@@@QEAA@XZ" Class c1_cv; // CHECK: call {{.*}} @"\01??0?$Class@$$CDVTypename@@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@$$CDVTypename@@@@QEAA@XZ" Class > c2; // CHECK: call {{.*}} @"\01??0?$Class@V?$Nested@VTypename@@@@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@V?$Nested@VTypename@@@@@@QEAA@XZ" Class c_intpc; // CHECK: call {{.*}} @"\01??0?$Class@QAH@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@QEAH@@QEAA@XZ" Class c_ft; // CHECK: call {{.*}} @"\01??0?$Class@$$A6AHXZ@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@$$A6AHXZ@@QEAA@XZ" Class c_inti; // CHECK: call {{.*}} @"\01??0?$Class@$$BY0A@H@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@$$BY0A@H@@QEAA@XZ" Class c_int5; // CHECK: call {{.*}} @"\01??0?$Class@$$BY04H@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@$$BY04H@@QEAA@XZ" Class c_intc5; // CHECK: call {{.*}} @"\01??0?$Class@$$BY04$$CBH@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@$$BY04$$CBH@@QEAA@XZ" Class c_intpc5; // CHECK: call {{.*}} @"\01??0?$Class@$$BY04QAH@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$Class@$$BY04QEAH@@QEAA@XZ" BoolTemplate _false; // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QEAA@XZ" BoolTemplate _true; // PR13158 _true.Foo(1); // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$BoolTemplate@$00@@QEAA@XZ" // CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z" +// X64: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QEAAXH@Z" IntTemplate<0> zero; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0A@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0A@@@QEAA@XZ" IntTemplate<5> five; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$04@@QEAA@XZ" IntTemplate<11> eleven; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QEAA@XZ" IntTemplate<256> _256; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0BAA@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0BAA@@@QEAA@XZ" IntTemplate<513> _513; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0CAB@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0CAB@@@QEAA@XZ" IntTemplate<1026> _1026; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0EAC@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0EAC@@@QEAA@XZ" IntTemplate<65535> ffff; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QEAA@XZ" + + IntTemplate<-1> neg_1; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0?0@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0?0@@QEAA@XZ" + IntTemplate<-9> neg_9; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0?8@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0?8@@QEAA@XZ" + IntTemplate<-10> neg_10; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0?9@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0?9@@QEAA@XZ" + IntTemplate<-11> neg_11; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0?L@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0?L@@@QEAA@XZ" + + LongLongTemplate<-9223372036854775807LL-1LL> int64_min; +// CHECK: call {{.*}} @"\01??0?$LongLongTemplate@$0?IAAAAAAAAAAAAAAA@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$LongLongTemplate@$0?IAAAAAAAAAAAAAAA@@@QEAA@XZ" + LongLongTemplate<9223372036854775807LL> int64_max; +// CHECK: call {{.*}} @"\01??0?$LongLongTemplate@$0HPPPPPPPPPPPPPPP@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$LongLongTemplate@$0HPPPPPPPPPPPPPPP@@@QEAA@XZ" + UnsignedLongLongTemplate<18446744073709551615ULL> uint64_max; +// CHECK: call {{.*}} @"\01??0?$UnsignedLongLongTemplate@$0?0@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$UnsignedLongLongTemplate@$0?0@@QEAA@XZ" + UnsignedLongLongTemplate<(unsigned long long)-1> uint64_neg_1; +// CHECK: call {{.*}} @"\01??0?$UnsignedLongLongTemplate@$0?0@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$UnsignedLongLongTemplate@$0?0@@QEAA@XZ" } namespace space { template const T& foo(const T& l) { return l; } } // CHECK: "\01??$foo@H@space@@YAABHABH@Z" +// X64: "\01??$foo@H@space@@YAAEBHAEBH@Z" void use() { space::foo(42); @@ -108,4 +169,96 @@ void FunctionPointerTemplate() { void spam() { FunctionPointerTemplate(); // CHECK: "\01??$FunctionPointerTemplate@$1?spam@@YAXXZ@@YAXXZ" +// X64: "\01??$FunctionPointerTemplate@$1?spam@@YAXXZ@@YAXXZ" +} + +// Unlike Itanium, there is no character code to indicate an argument pack. +// Tested with MSVC 2013, the first version which supports variadic templates. + +template void variadic_fn_template(const Ts &...args) { } +void variadic_fn_instantiate() { + variadic_fn_template(0, 1, 3, 4); + variadic_fn_template(0, 1, 'a', "b"); +} +// CHECK: "\01??$variadic_fn_template@HHHH@@YAXABH000@Z" +// CHECK: "\01??$variadic_fn_template@HHD$$BY01D@@YAXABH0ABDAAY01$$CBD@Z" + +template +struct VariadicClass { + VariadicClass() { } + int x; +}; +void variadic_class_instantiate() { + VariadicClass a; + VariadicClass b; +} +// CHECK: call {{.*}} @"\01??0?$VariadicClass@HD_N@@QAE@XZ" +// CHECK: call {{.*}} @"\01??0?$VariadicClass@_NDH@@QAE@XZ" + +template +struct Second {}; + +template class> +struct Type {}; + +template