[PATCH] D31697: Check for null before using TUScope

Kim Gräsman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 7 13:32:12 PDT 2021


kimgr added a comment.

This was eventually fixed in IWYU. I believe the problem is/was:

- After code is parsed and the AST is built, Sema resets its `TUScope` member to null
- We use Sema to lookup and define default constructors before traversing the AST using a RAV
- Some yet-not-fully-identified constructs cause Sema to need a TUScope for this (something to do with `LazilyCreateBuiltin`, but I haven't been able to construct a reduced testcase)

So in https://github.com/include-what-you-use/include-what-you-use/commit/5e7843434169a8af333305ebd6e1434cc3cffb66, we explicitly re-point `Sema::TUScope` to `Sema::getCurScope()`, which seems to have fixed the crash.

This revision can be closed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D31697/new/

https://reviews.llvm.org/D31697



More information about the cfe-commits mailing list