[cfe-commits] r151118 - in /cfe/trunk: test/Index/index-refs.cpp tools/libclang/IndexBody.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Feb 21 18:10:41 PST 2012


Author: akirtzidis
Date: Tue Feb 21 20:10:41 2012
New Revision: 151118

URL: http://llvm.org/viewvc/llvm-project?rev=151118&view=rev
Log:
[libclang] Index the field references of a designated initializer, rdar://10906206

Modified:
    cfe/trunk/test/Index/index-refs.cpp
    cfe/trunk/tools/libclang/IndexBody.cpp

Modified: cfe/trunk/test/Index/index-refs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-refs.cpp?rev=151118&r1=151117&r2=151118&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-refs.cpp (original)
+++ cfe/trunk/test/Index/index-refs.cpp Tue Feb 21 20:10:41 2012
@@ -61,6 +61,14 @@
 const int default_param = 3;
 void foo4(int p = default_param);
 
+struct S2 {
+  int x,y;
+};
+
+void foo5() {
+  struct S2 s = { .y = 1, .x = 4};
+}
+
 // RUN: c-index-test -index-file %s | FileCheck %s
 // CHECK:      [indexDeclaration]: kind: namespace | name: NS
 // CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
@@ -108,3 +116,6 @@
 // CHECK:      [indexEntityReference]: kind: variable | name: array_size | {{.*}} | loc: 59:22
 // CHECK:      [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
 // CHECK-NOT:  [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
+
+// CHECK:      [indexEntityReference]: kind: field | name: y | {{.*}} | loc: 69:20
+// CHECK-NEXT: [indexEntityReference]: kind: field | name: x | {{.*}} | loc: 69:28

Modified: cfe/trunk/tools/libclang/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexBody.cpp?rev=151118&r1=151117&r2=151118&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexBody.cpp (original)
+++ cfe/trunk/tools/libclang/IndexBody.cpp Tue Feb 21 20:10:41 2012
@@ -51,6 +51,17 @@
     return true;
   }
 
+  bool VisitDesignatedInitExpr(DesignatedInitExpr *E) {
+    for (DesignatedInitExpr::reverse_designators_iterator
+           D = E->designators_rbegin(), DEnd = E->designators_rend();
+           D != DEnd; ++D) {
+      if (D->isFieldDesignator())
+        IndexCtx.handleReference(D->getField(), D->getFieldLoc(),
+                                 Parent, ParentDC, E);
+    }
+    return true;
+  }
+
   bool VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
     IndexCtx.handleReference(E->getDecl(), E->getLocation(),
                              Parent, ParentDC, E);





More information about the cfe-commits mailing list