[HeaderSearch] Fix processing #import-ed headers multiple times with modules enabled.
authorVolodymyr Sapsai <vsapsai@apple.com>
Wed, 20 May 2020 00:29:35 +0000 (17:29 -0700)
committerVolodymyr Sapsai <vsapsai@apple.com>
Fri, 21 Aug 2020 00:41:28 +0000 (17:41 -0700)
commit7ac737e56bee721fb3535006140362c6e08726bb
treef537c5396352fb006d934d3679ad7c05722af745
parentea9bf460a876fbdf9457ef48bc61a9cece5b6b40
[HeaderSearch] Fix processing #import-ed headers multiple times with modules enabled.

HeaderSearch was marking requested HeaderFileInfo as Resolved only based on
the presence of ExternalSource. As the result, using any module was enough
to set ExternalSource and headers unknown to this module would have
HeaderFileInfo with empty fields, including `isImport = 0`, `NumIncludes = 0`.
Such HeaderFileInfo was preserved without changes regardless of how the
header was used in other modules and caused incorrect result in
`HeaderSearch::ShouldEnterIncludeFile`.

Fix by marking HeaderFileInfo as Resolved only if ExternalSource knows
about this header.

rdar://problem/62126911

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D80263
clang/lib/Lex/HeaderSearch.cpp
clang/test/Modules/Inputs/import-once/ImportOnce.framework/Headers/ImportOnce.h [new file with mode: 0644]
clang/test/Modules/Inputs/import-once/ImportOnce.framework/Modules/module.modulemap [new file with mode: 0644]
clang/test/Modules/Inputs/import-once/IndirectImporter.framework/Headers/IndirectImporter.h [new file with mode: 0644]
clang/test/Modules/Inputs/import-once/IndirectImporter.framework/Modules/module.modulemap [new file with mode: 0644]
clang/test/Modules/Inputs/import-once/Unrelated.framework/Headers/Unrelated.h [new file with mode: 0644]
clang/test/Modules/Inputs/import-once/Unrelated.framework/Modules/module.modulemap [new file with mode: 0644]
clang/test/Modules/import-once.m [new file with mode: 0644]