[PATCH] D62611: [analyzer][Dominators] Add unittests

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 13:27:47 PDT 2019


NoQ added inline comments.


================
Comment at: clang/unittests/Analysis/CFGBuilder.h:16
+
+class BuildResult {
+public:
----------------
Given that now it's in a header, i guess we need to pick a less generic name. Eg., `CFGBuildResult`.


================
Comment at: clang/unittests/Analysis/CFGBuilder.h:54
+
+inline BuildResult BuildCFG(const char *Code) {
+  CFGCallback Callback;
----------------
xazax.hun wrote:
> Do you expect the code to only contain one function? If so, you should enforce it.
I guess it sucks that we can't re-use my `findDeclByName()` helper here.


================
Comment at: clang/unittests/Analysis/CFGDominatorTree.cpp:22-28
+template <class StmtType> struct FindStmt {
+  bool operator()(const CFGElement &E) {
+    if (auto S = E.getAs<CFGStmt>())
+      return isa<StmtType>(S->getStmt());
+    return false;
+  }
+};
----------------
Why isn't this a simple function template?


================
Comment at: clang/unittests/Analysis/CFGDominatorTree.cpp:30-32
+template <class StmtType> bool hasStmtType(CFGBlock *Block) {
+  return llvm::find_if(*Block, FindStmt<SwitchStmt>()) == Block->end();
+}
----------------
`StmtType` is unused. Did you mean `FindStmt<StmtType>`?


================
Comment at: clang/unittests/Analysis/CFGDominatorTree.cpp:31
+template <class StmtType> bool hasStmtType(CFGBlock *Block) {
+  return llvm::find_if(*Block, FindStmt<SwitchStmt>()) == Block->end();
+}
----------------
This looks like "`hasNoStmtType`" to me, did you mean `!=`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62611/new/

https://reviews.llvm.org/D62611





More information about the cfe-commits mailing list