[PATCH] D70056: clang/Modules: Split loop in ReadAST between failable and not
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 10 11:44:23 PST 2019
dexonsmith created this revision.
dexonsmith added reviewers: aprantl, bruno, Bigcheese.
Herald added a subscriber: ributzka.
Split a loop in ReadAST that visits the just-loaded module chain,
between an initial loop that reads further from the ASTs (and can fail)
and a second loop that does some preloading (and cannot fail). This
makes it less likely for a reading failure to affect the AST.
This is not fixing a known bug and the behaviour change may not be
observable, it's just part of an audit to look at all of the error
handling in the ASTReader.
https://reviews.llvm.org/D70056
Files:
clang/lib/Serialization/ASTReader.cpp
Index: clang/lib/Serialization/ASTReader.cpp
===================================================================
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4206,7 +4206,8 @@
// Here comes stuff that we only do once the entire chain is loaded.
- // Load the AST blocks of all of the modules that we loaded.
+ // Load the AST blocks of all of the modules that we loaded. We can still
+ // hit errors parsing the ASTs at this point.
for (SmallVectorImpl<ImportedModule>::iterator M = Loaded.begin(),
MEnd = Loaded.end();
M != MEnd; ++M) {
@@ -4227,7 +4228,13 @@
F.GlobalBitOffset = TotalModulesSizeInBits;
TotalModulesSizeInBits += F.SizeInBits;
GlobalBitOffsetsMap.insert(std::make_pair(F.GlobalBitOffset, &F));
+ }
+ // Preload source locations and interesting indentifiers.
+ for (SmallVectorImpl<ImportedModule>::iterator M = Loaded.begin(),
+ MEnd = Loaded.end();
+ M != MEnd; ++M) {
+ ModuleFile &F = *M->Mod;
// Preload SLocEntries.
for (unsigned I = 0, N = F.PreloadSLocEntries.size(); I != N; ++I) {
int Index = int(F.PreloadSLocEntries[I] - 1) + F.SLocEntryBaseID;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70056.228614.patch
Type: text/x-patch
Size: 1277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191110/bf3db3cb/attachment-0001.bin>
More information about the cfe-commits
mailing list