[IDF] Generalize IDFCalculator to be used with Clang's CFG
authorKristof Umann <dkszelethus@gmail.com>
Tue, 2 Jul 2019 11:30:12 +0000 (11:30 +0000)
committerKristof Umann <dkszelethus@gmail.com>
Tue, 2 Jul 2019 11:30:12 +0000 (11:30 +0000)
commit9353421ecd12d071a27a0f05948113a45888f16b
tree6c23421f7ec145027540f625282c0a16829ed61c
parentbffd099d158291ecd32413093e477ed10a7b35e5
[IDF] Generalize IDFCalculator to be used with Clang's CFG

I'm currently working on a GSoC project that aims to improve the the bug reports
of the analyzer. The main heuristic I plan to use is to explain values that are
a control dependency of the bug location better.

01 bool b = messyComputation();
02 int i = 0;
03 if (b) // control dependency of the bug site, let's explain why we assume val
04        // to be true
05   10 / i; // warn: division by zero

Because of this, I'd like to generalize IDFCalculator so that I could use it for
Clang's CFG: D62883.

In detail:

* Rename IDFCalculator to IDFCalculatorBase, make it take a general CFG node
  type as a template argument rather then strictly BasicBlock (but preserve
  ForwardIDFCalculator and ReverseIDFCalculator)
* Move IDFCalculatorBase from llvm/include/llvm/Analysis to
  llvm/include/llvm/Support (but leave the BasicBlock variants in
  llvm/include/llvm/Analysis)
* clang-format the file since this patch messes up git blame anyways
* Change typedef to using
* Add the new type ChildrenGetterTy, and store an instance of it in
  IDFCalculatorBase. This is important because I'll have to specialize it for
  Clang's CFG to filter out nullpointer successors, similarly to D62507.

Differential Revision: https://reviews.llvm.org/D63389

llvm-svn: 364911
llvm/include/llvm/Analysis/IteratedDominanceFrontier.h
llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h [new file with mode: 0644]
llvm/lib/Analysis/CMakeLists.txt
llvm/lib/Analysis/IteratedDominanceFrontier.cpp [deleted file]