aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-12-17 16:18:04 +0000
committerDouglas Gregor <dgregor@apple.com>2010-12-17 16:18:04 +0000
commitc7b5ed6da7410849b51ba9a9ea04d2cc7b720f48 (patch)
tree695f8eb3171e4f42a7a60fdee796440d57e39938
parent320e153dbce9c7f57f22a59e4d162795059717e5 (diff)
Swap the order of the condition and body of a do-while statement in
the AST, so that we visit them in source order. Fixes <rdar://problem/8779113>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122062 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Stmt.h2
-rw-r--r--test/Index/annotate-tokens.c23
2 files changed, 23 insertions, 2 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 01e0ae56c9..b3523a146c 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -868,7 +868,7 @@ public:
/// DoStmt - This represents a 'do/while' stmt.
///
class DoStmt : public Stmt {
- enum { COND, BODY, END_EXPR };
+ enum { BODY, COND, END_EXPR };
Stmt* SubExprs[END_EXPR];
SourceLocation DoLoc;
SourceLocation WhileLoc;
diff --git a/test/Index/annotate-tokens.c b/test/Index/annotate-tokens.c
index e251596c80..d692bd3bba 100644
--- a/test/Index/annotate-tokens.c
+++ b/test/Index/annotate-tokens.c
@@ -14,9 +14,14 @@ void g(int i, ...) {
__builtin_va_list va;
(void)__builtin_va_arg(va, Int);
(void)__builtin_types_compatible_p(Int, Int);
+
+ struct X x = { 0, 0 };
+ do {
+ x.a++;
+ } while (x.a < 10);
}
-// RUN: c-index-test -test-annotate-tokens=%s:4:1:17:1 %s | FileCheck %s
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:22:1 %s | FileCheck %s
// CHECK: Identifier: "T" [4:3 - 4:4] TypeRef=T:1:13
// CHECK: Punctuation: "*" [4:4 - 4:5] VarDecl=t_ptr:4:6 (Definition)
// CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition)
@@ -74,5 +79,21 @@ void g(int i, ...) {
// CHECK: Identifier: "Int" [16:38 - 16:41] TypeRef=Int:12:13
// CHECK: Punctuation: "," [16:41 - 16:42] UnexposedExpr=
// CHECK: Identifier: "Int" [16:43 - 16:46] TypeRef=Int:12:13
+// CHECK: Keyword: "struct" [18:3 - 18:9] UnexposedStmt=
+// CHECK: Identifier: "X" [18:10 - 18:11] TypeRef=struct X:2:8
+// CHECK: Identifier: "x" [18:12 - 18:13] VarDecl=x:18:12 (Definition)
+// CHECK: Keyword: "do" [19:3 - 19:5] UnexposedStmt=
+// CHECK: Identifier: "x" [20:5 - 20:6] DeclRefExpr=x:18:12
+// CHECK: Punctuation: "." [20:6 - 20:7] MemberRefExpr=a:2:16
+// CHECK: Identifier: "a" [20:7 - 20:8] MemberRefExpr=a:2:16
+// CHECK: Punctuation: "++" [20:8 - 20:10] UnexposedExpr=
+// CHECK: Punctuation: ";" [20:10 - 20:11] UnexposedStmt=
+// CHECK: Punctuation: "}" [21:3 - 21:4] UnexposedStmt=
+// CHECK: Keyword: "while" [21:5 - 21:10] UnexposedStmt=
+// CHECK: Punctuation: "(" [21:11 - 21:12] UnexposedStmt=
+// CHECK: Identifier: "x" [21:12 - 21:13] DeclRefExpr=x:18:12
+// CHECK: Punctuation: "." [21:13 - 21:14] MemberRefExpr=a:2:16
+// CHECK: Identifier: "a" [21:14 - 21:15] MemberRefExpr=a:2:16
+
// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 %s | FileCheck %s
// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 %s | FileCheck %s