[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template
Tomasz KamiĆski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 23 01:20:40 PDT 2023
tomasz-kaminski-sonarsource added a comment.
As a downstream, we have concerns with this change. From what I saw it breaks the behavior of the fix-it that wants to remove the whole variable definition (including the initializer). For example, I have unused, that I want to remove variable x and unnecessary explicit specialization temp<double:
template<typename T>
T temp = 1;
int x = 10;
template<> double temp<double> = 1;
Previously, this could be handled (in case of single variable declaration) by simply removing the `var->getSourceRange()` with succeeding coma. However, such code does not work for variable templates (and only for them).
As an alternative, I would suggest introducing an additional function to VarDecl (which could be moved up in the hierarchy), that would report a source range that corresponds to `declarator-id`, i.e. for template variable it would include template arguments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139705/new/
https://reviews.llvm.org/D139705
More information about the cfe-commits
mailing list