diff options
| author | Owen Reynolds <gbreynoo@gmail.com> | 2019-09-19 10:51:43 +0000 |
|---|---|---|
| committer | Owen Reynolds <gbreynoo@gmail.com> | 2019-09-19 10:51:43 +0000 |
| commit | 04398c729b20c16aa06bfab4330cf1831d1f8dec (patch) | |
| tree | 27976771f78a295e636546646e43d253054465ea /llvm/tools/llvm-ar/llvm-ar.cpp | |
| parent | da89495a3e73bfc02ffb7d881da1db628d1d0815 (diff) | |
| download | bcm5719-llvm-04398c729b20c16aa06bfab4330cf1831d1f8dec.tar.gz bcm5719-llvm-04398c729b20c16aa06bfab4330cf1831d1f8dec.zip | |
[llvm-ar] Include a line number when failing to parse an MRI script
Errors that occur when reading an MRI script now include a corresponding
line number.
Differential Revision: https://reviews.llvm.org/D67449
llvm-svn: 372309
Diffstat (limited to 'llvm/tools/llvm-ar/llvm-ar.cpp')
| -rw-r--r-- | llvm/tools/llvm-ar/llvm-ar.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index 006d8ed74cf..568c603fc32 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -116,10 +116,19 @@ void printHelpMessage() { outs() << ArHelp; } +static unsigned MRILineNumber; +static bool ParsingMRIScript; + // Show the error message and exit. LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) { - WithColor::error(errs(), ToolName) << Error << "\n"; - printHelpMessage(); + if (ParsingMRIScript) { + WithColor::error(errs(), ToolName) + << "script line " << MRILineNumber << ": " << Error << "\n"; + } else { + WithColor::error(errs(), ToolName) << Error << "\n"; + printHelpMessage(); + } + exit(1); } @@ -959,8 +968,10 @@ static void runMRIScript() { const MemoryBuffer &Ref = *Buf.get(); bool Saved = false; std::vector<NewArchiveMember> NewMembers; + ParsingMRIScript = true; for (line_iterator I(Ref, /*SkipBlanks*/ false), E; I != E; ++I) { + ++MRILineNumber; StringRef Line = *I; Line = Line.split(';').first; Line = Line.split('*').first; @@ -1022,7 +1033,9 @@ static void runMRIScript() { fail("unknown command: " + CommandStr); } } - + + ParsingMRIScript = false; + // Nothing to do if not saved. if (Saved) performOperation(ReplaceOrInsert, &NewMembers); |

