This is an archive of the discontinued LLVM Phabricator instance.

[AST] Use data-recursion when building ParentMap, avoid stack overflow.
ClosedPublic

Authored by sammccall on Sep 24 2020, 5:29 AM.

Details

Summary

The following crashes on my system before this patch, but not after:

void foo(int i) {
  switch (i) {
    case 1:
    case 2:
    ... 100000 cases ...
      ;
  }
}

clang-query -c="match stmt(hasAncestor(stmt()))" deep.c

I'm not sure it's actually a sane testcase to run though, it's pretty slow :-)

Diff Detail

Event Timeline

sammccall created this revision.Sep 24 2020, 5:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 24 2020, 5:29 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
sammccall requested review of this revision.Sep 24 2020, 5:29 AM
hokein accepted this revision.Sep 24 2020, 8:19 AM

Thanks for fixing this!

clang/lib/AST/ParentMapContext.cpp
229

can we make some comments explaining what this method does? I think I have a vague understanding, but would be helpful to have some documentation.

This revision is now accepted and ready to land.Sep 24 2020, 8:19 AM
sammccall updated this revision to Diff 294154.Sep 24 2020, 1:50 PM
sammccall marked an inline comment as done.

Address comments.

Also remove a stale fixme, and simplify a little.

This revision was landed with ongoing or failed builds.Sep 24 2020, 1:50 PM
This revision was automatically updated to reflect the committed changes.