questions regarding using addPPCallbacks

Lets say I want to add a PP callback every time the PP runs into an
InclusionDirective.
going through the docs, I find that clang::PPCallbacks has the virtual
member functions for me implement to do just that. So far so good.
Now, how to tell the PP to use my callbacks?
I came across addPPCallbacks in clang::Preprocessor.
The code already has a class that derives from ASTConsumer to add and
run the matchers.
There is also a class that derives from ASTFrontendAction that is
passed to newFrontendActionFactory to create an instance of, to be
passed to a ClangTool instance to run the action.
Now the questions:
Do i need to cerate a new FrontendAction for the PPCallbacks? If yes,
then does that mean that the inputs get lexed and parsed twice?

There is only one preprocessor instance used for each frontendaction,right?
So i need to get a hold of that instance and add my PPCallbacks there.
I went through the docs again and found that I could do that with a
clang::CompilerInstace.
Now in my class that derives from ASTFrontendAction, I figured I'm
getting the CompilerInstance, so maybe i can get the preprocessor
there:
  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef file) override
{
    Preprocessor &PP = CI.getPreprocessor();
    PP.addCallbacks(std::unique_ptr<PPCallback> PPInclusion)

    TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
    return llvm::make_unique<MyASTConsumer>(TheRewriter);
}

PPInclusio is the class that derives from clang::PPCallbacks.
But the compiler tells me "error: member access into incomplete type"
which basically means that the Preprocessor i got from
CompilerInstance is a forward declaration.
How can I actually add a preprocessor callback then?

You could do: CI.getPreprocessor().addCallbacks(…) instead. BTW, have you implemented InclusionDirective in PPInclusion?

This is how clang-move handles it: https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-move/ClangMove.cpp#L401

yes, InclusionDirective is implemented in PPInclusion.
ok, thank you.

using CI.getPreprocessor().addCallbacks(...) also gets me the same
error. it says i'm accessing an incomplete type.
I looked at clang-move. I'm using the exact same methods but im still
having problems with forward declaration of Preprocessor. could this
problem be cause by the fact that I'm putting everything in a cpp file
and i have no header?

Did you #include “clang/Lex/Preprocessor.h”?

no. that solved the issue. thank you.
i thought since I'm already running matchers, the Preprocessor is
being included anyways somewhere so i don't need to explicitly include
it...