[clang] [libclang] Document CXUnsavedFile::Length width and fix test narrowing (PR #228405)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 16 06:06:21 PDT 2026
================
@@ -82,9 +82,11 @@ class LibclangParseTest : public ::testing::Test {
fixed_addr_string(new std::string(Filename)),
fixed_addr_string(new std::string(Contents))));
UnsavedFiles.push_back({
- it.first->first->c_str(), // filename
- it.first->second->c_str(), // contents
- it.first->second->size() // length
+ it.first->first->c_str(), // filename
+ it.first->second->c_str(), // contents
+ // CXUnsavedFile::Length is `unsigned long`, which is 32 bits on
+ // 64-bit Windows, so converting from size_t here narrows.
+ static_cast<unsigned long>(it.first->second->size()) // length
----------------
AaronBallman wrote:
I was trying to figure out how we got into this state, but the PR summary answers it:
> the Bazel libclang_tests target builds them there and fails to compile under --config=msvc. Cast explicitly.
Shouldn't Bazel also be excluding building these tests the same as CMake (if the reason we disabled in cmake is because of failing tests, those will still fail with Bazel; if the tests are not failing, then perhaps we should update CMake)? CC @boomanaiden154
Regardless, I think this change is defensible on its own merit.
https://github.com/llvm/llvm-project/pull/228405
More information about the cfe-commits
mailing list