[clang] [clang][test] Use sizeof(wchar_t) instead of __WCHAR_WIDTH__ (PR #218707)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 25 08:16:55 PDT 2026
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/218707
>From 02a1a07584a7ba98ec6d75a79f2a02d77062322e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Tue, 25 Aug 2026 17:13:41 +0200
Subject: [PATCH] [clang][test] Use sizeof(wchar_t) instead of __WCHAR_WIDTH__
---
clang/unittests/AST/ByteCode/Pointer.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/clang/unittests/AST/ByteCode/Pointer.cpp b/clang/unittests/AST/ByteCode/Pointer.cpp
index a42388d434c0c..7541a588f526a 100644
--- a/clang/unittests/AST/ByteCode/Pointer.cpp
+++ b/clang/unittests/AST/ByteCode/Pointer.cpp
@@ -315,7 +315,7 @@ TEST(Pointer, Strings) {
Pointee = GlobalPtr.load<Pointer>();
ASSERT_TRUE(Pointee.isStringPointer());
ASSERT_EQ(Pointee.getNumElems(), 7u);
- ASSERT_EQ(Pointee.elemSize(), __WCHAR_WIDTH__ / 8u);
+ ASSERT_EQ(Pointee.elemSize(), sizeof(wchar_t));
D = match(varDecl(hasGlobalStorage(), hasName("c")).bind("c"), ASTCtx)[0]
.getNodeAs<VarDecl>("c");
@@ -327,12 +327,13 @@ TEST(Pointer, Strings) {
Pointee = GlobalPtr.load<Pointer>();
ASSERT_TRUE(Pointee.isStringPointer());
ASSERT_EQ(Pointee.getNumElems(), 7u);
- ASSERT_EQ(Pointee.elemSize(), __WCHAR_WIDTH__ / 8u);
+ ASSERT_EQ(Pointee.elemSize(), sizeof(wchar_t));
ASSERT_EQ(Pointee.getIndex(), 5u);
APValue APV = Pointee.toAPValue(ASTCtx);
ASSERT_TRUE(APV.isLValue());
ASSERT_FALSE(APV.isLValueOnePastTheEnd());
- ASSERT_EQ(APV.getLValueOffset().getQuantity(), 5u * (__WCHAR_WIDTH__ / 8u));
+ ASSERT_EQ(static_cast<size_t>(APV.getLValueOffset().getQuantity()),
+ 5 * sizeof(wchar_t));
ASSERT_TRUE(APV.hasLValuePath());
const auto &Path = APV.getLValuePath();
ASSERT_EQ(Path.size(), 1u);
More information about the cfe-commits
mailing list