[clang-tools-extra] Support renaming designated initializers (PR #86976)
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 30 20:36:04 PDT 2024
================
@@ -367,6 +367,25 @@ class RenamerClangTidyVisitor
return true;
}
+ bool VisitDesignatedInitExpr(DesignatedInitExpr *Expr) {
+ for (const auto &Designator : Expr->designators()) {
+ if (!Designator.isFieldDesignator())
+ continue;
+ auto *FieldDecl = Designator.getFieldDecl();
+ if (!FieldDecl)
+ continue;
+ auto *II = FieldDecl->getIdentifier();
+ if (!II)
+ continue;
+ SourceRange FixLocation{
+ Designator.getFieldLoc(),
+ Designator.getFieldLoc().getLocWithOffset(II->getLength())};
----------------
PiotrZSL wrote:
won't this getLocWithOffset point pass the end ?, usually end should point to last token, this will point to last token +1 character. In theory: `SourceRange FixLocation{Designator.getFieldLoc(), Designator.getFieldLoc());` should work in same way.
https://github.com/llvm/llvm-project/pull/86976
More information about the cfe-commits
mailing list