[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 8 12:46:54 PST 2021


xazax.hun added inline comments.


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:48
+                              << std::declval<const Lattice &>())>
+std::ostream &operator<<(std::ostream &OS,
+                         const DataflowAnalysisState<Lattice> &S) {
----------------
This would also be useful for debugging. I wonder whether utilities not strictly related to testing should be closer to the actual code, so someone wanting to use this for debugging does not need to include the header that is dedicated to the tests.


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:77
+// the files provided in `VirtualMappedFiles`.
+bool runOnCode(llvm::StringRef Code,
+               const std::function<void(ASTContext &)> &Operation,
----------------
I feel like some of our tests keep recreating lightweight versions of the LibTooling. Not really an action item for this PR, just a rant :) I hope we will have some more centralized stuff at some point. 


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:94
+template <typename AnalysisT>
+void runDataflow(
+    llvm::StringRef Code,
----------------
Since this function is actually matching the dataflow results against expectations, I wonder if something like `checkDataflow` would better describe its function. But feel free to keep the current name.


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:137
+            TypeErasedBlockStates =
+                runTypeErasedDataflowAnalysis(*cfg, Analysis, Env);
+
----------------
Wouldn't users end up calling the template (not the type erased) version of this function? I wonder if we should mimic how users would interact with the framework in the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115341



More information about the cfe-commits mailing list