Hi
We use the VisitStmt function and there is a specific statement that we get only a partial of the line.
this is the line that we get only a partial stament of that:
CAutoPtr< CBENode > pNew( new CBENode );
after we print the line that we get in the VisitStmt function we get only the CAutoPtr<
but the strange thing is that when we change this line to:
CAutoPtr<CBENode> pNew = CAutoPtr<CBENode> temp(new CBENode())
we get the entire statement perfectly.
Can someone please explain why this is happening
We use clang version 14
P.S. we also see that in other places in the code but this one we succeeded to narrow it down
This is how we create the AST and the source files relevant
main.cpp
ASTUnit* astUnit = ASTUnit::LoadFromCommandLine(files, endOfArgsVec, astCI.getPCHContainerOperations(), &astCI.getDiagnostics(), StringRef(astCI.getHeaderSearchOpts().ResourceDir));
StmtVisitor.cpp
string printPretty(Stmt* stmt, SourceManager* SM) {
if (stmt != NULL)
{
SourceRange sr = stmt->getSourceRange();
string text = Lexer::getSourceText(CharSourceRange::getTokenRange(sr), *SM, LangOptions(), 0).str();
if (text.size() > 0 && (text.at(text.size() - 1) == ',')) //the text can be ""
return Lexer::getSourceText(CharSourceRange::getCharRange(stmt->getSourceRange()), *SM, LangOptions(), 0).str();
return text;
}
return "";
}
bool StmtVisitor::VisitStmt(Stmt* s) {
string stmt = printPretty(s, &TheRewriter.getSourceMgr());
cout << stmt << endl;
}