[PATCH] Use 'auto' with 'new' expressions
Edwin Vane
edwin.vane at intel.com
Tue Apr 2 11:52:18 PDT 2013
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:97
@@ +96,3 @@
+ // Space after 'auto' to handle styles where the pointer indicator goes
+ // next to the variable and not the type specifier.
+ Replace.insert(tooling::Replacement(SM, Range, "auto "));
----------------
Manuel Klimek wrote:
> Shouldn't formatting be done by clang-format?
It will but if the type is:
int *p
the replacement (without the space) would be:
autop
since the TypeLoc info includes the '*' as part of the source range for the type.
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:95
@@ +94,3 @@
+ TypeLoc TL = D->getTypeSourceInfo()->getTypeLoc();
+ CharSourceRange Range(TL.getSourceRange(), true);
+ // Space after 'auto' to handle styles where the pointer indicator goes
----------------
Manuel Klimek wrote:
> Sad story: I wanted to propose using /*<varname>=*/ for the second parameter, and looked up what the name of the parameter is in the CharSourceRange. Entertainingly enough it's "ITR", which doesn't help anybody reading this :(
I like this idea. In the past I've just used static const bools but the comment thing is nice.
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:104
@@ +103,3 @@
+ // If the CV qualifiers for the pointer differ then we still use auto, just
+ // need to leave the qualifier behind. S
+ if (Result.Context->hasSameUnqualifiedType(D->getType(),
----------------
Manuel Klimek wrote:
> Incomplete sentence?
Not sure what I was going to say there.
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:71
@@ +70,3 @@
+ QualType PointeeType = DeclType->getPointeeType();
+ return PointeeType.hasLocalQualifiers();
+}
----------------
Manuel Klimek wrote:
> Any reason to not put the PointeeType binding into the matcher? Seems like that would save a bunch of code.
Done.
http://llvm-reviews.chandlerc.com/D582
More information about the cfe-commits
mailing list