Hi Clang Experts, could you kindly advice how to get location of a function *name* when visiting FunctionDecl in RecursiveASTVisitor (getBeginLoc and getEndLoc return the whole range for the definition, not just the name). Example:
For source code like this: int f(int x) { return x + 1; } this is the current code bool VisitFunctionDecl(clang::FunctionDecl *FD) { clang::ASTContext &context = FD->getASTContext(); int begin = context.getFullLoc(FD->getBeginLoc()).getFileOffset(); int end = context.getFullLoc(FD->getEndLoc()).getFileOffset(); std::string path = context.getFullLoc(FD->getBeginLoc()).getFileEntry()->getName().str(); . .. } will give offsets [0,29], but I'd like to get the location of the "f", i.e. [5-6]. Thanks! Sterling.
_______________________________________________ cfe-users mailing list cfe-users@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users