Skip to content

Commit 6e1afd8

Browse files
committed
[lldb][NFC] Minor comment and inlining fixes for Args
The element count getter can just be in the header. Also doxygenify some of the comments and document m_argv's terminating nullptr element that the other comments keep mentioning.
1 parent b0f4ffb commit 6e1afd8

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

lldb/include/lldb/Utility/Args.h

+21-17
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ class Args {
115115
///
116116
/// \return
117117
/// The number or arguments in this object.
118-
size_t GetArgumentCount() const;
118+
size_t GetArgumentCount() const { return m_entries.size(); }
119+
119120
bool empty() const { return GetArgumentCount() == 0; }
120121

121122
/// Gets the NULL terminated C string argument pointer for the argument at
@@ -252,9 +253,9 @@ class Args {
252253
/// If the argument was originally quoted, put in the quote char here.
253254
void Unshift(llvm::StringRef arg_str, char quote_char = '\0');
254255

255-
// Clear the arguments.
256-
//
257-
// For re-setting or blanking out the list of arguments.
256+
/// Clear the arguments.
257+
///
258+
/// For re-setting or blanking out the list of arguments.
258259
void Clear();
259260

260261
static lldb::Encoding
@@ -266,21 +267,20 @@ class Args {
266267
static std::string GetShellSafeArgument(const FileSpec &shell,
267268
llvm::StringRef unsafe_arg);
268269

269-
// EncodeEscapeSequences will change the textual representation of common
270-
// escape sequences like "\n" (two characters) into a single '\n'. It does
271-
// this for all of the supported escaped sequences and for the \0ooo (octal)
272-
// and \xXX (hex). The resulting "dst" string will contain the character
273-
// versions of all supported escape sequences. The common supported escape
274-
// sequences are: "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\'", "\"", "\\".
275-
270+
/// EncodeEscapeSequences will change the textual representation of common
271+
/// escape sequences like "\n" (two characters) into a single '\n'. It does
272+
/// this for all of the supported escaped sequences and for the \0ooo (octal)
273+
/// and \xXX (hex). The resulting "dst" string will contain the character
274+
/// versions of all supported escape sequences. The common supported escape
275+
/// sequences are: "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\'", "\"", "\\".
276276
static void EncodeEscapeSequences(const char *src, std::string &dst);
277277

278-
// ExpandEscapeSequences will change a string of possibly non-printable
279-
// characters and expand them into text. So '\n' will turn into two
280-
// characters like "\n" which is suitable for human reading. When a character
281-
// is not printable and isn't one of the common in escape sequences listed in
282-
// the help for EncodeEscapeSequences, then it will be encoded as octal.
283-
// Printable characters are left alone.
278+
/// ExpandEscapeSequences will change a string of possibly non-printable
279+
/// characters and expand them into text. So '\n' will turn into two
280+
/// characters like "\n" which is suitable for human reading. When a character
281+
/// is not printable and isn't one of the common in escape sequences listed in
282+
/// the help for EncodeEscapeSequences, then it will be encoded as octal.
283+
/// Printable characters are left alone.
284284
static void ExpandEscapedCharacters(const char *src, std::string &dst);
285285

286286
static std::string EscapeLLDBCommandArgument(const std::string &arg,
@@ -290,6 +290,10 @@ class Args {
290290
friend struct llvm::yaml::MappingTraits<Args>;
291291

292292
std::vector<ArgEntry> m_entries;
293+
/// The arguments as C strings with a trailing nullptr element.
294+
///
295+
/// These strings are owned by the ArgEntry object in m_entries with the
296+
/// same index.
293297
std::vector<char *> m_argv;
294298
};
295299

lldb/source/Utility/Args.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ void Args::SetCommandString(llvm::StringRef command) {
256256
m_argv.push_back(nullptr);
257257
}
258258

259-
size_t Args::GetArgumentCount() const { return m_entries.size(); }
260-
261259
const char *Args::GetArgumentAtIndex(size_t idx) const {
262260
if (idx < m_argv.size())
263261
return m_argv[idx];

0 commit comments

Comments
 (0)