Visitor Question

Dear Sir/Madam,

I am implementing a code that typechecks C source code.
At some point in my program I used the following function in order to visit all functions and their bodies.

// Function (declaration and body) visitor.
void VisitFunctionDecl(FunctionDecl *D) {
BaseDeclVisitor::VisitFunctionDecl(D);
if (D->isThisDeclarationADefinition()) {
BaseStmtVisitor::Visit(D->getBody());

}
}

The problem that I have is that if I test a C source file that has function calls to another file which contains the declaration and body of the functions, then it does not give me back the body of these functions.
As a result it tests only functions that their body is specified in the same source file that I am testing.
Any suggestions on how can I retrieve the functions bodies of these functions that are specified in other files ?

Sincerely yours,

Socrates

Dear Sir/Madam,

I am implementing a code that typechecks C source code.
At some point in my program I used the following function in order to visit
all functions and their bodies.

      // Function (declaration and body) visitor.
      void VisitFunctionDecl(FunctionDecl *D) {
BaseDeclVisitor::VisitFunctionDecl(D);
if (D->isThisDeclarationADefinition()) {
            BaseStmtVisitor::Visit(D->getBody());

}
      }

The problem that I have is that if I test a C source file that has function
calls to another file which contains the declaration and body of the
functions, then it does not give me back the body of these functions.
As a result it tests only functions that their body is specified in the same
source file that I am testing.
Any suggestions on how can I retrieve the functions bodies of these
functions that are specified in other files ?

Clang works per-TU. You'd have to implement your own storage to
gather/inspect cross-TU facts, as far as I know.

- David