HOW TO GET smallest AST

a cpp like this:
int mian()

when I get the AST of this cpp,
All the decl identify .. in stdio.h
included in the AST.

How Can I get The AST only contain decl I wrote or used.

You can’t, the AST is built from the preprocessed file. In this specific case you could get away with it by providing a printf declaration and not including stdio.h but this solution doesn’t really scale.

Could you not use the SourceLocation to work out if the declaration was in the main file?

if the "printf" used decl or something in another .h.

you can use clang-check -ast-dump -ast-dump-filter= (or use -ast-list to show what is filterable)

What I want is not just looks like.

I need the real small AST .

thanks for your reply