[cfe-dev] llvm::FoldingSetNodeID to compare Stmt
Pedro Delgado Perez
pedro.delgadoperez at mail.uca.es
Sat Jan 18 04:20:30 PST 2014
Hi,
Up to now, to determine if two objects "Stmt" were the same, I have been using the function "areSameExpr", which appers at the end of this link:
http://clang.llvm.org/docs/LibASTMatchersTutorial.html [ http://clang.llvm.org/docs/LibASTMatchersTutorial.html ]
static bool areSameExpr(ASTContext *Context, const Expr *First, const Expr *Second) { if (!First || !Second) return false; llvm::FoldingSetNodeID FirstID, SecondID; First->Profile(FirstID, *Context, true); Second->Profile(SecondID, *Context, true); return FirstID == SecondID;}
However, I have a problem with that function. To illustrate the issue, I retrieve a concrete Stmt (in bold in the example below) in a CompoundStmt through a matcher:
{
A::getca();
m();
A::getca();
int l = 1;
}
Then, when handling that Stmt, I search for the position of that stmt within the compoundStmt with a simple loop and using the function "areSameExpr" aforementioned.
for(CompoundStmt::body_iterator st = CompStmt->body_begin(); st != CompStmt->body_end(); st++){
if(areSameStmt(Context, *st, StmtBound)){
....
}
}
However, this function considers that the first stmt in the compoundStmt is the same as the third one, and that is a problem in my case because I need to determine every stmt as unique to know the position.
I have been studying the class llvm::FoldingSetNodeID
http://llvm.org/docs/doxygen/html/classllvm_1_1FoldingSetNodeID.html#a66f5b8a0b6a74b310d856ca736c1eb8c [ http://llvm.org/docs/doxygen/html/classllvm_1_1FoldingSetNodeID.html#a66f5b8a0b6a74b310d856ca736c1eb8c ]
I tried to use the method "ComputeHash" to compare both stmt, but it didn't suppose any change.
Please, does anyone know how I could fix this?
Thanks,
Pedro.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140118/c9742ed8/attachment.html>
More information about the cfe-dev
mailing list