When we make a previously-deserialized module definition visible,

notify the AST deserialization listener so that the AST writer knows
that it can write the macro definition.

llvm-svn: 146994
This commit is contained in:
Douglas Gregor 2011-12-20 22:06:13 +00:00
parent a1745c24c4
commit 0abc262b02
6 changed files with 24 additions and 3 deletions

View File

@ -48,6 +48,9 @@ public:
/// \brief A macro definition was read from the AST file.
virtual void MacroDefinitionRead(serialization::PreprocessedEntityID,
MacroDefinition *MD) { }
/// \brief A macro definition that had previously been deserialized
/// (and removed via IdentifierRead) has now been made visible.
virtual void MacroVisible(IdentifierInfo *II) { }
/// \brief A module definition was read from the AST file.
virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) { }
};

View File

@ -671,6 +671,7 @@ public:
void SelectorRead(serialization::SelectorID ID, Selector Sel);
void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinition *MD);
void MacroVisible(IdentifierInfo *II);
void ModuleRead(serialization::SubmoduleID ID, Module *Mod);
// ASTMutationListener implementation.

View File

@ -2487,8 +2487,14 @@ void ASTReader::makeNamesVisible(const HiddenNames &Names) {
for (unsigned I = 0, N = Names.size(); I != N; ++I) {
if (Decl *D = Names[I].dyn_cast<Decl *>())
D->ModulePrivate = false;
else
Names[I].get<IdentifierInfo *>()->setHasMacroDefinition(true);
else {
IdentifierInfo *II = Names[I].get<IdentifierInfo *>();
if (!II->hasMacroDefinition()) {
II->setHasMacroDefinition(true);
if (DeserializationListener)
DeserializationListener->MacroVisible(II);
}
}
}
}

View File

@ -1660,8 +1660,9 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
for (Preprocessor::macro_iterator I = PP.macro_begin(Chain == 0),
E = PP.macro_end(Chain == 0);
I != E; ++I) {
const IdentifierInfo *Name = I->first;
if (!IsModule || I->second->isPublic()) {
MacroDefinitionsSeen.insert(I->first);
MacroDefinitionsSeen.insert(Name);
MacrosToEmit.push_back(std::make_pair(I->first, I->second));
}
}
@ -4262,6 +4263,10 @@ void ASTWriter::MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinitions[MD] = ID;
}
void ASTWriter::MacroVisible(IdentifierInfo *II) {
DeserializedMacroNames.push_back(II);
}
void ASTWriter::ModuleRead(serialization::SubmoduleID ID, Module *Mod) {
assert(SubmoduleIDs.find(Mod) == SubmoduleIDs.end());
SubmoduleIDs[Mod] = ID;

View File

@ -21,3 +21,7 @@ public:
void push_back(const T&);
};
#endif
int ONE;
__import_module__ redecl_merge_top.Explicit;
const int one = ONE;

View File

@ -3,3 +3,5 @@
int *explicit_func(void);
struct explicit_struct { int member; };
#define ONE 1