[PATCH] D106203: [clangd] Propagate header-guarded flag from preamble to main AST

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 21 02:19:21 PDT 2021


sammccall added a comment.

Sorry, forgot to address the style comments. Will send a followup patch.



================
Comment at: clang-tools-extra/clangd/Preamble.cpp:87
+
+    const SourceManager &SM = CI.getSourceManager();
+    const FileEntry *MainFE = SM.getFileEntryForID(SM.getMainFileID());
----------------
kadircet wrote:
> nit: maybe do this at the top and keep the early exit?
that makes sense if ParsedCallback is the "main line" case that we're bailing out of (which is how it was written before), but I don't really see it that way.


================
Comment at: clang-tools-extra/clangd/Preamble.cpp:400
+        std::move(StatCache), CapturedInfo.takeCanonicalIncludes());
+    Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded();
+    return Result;
----------------
kadircet wrote:
> any reason for not making this part of the constructor ?
I think this pattern of constructor (long list of args, forwards them into public fields) isn't terribly useful, but I should have been consistent here.

Will send a cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106203



More information about the cfe-commits mailing list