This is an archive of the discontinued LLVM Phabricator instance.

Modernize Enable/DisableLogChannel interface a bit
ClosedPublic

Authored by labath on Feb 27 2017, 4:42 AM.

Details

Summary

Use StringRef and ArrayRef where possible. This adds an accessor to the
Args class to get a view of the arguments as ArrayRef<const char *>.

Event Timeline

labath created this revision.Feb 27 2017, 4:42 AM
zturner added inline comments.Feb 27 2017, 11:58 AM
include/lldb/Interpreter/Args.h
196–197

can this be written return makeArrayRef(m_argv).drop_back();?

source/API/SBDebugger.cpp
1129

makeArrayRef(categories, len) again seems more readable.

source/Core/Log.cpp
74–80

How about

bool exists = llvm::any(entry.second.channel.categories,
        [&](const Log::Category &c) { return c.name.equals_lower(category); }));
if (exists) {
  ...
}
unittests/Interpreter/TestArgs.cpp
174

I'd probably use auto here since the function indicates that it's returning an ArrayRef. I don't feel strongly though.

labath updated this revision to Diff 89996.Feb 28 2017, 2:54 AM
labath marked 3 inline comments as done.

Address review comments

include/lldb/Interpreter/Args.h
196–197

Yes, it looks like it can.

source/Core/Log.cpp
74–80

That won't work, because I actually need the relevant iterator to get the associated flag (flags |= cat->flag below).

labath updated this revision to Diff 90000.Feb 28 2017, 3:08 AM

rebase on top of tree

This revision was automatically updated to reflect the committed changes.