[PATCH] D54222: [clang-tidy] Add a check to detect returning static locals in public headers

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 8 14:35:49 PST 2018


JonasToth added inline comments.


================
Comment at: clang-tidy/llvm/ProblematicStaticsCheck.cpp:33
+  const auto *VD = Result.Nodes.getNodeAs<VarDecl>("var");
+  const auto *Return = Result.Nodes.getNodeAs<ReturnStmt>("return");
+  diag(Return->getBeginLoc(), "address of static local variable %0 may not "
----------------
aaron.ballman wrote:
> JonasToth wrote:
> > Please `assert` on `VD` and `Return`
> > Please assert on VD and Return
> Why?
because the matcher might evolve over time. Right now this can not be triggered, that is correct. Asking for it was  inappropriate but having it doesn't hurt.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54222





More information about the cfe-commits mailing list