<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 31, 2016, at 4:49 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 31, 2016 at 3:12 PM, Argyrios Kyrtzidis via cfe-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: akirtzidis<br class="">Date: Mon Oct 31 17:12:12 2016<br class="">New Revision: 285647<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=285647&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project?rev=285647&view=rev</a><br class="">Log:<br class="">[index] Fix repeated visitation of the same InitListExpr for indexing.<br class=""><br class="">It was visited multiple times unnecessarily.<br class=""><br class=""><a href="rdar://28985038" class="">rdar://28985038</a><br class=""><br class="">Added:<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/test/Index/Core/<wbr class="">designated-inits.c<br class="">Modified:<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/lib/Index/IndexBody.<wbr class="">cpp<br class=""><br class="">Modified: cfe/trunk/lib/Index/IndexBody.<wbr class="">cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=285647&r1=285646&r2=285647&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/cfe/trunk/lib/Index/<wbr class="">IndexBody.cpp?rev=285647&r1=<wbr class="">285646&r2=285647&view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- cfe/trunk/lib/Index/IndexBody.<wbr class="">cpp (original)<br class="">+++ cfe/trunk/lib/Index/IndexBody.<wbr class="">cpp Mon Oct 31 17:12:12 2016<br class="">@@ -300,6 +300,7 @@ public:<br class=""> IndexingContext &IndexCtx;<br class=""> const NamedDecl *Parent;<br class=""> const DeclContext *ParentDC;<br class="">+ bool Visited = false;<br class=""><br class=""> public:<br class=""> SyntacticFormIndexer(<wbr class="">IndexingContext &indexCtx,<br class=""></blockquote><div class=""><br class=""></div><div class="">Do we need SyntacticFromIndexer to be a RecursiveASTVisitor at all? It looks like you would get the desired effect by simply walking the elements of the syntactic form looking for DesignatedInitExprs (which will always be at the top level of the InitListExpr's element if they exist). Right now, it looks like you still traverse expression E twice in cases like this:</div><div class=""><br class=""></div><div class=""> int arr[] = { [0] = 0, E };</div><div class=""><br class=""></div><div class="">... and you'd still get a quadratic traversal for a case like { [0] = {}, { [0] = {}, { [0] = {}, ... } } }.</div></div></div></div></div></blockquote><div><br class=""></div><div>This is excellent feedback, see r285666.</div><div>Thanks for reviewing!</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">@@ -308,6 +309,22 @@ public:<br class=""><br class=""> bool shouldWalkTypesOfTypeLocs() const { return false; }<br class=""><br class="">+ bool TraverseInitListExpr(<wbr class="">InitListExpr *S, DataRecursionQueue *Q = nullptr) {<br class="">+ // Don't visit nested InitListExprs, this visitor will be called again<br class="">+ // later on for the nested ones.<br class="">+ if (Visited)<br class="">+ return true;<br class="">+ Visited = true;<br class="">+ InitListExpr *SyntaxForm = S->isSemanticForm() ? S->getSyntacticForm() : S;<br class="">+ if (SyntaxForm) {<br class="">+ for (Stmt *SubStmt : SyntaxForm->children()) {<br class="">+ if (!TraverseStmt(SubStmt, Q))<br class="">+ return false;<br class="">+ }<br class="">+ }<br class="">+ return true;<br class="">+ }<br class="">+<br class=""> bool VisitDesignatedInitExpr(<wbr class="">DesignatedInitExpr *E) {<br class=""> for (DesignatedInitExpr::<wbr class="">Designator &D : llvm::reverse(E->designators()<wbr class="">)) {<br class=""> if (D.isFieldDesignator())<br class=""><br class="">Added: cfe/trunk/test/Index/Core/<wbr class="">designated-inits.c<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/designated-inits.c?rev=285647&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/cfe/trunk/test/Index/<wbr class="">Core/designated-inits.c?rev=<wbr class="">285647&view=auto</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- cfe/trunk/test/Index/Core/<wbr class="">designated-inits.c (added)<br class="">+++ cfe/trunk/test/Index/Core/<wbr class="">designated-inits.c Mon Oct 31 17:12:12 2016<br class="">@@ -0,0 +1,33 @@<br class="">+// RUN: c-index-test core -print-source-symbols -- %s -target x86_64-apple-macosx10.7 | FileCheck %s<br class="">+<br class="">+struct MyStruct {<br class="">+ int myfield;<br class="">+};<br class="">+<br class="">+enum {<br class="">+ MyValToSet;<br class="">+};<br class="">+<br class="">+// CHECK: [[@LINE+1]]:14 | struct/C | MyStruct |<br class="">+const struct MyStruct _MyStruct[]<br class="">+ [16]<br class="">+ [3]<br class="">+ [3]<br class="">+ [2]<br class="">+ [2] = {<br class="">+ [0] = {<br class="">+ [0] = {<br class="">+ [0] = {<br class="">+ [0][0] = {<br class="">+ [0] = {<br class="">+ // CHECK: [[@LINE+2]]:14 | field/C | myfield | {{.*}} | Ref |<br class="">+ // CHECK: [[@LINE+1]]:24 | enumerator/C | MyValToSet |<br class="">+ .myfield = MyValToSet,<br class="">+ // CHECK-NOT: | field/C | myfield |<br class="">+ // CHECK-NOT: | enumerator/C | MyValToSet |<br class="">+ },<br class="">+ },<br class="">+ },<br class="">+ },<br class="">+ },<br class="">+};<br class=""><br class=""><br class="">______________________________<wbr class="">_________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/cfe-commits</a></blockquote></div></div></div></div></blockquote></div><br class=""></body></html>