[PATCH] D92053: [clangd] Addusing tweak: find insertion point after definition
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 24 13:24:16 PST 2020
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.
thanks, LGTM
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp:158
+
+ if (MustInsertAfterLoc.isValid() &&
+ SM.isBeforeInTranslationUnit(U->getUsingLoc(), MustInsertAfterLoc))
----------------
why not check for this below? as usings are sorted, we expect `LastUsingLoc` to be after this point. so maybe change the `if` below to:
`if(LastUsingLoc.isValid() && (!MustInsertAfterLoc.isValid() || SM.isBeforeInTranslationUnit(MustInsertAfterLoc, LastUsingLoc)))`
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp:201
+ for (const auto &TLD : TLDs) {
+ if (MustInsertAfterLoc.isValid() &&
+ SM.isBeforeInTranslationUnit(TLD->getBeginLoc(), MustInsertAfterLoc))
----------------
nit: maybe factor this into a lambda `bool IsUsingValidAt(SourceLocation)` ?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92053/new/
https://reviews.llvm.org/D92053
More information about the cfe-commits
mailing list