[llvm] [llvm-readobj][COFF] Dump .modmeta section (PR #201695)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 02:33:15 PDT 2026
================
@@ -22,99 +21,95 @@ bool COFFCxxModuleMetadataReader::hasModuleData() const {
}
Expected<uint32_t> COFFCxxModuleMetadataReader::readModuleID() {
+ if (ModuleIndexWidth != 1 && ModuleIndexWidth != 2 && ModuleIndexWidth != 4)
+ return createStringError("unsupported index width: %d", ModuleIndexWidth);
+
+ if (ModuleData.size() < ModuleIndexWidth)
+ return createStringError("not enough data");
+
+ uint32_t ID = std::numeric_limits<uint32_t>::max();
switch (ModuleIndexWidth) {
case 1: {
- if (ModuleData.size() < 1)
- return createStringError("Not enough data");
- uint8_t ID = static_cast<uint8_t>(ModuleData[0]);
- ModuleData = ModuleData.slice(1, StringRef::npos);
- if (ID == std::numeric_limits<uint8_t>::max())
- return std::numeric_limits<uint32_t>::max();
- return ID;
- }
+ uint8_t V = static_cast<uint8_t>(ModuleData[0]);
+ if (V != std::numeric_limits<uint8_t>::max())
----------------
jh7370 wrote:
I'm probably missing something: what's the purpose of these checks?
https://github.com/llvm/llvm-project/pull/201695
More information about the llvm-commits
mailing list