[PATCH] D106654: [clangd] Avoid range-loop init-list lifetime subtleties.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 23 06:34:36 PDT 2021
sammccall marked an inline comment as done.
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:288
};
- for (const auto &Entry : {CDBFile{&CompileCommandsJson, parseJSON},
- CDBFile{&BuildCompileCommandsJson, parseJSON},
- CDBFile{&CompileFlagsTxt, parseFixed}}) {
+ CDBFile Files[] = {
+ {&CompileCommandsJson, parseJSON},
----------------
kadircet wrote:
> kadircet wrote:
> > nit: I'd make it `static const` just to make sure they are not going away this time + it will save up some stack space.
> >
> > nit: Maybe also get rid of the struct's name ? (`static const struct { ... } Files[] = { ... };`)
> as discussed, `CachedFile` entries are actually pointers to members, so NVM the `static`.
There are pointers to members in here! The fact that `static const` even compiles is a massive footgun :-(
We should write a clang-tidy check for that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106654/new/
https://reviews.llvm.org/D106654
More information about the cfe-commits
mailing list