benhamilton added inline comments.

================
Comment at: lib/Format/Format.cpp:1542
     };
-    for (auto Line : AnnotatedLines) {
-      if (LineContainsObjCCode(*Line))
+    llvm::DenseSet<AnnotatedLine *> LinesToCheckSet;
+    LinesToCheckSet.reserve(AnnotatedLines.size());
----------------
djasper wrote:
> Wouldn't it be much easier to call this function recursively for Children 
> instead of using the lambda as well as this additional set? Lines and their 
> children should form a tree, I think, so you should never see the same line 
> again during recursion.
I'm less worried about cycles and more worried about a maliciously deeply 
nested set of children blowing out the stack and causing a crash.

It seemed safer to use the heap here to avoid that scenario (I don't know of 
any other way to avoid it, since we don't know the stack size and we don't 
control it.)


Repository:
  rC Clang

https://reviews.llvm.org/D44831



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to