clang/Modules: Sink CompilerInstance::KnownModules into ModuleMap
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 4 Nov 2019 03:29:29 +0000 (19:29 -0800)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 4 Nov 2019 03:57:33 +0000 (19:57 -0800)
commit31e14f41a21f9016050a20f07d5da03db2e8c13e
tree414a5b696961e951b4170658023c6d674756b71b
parent858b15cb9cf675b33d5c3bf17b3050d98b73ec3f
clang/Modules: Sink CompilerInstance::KnownModules into ModuleMap

Avoid use-after-frees when FrontendAction::BeginSourceFile is called
twice on the same CompilerInstance by sinking
CompilerInstance::KnownModules into ModuleMap.  On the way, rename the
map to CachedModuleLoads.  I considered (but rejected) merging this with
ModuleMap::Modules, since that only has top-level modules and this map
includes submodules.

This is an alternative to https://reviews.llvm.org/D58497.  Thanks to
nemanjai for the detailed analysis of the problem!
clang/include/clang/Frontend/CompilerInstance.h
clang/include/clang/Lex/ModuleMap.h
clang/lib/Frontend/CompilerInstance.cpp