forked from OSchip/llvm-project
This reverts r291628. As suggested by Richard, we can simply
filter out the implicilty imported modules at CodeGen instead of removing the implicit ImportDecl when an implementation TU of a module imports a header of that same module. llvm-svn: 291688
This commit is contained in:
parent
d1efea89c9
commit
3e9dea024e
|
@ -1905,8 +1905,7 @@ public:
|
|||
/// \brief The parser has processed a module import translated from a
|
||||
/// #include or similar preprocessing directive.
|
||||
void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
|
||||
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
|
||||
bool NoImport);
|
||||
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
|
||||
|
||||
/// \brief The parsed has entered a submodule.
|
||||
void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
|
||||
|
|
|
@ -15652,11 +15652,10 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
|
|||
|
||||
void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
|
||||
checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext, true);
|
||||
BuildModuleInclude(DirectiveLoc, Mod, false/*NoImport*/);
|
||||
BuildModuleInclude(DirectiveLoc, Mod);
|
||||
}
|
||||
|
||||
void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
|
||||
bool NoImport) {
|
||||
void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
|
||||
// Determine whether we're in the #include buffer for a module. The #includes
|
||||
// in that buffer do not qualify as module imports; they're just an
|
||||
// implementation detail of us building the module.
|
||||
|
@ -15666,7 +15665,7 @@ void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
|
|||
TUKind == TU_Module &&
|
||||
getSourceManager().isWrittenInMainFile(DirectiveLoc);
|
||||
|
||||
bool ShouldAddImport = !IsInModuleIncludes && !NoImport;
|
||||
bool ShouldAddImport = !IsInModuleIncludes;
|
||||
|
||||
// If this module import was due to an inclusion directive, create an
|
||||
// implicit import declaration to capture it in the AST.
|
||||
|
@ -15714,11 +15713,7 @@ void Sema::ActOnModuleEnd(SourceLocation EofLoc, Module *Mod) {
|
|||
assert(File != getSourceManager().getMainFileID() &&
|
||||
"end of submodule in main source file");
|
||||
SourceLocation DirectiveLoc = getSourceManager().getIncludeLoc(File);
|
||||
// Do not create implicit ImportDecl if we are building the implementation
|
||||
// of a module.
|
||||
bool NoImport = Mod->getTopLevelModuleName() == getLangOpts().CurrentModule &&
|
||||
!getLangOpts().isCompilingModule();
|
||||
BuildModuleInclude(DirectiveLoc, Mod, NoImport);
|
||||
BuildModuleInclude(DirectiveLoc, Mod);
|
||||
}
|
||||
|
||||
void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
//empty
|
|
@ -1,4 +0,0 @@
|
|||
module Clib {
|
||||
header "foo.h"
|
||||
link "Clib"
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fmodule-name=Clib %s -I %S/Inputs/module-impl-with-link -emit-llvm -o -
|
||||
#include "foo.h"
|
||||
// CHECK: !{{[0-9]+}} = !{i32 6, !"Linker Options", ![[LINK_OPTIONS:[0-9]+]]}
|
||||
// Make sure we don't generate linker option for module Clib since this TU is
|
||||
// an implementation of Clib.
|
||||
// CHECK: ![[LINK_OPTIONS]] = !{}
|
Loading…
Reference in New Issue