[PATCH] Driver: support detecting driver mode when clang has a version suffix without dash (PR21094)
Hans Wennborg
hans at chromium.org
Fri Oct 17 10:18:04 PDT 2014
================
Comment at: tools/driver/driver.cpp:258
@@ +257,3 @@
+ if (!DS) {
+ // Try again after stripping trailing -component.
+ ProgNameRef = ProgNameRef.slice(0, ProgNameRef.rfind('-'));
----------------
dblaikie wrote:
> Might help if these comments were maybe illustrated with an example:
>
> // Strip trailing version: clang-3.4 -> clang
>
> // Strip trailing -component: clang-foo -> clang
Done.
================
Comment at: tools/driver/driver.cpp:251
@@ +250,3 @@
+ while (!ProgNameRef.empty() &&
+ (isDigit(ProgNameRef.back()) || ProgNameRef.back() == '.'))
+ ProgNameRef = ProgNameRef.drop_back(1);
----------------
dblaikie wrote:
> hans wrote:
> > dblaikie wrote:
> > > the extra parens around the isDigit call are a bit confusing/misleading (I saw the end ')' and thought it was maybe grouped with the empty() call above for some reason)
> > The extra parenthesis are around the || expression.
> >
> > Anyway, I've rewritten this with less parenthesis, and fitting on one line.
> Oh, right - I just can't count. Sorry about that.
>
> The new version isn't necessarily 'portable' to interesting digit characters in other languages? Maybe? Dunno if that's important.
>
> If you're going to write it that way, I'll at least optionally suggest that you could use StringRef's find_last_not_of to do that search.
I found that StringRef has an rtrim(); I think that's what we want here.
http://reviews.llvm.org/D5833
More information about the cfe-commits
mailing list