diff options
Diffstat (limited to 'test')
56 files changed, 1172 insertions, 89 deletions
diff --git a/test/Analysis/nullability-notes.m b/test/Analysis/nullability-notes.m new file mode 100644 index 0000000000000..c93aa02c4200b --- /dev/null +++ b/test/Analysis/nullability-notes.m @@ -0,0 +1,204 @@ +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-output=plist -analyzer-config path-diagnostics-alternate=true -o %t.plist %s +// RUN: FileCheck --input-file=%t.plist %s + +#include "Inputs/system-header-simulator-for-nullability.h" + +void takesNonnull(NSObject *_Nonnull y); + +@interface ClassWithProperties: NSObject +@property(copy, nullable) NSObject *x; // plist check ensures no control flow piece from here to 'self.x'. +-(void) method; +@end; +@implementation ClassWithProperties +-(void) method { + // no-crash + NSObject *x = self.x; // expected-note{{Nullability 'nullable' is inferred}} + takesNonnull(x); // expected-warning{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} + // expected-note@-1{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} +} +@end + +// CHECK: <key>diagnostics</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>path</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>kind</key><string>control</string> +// CHECK-NEXT: <key>edges</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>start</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>3</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>10</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: <key>end</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>22</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>22</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>kind</key><string>event</string> +// CHECK-NEXT: <key>location</key> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>22</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <key>ranges</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>22</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>22</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: </array> +// CHECK-NEXT: <key>depth</key><integer>1</integer> +// CHECK-NEXT: <key>extended_message</key> +// CHECK-NEXT: <string>Nullability 'nullable' is inferred</string> +// CHECK-NEXT: <key>message</key> +// CHECK-NEXT: <string>Nullability 'nullable' is inferred</string> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>kind</key><string>control</string> +// CHECK-NEXT: <key>edges</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>start</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>22</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>22</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: <key>end</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>3</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>10</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>kind</key><string>control</string> +// CHECK-NEXT: <key>edges</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>start</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>3</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>16</integer> +// CHECK-NEXT: <key>col</key><integer>10</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: <key>end</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>17</integer> +// CHECK-NEXT: <key>col</key><integer>3</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>17</integer> +// CHECK-NEXT: <key>col</key><integer>14</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>kind</key><string>event</string> +// CHECK-NEXT: <key>location</key> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>17</integer> +// CHECK-NEXT: <key>col</key><integer>3</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <key>ranges</key> +// CHECK-NEXT: <array> +// CHECK-NEXT: <array> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>17</integer> +// CHECK-NEXT: <key>col</key><integer>16</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>17</integer> +// CHECK-NEXT: <key>col</key><integer>16</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: </array> +// CHECK-NEXT: <key>depth</key><integer>0</integer> +// CHECK-NEXT: <key>extended_message</key> +// CHECK-NEXT: <string>Nullable pointer is passed to a callee that requires a non-null 1st parameter</string> +// CHECK-NEXT: <key>message</key> +// CHECK-NEXT: <string>Nullable pointer is passed to a callee that requires a non-null 1st parameter</string> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> +// CHECK-NEXT: <key>description</key><string>Nullable pointer is passed to a callee that requires a non-null 1st parameter</string> +// CHECK-NEXT: <key>category</key><string>Memory error</string> +// CHECK-NEXT: <key>type</key><string>Nullability</string> +// CHECK-NEXT: <key>check_name</key><string>nullability.NullPassedToNonnull</string> +// CHECK-NEXT: <!-- This hash is experimental and going to change! --> +// CHECK-NEXT: <key>issue_hash_content_of_line_in_context</key><string>b6bc8126de8e6eb3375483a656fe858d</string> +// CHECK-NEXT: <key>issue_context_kind</key><string>Objective-C method</string> +// CHECK-NEXT: <key>issue_context</key><string>method</string> +// CHECK-NEXT: <key>issue_hash_function_offset</key><string>3</string> +// CHECK-NEXT: <key>location</key> +// CHECK-NEXT: <dict> +// CHECK-NEXT: <key>line</key><integer>17</integer> +// CHECK-NEXT: <key>col</key><integer>3</integer> +// CHECK-NEXT: <key>file</key><integer>0</integer> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </array> diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp index 12237a39ab54a..6e150ce5a554a 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp @@ -4,3 +4,31 @@ void f0() { // expected-note {{previous definition is here}} } inline void f0(); // expected-error {{inline declaration of 'f0' follows non-inline definition}} + +void func_01() {} // expected-note{{previous definition is here}} +struct C01 { + friend void func_01() {} // expected-error{{redefinition of 'func_01'}} +}; + +void func_02() {} // expected-note{{previous definition is here}} +struct C02 { + friend inline void func_02(); // expected-error{{inline declaration of 'func_02' follows non-inline definition}} +}; + +void func_03() {} // expected-note{{previous definition is here}} +struct C03 { + friend inline void func_03() {} // expected-error{{inline declaration of 'func_03' follows non-inline definition}} +}; + +void func_04() {} // expected-note{{previous definition is here}} +inline void func_04() {} // expected-error{{inline declaration of 'func_04' follows non-inline definition}} + +void func_06() {} // expected-note{{previous definition is here}} +template<typename T> struct C06 { + friend inline void func_06() {} // expected-error{{inline declaration of 'func_06' follows non-inline definition}} +}; + +void func_07() {} // expected-note{{previous definition is here}} +template<typename T> struct C07 { + friend inline void func_07(); // expected-error{{inline declaration of 'func_07' follows non-inline definition}} +}; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp index a5ac85cb6f3a3..6014268a18601 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp @@ -73,3 +73,36 @@ void Test () } } // namespace + +namespace pr12724 { + +void func_01(bool param = true); +class C01 { +public: + friend void func_01(bool param); +}; + +void func_02(bool param = true); +template<typename T> +class C02 { +public: + friend void func_02(bool param); +}; +C02<int> c02; + +void func_03(bool param); +template<typename T> +class C03 { +public: + friend void func_03(bool param); +}; +void func_03(bool param = true); +C03<int> c03; + +void main() { + func_01(); + func_02(); + func_03(); +} + +} // namespace pr12724 diff --git a/test/CXX/drs/dr13xx.cpp b/test/CXX/drs/dr13xx.cpp index 56ff1237480ff..64ba3be2a618d 100644 --- a/test/CXX/drs/dr13xx.cpp +++ b/test/CXX/drs/dr13xx.cpp @@ -192,7 +192,7 @@ namespace dr1330 { // dr1330: 4 c++11 static_assert(!noexcept(B<Q>().g()), ""); #endif - template<typename T> int f() throw(typename T::error) { return 0; } // expected-error 1-4{{prior to '::'}} expected-note 0-1{{instantiation of}} + template<typename T> int f() throw(typename T::error) { return 0; } // expected-error 1-4{{prior to '::'}} expected-note 0-1{{prior to '::'}} expected-note 0-1{{requested here}} #if __cplusplus > 201402L // expected-error@-2 0-1{{C++1z}} expected-note@-2 0-1{{noexcept}} #endif @@ -203,7 +203,16 @@ namespace dr1330 { // dr1330: 4 c++11 decltype(f<char>()) f2; // expected-note {{instantiation of}} bool f3 = noexcept(f<float>()); // expected-note {{instantiation of}} #endif - template int f<short>(); // expected-note {{instantiation of}} + // In C++1z onwards, substituting explicit template arguments into the + // function type substitutes into the exception specification (because it's + // part of the type). In earlier languages, we don't notice there's a problem + // until we've already started to instantiate. + template int f<short>(); +#if __cplusplus >= 201703L + // expected-error@-2 {{does not refer to a function template}} +#else + // expected-note@-4 {{instantiation of}} +#endif template<typename T> struct C { C() throw(typename T::type); // expected-error 1-2{{prior to '::'}} diff --git a/test/CXX/temp/temp.decls/temp.mem/p5.cpp b/test/CXX/temp/temp.decls/temp.mem/p5.cpp index 1e061fa33d3a4..a41ea6b5e109e 100644 --- a/test/CXX/temp/temp.decls/temp.mem/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.mem/p5.cpp @@ -77,3 +77,16 @@ void test_X0(X0 x0, const X0 &x0c) { x0.operator float *(); x0c.operator const char*(); } + +namespace PR14211 { +template <class U> struct X { + void foo(U){} + template <class T> void foo(T){} + + template <class T> void bar(T){} + void bar(U){} +}; + +template void X<int>::foo(int); +template void X<int>::bar(int); +} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp index e7b665a341371..357ea664037df 100644 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp @@ -46,10 +46,11 @@ namespace noexcept_conversion { template <class T> int h(T *, T *); // expected-note {{deduced conflicting types for parameter 'T' ('void () noexcept' vs. 'void ()')}} int x = h(g1, g2); // expected-error {{no matching function}} - // FIXME: It seems like a defect that B is not deducible here. - template<bool B> int i(void () noexcept(B)); // expected-note 2{{couldn't infer template argument 'B'}} - int i1 = i(g1); // expected-error {{no matching function}} - int i2 = i(g2); // expected-error {{no matching function}} + // We consider it a defect that deduction does not support the following. + // FIXME: Check that the defect is resolved as we expect. + template<bool B> int i(void () noexcept(B)); + int i1 = i(g1); + int i2 = i(g2); } #else // expected-no-diagnostics diff --git a/test/CodeGen/arm-long-calls.c b/test/CodeGen/arm-long-calls.c index fdd7babe9fe6a..cff2d66071134 100644 --- a/test/CodeGen/arm-long-calls.c +++ b/test/CodeGen/arm-long-calls.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple thumbv7-apple-ios5 -target-feature +long-calls -emit-llvm -o - %s | FileCheck -check-prefix=LONGCALL %s // RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck -check-prefix=NOLONGCALL %s -// LONGCALL: attributes #0 = { {{.*}} "target-features"="+long-calls" -// NOLONGCALL-NOT: attributes #0 = { {{.*}} "target-features"="+long-calls" +// LONGCALL: attributes #0 = { {{.*}} "target-features"="+long-calls,+thumb-mode" +// NOLONGCALL-NOT: attributes #0 = { {{.*}} "target-features"="+long-calls,+thumb-mode" int foo1(int a) { return a; } diff --git a/test/CodeGen/arm-no-movt.c b/test/CodeGen/arm-no-movt.c index 0773941fb384b..f61f2248643e6 100644 --- a/test/CodeGen/arm-no-movt.c +++ b/test/CodeGen/arm-no-movt.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple thumbv7-apple-ios5 -target-feature +no-movt -emit-llvm -o - %s | FileCheck -check-prefix=NO-MOVT %s // RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck -check-prefix=MOVT %s -// NO-MOVT: attributes #0 = { {{.*}} "target-features"="+no-movt" -// MOVT-NOT: attributes #0 = { {{.*}} "target-features"="+no-movt" +// NO-MOVT: attributes #0 = { {{.*}} "target-features"="+no-movt,+thumb-mode" +// MOVT-NOT: attributes #0 = { {{.*}} "target-features"="+no-movt,+thumb-mode" int foo1(int a) { return a; } diff --git a/test/CodeGen/arm-target-attr.c b/test/CodeGen/arm-target-attr.c new file mode 100644 index 0000000000000..42fe8d15aaf42 --- /dev/null +++ b/test/CodeGen/arm-target-attr.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s +// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s +// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s +// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s + +__attribute__((target("arm"))) void test_target_arm() { + // CHECKPOS: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]] + // CHECKNEG: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]] +} + +__attribute__((target("thumb"))) void test_target_thumb() { + // CHECKPOS: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]] + // CHECKNEG: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]] +} + +// CHECKPOS: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}" +// CHECKPOS: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}" +// CHECKNEG-NOT: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}" +// CHECKNEG-NOT: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}" diff --git a/test/CodeGen/arm-target-features.c b/test/CodeGen/arm-target-features.c index 7437fb0e4ed2f..e5591a28ad1ac 100644 --- a/test/CodeGen/arm-target-features.c +++ b/test/CodeGen/arm-target-features.c @@ -1,65 +1,63 @@ // REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3 -// CHECK-VFP3: "target-features"="+dsp,+neon,+vfp3" - - -// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a9 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-FP16 -// CHECK-VFP3-FP16: "target-features"="+dsp,+fp16,+neon,+vfp3" +// CHECK-VFP3: "target-features"="+dsp,+neon,+thumb-mode // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4 -// CHECK-VFP4: "target-features"="+dsp,+neon,+vfp4" +// CHECK-VFP4: "target-features"="+dsp,+neon,+thumb-mode,+vfp4" // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV -// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV -// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV // RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV -// CHECK-VFP4-DIV: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+vfp4" +// CHECK-VFP4-DIV: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp4" +// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM +// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM +// CHECK-VFP4-DIV-ARM: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+vfp4,-thumb-mode" // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a32 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a35 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 -// RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a72 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a73 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m1 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m2 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m3 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8 -// CHECK-BASIC-V8: "target-features"="+crc,+crypto,+dsp,+fp-armv8,+hwdiv,+hwdiv-arm,+neon" +// CHECK-BASIC-V8: "target-features"="+crc,+crypto,+dsp,+fp-armv8,+hwdiv,+hwdiv-arm,+neon,+thumb-mode" +// RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8-ARM +// CHECK-BASIC-V8-ARM: "target-features"="+crc,+crypto,+dsp,+fp-armv8,+hwdiv,+hwdiv-arm,+neon,-thumb-mode" // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-r5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-DIV -// CHECK-VFP3-D16-DIV: "target-features"="+d16,+dsp,+hwdiv,+hwdiv-arm,+vfp3" +// CHECK-VFP3-D16-DIV: "target-features"="+d16,+dsp,+hwdiv,+hwdiv-arm,+thumb-mode,+vfp3" // RUN: %clang_cc1 -triple armv7-linux-gnueabi -target-cpu cortex-r4f -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-THUMB-DIV -// CHECK-VFP3-D16-THUMB-DIV: "target-features"="+d16,+dsp,+hwdiv,+vfp3" +// CHECK-VFP3-D16-THUMB-DIV: "target-features"="+d16,+dsp,+hwdiv,+vfp3,-thumb-mode" // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-r7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-FP16-DIV // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-r8 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-FP16-DIV -// CHECK-VFP3-D16-FP16-DIV: "target-features"="+d16,+dsp,+fp16,+hwdiv,+hwdiv-arm,+vfp3" +// CHECK-VFP3-D16-FP16-DIV: "target-features"="+d16,+dsp,+fp16,+hwdiv,+hwdiv-arm,+thumb-mode,+vfp3" // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-m4 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-D16-SP-THUMB-DIV -// CHECK-VFP4-D16-SP-THUMB-DIV: "target-features"="+d16,+dsp,+fp-only-sp,+hwdiv,+vfp4" +// CHECK-VFP4-D16-SP-THUMB-DIV: "target-features"="+d16,+dsp,+fp-only-sp,+hwdiv,+thumb-mode,+vfp4" // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-m7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP5-D16-THUMB-DIV -// CHECK-VFP5-D16-THUMB-DIV: "target-features"="+d16,+dsp,+fp-armv8,+hwdiv" +// CHECK-VFP5-D16-THUMB-DIV: "target-features"="+d16,+dsp,+fp-armv8,+hwdiv,+thumb-mode" // RUN: %clang_cc1 -triple armv7-linux-gnueabi -target-cpu cortex-r4 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-THUMB-DIV -// CHECK-THUMB-DIV: "target-features"="+dsp,+hwdiv" +// CHECK-THUMB-DIV: "target-features"="+dsp,+hwdiv,-thumb-mode" // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-m3 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-THUMB-DIV-M3 -// CHECK-THUMB-DIV-M3: "target-features"="+hwdiv" +// CHECK-THUMB-DIV-M3: "target-features"="+hwdiv,+thumb-mode" void foo() {} diff --git a/test/CodeGen/arm-thumb-mode-target-feature.c b/test/CodeGen/arm-thumb-mode-target-feature.c new file mode 100644 index 0000000000000..5c41d0b16fdaa --- /dev/null +++ b/test/CodeGen/arm-thumb-mode-target-feature.c @@ -0,0 +1,33 @@ +// REQUIRES: arm-registered-target + +// RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix THUMB %s +// RUN: %clang_cc1 -triple thumbv7eb-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix THUMB %s +// RUN: %clang -target armv7-linux-gnueabihf -mthumb -S -emit-llvm -o - %s | FileCheck --check-prefix THUMB-CLANG %s +// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix ARM %s +// RUN: %clang_cc1 -triple armv7eb-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix ARM %s + +void t1() {} + + __attribute__((target("no-thumb-mode"))) +void t2() {} + + __attribute__((target("thumb-mode"))) +void t3() {} + +// THUMB: void @t1() [[ThumbAttr:#[0-7]]] +// THUMB: void @t2() [[NoThumbAttr:#[0-7]]] +// THUMB: void @t3() [[ThumbAttr:#[0-7]]] +// THUMB: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode" +// THUMB: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode" +// +// THUMB-CLANG: void @t1() [[ThumbAttr:#[0-7]]] +// THUMB-CLANG: void @t2() [[NoThumbAttr:#[0-7]]] +// THUMB-CLANG: void @t3() [[ThumbAttr:#[0-7]]] +// THUMB-CLANG: attributes [[ThumbAttr]] = { {{.*}} "target-features"="{{.*}}+thumb-mode +// THUMB-CLANG: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="{{.*}}-thumb-mode + +// ARM: void @t1() [[NoThumbAtr:#[0-7]]] +// ARM: void @t2() [[NoThumbAttr:#[0-7]]] +// ARM: void @t3() [[ThumbAttr:#[0-7]]] +// ARM: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode" +// ARM: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode" diff --git a/test/CodeGen/captured-statements.c b/test/CodeGen/captured-statements.c index 607ec8e55f48b..68ff2517be1e8 100644 --- a/test/CodeGen/captured-statements.c +++ b/test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 @@ -98,3 +98,8 @@ void dont_capture_global() { // CHECK-GLOBALS: load i32, i32* @global // CHECK-GLOBALS: load i32, i32* @ // CHECK-GLOBALS: load i32, i32* @e + +// CHECK-GLOBALS-NOT: DIFlagObjectPointer +// CHECK-1-NOT: DIFlagObjectPointer +// CHECK-2-NOT: DIFlagObjectPointer +// CHECK-3-NOT: DIFlagObjectPointer diff --git a/test/CodeGen/mips-madd4.c b/test/CodeGen/mips-madd4.c new file mode 100644 index 0000000000000..bc7bb593f95d6 --- /dev/null +++ b/test/CodeGen/mips-madd4.c @@ -0,0 +1,87 @@ +// REQUIRES: mips-registered-target +// RUN: %clang --target=mips64-unknown-linux -S -mmadd4 %s -o -| FileCheck %s -check-prefix=MADD4 +// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 %s -o -| FileCheck %s -check-prefix=NOMADD4 +// RUN: %clang --target=mips64-unknown-linux -S -mmadd4 -fno-honor-nans %s -o -| FileCheck %s -check-prefix=MADD4-NONAN +// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 -fno-honor-nans %s -o -| FileCheck %s -check-prefix=NOMADD4-NONAN + +float madd_s (float f, float g, float h) +{ + return (f * g) + h; +} +// MADD4: madd.s +// NOMADD4: mul.s +// NOMADD4: add.s + +float msub_s (float f, float g, float h) +{ + return (f * g) - h; +} +// MADD4: msub.s +// NOMADD4: mul.s +// NOMADD4: sub.s + +double madd_d (double f, double g, double h) +{ + return (f * g) + h; +} +// MADD4: madd.d +// NOMADD4: mul.d +// NOMADD4: add.d + +double msub_d (double f, double g, double h) +{ + return (f * g) - h; +} +// MADD4: msub.d +// NOMADD4: mul.d +// NOMADD4: sub.d + + +float nmadd_s (float f, float g, float h) +{ + // FIXME: Zero has been explicitly placed to force generation of a positive + // zero in IR until pattern used to match this instruction is changed to + // comply with negative zero as well. + return 0-((f * g) + h); +} +// MADD4-NONAN: nmadd.s +// NOMADD4-NONAN: mul.s +// NOMADD4-NONAN: add.s +// NOMADD4-NONAN: sub.s + +float nmsub_s (float f, float g, float h) +{ + // FIXME: Zero has been explicitly placed to force generation of a positive + // zero in IR until pattern used to match this instruction is changed to + // comply with negative zero as well. + return 0-((f * g) - h); +} +// MADD4-NONAN: nmsub.s +// NOMADD4-NONAN: mul.s +// NOMADD4-NONAN: sub.s +// NOMADD4-NONAN: sub.s + +double nmadd_d (double f, double g, double h) +{ + // FIXME: Zero has been explicitly placed to force generation of a positive + // zero in IR until pattern used to match this instruction is changed to + // comply with negative zero as well. + return 0-((f * g) + h); +} +// MADD4-NONAN: nmadd.d +// NOMADD4-NONAN: mul.d +// NOMADD4-NONAN: add.d +// NOMADD4-NONAN: sub.d + +double nmsub_d (double f, double g, double h) +{ + // FIXME: Zero has been explicitly placed to force generation of a positive + // zero in IR until pattern used to match this instruction is changed to + // comply with negative zero as well. + return 0-((f * g) - h); +} +// MADD4-NONAN: nmsub.d +// NOMADD4-NONAN: mul.d +// NOMADD4-NONAN: sub.d +// NOMADD4-NONAN: sub.d + diff --git a/test/CodeGen/neon-aapcs-align.c b/test/CodeGen/neon-aapcs-align.c new file mode 100644 index 0000000000000..4b7e5ff4d387a --- /dev/null +++ b/test/CodeGen/neon-aapcs-align.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple armv7a-none-eabi -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS +// RUN: %clang_cc1 -triple armv7a-none-gnueabi -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS +// RUN: %clang_cc1 -triple armv7a-none-freebsd -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS + +// RUN: %clang_cc1 -triple armv7a-apple-ios -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT +// RUN: %clang_cc1 -triple armv7a-none-android -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT +// RUN: %clang_cc1 -triple armv7a-none-androideabi -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT + +#include <arm_neon.h> +// Neon types have 64-bit alignment +int32x4_t gl_b; +void t3(int32x4_t *src) { +// CHECK: @t3 + gl_b = *src; +// AAPCS: store <4 x i32> {{%.*}}, <4 x i32>* @gl_b, align 8 +// DEFAULT: store <4 x i32> {{%.*}}, <4 x i32>* @gl_b, align 16 +} diff --git a/test/CodeGenCXX/captured-statements.cpp b/test/CodeGenCXX/captured-statements.cpp index 4b95503ad7b39..95e73e548399b 100644 --- a/test/CodeGenCXX/captured-statements.cpp +++ b/test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // 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 @@ -194,3 +194,18 @@ inline int test_captured_linkage() { void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) diff --git a/test/CodeGenCXX/clang-sections-tentative.c b/test/CodeGenCXX/clang-sections-tentative.c new file mode 100644 index 0000000000000..e663079b9aa41 --- /dev/null +++ b/test/CodeGenCXX/clang-sections-tentative.c @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -x c -emit-llvm -triple arm-none-eabi -o - %s | FileCheck %s + +// Test that section attributes are attached to C tentative definitions as per +// '#pragma clang section' directives. + +#pragma clang section bss = ".bss.1" +int x; // bss.1 + +#pragma clang section bss = "" +int x; // stays in .bss.1 +int y; // not assigned a section attribute +int z; // not assigned a section attribute + +#pragma clang section bss = ".bss.2" +int x; // stays in .bss.1 +int y; // .bss.2 + +// Test the same for `const` declarations. +#pragma clang section rodata = ".rodata.1" +const int cx; // rodata.1 + +#pragma clang section rodata = "" +const int cx; // stays in .rodata.1 +const int cy; // not assigned a section attribute +const int cz; // not assigned a rodata section attribute + +#pragma clang section rodata = ".rodata.2" +const int cx; // stays in .rodata.1 +const int cy; // .rodata.2 + +// CHECK: @x = global i32 0, align 4 #0 +// CHECK: @y = global i32 0, align 4 #1 +// CHECK: @z = common global i32 0, align 4 +// CHECK: @cx = constant i32 0, align 4 #2 +// CHECK: @cy = constant i32 0, align 4 #3 +// CHECK: @cz = constant i32 0, align 4 #1 + +// CHECK: attributes #0 = { "bss-section"=".bss.1" } +// CHECK: attributes #1 = { "bss-section"=".bss.2" } +// CHECK: attributes #2 = { "bss-section"=".bss.2" "rodata-section"=".rodata.1" } +// CHECK: attributes #3 = { "bss-section"=".bss.2" "rodata-section"=".rodata.2" } diff --git a/test/CodeGenCXX/clang-sections.cpp b/test/CodeGenCXX/clang-sections.cpp new file mode 100644 index 0000000000000..4fe42eaf77890 --- /dev/null +++ b/test/CodeGenCXX/clang-sections.cpp @@ -0,0 +1,78 @@ +// RUN: %clang_cc1 -emit-llvm -triple arm-none-eabi -o - %s | FileCheck %s +// Test that global variables, statics and functions are attached section-attributes +// as per '#pragma clang section' directives. + +extern "C" { +// test with names for each section +#pragma clang section bss="my_bss.1" data="my_data.1" rodata="my_rodata.1" +#pragma clang section text="my_text.1" +int a; // my_bss.1 +int b = 1; // my_data.1 +int c[4]; // my_bss.1 +short d[5] = {0}; // my_bss.1 +short e[6] = {0, 0, 1}; // my_data.1 +extern const int f; +const int f = 2; // my_rodata.1 +int foo(void) { // my_text.1 + return b; +} +static int g[2]; // my_bss.1 +#pragma clang section bss="" +int h; // default - .bss +#pragma clang section data="" bss="my_bss.2" text="my_text.2" +int i = 0; // my_bss.2 +extern const int j; +const int j = 4; // default - .rodata +int k; // my_bss.2 +extern int zoo(int *x, int *y); +int goo(void) { // my_text.2 + static int lstat_h; // my_bss.2 + return zoo(g, &lstat_h); +} +#pragma clang section rodata="my_rodata.2" data="my_data.2" +int l = 5; // my_data.2 +extern const int m; +const int m = 6; // my_rodata.2 +#pragma clang section rodata="" data="" bss="" text="" +int n; // default +int o = 6; // default +extern const int p; +const int p = 7; // default +int hoo(void) { + return b; +} +} +//CHECK: @a = global i32 0, align 4 #0 +//CHECK: @b = global i32 1, align 4 #0 +//CHECK: @c = global [4 x i32] zeroinitializer, align 4 #0 +//CHECK: @d = global [5 x i16] zeroinitializer, align 2 #0 +//CHECK: @e = global [6 x i16] [i16 0, i16 0, i16 1, i16 0, i16 0, i16 0], align 2 #0 +//CHECK: @f = constant i32 2, align 4 #0 + +//CHECK: @h = global i32 0, align 4 #1 +//CHECK: @i = global i32 0, align 4 #2 +//CHECK: @j = constant i32 4, align 4 #2 +//CHECK: @k = global i32 0, align 4 #2 +//CHECK: @_ZZ3gooE7lstat_h = internal global i32 0, align 4 #2 +//CHECK: @_ZL1g = internal global [2 x i32] zeroinitializer, align 4 #0 + +//CHECK: @l = global i32 5, align 4 #3 +//CHECK: @m = constant i32 6, align 4 #3 + +//CHECK: @n = global i32 0, align 4 +//CHECK: @o = global i32 6, align 4 +//CHECK: @p = constant i32 7, align 4 + +//CHECK: define i32 @foo() #4 { +//CHECK: define i32 @goo() #5 { +//CHECK: declare i32 @zoo(i32*, i32*) #6 +//CHECK: define i32 @hoo() #7 { + +//CHECK: attributes #0 = { "bss-section"="my_bss.1" "data-section"="my_data.1" "rodata-section"="my_rodata.1" } +//CHECK: attributes #1 = { "data-section"="my_data.1" "rodata-section"="my_rodata.1" } +//CHECK: attributes #2 = { "bss-section"="my_bss.2" "rodata-section"="my_rodata.1" } +//CHECK: attributes #3 = { "bss-section"="my_bss.2" "data-section"="my_data.2" "rodata-section"="my_rodata.2" } +//CHECK: attributes #4 = { {{.*"implicit-section-name"="my_text.1".*}} } +//CHECK: attributes #5 = { {{.*"implicit-section-name"="my_text.2".*}} } +//CHECK-NOT: attributes #6 = { {{.*"implicit-section-name".*}} } +//CHECK-NOT: attributes #7 = { {{.*"implicit-section-name".*}} } diff --git a/test/CodeGenObjC/exceptions-asm-attribute.m b/test/CodeGenObjC/exceptions-asm-attribute.m index 5719198f7962f..93e89b8e0a8ac 100644 --- a/test/CodeGenObjC/exceptions-asm-attribute.m +++ b/test/CodeGenObjC/exceptions-asm-attribute.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -fobjc-exceptions -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -Wno-objc-root-class -fexceptions -fobjc-exceptions -o %t %s // RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s // RUN: FileCheck -check-prefix=CHECK-EHTYPE < %t %s // rdar://16462586 @@ -15,11 +15,11 @@ // CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak global {{.*}}, align 8 // CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global // CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" = global {{.*}}, section "__DATA,__objc_const", align 8 -// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8 +// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip", align 8 // CHECK-X86_64: define internal void @"\01-[A im0]" // CHECK-X86_64: define internal void @"\01-[A(Cat) im1]" -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class -fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s // RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s // CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_MySecretNamespace.A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8 @@ -30,7 +30,7 @@ // CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]" // CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]" -// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -fobjc-exceptions -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -Wno-objc-root-class -fobjc-exceptions -emit-llvm -o %t %s // RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s // CHECK-ARMV6: @"OBJC_CLASS_$_MySecretNamespace.A" = global {{.*}}, section "__DATA, __objc_data", align 4 @@ -39,7 +39,7 @@ // CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak global {{.*}}, align 4 // CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global // CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" = global {{.*}}, section "__DATA,__objc_const", align 4 -// CHECK-ARMV6: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4 +// CHECK-ARMV6: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip", align 4 // CHECK-ARMV6: define internal void @"\01-[A im0]" // CHECK-ARMV6: define internal void @"\01-[A(Cat) im1]" diff --git a/test/CodeGenObjC/image-info.m b/test/CodeGenObjC/image-info.m index 43fb125a4cc67..37156ed039e4c 100644 --- a/test/CodeGenObjC/image-info.m +++ b/test/CodeGenObjC/image-info.m @@ -7,11 +7,11 @@ // CHECK-FRAGILE: !llvm.module.flags = !{{{.*}}} // CHECK-FRAGILE: !{{[0-9]+}} = !{i32 1, !"Objective-C Version", i32 1} // CHECK-FRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Version", i32 0} -// CHECK-FRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"__OBJC, __image_info,regular"} +// CHECK-FRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"__OBJC,__image_info,regular"} // CHECK-FRAGILE-NEXT: !{{[0-9]+}} = !{i32 4, !"Objective-C Garbage Collection", i32 0} // CHECK-NONFRAGILE: !llvm.module.flags = !{{{.*}}} // CHECK-NONFRAGILE: !{{[0-9]+}} = !{i32 1, !"Objective-C Version", i32 2} // CHECK-NONFRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Version", i32 0} -// CHECK-NONFRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"} +// CHECK-NONFRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"} // CHECK-NONFRAGILE-NEXT: !{{[0-9]+}} = !{i32 4, !"Objective-C Garbage Collection", i32 0} diff --git a/test/CodeGenObjC/metadata-symbols-64.m b/test/CodeGenObjC/metadata-symbols-64.m index 5139cd8fdedf6..b94f1b63843eb 100644 --- a/test/CodeGenObjC/metadata-symbols-64.m +++ b/test/CodeGenObjC/metadata-symbols-64.m @@ -12,7 +12,7 @@ // CHECK: @"\01l_OBJC_$_PROTOCOL_INSTANCE_METHODS_P" = private global {{.*}} section "__DATA, __objc_const", align 8 // CHECK: @"\01l_OBJC_$_PROTOCOL_CLASS_METHODS_P" = private global {{.*}} section "__DATA, __objc_const", align 8 // CHECK: @"\01l_OBJC_PROTOCOL_$_P" = weak hidden global {{.*}}, align 8 -// CHECK: @"\01l_OBJC_LABEL_PROTOCOL_$_P" = weak hidden global {{.*}} section "__DATA, __objc_protolist, coalesced, no_dead_strip", align 8 +// CHECK: @"\01l_OBJC_LABEL_PROTOCOL_$_P" = weak hidden global {{.*}} section "__DATA,__objc_protolist,coalesced,no_dead_strip", align 8 // CHECK: @"\01l_OBJC_CLASS_PROTOCOLS_$_A" = private global {{.*}} section "__DATA, __objc_const", align 8 // CHECK: @"\01l_OBJC_METACLASS_RO_$_A" = private global {{.*}} section "__DATA, __objc_const", align 8 // CHECK: @"\01l_OBJC_$_INSTANCE_METHODS_A" = private global {{.*}} section "__DATA, __objc_const", align 8 @@ -23,14 +23,14 @@ // CHECK: @"\01l_OBJC_$_CATEGORY_INSTANCE_METHODS_A_$_Cat" = private global {{.*}} section "__DATA, __objc_const", align 8 // CHECK: @"\01l_OBJC_$_CATEGORY_CLASS_METHODS_A_$_Cat" = private global {{.*}} section "__DATA, __objc_const", align 8 // CHECK: @"\01l_OBJC_$_CATEGORY_A_$_Cat" = private global {{.*}} section "__DATA, __objc_const", align 8 -// CHECK: @"OBJC_CLASSLIST_SUP_REFS_$_{{[0-9]*}}" = private global {{.*}} section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8 -// CHECK: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global {{.*}} section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip" -// CHECK: @"OBJC_CLASSLIST_SUP_REFS_$_{{[\.0-9]*}}" = private global {{.*}} section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8 +// CHECK: @"OBJC_CLASSLIST_SUP_REFS_$_{{[0-9]*}}" = private global {{.*}} section "__DATA,__objc_superrefs,regular,no_dead_strip", align 8 +// CHECK: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global {{.*}} section "__DATA,__objc_selrefs,literal_pointers,no_dead_strip" +// CHECK: @"OBJC_CLASSLIST_SUP_REFS_$_{{[\.0-9]*}}" = private global {{.*}} section "__DATA,__objc_superrefs,regular,no_dead_strip", align 8 // CHECK: @"OBJC_CLASS_$_B" = external global -// CHECK: @"OBJC_CLASSLIST_REFERENCES_$_{{[0-9]*}}" = private global {{.*}} section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8 -// CHECK: @"\01l_objc_msgSend_fixup_alloc" = weak hidden global {{.*}} section "__DATA, __objc_msgrefs, coalesced", align 16 -// CHECK: @"OBJC_LABEL_CLASS_$" = private global {{.*}} section "__DATA, __objc_classlist, regular, no_dead_strip", align 8 -// CHECK: @"OBJC_LABEL_CATEGORY_$" = private global {{.*}} section "__DATA, __objc_catlist, regular, no_dead_strip", align 8 +// CHECK: @"OBJC_CLASSLIST_REFERENCES_$_{{[0-9]*}}" = private global {{.*}} section "__DATA,__objc_classrefs,regular,no_dead_strip", align 8 +// CHECK: @"\01l_objc_msgSend_fixup_alloc" = weak hidden global {{.*}} section "__DATA,__objc_msgrefs,coalesced", align 16 +// CHECK: @"OBJC_LABEL_CLASS_$" = private global {{.*}} section "__DATA,__objc_classlist,regular,no_dead_strip", align 8 +// CHECK: @"OBJC_LABEL_CATEGORY_$" = private global {{.*}} section "__DATA,__objc_catlist,regular,no_dead_strip", align 8 // CHECK: @objc_msgSend_fpret( // CHECK: @objc_msgSend_fixup( diff --git a/test/CodeGenObjC/metadata_symbols.m b/test/CodeGenObjC/metadata_symbols.m index 4c365a14f9826..9aee55bb8e1a6 100644 --- a/test/CodeGenObjC/metadata_symbols.m +++ b/test/CodeGenObjC/metadata_symbols.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -fobjc-exceptions -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -Wno-objc-root-class -fexceptions -fobjc-exceptions -o %t %s // RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s // RUN: FileCheck -check-prefix=CHECK-EHTYPE < %t %s @@ -14,11 +14,11 @@ // CHECK-X86_64: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, align 8 // CHECK-X86_64: @"OBJC_EHTYPE_$_EH2" = external global // CHECK-X86_64: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 8 -// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8 +// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip", align 8 // CHECK-X86_64: define internal void @"\01-[A im0]" // CHECK-X86_64: define internal void @"\01-[A(Cat) im1]" -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class -fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s // RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s // CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8 @@ -29,7 +29,7 @@ // CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]" // CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]" -// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -fobjc-exceptions -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -Wno-objc-root-class -fobjc-exceptions -emit-llvm -o %t %s // RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s // CHECK-ARMV6: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4 @@ -38,7 +38,7 @@ // CHECK-ARMV6: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, align 4 // CHECK-ARMV6: @"OBJC_EHTYPE_$_EH2" = external global // CHECK-ARMV6: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 4 -// CHECK-ARMV6: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4 +// CHECK-ARMV6: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip", align 4 // CHECK-ARMV6: define internal void @"\01-[A im0]" // CHECK-ARMV6: define internal void @"\01-[A(Cat) im1]" diff --git a/test/CodeGenObjC/non-lazy-classes.m b/test/CodeGenObjC/non-lazy-classes.m index 400d3e9fdf940..b04b020e20ee7 100644 --- a/test/CodeGenObjC/non-lazy-classes.m +++ b/test/CodeGenObjC/non-lazy-classes.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class -emit-llvm -o - %s | \ // RUN: FileCheck %s -// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [1 x {{.*}}] {{.*}}@"OBJC_CLASS_$_A"{{.*}}, section "__DATA, __objc_nlclslist, regular, no_dead_strip", align 8 -// CHECK: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = private global [1 x {{.*}}] {{.*}}@"\01l_OBJC_$_CATEGORY_A_$_Cat"{{.*}}, section "__DATA, __objc_nlcatlist, regular, no_dead_strip", align 8 +// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [1 x {{.*}}] {{.*}}@"OBJC_CLASS_$_A"{{.*}}, section "__DATA,__objc_nlclslist,regular,no_dead_strip", align 8 +// CHECK: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = private global [1 x {{.*}}] {{.*}}@"\01l_OBJC_$_CATEGORY_A_$_Cat"{{.*}}, section "__DATA,__objc_nlcatlist,regular,no_dead_strip", align 8 @interface A @end @implementation A diff --git a/test/CodeGenObjC/sections.m b/test/CodeGenObjC/sections.m new file mode 100644 index 0000000000000..f98b7db073c6f --- /dev/null +++ b/test/CodeGenObjC/sections.m @@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-windows -fobjc-dispatch-method=mixed -fobjc-runtime=ios -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-COFF +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fobjc-dispatch-method=mixed -fobjc-runtime=ios -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-ELF +// RUN: %clang_cc1 -triple x86_64-apple-ios -fobjc-dispatch-method=mixed -fobjc-runtime=ios -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-MACHO + +__attribute__((__objc_root_class__)) +@interface NSObject ++ (void)load; ++ (id)class; +@end + +@protocol P +@end + +@interface I<P> : NSObject ++ (void)load; +@end + +@implementation I ++ (void)load; { } +@end + +@implementation I(C) ++ (void)load; { + [super load]; +} +@end + +@interface J : NSObject +- (void)m; +@end + +_Bool f(J *j) { + [j m]; + return [I class] == @protocol(P); +} + +// CHECK-COFF: @"OBJC_CLASSLIST_SUP_REFS_$_" = {{.*}}, section ".objc_superrefs$B" +// CHECK-COFF: @OBJC_SELECTOR_REFERENCES_ = {{.*}}, section ".objc_selrefs$B" +// CHECK-COFF: @"OBJC_CLASSLIST_REFERENCES_$_" = {{.*}}, section ".objc_classrefs$B" +// CHECK-COFF: @"\01l_objc_msgSend_fixup_class" = {{.*}}, section ".objc_msgrefs$B" +// CHECK-COFF: @"\01l_OBJC_LABEL_PROTOCOL_$_P" = {{.*}}, section ".objc_protolist$B" +// CHECK-COFF: @"\01l_OBJC_PROTOCOL_REFERENCE_$_P" = {{.*}}, section ".objc_protorefs$B" +// CHECK-COFF: @"OBJC_LABEL_CLASS_$" = {{.*}}, section ".objc_classlist$B" +// CHECK-COFF: @"OBJC_LABEL_NONLAZY_CLASS_$" = {{.*}}, section ".objc_nlclslist$B" +// CHECK-COFF: @"OBJC_LABEL_CATEGORY_$" = {{.*}}, section ".objc_catlist$B" +// CHECK-COFF: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = {{.*}}, section ".objc_nlcatlist$B" +// CHECK-COFF: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !".objc_imageinfo$B"} + +// CHECK-ELF: @"OBJC_CLASSLIST_SUP_REFS_$_" = {{.*}}, section "objc_superrefs" +// CHECK-ELF: @OBJC_SELECTOR_REFERENCES_ = {{.*}}, section "objc_selrefs" +// CHECK-ELF: @"OBJC_CLASSLIST_REFERENCES_$_" = {{.*}}, section "objc_classrefs" +// CHECK-ELF: @"\01l_objc_msgSend_fixup_class" = {{.*}}, section "objc_msgrefs" +// CHECK-ELF: @"\01l_OBJC_LABEL_PROTOCOL_$_P" = {{.*}}, section "objc_protolist" +// CHECK-ELF: @"\01l_OBJC_PROTOCOL_REFERENCE_$_P" = {{.*}}, section "objc_protorefs" +// CHECK-ELF: @"OBJC_LABEL_CLASS_$" = {{.*}}, section "objc_classlist" +// CHECK-ELF: @"OBJC_LABEL_NONLAZY_CLASS_$" = {{.*}}, section "objc_nlclslist" +// CHECK-ELF: @"OBJC_LABEL_CATEGORY_$" = {{.*}}, section "objc_catlist" +// CHECK-ELF: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = {{.*}}, section "objc_nlcatlist" +// CHECK-ELF: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"objc_imageinfo"} + +// CHECK-MACHO: @"OBJC_CLASSLIST_SUP_REFS_$_" = {{.*}}, section "__DATA,__objc_superrefs,regular,no_dead_strip" +// CHECK-MACHO: @OBJC_SELECTOR_REFERENCES_ = {{.*}}, section "__DATA,__objc_selrefs,literal_pointers,no_dead_strip" +// CHECK-MACHO: @"OBJC_CLASSLIST_REFERENCES_$_" = {{.*}}, section "__DATA,__objc_classrefs,regular,no_dead_strip" +// CHECK-MACHO: @"\01l_objc_msgSend_fixup_class" = {{.*}}, section "__DATA,__objc_msgrefs,coalesced" +// CHECK-MACHO: @"\01l_OBJC_LABEL_PROTOCOL_$_P" = {{.*}}, section "__DATA,__objc_protolist,coalesced,no_dead_strip" +// CHECK-MACHO: @"\01l_OBJC_PROTOCOL_REFERENCE_$_P" = {{.*}}, section "__DATA,__objc_protorefs,coalesced,no_dead_strip" +// CHECK-MACHO: @"OBJC_LABEL_CLASS_$" = {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip" +// CHECK-MACHO: @"OBJC_LABEL_NONLAZY_CLASS_$" = {{.*}}, section "__DATA,__objc_nlclslist,regular,no_dead_strip" +// CHECK-MACHO: @"OBJC_LABEL_CATEGORY_$" = {{.*}}, section "__DATA,__objc_catlist,regular,no_dead_strip" +// CHECK-MACHO: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = {{.*}}, section "__DATA,__objc_nlcatlist,regular,no_dead_strip" +// CHECK-MACHO: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"} + diff --git a/test/Driver/baremetal.cpp b/test/Driver/baremetal.cpp index aed90ac12c1e5..ec78b91363719 100644 --- a/test/Driver/baremetal.cpp +++ b/test/Driver/baremetal.cpp @@ -5,13 +5,13 @@ // RUN: --sysroot=%S/Inputs/baremetal_arm \ // RUN: | FileCheck --check-prefix=CHECK-V6M-C %s // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi" -// CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]" +// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]" // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include" // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp" // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic" -// CHECK-V6M-C-SAME: "-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal" +// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for" // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" // CHECK-V6M-C-SAME: "-o" "{{.*}}.o" diff --git a/test/Driver/cl-link.c b/test/Driver/cl-link.c index 4cc170c1cbb8a..142725fed8eb2 100644 --- a/test/Driver/cl-link.c +++ b/test/Driver/cl-link.c @@ -56,4 +56,4 @@ // NONEXISTENT: nonexistent // RUN: %clang_cl /Tc%s -fuse-ld=lld -### 2>&1 | FileCheck --check-prefix=USE_LLD %s -// USE_LLD: lld-link.exe +// USE_LLD: lld-link diff --git a/test/Driver/fsanitize-coverage.c b/test/Driver/fsanitize-coverage.c index 0516b6db524ce..b8a9fa60aa88f 100644 --- a/test/Driver/fsanitize-coverage.c +++ b/test/Driver/fsanitize-coverage.c @@ -5,6 +5,7 @@ // CHECK-SANITIZE-COVERAGE-0: -fsanitize=address // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC +// RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-address -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c index 786f517f5371e..f14459df6391f 100644 --- a/test/Driver/fsanitize.c +++ b/test/Driver/fsanitize.c @@ -271,6 +271,12 @@ // RUN: %clang -target thumbeb-linux -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-THUMBEB // CHECK-SANA-SANL-NO-SANA-THUMBEB: "-fsanitize=leak" +// RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS +// CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 'mips-unknown-linux' + +// RUN: %clang -target powerpc-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-PPC +// CHECK-SANL-PPC: unsupported option '-fsanitize=leak' for target 'powerpc-unknown-linux' + // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN // CHECK-MSAN: "-fno-assume-sane-operator-new" // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN diff --git a/test/FixIt/fixit-format-darwin.m b/test/FixIt/fixit-format-darwin.m new file mode 100644 index 0000000000000..bfc71291a5c3a --- /dev/null +++ b/test/FixIt/fixit-format-darwin.m @@ -0,0 +1,59 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -Wformat -fixit %t +// RUN: grep -v CHECK %t | FileCheck %s + +/* This is a test of code modifications created by darwin format fix-its hints + that are provided as part of warning */ + +int printf(const char * restrict, ...); + +#if __LP64__ +typedef long NSInteger; +typedef unsigned long NSUInteger; +#else +typedef int NSInteger; +typedef unsigned int NSUInteger; +#endif +NSInteger getNSInteger(); +NSUInteger getNSUInteger(); + +#define Log1(...) \ +do { \ + printf(__VA_ARGS__); \ +} while (0) + +#define Log2(...) \ +do { \ + printf(__VA_ARGS__); \ + printf(__VA_ARGS__); \ +} while (0) \ + +#define Log3(X, Y, Z) \ +do { \ + printf(X, Y); \ + printf(X, Z); \ +} while (0) \ + +void test() { + printf("test 1: %s", getNSInteger()); + // CHECK: printf("test 1: %ld", (long)getNSInteger()); + printf("test 2: %s %s", getNSInteger(), getNSInteger()); + // CHECK: printf("test 2: %ld %ld", (long)getNSInteger(), (long)getNSInteger()); + + Log1("test 3: %s", getNSInteger()); + // CHECK: Log1("test 3: %ld", (long)getNSInteger()); + Log1("test 4: %s %s", getNSInteger(), getNSInteger()); + // CHECK: Log1("test 4: %ld %ld", (long)getNSInteger(), (long)getNSInteger()); + + Log2("test 5: %s", getNSInteger()); + // CHECK: Log2("test 5: %ld", (long)getNSInteger()); + Log2("test 6: %s %s", getNSInteger(), getNSInteger()); + // CHECK: Log2("test 6: %ld %ld", (long)getNSInteger(), (long)getNSInteger()); + + // Artificial test to check that X (in Log3(X, Y, Z)) + // is modified only according to the diagnostics + // for the first printf and the modification caused + // by the second printf is dropped. + Log3("test 7: %s", getNSInteger(), getNSUInteger()); + // CHECK: Log3("test 7: %ld", (long)getNSInteger(), (unsigned long)getNSUInteger()); +} diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index 6443fe53c2a1d..a46558c7fb0b5 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -1,9 +1,8 @@ // RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s // RUN: cp %s %t // RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t -// RUN: grep -v CHECK %t > %t2 // RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t -// RUN: FileCheck -input-file=%t2 %t +// RUN: grep -v CHECK %t | FileCheck %t /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the diff --git a/test/Headers/ms-cppoperkey.cpp b/test/Headers/ms-cppoperkey.cpp new file mode 100644 index 0000000000000..ca56ee17bcb1c --- /dev/null +++ b/test/Headers/ms-cppoperkey.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 \ +// RUN: -fms-compatibility -x c++-cpp-output \ +// RUN: -ffreestanding -fsyntax-only -Werror \ +// RUN: %s -verify +// expected-no-diagnostics +# 1 "t.cpp" +# 1 "query.h" 1 3 +// MS header <query.h> uses operator keyword as field name. +// Compile without syntax errors. +struct tagRESTRICTION + { + union _URes + { + int or; // Note use of cpp operator token + } res; + }; diff --git a/test/Headers/ms-cppoperkey1.cpp b/test/Headers/ms-cppoperkey1.cpp new file mode 100644 index 0000000000000..c03efc9dacde4 --- /dev/null +++ b/test/Headers/ms-cppoperkey1.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 \ +// RUN: -fms-compatibility -x c++-cpp-output \ +// RUN: -ffreestanding -fsyntax-only -Werror \ +// RUN: %s -verify + + +# 1 "t.cpp" +# 1 "query.h" 1 3 4 +// MS header <query.h> uses operator keyword as field name. +// Compile without syntax errors. +struct tagRESTRICTION + { + union _URes + { + int or; // Note use of cpp operator token + } res; + }; + ; + +int aa ( int x) +{ + // In system header code, treat operator keyword as identifier. + if ( // expected-note{{to match this '('}} + x>1 or x<0) return 1; // expected-error{{expected ')'}} + else return 0; +} + diff --git a/test/Headers/ms-cppoperkey2.cpp b/test/Headers/ms-cppoperkey2.cpp new file mode 100644 index 0000000000000..2afed36b74468 --- /dev/null +++ b/test/Headers/ms-cppoperkey2.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-pc-win32 -fms-compatibility \ +// RUN: -ffreestanding -fsyntax-only -Werror %s -verify +// RUN: %clang_cc1 \ +// RUN: -ffreestanding -fsyntax-only -Werror %s -verify +// expected-no-diagnostics +int bb ( int x) +{ + // In user code, treat operator keyword as operator keyword. + if ( x>1 or x<0) return 1; + else return 0; +} diff --git a/test/Index/pipe-size.cl b/test/Index/pipe-size.cl new file mode 100644 index 0000000000000..d07d7067da8c3 --- /dev/null +++ b/test/Index/pipe-size.cl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86 +// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR +// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64 +// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl %s -o - | FileCheck %s --check-prefix=AMD +__kernel void testPipe( pipe int test ) +{ + int s = sizeof(test); + // X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8 + // X86: store i32 8, i32* %s, align 4 + // SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4 + // SPIR: store i32 4, i32* %s, align 4 + // SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8 + // SPIR64: store i32 8, i32* %s, align 4 + // AMD: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)* addrspace(5)* %test.addr, align 4 + // AMD: store i32 8, i32 addrspace(5)* %s, align 4 +} diff --git a/test/Index/singe-file-parse.m b/test/Index/singe-file-parse.m new file mode 100644 index 0000000000000..d13915b30c5f6 --- /dev/null +++ b/test/Index/singe-file-parse.m @@ -0,0 +1,11 @@ +// RUN: c-index-test -single-file-parse %s | FileCheck %s + +#include <stdint.h> + +// CHECK-NOT: TypedefDecl=intptr_t + +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=MyCls +@interface MyCls +// CHECK: [[@LINE+1]]:8: ObjCInstanceMethodDecl=some_meth +-(void)some_meth; +@end diff --git a/test/Modules/Inputs/crash-typo-correction-visibility/module.h b/test/Modules/Inputs/crash-typo-correction-visibility/module.h new file mode 100644 index 0000000000000..6e73c3c729e31 --- /dev/null +++ b/test/Modules/Inputs/crash-typo-correction-visibility/module.h @@ -0,0 +1 @@ +struct member; diff --git a/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap b/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap new file mode 100644 index 0000000000000..7310d6a2ef186 --- /dev/null +++ b/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap @@ -0,0 +1,3 @@ +module "module" { + header "module.h" +} diff --git a/test/Modules/crash-typo-correction-visibility.cpp b/test/Modules/crash-typo-correction-visibility.cpp new file mode 100644 index 0000000000000..518293026a639 --- /dev/null +++ b/test/Modules/crash-typo-correction-visibility.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o %T/module.pcm -emit-module %S/Inputs/crash-typo-correction-visibility/module.modulemap +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s -verify + +struct S { + int member; // expected-note {{declared here}} +}; + +int f(...); + +int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}} diff --git a/test/Modules/preprocess-build-diamond.m b/test/Modules/preprocess-build-diamond.m new file mode 100644 index 0000000000000..b031a0a91460c --- /dev/null +++ b/test/Modules/preprocess-build-diamond.m @@ -0,0 +1,26 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -E -o %t/diamond.mi -frewrite-imports +// RUN: FileCheck %s --input-file %t/diamond.mi +// RUN: %clang_cc1 -fmodules %t/diamond.mi -I. -verify + +// CHECK: {{^}}#pragma clang module build diamond_top +// CHECK: {{^}}module diamond_top { +// CHECK: {{^}}#pragma clang module contents + +// FIXME: @import does not work under -frewrite-includes / -frewrite-imports +// because we disable it when macro expansion is disabled. +#include "diamond_bottom.h" + +// expected-no-diagnostics +void test_diamond(int i, float f, double d, char c) { + top(&i); + left(&f); + right(&d); + bottom(&c); + top_left(&c); + left_and_right(&i); + struct left_and_right lr; + lr.left = 17; +} + diff --git a/test/Modules/preprocess-build.cpp b/test/Modules/preprocess-build.cpp new file mode 100644 index 0000000000000..bf9f16162be24 --- /dev/null +++ b/test/Modules/preprocess-build.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -std=c++1z %s -verify + +#pragma clang module build baz + module baz {} +#pragma clang module endbuild // baz + +#pragma clang module build foo + module foo { module bar {} } +#pragma clang module contents + #pragma clang module begin foo.bar + + // Can import baz here even though it was created in an outer build. + #pragma clang module import baz + + #pragma clang module build bar + module bar {} + #pragma clang module contents + #pragma clang module begin bar + extern int n; + #pragma clang module end + #pragma clang module endbuild // bar + + #pragma clang module import bar + + constexpr int *f() { return &n; } + + #pragma clang module end +#pragma clang module endbuild // foo + +#pragma clang module import bar +#pragma clang module import foo.bar +static_assert(f() == &n); + +#pragma clang module build // expected-error {{expected module name}} +#pragma clang module build unterminated // expected-error {{no matching '#pragma clang module endbuild'}} diff --git a/test/Modules/preprocess-module.cpp b/test/Modules/preprocess-module.cpp index 1e9458e667e1e..000290fc971bb 100644 --- a/test/Modules/preprocess-module.cpp +++ b/test/Modules/preprocess-module.cpp @@ -34,9 +34,29 @@ // RUN: rm %t/fwd.h %t/file.h %t/file2.h %t/module.modulemap // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x c++-module-map-cpp-output %t/copy.ii -emit-module -o %t/copy.pcm -// Finally, check that our module contains correct mapping information for the headers. +// Check that our module contains correct mapping information for the headers. // RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h %S/Inputs/preprocess/file2.h %S/Inputs/preprocess/module.modulemap %t // RUN: %clang_cc1 -fmodules -fmodule-file=%t/copy.pcm %s -I%t -verify -fno-modules-error-recovery -DCOPY -DINCLUDE +// RUN: rm %t/fwd.h %t/file.h %t/file2.h %t/module.modulemap + +// Check that we can preprocess from a .pcm file and that we get the same result as preprocessing from the original sources. +// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -I%S/Inputs/preprocess -x c++-module-map %S/Inputs/preprocess/module.modulemap -emit-module -o %t/file.pcm +// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -I%S/Inputs/preprocess %t/file.pcm -E -frewrite-includes -o %t/file.rewrite.ii +// FIXME: This check fails on Windows targets, due to canonicalization of directory separators. +// FIXME: cmp %t/rewrite.ii %t/file.rewrite.ii +// FIXME: Instead, just check that the preprocessed output is functionally equivalent to the output when preprocessing from the original sources. +// RUN: FileCheck %s --input-file %t/file.rewrite.ii --check-prefix=CHECK --check-prefix=REWRITE +// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x c++-module-map-cpp-output %t/file.rewrite.ii -emit-module -o %t/file.rewrite.pcm +// RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DFILE_REWRITE +// RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DFILE_REWRITE -DINCLUDE -I%S/Inputs/preprocess +// +// Check that language / header search options are ignored when preprocessing from a .pcm file. +// RUN: %clang_cc1 %t/file.pcm -E -frewrite-includes -o %t/file.rewrite.ii.2 +// RUN: cmp %t/file.rewrite.ii %t/file.rewrite.ii.2 +// +// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -I%S/Inputs/preprocess %t/file.pcm -E -o %t/file.no-rewrite.ii +// RUN: %clang_cc1 %t/file.pcm -E -o %t/file.no-rewrite.ii.2 -Dstruct=error +// RUN: cmp %t/file.no-rewrite.ii %t/file.no-rewrite.ii.2 // == module map // CHECK: # 1 "{{.*}}module.modulemap" @@ -105,7 +125,9 @@ __FILE *a; // expected-error {{declaration of '__FILE' must be imported}} -#ifdef REWRITE +#if FILE_REWRITE +// expected-note@file.rewrite.ii:1 {{here}} +#elif REWRITE // expected-note@rewrite.ii:1 {{here}} #elif COPY // expected-note@copy.ii:1 {{here}} diff --git a/test/Modules/requires-coroutines.mm b/test/Modules/requires-coroutines.mm index d3519cd2bba75..8e25a3c575211 100644 --- a/test/Modules/requires-coroutines.mm +++ b/test/Modules/requires-coroutines.mm @@ -1,12 +1,13 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -fcoroutines-ts -DCOROUTINES - +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs/DependsOnModule.framework %s -verify +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs/DependsOnModule.framework %s -verify -fcoroutines-ts -DCOROUTINES #ifdef COROUTINES @import DependsOnModule.Coroutines; -@import DependsOnModule.NotCoroutines; // expected-error {{module 'DependsOnModule.NotCoroutines' is incompatible with feature 'coroutines'}} +// expected-error@module.map:29 {{module 'DependsOnModule.NotCoroutines' is incompatible with feature 'coroutines'}} +@import DependsOnModule.NotCoroutines; // expected-note {{module imported here}} #else @import DependsOnModule.NotCoroutines; -@import DependsOnModule.Coroutines; // expected-error {{module 'DependsOnModule.Coroutines' requires feature 'coroutines'}} +// expected-error@module.map:25 {{module 'DependsOnModule.Coroutines' requires feature 'coroutines'}} +@import DependsOnModule.Coroutines; // expected-note {{module imported here}} #endif diff --git a/test/Modules/requires-gnuinlineasm.m b/test/Modules/requires-gnuinlineasm.m index 80b1b18d0742f..e710b6bf8d4b5 100644 --- a/test/Modules/requires-gnuinlineasm.m +++ b/test/Modules/requires-gnuinlineasm.m @@ -1,6 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules \ // RUN: -fimplicit-module-maps -F %S/Inputs/GNUAsm %s \ +// RUN: -I %S/Inputs/GNUAsm \ // RUN: -fno-gnu-inline-asm -DNO_ASM_INLINE -verify // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules \ @@ -8,7 +9,8 @@ // RUN: -DASM_INLINE -verify #ifdef NO_ASM_INLINE -@import NeedsGNUInlineAsm.Asm; // expected-error{{module 'NeedsGNUInlineAsm.Asm' requires feature 'gnuinlineasm'}} +// expected-error@NeedsGNUInlineAsm.framework/module.map:4 {{module 'NeedsGNUInlineAsm.Asm' requires feature 'gnuinlineasm'}} +@import NeedsGNUInlineAsm.Asm; // expected-note {{module imported here}} #endif #ifdef ASM_INLINE diff --git a/test/Modules/requires.m b/test/Modules/requires.m index 1a013727108b7..d61de6bd48d0e 100644 --- a/test/Modules/requires.m +++ b/test/Modules/requires.m @@ -1,12 +1,17 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -fmodule-feature custom_req1 +// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify -fmodule-feature custom_req1 -@import DependsOnModule.CXX; // expected-error{{module 'DependsOnModule.CXX' requires feature 'cplusplus'}} +// expected-error@DependsOnModule.framework/module.map:7 {{module 'DependsOnModule.CXX' requires feature 'cplusplus'}} +@import DependsOnModule.CXX; // expected-note {{module imported here}} @import DependsOnModule.NotCXX; -@import DependsOnModule.NotObjC; // expected-error{{module 'DependsOnModule.NotObjC' is incompatible with feature 'objc'}} +// expected-error@DependsOnModule.framework/module.map:15 {{module 'DependsOnModule.NotObjC' is incompatible with feature 'objc'}} +@import DependsOnModule.NotObjC; // expected-note {{module imported here}} @import DependsOnModule.CustomReq1; // OK -@import DependsOnModule.CustomReq2; // expected-error{{module 'DependsOnModule.CustomReq2' requires feature 'custom_req2'}} +// expected-error@DependsOnModule.framework/module.map:22 {{module 'DependsOnModule.CustomReq2' requires feature 'custom_req2'}} +@import DependsOnModule.CustomReq2; // expected-note {{module imported here}} @import RequiresWithMissingHeader; // OK -@import RequiresWithMissingHeader.HeaderBefore; // expected-error{{module 'RequiresWithMissingHeader.HeaderBefore' requires feature 'missing'}} -@import RequiresWithMissingHeader.HeaderAfter; // expected-error{{module 'RequiresWithMissingHeader.HeaderAfter' requires feature 'missing'}} +// expected-error@module.map:* {{module 'RequiresWithMissingHeader.HeaderBefore' requires feature 'missing'}} +@import RequiresWithMissingHeader.HeaderBefore; // expected-note {{module imported here}} +// expected-error@module.map:* {{module 'RequiresWithMissingHeader.HeaderAfter' requires feature 'missing'}} +@import RequiresWithMissingHeader.HeaderAfter; // expected-note {{module imported here}} diff --git a/test/Modules/requires.mm b/test/Modules/requires.mm index cc64a500bd578..f90622ece842a 100644 --- a/test/Modules/requires.mm +++ b/test/Modules/requires.mm @@ -1,6 +1,8 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify +// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs/DependsOnModule.framework %s -verify @import DependsOnModule.CXX; -@import DependsOnModule.NotCXX; // expected-error{{module 'DependsOnModule.NotCXX' is incompatible with feature 'cplusplus'}} -@import DependsOnModule.NotObjC; // expected-error{{module 'DependsOnModule.NotObjC' is incompatible with feature 'objc'}} +// expected-error@module.map:11 {{module 'DependsOnModule.NotCXX' is incompatible with feature 'cplusplus'}} +@import DependsOnModule.NotCXX; // expected-note {{module imported here}} +// expected-error@module.map:15 {{module 'DependsOnModule.NotObjC' is incompatible with feature 'objc'}} +@import DependsOnModule.NotObjC; // expected-note {{module imported here}} diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 36ef9b213658e..0bd9e9784599b 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -4664,6 +4664,16 @@ // RUN: | FileCheck -match-full-lines -check-prefix MIPS-MSA %s // MIPS-MSA:#define __mips_msa 1 // +// RUN: %clang_cc1 -target-feature +nomadd4 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -match-full-lines -check-prefix MIPS-NOMADD4 %s +// MIPS-NOMADD4:#define __mips_no_madd4 1 +// +// RUN: %clang_cc1 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -match-full-lines -check-prefix MIPS-MADD4 %s +// MIPS-MADD4-NOT:#define __mips_no_madd4 1 +// // RUN: %clang_cc1 -target-cpu mips32r3 -target-feature +nan2008 \ // RUN: -E -dM -triple=mips-none-none < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefix MIPS-NAN2008 %s @@ -8851,7 +8861,7 @@ // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_CHAR_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_INT_LOCK_FREE 2 -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_LLONG_LOCK_FREE 1 +// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_LLONG_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_LONG_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2 @@ -8895,7 +8905,7 @@ // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2 -// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1 +// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2 diff --git a/test/Sema/2010-05-31-palignr.c b/test/Sema/2010-05-31-palignr.c index 12be29af95c0c..d9bf8f68b7a51 100644 --- a/test/Sema/2010-05-31-palignr.c +++ b/test/Sema/2010-05-31-palignr.c @@ -1,13 +1,12 @@ -// RUN: not %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o /dev/null %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -ffreestanding -verify -fsyntax-only %s #include <tmmintrin.h> +#include <stdint.h> extern int i; int main () { -#if defined( __SSSE3__ ) - typedef int16_t vSInt16 __attribute__ ((__vector_size__ (16))); short dtbl[] = {1,2,3,4,5,6,7,8}; @@ -15,8 +14,7 @@ int main () vSInt16 v0; v0 = *vdtbl; - v0 = _mm_alignr_epi8(v0, v0, i); // expected-error {{argument to '__builtin_ia32_palignr128' must be a constant integer}} + _mm_alignr_epi8(v0, v0, i); // expected-error {{argument to '__builtin_ia32_palignr128' must be a constant integer}} return 0; -#endif } diff --git a/test/Sema/ext_vector_ops.c b/test/Sema/ext_vector_ops.c new file mode 100644 index 0000000000000..af4df07e14da9 --- /dev/null +++ b/test/Sema/ext_vector_ops.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10 + +typedef unsigned int v2u __attribute__ ((ext_vector_type(2))); +typedef int v2s __attribute__ ((ext_vector_type(2))); +typedef float v2f __attribute__ ((ext_vector_type(2))); + +void test1(v2u v2ua, v2s v2sa, v2f v2fa) { + // Bitwise binary operators + (void)(v2ua & v2ua); + (void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}} + + // Unary operators + (void)(~v2ua); + (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}} + + // Comparison operators + v2sa = (v2ua==v2sa); + + // Arrays + int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values}} + int array2[17]; + // FIXME: error message below needs type! + (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}} + + v2u *v2u_ptr = 0; + v2s *v2s_ptr; +} diff --git a/test/Sema/pragma-clang-section.c b/test/Sema/pragma-clang-section.c new file mode 100644 index 0000000000000..49463889d37b3 --- /dev/null +++ b/test/Sema/pragma-clang-section.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple arm-none-eabi +#pragma clang section bss="mybss.1" data="mydata.1" rodata="myrodata.1" text="mytext.1" +#pragma clang section bss="" data="" rodata="" text="" +#pragma clang section + +#pragma clang section dss="mybss.2" // expected-error {{expected one of [bss|data|rodata|text] section kind in '#pragma clang section'}} +#pragma clang section deta="mydata.2" // expected-error {{expected one of [bss|data|rodata|text] section kind in '#pragma clang section'}} +#pragma clang section rodeta="rodata.2" // expected-error {{expected one of [bss|data|rodata|text] section kind in '#pragma clang section'}} +#pragma clang section taxt="text.2" // expected-error {{expected one of [bss|data|rodata|text] section kind in '#pragma clang section'}} + +#pragma clang section section bss="mybss.2" // expected-error {{expected one of [bss|data|rodata|text] section kind in '#pragma clang section'}} + +#pragma clang section bss "mybss.2" // expected-error {{expected '=' following '#pragma clang section bss'}} +#pragma clang section data "mydata.2" // expected-error {{expected '=' following '#pragma clang section data'}} +#pragma clang section rodata "myrodata.2" // expected-error {{expected '=' following '#pragma clang section rodata'}} +#pragma clang section bss="" data="" rodata="" text="" more //expected-error {{expected one of [bss|data|rodata|text] section kind in '#pragma clang section'}} +int a; diff --git a/test/SemaCXX/PR27037.cpp b/test/SemaCXX/PR27037.cpp new file mode 100644 index 0000000000000..422de0e6371ac --- /dev/null +++ b/test/SemaCXX/PR27037.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct A { + void f(); +}; + +struct B : A {}; + +void m() { + const B b; + (b.*&B::f)(); // expected-error{{drops 'const' qualifier}} + ((&b)->*&B::f)(); // expected-error{{drops 'const' qualifier}} +} diff --git a/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/test/SemaCXX/cxx0x-cursory-default-delete.cpp index 17215fedf0aba..7a581fd519a9e 100644 --- a/test/SemaCXX/cxx0x-cursory-default-delete.cpp +++ b/test/SemaCXX/cxx0x-cursory-default-delete.cpp @@ -136,13 +136,13 @@ struct bad_decls { }; struct DefaultDelete { - DefaultDelete() = default; // expected-note {{previous declaration is here}} + DefaultDelete() = default; // expected-note {{previous definition is here}} DefaultDelete() = delete; // expected-error {{constructor cannot be redeclared}} - ~DefaultDelete() = default; // expected-note {{previous declaration is here}} + ~DefaultDelete() = default; // expected-note {{previous definition is here}} ~DefaultDelete() = delete; // expected-error {{destructor cannot be redeclared}} - DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous declaration is here}} + DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous definition is here}} DefaultDelete &operator=(const DefaultDelete &) = delete; // expected-error {{class member cannot be redeclared}} }; diff --git a/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp b/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp index b08d58abd2a9c..dc3adca62fd36 100644 --- a/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp +++ b/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp @@ -1376,3 +1376,7 @@ XT<int> xt{}; } + +void PR33318(int i) { + [&](auto) { static_assert(&i != nullptr, ""); }(0); // expected-warning 2{{always true}} expected-note {{instantiation}} +} diff --git a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp index 5de228ad28574..159b7072e61e5 100644 --- a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp @@ -248,3 +248,35 @@ namespace variadic { }; Z z(1, a, b); } + +namespace tuple_tests { + // The converting n-ary constructor appears viable, deducing T as an empty + // pack (until we check its SFINAE constraints). + namespace libcxx_1 { + template<class ...T> struct tuple { + template<class ...Args> struct X { static const bool value = false; }; + template<class ...U, bool Y = X<U...>::value> tuple(U &&...u); + }; + tuple a = {1, 2, 3}; + } + + // Don't get caught by surprise when X<...> doesn't even exist in the + // selected specialization! + namespace libcxx_2 { + template<class ...T> struct tuple { // expected-note {{candidate}} + template<class ...Args> struct X { static const bool value = false; }; + template<class ...U, bool Y = X<U...>::value> tuple(U &&...u); + // expected-note@-1 {{substitution failure [with T = <>, U = <int, int, int>]: cannot reference member of primary template because deduced class template specialization 'tuple<>' is an explicit specialization}} + }; + template <> class tuple<> {}; + tuple a = {1, 2, 3}; // expected-error {{no viable constructor or deduction guide}} + } + + namespace libcxx_3 { + template<typename ...T> struct scoped_lock { + scoped_lock(T...); + }; + template<> struct scoped_lock<> {}; + scoped_lock l = {}; + } +} diff --git a/test/SemaCXX/cxx1z-noexcept-function-type.cpp b/test/SemaCXX/cxx1z-noexcept-function-type.cpp index a3f710970456b..40dc3a22e530b 100644 --- a/test/SemaCXX/cxx1z-noexcept-function-type.cpp +++ b/test/SemaCXX/cxx1z-noexcept-function-type.cpp @@ -16,7 +16,7 @@ template<typename A, typename B> void redecl3() throw(B); // expected-error {{do typedef int I; template<bool B> void redecl4(I) noexcept(B); -template<bool B> void redecl4(I) noexcept(B); // expected-note {{failed template argument deduction}} +template<bool B> void redecl4(I) noexcept(B); // expected-note {{could not match 'void (I) noexcept(false)' (aka 'void (int) noexcept(false)') against 'void (int) noexcept'}} void (*init_with_exact_type_a)(int) noexcept = redecl4<true>; void (*init_with_mismatched_type_a)(int) = redecl4<true>; diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp index 74eb5a6ee5819..be86f18729dc2 100644 --- a/test/SemaTemplate/deduction.cpp +++ b/test/SemaTemplate/deduction.cpp @@ -305,11 +305,11 @@ namespace nullptr_deduction { template<typename T, T v> struct X {}; template<typename T, T v> void f(X<T, v>) { - static_assert(!v, ""); + static_assert(!v, ""); // expected-warning 2{{implicit conversion of nullptr constant to 'bool'}} } void g() { - f(X<int*, nullptr>()); - f(X<nullptr_t, nullptr>()); + f(X<int*, nullptr>()); // expected-note {{instantiation of}} + f(X<nullptr_t, nullptr>()); // expected-note {{instantiation of}} } template<template<typename T, T> class X, typename T, typename U, int *P> diff --git a/test/SemaTemplate/dependent-template-recover.cpp b/test/SemaTemplate/dependent-template-recover.cpp index 3c01f6586b016..ac1623041719b 100644 --- a/test/SemaTemplate/dependent-template-recover.cpp +++ b/test/SemaTemplate/dependent-template-recover.cpp @@ -17,6 +17,28 @@ struct X { } }; +struct MrsBadcrumble { + friend MrsBadcrumble operator<(void (*)(int), MrsBadcrumble); + friend void operator>(MrsBadcrumble, int); +} mb; + +template<int N, typename T> void f(T t) { + t.f<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}} + t.T::f<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}} + T::g<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'g'}} + + // Note: no diagnostic here, this is actually valid as a comparison between + // the decayed pointer to Y::g<> and mb! + T::g<mb>(0); +} + +struct Y { + template <int> void f(int); + template <int = 0> static void g(int); // expected-warning 0-1{{extension}} +}; +void q() { void (*p)(int) = Y::g; } +template void f<0>(Y); // expected-note {{in instantiation of}} + namespace PR9401 { // From GCC PR c++/45558 template <typename S, typename T> diff --git a/test/SemaTemplate/temp_arg_type.cpp b/test/SemaTemplate/temp_arg_type.cpp index daad61c14292c..9069f63e0224f 100644 --- a/test/SemaTemplate/temp_arg_type.cpp +++ b/test/SemaTemplate/temp_arg_type.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s template<typename T> class A; // expected-note 2 {{template parameter is declared here}} expected-note{{template is declared here}} @@ -53,3 +54,56 @@ A1<Array<int, 17>::type> ax; // FIXME: [temp.arg.type]p3. The check doesn't really belong here (it // belongs somewhere in the template instantiation section). + +#if __cplusplus >= 201703 +// As a defect resolution, we support deducing B in noexcept(B). +namespace deduce_noexcept { + template<typename> struct function; + template<typename R, typename ...A, bool N> + struct function<R(A...) noexcept(N)> { + static constexpr bool Noexcept = N; + }; + static_assert(function<int(float, double) noexcept>::Noexcept); + static_assert(!function<int(float, double)>::Noexcept); + + void noexcept_function() noexcept; + void throwing_function(); + + template<typename T, bool B> float &deduce_function(T(*)() noexcept(B)); // expected-note {{candidate}} + template<typename T> int &deduce_function(T(*)() noexcept); // expected-note {{candidate}} + void test_function_deduction() { + // FIXME: This should probably unambiguously select the second overload. + int &r = deduce_function(noexcept_function); // expected-error {{ambiguous}} + float &s = deduce_function(throwing_function); + } + + namespace low_priority_deduction { + template<int> struct A {}; + template<auto B> void f(A<B>, void(*)() noexcept(B)) { + using T = decltype(B); + using T = int; + } + void g() { f(A<0>(), g); } // ok, deduce B as an int + } + + // FIXME: It's not clear whether this should work. We're told to deduce with + // P being the function template type and A being the declared type, which + // would accept this, but considering the exception specification in such + // cases breaks new/delete matching. + template<bool Noexcept> void dep() noexcept(Noexcept) {} // expected-note 3{{couldn't infer template argument 'Noexcept'}} + template void dep(); // expected-error {{does not refer to a function template}} + template void dep() noexcept(true); // expected-error {{does not refer to a function template}} + template void dep() noexcept(false); // expected-error {{does not refer to a function template}} + + // FIXME: It's also not clear whether this should be valid: do we substitute + // into the function type (including the exception specification) or not? + template<typename T> typename T::type1 f() noexcept(T::a); + template<typename T> typename T::type2 f() noexcept(T::b) {} + struct X { + static constexpr bool b = true; + using type1 = void; + using type2 = void; + }; + template void f<X>(); +} +#endif |