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

Valeriy Savchenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 17 00:07:58 PDT 2021


vsavchenko added inline comments.


================
Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:1729
+  handleBlockThatIsGuaranteedToBeCalledOnce(const BlockDecl *Block) override {
+    Data.flushWarnings(Block, S);
+  }
----------------
NoQ wrote:
> 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?
Exactly, function is analyzed the moment it's fully parsed.


================
Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2206
 
+sema::AnalysisBasedWarnings::~AnalysisBasedWarnings() { delete IPData; }
+
----------------
NoQ wrote:
> 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.
I definitely don't want to move `InterProceduralData` definition to the header, so value is not an option.
`std::unique_ptr` will definitely work, but we still need to move the destructor into the cpp file because of the forward declaration as far as I understand.


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