Author: Timm Baeder Date: 2026-08-26T08:25:00+02:00 New Revision: fc7697c45feeb5eba0f676ea8c252e59de922f06
URL: https://github.com/llvm/llvm-project/commit/fc7697c45feeb5eba0f676ea8c252e59de922f06 DIFF: https://github.com/llvm/llvm-project/commit/fc7697c45feeb5eba0f676ea8c252e59de922f06.diff LOG: [clang][bytecode][test] Test elem size against target wchar (#218837) I *think* this is the problem here. I thought since I'm not specifying a target triple, the host triple would always be used. I've locally checked that elemSize() returns the correct value when changing the target triple and that works. The previous approach caused problems on some builders, see https://github.com/llvm/llvm-project/pull/218707#issuecomment-5417327986 https://github.com/llvm/llvm-project/pull/216736#issuecomment-5419450306 Added: Modified: clang/unittests/AST/ByteCode/Pointer.cpp Removed: ################################################################################ diff --git a/clang/unittests/AST/ByteCode/Pointer.cpp b/clang/unittests/AST/ByteCode/Pointer.cpp index 7541a588f526a..a93222ad05c12 100644 --- a/clang/unittests/AST/ByteCode/Pointer.cpp +++ b/clang/unittests/AST/ByteCode/Pointer.cpp @@ -287,6 +287,10 @@ TEST(Pointer, Strings) { .getNodeAs<VarDecl>("str1"); ASSERT_NE(D, nullptr); + auto getWCharWidth = [&ASTCtx]() -> unsigned { + return ASTCtx.getTargetInfo().getWCharWidth() / 8; + }; + const auto &Ctx = AST->getASTContext().getInterpContext(); Program &Prog = Ctx.getProgram(); ASSERT_TRUE(Prog.getGlobal(D)); @@ -315,7 +319,7 @@ TEST(Pointer, Strings) { Pointee = GlobalPtr.load<Pointer>(); ASSERT_TRUE(Pointee.isStringPointer()); ASSERT_EQ(Pointee.getNumElems(), 7u); - ASSERT_EQ(Pointee.elemSize(), sizeof(wchar_t)); + ASSERT_EQ(Pointee.elemSize(), getWCharWidth()); D = match(varDecl(hasGlobalStorage(), hasName("c")).bind("c"), ASTCtx)[0] .getNodeAs<VarDecl>("c"); @@ -327,13 +331,12 @@ TEST(Pointer, Strings) { Pointee = GlobalPtr.load<Pointer>(); ASSERT_TRUE(Pointee.isStringPointer()); ASSERT_EQ(Pointee.getNumElems(), 7u); - ASSERT_EQ(Pointee.elemSize(), sizeof(wchar_t)); + ASSERT_EQ(Pointee.elemSize(), getWCharWidth()); ASSERT_EQ(Pointee.getIndex(), 5u); APValue APV = Pointee.toAPValue(ASTCtx); ASSERT_TRUE(APV.isLValue()); ASSERT_FALSE(APV.isLValueOnePastTheEnd()); - ASSERT_EQ(static_cast<size_t>(APV.getLValueOffset().getQuantity()), - 5 * sizeof(wchar_t)); + ASSERT_EQ(APV.getLValueOffset().getQuantity(), 5u * getWCharWidth()); ASSERT_TRUE(APV.hasLValuePath()); const auto &Path = APV.getLValuePath(); ASSERT_EQ(Path.size(), 1u); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
