HelpText<"Disable generation of rtti information">;
def fno_validate_pch : Flag<"-fno-validate-pch">,
HelpText<"Disable validation of precompiled headers">;
+def dump_deserialized_pch_decls : Flag<"-dump-deserialized-decls">,
+ HelpText<"Dump declarations that are deserialized from PCH, for testing">;
def fshort_wchar : Flag<"-fshort-wchar">,
HelpText<"Force wchar_t to be a short unsigned int">;
def fshort_enums : Flag<"-fshort-enums">,
/// \brief When true, disables most of the normal validation performed on
/// precompiled headers.
bool DisablePCHValidation;
-
+
+ /// \brief Dump declarations that are deserialized from PCH, for testing.
+ bool DumpDeserializedPCHDecls;
+
/// \brief If non-zero, the implicit PCH include is actually a precompiled
/// preamble that covers this number of bytes in the main source file.
///
public:
PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
DisablePCHValidation(false),
+ DumpDeserializedPCHDecls(false),
PrecompiledPreambleBytes(0, true),
RetainRemappedFileBuffers(false) { }
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Parse/ParseAST.h"
+#include "clang/Serialization/ASTDeserializationListener.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
+namespace {
+
+/// \brief Dumps deserialized declarations.
+class DeserializedDeclsDumper : public ASTDeserializationListener {
+ ASTDeserializationListener *Previous;
+
+public:
+ DeserializedDeclsDumper(ASTDeserializationListener *Previous)
+ : Previous(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);
+ }
+
+ virtual void SetReader(ASTReader *Reader) {}
+ virtual void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) {}
+ virtual void TypeRead(serialization::TypeIdx Idx, QualType T) {}
+ virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
+ virtual void MacroDefinitionRead(serialization::MacroID,
+ MacroDefinition *MD) {}
+};
+
+} // end anonymous namespace
+
FrontendAction::FrontendAction() : Instance(0) {}
FrontendAction::~FrontendAction() {}
/// Use PCH?
if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
assert(hasPCHSupport() && "This action does not have PCH support!");
+ ASTDeserializationListener *DeserialListener
+ = CI.getInvocation().getFrontendOpts().ChainedPCH ?
+ Consumer->GetASTDeserializationListener() : 0;
+ if (CI.getPreprocessorOpts().DumpDeserializedPCHDecls)
+ DeserialListener = new DeserializedDeclsDumper(DeserialListener);
CI.createPCHExternalASTSource(
CI.getPreprocessorOpts().ImplicitPCHInclude,
CI.getPreprocessorOpts().DisablePCHValidation,
- CI.getInvocation().getFrontendOpts().ChainedPCH?
- Consumer->GetASTDeserializationListener() : 0);
+ DeserialListener);
if (!CI.getASTContext().getExternalSource())
goto failure;
}