This is an archive of the discontinued LLVM Phabricator instance.

[change-namespace] Don't match a function call/ref multiple times.
ClosedPublic

Authored by ioeric on Mar 15 2018, 7:28 AM.

Details

Summary

Previously, the matcher matches a function call/ref multiple times, one
for each decl ancestor. This might cause problems. For example, in the following
case, func() would be matched once (with namespace context) before using decl is
seen and once after using decl is seeing, which would result in different conflicting
replacements as the first match would replace func with "ns::func" as it doesn't
know about the using decl.

namespace x {
namespace {
using ::ns::func;
void f() { func(); }
}
}

Switching from hasDescendant matching to hasAncestor matching solves the
problem.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric created this revision.Mar 15 2018, 7:28 AM
ioeric updated this revision to Diff 138550.Mar 15 2018, 7:29 AM
  • small fix.
hokein accepted this revision.Mar 15 2018, 7:43 AM

LGTM.

This revision is now accepted and ready to land.Mar 15 2018, 7:43 AM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.