JonasToth added inline comments.

================
Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:22
+  if (getLangOpts().CPlusPlus)
+    Finder->addMatcher(gotoStmt().bind("goto"), this);
+}
----------------
aaron.ballman wrote:
> JonasToth wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > Are you planning to add the exception listed in the C++ Core Guideline? 
> > > > It makes an explicit exception allowing you to jump forward out of a 
> > > > loop construct.
> > > What should this check do with indirect goto statements (it's a GCC 
> > > extension we support where you can jump to an expression)?
> > > 
> > > Regardless, there should be a test for indirect gotos and jump forward 
> > > out of loop constructs.
> > > Are you planning to add the exception listed in the C++ Core Guideline? 
> > > It makes an explicit exception allowing you to jump forward out of a loop 
> > > construct.
> > 
> > I do plan for this. Because I dont have any experience with gotos I wanted 
> > to do it in small steps.
> > 
> > > What should this check do with indirect goto statements (it's a GCC 
> > > extension we support where you can jump to an expression)?
> > Iam not aware of these :) 
> >> What should this check do with indirect goto statements (it's a GCC 
> >> extension we support where you can jump to an expression)?
> >
> > Iam not aware of these :)
> 
> https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
> (and a good reference on why these are interesting: 
> https://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables)
I would think that this is a special feature that will only be used if you know 
what you are doing. So it should be allowed with configuration. I am not sure 
about the default though. For now it is ignored.

HICPP has a rule on gotos as well, which states that only forward jumps are 
allowed.

I think that these different approaches to `goto` should land here sometime as 
different configurations.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to