Fix an assertion when -print-prog-name= is invoked without parameter.
Returns an empty string.
Patch by Christian Bruel!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331296
91177308-0d34-0410-b5e6-
96231b3b80d8
}
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;
}
--- /dev/null
+// Test that -print-prog-name= correctly returns an empty string
+
+// RUN: %clang -print-prog-name= 2>&1 | FileCheck %s
+// CHECK-NOT:{{.+}}
+