r331296 - Driver: fix an assertion with `-print-prog-name=`
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Tue May 1 11:40:42 PDT 2018
Author: compnerd
Date: Tue May 1 11:40:42 2018
New Revision: 331296
URL: http://llvm.org/viewvc/llvm-project?rev=331296&view=rev
Log:
Driver: fix an assertion with `-print-prog-name=`
Fix an assertion when -print-prog-name= is invoked without parameter.
Returns an empty string.
Patch by Christian Bruel!
Added:
cfe/trunk/test/Driver/print-empty-prog-name.c
Modified:
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=331296&r1=331295&r2=331296&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue May 1 11:40:42 2018
@@ -1594,7 +1594,13 @@ bool Driver::HandleImmediateArgs(const C
}
if (Arg *A = C.getArgs().getLastArg(options::OPT_print_prog_name_EQ)) {
- llvm::outs() << GetProgramPath(A->getValue(), TC) << "\n";
+ StringRef ProgName = A->getValue();
+
+ // Null program name cannot have a path.
+ if (! ProgName.empty())
+ llvm::outs() << GetProgramPath(ProgName, TC);
+
+ llvm::outs() << "\n";
return false;
}
Added: cfe/trunk/test/Driver/print-empty-prog-name.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/print-empty-prog-name.c?rev=331296&view=auto
==============================================================================
--- cfe/trunk/test/Driver/print-empty-prog-name.c (added)
+++ cfe/trunk/test/Driver/print-empty-prog-name.c Tue May 1 11:40:42 2018
@@ -0,0 +1,5 @@
+// Test that -print-prog-name= correctly returns an empty string
+
+// RUN: %clang -print-prog-name= 2>&1 | FileCheck %s
+// CHECK-NOT:{{.+}}
+
More information about the cfe-commits
mailing list