[clang] 20c873c - [PS5] Avoid a driver crash

Paul Robinson via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 19 15:55:42 PDT 2022


Author: Paul Robinson
Date: 2022-04-19T15:55:32-07:00
New Revision: 20c873c12fa5563bbfb07c880db51fa68db571cc

URL: https://github.com/llvm/llvm-project/commit/20c873c12fa5563bbfb07c880db51fa68db571cc
DIFF: https://github.com/llvm/llvm-project/commit/20c873c12fa5563bbfb07c880db51fa68db571cc.diff

LOG: [PS5] Avoid a driver crash

In some cases, an error constructing a compiler or assembler job could
leave the Inputs in a state that the code for constructing the linker
job was not ready for.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/CommonArgs.cpp
    clang/test/Driver/no-integrated-as.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1207bf37b5bb0..96a54228626f6 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -255,6 +255,10 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
       continue;
     }
 
+    // In some error cases, the input could be Nothing; skip those.
+    if (II.isNothing())
+      continue;
+
     // Otherwise, this is a linker input argument.
     const Arg &A = II.getInputArg();
 

diff  --git a/clang/test/Driver/no-integrated-as.c b/clang/test/Driver/no-integrated-as.c
index 6f45a6050e9fd..617e319764efb 100644
--- a/clang/test/Driver/no-integrated-as.c
+++ b/clang/test/Driver/no-integrated-as.c
@@ -13,8 +13,9 @@
 
 // DEFAULT-NOT: -no-integrated-as
 
-// RUN: %clang -target x86_64-sie-ps5 -### -no-integrated-as %s -c 2>&1 \
+/// -c omitted on purpose, this used to crash.
+// RUN: %clang -target x86_64-sie-ps5 -### -no-integrated-as %s 2>&1 \
 // RUN:     | FileCheck %s -check-prefix PS5
-// RUN: %clang -target x86_64-sie-ps5 -### -no-integrated-as %s -c -x assembler 2>&1 \
+// RUN: %clang -target x86_64-sie-ps5 -### -no-integrated-as %s -x assembler 2>&1 \
 // RUN:     | FileCheck %s -check-prefix PS5
 // PS5: there is no external assembler that can be used on this platform


        


More information about the cfe-commits mailing list