This is an archive of the discontinued LLVM Phabricator instance.

Allow to construct CMIUtilString using std::string directly + cleanup CMIUtilString (MI)
ClosedPublic

Authored by ki.stfu on Sep 24 2015, 11:19 PM.

Details

Summary

Allow to construct CMIUtilString using std::string directly + cleanup CMIUtilString (MI)

This patch cleans up lldb-mi code, and serves to simplify
the following case:

std::string strGoodbye = "!Hello";
CMIUtilString strHello(strGoodbye.substr(1).c_str());

With CMIUtilString(std::string) we can omit .c_str():

std::string strGoodbye = "!Hello";
CMIUtilString strHello(strGoodbye.substr(1));

Also, it removes 2 ctors because they aren't needed:

  1. CMIUtilString::CMIUtilString(const char *const *vpData)
  2. CMIUtilString::CMIUtilString(const char *vpData, size_t nLen)

and cleans up CMIUtilString::operator=(const std::string &vrRhs).

Diff Detail

Repository
rL LLVM

Event Timeline

ki.stfu updated this revision to Diff 35702.Sep 24 2015, 11:19 PM
ki.stfu retitled this revision from to Allow to construct CMIUtilString using std::string directly (MI).
ki.stfu updated this object.
ki.stfu added reviewers: abidh, brucem.
ki.stfu added subscribers: abidh, brucem, lldb-commits.
ki.stfu updated this object.Sep 24 2015, 11:21 PM
brucem added inline comments.Sep 24 2015, 11:27 PM
tools/lldb-mi/MICmdInterpreter.cpp
166 ↗(On Diff #35702)

Can this one be changed too?

ki.stfu added inline comments.Sep 24 2015, 11:30 PM
tools/lldb-mi/MICmdInterpreter.cpp
166 ↗(On Diff #35702)

Sure.

ki.stfu updated this revision to Diff 35703.Sep 24 2015, 11:36 PM

A little fix as @brucem requested; Remove CMIUtilString(const char *const *vpData) and CMIUtilString(const char *vpData, size_t nLen) ctors; Cleanup CMIUtilString::operator=(const std::string &vrRhs)

ki.stfu retitled this revision from Allow to construct CMIUtilString using std::string directly (MI) to Allow to construct CMIUtilString using std::string directly + cleanup CMIUtilString (MI).Sep 24 2015, 11:40 PM
ki.stfu updated this object.

I perceive it as a simple patch, so I am going to go ahead.

brucem accepted this revision.Sep 25 2015, 1:06 AM
brucem edited edge metadata.
This revision is now accepted and ready to land.Sep 25 2015, 1:06 AM
abidh accepted this revision.Sep 25 2015, 1:28 AM
abidh edited edge metadata.
ki.stfu closed this revision.Sep 25 2015, 1:30 AM
This revision was automatically updated to reflect the committed changes.