| 3141 | } |
| 3142 | |
| 3143 | Error BitcodeReader::parseModule(uint64_t ResumeBit, |
| 3144 | bool ShouldLazyLoadMetadata) { |
| 3145 | if (ResumeBit) |
| 3146 | Stream.JumpToBit(ResumeBit); |
| 3147 | else if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID)) |
| 3148 | return error("Invalid record"); |
| 3149 | |
| 3150 | SmallVector<uint64_t, 64> Record; |
| 3151 | |
| 3152 | // Read all the records for this module. |
| 3153 | while (true) { |
| 3154 | BitstreamEntry Entry = Stream.advance(); |
| 3155 | |
| 3156 | switch (Entry.Kind) { |
| 3157 | case BitstreamEntry::Error: |
| 3158 | return error("Malformed block"); |
| 3159 | case BitstreamEntry::EndBlock: |
| 3160 | return globalCleanup(); |
| 3161 | |
| 3162 | case BitstreamEntry::SubBlock: |
| 3163 | switch (Entry.ID) { |
| 3164 | default: // Skip unknown content. |
| 3165 | if (Stream.SkipBlock()) |
| 3166 | return error("Invalid record"); |
| 3167 | break; |
| 3168 | case bitc::BLOCKINFO_BLOCK_ID: |
| 3169 | if (readBlockInfo()) |
| 3170 | return error("Malformed block"); |
| 3171 | break; |
| 3172 | case bitc::PARAMATTR_BLOCK_ID: |
| 3173 | if (Error Err = parseAttributeBlock()) |
| 3174 | return Err; |
| 3175 | break; |
| 3176 | case bitc::PARAMATTR_GROUP_BLOCK_ID: |
| 3177 | if (Error Err = parseAttributeGroupBlock()) |
| 3178 | return Err; |
| 3179 | break; |
| 3180 | case bitc::TYPE_BLOCK_ID_NEW: |
| 3181 | if (Error Err = parseTypeTable()) |
| 3182 | return Err; |
| 3183 | break; |
| 3184 | case bitc::VALUE_SYMTAB_BLOCK_ID: |
| 3185 | if (!SeenValueSymbolTable) { |
| 3186 | // Either this is an old form VST without function index and an |
| 3187 | // associated VST forward declaration record (which would have caused |
| 3188 | // the VST to be jumped to and parsed before it was encountered |
| 3189 | // normally in the stream), or there were no function blocks to |
| 3190 | // trigger an earlier parsing of the VST. |
| 3191 | assert(VSTOffset == 0 || FunctionsWithBodies.empty()); |
| 3192 | if (Error Err = parseValueSymbolTable()) |
| 3193 | return Err; |
| 3194 | SeenValueSymbolTable = true; |
| 3195 | } else { |
| 3196 | // We must have had a VST forward declaration record, which caused |
| 3197 | // the parser to jump to and parse the VST earlier. |
| 3198 | assert(VSTOffset > 0); |
| 3199 | if (Stream.SkipBlock()) |
| 3200 | return error("Invalid record"); |
no test coverage detected