This is an archive of the discontinued LLVM Phabricator instance.

[Index] Remove reference to `UnresolvedUsingIfExists`
ClosedPublic

Authored by bnbarham on Apr 22 2022, 11:40 AM.

Details

Summary

Assuming ns::foo doesn't exist, given:

using ns::foo __attribute__((using_if_exists));

The AST will look something like:
UsingDecl

UsingShadowDecl
  UnresolvedUsingIfExistsDecl

Thus we end up adding a reference to UnresolvedUsingIfExistsDecl when
processing UsingDecl, but never add the decl itself. In this case the
decl is really the UsingDecl anyway though (which we do output), so it
makes more sense to just remove the extra reference.

Diff Detail

Event Timeline

bnbarham created this revision.Apr 22 2022, 11:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2022, 11:40 AM
bnbarham requested review of this revision.Apr 22 2022, 11:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2022, 11:40 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
bnbarham added inline comments.Apr 22 2022, 11:44 AM
clang/test/Index/using_if_exists.cpp
9

The AST here is:
UsingDecl -> UsingShadowDecl -> UnresolvedUsingIfExistsDecl

So the UnresolvedUsingIfExistsDecl is a reference, which is a bit weird since there is no decl. But... there is no decl ("foo" doesn't exist), so this seems somewhat reasonable. Any objections?

bnbarham updated this revision to Diff 424621.Apr 22 2022, 2:42 PM

After speaking with Ben, we decided it makes more sense to just remove the reference entirely.

bnbarham updated this revision to Diff 424622.Apr 22 2022, 2:43 PM
bnbarham retitled this revision from [Index] Add a USR and symbol kind for UnresolvedUsingIfExists to [Index] Remove reference to `UnresolvedUsingIfExists`.
bnbarham edited the summary of this revision. (Show Details)

Update title/message

benlangmuir accepted this revision.Apr 22 2022, 2:49 PM

Minor suggestion for the test case, but otherwise LGTM.

clang/test/Index/using_if_exists.cpp
10

Could we drop the [[@LINE-2]]:11 | part of the CHECK-NOT to make it a bit more robust?

This revision is now accepted and ready to land.Apr 22 2022, 2:49 PM
bnbarham updated this revision to Diff 424631.Apr 22 2022, 3:16 PM

Remove line for <unknown> check

bnbarham marked an inline comment as done.Apr 22 2022, 3:17 PM
This revision was automatically updated to reflect the committed changes.