[PATCH] D92663: [clangd] Add hot-reload of compile_commands.json and compile_flags.txt
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 18 02:06:48 PST 2020
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:217
+ if (!Buf || (*Buf)->getBufferSize() != Stat->getSize()) {
+ Size = NoFileCached;
+ elog("Failed to read {0}: {1}", Path,
----------------
sammccall wrote:
> adamcz wrote:
> > Why throw away the information we have? Better keep the cached metadata around, transient error here could mean the build system is re-creating the file, but it may end up being identical to what we already read, it's just that someone re-run cmake or something.
> Good point, done.
>
> Of course this relies on us getting "lucky" and seeing two different sizes for the file between the calls. If it's being written then we could e.g. see it with size 0 on both stat and read, and then we'll throw away the content.
>
> The way around this would be to e.g. call an unparseable file a transient error (reuse cached value), which requires some structural changes here I think. What do you think about that? (I think this would help with compile_commands.json but not compile_flags.txt)
> Another way would be to handle a size of 0 as a special case (presumed invalid), which may catch the practical cases.
Decided not to do anything about this for now, the most common generator is cmake and it does atomic writes. Seems likely other build systems will too.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92663/new/
https://reviews.llvm.org/D92663
More information about the cfe-commits
mailing list