On Wed, Sep 4, 2013 at 4:24 AM, Enea Zaffanella <[email protected]>wrote:
> When dumping the following C++11 chunk of code
>
> $ cat chunk.cc
> struct A { A(int, int); };
> A a_paren( A(0,0) );
> A a_range( A{0,0} );
>
> the CXXTemporaryObjectExpr generated by A{0,0}
> is missing a proper end location
> (the source location is correctly set for A(0,0)).
>
> $ clang -cc1 -std=c++11 -ast-dump chunk.cc
> [...]
> `-VarDecl 0x5a963e0 <line:3:1, col:19> a_range 'struct A'
> `-CXXConstructExpr 0x5a96570 <col:3, col:19> 'struct A' 'void (struct A
> &&) noexcept' elidable
> `-MaterializeTemporaryExpr 0x5a96550 <col:12, <invalid sloc>> 'struct
> A' xvalue
> `-CXXTemporaryObjectExpr 0x5a964d8 <col:12, <invalid sloc>> 'struct
> A' 'void (int, int)'
> |-IntegerLiteral 0x5a96448 <col:14> 'int' 0
> `-IntegerLiteral 0x5a96468 <col:16> 'int' 0
>
>
> Please find attached a patch (with testcase) fixing this issue.
> OK to commit?
>
>
+ if (Kind.getKind() == InitializationKind::IK_DirectList)
+ ParenRange = SourceRange(LBraceLoc, RBraceLoc);
+ else
ParenRange = Kind.getParenRange();
This isn't right: there aren't any parentheses. getParenRange() on a
CXXTemporaryObjectExpr shouldn't return source locations pointing at tokens
which aren't parentheses.
You should be able to fix this purely in
CXXTemporaryObjectExpr::getLocStart()/getLocEnd().
-Eli
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits