Skip to content

Commit 1e2ad67

Browse files
committed
Revert "[clang][bytecode] Implement __builtin_{wcscmp,wcsncmp} (#132723)"
This reverts commit f7aea4d. This broke the clang-solaris11-sparcv9 builder: https://lab.llvm.org/buildbot/#/builders/13/builds/6151
1 parent fac8fe9 commit 1e2ad67

File tree

2 files changed

+2
-72
lines changed

2 files changed

+2
-72
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,11 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC,
212212
const Pointer &A = getParam<Pointer>(Frame, 0);
213213
const Pointer &B = getParam<Pointer>(Frame, 1);
214214

215-
if (ID == Builtin::BIstrcmp || ID == Builtin::BIstrncmp ||
216-
ID == Builtin::BIwcscmp || ID == Builtin::BIwcsncmp)
215+
if (ID == Builtin::BIstrcmp || ID == Builtin::BIstrncmp)
217216
diagnoseNonConstexprBuiltin(S, OpPC, ID);
218217

219218
uint64_t Limit = ~static_cast<uint64_t>(0);
220-
if (ID == Builtin::BIstrncmp || ID == Builtin::BI__builtin_strncmp ||
221-
ID == Builtin::BIwcsncmp || ID == Builtin::BI__builtin_wcsncmp)
219+
if (ID == Builtin::BIstrncmp || ID == Builtin::BI__builtin_strncmp)
222220
Limit = peekToAPSInt(S.Stk, *S.getContext().classify(Call->getArg(2)))
223221
.getZExtValue();
224222

@@ -233,9 +231,6 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC,
233231
if (A.isDummy() || B.isDummy())
234232
return false;
235233

236-
bool IsWide = ID == Builtin::BIwcscmp || ID == Builtin::BIwcsncmp ||
237-
ID == Builtin::BI__builtin_wcscmp ||
238-
ID == Builtin::BI__builtin_wcsncmp;
239234
assert(A.getFieldDesc()->isPrimitiveArray());
240235
assert(B.getFieldDesc()->isPrimitiveArray());
241236

@@ -253,21 +248,6 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC,
253248
!CheckRange(S, OpPC, PB, AK_Read)) {
254249
return false;
255250
}
256-
257-
if (IsWide)
258-
INT_TYPE_SWITCH(
259-
*S.getContext().classify(S.getASTContext().getWCharType()), {
260-
T A = PA.deref<T>();
261-
T B = PB.deref<T>();
262-
if (A < B) {
263-
pushInteger(S, -1, Call->getType());
264-
return true;
265-
} else if (A > B) {
266-
pushInteger(S, 1, Call->getType());
267-
return true;
268-
}
269-
});
270-
271251
uint8_t CA = PA.deref<uint8_t>();
272252
uint8_t CB = PB.deref<uint8_t>();
273253

@@ -2140,10 +2120,6 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
21402120
case Builtin::BIstrcmp:
21412121
case Builtin::BI__builtin_strncmp:
21422122
case Builtin::BIstrncmp:
2143-
case Builtin::BI__builtin_wcsncmp:
2144-
case Builtin::BIwcsncmp:
2145-
case Builtin::BI__builtin_wcscmp:
2146-
case Builtin::BIwcscmp:
21472123
if (!interp__builtin_strcmp(S, OpPC, Frame, F, Call))
21482124
return false;
21492125
break;

clang/test/AST/ByteCode/builtin-functions.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ extern "C" {
2828
extern char *strchr(const char *s, int c);
2929
extern wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
3030
extern wchar_t *wcschr(const wchar_t *s, wchar_t c);
31-
extern int wcscmp(const wchar_t *s1, const wchar_t *s2);
32-
extern int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
3331
}
3432

3533
namespace strcmp {
@@ -74,50 +72,6 @@ namespace strcmp {
7472
static_assert(__builtin_strncmp("abab\0banana", "abab\0canada", 100) == 0);
7573
}
7674

77-
namespace WcsCmp {
78-
constexpr wchar_t kFoobar[6] = {L'f',L'o',L'o',L'b',L'a',L'r'};
79-
constexpr wchar_t kFoobazfoobar[12] = {L'f',L'o',L'o',L'b',L'a',L'z',L'f',L'o',L'o',L'b',L'a',L'r'};
80-
81-
static_assert(__builtin_wcscmp(L"abab", L"abab") == 0);
82-
static_assert(__builtin_wcscmp(L"abab", L"abba") == -1);
83-
static_assert(__builtin_wcscmp(L"abab", L"abaa") == 1);
84-
static_assert(__builtin_wcscmp(L"ababa", L"abab") == 1);
85-
static_assert(__builtin_wcscmp(L"abab", L"ababa") == -1);
86-
static_assert(__builtin_wcscmp(L"abab\0banana", L"abab") == 0);
87-
static_assert(__builtin_wcscmp(L"abab", L"abab\0banana") == 0);
88-
static_assert(__builtin_wcscmp(L"abab\0banana", L"abab\0canada") == 0);
89-
#if __WCHAR_WIDTH__ == 32
90-
static_assert(__builtin_wcscmp(L"a\x83838383", L"a") == (wchar_t)-1U >> 31);
91-
#endif
92-
static_assert(__builtin_wcscmp(0, L"abab") == 0); // both-error {{not an integral constant}} \
93-
// both-note {{dereferenced null}}
94-
static_assert(__builtin_wcscmp(L"abab", 0) == 0); // both-error {{not an integral constant}} \
95-
// both-note {{dereferenced null}}
96-
97-
static_assert(__builtin_wcscmp(kFoobar, kFoobazfoobar) == -1);
98-
static_assert(__builtin_wcscmp(kFoobar, kFoobazfoobar + 6) == 0); // both-error {{not an integral constant}} \
99-
// both-note {{dereferenced one-past-the-end}}
100-
101-
static_assert(__builtin_wcsncmp(L"abaa", L"abba", 5) == -1);
102-
static_assert(__builtin_wcsncmp(L"abaa", L"abba", 4) == -1);
103-
static_assert(__builtin_wcsncmp(L"abaa", L"abba", 3) == -1);
104-
static_assert(__builtin_wcsncmp(L"abaa", L"abba", 2) == 0);
105-
static_assert(__builtin_wcsncmp(L"abaa", L"abba", 1) == 0);
106-
static_assert(__builtin_wcsncmp(L"abaa", L"abba", 0) == 0);
107-
static_assert(__builtin_wcsncmp(0, 0, 0) == 0);
108-
static_assert(__builtin_wcsncmp(L"abab\0banana", L"abab\0canada", 100) == 0);
109-
#if __WCHAR_WIDTH__ == 32
110-
static_assert(__builtin_wcsncmp(L"a\x83838383", L"aa", 2) ==
111-
(wchar_t)-1U >> 31);
112-
#endif
113-
114-
static_assert(__builtin_wcsncmp(kFoobar, kFoobazfoobar, 6) == -1);
115-
static_assert(__builtin_wcsncmp(kFoobar, kFoobazfoobar, 7) == -1);
116-
static_assert(__builtin_wcsncmp(kFoobar, kFoobazfoobar + 6, 6) == 0);
117-
static_assert(__builtin_wcsncmp(kFoobar, kFoobazfoobar + 6, 7) == 0); // both-error {{not an integral constant}} \
118-
// both-note {{dereferenced one-past-the-end}}
119-
}
120-
12175
/// Copied from constant-expression-cxx11.cpp
12276
namespace strlen {
12377
constexpr const char *a = "foo\0quux";

0 commit comments

Comments
 (0)