[PATCH] D106654: [clangd] Avoid range-loop init-list lifetime subtleties.

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 23 06:27:05 PDT 2021


kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks! it is unfortunate that history won't remember what an adventure it was to figure out the issue :D



================
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},
----------------
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[] = { ... };`)


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