// Show the error message and exit.
LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) {
- WithColor::error(errs(), ToolName) << Error << ".\n";
+ WithColor::error(errs(), ToolName) << Error << "\n";
printHelpMessage();
exit(1);
}
// associated with a, b, and i modifiers
static void getRelPos() {
if (PositionalArgs.empty())
- fail("Expected [relpos] for a, b, or i modifier");
+ fail("expected [relpos] for 'a', 'b', or 'i' modifier");
RelPos = PositionalArgs[0];
PositionalArgs.erase(PositionalArgs.begin());
}
// associated with the N modifier
static void getCountParam() {
if (PositionalArgs.empty())
- fail("Expected [count] for N modifier");
+ fail("expected [count] for 'N' modifier");
auto CountParamArg = StringRef(PositionalArgs[0]);
if (CountParamArg.getAsInteger(10, CountParam))
- fail("Value for [count] must be numeric, got: " + CountParamArg);
+ fail("value for [count] must be numeric, got: " + CountParamArg);
if (CountParam < 1)
- fail("Value for [count] must be positive, got: " + CountParamArg);
+ fail("value for [count] must be positive, got: " + CountParamArg);
PositionalArgs.erase(PositionalArgs.begin());
}
// Get the archive file name from the command line
static void getArchive() {
if (PositionalArgs.empty())
- fail("An archive name must be specified");
+ fail("an archive name must be specified");
ArchiveName = PositionalArgs[0];
PositionalArgs.erase(PositionalArgs.begin());
}
static object::Archive &readLibrary(const Twine &Library) {
auto BufOrErr = MemoryBuffer::getFile(Library, -1, false);
- failIfError(BufOrErr.getError(), "Could not open library " + Library);
+ failIfError(BufOrErr.getError(), "could not open library " + Library);
ArchiveBuffers.push_back(std::move(*BufOrErr));
auto LibOrErr =
object::Archive::create(ArchiveBuffers.back()->getMemBufferRef());
failIfError(errorToErrorCode(LibOrErr.takeError()),
- "Could not parse library");
+ "could not parse library");
Archives.push_back(std::move(*LibOrErr));
return *Archives.back();
}
static ArchiveOperation parseCommandLine() {
if (MRI) {
if (!PositionalArgs.empty() || !Options.empty())
- fail("Cannot mix -M and other options");
+ fail("cannot mix -M and other options");
runMRIScript();
}
NumOperations = 1;
Operation = CreateSymTab;
if (!Members.empty())
- fail("The s operation takes only an archive as argument");
+ fail("the 's' operation takes only an archive as argument");
}
// Perform various checks on the operation/modifier specification
// to make sure we are dealing with a legal request.
if (NumOperations == 0)
- fail("You must specify at least one of the operations");
+ fail("you must specify at least one of the operations");
if (NumOperations > 1)
- fail("Only one operation may be specified");
+ fail("only one operation may be specified");
if (NumPositional > 1)
- fail("You may only specify one of a, b, and i modifiers");
+ fail("you may only specify one of 'a', 'b', and 'i' modifiers");
if (AddAfter || AddBefore)
if (Operation != Move && Operation != ReplaceOrInsert)
- fail("The 'a', 'b' and 'i' modifiers can only be specified with "
+ fail("the 'a', 'b' and 'i' modifiers can only be specified with "
"the 'm' or 'r' operations");
if (CountParam)
if (Operation != Extract && Operation != Delete)
- fail("The 'N' modifier can only be specified with the 'x' or 'd' "
+ fail("the 'N' modifier can only be specified with the 'x' or 'd' "
"operations");
if (OriginalDates && Operation != Extract)
- fail("The 'o' modifier is only applicable to the 'x' operation");
+ fail("the 'o' modifier is only applicable to the 'x' operation");
if (OnlyUpdate && Operation != ReplaceOrInsert)
- fail("The 'u' modifier is only applicable to the 'r' operation");
+ fail("the 'u' modifier is only applicable to the 'r' operation");
if (AddLibrary && Operation != QuickAppend)
- fail("The 'L' modifier is only applicable to the 'q' operation");
+ fail("the 'L' modifier is only applicable to the 'q' operation");
// Return the parsed operation to the caller
return Operation;
const object::Archive::Child &M,
bool FlattenArchive = false) {
if (Thin && !M.getParent()->isThin())
- fail("Cannot convert a regular archive to a thin one");
+ fail("cannot convert a regular archive to a thin one");
Expected<NewArchiveMember> NMOrErr =
NewArchiveMember::getOldMember(M, Deterministic);
failIfError(NMOrErr.takeError());
return Ret;
if (!RelPos.empty() && InsertPos == -1)
- fail("Insertion point not found");
+ fail("insertion point not found");
if (RelPos.empty())
InsertPos = Ret.size();
break;
case BSD:
if (Thin)
- fail("Only the gnu format has a thin mode");
+ fail("only the gnu format has a thin mode");
Kind = object::Archive::K_BSD;
break;
case DARWIN:
if (Thin)
- fail("Only the gnu format has a thin mode");
+ fail("only the gnu format has a thin mode");
Kind = object::Archive::K_DARWIN;
break;
case Unknown:
MemoryBuffer::getFile(ArchiveName, -1, false);
std::error_code EC = Buf.getError();
if (EC && EC != errc::no_such_file_or_directory)
- fail("error opening '" + ArchiveName + "': " + EC.message() + "!");
+ fail("error opening '" + ArchiveName + "': " + EC.message());
if (!EC) {
Error Err = Error::success();
object::Archive Archive(Buf.get()->getMemBufferRef(), Err);
EC = errorToErrorCode(std::move(Err));
- failIfError(EC,
- "error loading '" + ArchiveName + "': " + EC.message() + "!");
+ failIfError(EC, "error loading '" + ArchiveName + "': " + EC.message());
if (Archive.isThin())
CompareFullPath = true;
performOperation(Operation, &Archive, std::move(Buf.get()), NewMembers);
case MRICommand::Create:
Create = true;
if (!ArchiveName.empty())
- fail("Editing multiple archives not supported");
+ fail("editing multiple archives not supported");
if (Saved)
- fail("File already saved");
+ fail("file already saved");
ArchiveName = Rest;
break;
case MRICommand::Delete: {
case MRICommand::End:
break;
case MRICommand::Invalid:
- fail("Unknown command: " + CommandStr);
+ fail("unknown command: " + CommandStr);
}
}
return 0;
} else {
if (ArchiveSpecified)
- fail("Exactly one archive should be specified");
+ fail("exactly one archive should be specified");
ArchiveSpecified = true;
ArchiveName = argv[i];
}
if (Stem.contains_lower("ar"))
return ar_main(argc, argv);
- fail("Not ranlib, ar, lib or dlltool!");
+ fail("not ranlib, ar, lib or dlltool");
}