llvm.org GIT mirror llvm / af481e4
[llvm-ar] Support an options string that start with a dash Some projects call $AR like "$AR -crs output input1 input2". Differential Revision: https://reviews.llvm.org/D39538 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317358 91177308-0d34-0410-b5e6-96231b3b80d8 Martin Storsjo 1 year, 11 months ago
2 changed file(s) with 22 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
33 RUN: rm -f %t.ar
44 RUN: llvm-ar crs %t.ar %t-macho.o
55 RUN: grep -q __.SYMDEF %t.ar
6 RUN: llvm-ar crs %t.ar %t-coff.o
6 Test that an option string prefixed by a dash works.
7 RUN: llvm-ar -crs %t.ar %t-coff.o
78 RUN: grep -q __.SYMDEF %t.ar
89
910 RUN: rm -f %t.ar
126126 " [v] - be verbose about actions taken\n"
127127 );
128128
129 static const char OptionChars[] = "dmpqrtxabiosSTucv";
130
129131 // This enumeration delineates the kinds of operations on an archive
130132 // that are permitted.
131133 enum ArchiveOperation {
863865 Stem.find("lib") != StringRef::npos)
864866 return libDriverMain(makeArrayRef(argv, argc));
865867
868 for (int i = 1; i < argc; i++) {
869 // If an argument starts with a dash and only contains chars
870 // that belong to the options chars set, remove the dash.
871 // We can't handle it after the command line options parsing
872 // is done, since it will error out on an unrecognized string
873 // starting with a dash.
874 // Make sure this doesn't match the actual llvm-ar specific options
875 // that start with a dash.
876 StringRef S = argv[i];
877 if (S.startswith("-") &&
878 S.find_first_not_of(OptionChars, 1) == StringRef::npos) {
879 argv[i]++;
880 break;
881 }
882 if (S == "--")
883 break;
884 }
885
866886 // Have the command line options parsed and handle things
867887 // like --help and --version.
868888 cl::ParseCommandLineOptions(argc, argv,