forked from OSchip/llvm-project
[modules] When building a module, make sure we don't serialize out HeaderFileInfo for headers not belonging to the module.
After r180934 we may initiate module map parsing for modules not related to the module what we are building, make sure we ignore the header file info of headers from such modules. First part of rdar://13840148 llvm-svn: 181489
This commit is contained in:
parent
65c163529d
commit
6f722b4eb9
|
@ -53,6 +53,9 @@ struct HeaderFileInfo {
|
|||
|
||||
/// \brief Whether this header is part of a module.
|
||||
unsigned isModuleHeader : 1;
|
||||
|
||||
/// \brief Whether this header is part of the module that we are building.
|
||||
unsigned isCompilingModuleHeader : 1;
|
||||
|
||||
/// \brief Whether this structure is considered to already have been
|
||||
/// "resolved", meaning that it was loaded from the external source.
|
||||
|
@ -93,8 +96,8 @@ struct HeaderFileInfo {
|
|||
|
||||
HeaderFileInfo()
|
||||
: isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
|
||||
External(false), isModuleHeader(false), Resolved(false),
|
||||
IndexHeaderMapHeader(false),
|
||||
External(false), isModuleHeader(false), isCompilingModuleHeader(false),
|
||||
Resolved(false), IndexHeaderMapHeader(false),
|
||||
NumIncludes(0), ControllingMacroID(0), ControllingMacro(0) {}
|
||||
|
||||
/// \brief Retrieve the controlling macro for this header file, if
|
||||
|
@ -405,7 +408,7 @@ public:
|
|||
}
|
||||
|
||||
/// \brief Mark the specified file as part of a module.
|
||||
void MarkFileModuleHeader(const FileEntry *File);
|
||||
void MarkFileModuleHeader(const FileEntry *File, bool IsCompiledModuleHeader);
|
||||
|
||||
/// \brief Increment the count for the number of times the specified
|
||||
/// FileEntry has been entered.
|
||||
|
|
|
@ -52,6 +52,9 @@ class ModuleMap {
|
|||
/// These are always simple C language options.
|
||||
LangOptions MMapLangOpts;
|
||||
|
||||
// The module that we are building; related to \c LangOptions::CurrentModule.
|
||||
Module *CompilingModule;
|
||||
|
||||
/// \brief The top-level modules that are known.
|
||||
llvm::StringMap<Module *> Modules;
|
||||
|
||||
|
|
|
@ -866,12 +866,14 @@ bool HeaderSearch::isFileMultipleIncludeGuarded(const FileEntry *File) {
|
|||
HFI.ControllingMacro || HFI.ControllingMacroID;
|
||||
}
|
||||
|
||||
void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE) {
|
||||
void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE,
|
||||
bool isCompilingModuleHeader) {
|
||||
if (FE->getUID() >= FileInfo.size())
|
||||
FileInfo.resize(FE->getUID()+1);
|
||||
|
||||
HeaderFileInfo &HFI = FileInfo[FE->getUID()];
|
||||
HFI.isModuleHeader = true;
|
||||
HFI.isCompilingModuleHeader = isCompilingModuleHeader;
|
||||
}
|
||||
|
||||
void HeaderSearch::setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID) {
|
||||
|
|
|
@ -87,7 +87,7 @@ ModuleMap::ModuleMap(FileManager &FileMgr, DiagnosticConsumer &DC,
|
|||
const LangOptions &LangOpts, const TargetInfo *Target,
|
||||
HeaderSearch &HeaderInfo)
|
||||
: LangOpts(LangOpts), Target(Target), HeaderInfo(HeaderInfo),
|
||||
BuiltinIncludeDir(0)
|
||||
BuiltinIncludeDir(0), CompilingModule(0)
|
||||
{
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(new DiagnosticIDs);
|
||||
Diags = IntrusiveRefCntPtr<DiagnosticsEngine>(
|
||||
|
@ -388,8 +388,13 @@ ModuleMap::findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
|
|||
// Create a new module with this name.
|
||||
Module *Result = new Module(Name, SourceLocation(), Parent, IsFramework,
|
||||
IsExplicit);
|
||||
if (!Parent)
|
||||
if (!Parent) {
|
||||
Modules[Name] = Result;
|
||||
if (!LangOpts.CurrentModule.empty() && !CompilingModule &&
|
||||
Name == LangOpts.CurrentModule) {
|
||||
CompilingModule = Result;
|
||||
}
|
||||
}
|
||||
return std::make_pair(Result, true);
|
||||
}
|
||||
|
||||
|
@ -605,7 +610,8 @@ void ModuleMap::addHeader(Module *Mod, const FileEntry *Header,
|
|||
Mod->ExcludedHeaders.push_back(Header);
|
||||
} else {
|
||||
Mod->Headers.push_back(Header);
|
||||
HeaderInfo.MarkFileModuleHeader(Header);
|
||||
bool isCompilingModuleHeader = Mod->getTopLevelModule() == CompilingModule;
|
||||
HeaderInfo.MarkFileModuleHeader(Header, isCompilingModuleHeader);
|
||||
}
|
||||
Headers[Header] = KnownHeader(Mod, Excluded);
|
||||
}
|
||||
|
|
|
@ -1542,6 +1542,8 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS, StringRef isysroot) {
|
|||
const HeaderFileInfo &HFI = HS.getFileInfo(File);
|
||||
if (HFI.External && Chain)
|
||||
continue;
|
||||
if (HFI.isModuleHeader && !HFI.isCompilingModuleHeader)
|
||||
continue;
|
||||
|
||||
// Turn the file name into an absolute path, if it isn't already.
|
||||
const char *Filename = File->getName();
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
@import DepBuiltin;
|
||||
|
||||
@interface Foo
|
||||
@end
|
|
@ -0,0 +1 @@
|
|||
#import "a1.h"
|
|
@ -0,0 +1,4 @@
|
|||
framework module af {
|
||||
header "a1.h"
|
||||
header "a2.h"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
#include <float.h>
|
|
@ -0,0 +1,5 @@
|
|||
module DepBuiltin {
|
||||
header "h1.h"
|
||||
export *
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
// rdar://13840148
|
||||
|
||||
// RUN: rm -rf %t
|
||||
// RUN: %clang -fsyntax-only -isysroot %S/../Inputs/System/usr/include -fmodules -fmodules-cache-path=%t \
|
||||
// RUN: -F %S -I %S %s -D__need_wint_t -Werror=implicit-function-declaration
|
||||
|
||||
@import af;
|
Loading…
Reference in New Issue