Interesting problem trying to obtain UsingShadowDecl from DeclRefExpr

namespace ns {
int a;
}

int main() {
  using ns::a;
  return a;
}

I need to relate DeclRefExpr for 'a' to the used UsingShadowDecl, but
DeclRefExpr::getDecl() is designed to give me the target VarDecl instead
of the "bridge".

Is this intentional?

Do I have another way to get this info?

A similar problem is present trying to obtain target UsingShadowDecl
from another UsingShadowDecl.

This is fundamental to build a dependency graph and to detect unused
UsingDecl.

namespace ns {
int a;
}

int main() {
using ns::a;
return a;
}

I need to relate DeclRefExpr for 'a' to the used UsingShadowDecl, but
DeclRefExpr::getDecl() is designed to give me the target VarDecl instead
of the "bridge".

Is this intentional?

It probably was, since DeclRefExpr tends to refer to the declaration as resolved. That said, it doesn't seem like there is any reason to require this behavior.

Do I have another way to get this info?

I don't think so.

A similar problem is present trying to obtain target UsingShadowDecl
from another UsingShadowDecl.

This is fundamental to build a dependency graph and to detect unused
UsingDecl.

Agreed. I think it would be perfectly reasonable to store the UsingShadowDecl within the DeclRefExpr. It might make sense, however, for the normal accessor (DeclRefExpr::getDecl()) to return the underlying declaration, and add a different accessor (say, DeclRefExpr::getReferencedDecl()) to get the result as found by name lookup.

  - Doug