Filtering declarations based on the a file with the C API

I'm creating a tool that visits all the declarations in a file and collects some information about them. I'm only interested in the declarations that are actually written in the file and not coming from an include. I got help here doing this before with the C++ API, I'm trying to do the same thing now with the C API.

This is the code I have that uses the C++ API:

bool shouldSkipDeclaration (Decl* declaration)
     if (!declaration || declaration->getLocation().isInvalid())
         return true;

     FileID fileId = sourceManager->getFileID(declaration->getLocation());

     if (sourceManager->getMainFileID() != fileId)
         return true;

     return false;

This method is used in a class which is a subclass to ASTConsumer. "sourceManager" is the SourceManager from the ASTContext received in the "Initialize" method.

I think this is code quite old now and I don't know if it's still valid.