diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2019-11-10 10:50:12 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2019-11-11 15:53:48 -0800 |
commit | 01782c3e4df1830d7991e9edfee9119ed41e4c27 (patch) | |
tree | ff5560fd737399b1baace79ad13f02021377272c /clang/lib/Serialization/ASTReader.cpp | |
parent | bfd58fc60ff4b0c081b5b489119c3798d3e2b53c (diff) | |
download | bcm5719-llvm-01782c3e4df1830d7991e9edfee9119ed41e4c27.tar.gz bcm5719-llvm-01782c3e4df1830d7991e9edfee9119ed41e4c27.zip |
clang/Modules: Split loop in ReadAST between failable and not
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
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 412bc78c1af..a5cd9e9f83e 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4202,7 +4202,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, // 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 (ImportedModule &M : Loaded) { ModuleFile &F = *M.Mod; @@ -4221,6 +4222,11 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, F.GlobalBitOffset = TotalModulesSizeInBits; TotalModulesSizeInBits += F.SizeInBits; GlobalBitOffsetsMap.insert(std::make_pair(F.GlobalBitOffset, &F)); + } + + // Preload source locations and interesting indentifiers. + for (ImportedModule &M : Loaded) { + ModuleFile &F = *M.Mod; // Preload SLocEntries. for (unsigned I = 0, N = F.PreloadSLocEntries.size(); I != N; ++I) { |