Help with AST (de)serialization API

I am trying to write some code that can traverse 2 (or more) ASTs from different programs simultaneously. So far my approach has been to use “clang -emit-pch” to create serialized ASTs so that I can then traverse them at-will in my program. I am having trouble, however, successfully loading the ASTs from the PCH files. I tried instantiating an ASTReader and a derivative of ASTConsumer in order to call ASTReader::StartTranslationUnit, but when I do, the program segfaults in Allocator.cpp. Is this even the right approach?* I’ve looked into ASTUnit::LoadFromASTFile as well, but was unsure how to move forward once the AST file was loaded. Any guidance is appreciated.

  • Admittedly, I am trying to infer a lot from the Clang API documentation.

Thanks for your help,
Sam