[PATCH] D137697: Move the isSelfContained function from clangd to libtooling.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 11 04:41:30 PST 2022


sammccall added inline comments.


================
Comment at: clang/lib/Tooling/Inclusions/Header.cpp:64
+  // particular preprocessor state, usually set up by another header.
+  return !isDontIncludeMeHeader(SM.getBufferData(SM.translateFile(FE)));
+}
----------------
kadircet wrote:
> sammccall wrote:
> > kadircet wrote:
> > > `translateFile` actually does a linear scan over all the slocentries, so i think it's better for this API to be based on FileID. (later on we can easily get fileentry from fileid in constant time)
> > You can get content through the fileentry directly, no?
> oh thanks for reminding that i forgot to mention it here, yes we can get that, but that would misbehave in the case of virtual/remapped files. so can you actually add a comment here about why we should get the contents from source manager?
But even when that remapping happens at the sourcemanager level, it happens on fileentries, not FileIDs (how would the latter even work?)

So SM.getMemoryBufferForFileOrNone(FileEntry)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137697



More information about the cfe-commits mailing list