sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

The original code appears to be OK per the spec, but we've had 3 reports of
crashes with certain unofficial builds of clangd that look a lot like old
compilers (GCC 5.4?) getting lifetime rules wrong.

Fixes https://github.com/clangd/clangd/issues/800


Repository:
  rG LLVM Github Monorepo

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
@@ -285,9 +285,12 @@
         /*ErrorMsg*/ std::string &)>
         Parser;
   };
-  for (const auto &Entry : {CDBFile{&CompileCommandsJson, parseJSON},
-                            CDBFile{&BuildCompileCommandsJson, parseJSON},
-                            CDBFile{&CompileFlagsTxt, parseFixed}}) {
+  CDBFile Files[] = {
+      {&CompileCommandsJson, parseJSON},
+      {&BuildCompileCommandsJson, parseJSON},
+      {&CompileFlagsTxt, parseFixed},
+  };
+  for (const auto &Entry : Files) {
     bool Active = ActiveCachedFile == Entry.File;
     auto Loaded = Entry.File->load(FS, Active);
     switch (Loaded.Result) {


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===================================================================
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -285,9 +285,12 @@
         /*ErrorMsg*/ std::string &)>
         Parser;
   };
-  for (const auto &Entry : {CDBFile{&CompileCommandsJson, parseJSON},
-                            CDBFile{&BuildCompileCommandsJson, parseJSON},
-                            CDBFile{&CompileFlagsTxt, parseFixed}}) {
+  CDBFile Files[] = {
+      {&CompileCommandsJson, parseJSON},
+      {&BuildCompileCommandsJson, parseJSON},
+      {&CompileFlagsTxt, parseFixed},
+  };
+  for (const auto &Entry : Files) {
     bool Active = ActiveCachedFile == Entry.File;
     auto Loaded = Entry.File->load(FS, Active);
     switch (Loaded.Result) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to