This adds unit tests for the PostOrderCFGView class which will be
used as part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.
Details
Details
- Reviewers
ymandel xazax.hun gribozavr2
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Looks good, but why split the test into its own directory? I see that the implementation file is in clang/lib/Analysis and, in general, the lib and unittest directories are often flatter than the corresponding include directories. Maybe just put it directly into unittests/Analysis?
Comment Actions
I don't have strong opinions, just some small preferences, feel free to ignore them:
- Using ASTMatchers feels a bit heavy weight for this task to me. Simply enumerating the function definitions in the TranslationUnitDecl should be sufficient for these tests.
- The tests might be a bit too strict, but this might be by design. In fact, there are more than one (reverse) post orders traversals of the same Cfg. Do we want to bake that particular order into the tests? This makes it harder to do changes but makes sure the tests notify us about such changes. Alternatively, we could do property-based testing, and verify that the view has the fundamental property we are interested in. Namely, if we visit nodes in the right order, we always visit all the predecessors of a node first (before visiting the node itself). Property-based tests are resilient to changes in which order we pick, and they can also make it somewhat easier to write tests (we no longer need to know about basic block IDs).
clang/unittests/Analysis/Analyses/PostOrderCFGViewTest.cpp | ||
---|---|---|
23 | We could use using namespace here. |
We could use using namespace here.