【发布时间】:2015-12-29 15:42:58
【问题描述】:
我想在使用 Clang 的变量声明之后写一个注释。
我尝试使用 getLocEnd 函数:
void PreprocessConsumer::WriteId(clang::VarDecl *vd)
{
auto location = vd->getLocEnd();
_rewriter.InsertTextAfterToken(location, "//My label");
_rewriter.overwriteChangedFiles();
}
对于这个输入
void f (int n)
{
float x[10];
}
它在分号前添加注释:
void f (int n)
{
float x[10]//My label;
}
但我想让 Clang 在分号后写如下注释:
void f (int n)
{
float x[10];//My label
}
【问题讨论】:
标签: c++ clang abstract-syntax-tree