================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:174
@@ +173,3 @@
+void RemoveVoidArg::processFieldDecl(const MatchFinder::MatchResult &Result, 
FieldDecl const *const Member) {
+    std::string const Text = getText(Result, *Member);
+    removeVoidArgumentTokens(Result, Member->getLocStart(), Text, "Redundant 
void argument list in field declaration.");
----------------
LegalizeAdulthood wrote:
> sbenza wrote:
> > LegalizeAdulthood wrote:
> > > sbenza wrote:
> > > > Any reason all of these convert the StringRef into a std::string?
> > > > Couldn't they work with the StringRef directly?
> > > I tried switching it to a StringRef, but when I tried to combine it with 
> > > other text to build a replacement for diag(), it got turned into Twine 
> > > and then failed to match any signature for diag().  I'm open to 
> > > suggestions for what you'd like to see instead.
> > Twine::str() constructs the string.
> > I don't mind constructing a string when a match happens. Those are rare.
> > But we should avoid allocating memory when no match happens.
> > Right now temporary memory allocations are a considerable part of 
> > clang-tidy's runtime. We should try to minimize that.
> I think we are at that stage now; I do all early-out testing before 
> constructing the replacement string.
You are still generating a copy of the code before re-parsing it.
Those will happen for anything that passes the matcher, even if they have no 
'void' argument.
removeVoidArgumentTokens should take the code as a StringRef directly from 
getText(), without converting to std::string first. GrammarLocation should also 
be a StringRef.
Basically, avoid std::string until you are about to call diag().

http://reviews.llvm.org/D7639

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/



_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to