[cfe-commits] r162408 - in /cfe/trunk: test/Index/overrides.m tools/c-index-test/c-index-test.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Aug 22 16:15:52 PDT 2012
Author: akirtzidis
Date: Wed Aug 22 18:15:52 2012
New Revision: 162408
URL: http://llvm.org/viewvc/llvm-project?rev=162408&view=rev
Log:
[libclang] c-index-test: Make the printing of the overrides list of a cursor in
a deterministic order, to avoid random test failures.
Modified:
cfe/trunk/test/Index/overrides.m
cfe/trunk/tools/c-index-test/c-index-test.c
Modified: cfe/trunk/test/Index/overrides.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/overrides.m?rev=162408&r1=162407&r2=162408&view=diff
==============================================================================
--- cfe/trunk/test/Index/overrides.m (original)
+++ cfe/trunk/test/Index/overrides.m Wed Aug 22 18:15:52 2012
@@ -99,11 +99,11 @@
// RUN: c-index-test -test-load-source local %s | FileCheck %s
// CHECK: overrides.m:12:9: ObjCInstanceMethodDecl=protoMethod:12:9 [Overrides @3:9]
// CHECK: overrides.m:22:9: ObjCInstanceMethodDecl=method:22:9 [Overrides @16:9]
-// CHECK: overrides.m:23:9: ObjCInstanceMethodDecl=protoMethod:23:9 [Overrides @12:9, @8:9, @32:9, @17:9]
+// CHECK: overrides.m:23:9: ObjCInstanceMethodDecl=protoMethod:23:9 [Overrides @8:9, @12:9, @17:9, @32:9]
// CHECK: overrides.m:27:9: ObjCInstanceMethodDecl=method:27:9 (Definition) [Overrides @16:9]
// CHECK: overrides.m:28:9: ObjCClassMethodDecl=methodWithParam::28:9 (Definition) [Overrides @18:9]
// CHECK: overrides.m:32:9: ObjCInstanceMethodDecl=protoMethod:32:9 [Overrides @8:9]
-// CHECK: overrides.m:36:9: ObjCInstanceMethodDecl=protoMethod:36:9 [Overrides @12:9, @8:9, @32:9, @17:9]
+// CHECK: overrides.m:36:9: ObjCInstanceMethodDecl=protoMethod:36:9 [Overrides @8:9, @12:9, @17:9, @32:9]
// CHECK: overrides.m:50:8: ObjCInstanceMethodDecl=meth:50:8 (Definition) [Overrides @43:8]
// CHECK: overrides.m:55:8: ObjCInstanceMethodDecl=kol:55:8 Extent=[55:1 - 55:12]
// CHECK: overrides.m:65:26: ObjCInstanceMethodDecl=prop1:65:26 [Overrides @59:25] Extent=[65:26 - 65:31]
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=162408&r1=162407&r2=162408&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Aug 22 18:15:52 2012
@@ -554,6 +554,19 @@
}
}
+typedef struct {
+ unsigned line;
+ unsigned col;
+} LineCol;
+
+static int lineCol_cmp(const void *p1, const void *p2) {
+ const LineCol *lhs = p1;
+ const LineCol *rhs = p2;
+ if (lhs->line != rhs->line)
+ return (int)lhs->line - (int)rhs->line;
+ return (int)lhs->col - (int)rhs->col;
+}
+
static void PrintCursor(CXCursor Cursor,
CommentXMLValidationData *ValidationData) {
CXTranslationUnit TU = clang_Cursor_getTranslationUnit(Cursor);
@@ -718,13 +731,21 @@
clang_getOverriddenCursors(Cursor, &overridden, &num_overridden);
if (num_overridden) {
unsigned I;
+ LineCol lineCols[50];
+ assert(num_overridden <= 50);
printf(" [Overrides ");
for (I = 0; I != num_overridden; ++I) {
CXSourceLocation Loc = clang_getCursorLocation(overridden[I]);
clang_getSpellingLocation(Loc, 0, &line, &column, 0);
+ lineCols[I].line = line;
+ lineCols[I].col = column;
+ }
+ // Make the order of the override list deterministic.
+ qsort(lineCols, num_overridden, sizeof(LineCol), lineCol_cmp);
+ for (I = 0; I != num_overridden; ++I) {
if (I)
printf(", ");
- printf("@%d:%d", line, column);
+ printf("@%d:%d", lineCols[I].line, lineCols[I].col);
}
printf("]");
clang_disposeOverriddenCursors(overridden);
More information about the cfe-commits
mailing list