summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/COFF/Driver.cpp5
-rw-r--r--lld/test/COFF/invalid-debug-type.test11
-rw-r--r--llvm/include/llvm/Option/Arg.h8
3 files changed, 19 insertions, 5 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index c1520a4ae12..413b1e7a30f 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -642,7 +642,8 @@ static unsigned parseDebugTypes(const opt::InputArgList &Args) {
if (auto *A = Args.getLastArg(OPT_debugtype)) {
SmallVector<StringRef, 3> Types;
- A->getSpelling().split(Types, ',', /*KeepEmpty=*/false);
+ StringRef(A->getValue())
+ .split(Types, ',', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
for (StringRef Type : Types) {
unsigned V = StringSwitch<unsigned>(Type.lower())
@@ -651,7 +652,7 @@ static unsigned parseDebugTypes(const opt::InputArgList &Args) {
.Case("fixup", static_cast<unsigned>(DebugType::Fixup))
.Default(0);
if (V == 0) {
- warn("/debugtype: unknown option: " + Twine(A->getValue()));
+ warn("/debugtype: unknown option '" + Type + "'");
continue;
}
DebugTypes |= V;
diff --git a/lld/test/COFF/invalid-debug-type.test b/lld/test/COFF/invalid-debug-type.test
index 0fa40b0312b..de6add7dfdb 100644
--- a/lld/test/COFF/invalid-debug-type.test
+++ b/lld/test/COFF/invalid-debug-type.test
@@ -1,6 +1,11 @@
# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
-# RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
-# RUN: %t1.obj %t2.obj 2>&1 | FileCheck %s
+# RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll \
+# RUN: /entry:main /nodefaultlib %t1.obj %t2.obj 2>&1 | FileCheck %s
+# CHECK: /debugtype: unknown option 'invalid'
-# CHECK: /debugtype: unknown option: invalid \ No newline at end of file
+# RUN: lld-link /debug /debugtype:invalid,foo /pdb:%t.pdb /dll /out:%t.dll \
+# RUN: /entry:main /nodefaultlib %t1.obj %t2.obj 2>&1 | \
+# RUN: FileCheck --check-prefix=TWO %s
+# TWO: /debugtype: unknown option 'invalid'
+# TWO: /debugtype: unknown option 'foo'
diff --git a/llvm/include/llvm/Option/Arg.h b/llvm/include/llvm/Option/Arg.h
index d3623a0c1e4..8c4787051cf 100644
--- a/llvm/include/llvm/Option/Arg.h
+++ b/llvm/include/llvm/Option/Arg.h
@@ -70,7 +70,15 @@ public:
~Arg();
const Option &getOption() const { return Opt; }
+
+ /// Returns the used prefix and name of the option:
+ /// For `--foo=bar`, returns `--foo=`.
+ /// This is often the wrong function to call:
+ /// * Use `getValue()` to get `bar`.
+ /// * Use `getAsString()` to get a string suitable for printing an Arg in
+ /// a diagnostic.
StringRef getSpelling() const { return Spelling; }
+
unsigned getIndex() const { return Index; }
/// Return the base argument which generated this arg.
OpenPOWER on IntegriCloud