Hi all,
Playing around with the plugin (in the hope of eventually using it to
find out interesting things in the LibreOffice code base), I'm not sure
I'm trying to use it in a sensible manner. Maybe somebody on this list
can set me on track?
As a first experiment, I wanted to do the following: LO has a string
class rtl::OUString with member functions getLength and isEmpty. Now, I
wanted to find places in the code that call getLength and check the
result against null, instead of calling isEmpty directly.
My first doubt is whether doing that at Gimple-level is practical at all
(and whether the plugin would also support doing it at another, more
appropriate level that is closer to the original AST)?
I figure I need to find GimpleCall statements that call
rtl::OUString::getLength and trace their lhs variables (potentially
through further GimpleAssign statements) to GimpleCond statements.
Something like
class TryOut(gcc.GimplePass):
def execute(self, fun):
for bb in fun.cfg.basic_blocks:
if bb.gimple:
for stmt in bb.gimple:
print ' stmt:', stmt
if isinstance(stmt, gcc.GimpleCall):
name = stmt.fndecl.name
# ...
elif isinstance(stmt, gcc.GimpleAssign):
# ...
elif isinstance(stmt, gcc.GimpleCond):
# ...
But the first obstacle is already how to determine the full name of the
called function, as stmt.fndecl.name would only be "getLength", without
the class and namespace information.
Any pointers appreciated,
Stephan