diff options
Diffstat (limited to 'test/PCH')
27 files changed, 668 insertions, 22 deletions
diff --git a/test/PCH/Inputs/pch-through-use0.cpp b/test/PCH/Inputs/pch-through-use0.cpp new file mode 100644 index 0000000000000..a39080144fbb8 --- /dev/null +++ b/test/PCH/Inputs/pch-through-use0.cpp @@ -0,0 +1,2 @@ +void foo() { +} diff --git a/test/PCH/Inputs/pch-through-use1.cpp b/test/PCH/Inputs/pch-through-use1.cpp new file mode 100644 index 0000000000000..4eda7cecc9513 --- /dev/null +++ b/test/PCH/Inputs/pch-through-use1.cpp @@ -0,0 +1,5 @@ +#include "Inputs/pch-through1.h" +#include "Inputs/pch-through3.h" +void foo() { + through2(0); +} diff --git a/test/PCH/Inputs/pch-through-use2.cpp b/test/PCH/Inputs/pch-through-use2.cpp new file mode 100644 index 0000000000000..217803ba398cd --- /dev/null +++ b/test/PCH/Inputs/pch-through-use2.cpp @@ -0,0 +1,3 @@ +void foo() { + through4(0); +} diff --git a/test/PCH/Inputs/pch-through-use3a.cpp b/test/PCH/Inputs/pch-through-use3a.cpp new file mode 100644 index 0000000000000..dfd1d11071c0e --- /dev/null +++ b/test/PCH/Inputs/pch-through-use3a.cpp @@ -0,0 +1,2 @@ +#define AFOO 0 +#include "Inputs/pch-through1.h" diff --git a/test/PCH/Inputs/pch-through-use3b.cpp b/test/PCH/Inputs/pch-through-use3b.cpp new file mode 100644 index 0000000000000..5b547647d85be --- /dev/null +++ b/test/PCH/Inputs/pch-through-use3b.cpp @@ -0,0 +1,3 @@ +#define AFOO 1 +#define BFOO 2 +#include "Inputs/pch-through1.h" diff --git a/test/PCH/Inputs/pch-through1.h b/test/PCH/Inputs/pch-through1.h new file mode 100644 index 0000000000000..7ebfa7d5df28e --- /dev/null +++ b/test/PCH/Inputs/pch-through1.h @@ -0,0 +1,2 @@ +#define THROUGH1 +int through1(int); diff --git a/test/PCH/Inputs/pch-through2.h b/test/PCH/Inputs/pch-through2.h new file mode 100644 index 0000000000000..4c1f2981f9327 --- /dev/null +++ b/test/PCH/Inputs/pch-through2.h @@ -0,0 +1,2 @@ +#define THROUGH2 +int through2(int); diff --git a/test/PCH/Inputs/pch-through3.h b/test/PCH/Inputs/pch-through3.h new file mode 100644 index 0000000000000..28368655004d0 --- /dev/null +++ b/test/PCH/Inputs/pch-through3.h @@ -0,0 +1,2 @@ +#define THROUGH3 +int through3(int); diff --git a/test/PCH/Inputs/pch-through4.h b/test/PCH/Inputs/pch-through4.h new file mode 100644 index 0000000000000..95860edd196b7 --- /dev/null +++ b/test/PCH/Inputs/pch-through4.h @@ -0,0 +1,2 @@ +#define THROUGH4 +int through4(int); diff --git a/test/PCH/Inputs/std-compare.h b/test/PCH/Inputs/std-compare.h new file mode 100644 index 0000000000000..a6ab605bb5276 --- /dev/null +++ b/test/PCH/Inputs/std-compare.h @@ -0,0 +1,437 @@ +#ifndef STD_COMPARE_H +#define STD_COMPARE_H + +namespace std { +inline namespace __1 { + +// exposition only +enum class _EqResult : unsigned char { + __zero = 0, + __equal = __zero, + __equiv = __equal, + __nonequal = 1, + __nonequiv = __nonequal +}; + +enum class _OrdResult : signed char { + __less = -1, + __greater = 1 +}; + +enum class _NCmpResult : signed char { + __unordered = -127 +}; + +struct _CmpUnspecifiedType; +using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)(); + +class weak_equality { + constexpr explicit weak_equality(_EqResult __val) noexcept : __value_(__val) {} + +public: + static const weak_equality equivalent; + static const weak_equality nonequivalent; + + friend constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept; + friend constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept; + friend constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept; + friend constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept; + + // test helper + constexpr bool test_eq(weak_equality const &other) const noexcept { + return __value_ == other.__value_; + } + +private: + _EqResult __value_; +}; + +inline constexpr weak_equality weak_equality::equivalent(_EqResult::__equiv); +inline constexpr weak_equality weak_equality::nonequivalent(_EqResult::__nonequiv); +inline constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ == _EqResult::__zero; +} +inline constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept { + return __v.__value_ == _EqResult::__zero; +} +inline constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ != _EqResult::__zero; +} +inline constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept { + return __v.__value_ != _EqResult::__zero; +} + +inline constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept { + return __v; +} +inline constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept { + return __v; +} + +class strong_equality { + explicit constexpr strong_equality(_EqResult __val) noexcept : __value_(__val) {} + +public: + static const strong_equality equal; + static const strong_equality nonequal; + static const strong_equality equivalent; + static const strong_equality nonequivalent; + + // conversion + constexpr operator weak_equality() const noexcept { + return __value_ == _EqResult::__zero ? weak_equality::equivalent + : weak_equality::nonequivalent; + } + + // comparisons + friend constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept; + friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept; + + friend constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept; + friend constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept; + + // test helper + constexpr bool test_eq(strong_equality const &other) const noexcept { + return __value_ == other.__value_; + } + +private: + _EqResult __value_; +}; + +inline constexpr strong_equality strong_equality::equal(_EqResult::__equal); +inline constexpr strong_equality strong_equality::nonequal(_EqResult::__nonequal); +inline constexpr strong_equality strong_equality::equivalent(_EqResult::__equiv); +inline constexpr strong_equality strong_equality::nonequivalent(_EqResult::__nonequiv); +constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ == _EqResult::__zero; +} +constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept { + return __v.__value_ == _EqResult::__zero; +} +constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ != _EqResult::__zero; +} +constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept { + return __v.__value_ != _EqResult::__zero; +} + +constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept { + return __v; +} +constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept { + return __v; +} + +class partial_ordering { + using _ValueT = signed char; + explicit constexpr partial_ordering(_EqResult __v) noexcept + : __value_(_ValueT(__v)) {} + explicit constexpr partial_ordering(_OrdResult __v) noexcept + : __value_(_ValueT(__v)) {} + explicit constexpr partial_ordering(_NCmpResult __v) noexcept + : __value_(_ValueT(__v)) {} + + constexpr bool __is_ordered() const noexcept { + return __value_ != _ValueT(_NCmpResult::__unordered); + } + +public: + // valid values + static const partial_ordering less; + static const partial_ordering equivalent; + static const partial_ordering greater; + static const partial_ordering unordered; + + // conversion + constexpr operator weak_equality() const noexcept { + return __value_ == 0 ? weak_equality::equivalent : weak_equality::nonequivalent; + } + + // comparisons + friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept; + friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept; + friend constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept; + friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept; + friend constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept; + friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept; + + friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept; + + // test helper + constexpr bool test_eq(partial_ordering const &other) const noexcept { + return __value_ == other.__value_; + } + +private: + _ValueT __value_; +}; + +inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less); +inline constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv); +inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater); +inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered); +constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ == 0; +} +constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ < 0; +} +constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ <= 0; +} +constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ > 0; +} +constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ >= 0; +} +constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 == __v.__value_; +} +constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 < __v.__value_; +} +constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 <= __v.__value_; +} +constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 > __v.__value_; +} +constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 >= __v.__value_; +} +constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return !__v.__is_ordered() || __v.__value_ != 0; +} +constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return !__v.__is_ordered() || __v.__value_ != 0; +} + +constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v; +} +constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v); +} + +class weak_ordering { + using _ValueT = signed char; + explicit constexpr weak_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {} + explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} + +public: + static const weak_ordering less; + static const weak_ordering equivalent; + static const weak_ordering greater; + + // conversions + constexpr operator weak_equality() const noexcept { + return __value_ == 0 ? weak_equality::equivalent + : weak_equality::nonequivalent; + } + constexpr operator partial_ordering() const noexcept { + return __value_ == 0 ? partial_ordering::equivalent + : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater); + } + + // comparisons + friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator<(weak_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator>(weak_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept; + friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept; + friend constexpr bool operator<(_CmpUnspecifiedParam, weak_ordering __v) noexcept; + friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept; + friend constexpr bool operator>(_CmpUnspecifiedParam, weak_ordering __v) noexcept; + friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept; + + friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept; + + // test helper + constexpr bool test_eq(weak_ordering const &other) const noexcept { + return __value_ == other.__value_; + } + +private: + _ValueT __value_; +}; + +inline constexpr weak_ordering weak_ordering::less(_OrdResult::__less); +inline constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv); +inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater); +constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ == 0; +} +constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ != 0; +} +constexpr bool operator<(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ < 0; +} +constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ <= 0; +} +constexpr bool operator>(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ > 0; +} +constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ >= 0; +} +constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 == __v.__value_; +} +constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 != __v.__value_; +} +constexpr bool operator<(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 < __v.__value_; +} +constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 <= __v.__value_; +} +constexpr bool operator>(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 > __v.__value_; +} +constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 >= __v.__value_; +} + +constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v; +} +constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v); +} + +class strong_ordering { + using _ValueT = signed char; + explicit constexpr strong_ordering(_EqResult __v) noexcept : __value_(static_cast<signed char>(__v)) {} + explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(static_cast<signed char>(__v)) {} + +public: + static const strong_ordering less; + static const strong_ordering equal; + static const strong_ordering equivalent; + static const strong_ordering greater; + + // conversions + constexpr operator weak_equality() const noexcept { + return __value_ == 0 ? weak_equality::equivalent + : weak_equality::nonequivalent; + } + constexpr operator strong_equality() const noexcept { + return __value_ == 0 ? strong_equality::equal + : strong_equality::nonequal; + } + constexpr operator partial_ordering() const noexcept { + return __value_ == 0 ? partial_ordering::equivalent + : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater); + } + constexpr operator weak_ordering() const noexcept { + return __value_ == 0 ? weak_ordering::equivalent + : (__value_ < 0 ? weak_ordering::less : weak_ordering::greater); + } + + // comparisons + friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator<(strong_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator>(strong_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept; + friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept; + friend constexpr bool operator<(_CmpUnspecifiedParam, strong_ordering __v) noexcept; + friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept; + friend constexpr bool operator>(_CmpUnspecifiedParam, strong_ordering __v) noexcept; + friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept; + + friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept; + friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept; + + // test helper + constexpr bool test_eq(strong_ordering const &other) const noexcept { + return __value_ == other.__value_; + } + +private: + _ValueT __value_; +}; + +inline constexpr strong_ordering strong_ordering::less(_OrdResult::__less); +inline constexpr strong_ordering strong_ordering::equal(_EqResult::__equal); +inline constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv); +inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater); + +constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ == 0; +} +constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ != 0; +} +constexpr bool operator<(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ < 0; +} +constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ <= 0; +} +constexpr bool operator>(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ > 0; +} +constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ >= 0; +} +constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 == __v.__value_; +} +constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 != __v.__value_; +} +constexpr bool operator<(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 < __v.__value_; +} +constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 <= __v.__value_; +} +constexpr bool operator>(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 > __v.__value_; +} +constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 >= __v.__value_; +} + +constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v; +} +constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v); +} + +// named comparison functions +constexpr bool is_eq(weak_equality __cmp) noexcept { return __cmp == 0; } +constexpr bool is_neq(weak_equality __cmp) noexcept { return __cmp != 0; } +constexpr bool is_lt(partial_ordering __cmp) noexcept { return __cmp < 0; } +constexpr bool is_lteq(partial_ordering __cmp) noexcept { return __cmp <= 0; } +constexpr bool is_gt(partial_ordering __cmp) noexcept { return __cmp > 0; } +constexpr bool is_gteq(partial_ordering __cmp) noexcept { return __cmp >= 0; } + +} // namespace __1 +} // end namespace std + +#endif // STD_COMPARE_H diff --git a/test/PCH/chain-openmp-threadprivate.cpp b/test/PCH/chain-openmp-threadprivate.cpp index c7f0f41959670..d719d4d2949c8 100644 --- a/test/PCH/chain-openmp-threadprivate.cpp +++ b/test/PCH/chain-openmp-threadprivate.cpp @@ -23,7 +23,7 @@ int *a = malloc(20); #else // CHECK: call {{.*}} @__kmpc_threadprivate_register( -// CHECK-TLS-1: @{{a|\"\\01\?a@@3PE?AHE?A\"}} = {{.*}}thread_local {{.*}}global {{.*}}i32* +// CHECK-TLS-1: @{{a|\"\?a@@3PE?AHE?A\"}} = {{.*}}thread_local {{.*}}global {{.*}}i32* // CHECK-LABEL: foo // CHECK-TLS-LABEL: foo @@ -31,9 +31,9 @@ int foo() { return *a; // CHECK: call {{.*}} @__kmpc_global_thread_num( // CHECK: call {{.*}} @__kmpc_threadprivate_cached( - // CHECK-TLS-1: call {{.*}} @{{_ZTW1a|\"\\01\?\?__Ea@@YAXXZ\"}}() + // CHECK-TLS-1: call {{.*}} @{{_ZTW1a|\"\?\?__Ea@@YAXXZ\"}}() } -// CHECK-TLS-2: define {{.*}} @{{_ZTW1a|\"\\01\?\?__Ea@@YAXXZ\"}}() +// CHECK-TLS-2: define {{.*}} @{{_ZTW1a|\"\?\?__Ea@@YAXXZ\"}}() #endif diff --git a/test/PCH/cxx-required-decls.cpp b/test/PCH/cxx-required-decls.cpp index c2f8e2fd68fe7..132af6c952004 100644 --- a/test/PCH/cxx-required-decls.cpp +++ b/test/PCH/cxx-required-decls.cpp @@ -7,4 +7,4 @@ // CHECK: @_ZL5globS = internal global %struct.S zeroinitializer // CHECK: @_ZL3bar = internal global i32 0, align 4 -// CHECK: @glob_var = global i32 0 +// CHECK: @glob_var = {{(dso_local )?}}global i32 0 diff --git a/test/PCH/cxx2a-compare.cpp b/test/PCH/cxx2a-compare.cpp new file mode 100644 index 0000000000000..9ad368d88fd9f --- /dev/null +++ b/test/PCH/cxx2a-compare.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -pedantic-errors -std=c++2a -emit-pch %s -o %t +// RUN: %clang_cc1 -pedantic-errors -std=c++2a -include-pch %t -verify %s +// RUN: %clang_cc1 -pedantic-errors -std=c++2a -include-pch %t -emit-llvm %s -o - + + +#ifndef HEADER +#define HEADER + +#include "Inputs/std-compare.h" +constexpr auto foo() { + return (42 <=> 101); +} + +inline auto bar(int x) { + return (1 <=> x); +} + +#else + +// expected-no-diagnostics + +static_assert(foo() < 0); + +auto bar2(int x) { + return bar(x); +} + +#endif diff --git a/test/PCH/cxx_exprs.cpp b/test/PCH/cxx_exprs.cpp index 0fb7590c68b57..928a21125db0b 100644 --- a/test/PCH/cxx_exprs.cpp +++ b/test/PCH/cxx_exprs.cpp @@ -1,9 +1,9 @@ // Test this without pch. -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx_exprs.h -std=c++11 -fsyntax-only -verify %s -ast-dump +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx_exprs.h -std=c++11 -fsyntax-only -verify %s -ast-dump | FileCheck %s // Test with pch. Use '-ast-dump' to force deserialization of function bodies. // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -std=c++11 -emit-pch -o %t %S/cxx_exprs.h -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-dump +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-dump-all | FileCheck %s // expected-no-diagnostics @@ -14,19 +14,49 @@ bool boolean; // CXXStaticCastExpr static_cast_result void_ptr = &integer; +// CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}}{{(imported)?}} referenced static_cast_result 'typeof (static_cast<void *>(0))':'void *'{{$}} +// CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (static_cast<void *>(0))' sugar{{( imported)?}}{{$}} +// CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'void *'{{$}} +// CHECK-NEXT: CXXStaticCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'void *' static_cast<void *> <NoOp>{{$}} +// CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'void *' <NullToPointer> part_of_explicit_cast{{$}} +// CHECK-NEXT: IntegerLiteral {{.*}} <col:{{.*}}> 'int' 0{{$}} // CXXDynamicCastExpr Derived *d; dynamic_cast_result derived_ptr = d; +// CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}} referenced dynamic_cast_result 'typeof (dynamic_cast<Derived *>(base_ptr))':'Derived *'{{$}} +// CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (dynamic_cast<Derived *>(base_ptr))' sugar{{( imported)?}}{{$}} +// CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'Derived *'{{$}} +// CHECK-NEXT: CXXDynamicCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'Derived *' dynamic_cast<struct Derived *> <Dynamic>{{$}} +// CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'Base *' <LValueToRValue> part_of_explicit_cast{{$}} +// CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'Base *' lvalue Var {{.*}} 'base_ptr' 'Base *'{{$}} // CXXReinterpretCastExpr reinterpret_cast_result void_ptr2 = &integer; +// CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}} referenced reinterpret_cast_result 'typeof (reinterpret_cast<void *>(0))':'void *'{{$}} +// CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (reinterpret_cast<void *>(0))' sugar{{( imported)?}}{{$}} +// CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'void *'{{$}} +// CHECK-NEXT: CXXReinterpretCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'void *' reinterpret_cast<void *> <IntegralToPointer>{{$}} +// CHECK-NEXT: IntegerLiteral {{.*}} <col:{{.*}}> 'int' 0{{$}} // CXXConstCastExpr const_cast_result char_ptr = &character; +// CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}} referenced const_cast_result 'typeof (const_cast<char *>(const_char_ptr_value))':'char *'{{$}} +// CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (const_cast<char *>(const_char_ptr_value))' sugar{{( imported)?}}{{$}} +// CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'char *'{{$}} +// CHECK-NEXT: CXXConstCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'char *' const_cast<char *> <NoOp>{{$}} +// CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'const char *' <LValueToRValue> part_of_explicit_cast{{$}} +// CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'const char *' lvalue Var {{.*}} 'const_char_ptr_value' 'const char *'{{$}} // CXXFunctionalCastExpr functional_cast_result *double_ptr = &floating; +// CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}} referenced functional_cast_result 'typeof (double(int_value))':'double'{{$}} +// CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (double(int_value))' sugar{{( imported)?}}{{$}} +// CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'double'{{$}} +// CHECK-NEXT: CXXFunctionalCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'double' functional cast to double <NoOp>{{$}} +// CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'double' <IntegralToFloating> part_of_explicit_cast{{$}} +// CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'int' <LValueToRValue> part_of_explicit_cast{{$}} +// CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'int' lvalue Var {{.*}} 'int_value' 'int'{{$}} // CXXBoolLiteralExpr bool_literal_result *bool_ptr = &boolean; diff --git a/test/PCH/dllexport-default-arg-closure.cpp b/test/PCH/dllexport-default-arg-closure.cpp index 892f1eb9bff8f..32e0a721c7752 100644 --- a/test/PCH/dllexport-default-arg-closure.cpp +++ b/test/PCH/dllexport-default-arg-closure.cpp @@ -17,8 +17,8 @@ struct __declspec(dllexport) Foo { // Demangles as: // void Foo::`default constructor closure'(void) -// CHECK: define weak_odr dllexport void @"\01??_FFoo@@QEAAXXZ"(%struct.Foo*{{.*}}) -// CHECK: call %struct.Foo* @"\01??0Foo@@QEAA@W4E@0@@Z"(%struct.Foo* {{.*}}, i32 0) +// CHECK: define weak_odr dso_local dllexport void @"??_FFoo@@QEAAXXZ"(%struct.Foo*{{.*}}) +// CHECK: call %struct.Foo* @"??0Foo@@QEAA@W4E@0@@Z"(%struct.Foo* {{.*}}, i32 0) #else diff --git a/test/PCH/include-stream-type.cpp b/test/PCH/include-stream-type.cpp new file mode 100644 index 0000000000000..30e2586b0bf07 --- /dev/null +++ b/test/PCH/include-stream-type.cpp @@ -0,0 +1,10 @@ +// Test that llvm-bcanalyzer recognizes the stream type of a PCH file. + +// RUN: mkdir -p %t-dir +// Copying files allow for read-only checkouts to run this test. +// RUN: cp %S/Inputs/pragma-once2-pch.h %t-dir +// RUN: cp %S/Inputs/pragma-once2.h %t-dir +// RUN: %clang_cc1 -x c++-header -emit-pch -fmodule-format=raw -o %t %t-dir/pragma-once2-pch.h +// RUN: llvm-bcanalyzer -dump %t | FileCheck %s +// +// CHECK: Stream type: Clang Serialized AST diff --git a/test/PCH/late-parsed-instantiations.cpp b/test/PCH/late-parsed-instantiations.cpp new file mode 100644 index 0000000000000..f1fe8bb06a516 --- /dev/null +++ b/test/PCH/late-parsed-instantiations.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fdelayed-template-parsing -std=c++14 -emit-pch %s -o %t.pch -verify +// RUN: %clang_cc1 -fdelayed-template-parsing -std=c++14 -include-pch %t.pch %s -verify + +#ifndef HEADER_INCLUDED + +#define HEADER_INCLUDED + +// pr33561 +class ArrayBuffer; +template <typename T> class Trans_NS_WTF_RefPtr { +public: + ArrayBuffer *operator->() { return nullptr; } +}; +Trans_NS_WTF_RefPtr<ArrayBuffer> get(); +template <typename _Visitor> +constexpr void visit(_Visitor __visitor) { + __visitor(get()); // expected-note {{in instantiation}} +} +class ArrayBuffer { + char data() { + visit([](auto buffer) -> char { // expected-note {{in instantiation}} + buffer->data(); + }); // expected-warning {{control reaches end of non-void lambda}} + } // expected-warning {{control reaches end of non-void function}} +}; + +#else + +// expected-no-diagnostics + +#endif diff --git a/test/PCH/modified-header-crash.c b/test/PCH/modified-header-crash.c index 4c21a8c2b8259..39b2530a32f28 100644 --- a/test/PCH/modified-header-crash.c +++ b/test/PCH/modified-header-crash.c @@ -1,6 +1,6 @@ // Don't crash. -// RUN: cp %S/modified-header-crash.h %t.h +// RUN: cat %S/modified-header-crash.h > %t.h // RUN: %clang_cc1 -DCAKE -x c-header %t.h -emit-pch -o %t // RUN: echo 'int foobar;' >> %t.h // RUN: not %clang_cc1 %s -include-pch %t -fsyntax-only diff --git a/test/PCH/objc_stmts.m b/test/PCH/objc_stmts.m index 8deb14a815451..ee7b780731a97 100644 --- a/test/PCH/objc_stmts.m +++ b/test/PCH/objc_stmts.m @@ -1,11 +1,11 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/objc_stmts.h -emit-llvm -fobjc-exceptions -o - %s -// RUN: %clang_cc1 -include %S/objc_stmts.h -ast-print -fobjc-exceptions -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -include %S/objc_stmts.h -emit-llvm -fobjc-exceptions -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -include %S/objc_stmts.h -ast-print -fobjc-exceptions -o - %s | FileCheck %s // Test with pch. -// RUN: %clang_cc1 -x objective-c -emit-pch -fobjc-exceptions -o %t %S/objc_stmts.h -// RUN: %clang_cc1 -include-pch %t -emit-llvm -fobjc-exceptions -o - %s -// RUN: %clang_cc1 -include-pch %t -ast-print -fobjc-exceptions -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -x objective-c -emit-pch -fobjc-exceptions -o %t %S/objc_stmts.h +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -include-pch %t -emit-llvm -fobjc-exceptions -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -include-pch %t -ast-print -fobjc-exceptions -o - %s | FileCheck %s // CHECK: @catch(A *a) // CHECK: @catch(B *b) diff --git a/test/PCH/pch-through1.cpp b/test/PCH/pch-through1.cpp new file mode 100644 index 0000000000000..b7e7fa82a19a8 --- /dev/null +++ b/test/PCH/pch-through1.cpp @@ -0,0 +1,34 @@ +// Through header not found (anywhere) +// RUN: not %clang_cc1 -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-does-not-exist.h -o %t %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST0A %s +// CHECK-TEST0A: fatal error:{{.*}} 'Inputs/pch-does-not-exist.h' +// CHECK-TEST0A-SAME: required for precompiled header not found + +// Through header not found in search path +// RUN: not %clang_cc1 -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through2.h -o %t \ +// RUN: %S/Inputs/pch-through-use0.cpp 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST0B %s +// CHECK-TEST0B: fatal error:{{.*}}'Inputs/pch-through2.h' +// CHECK-TEST0B-SAME: required for precompiled header not found + +// No #include of through header during pch create +// RUN: not %clang_cc1 -I %S -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through2.h -o %t %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST1A %s +// CHECK-TEST1A: fatal error:{{.*}} #include of +// CHECK-TEST1A-SAME: 'Inputs/pch-through2.h' not seen while attempting to +// CHECK-TEST1A-SAME: create precompiled header + +// checks for through headers that are also -includes +// RUN: %clang_cc1 -I %S -include Inputs/pch-through1.h \ +// RUN: -pch-through-header=Inputs/pch-through1.h -emit-pch -o %t.s3t1 %s +// RUN: %clang_cc1 -I %S -include Inputs/pch-through1.h \ +// RUN: -include Inputs/pch-through2.h -include Inputs/pch-through3.h \ +// RUN: -pch-through-header=Inputs/pch-through2.h -emit-pch -o %t.s3t2 %s +// Use through header from -includes +// RUN: %clang_cc1 -I %S -include Inputs/pch-through1.h \ +// RUN: -include Inputs/pch-through2.h -include Inputs/pch-through4.h \ +// RUN: -pch-through-header=Inputs/pch-through2.h -include-pch %t.s3t2 \ +// RUN: %S/Inputs/pch-through-use2.cpp -o %t.out diff --git a/test/PCH/pch-through2.cpp b/test/PCH/pch-through2.cpp new file mode 100644 index 0000000000000..6bf7a29d9a08e --- /dev/null +++ b/test/PCH/pch-through2.cpp @@ -0,0 +1,28 @@ +// Create +// RUN: %clang_cc1 -I %S -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through2.h -o %t.1 %s + +// Use +// RUN: %clang_cc1 -I %S -include-pch %t.1 \ +// RUN: -pch-through-header=Inputs/pch-through2.h %s + +// No #include of through header during pch use +// RUN: not %clang_cc1 -I %S -include-pch %t.1 \ +// RUN: -pch-through-header=Inputs/pch-through2.h \ +// RUN: %S/Inputs/pch-through-use1.cpp 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST2A %s +// CHECK-TEST2A: fatal error:{{.*}} #include of +// CHECK-TEST2A-SAME: 'Inputs/pch-through2.h' not seen while attempting to +// CHECK-TEST2A-SAME: use precompiled header + +// check that pch only contains code before the through header. +// RUN: %clang_cc1 -I %S -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through1.h -o %t.2 %s +// RUN: not %clang_cc1 -I %S -include-pch %t.2 \ +// RUN: -pch-through-header=Inputs/pch-through1.h \ +// RUN: %S/Inputs/pch-through-use1.cpp 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST3 %s +// CHECK-TEST3: error: use of undeclared identifier 'through2' + +#include "Inputs/pch-through1.h" +#include "Inputs/pch-through2.h" diff --git a/test/PCH/pch-through3a.cpp b/test/PCH/pch-through3a.cpp new file mode 100644 index 0000000000000..3a134e9310bc4 --- /dev/null +++ b/test/PCH/pch-through3a.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -verify -I %S -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through1.h -o %t.s3at1 %s + +// RUN: %clang_cc1 -I %S -include-pch %t.s3at1 \ +// RUN: -pch-through-header=Inputs/pch-through1.h \ +// RUN: %S/Inputs/pch-through-use3a.cpp +//expected-no-diagnostics + +#define AFOO 0 +#include "Inputs/pch-through1.h" diff --git a/test/PCH/pch-through3b.cpp b/test/PCH/pch-through3b.cpp new file mode 100644 index 0000000000000..2a7695a7098a7 --- /dev/null +++ b/test/PCH/pch-through3b.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -I %S -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through1.h -o %t.s3bt1 %s + +// RUN: %clang_cc1 -I %S -include-pch %t.s3bt1 \ +// RUN: -pch-through-header=Inputs/pch-through1.h \ +// RUN: %S/Inputs/pch-through-use3b.cpp 2>&1 | FileCheck %s + +//CHECK: warning: definition of macro 'AFOO' does not match definition in +//CHECK-SAME: precompiled header +//CHECK: warning: definition of macro 'BFOO' does not match definition in +//CHECK-SAME: precompiled header + +#define AFOO 0 +#include "Inputs/pch-through1.h" diff --git a/test/PCH/pragma-loop.cpp b/test/PCH/pragma-loop.cpp index 5975816f69a61..7f443ddb034e7 100644 --- a/test/PCH/pragma-loop.cpp +++ b/test/PCH/pragma-loop.cpp @@ -4,7 +4,7 @@ // FIXME: A bug in ParsedAttributes causes the order of the attributes to be // reversed. The checks are consequently in the reverse order below. -// CHECK: #pragma clang loop unroll_count(16) +// CHECK: #pragma clang loop unroll_count(16){{$}} // CHECK: #pragma clang loop interleave_count(8) // CHECK: #pragma clang loop vectorize_width(4) // CHECK: #pragma clang loop distribute(enable) @@ -15,9 +15,10 @@ // CHECK: #pragma clang loop unroll(full) // CHECK: #pragma clang loop interleave(enable) // CHECK: #pragma clang loop vectorize(disable) -// CHECK: #pragma unroll -// CHECK: #pragma unroll (32) -// CHECK: #pragma nounroll +// FIXME: "#pragma unroll (enable)" is invalid and is not the input source. +// CHECK: #pragma unroll (enable){{$}} +// CHECK: #pragma unroll (32){{$}} +// CHECK: #pragma nounroll{{$}} // CHECK: #pragma clang loop interleave_count(I) // CHECK: #pragma clang loop vectorize_width(V) diff --git a/test/PCH/pragma-weak.c b/test/PCH/pragma-weak.c index 1a8724c35cd75..4a4819764025e 100644 --- a/test/PCH/pragma-weak.c +++ b/test/PCH/pragma-weak.c @@ -5,6 +5,6 @@ // RUN: %clang_cc1 -x c-header -emit-pch -o %t %S/pragma-weak.h // RUN: not %clang_cc1 -include-pch %t %s -verify -emit-llvm -o - | FileCheck %s -// CHECK: @weakvar = weak global i32 0 +// CHECK: @weakvar = weak {{(dso_local )?}}global i32 0 int weakvar; // expected-warning {{weak identifier 'undeclaredvar' never declared}} diff --git a/test/PCH/uses-seh.cpp b/test/PCH/uses-seh.cpp index 6fbfc9766c488..53ca1ef154ffd 100644 --- a/test/PCH/uses-seh.cpp +++ b/test/PCH/uses-seh.cpp @@ -19,8 +19,8 @@ inline int f() { } int x = f(); -// CHECK: define linkonce_odr i32 @"\01?f@@YAHXZ"() -// CHECK: define internal i32 @"\01?filt$0@0@f@@"({{.*}}) +// CHECK: define linkonce_odr dso_local i32 @"?f@@YAHXZ"() +// CHECK: define internal i32 @"?filt$0@0@f@@"({{.*}}) #else diff --git a/test/PCH/verify_pch.m b/test/PCH/verify_pch.m index e905f2537c7f5..d50e23456e35c 100644 --- a/test/PCH/verify_pch.m +++ b/test/PCH/verify_pch.m @@ -2,7 +2,7 @@ // RUN: rm -rf %t // RUN: mkdir -p %t/usr/include // RUN: echo '// empty' > %t/usr/include/sys_header.h -// RUN: cp %s %t.h +// RUN: cat %s > %t.h // // Precompile // RUN: %clang_cc1 -isystem %t/usr/include -x objective-c-header -emit-pch -o %t.pch %t.h |