Remove parenthesis surrounding the new loop index.
Details
Diff Detail
Event Timeline
Can you add a test where we need the parens? (where the element is of ** type or something)
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
482 | Perhaps add a comment (or correct me if I'm wrong ;) (can Usage.Expression be something more complex?) |
Usage.Expression can be:
-CXXMemberCallExpr: "container.at(i)"
-CXXOperatorCallExpr: "*it" or "container[i]"
-ArraySubscripExpr: "Arr[i]"
-UnaryOperator: "*ptr"
-MemberExpr: "it->member" (we only replace "it->" with "elem." in this
case).
The point is that all of them except the last one will be replaced by
"elem" (or any other identifier), so it will be a DeclRefExpr after the
change, and the parenthesis can always be removed. I can add a comment
explaining this.
Perhaps add a comment (or correct me if I'm wrong ;)
Usage.Expression contains the DeclRefExpr from the point of usage.
Parens around a simple DeclRefExpr can always be removed.
(can Usage.Expression be something more complex?)