Asserts in StringRef::front

I fixed a bug in CommandObject::Execute that cause test-suite crashes when running with an Assert build of llvm (r283479.)

The test was doing:

break modify -c ''

which is the way you unset a condition on a breakpoint.

So the StringRef for that option value was empty, and it appears that you aren't supposed to call "front" on an empty StringRef. But empty option values are used in a bunch of places in lldb.

Zachary, you might want to go scrub through the Args changes (and anywhere else you might be parsing an empty StringRef) to make sure there aren't other errors of this sort.

And if you aren't running your prep testsuite runs with an Assert build of llvm, it's probably a good idea to do so.


Thanks for the heads up. I do run with asserts, so I’m not sure why I didn’t see this particular failure. In any case i’ll go back and look through my changes for any other occurrences of this.

Most of the time args were being checked before being used. Like the code would go:

const char *arg = args.GetArgumentAtIndex(i);
if (!arg || arg[0] == ‘\0’)

// Use it.

I shouldn’t have messed up any of those because I converted them all to

if (arg.empty())

So hopefully the one you found is the only one.