[PATCH] D154602: [clang][clangd] Don't crash/assert on -gsplit-dwarf=single without output

Dmitry Polukhin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 6 09:59:32 PDT 2023


DmitryPolukhin updated this revision to Diff 537774.
DmitryPolukhin added a comment.

Rebase and uun clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154602

Files:
  clang-tools-extra/clangd/unittests/CompilerTests.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1271,7 +1271,7 @@
     F += ".dwo";
   };
   if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
-    if (StringRef(A->getValue()) == "single")
+    if (StringRef(A->getValue()) == "single" && Output.isFilename())
       return Args.MakeArgString(Output.getFilename());
 
   SmallString<128> T;
Index: clang-tools-extra/clangd/unittests/CompilerTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CompilerTests.cpp
+++ clang-tools-extra/clangd/unittests/CompilerTests.cpp
@@ -113,6 +113,13 @@
   // No crash.
   EXPECT_EQ(buildCompilerInvocation(Inputs, Diags), nullptr);
 }
+
+TEST(BuildCompilerInvocation, SplitSwarfSingleCrash) {
+  TestTU TU;
+  TU.ExtraArgs = {"-gdwarf-4", "-gsplit-dwarf=single"};
+  TU.build(); // no-crash
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154602.537774.patch
Type: text/x-patch
Size: 1086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230706/5e759b66/attachment-0001.bin>


More information about the cfe-commits mailing list