llvm-project
6ba68122 - [Support][NFC] Fix MSVC C4267 warning in SourceMgr.h (#233299)

Commit
6 days ago
[Support][NFC] Fix MSVC C4267 warning in SourceMgr.h (#233299) `SourceMgr::getNumBuffers()` and `SourceMgr::AddNewSourceBuffer()` return `unsigned` but implicitly narrow `std::vector::size()` (`size_t`). When compiled with 64-bit MSVC at the default `/W3` level, code using these functions gets: - `warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data` LLVM's own MSVC build disables C4267 (`-wd4267` in `HandleLLVMOptions.cmake`), so this does not show up in-tree, but it does in projects that include LLVM headers without that suppression. Add explicit `static_cast`s. Verified with MSVC 19.36 (VS 2022 17.6), x64, `/W3`: the warning appears before this change and is gone after it. No functional change; existing SourceMgrTest coverage exercises both functions. SourceMgrTest passed 42/42, and the whole SupportTests suite passed. Assisted-by: Claude Code
Parents
Loading