This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Make MultiplexExternalSemaSource own sources
ClosedPublic

Authored by beanz on Sep 1 2022, 2:38 PM.

Details

Summary

This change refactors the MuiltiplexExternalSemaSource to take ownership
of the underlying sources. As a result it makes a larger cleanup of
external source ownership in Sema and the ChainedIncludesSource.

Diff Detail

Event Timeline

beanz created this revision.Sep 1 2022, 2:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 2:38 PM
beanz requested review of this revision.Sep 1 2022, 2:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 2:38 PM
aprantl added inline comments.Sep 1 2022, 2:45 PM
clang/include/clang/Sema/MultiplexExternalSemaSource.h
53

why this change? Does & imply ownership in our coding style?

beanz added inline comments.Sep 1 2022, 4:00 PM
clang/include/clang/Sema/MultiplexExternalSemaSource.h
53

The old implementation took the address of the references to store. It seems more clear to me to accept a pointer when you need a pointer.

The old interface using references also allowed for passing in stack-allocated objects, which causes problems since the change here calls retain and release on the underlying ref count object. Taking pointers puts the onus on the user of the API to think through where the address passed in comes from.

aprantl accepted this revision.Sep 1 2022, 4:49 PM

This looks plausible to me — did you build clang-tools-extra & lldb to make sure nothing else needs to be updated?

clang/include/clang/Sema/MultiplexExternalSemaSource.h
53

nit: clang-format :-)

This revision is now accepted and ready to land.Sep 1 2022, 4:49 PM
aaron.ballman accepted this revision.Sep 2 2022, 9:09 AM

LGTM aside from some minor nits (also, please run clang-format over the patch before landing).

clang/lib/Sema/MultiplexExternalSemaSource.cpp
32
clang/lib/Sema/Sema.cpp
548
beanz updated this revision to Diff 457651.Sep 2 2022, 11:24 AM

Updating with changes based on review feedback, and fixups for clang-tools-extra

Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2022, 11:24 AM
beanz added a comment.Sep 2 2022, 11:39 AM

I built LLDB and ran its tests. I see no additional failures after applying my change, but LLDB's tests do not execute successfully on my local system (22 failures).

This revision was landed with ongoing or failed builds.Sep 2 2022, 11:58 AM
This revision was automatically updated to reflect the committed changes.