Revert [llvm-ar] Include a line number when failing to parse an MRI script

Revert r372309 due to buildbot failures

Differential Revision: https://reviews.llvm.org/D67449

llvm-svn: 372311
This commit is contained in:
Owen Reynolds 2019-09-19 11:22:59 +00:00
parent cce2342d46
commit aa03c14827
3 changed files with 5 additions and 59 deletions

View File

@ -22,7 +22,7 @@
# RUN: not llvm-ar -M < %t/badlib.mri 2>&1 | FileCheck --check-prefix=PARSE %s # RUN: not llvm-ar -M < %t/badlib.mri 2>&1 | FileCheck --check-prefix=PARSE %s
# RUN: not ls %t/badlib.a # RUN: not ls %t/badlib.a
# PARSE: error: script line 2: could not parse library # PARSE: error: could not parse library
## No create command. ## No create command.
# RUN: echo "ADDLIB %t/f.a" > %t/nocreate.mri # RUN: echo "ADDLIB %t/f.a" > %t/nocreate.mri

View File

@ -1,41 +0,0 @@
## Test different MRI comment formats and whitespace.
# RUN: rm -rf %t && mkdir -p %t
# RUN: echo "create %t/mri.ar" > %t/script1.mri
# RUN: echo "addlib %t/missing.a" >> %t/script1.mri
# RUN: not llvm-ar -M < %t/script1.mri 2>&1 | FileCheck --check-prefix=SCRIPT1 %s
# SCRIPT1: error: script line 2: could not open library
# RUN: echo "create %t/mri.ar" > %t/script2.mri
# RUN: echo "addlib %t/bad.a" >> %t/script2.mri
# RUN: echo "bad archive" > %t/bad.a
# RUN: not llvm-ar -M < %t/script2.mri 2>&1 | FileCheck --check-prefix=SCRIPT2 %s
# SCRIPT2: error: script line 2: could not parse library
# RUN: echo "create %t/mri.ar" > %t/script3.mri
# RUN: echo "create %t/second.ar" >> %t/script3.mri
# RUN: not llvm-ar -M < %t/script3.mri 2>&1 | FileCheck --check-prefix=SCRIPT3 %s
# SCRIPT3: error: script line 2: editing multiple archives not supported
# RUN: echo "save" > %t/script4.mri
# RUN: echo "create %t/mri.ar" >> %t/script4.mri
# RUN: not llvm-ar -M < %t/script4.mri 2>&1 | FileCheck --check-prefix=SCRIPT4 %s
# SCRIPT4: error: script line 2: file already saved
# RUN: echo "create %t/mri.ar" > %t/script5.mri
# RUN: echo "bad command" >> %t/script5.mri
# RUN: not llvm-ar -M < %t/script5.mri 2>&1 | FileCheck --check-prefix=SCRIPT5 %s
# SCRIPT5: error: script line 2: unknown command: bad
# RUN: echo "bad command" | not llvm-ar -M 2>&1 | FileCheck --check-prefix=SCRIPT6 %s
# SCRIPT6: error: script line 1: unknown command: bad
# RUN: not llvm-ar -M rc %t/mri.ar 2>&1 | FileCheck --check-prefix=SCRIPT7 %s
# SCRIPT7: error: cannot mix -M and other options

View File

@ -116,19 +116,10 @@ void printHelpMessage() {
outs() << ArHelp; outs() << ArHelp;
} }
static unsigned MRILineNumber;
static bool ParsingMRIScript;
// Show the error message and exit. // Show the error message and exit.
LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) { LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) {
if (ParsingMRIScript) {
WithColor::error(errs(), ToolName)
<< "script line " << MRILineNumber << ": " << Error << "\n";
} else {
WithColor::error(errs(), ToolName) << Error << "\n"; WithColor::error(errs(), ToolName) << Error << "\n";
printHelpMessage(); printHelpMessage();
}
exit(1); exit(1);
} }
@ -968,10 +959,8 @@ static void runMRIScript() {
const MemoryBuffer &Ref = *Buf.get(); const MemoryBuffer &Ref = *Buf.get();
bool Saved = false; bool Saved = false;
std::vector<NewArchiveMember> NewMembers; std::vector<NewArchiveMember> NewMembers;
ParsingMRIScript = true;
for (line_iterator I(Ref, /*SkipBlanks*/ false), E; I != E; ++I) { for (line_iterator I(Ref, /*SkipBlanks*/ false), E; I != E; ++I) {
++MRILineNumber;
StringRef Line = *I; StringRef Line = *I;
Line = Line.split(';').first; Line = Line.split(';').first;
Line = Line.split('*').first; Line = Line.split('*').first;
@ -1034,8 +1023,6 @@ static void runMRIScript() {
} }
} }
ParsingMRIScript = false;
// Nothing to do if not saved. // Nothing to do if not saved.
if (Saved) if (Saved)
performOperation(ReplaceOrInsert, &NewMembers); performOperation(ReplaceOrInsert, &NewMembers);