[PATCH] D144730: [FlowSensitive] Log analysis progress for debugging purposes

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 22 10:09:59 PDT 2023


sammccall added inline comments.


================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:186
+  Logger &logger() const {
+    return DACtx->getOptions().Log ? *DACtx->getOptions().Log : Logger::null();
+  }
----------------
xazax.hun wrote:
> If we already have a `NullLogger`, I wonder if making `DACtx->getOptions().Log` a reference that points to NullLogger when logging is disabled would be less confusing (and fewer branches).
Made the DataAnalysisContext constructor fill in this field with NullLogger if there isn't anything else, to avoid the branch. (Added a comment on the field).

It's still a pointer because of the ergonomic problems with ref fields in structs like this (can't initialize incrementally), and because we need a value for "no programmatic logging requested, feel free to respect the -dataflow-log flag" and using Logger::null() as a sentinel seems pretty surprising.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144730



More information about the cfe-commits mailing list