[PATCH] Use 'auto' with 'new' expressions
Manuel Klimek
klimek at google.com
Tue Apr 2 06:54:33 PDT 2013
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.h:22
@@ -21,2 +21,3 @@
/// \brief The callback to be used for use-auto AST matchers.
+class IteratorReplacer
----------------
Please update comment.
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:66
@@ +65,3 @@
+
+bool testPointeeCVQualified(QualType QT) {
+ QT.dump();
----------------
"test" sounds like a test to me, I'd call it isPointeeCVQualified.
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:67
@@ +66,3 @@
+bool testPointeeCVQualified(QualType QT) {
+ QT.dump();
+ const PointerType *DeclType = QT->getAs<PointerType>();
----------------
Remove debug output.
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:71
@@ +70,3 @@
+ QualType PointeeType = DeclType->getPointeeType();
+ return PointeeType.hasLocalQualifiers();
+}
----------------
Any reason to not put the PointeeType binding into the matcher? Seems like that would save a bunch of code.
================
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
----------------
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 :(
================
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 "));
----------------
Shouldn't formatting be done by clang-format?
================
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(),
----------------
Incomplete sentence?
http://llvm-reviews.chandlerc.com/D582
More information about the cfe-commits
mailing list