Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您好,我正在使用 clang libtooling。我需要一个 .c 文件并打印所有存在的函数的名称和函数声明所在的行。在 ASTRecursive 类中,我有函数 VisitFunctionDecl 并找到了函数,但很困惑如何找到斯坦茨。
给定 a FunctionDecl *f,f->getSourceRange()是它的源范围(开始和结束)。给定 a SourceRange sr,sr.getBegin()给你 aSourceLocation这是范围的开始。
FunctionDecl *f
f->getSourceRange()
SourceRange sr
sr.getBegin()
SourceLocation
查看所提到的类的文档/声明以获取更多详细信息。