[cfe-dev] [RFC] Extending CFG::BuildOptions::alwaysAdd for user-defined predicates

Meador Inge via cfe-dev cfe-dev at lists.llvm.org
Fri Feb 12 10:34:31 PST 2016


Hi All,

I am working with some code that needs a finer granularity
of control when deciding how the CFGBuilder breaks up
statements in the CFG block.  Since the current implementation
is limited to 'StmtClass's it is impossible to control individual
operations within a 'StmtClass'.

I was thinking about modifying CFG::BuildOptions to be accept
predicates.  Something like the attached.  Then one could write
code like:

  setAddPredicate(Stmt::UnaryOperatorClass,
                                                [=](const Stmt *stmt) ->
bool {
                                                  const UnaryOperator *UO =
cast<UnaryOperator>(stmt);
                                                  return UO->getOpcode() ==
UO_PreInc;
                                                });


I wanted to float the idea first before submitting a patch.

Any comments on this approach?  Is this something others find useful?

Cheers,

Meador
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160212/776d91ae/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfg-add-stmt-predicate.patch
Type: application/octet-stream
Size: 1306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160212/776d91ae/attachment.obj>


More information about the cfe-dev mailing list