[PATCH] D47466: [clangd] Avoid inserting new #include when declaration is present in the main file.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 29 04:26:19 PDT 2018


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clangd/CodeComplete.cpp:249
+      if (SemaResult->Kind == CodeCompletionResult::RK_Declaration) {
+        if (const auto *D = SemaResult->getDeclaration()) {
+          const auto &SM = D->getASTContext().getSourceManager();
----------------
do you need to iterate over all redecls?


================
Comment at: clangd/CodeComplete.cpp:251
+          const auto &SM = D->getASTContext().getSourceManager();
+          ShouldInsertInclude =
+              !SM.isInMainFile(SM.getExpansionLoc(D->getLocStart()));
----------------
`ShouldInsertInclude = ShouldInsertInclude && ...` would be a little more future-proof


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47466





More information about the cfe-commits mailing list