[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 15:20:56 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:
> > 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.
I don't insist.

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list