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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 8 14:39:54 PST 2018

aaron.ballman 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 "
JonasToth wrote:
> 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.
All checks may evolve over time -- this isn't a pattern I'd like to see used in this sort of case, personally.

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list