diff options
| author | Owen Reynolds <gbreynoo@gmail.com> | 2019-09-20 08:10:14 +0000 |
|---|---|---|
| committer | Owen Reynolds <gbreynoo@gmail.com> | 2019-09-20 08:10:14 +0000 |
| commit | 25040f8dec2e2dda5b0951744f9a32fb7aab3755 (patch) | |
| tree | 2e6270bd065f377d6cbad8dcc6dfdbce9498cae7 /llvm/tools/llvm-ar/llvm-ar.cpp | |
| parent | 621c93ec1fd804f736cbcb58282ef037fa1a9c48 (diff) | |
| download | bcm5719-llvm-25040f8dec2e2dda5b0951744f9a32fb7aab3755.tar.gz bcm5719-llvm-25040f8dec2e2dda5b0951744f9a32fb7aab3755.zip | |
Reapply [llvm-ar] Include a line number when failing to parse an MRI script
Reapply r372309
Errors that occur when reading an MRI script now include a corresponding
line number.
Differential Revision: https://reviews.llvm.org/D67449
llvm-svn: 372374
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 65a86192091..4eb50a12490 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); } @@ -958,8 +967,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; @@ -1021,7 +1032,9 @@ static void runMRIScript() { fail("unknown command: " + CommandStr); } } - + + ParsingMRIScript = false; + // Nothing to do if not saved. if (Saved) performOperation(ReplaceOrInsert, &NewMembers); |

