[PATCH] D25406: Fix doubled whitespace in modernize-use-auto fixit

Malcolm Parsons via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 12 12:57:30 PDT 2016


malcolm.parsons added inline comments.


================
Comment at: clang-tidy/modernize/UseAutoCheck.cpp:378
+      Lexer::getLocForEndOfToken(Range.getEnd(), 0, SM, Context->getLangOpts());
+  bool Whitespace = isWhitespace(*FullSourceLoc(Next, SM).getCharacterData());
+
----------------
aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > malcolm.parsons wrote:
> > > > aaron.ballman wrote:
> > > > > Oye, this is deceptively expensive because you now have to go back to the actual source file for this information. That source file may live on a network share somewhere, for instance.
> > > > > 
> > > > > Can you use `Token::hasLeadingSpace()` instead?
> > > > > 
> > > > > Also, doesn't this still need to care about the `RemoveStars` option?
> > > > Where would I get a Token from?
> > > Hrm, might not be as trivial as I was hoping (I thought we had a way to go from a `SourceLocation` back to a `Token`, but I'm not seeing one off-hand). Regardless, I worry about the expense of going all the way back to the source for this.
> > > 
> > > @alexfh -- should this functionality be a part of a more general "we've made a fixit, now make it not look ugly?" pass? At least then, if we go back to the source, we can do it in a more controlled manner and hopefully get some performance back from that.
> > `LineIsMarkedWithNOLINT` is going to read the source anyway, so I don't see any additional expense.
> The additional expense comes from many checks needing similar functionality -- generally, fixit replacements are going to require formatting modifications of some sort. It's better to handle all of those in the same place and transparently rather than have every check with a fixit manually handle formatting. Additionally, this means we can go back to the source as infrequently as possible.
I ran strace -c on clang-tidy on several real world source files that modernize-use-auto warns about before and after this change and the counts for read, write, stat, open, close, openat and fstat syscalls were all unchanged.
The expense is exactly zero.
It will still be zero when multiplied by many checks.
There is no performance issue here.
Do you have any other issues with this change?


https://reviews.llvm.org/D25406





More information about the cfe-commits mailing list