<div dir="ltr"><div></div><div>When parsing a named declaration with an equals sign
with clang -std c++11/14, clang builds an initializer expression whose SourceRange covers from variable name through the end of the initial value:<br></div><div><span style="font-family:monospace"> std::string foo = "bar";</span></div><div><span style="font-family:monospace"></span>
<div><span style="font-family:monospace"> -----------<br></span></div>
</div><div><br></div><div>When parsing the same code with clang -std c++17/2x, the initializer expression's SourceRange only includes the initial value itself, and not the variable name or the equals sign:</div><div>
<div><span style="font-family:monospace"> std::string foo = "bar";</span><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"> -----<br></span>
</div><br></div><div>
<div>If the string is initialized using parentheses rather than an equals sign, in all of c++11/14/17/2x the initializer expression's SourceRange includes the variable name and both parentheses:</div><div>
<div><span style="font-family:monospace"> std::string foo("bar");</span><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"> ----------<br></span>
</div><br></div>
</div><div>This difference breaks clang-tidy's <a href="https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-string-init.html">readability-remove-redundant-string</a> for c++17 and c++2x, as described in at <a href="https://reviews.llvm.org/D69238/">reviews.llvm.org/D69238</a>. Is this
SourceRange
difference intentional, and if not does anyone have thoughts on how to make the SourceRange consistent across C++ standards? Thanks!<br></div><div><br></div></div>