aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-05-01 01:53:09 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-05-01 01:53:09 +0000
commita7e2cc684fee41abe367205521bf225dd3d582c0 (patch)
tree181a89be83c538a615bd2a1cf9200826c848960a /clang/lib/Lex/Preprocessor.cpp
parent65ace9daa36051aeeb8140bce8e154c61374938f (diff)
downloadllvm-a7e2cc684fee41abe367205521bf225dd3d582c0.zip
llvm-a7e2cc684fee41abe367205521bf225dd3d582c0.tar.gz
llvm-a7e2cc684fee41abe367205521bf225dd3d582c0.tar.bz2
[modules] Start moving the module visibility information off the Module itself.
It has no place there; it's not a property of the Module, and it makes restoring the visibility set when we leave a submodule more difficult. llvm-svn: 236300
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 231720b..2db1095 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -107,9 +107,6 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts,
// We haven't read anything from the external source.
ReadMacrosFromExternalSource = false;
- // We might already have some macros from an imported module (via a PCH or
- // preamble) if modules is enabled.
- MacroVisibilityGeneration = LangOpts.Modules ? 1 : 0;
// "Poison" __VA_ARGS__, which can only appear in the expansion of a macro.
// This gets unpoisoned where it is allowed.
@@ -757,13 +754,34 @@ void Preprocessor::LexAfterModuleImport(Token &Result) {
ModuleImportPath,
Module::MacrosVisible,
/*IsIncludeDirective=*/false);
- ++MacroVisibilityGeneration;
+ if (Imported)
+ makeModuleVisible(Imported, ModuleImportLoc);
}
if (Callbacks && (getLangOpts().Modules || getLangOpts().DebuggerSupport))
Callbacks->moduleImport(ModuleImportLoc, ModuleImportPath, Imported);
}
}
+void Preprocessor::makeModuleVisible(Module *M, SourceLocation Loc) {
+ if (VisibleModules.isVisible(M))
+ return;
+
+ VisibleModules.setVisible(
+ M, Loc, [](Module *) {},
+ [&](ArrayRef<Module *> Path, Module *Conflict, StringRef Message) {
+ // FIXME: Include the path in the diagnostic.
+ // FIXME: Include the import location for the conflicting module.
+ Diag(ModuleImportLoc, diag::warn_module_conflict)
+ << Path[0]->getFullModuleName()
+ << Conflict->getFullModuleName()
+ << Message;
+ });
+
+ // Add this module to the imports list of the currently-built submodule.
+ if (!BuildingSubmoduleStack.empty())
+ BuildingSubmoduleStack.back().M->Imports.push_back(M);
+}
+
bool Preprocessor::FinishLexStringLiteral(Token &Result, std::string &String,
const char *DiagnosticTag,
bool AllowMacroExpansion) {