From 201cbad62dca645abcee1fd01df3e29bf5fe0deb Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Thu, 13 Mar 2014 16:46:36 +0000 Subject: Prevent outputting HeaderFileInfos for files not used as headers When building an AST file, we don't want to output HeaderFileInfo structures for files that are not actually used as headers in the current context. This can lead to assuming that unrelated files have include counts of 0, defeating multiple-include prevention. This is accomplished by adding an IsValid bit to the HFI. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203813 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Serialization/ASTWriter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/Serialization/ASTWriter.cpp') diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index fc1806fca6..95a470d922 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1547,10 +1547,10 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS, StringRef isysroot) { // Use HeaderSearch's getFileInfo to make sure we get the HeaderFileInfo // from the external source if it was not provided already. - const HeaderFileInfo &HFI = HS.getFileInfo(File); - if (HFI.External && Chain) - continue; - if (HFI.isModuleHeader && !HFI.isCompilingModuleHeader) + HeaderFileInfo HFI; + if (!HS.tryGetFileInfo(File, HFI) || + (HFI.External && Chain) || + (HFI.isModuleHeader && !HFI.isCompilingModuleHeader)) continue; // Turn the file name into an absolute path, if it isn't already. -- cgit v1.2.3