[PATCH] D58185: [clangd] Handle unresolved scope specifier when fixing includes.

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 18 04:40:05 PST 2019


ioeric added inline comments.


================
Comment at: clangd/IncludeFixer.cpp:235
+          std::string Spelling = (Code.substr(B, E - B) + "::").str();
+          if (llvm::StringRef(SpecifiedNS).endswith(Spelling))
+            SpecifiedScope = SpecifiedNS;
----------------
sammccall wrote:
> hmm, won't this heuristic have false positives?
> ```
> // indexed-header.h
> namespace a { int X; }
> 
> // main-file.cc
> namespace b = a;
> namespace c { int Y = b::x; }
> ```
> I worry spelling is going to be "b::" here, while SpecifiedNS is going to be "a::".
Thanks for pointing this out! I completely missed the namespace alias case. Fixed and added a test.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58185/new/

https://reviews.llvm.org/D58185





More information about the cfe-commits mailing list