0

Hello I'm working with clang libtooling. I need to take a .c file and print the names of all functions present and the lines the function declaration is in. In the ASTRecursive class I have function VisitFunctionDecl and have found the functions but am very confused how to find the line number of the Stmts.

Awaid Shaheen
  • 95
  • 1
  • 9

1 Answers1

1

Given a FunctionDecl *f, f->getSourceRange() is its source range (beginning and end). Given a SourceRange sr, sr.getBegin() gives you a SourceLocation which is the beginning of the range.

Look up the documentation / declarations of the classes mentioned for more details.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412