[cfe-commits] r146994 - in /cfe/trunk: include/clang/Serialization/ASTDeserializationListener.h include/clang/Serialization/ASTWriter.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp test/Modules/Inputs/redecl-merge-right.h test/Modules/Inputs/redecl-merge-top-explicit.h
Douglas Gregor
dgregor at apple.com
Tue Dec 20 14:06:13 PST 2011
Author: dgregor
Date: Tue Dec 20 16:06:13 2011
New Revision: 146994
URL: http://llvm.org/viewvc/llvm-project?rev=146994&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/Inputs/redecl-merge-right.h
cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h
Modified: cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h?rev=146994&r1=146993&r2=146994&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h Tue Dec 20 16:06:13 2011
@@ -48,6 +48,9 @@
/// \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) { }
};
Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=146994&r1=146993&r2=146994&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Dec 20 16:06:13 2011
@@ -671,6 +671,7 @@
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.
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=146994&r1=146993&r2=146994&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Dec 20 16:06:13 2011
@@ -2487,8 +2487,14 @@
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);
+ }
+ }
}
}
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=146994&r1=146993&r2=146994&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Dec 20 16:06:13 2011
@@ -1660,8 +1660,9 @@
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 @@
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;
Modified: cfe/trunk/test/Modules/Inputs/redecl-merge-right.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/redecl-merge-right.h?rev=146994&r1=146993&r2=146994&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/redecl-merge-right.h (original)
+++ cfe/trunk/test/Modules/Inputs/redecl-merge-right.h Tue Dec 20 16:06:13 2011
@@ -21,3 +21,7 @@
void push_back(const T&);
};
#endif
+
+int ONE;
+__import_module__ redecl_merge_top.Explicit;
+const int one = ONE;
Modified: cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h?rev=146994&r1=146993&r2=146994&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h (original)
+++ cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h Tue Dec 20 16:06:13 2011
@@ -3,3 +3,5 @@
int *explicit_func(void);
struct explicit_struct { int member; };
+
+#define ONE 1
More information about the cfe-commits
mailing list