#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/Path.h"
using namespace clang;
bool Preprocessor::isInPrimaryFile() const {
if (IsFileLexer())
return IncludeMacroStack.empty();
assert(IsFileLexer(IncludeMacroStack[0]) &&
"Top level include stack isn't our primary lexer?");
return llvm::none_of(
llvm::drop_begin(IncludeMacroStack),
[&](const IncludeStackInfo &ISI) -> bool { return IsFileLexer(ISI); });
}
PreprocessorLexer *Preprocessor::getCurrentFileLexer() const {
if (IsFileLexer())
return CurPPLexer;
for (const IncludeStackInfo &ISI : llvm::reverse(IncludeMacroStack)) {
if (IsFileLexer(ISI))
return ISI.ThePPLexer;
}
return nullptr;
}
bool Preprocessor::EnterSourceFile(FileID FID, ConstSearchDirIterator CurDir,
SourceLocation Loc,
bool IsFirstIncludeOfFile) {
assert(!CurTokenLexer && "Cannot #include a file inside a macro!");
++NumEnteredSourceFiles;
if (MaxIncludeStackDepth < IncludeMacroStack.size())
MaxIncludeStackDepth = IncludeMacroStack.size();
llvm::Optional<llvm::MemoryBufferRef> InputFile =
getSourceManager().getBufferOrNone(FID, Loc);
if (!InputFile) {
SourceLocation FileStart = SourceMgr.getLocForStartOfFile(FID);
Diag(Loc, diag::err_pp_error_opening_file)
<< std::string(SourceMgr.getBufferName(FileStart)) << "";
return true;
}
if (isCodeCompletionEnabled() &&
SourceMgr.getFileEntryForID(FID) == CodeCompletionFile) {
CodeCompletionFileLoc = SourceMgr.getLocForStartOfFile(FID);
CodeCompletionLoc =
CodeCompletionFileLoc.getLocWithOffset(CodeCompletionOffset);
}
Lexer *TheLexer = new Lexer(FID, *InputFile, *this, IsFirstIncludeOfFile);
if (getPreprocessorOpts().DependencyDirectivesForFile &&
FID != PredefinesFileID) {
if (Optional<FileEntryRef> File = SourceMgr.getFileEntryRefForID(FID)) {
if (Optional<ArrayRef<dependency_directives_scan::Directive>>
DepDirectives =
getPreprocessorOpts().DependencyDirectivesForFile(*File)) {
TheLexer->DepDirectives = *DepDirectives;
}
}
}
EnterSourceFileWithLexer(TheLexer, CurDir);
return false;
}
void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
ConstSearchDirIterator CurDir) {
PreprocessorLexer *PrevPPLexer = CurPPLexer;
if (CurPPLexer || CurTokenLexer)
PushIncludeMacroStack();
CurLexer.reset(TheLexer);
CurPPLexer = TheLexer;
CurDirLookup = CurDir;
CurLexerSubmodule = nullptr;
if (CurLexerKind != CLK_LexAfterModuleImport)
CurLexerKind = TheLexer->isDependencyDirectivesLexer()
? CLK_DependencyDirectivesLexer
: CLK_Lexer;
if (Callbacks && !CurLexer->Is_PragmaLexer) {
SrcMgr::CharacteristicKind FileType =
SourceMgr.getFileCharacteristic(CurLexer->getFileLoc());
FileID PrevFID;
SourceLocation EnterLoc;
if (PrevPPLexer) {
PrevFID = PrevPPLexer->getFileID();
EnterLoc = PrevPPLexer->getSourceLocation();
}
Callbacks->FileChanged(CurLexer->getFileLoc(), PPCallbacks::EnterFile,
FileType, PrevFID);
Callbacks->LexedFileChanged(CurLexer->getFileID(),
PPCallbacks::LexedFileChangeReason::EnterFile,
FileType, PrevFID, EnterLoc);
}
}
void Preprocessor::EnterMacro(Token &Tok, SourceLocation ILEnd,
MacroInfo *Macro, MacroArgs *Args) {
std::unique_ptr<TokenLexer> TokLexer;
if (NumCachedTokenLexers == 0) {
TokLexer = std::make_unique<TokenLexer>(Tok, ILEnd, Macro, Args, *this);
} else {
TokLexer = std::move(TokenLexerCache[--NumCachedTokenLexers]);
TokLexer->Init(Tok, ILEnd, Macro, Args);
}
PushIncludeMacroStack();
CurDirLookup = nullptr;
CurTokenLexer = std::move(TokLexer);
if (CurLexerKind != CLK_LexAfterModuleImport)
CurLexerKind = CLK_TokenLexer;
}
void Preprocessor::EnterTokenStream(const Token *Toks, unsigned NumToks,
bool DisableMacroExpansion, bool OwnsTokens,
bool IsReinject) {
if (CurLexerKind == CLK_CachingLexer) {
if (CachedLexPos < CachedTokens.size()) {
assert(IsReinject && "new tokens in the middle of cached stream");
CachedTokens.insert(CachedTokens.begin() + CachedLexPos,
Toks, Toks + NumToks);
if (OwnsTokens)
delete [] Toks;
return;
}
ExitCachingLexMode();
EnterTokenStream(Toks, NumToks, DisableMacroExpansion, OwnsTokens,
IsReinject);
EnterCachingLexMode();
return;
}
std::unique_ptr<TokenLexer> TokLexer;
if (NumCachedTokenLexers == 0) {
TokLexer = std::make_unique<TokenLexer>(
Toks, NumToks, DisableMacroExpansion, OwnsTokens, IsReinject, *this);
} else {
TokLexer = std::move(TokenLexerCache[--NumCachedTokenLexers]);
TokLexer->Init(Toks, NumToks, DisableMacroExpansion, OwnsTokens,
IsReinject);
}
PushIncludeMacroStack();
CurDirLookup = nullptr;
CurTokenLexer = std::move(TokLexer);
if (CurLexerKind != CLK_LexAfterModuleImport)
CurLexerKind = CLK_TokenLexer;
}
static void computeRelativePath(FileManager &FM, const DirectoryEntry *Dir,
const FileEntry *File,
SmallString<128> &Result) {
Result.clear();
StringRef FilePath = File->getDir()->getName();
StringRef Path = FilePath;
while (!Path.empty()) {
if (auto CurDir = FM.getDirectory(Path)) {
if (*CurDir == Dir) {
Result = FilePath.substr(Path.size());
llvm::sys::path::append(Result,
llvm::sys::path::filename(File->getName()));
return;
}
}
Path = llvm::sys::path::parent_path(Path);
}
Result = File->getName();
}
void Preprocessor::PropagateLineStartLeadingSpaceInfo(Token &Result) {
if (CurTokenLexer) {
CurTokenLexer->PropagateLineStartLeadingSpaceInfo(Result);
return;
}
if (CurLexer) {
CurLexer->PropagateLineStartLeadingSpaceInfo(Result);
return;
}
}
const char *Preprocessor::getCurLexerEndPos() {
const char *EndPos = CurLexer->BufferEnd;
if (EndPos != CurLexer->BufferStart &&
(EndPos[-1] == '\n' || EndPos[-1] == '\r')) {
--EndPos;
if (EndPos != CurLexer->BufferStart &&
(EndPos[-1] == '\n' || EndPos[-1] == '\r') &&
EndPos[-1] != EndPos[0])
--EndPos;
}
return EndPos;
}
static void collectAllSubModulesWithUmbrellaHeader(
const Module &Mod, SmallVectorImpl<const Module *> &SubMods) {
if (Mod.getUmbrellaHeader())
SubMods.push_back(&Mod);
for (auto *M : Mod.submodules())
collectAllSubModulesWithUmbrellaHeader(*M, SubMods);
}
void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
const Module::Header &UmbrellaHeader = Mod.getUmbrellaHeader();
assert(UmbrellaHeader.Entry && "Module must use umbrella header");
const FileID &File = SourceMgr.translateFile(UmbrellaHeader.Entry);
SourceLocation ExpectedHeadersLoc = SourceMgr.getLocForEndOfFile(File);
if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header,
ExpectedHeadersLoc))
return;
ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
const DirectoryEntry *Dir = Mod.getUmbrellaDir().Entry;
llvm::vfs::FileSystem &FS = FileMgr.getVirtualFileSystem();
std::error_code EC;
for (llvm::vfs::recursive_directory_iterator Entry(FS, Dir->getName(), EC),
End;
Entry != End && !EC; Entry.increment(EC)) {
using llvm::StringSwitch;
if (!StringSwitch<bool>(llvm::sys::path::extension(Entry->path()))
.Cases(".h", ".H", ".hh", ".hpp", true)
.Default(false))
continue;
if (auto Header = getFileManager().getFile(Entry->path()))
if (!getSourceManager().hasFileInfo(*Header)) {
if (!ModMap.isHeaderInUnavailableModule(*Header)) {
SmallString<128> RelativePath;
computeRelativePath(FileMgr, Dir, *Header, RelativePath);
Diag(ExpectedHeadersLoc, diag::warn_uncovered_module_header)
<< Mod.getFullModuleName() << RelativePath;
}
}
}
}
bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
assert(!CurTokenLexer &&
"Ending a file when currently in a macro!");
const bool LeavingSubmodule = CurLexer && CurLexerSubmodule;
if ((LeavingSubmodule || IncludeMacroStack.empty()) &&
!BuildingSubmoduleStack.empty() &&
BuildingSubmoduleStack.back().IsPragma) {
Diag(BuildingSubmoduleStack.back().ImportLoc,
diag::err_pp_module_begin_without_module_end);
Module *M = LeaveSubmodule(true);
Result.startToken();
const char *EndPos = getCurLexerEndPos();
CurLexer->BufferPtr = EndPos;
CurLexer->FormTokenWithChars(Result, EndPos, tok::annot_module_end);
Result.setAnnotationEndLoc(Result.getLocation());
Result.setAnnotationValue(M);
return true;
}
if (CurPPLexer) { if (const IdentifierInfo *ControllingMacro =
CurPPLexer->MIOpt.GetControllingMacroAtEndOfFile()) {
if (const FileEntry *FE = CurPPLexer->getFileEntry()) {
HeaderInfo.SetFileControllingMacro(FE, ControllingMacro);
if (MacroInfo *MI =
getMacroInfo(const_cast<IdentifierInfo*>(ControllingMacro)))
MI->setUsedForHeaderGuard(true);
if (const IdentifierInfo *DefinedMacro =
CurPPLexer->MIOpt.GetDefinedMacro()) {
if (!isMacroDefined(ControllingMacro) &&
DefinedMacro != ControllingMacro &&
CurLexer->isFirstTimeLexingFile()) {
const StringRef ControllingMacroName = ControllingMacro->getName();
const StringRef DefinedMacroName = DefinedMacro->getName();
const size_t MaxHalfLength = std::max(ControllingMacroName.size(),
DefinedMacroName.size()) / 2;
const unsigned ED = ControllingMacroName.edit_distance(
DefinedMacroName, true, MaxHalfLength);
if (ED <= MaxHalfLength) {
Diag(CurPPLexer->MIOpt.GetMacroLocation(),
diag::warn_header_guard)
<< CurPPLexer->MIOpt.GetMacroLocation() << ControllingMacro;
Diag(CurPPLexer->MIOpt.GetDefinedLocation(),
diag::note_header_guard)
<< CurPPLexer->MIOpt.GetDefinedLocation() << DefinedMacro
<< ControllingMacro
<< FixItHint::CreateReplacement(
CurPPLexer->MIOpt.GetDefinedLocation(),
ControllingMacro->getName());
}
}
}
}
}
}
if (PragmaARCCFCodeAuditedInfo.second.isValid() && !isEndOfMacro &&
!(CurLexer && CurLexer->Is_PragmaLexer)) {
Diag(PragmaARCCFCodeAuditedInfo.second,
diag::err_pp_eof_in_arc_cf_code_audited);
PragmaARCCFCodeAuditedInfo = {nullptr, SourceLocation()};
}
if (PragmaAssumeNonNullLoc.isValid() &&
!isEndOfMacro && !(CurLexer && CurLexer->Is_PragmaLexer)) {
if (isRecordingPreamble() && isInPrimaryFile())
PreambleRecordedPragmaAssumeNonNullLoc = PragmaAssumeNonNullLoc;
else
Diag(PragmaAssumeNonNullLoc, diag::err_pp_eof_in_assume_nonnull);
PragmaAssumeNonNullLoc = SourceLocation();
}
bool LeavingPCHThroughHeader = false;
if (!IncludeMacroStack.empty()) {
if (isCodeCompletionEnabled() && CurPPLexer &&
SourceMgr.getLocForStartOfFile(CurPPLexer->getFileID()) ==
CodeCompletionFileLoc) {
assert(CurLexer && "Got EOF but no current lexer set!");
Result.startToken();
CurLexer->FormTokenWithChars(Result, CurLexer->BufferEnd, tok::eof);
CurLexer.reset();
CurPPLexer = nullptr;
recomputeCurLexerKind();
return true;
}
if (!isEndOfMacro && CurPPLexer &&
(SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid() ||
(PredefinesFileID.isValid() &&
CurPPLexer->getFileID() == PredefinesFileID))) {
unsigned NumFIDs =
SourceMgr.local_sloc_entry_size() -
CurPPLexer->getInitialNumSLocEntries() + 1;
SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs);
}
bool ExitedFromPredefinesFile = false;
FileID ExitedFID;
if (!isEndOfMacro && CurPPLexer) {
ExitedFID = CurPPLexer->getFileID();
assert(PredefinesFileID.isValid() &&
"HandleEndOfFile is called before PredefinesFileId is set");
ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID);
}
if (LeavingSubmodule) {
Module *M = LeaveSubmodule(false);
const char *EndPos = getCurLexerEndPos();
Result.startToken();
CurLexer->BufferPtr = EndPos;
CurLexer->FormTokenWithChars(Result, EndPos, tok::annot_module_end);
Result.setAnnotationEndLoc(Result.getLocation());
Result.setAnnotationValue(M);
}
bool FoundPCHThroughHeader = false;
if (CurPPLexer && creatingPCHWithThroughHeader() &&
isPCHThroughHeader(
SourceMgr.getFileEntryForID(CurPPLexer->getFileID())))
FoundPCHThroughHeader = true;
RemoveTopOfLexerStack();
PropagateLineStartLeadingSpaceInfo(Result);
if (Callbacks && !isEndOfMacro && CurPPLexer) {
SourceLocation Loc = CurPPLexer->getSourceLocation();
SrcMgr::CharacteristicKind FileType =
SourceMgr.getFileCharacteristic(Loc);
Callbacks->FileChanged(Loc, PPCallbacks::ExitFile, FileType, ExitedFID);
Callbacks->LexedFileChanged(CurPPLexer->getFileID(),
PPCallbacks::LexedFileChangeReason::ExitFile,
FileType, ExitedFID, Loc);
}
if (ExitedFromPredefinesFile) {
replayPreambleConditionalStack();
if (PreambleRecordedPragmaAssumeNonNullLoc.isValid())
PragmaAssumeNonNullLoc = PreambleRecordedPragmaAssumeNonNullLoc;
}
if (!isEndOfMacro && CurPPLexer && FoundPCHThroughHeader &&
(isInPrimaryFile() ||
CurPPLexer->getFileID() == getPredefinesFileID())) {
LeavingPCHThroughHeader = true;
} else {
return LeavingSubmodule;
}
}
assert(CurLexer && "Got EOF but no current lexer set!");
const char *EndPos = getCurLexerEndPos();
Result.startToken();
CurLexer->BufferPtr = EndPos;
CurLexer->FormTokenWithChars(Result, EndPos, tok::eof);
if (isCodeCompletionEnabled()) {
if (CurLexer->getFileLoc() == CodeCompletionFileLoc)
Result.setLocation(Result.getLocation().getLocWithOffset(-1));
}
if (creatingPCHWithThroughHeader() && !LeavingPCHThroughHeader) {
Diag(CurLexer->getFileLoc(), diag::err_pp_through_header_not_seen)
<< PPOpts->PCHThroughHeader << 0;
}
if (!isIncrementalProcessingEnabled())
CurLexer.reset();
if (!isIncrementalProcessingEnabled())
CurPPLexer = nullptr;
if (TUKind == TU_Complete) {
for (WarnUnusedMacroLocsTy::iterator
I=WarnUnusedMacroLocs.begin(), E=WarnUnusedMacroLocs.end();
I!=E; ++I)
Diag(*I, diag::pp_macro_not_used);
}
if (Module *Mod = getCurrentModule()) {
llvm::SmallVector<const Module *, 4> AllMods;
collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods);
for (auto *M : AllMods)
diagnoseMissingHeaderInUmbrellaDir(*M);
}
return true;
}
bool Preprocessor::HandleEndOfTokenLexer(Token &Result) {
assert(CurTokenLexer && !CurPPLexer &&
"Ending a macro when currently in a #include file!");
if (!MacroExpandingLexersStack.empty() &&
MacroExpandingLexersStack.back().first == CurTokenLexer.get())
removeCachedMacroExpandedTokensOfLastLexer();
if (NumCachedTokenLexers == TokenLexerCacheSize)
CurTokenLexer.reset();
else
TokenLexerCache[NumCachedTokenLexers++] = std::move(CurTokenLexer);
return HandleEndOfFile(Result, true);
}
void Preprocessor::RemoveTopOfLexerStack() {
assert(!IncludeMacroStack.empty() && "Ran out of stack entries to load");
if (CurTokenLexer) {
if (NumCachedTokenLexers == TokenLexerCacheSize)
CurTokenLexer.reset();
else
TokenLexerCache[NumCachedTokenLexers++] = std::move(CurTokenLexer);
}
PopIncludeMacroStack();
}
void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
assert(CurTokenLexer && !CurPPLexer &&
"Pasted comment can only be formed from macro");
PreprocessorLexer *FoundLexer = nullptr;
bool LexerWasInPPMode = false;
for (const IncludeStackInfo &ISI : llvm::reverse(IncludeMacroStack)) {
if (ISI.ThePPLexer == nullptr) continue;
FoundLexer = ISI.ThePPLexer;
FoundLexer->LexingRawMode = true;
LexerWasInPPMode = FoundLexer->ParsingPreprocessorDirective;
FoundLexer->ParsingPreprocessorDirective = true;
break;
}
if (!HandleEndOfTokenLexer(Tok)) Lex(Tok);
while (Tok.isNot(tok::eod) && Tok.isNot(tok::eof))
Lex(Tok);
if (Tok.is(tok::eod)) {
assert(FoundLexer && "Can't get end of line without an active lexer");
FoundLexer->LexingRawMode = false;
if (LexerWasInPPMode) return;
FoundLexer->ParsingPreprocessorDirective = false;
return Lex(Tok);
}
assert(!FoundLexer && "Lexer should return EOD before EOF in PP mode");
}
void Preprocessor::EnterSubmodule(Module *M, SourceLocation ImportLoc,
bool ForPragma) {
if (!getLangOpts().ModulesLocalVisibility) {
BuildingSubmoduleStack.push_back(
BuildingSubmoduleInfo(M, ImportLoc, ForPragma, CurSubmoduleState,
PendingModuleMacroNames.size()));
if (Callbacks)
Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
return;
}
ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
ModMap.resolveExports(M, false);
ModMap.resolveUses(M, false);
ModMap.resolveConflicts(M, false);
auto R = Submodules.insert(std::make_pair(M, SubmoduleState()));
auto &State = R.first->second;
bool FirstTime = R.second;
if (FirstTime) {
auto &StartingMacros = NullSubmoduleState.Macros;
for (auto &Macro : StartingMacros) {
if (!Macro.second.getLatest() &&
Macro.second.getOverriddenMacros().empty())
continue;
MacroState MS(Macro.second.getLatest());
MS.setOverriddenMacros(*this, Macro.second.getOverriddenMacros());
State.Macros.insert(std::make_pair(Macro.first, std::move(MS)));
}
}
BuildingSubmoduleStack.push_back(
BuildingSubmoduleInfo(M, ImportLoc, ForPragma, CurSubmoduleState,
PendingModuleMacroNames.size()));
if (Callbacks)
Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
CurSubmoduleState = &State;
if (FirstTime)
makeModuleVisible(M, ImportLoc);
}
bool Preprocessor::needModuleMacros() const {
if (BuildingSubmoduleStack.empty())
return false;
if (getLangOpts().ModulesLocalVisibility)
return true;
return getLangOpts().isCompilingModule();
}
Module *Preprocessor::LeaveSubmodule(bool ForPragma) {
if (BuildingSubmoduleStack.empty() ||
BuildingSubmoduleStack.back().IsPragma != ForPragma) {
assert(ForPragma && "non-pragma module enter/leave mismatch");
return nullptr;
}
auto &Info = BuildingSubmoduleStack.back();
Module *LeavingMod = Info.M;
SourceLocation ImportLoc = Info.ImportLoc;
if (!needModuleMacros() ||
(!getLangOpts().ModulesLocalVisibility &&
LeavingMod->getTopLevelModuleName() != getLangOpts().CurrentModule)) {
BuildingSubmoduleStack.pop_back();
if (Callbacks)
Callbacks->LeftSubmodule(LeavingMod, ImportLoc, ForPragma);
makeModuleVisible(LeavingMod, ImportLoc);
return LeavingMod;
}
llvm::SmallPtrSet<const IdentifierInfo*, 8> VisitedMacros;
for (unsigned I = Info.OuterPendingModuleMacroNames;
I != PendingModuleMacroNames.size(); ++I) {
auto *II = const_cast<IdentifierInfo*>(PendingModuleMacroNames[I]);
if (!VisitedMacros.insert(II).second)
continue;
auto MacroIt = CurSubmoduleState->Macros.find(II);
if (MacroIt == CurSubmoduleState->Macros.end())
continue;
auto &Macro = MacroIt->second;
MacroDirective *OldMD = nullptr;
auto *OldState = Info.OuterSubmoduleState;
if (getLangOpts().ModulesLocalVisibility)
OldState = &NullSubmoduleState;
if (OldState && OldState != CurSubmoduleState) {
auto &OldMacros = OldState->Macros;
auto OldMacroIt = OldMacros.find(II);
if (OldMacroIt == OldMacros.end())
OldMD = nullptr;
else
OldMD = OldMacroIt->second.getLatest();
}
bool ExplicitlyPublic = false;
for (auto *MD = Macro.getLatest(); MD != OldMD; MD = MD->getPrevious()) {
assert(MD && "broken macro directive chain");
if (auto *VisMD = dyn_cast<VisibilityMacroDirective>(MD)) {
if (VisMD->isPublic())
ExplicitlyPublic = true;
else if (!ExplicitlyPublic)
break;
} else {
MacroInfo *Def = nullptr;
if (DefMacroDirective *DefMD = dyn_cast<DefMacroDirective>(MD))
Def = DefMD->getInfo();
bool IsNew;
if (Def || !Macro.getOverriddenMacros().empty())
addModuleMacro(LeavingMod, II, Def,
Macro.getOverriddenMacros(), IsNew);
if (!getLangOpts().ModulesLocalVisibility) {
Macro.setLatest(nullptr);
Macro.setOverriddenMacros(*this, {});
}
break;
}
}
}
PendingModuleMacroNames.resize(Info.OuterPendingModuleMacroNames);
if (getLangOpts().ModulesLocalVisibility)
CurSubmoduleState = Info.OuterSubmoduleState;
BuildingSubmoduleStack.pop_back();
if (Callbacks)
Callbacks->LeftSubmodule(LeavingMod, ImportLoc, ForPragma);
makeModuleVisible(LeavingMod, ImportLoc);
return LeavingMod;
}