/// \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.
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
}
/// \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.
/// 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;
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) {
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>(
// 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);
}
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);
}
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();
--- /dev/null
+@import DepBuiltin;
+
+@interface Foo
+@end
--- /dev/null
+#import "a1.h"
--- /dev/null
+framework module af {
+ header "a1.h"
+ header "a2.h"
+}
--- /dev/null
+#include <float.h>
--- /dev/null
+module DepBuiltin {
+header "h1.h"
+ export *
+}
+
--- /dev/null
+// 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;