[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
Tue Jul 11 11:51:12 PDT 2023


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

Added -target arm-linux-gnueabi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154602

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===================================================================
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -367,6 +367,19 @@
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(CompilerInvocation, SplitSwarfSingleCrash) {
+  static constexpr const char *Args[] = {"clang",
+                                         "-target",
+                                         "arm-linux-gnueabi",
+                                         "-gdwarf-4",
+                                         "-gsplit-dwarf=single",
+                                         "-c",
+                                         "foo.cpp"};
+  CreateInvocationOptions CIOpts;
+  std::unique_ptr<CompilerInvocation> CI = createInvocation(Args, CIOpts);
+  EXPECT_TRUE(CI); // no-crash
+}
+
 TEST(GetDriverMode, PrefersLastDriverMode) {
   static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo",
                                          "--driver-mode=bar", "foo.cpp"};
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1269,7 +1269,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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154602.539223.patch
Type: text/x-patch
Size: 1571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230711/6db86fb2/attachment-0001.bin>


More information about the cfe-commits mailing list