Header Pasting and ASTMatchers

I have an ASTFronendAction that runs some matchers and has some PPCallbacks.
Ever since i added the PPCallbacks, I'm getting the AST of a source
file that has the headers actually pasted at the top of it, so if
something's in an included file, i'm matching it twice.
is there a way to check for that when a MatchFinder::Callback is
called or is there a way to tell the Preprocessor to not paste the
headers at the top of the source files that included them?

You shouldn't be seeing the AST twice. Can you show the code where you
set up PPCallbacks?

this is the ASTConsumer:
class MyFrontendAction : public ASTFrontendAction
  MyFrontendAction() {}

  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef file) override

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

  Rewriter TheRewriter;

here's the class containing the callbacks:
class PPInclusion : public PPCallbacks
  explicit PPInclusion (SourceManager *SM) : SM(*SM) {}

  /*bunch of callbacks here*/

  const SourceManager &SM;

also the same is true for PPCallbacks.
what i mean is, if for example, i have a macro in a file that's
included in another file, i see the macro twice. and the
SourceLocation also tells me that the macro's are both in file A and
the file that included File A.
For ASTMatchers in MatchFinder::MatchCallback, the SourcLocation says
that the two copies are in the same header file. My only proof for
this one is that it is being matched twice. And I've tried my theory
for other MatchFinderCallbacks as well. They all act like this now. as
soon as there is a match in the header file, it is matched twice(it is
matched twice since the header file is only included in one other
The Code is from an open-source project on Github.
Would you like me to provide a link?

ok, problem solved.
turns out it was happening because there is something wrong with the
compilation database.
i started using a compilation databse for the test codes and that was
the problem, not the PPCallbacks.
if i just call the tool with `--` instead of using my compilation
database, i wont see the headers twice.
the headers have inclusion guards so not sure why that's happening but
anyways, the problem was my CMake file.
thanks for your time.