[PATCH] D39538: [llvm-ar] Support an options string that start with a dash

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 12:51:42 PDT 2017


ruiu added inline comments.


================
Comment at: tools/llvm-ar/llvm-ar.cpp:892-893
+    // that start with a dash.
+    if (argv[i][0] == '-' &&
+        strspn(&argv[i][1], OptionChars) + 1 == strlen(argv[i])) {
+      argv[i]++;
----------------
smeenai wrote:
> mstorsjo wrote:
> > ruiu wrote:
> > > If you are going to use StringRef, then something like this is probably better than using stdlib's string functions.
> > > 
> > >   StringRef S = argv[i];
> > >   if (S.startswith("-") && S.find_first_of("dmpqrtxabiosSTucv") == StringRef::npos)
> > Ok, I can do something like that. Although I prefer to keep the definition of the chars string where I have it right now (close to the docs listing the option chars).
> Did you mean `find_first_not_of`?
Ah, yes. Thank you for the correction.


https://reviews.llvm.org/D39538





More information about the llvm-commits mailing list