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

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 12:47:09 PDT 2017


mstorsjo 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]++;
----------------
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).


https://reviews.llvm.org/D39538





More information about the llvm-commits mailing list