Macros 如何插入包含宏的C程序

Macros 如何插入包含宏的C程序,macros,clang,instrumentation,Macros,Clang,Instrumentation,我试图在C程序中插入所有if语句。比如说 if(condition) statement1; else statement2; 用于 if(condition) { statement1; } else { statement2; } 我有以下用于检测的代码 void MyRecursiveASTVisitor::InstrumentStmt(Stmt *s) { // Only perform if statement is not compound

我试图在C程序中插入所有if语句。比如说

if(condition)
   statement1;
else
   statement2;
用于

if(condition)
{
   statement1;
}
else
{
   statement2;
}
我有以下用于检测的代码

void MyRecursiveASTVisitor::InstrumentStmt(Stmt *s)
{
    // Only perform if statement is not compound
    SourceLocation ST = s->getLocStart();
    if (!isa<CompoundStmt>(s)) {
        //insert an opening brace if not present
        Rewrite.InsertText(ST, "{\n", true, true);
        ST = s->getLocEnd();
        ST = ST.getLocWithOffset(1);
        Rewrite.InsertText(ST, "\n}\n", true, true);
    }
    return true;
}
我得到一个断言失败

Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.

有人能解释为什么会这样吗?处理叮当声中的宏有什么特殊情况吗?

警告的定义是什么?它在你的控制之下吗?它是程序中的一个定义。我无法对程序进行预处理以删除宏,因为这样会删除所有动态定义的宏。请向我们展示它的定义。
Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.