[PATCH] D41815: [clang-tidy] implement check for goto

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 13 08:23:53 PST 2018


JonasToth marked 3 inline comments as done.
JonasToth added inline comments.


================
Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:21
+AST_MATCHER(GotoStmt, isForwardJumping) {
+  return Node.getLocStart() < Node.getLabel()->getLocStart();
+}
----------------
lebedev.ri wrote:
> JonasToth wrote:
> > lebedev.ri wrote:
> > > Hm, on a second thought, i think this will have false-positive if the label and the goto are on the same line, like
> > > ```
> > > goto label; ; label: ; 
> > > ```
> > > I wonder we could **easily** compare accounting for the position in the line, or it is not worth the extra complexity.
> > Iam not sure what you mean. Is the concern that the `goto` does not actually skip something?
> > If yes it is still worth it, because its not necessary to have the `goto` then.
> > 
> > The `<` on the locations should always be sensefull because AFAIK its at byte level (or something similar).
> > 
> > Your example is diagnosed correctly.
> > The < on the locations should always be sensefull because AFAIK its at byte level (or something similar).
> Ah, great then. I had some recollections of having some issues with that before, but it makes sense that it would just work.
> 
I dont know the internals, i just assume because it works :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815





More information about the cfe-commits mailing list