summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPLexerChange.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-04-23 23:29:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-04-23 23:29:05 +0000
commit50474bf5d2356feab24d985cac3ea91f856df59b (patch)
tree0936843b327d846c0a5f6775361e71e7bb5768ba /clang/lib/Lex/PPLexerChange.cpp
parent43fb8a157b270e70d553231c8561a2efd012c774 (diff)
downloadbcm5719-llvm-50474bf5d2356feab24d985cac3ea91f856df59b.tar.gz
bcm5719-llvm-50474bf5d2356feab24d985cac3ea91f856df59b.zip
[modules] Refactor creation of ModuleMacros and create them when importing from local submodules.
llvm-svn: 235669
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r--clang/lib/Lex/PPLexerChange.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index 8a74a95ab3a..6cffbc39855 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -609,9 +609,9 @@ void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
assert(!FoundLexer && "Lexer should return EOD before EOF in PP mode");
}
-void Preprocessor::EnterSubmodule(Module *M) {
+void Preprocessor::EnterSubmodule(Module *M, SourceLocation ImportLoc) {
// Save the current state for future imports.
- BuildingSubmoduleStack.push_back(BuildingSubmoduleInfo(M));
+ BuildingSubmoduleStack.push_back(BuildingSubmoduleInfo(M, ImportLoc));
auto &Info = BuildingSubmoduleStack.back();
// Copy across our macros and start the submodule with the current state.
@@ -630,6 +630,7 @@ void Preprocessor::LeaveSubmodule() {
// This module may have exported a new macro. If so, create a ModuleMacro
// representing that fact.
bool ExplicitlyPublic = false;
+ ModuleMacro *MM = nullptr;
for (auto *MD = Macro.second.getLatest(); MD != State.getLatest();
MD = MD->getPrevious()) {
// Skip macros defined in other submodules we #included along the way.
@@ -653,8 +654,8 @@ void Preprocessor::LeaveSubmodule() {
// FIXME: Issue a warning if multiple headers for the same submodule
// define a macro, rather than silently ignoring all but the first.
bool IsNew;
- addModuleMacro(Info.M, II, Def, Macro.second.getOverriddenMacros(),
- IsNew);
+ MM = addModuleMacro(Info.M, II, Def, Macro.second.getOverriddenMacros(),
+ IsNew);
break;
}
}
@@ -664,6 +665,12 @@ void Preprocessor::LeaveSubmodule() {
// Restore the old macro state.
Macro.second = State;
+
+ // If our submodule defined a macro, import it.
+ // FIXME: Do this lazily.
+ if (MM)
+ appendMacroDirective(II,
+ AllocateImportedMacroDirective(MM, Info.ImportLoc));
}
BuildingSubmoduleStack.pop_back();
OpenPOWER on IntegriCloud