summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Lex/Preprocessor.h6
-rw-r--r--clang/lib/Lex/Preprocessor.cpp7
-rw-r--r--clang/test/Modules/Inputs/PR28438/a.h1
-rw-r--r--clang/test/Modules/Inputs/PR28438/b1.h2
-rw-r--r--clang/test/Modules/Inputs/PR28438/b2.h0
-rw-r--r--clang/test/Modules/Inputs/PR28438/module.modulemap2
-rw-r--r--clang/test/Modules/pr28438.cpp9
7 files changed, 26 insertions, 1 deletions
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 000df6647fe..66ff490de14 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -398,6 +398,8 @@ class Preprocessor : public RefCountedBase<Preprocessor> {
ModuleMacroInfo *getModuleInfo(Preprocessor &PP,
const IdentifierInfo *II) const {
+ if (II->isOutOfDate())
+ PP.updateOutOfDateIdentifier(const_cast<IdentifierInfo&>(*II));
// FIXME: Find a spare bit on IdentifierInfo and store a
// HasModuleMacros flag.
if (!II->hasMacroDefinition() ||
@@ -653,6 +655,8 @@ class Preprocessor : public RefCountedBase<Preprocessor> {
};
DeserializedMacroInfoChain *DeserialMIChainHead;
+ void updateOutOfDateIdentifier(IdentifierInfo &II) const;
+
public:
Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts,
DiagnosticsEngine &diags, LangOptions &opts,
@@ -900,6 +904,8 @@ public:
/// \brief Get the list of leaf (non-overridden) module macros for a name.
ArrayRef<ModuleMacro*> getLeafModuleMacros(const IdentifierInfo *II) const {
+ if (II->isOutOfDate())
+ updateOutOfDateIdentifier(const_cast<IdentifierInfo&>(*II));
auto I = LeafModuleMacros.find(II);
if (I != LeafModuleMacros.end())
return I->second;
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index f0d68725462..73039373824 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -618,6 +618,11 @@ static diag::kind getFutureCompatDiagKind(const IdentifierInfo &II,
"Keyword not known to come from a newer Standard or proposed Standard");
}
+void Preprocessor::updateOutOfDateIdentifier(IdentifierInfo &II) const {
+ assert(II.isOutOfDate() && "not out of date");
+ getExternalSource()->updateOutOfDateIdentifier(II);
+}
+
/// HandleIdentifier - This callback is invoked when the lexer reads an
/// identifier. This callback looks up the identifier in the map and/or
/// potentially macro expands it or turns it into a named token (like 'for').
@@ -642,7 +647,7 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) {
if (&II == Ident__VA_ARGS__)
CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
- ExternalSource->updateOutOfDateIdentifier(II);
+ updateOutOfDateIdentifier(II);
Identifier.setKind(II.getTokenID());
if (&II == Ident__VA_ARGS__)
diff --git a/clang/test/Modules/Inputs/PR28438/a.h b/clang/test/Modules/Inputs/PR28438/a.h
new file mode 100644
index 00000000000..a7e26ac6cdb
--- /dev/null
+++ b/clang/test/Modules/Inputs/PR28438/a.h
@@ -0,0 +1 @@
+#define FOO
diff --git a/clang/test/Modules/Inputs/PR28438/b1.h b/clang/test/Modules/Inputs/PR28438/b1.h
new file mode 100644
index 00000000000..262976e357f
--- /dev/null
+++ b/clang/test/Modules/Inputs/PR28438/b1.h
@@ -0,0 +1,2 @@
+#define FOO
+#include "a.h"
diff --git a/clang/test/Modules/Inputs/PR28438/b2.h b/clang/test/Modules/Inputs/PR28438/b2.h
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/clang/test/Modules/Inputs/PR28438/b2.h
diff --git a/clang/test/Modules/Inputs/PR28438/module.modulemap b/clang/test/Modules/Inputs/PR28438/module.modulemap
new file mode 100644
index 00000000000..cb77d47b6ce
--- /dev/null
+++ b/clang/test/Modules/Inputs/PR28438/module.modulemap
@@ -0,0 +1,2 @@
+module A { header "a.h" export * }
+module B { module B1 { header "b1.h" export * } module B2 { header "b2.h" export * } }
diff --git a/clang/test/Modules/pr28438.cpp b/clang/test/Modules/pr28438.cpp
new file mode 100644
index 00000000000..b8b9077046a
--- /dev/null
+++ b/clang/test/Modules/pr28438.cpp
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fmodules -fmodules-cache-path=%t -I%S/Inputs/PR28438 -fimplicit-module-maps
+
+#include "a.h"
+#include "b2.h"
+
+#pragma clang __debug macro FOO
+
+FOO // xpected-no-diagnostics
OpenPOWER on IntegriCloud