[PATCH] D44831: [clang-format] Refine ObjC guesser to handle child lines of child lines
Ben Hamilton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 26 08:23:31 PDT 2018
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
More information about the cfe-commits
mailing list