[PATCH] D49012: [clangd] Uprank delcarations when "using q::name" is present in the main file

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 6 03:07:50 PDT 2018


ioeric added a comment.

Nice!

Just one caveat regarding locations in addition to Sam's comments :)



================
Comment at: clang-tools-extra/clangd/Quality.cpp:48
+  if (R.ShadowDecl) {
+    const auto Loc = SourceMgr.getSpellingLoc(R.ShadowDecl->getLocation());
+    if (SourceMgr.isWrittenInMainFile(Loc))
----------------
I think we might want to use `getExpansionLoc` here. Consider `DEFINE_string` which is implemented like:
```
#define DEFINE_string(XXX) \
namespace FLs { \
SomeType FLAGS_XXX; \
} \
using FLs::FLAGS_XXX;
```
When you have `DEFINE_string(X) in the main file, the spelling location will be in the file where the macro is defined, while the expansion location will be in the main file, and I think we would want later.



https://reviews.llvm.org/D49012





More information about the cfe-commits mailing list