[PATCH] D156254: [clang][dataflow] Add convenience function for analysing and `FunctionDecl` and diagnosing it.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 26 07:40:50 PDT 2023


ymandel marked 3 inline comments as done.
ymandel added inline comments.


================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h:261-265
+  using ::llvm::Expected;
+
+  Expected<ControlFlowContext> Context = ControlFlowContext::build(FuncDecl);
+  if (!Context)
+    return Context.takeError();
----------------
mboehme wrote:
> 
Nice! I wasn't aware of `moveInto`. Sadly, though, it doesn't work because CFC lacks a default constructor.


================
Comment at: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:101-103
+  auto Diagnoser = [&Count](const CFGElement &, ASTContext &,
+                            const TransferStateForDiagnostics<NoopLattice> &) {
+    return std::vector<int>({++Count});
----------------
mboehme wrote:
> I think this gives us a stronger and more explicit check for little extra effort.
Agreed! Great suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156254



More information about the cfe-commits mailing list