[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:09 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG253b8145dedb: [clangd] Avoid range-loop init-list lifetime subtleties. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D106654?vs=361165&id=361177#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106654

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===================================================================
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -276,7 +276,7 @@
   // For these, we know the files they read and cache their metadata so we can
   // cheaply validate whether they've changed, and hot-reload if they have.
   // (As a bonus, these are also VFS-clean)!
-  struct CDBFile {
+  struct {
     CachedFile *File;
     // Wrapper for {Fixed,JSON}CompilationDatabase::loadFromBuffer.
     llvm::function_ref<std::unique_ptr<tooling::CompilationDatabase>(
@@ -284,10 +284,12 @@
         /*Data*/ llvm::StringRef,
         /*ErrorMsg*/ std::string &)>
         Parser;
+  } Files[] = {
+      {&CompileCommandsJson, parseJSON},
+      {&BuildCompileCommandsJson, parseJSON},
+      {&CompileFlagsTxt, parseFixed},
   };
-  for (const auto &Entry : {CDBFile{&CompileCommandsJson, parseJSON},
-                            CDBFile{&BuildCompileCommandsJson, parseJSON},
-                            CDBFile{&CompileFlagsTxt, parseFixed}}) {
+  for (const auto &Entry : Files) {
     bool Active = ActiveCachedFile == Entry.File;
     auto Loaded = Entry.File->load(FS, Active);
     switch (Loaded.Result) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106654.361177.patch
Type: text/x-patch
Size: 1314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210723/14baaa3a/attachment.bin>


More information about the cfe-commits mailing list