On Dec 30, 2010, at 1:00 AM, sashan wrote:
> On Thu Dec 23 07:40:49 2010, Douglas Gregor wrote:
>>
>> It's still not the right solution to look at the source locations. Just
>> reverse the list and we'll have the cases in source order.
>>
>
> Reversing the list was what I originally (see
> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-December/012387.html) did but
> it
> doesn't work for this sort of statement:
>
> default:
> default:;
That seems like an easy fix?
> Anyway I've attached a patch that effectively reverses the list.
>
> <0001-Store-the-case-default-stmts-at-the-end-of-the-list.patch>
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -738,6 +738,7 @@ class SwitchStmt : public Stmt {
Stmt* SubExprs[END_EXPR];
// This points to a linked list of case and default statements.
SwitchCase *FirstCase;
+ SwitchCase *LastCase;
SourceLocation SwitchLoc;
/// If the SwitchStmt is a switch on an enum value, this records whether
It'd be much nicer if we could avoid making the AST larger. How about either
maintaining the LastCase state within Sema, or just reversing the list in-place
within Sema at the end of the switch statement?
- Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits