[cfe-dev] SourceRange not as expected for arithmetic types with direct initialization
Firat Kasmis via cfe-dev
cfe-dev at lists.llvm.org
Sun Nov 6 15:08:39 PST 2016
Hi,
following code:
int v(8);
bool b(false);
double d(0.5);
Structy s(23);
int v1, v2(3), v3, v4(4);
Structy s1, s2(23), s3, s4(3);
if(const auto *vardecl = Result.Nodes.getNodeAs<clang::VarDecl>("vardecl"))
{
llvm::outs() <<
Lexer::getSourceText(CharSourceRange::getTokenRange(vardecl->getSourceRange()),
*SM, LO) << "\n";
}
outputs:
int v(8
bool b(false
double d(0.5
Structy s(23)
int v1
int v1, v2(3
int v1, v2(3), v3
int v1, v2(3), v3, v4(4
Structy s1
Structy s1, s2(23)
Structy s1, s2(23), s3
Structy s1, s2(23), s3, s4(3)
As can be seen, the last parenthesis is missing for the arithmetic types.
The SourceRange is for any other kind of initialization right, except for
this case.
Regards,
Firat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161107/de31ea1b/attachment.html>
More information about the cfe-dev
mailing list