Hi all,
i have a question. This Code finds all For-Loop in a Cpp-File and gives LIKWID_MARKER_START(); and LIKWID_MARKER_STOP(); as output.
Now i want to search inside a for loop for nested for loops if this will find a nested forloop i dont want to set the text.
i just want to set the text in the outer for loop, not the inner for loop.
How i can do that in clang?
bool VisitStmt(Stmt *s) {
if (isa(s))
{
ForStmt *ForStatement = cast(s);
SourceLocation ST = ForStatement->getSourceRange().getBegin();
stringstream SSBefore;
SSBefore << “LIKWID_MARKER_START();\n”;
TheRewriter.InsertText(ST, SSBefore.str(), true, true);
stringstream SSAfter;
ST = ForStatement->getLocEnd().getLocWithOffset(1);
SSAfter << “\nLIKWID_MARKER_STOP();”;
TheRewriter.InsertText(ST, SSAfter.str(), true, true);
}
}
Bye
Anja