[PATCH] D76432: [clangd] Add a tweak for adding "using" statement.

Adam Czachorowski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 19 08:05:02 PDT 2020


adamcz created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, mgrang, jkorous, MaskRay, ilya-biryukov, mgorny.
Herald added a project: clang.

This triggers on types and function calls with namespace qualifiers. The
action is to remove the qualifier and instead add a "using" statement at
appropriate place.

It is not always clear where to add the "using" line. Right now we find
the nearest "using" line and add it there, thus keeping with local
convention. If there are no usings, we put it at the deepest relevant
namespace level.

This is an initial version only. There are several improvements that
can be made:

- Support for qualifiers that are not purely namespace (e.g.  record

types, etc).

- Removing qualifier from other instances of the same type/call.
- Smarter placement of the "using" line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76432

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/unittests/TweakTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76432.251386.patch
Type: text/x-patch
Size: 13042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200319/ddfcf4e5/attachment.bin>


More information about the cfe-commits mailing list