Thanks for the feedback. Here's an updated patch. To some extent,
yes, this situation is weird, but I think the only valid input
exercising this code path should are cases where it would have been
semantically equivalent to braces anyway.
--John
On 1/30/13, Richard Smith <[email protected]> wrote:
> On Wed, Jan 30, 2013 at 10:57 AM, John Stratton
> <[email protected]> wrote:
>> Hello. I've attached a small patch that fixes the 15095 bug I filed a
>> couple of days ago, and makes sure that the CompoundLiteral and child
>> AST nodes created from a vector literal have correct source-location
>> information. Does this make sense to the veteran Clang developers?
>
> It's a bit weird that we're building a CompoundLiteralExpr here for a
> construct which used parentheses not braces, but given that's our
> representation, it seems appropriate to pretend the braces are where
> the parens of the initializer were.
>
> + if (isVectorLiteral) {
> + SourceLocation litLParenLoc = (PE ? PE->getLParen() :
> PLE->getLParenLoc());
> + SourceLocation litRParenLoc = (PE ? PE->getRParen() :
> PLE->getRParenLoc());
>
> Please compute these locations in BuildVectorLiteral instead (within
> its 'if (ParenListExpr *PE = dyn_cast<ParenListExpr>(E))' code).
>
> Also, variable names should start with an uppercase letter (this code
> breaks the convention in a few places, but new code should conform).
>
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp (revision 174249)
+++ lib/Sema/SemaExpr.cpp (working copy)
@@ -4626,10 +4626,15 @@
Expr **exprs;
unsigned numExprs;
Expr *subExpr;
+ SourceLocation LiteralLParenLoc, LiteralRParenLoc;
if (ParenListExpr *PE = dyn_cast<ParenListExpr>(E)) {
+ LiteralLParenLoc = PE->getLParenLoc();
+ LiteralRParenLoc = PE->getRParenLoc();
exprs = PE->getExprs();
numExprs = PE->getNumExprs();
- } else {
+ } else { // isa<ParenExpr> by assertion at function entrance
+ LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
+ LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
subExpr = cast<ParenExpr>(E)->getSubExpr();
exprs = &subExpr;
numExprs = 1;
@@ -4689,7 +4694,8 @@
InitListExpr *initE = new (Context) InitListExpr(Context, LParenLoc,
initExprs, RParenLoc);
initE->setType(Ty);
- return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
+ return BuildCompoundLiteralExpr(LiteralLParenLoc, TInfo, LiteralRParenLoc,
+ initE);
}
/// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits