Author: Raphael Isemann Date: 2021-02-05T10:17:16+01:00 New Revision: 6e1afd858757256afdb619665befb790c76418bb
URL: https://github.com/llvm/llvm-project/commit/6e1afd858757256afdb619665befb790c76418bb DIFF: https://github.com/llvm/llvm-project/commit/6e1afd858757256afdb619665befb790c76418bb.diff LOG: [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. Added: Modified: lldb/include/lldb/Utility/Args.h lldb/source/Utility/Args.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Utility/Args.h b/lldb/include/lldb/Utility/Args.h index b93677b53935..cecf6b1502b5 100644 --- a/lldb/include/lldb/Utility/Args.h +++ b/lldb/include/lldb/Utility/Args.h @@ -115,7 +115,8 @@ class Args { /// /// \return /// The number or arguments in this object. - size_t GetArgumentCount() const; + size_t GetArgumentCount() const { return m_entries.size(); } + bool empty() const { return GetArgumentCount() == 0; } /// Gets the NULL terminated C string argument pointer for the argument at @@ -252,9 +253,9 @@ class Args { /// If the argument was originally quoted, put in the quote char here. void Unshift(llvm::StringRef arg_str, char quote_char = '\0'); - // Clear the arguments. - // - // For re-setting or blanking out the list of arguments. + /// Clear the arguments. + /// + /// For re-setting or blanking out the list of arguments. void Clear(); static lldb::Encoding @@ -266,21 +267,20 @@ class Args { static std::string GetShellSafeArgument(const FileSpec &shell, llvm::StringRef unsafe_arg); - // EncodeEscapeSequences will change the textual representation of common - // escape sequences like "\n" (two characters) into a single '\n'. It does - // this for all of the supported escaped sequences and for the \0ooo (octal) - // and \xXX (hex). The resulting "dst" string will contain the character - // versions of all supported escape sequences. The common supported escape - // sequences are: "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\'", "\"", "\\". - + /// EncodeEscapeSequences will change the textual representation of common + /// escape sequences like "\n" (two characters) into a single '\n'. It does + /// this for all of the supported escaped sequences and for the \0ooo (octal) + /// and \xXX (hex). The resulting "dst" string will contain the character + /// versions of all supported escape sequences. The common supported escape + /// sequences are: "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\'", "\"", "\\". static void EncodeEscapeSequences(const char *src, std::string &dst); - // ExpandEscapeSequences will change a string of possibly non-printable - // characters and expand them into text. So '\n' will turn into two - // characters like "\n" which is suitable for human reading. When a character - // is not printable and isn't one of the common in escape sequences listed in - // the help for EncodeEscapeSequences, then it will be encoded as octal. - // Printable characters are left alone. + /// ExpandEscapeSequences will change a string of possibly non-printable + /// characters and expand them into text. So '\n' will turn into two + /// characters like "\n" which is suitable for human reading. When a character + /// is not printable and isn't one of the common in escape sequences listed in + /// the help for EncodeEscapeSequences, then it will be encoded as octal. + /// Printable characters are left alone. static void ExpandEscapedCharacters(const char *src, std::string &dst); static std::string EscapeLLDBCommandArgument(const std::string &arg, @@ -290,6 +290,10 @@ class Args { friend struct llvm::yaml::MappingTraits<Args>; std::vector<ArgEntry> m_entries; + /// The arguments as C strings with a trailing nullptr element. + /// + /// These strings are owned by the ArgEntry object in m_entries with the + /// same index. std::vector<char *> m_argv; }; diff --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp index ed61e1c16303..60d0790c9d29 100644 --- a/lldb/source/Utility/Args.cpp +++ b/lldb/source/Utility/Args.cpp @@ -256,8 +256,6 @@ void Args::SetCommandString(llvm::StringRef command) { m_argv.push_back(nullptr); } -size_t Args::GetArgumentCount() const { return m_entries.size(); } - const char *Args::GetArgumentAtIndex(size_t idx) const { if (idx < m_argv.size()) return m_argv[idx]; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits