[cfe-commits] r143241 - /cfe/trunk/lib/Frontend/FrontendAction.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Oct 28 15:54:31 PDT 2011
Author: akirtzidis
Date: Fri Oct 28 17:54:31 2011
New Revision: 143241
URL: http://llvm.org/viewvc/llvm-project?rev=143241&view=rev
Log:
Make -error-on-deserialized-decl work correctly by correctly delegating to
the previous ASTDeserializationListener.
Modified:
cfe/trunk/lib/Frontend/FrontendAction.cpp
Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=143241&r1=143240&r2=143241&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Fri Oct 28 17:54:31 2011
@@ -30,37 +30,70 @@
namespace {
-/// \brief Dumps deserialized declarations.
-class DeserializedDeclsDumper : public ASTDeserializationListener {
+class DelegatingDeserializationListener : public ASTDeserializationListener {
ASTDeserializationListener *Previous;
public:
- DeserializedDeclsDumper(ASTDeserializationListener *Previous)
+ explicit DelegatingDeserializationListener(
+ ASTDeserializationListener *Previous)
: Previous(Previous) { }
+ virtual void ReaderInitialized(ASTReader *Reader) {
+ if (Previous)
+ Previous->ReaderInitialized(Reader);
+ }
+ virtual void IdentifierRead(serialization::IdentID ID,
+ IdentifierInfo *II) {
+ if (Previous)
+ Previous->IdentifierRead(ID, II);
+ }
+ virtual void TypeRead(serialization::TypeIdx Idx, QualType T) {
+ if (Previous)
+ Previous->TypeRead(Idx, T);
+ }
+ virtual void DeclRead(serialization::DeclID ID, const Decl *D) {
+ if (Previous)
+ Previous->DeclRead(ID, D);
+ }
+ virtual void SelectorRead(serialization::SelectorID ID, Selector Sel) {
+ if (Previous)
+ Previous->SelectorRead(ID, Sel);
+ }
+ virtual void MacroDefinitionRead(serialization::PreprocessedEntityID PPID,
+ MacroDefinition *MD) {
+ if (Previous)
+ Previous->MacroDefinitionRead(PPID, MD);
+ }
+};
+
+/// \brief Dumps deserialized declarations.
+class DeserializedDeclsDumper : public DelegatingDeserializationListener {
+public:
+ explicit DeserializedDeclsDumper(ASTDeserializationListener *Previous)
+ : DelegatingDeserializationListener(Previous) { }
+
virtual void DeclRead(serialization::DeclID ID, const Decl *D) {
llvm::outs() << "PCH DECL: " << D->getDeclKindName();
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
llvm::outs() << " - " << ND->getNameAsString();
llvm::outs() << "\n";
- if (Previous)
- Previous->DeclRead(ID, D);
+ DelegatingDeserializationListener::DeclRead(ID, D);
}
};
/// \brief Checks deserialized declarations and emits error if a name
/// matches one given in command-line using -error-on-deserialized-decl.
- class DeserializedDeclsChecker : public ASTDeserializationListener {
+ class DeserializedDeclsChecker : public DelegatingDeserializationListener {
ASTContext &Ctx;
std::set<std::string> NamesToCheck;
- ASTDeserializationListener *Previous;
public:
DeserializedDeclsChecker(ASTContext &Ctx,
const std::set<std::string> &NamesToCheck,
ASTDeserializationListener *Previous)
- : Ctx(Ctx), NamesToCheck(NamesToCheck), Previous(Previous) { }
+ : DelegatingDeserializationListener(Previous),
+ Ctx(Ctx), NamesToCheck(NamesToCheck) { }
virtual void DeclRead(serialization::DeclID ID, const Decl *D) {
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
@@ -72,8 +105,7 @@
<< ND->getNameAsString();
}
- if (Previous)
- Previous->DeclRead(ID, D);
+ DelegatingDeserializationListener::DeclRead(ID, D);
}
};
More information about the cfe-commits
mailing list