[PATCH] D46675: [clangd] Add helper for collecting #include directives in file.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 14 04:44:09 PDT 2018


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


================
Comment at: clangd/ClangdUnit.h:53
   std::vector<Diag> Diags;
-  InclusionLocations IncLocations;
+  std::vector<Inclusion> Inclusions;
 };
----------------
this might be a good place to explain *why* we collect these - processes like code completion will need #include information later, and their compile action skips the preamble range


================
Comment at: clangd/Headers.h:47
+std::unique_ptr<PPCallbacks>
+collectInclusionsInMainFileCallback(const SourceManager &SM,
+                                    std::vector<Inclusion> &Inclusions);
----------------
as Ilya suggested, I like the idea of passing a callback(Inclusion) here rather than a vector reference. It's much more obvious at the callsite what's going to happen (and doesn't force the use of the vector).
Also lifetime issues are still a little complicated, but easier to debug I think.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46675





More information about the cfe-commits mailing list