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

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:

[=](const Stmt *stmt) → bool {
const UnaryOperator *UO = cast(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?



cfg-add-stmt-predicate.patch (1.28 KB)