[PATCH] D98688: [-Wcalled-once-parameter] Harden analysis in terms of block use

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 21:16:12 PDT 2021


NoQ added inline comments.


================
Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:1729
+  handleBlockThatIsGuaranteedToBeCalledOnce(const BlockDecl *Block) override {
+    Data.flushWarnings(Block, S);
+  }
----------------
Do i understand correctly that you're relying on the order in which your analysis is invoked from Sema? I.e., Sema parses the inner block before the outer function, so it'll analyze the block first, so by the time you see a block expression in the surrounding function you'll already have all diagnostics for the block readily available and no other diagnostics will ever show up, right?


================
Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2206
 
+sema::AnalysisBasedWarnings::~AnalysisBasedWarnings() { delete IPData; }
+
----------------
Do we really need manual new-delete here? Ownership semantics don't seem to be that complicated, a `unique_ptr` would probably suffice. Or maybe even just store it by value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98688



More information about the cfe-commits mailing list