This is an archive of the discontinued LLVM Phabricator instance.

lambdas in modules: make PendingFakeDefinitionData a set
AbandonedPublic

Authored by elsteveogrande on Aug 19 2018, 1:36 PM.

Details

Summary

Of the three enums, only two are used (Fake and FakeLoaded), and even when switching the mapped value to FakeLoaded, it's leading to an unexpected state anyway (i.e. there's no check for only Fake's in the map). Discard the enum, make this a simple set to test for membership / emptiness.

Test Plan: ninja check-clang-modules

Diff Detail

Event Timeline

elsteveogrande created this revision.Aug 19 2018, 1:36 PM
elsteveogrande retitled this revision from make PendingFakeDefinitionData a set, not map of decl data -> enum to lambdas in modules: make PendingFakeDefinitionData a set.Aug 19 2018, 1:39 PM
elsteveogrande added a reviewer: rsmith.
rsmith added inline comments.Sep 4 2018, 7:26 PM
lib/Serialization/ASTReaderDecl.cpp
1766

Did you mean to add this FIXME?

4246

This does not appear to be NFC: the FakeLoaded vs absent-from-map distinction matters here. I think the idea here is that we still need to load the lexical contents of the declaration of the class that we pick to be the definition even if we've already found and merged another definition into it.

That said, if this is necessary, we should have some test coverage for it, and based on this change not breaking any of our tests, we evidently don't. :( I'll try this change out against our codebase and see if I can find a testcase.

elsteveogrande added inline comments.Sep 5 2018, 9:30 AM
lib/Serialization/ASTReaderDecl.cpp
1766

Yup: to indicate this is assert about faked up lambda definition will be addressed in an upcoming diff, i.e., fixing the lambda issues :) See D50948, D50949

4246

Thanks for checking this! Yup I missed this; count would be different and therefore this changes logic, which surprisingly didn't break things as far as I could see. I'll change this back to Fake vs. FakeLoaded.

elsteveogrande abandoned this revision.Sep 5 2018, 3:06 PM
elsteveogrande added inline comments.
lib/Serialization/ASTReaderDecl.cpp
1760–1765

(2) the find, and the flip to FakeLoaded

3080–3081

(1) the insert

4246

Hmm. In the lambda case, the FakeLoaded remains in the table, and we get "faked up a class definition but never saw the real one":

assert(PendingFakeDefinitionData.empty() &&
       "faked up a class definition but never saw the real one");

Failing assert here: lib/Serialization/ASTReader.cpp

So I'm digging into why PendingFakeDefinitionData isn't emptying out. Recapping the logic in this class (to make sure I know what's going on here / to help explain it to myself)

  1. a Fake insert happens around 3081, after creating a fake/empty DefinitionData and setting on a new CXXRecordDecl (and its canonical decl if different)
  2. this table is checked in MergeDefinitionData from 1765; if there's a Fake entry, flip it to FakeLoaded
  3. the only removal that I could find is when a decl is updated with UPD_CXX_INSTANTIATED_CLASS_DEFINITION around line 4256, only if there wasn't an update and there's a lexical DC. (In any event the UPD_CXX_INSTANTIATED_... wouldn't fire in my case)
4255

(3) ... and finally the erase

elsteveogrande reclaimed this revision.Sep 5 2018, 3:06 PM
elsteveogrande abandoned this revision.Sep 5 2018, 7:52 PM

I'll drop this one, since this is not the logic change we want.