From 8e2c192e2af8c760152ba3b28e774dbb1548e4aa Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sun, 10 Nov 2019 11:07:20 -0800 Subject: [PATCH] clang/Modules: Add missing diagnostics for malformed AST files These were found via an audit. In the case of `ParseLineTable` this is actually dead code, since parsing the line table always succeeds, but it's prudent to be defensive since it's possible an assertion there could be converted to a `true` return in the future. --- clang/lib/Serialization/ASTReader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index a5cd9e9..b780335 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -3408,8 +3408,10 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { break; case SOURCE_MANAGER_LINE_TABLE: - if (ParseLineTable(F, Record)) + if (ParseLineTable(F, Record)) { + Error("malformed SOURCE_MANAGER_LINE_TABLE in AST file"); return Failure; + } break; case SOURCE_LOCATION_PRELOADS: { @@ -4771,8 +4773,10 @@ ASTReader::ASTReadResult ASTReader::ReadExtensionBlock(ModuleFile &F) { switch (MaybeRecCode.get()) { case EXTENSION_METADATA: { ModuleFileExtensionMetadata Metadata; - if (parseModuleFileExtensionMetadata(Record, Blob, Metadata)) + if (parseModuleFileExtensionMetadata(Record, Blob, Metadata)) { + Error("malformed EXTENSION_METADATA in AST file"); return Failure; + } // Find a module file extension with this block name. auto Known = ModuleFileExtensions.find(Metadata.BlockName); -- 2.7.4