diff options
author | Adrian Prantl <aprantl@apple.com> | 2018-04-30 16:49:04 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2018-04-30 16:49:04 +0000 |
commit | 05097246f352eca76207c9ebb08656c88bdf751a (patch) | |
tree | bfc4ec8250a939aaf4ade6fc6c528726183e5367 /lldb/source/Utility | |
parent | add59c052dd6768fd54431e6a3bf045e7f25cb59 (diff) | |
download | llvm-05097246f352eca76207c9ebb08656c88bdf751a.zip llvm-05097246f352eca76207c9ebb08656c88bdf751a.tar.gz llvm-05097246f352eca76207c9ebb08656c88bdf751a.tar.bz2 |
Reflow paragraphs in comments.
This is intended as a clean up after the big clang-format commit
(r280751), which unfortunately resulted in many of the comment
paragraphs in LLDB being very hard to read.
FYI, the script I used was:
import textwrap
import commands
import os
import sys
import re
tmp = "%s.tmp"%sys.argv[1]
out = open(tmp, "w+")
with open(sys.argv[1], "r") as f:
header = ""
text = ""
comment = re.compile(r'^( *//) ([^ ].*)$')
special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$')
for line in f:
match = comment.match(line)
if match and not special.match(match.group(2)):
# skip intentionally short comments.
if not text and len(match.group(2)) < 40:
out.write(line)
continue
if text:
text += " " + match.group(2)
else:
header = match.group(1)
text = match.group(2)
continue
if text:
filled = textwrap.wrap(text, width=(78-len(header)),
break_long_words=False)
for l in filled:
out.write(header+" "+l+'\n')
text = ""
out.write(line)
os.rename(tmp, sys.argv[1])
Differential Revision: https://reviews.llvm.org/D46144
llvm-svn: 331197
Diffstat (limited to 'lldb/source/Utility')
-rw-r--r-- | lldb/source/Utility/ArchSpec.cpp | 71 | ||||
-rw-r--r-- | lldb/source/Utility/Args.cpp | 50 | ||||
-rw-r--r-- | lldb/source/Utility/ConstString.cpp | 28 | ||||
-rw-r--r-- | lldb/source/Utility/DataBufferHeap.cpp | 21 | ||||
-rw-r--r-- | lldb/source/Utility/DataEncoder.cpp | 78 | ||||
-rw-r--r-- | lldb/source/Utility/DataExtractor.cpp | 250 | ||||
-rw-r--r-- | lldb/source/Utility/FastDemangle.cpp | 83 | ||||
-rw-r--r-- | lldb/source/Utility/FileSpec.cpp | 98 | ||||
-rw-r--r-- | lldb/source/Utility/JSON.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Utility/Log.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Utility/RegularExpression.cpp | 43 | ||||
-rw-r--r-- | lldb/source/Utility/SelectHelper.cpp | 5 | ||||
-rw-r--r-- | lldb/source/Utility/SharingPtr.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Utility/Status.cpp | 37 | ||||
-rw-r--r-- | lldb/source/Utility/Stream.cpp | 25 | ||||
-rw-r--r-- | lldb/source/Utility/StringExtractor.cpp | 23 | ||||
-rw-r--r-- | lldb/source/Utility/StringExtractorGDBRemote.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Utility/StructuredData.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Utility/UUID.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Utility/VASprintf.cpp | 4 |
20 files changed, 402 insertions, 465 deletions
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index 7739520..8b2e693 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -223,8 +223,8 @@ static const CoreDefinition g_core_definitions[] = { "kalimba5"}}; // Ensure that we have an entry in the g_core_definitions for each core. If you -// comment out an entry above, -// you will need to comment out the corresponding ArchSpec::Core enumeration. +// comment out an entry above, you will need to comment out the corresponding +// ArchSpec::Core enumeration. static_assert(sizeof(g_core_definitions) / sizeof(CoreDefinition) == ArchSpec::kNumCores, "make sure we have one core definition for each core"); @@ -891,9 +891,9 @@ void ArchSpec::MergeFrom(const ArchSpec &other) { if (GetTriple().getArch() == llvm::Triple::UnknownArch) { GetTriple().setArch(other.GetTriple().getArch()); - // MachO unknown64 isn't really invalid as the debugger can - // still obtain information from the binary, e.g. line tables. - // As such, we don't update the core here. + // MachO unknown64 isn't really invalid as the debugger can still obtain + // information from the binary, e.g. line tables. As such, we don't update + // the core here. if (other.GetCore() != eCore_uknownMach64) UpdateCore(); } @@ -903,9 +903,8 @@ void ArchSpec::MergeFrom(const ArchSpec &other) { GetTriple().setEnvironment(other.GetTriple().getEnvironment()); } // If this and other are both arm ArchSpecs and this ArchSpec is a generic - // "some kind of arm" - // spec but the other ArchSpec is a specific arm core, adopt the specific arm - // core. + // "some kind of arm" spec but the other ArchSpec is a specific arm core, + // adopt the specific arm core. if (GetTriple().getArch() == llvm::Triple::arm && other.GetTriple().getArch() == llvm::Triple::arm && IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && @@ -931,24 +930,21 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu, if (core_def) { m_core = core_def->core; update_triple = false; - // Always use the architecture name because it might be more descriptive - // than the architecture enum ("armv7" -> llvm::Triple::arm). + // Always use the architecture name because it might be more + // descriptive than the architecture enum ("armv7" -> + // llvm::Triple::arm). m_triple.setArchName(llvm::StringRef(core_def->name)); if (arch_type == eArchTypeMachO) { m_triple.setVendor(llvm::Triple::Apple); // Don't set the OS. It could be simulator, macosx, ios, watchos, - // tvos. We could - // get close with the cpu type - but we can't get it right all of the - // time. Better - // to leave this unset so other sections of code will set it when they - // have more - // information. + // tvos. We could get close with the cpu type - but we can't get it + // right all of the time. Better to leave this unset so other + // sections of code will set it when they have more information. // NB: don't call m_triple.setOS (llvm::Triple::UnknownOS). That sets // the OSName to // "unknown" and the ArchSpec::TripleVendorWasSpecified() method says - // that any - // OSName setting means it was specified. + // that any OSName setting means it was specified. } else if (arch_type == eArchTypeELF) { switch (os) { case llvm::ELF::ELFOSABI_AIX: @@ -977,7 +973,8 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu, m_triple.setVendor(llvm::Triple::UnknownVendor); m_triple.setOS(llvm::Triple::UnknownOS); } - // Fall back onto setting the machine type if the arch by name failed... + // Fall back onto setting the machine type if the arch by name + // failed... if (m_triple.getArch() == llvm::Triple::UnknownArch) m_triple.setArch(core_def->machine); } @@ -1020,10 +1017,9 @@ static bool isCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, return true; // If one of the environment is Android and the other one is EABI then they - // are considered to - // be compatible. This is required as a workaround for shared libraries - // compiled for Android - // without the NOTE section indicating that they are using the Android ABI. + // are considered to be compatible. This is required as a workaround for + // shared libraries compiled for Android without the NOTE section indicating + // that they are using the Android ABI. if ((lhs == llvm::Triple::Android && rhs == llvm::Triple::EABI) || (rhs == llvm::Triple::Android && lhs == llvm::Triple::EABI) || (lhs == llvm::Triple::GNUEABI && rhs == llvm::Triple::EABI) || @@ -1055,8 +1051,8 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const { if (lhs_triple_vendor != rhs_triple_vendor) { const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified(); const bool lhs_vendor_specified = TripleVendorWasSpecified(); - // Both architectures had the vendor specified, so if they aren't - // equal then we return false + // Both architectures had the vendor specified, so if they aren't equal + // then we return false if (rhs_vendor_specified && lhs_vendor_specified) return false; @@ -1071,8 +1067,8 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const { if (lhs_triple_os != rhs_triple_os) { const bool rhs_os_specified = rhs.TripleOSWasSpecified(); const bool lhs_os_specified = TripleOSWasSpecified(); - // Both architectures had the OS specified, so if they aren't - // equal then we return false + // Both architectures had the OS specified, so if they aren't equal then + // we return false if (rhs_os_specified && lhs_os_specified) return false; @@ -1099,9 +1095,9 @@ void ArchSpec::UpdateCore() { const CoreDefinition *core_def = FindCoreDefinition(arch_name); if (core_def) { m_core = core_def->core; - // Set the byte order to the default byte order for an architecture. - // This can be modified if needed for cases when cores handle both - // big and little endian + // Set the byte order to the default byte order for an architecture. This + // can be modified if needed for cases when cores handle both big and + // little endian m_byte_order = core_def->default_byte_order; } else { Clear(); @@ -1198,9 +1194,8 @@ static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2, break; // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization - // Cortex-M0 - ARMv6-M - armv6m - // Cortex-M3 - ARMv7-M - armv7m - // Cortex-M4 - ARMv7E-M - armv7em + // Cortex-M0 - ARMv6-M - armv6m Cortex-M3 - ARMv7-M - armv7m Cortex-M4 - + // ARMv7E-M - armv7em case ArchSpec::eCore_arm_armv7em: if (!enforce_exact_match) { if (core2 == ArchSpec::eCore_arm_generic) @@ -1216,9 +1211,8 @@ static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2, break; // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization - // Cortex-M0 - ARMv6-M - armv6m - // Cortex-M3 - ARMv7-M - armv7m - // Cortex-M4 - ARMv7E-M - armv7em + // Cortex-M0 - ARMv6-M - armv6m Cortex-M3 - ARMv7-M - armv7m Cortex-M4 - + // ARMv7E-M - armv7em case ArchSpec::eCore_arm_armv7m: if (!enforce_exact_match) { if (core2 == ArchSpec::eCore_arm_generic) @@ -1466,9 +1460,8 @@ bool ArchSpec::IsAlwaysThumbInstructions() const { // Cortex-M0 through Cortex-M7 are ARM processor cores which can only // execute thumb instructions. We map the cores to arch names like this: // - // Cortex-M0, Cortex-M0+, Cortex-M1: armv6m - // Cortex-M3: armv7m - // Cortex-M4, Cortex-M7: armv7em + // Cortex-M0, Cortex-M0+, Cortex-M1: armv6m Cortex-M3: armv7m Cortex-M4, + // Cortex-M7: armv7em if (GetCore() == ArchSpec::Core::eCore_arm_armv7m || GetCore() == ArchSpec::Core::eCore_arm_armv7em || diff --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp index d9d7b35..16d6b71 100644 --- a/lldb/source/Utility/Args.cpp +++ b/lldb/source/Utility/Args.cpp @@ -19,12 +19,9 @@ using namespace lldb_private; // A helper function for argument parsing. // Parses the initial part of the first argument using normal double quote -// rules: -// backslash escapes the double quote and itself. The parsed string is appended -// to the second -// argument. The function returns the unparsed portion of the string, starting -// at the closing -// quote. +// rules: backslash escapes the double quote and itself. The parsed string is +// appended to the second argument. The function returns the unparsed portion +// of the string, starting at the closing quote. static llvm::StringRef ParseDoubleQuotes(llvm::StringRef quoted, std::string &result) { // Inside double quotes, '\' and '"' are special. @@ -49,8 +46,7 @@ static llvm::StringRef ParseDoubleQuotes(llvm::StringRef quoted, } // If the character after the backslash is not a whitelisted escapable - // character, we - // leave the character sequence untouched. + // character, we leave the character sequence untouched. if (strchr(k_escapable_characters, quoted.front()) == nullptr) result += '\\'; @@ -84,10 +80,10 @@ ParseSingleArgument(llvm::StringRef command) { // strings. std::string arg; - // Since we can have multiple quotes that form a single command - // in a command like: "Hello "world'!' (which will make a single - // argument "Hello world!") we remember the first quote character - // we encounter and use that for the quote character. + // Since we can have multiple quotes that form a single command in a command + // like: "Hello "world'!' (which will make a single argument "Hello world!") + // we remember the first quote character we encounter and use that for the + // quote character. char first_quote_char = '\0'; bool arg_complete = false; @@ -110,8 +106,7 @@ ParseSingleArgument(llvm::StringRef command) { } // If the character after the backslash is not a whitelisted escapable - // character, we - // leave the character sequence untouched. + // character, we leave the character sequence untouched. if (strchr(" \t\\'\"`", command.front()) == nullptr) arg += '\\'; @@ -122,8 +117,8 @@ ParseSingleArgument(llvm::StringRef command) { case ' ': case '\t': - // We are not inside any quotes, we just found a space after an - // argument. We are done. + // We are not inside any quotes, we just found a space after an argument. + // We are done. arg_complete = true; break; @@ -138,8 +133,7 @@ ParseSingleArgument(llvm::StringRef command) { command = ParseDoubleQuotes(command, arg); else { // For single quotes, we simply skip ahead to the matching quote - // character - // (or the end of the string). + // character (or the end of the string). size_t quoted = command.find(special); arg += command.substr(0, quoted); command = command.substr(quoted); @@ -274,9 +268,9 @@ char **Args::GetArgumentVector() { assert(!m_argv.empty()); // TODO: functions like execve and posix_spawnp exhibit undefined behavior // when argv or envp is null. So the code below is actually wrong. However, - // other code in LLDB depends on it being null. The code has been acting this - // way for some time, so it makes sense to leave it this way until someone - // has the time to come along and fix it. + // other code in LLDB depends on it being null. The code has been acting + // this way for some time, so it makes sense to leave it this way until + // someone has the time to come along and fix it. return (m_argv.size() > 1) ? m_argv.data() : nullptr; } @@ -555,17 +549,17 @@ void Args::EncodeEscapeSequences(const char *src, std::string &dst) { case '0': // 1 to 3 octal chars { - // Make a string that can hold onto the initial zero char, - // up to 3 octal digits, and a terminating NULL. + // Make a string that can hold onto the initial zero char, up to 3 + // octal digits, and a terminating NULL. char oct_str[5] = {'\0', '\0', '\0', '\0', '\0'}; int i; for (i = 0; (p[i] >= '0' && p[i] <= '7') && i < 4; ++i) oct_str[i] = p[i]; - // We don't want to consume the last octal character since - // the main for loop will do this for us, so we advance p by - // one less than i (even if i is zero) + // We don't want to consume the last octal character since the main + // for loop will do this for us, so we advance p by one less than i + // (even if i is zero) p += i - 1; unsigned long octal_value = ::strtoul(oct_str, nullptr, 8); if (octal_value <= UINT8_MAX) { @@ -596,8 +590,8 @@ void Args::EncodeEscapeSequences(const char *src, std::string &dst) { break; default: - // Just desensitize any other character by just printing what - // came after the '\' + // Just desensitize any other character by just printing what came + // after the '\' dst.append(1, *p); break; } diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp index 2ee5f67..5ef4b2f 100644 --- a/lldb/source/Utility/ConstString.cpp +++ b/lldb/source/Utility/ConstString.cpp @@ -43,8 +43,8 @@ public: static size_t GetConstCStringLength(const char *ccstr) { if (ccstr != nullptr) { - // Since the entry is read only, and we derive the entry entirely from the - // pointer, we don't need the lock. + // Since the entry is read only, and we derive the entry entirely from + // the pointer, we don't need the lock. const StringPoolEntryType &entry = GetStringMapEntryFromKeyData(ccstr); return entry.getKey().size(); } @@ -155,9 +155,8 @@ public: } //------------------------------------------------------------------ - // Return the size in bytes that this object and any items in its - // collection of uniqued strings + data count values takes in - // memory. + // Return the size in bytes that this object and any items in its collection + // of uniqued strings + data count values takes in memory. //------------------------------------------------------------------ size_t MemorySize() const { size_t mem_size = sizeof(Pool); @@ -184,15 +183,14 @@ protected: }; //---------------------------------------------------------------------- -// Frameworks and dylibs aren't supposed to have global C++ -// initializers so we hide the string pool in a static function so -// that it will get initialized on the first call to this static -// function. +// Frameworks and dylibs aren't supposed to have global C++ initializers so we +// hide the string pool in a static function so that it will get initialized on +// the first call to this static function. // -// Note, for now we make the string pool a pointer to the pool, because -// we can't guarantee that some objects won't get destroyed after the -// global destructor chain is run, and trying to make sure no destructors -// touch ConstStrings is difficult. So we leak the pool instead. +// Note, for now we make the string pool a pointer to the pool, because we +// can't guarantee that some objects won't get destroyed after the global +// destructor chain is run, and trying to make sure no destructors touch +// ConstStrings is difficult. So we leak the pool instead. //---------------------------------------------------------------------- static Pool &StringPool() { static llvm::once_flag g_pool_initialization_flag; @@ -246,8 +244,8 @@ bool ConstString::Equals(const ConstString &lhs, const ConstString &rhs, return true; // Since the pointers weren't equal, and identical ConstStrings always have - // identical pointers, - // the result must be false for case sensitive equality test. + // identical pointers, the result must be false for case sensitive equality + // test. if (case_sensitive) return false; diff --git a/lldb/source/Utility/DataBufferHeap.cpp b/lldb/source/Utility/DataBufferHeap.cpp index aa1c3d3..e686ee8 100644 --- a/lldb/source/Utility/DataBufferHeap.cpp +++ b/lldb/source/Utility/DataBufferHeap.cpp @@ -22,8 +22,7 @@ using namespace lldb_private; DataBufferHeap::DataBufferHeap() : m_data() {} //---------------------------------------------------------------------- -// Initialize this class with "n" characters and fill the buffer -// with "ch". +// Initialize this class with "n" characters and fill the buffer with "ch". //---------------------------------------------------------------------- DataBufferHeap::DataBufferHeap(lldb::offset_t n, uint8_t ch) : m_data() { if (n < m_data.max_size()) @@ -31,8 +30,7 @@ DataBufferHeap::DataBufferHeap(lldb::offset_t n, uint8_t ch) : m_data() { } //---------------------------------------------------------------------- -// Initialize this class with a copy of the "n" bytes from the "bytes" -// buffer. +// Initialize this class with a copy of the "n" bytes from the "bytes" buffer. //---------------------------------------------------------------------- DataBufferHeap::DataBufferHeap(const void *src, lldb::offset_t src_len) : m_data() { @@ -40,22 +38,21 @@ DataBufferHeap::DataBufferHeap(const void *src, lldb::offset_t src_len) } //---------------------------------------------------------------------- -// Virtual destructor since this class inherits from a pure virtual -// base class. +// Virtual destructor since this class inherits from a pure virtual base class. //---------------------------------------------------------------------- DataBufferHeap::~DataBufferHeap() = default; //---------------------------------------------------------------------- -// Return a pointer to the bytes owned by this object, or nullptr if -// the object contains no bytes. +// Return a pointer to the bytes owned by this object, or nullptr if the object +// contains no bytes. //---------------------------------------------------------------------- uint8_t *DataBufferHeap::GetBytes() { return (m_data.empty() ? nullptr : m_data.data()); } //---------------------------------------------------------------------- -// Return a const pointer to the bytes owned by this object, or nullptr -// if the object contains no bytes. +// Return a const pointer to the bytes owned by this object, or nullptr if the +// object contains no bytes. //---------------------------------------------------------------------- const uint8_t *DataBufferHeap::GetBytes() const { return (m_data.empty() ? nullptr : m_data.data()); @@ -67,8 +64,8 @@ const uint8_t *DataBufferHeap::GetBytes() const { uint64_t DataBufferHeap::GetByteSize() const { return m_data.size(); } //---------------------------------------------------------------------- -// Sets the number of bytes that this object should be able to -// contain. This can be used prior to copying data into the buffer. +// Sets the number of bytes that this object should be able to contain. This +// can be used prior to copying data into the buffer. //---------------------------------------------------------------------- uint64_t DataBufferHeap::SetByteSize(uint64_t new_size) { m_data.resize(new_size); diff --git a/lldb/source/Utility/DataEncoder.cpp b/lldb/source/Utility/DataEncoder.cpp index 433a15b..7edee3c 100644 --- a/lldb/source/Utility/DataEncoder.cpp +++ b/lldb/source/Utility/DataEncoder.cpp @@ -34,8 +34,8 @@ DataEncoder::DataEncoder() m_data_sp() {} //---------------------------------------------------------------------- -// This constructor allows us to use data that is owned by someone else. -// The data must stay around as long as this object is valid. +// This constructor allows us to use data that is owned by someone else. The +// data must stay around as long as this object is valid. //---------------------------------------------------------------------- DataEncoder::DataEncoder(void *data, uint32_t length, ByteOrder endian, uint8_t addr_size) @@ -43,11 +43,10 @@ DataEncoder::DataEncoder(void *data, uint32_t length, ByteOrder endian, m_byte_order(endian), m_addr_size(addr_size), m_data_sp() {} //---------------------------------------------------------------------- -// Make a shared pointer reference to the shared data in "data_sp" and -// set the endian swapping setting to "swap", and the address size to -// "addr_size". The shared data reference will ensure the data lives -// as long as any DataEncoder objects exist that have a reference to -// this data. +// Make a shared pointer reference to the shared data in "data_sp" and set the +// endian swapping setting to "swap", and the address size to "addr_size". The +// shared data reference will ensure the data lives as long as any DataEncoder +// objects exist that have a reference to this data. //---------------------------------------------------------------------- DataEncoder::DataEncoder(const DataBufferSP &data_sp, ByteOrder endian, uint8_t addr_size) @@ -59,9 +58,8 @@ DataEncoder::DataEncoder(const DataBufferSP &data_sp, ByteOrder endian, DataEncoder::~DataEncoder() = default; //------------------------------------------------------------------ -// Clears the object contents back to a default invalid state, and -// release any references to shared data that this object may -// contain. +// Clears the object contents back to a default invalid state, and release any +// references to shared data that this object may contain. //------------------------------------------------------------------ void DataEncoder::Clear() { m_start = nullptr; @@ -72,8 +70,8 @@ void DataEncoder::Clear() { } //------------------------------------------------------------------ -// If this object contains shared data, this function returns the -// offset into that shared data. Else zero is returned. +// If this object contains shared data, this function returns the offset into +// that shared data. Else zero is returned. //------------------------------------------------------------------ size_t DataEncoder::GetSharedDataOffset() const { if (m_start != nullptr) { @@ -90,13 +88,12 @@ size_t DataEncoder::GetSharedDataOffset() const { } //---------------------------------------------------------------------- -// Set the data with which this object will extract from to data -// starting at BYTES and set the length of the data to LENGTH bytes -// long. The data is externally owned must be around at least as -// long as this object points to the data. No copy of the data is -// made, this object just refers to this data and can extract from -// it. If this object refers to any shared data upon entry, the -// reference to that data will be released. Is SWAP is set to true, +// Set the data with which this object will extract from to data starting at +// BYTES and set the length of the data to LENGTH bytes long. The data is +// externally owned must be around at least as long as this object points to +// the data. No copy of the data is made, this object just refers to this data +// and can extract from it. If this object refers to any shared data upon +// entry, the reference to that data will be released. Is SWAP is set to true, // any data extracted will be endian swapped. //---------------------------------------------------------------------- uint32_t DataEncoder::SetData(void *bytes, uint32_t length, ByteOrder endian) { @@ -113,18 +110,17 @@ uint32_t DataEncoder::SetData(void *bytes, uint32_t length, ByteOrder endian) { } //---------------------------------------------------------------------- -// Assign the data for this object to be a subrange of the shared -// data in "data_sp" starting "data_offset" bytes into "data_sp" -// and ending "data_length" bytes later. If "data_offset" is not -// a valid offset into "data_sp", then this object will contain no -// bytes. If "data_offset" is within "data_sp" yet "data_length" is -// too large, the length will be capped at the number of bytes -// remaining in "data_sp". A ref counted pointer to the data in -// "data_sp" will be made in this object IF the number of bytes this -// object refers to in greater than zero (if at least one byte was -// available starting at "data_offset") to ensure the data stays -// around as long as it is needed. The address size and endian swap -// settings will remain unchanged from their current settings. +// Assign the data for this object to be a subrange of the shared data in +// "data_sp" starting "data_offset" bytes into "data_sp" and ending +// "data_length" bytes later. If "data_offset" is not a valid offset into +// "data_sp", then this object will contain no bytes. If "data_offset" is +// within "data_sp" yet "data_length" is too large, the length will be capped +// at the number of bytes remaining in "data_sp". A ref counted pointer to the +// data in "data_sp" will be made in this object IF the number of bytes this +// object refers to in greater than zero (if at least one byte was available +// starting at "data_offset") to ensure the data stays around as long as it is +// needed. The address size and endian swap settings will remain unchanged from +// their current settings. //---------------------------------------------------------------------- uint32_t DataEncoder::SetData(const DataBufferSP &data_sp, uint32_t data_offset, uint32_t data_length) { @@ -149,8 +145,8 @@ uint32_t DataEncoder::SetData(const DataBufferSP &data_sp, uint32_t data_offset, uint32_t new_size = GetByteSize(); - // Don't hold a shared pointer to the data buffer if we don't share - // any valid bytes in the shared buffer. + // Don't hold a shared pointer to the data buffer if we don't share any valid + // bytes in the shared buffer. if (new_size == 0) m_data_sp.reset(); @@ -158,8 +154,8 @@ uint32_t DataEncoder::SetData(const DataBufferSP &data_sp, uint32_t data_offset, } //---------------------------------------------------------------------- -// Extract a single unsigned char from the binary data and update -// the offset pointed to by "offset_ptr". +// Extract a single unsigned char from the binary data and update the offset +// pointed to by "offset_ptr". // // RETURNS the byte that was extracted, or zero on failure. //---------------------------------------------------------------------- @@ -208,12 +204,12 @@ uint32_t DataEncoder::PutU64(uint32_t offset, uint64_t value) { } //---------------------------------------------------------------------- -// Extract a single integer value from the data and update the offset -// pointed to by "offset_ptr". The size of the extracted integer -// is specified by the "byte_size" argument. "byte_size" should have -// a value >= 1 and <= 8 since the return value is only 64 bits -// wide. Any "byte_size" values less than 1 or greater than 8 will -// result in nothing being extracted, and zero being returned. +// Extract a single integer value from the data and update the offset pointed +// to by "offset_ptr". The size of the extracted integer is specified by the +// "byte_size" argument. "byte_size" should have a value >= 1 and <= 8 since +// the return value is only 64 bits wide. Any "byte_size" values less than 1 or +// greater than 8 will result in nothing being extracted, and zero being +// returned. // // RETURNS the integer value that was extracted, or zero on failure. //---------------------------------------------------------------------- diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp index 84c5f81..38481e0 100644 --- a/lldb/source/Utility/DataExtractor.cpp +++ b/lldb/source/Utility/DataExtractor.cpp @@ -126,8 +126,8 @@ DataExtractor::DataExtractor() m_data_sp(), m_target_byte_size(1) {} //---------------------------------------------------------------------- -// This constructor allows us to use data that is owned by someone else. -// The data must stay around as long as this object is valid. +// This constructor allows us to use data that is owned by someone else. The +// data must stay around as long as this object is valid. //---------------------------------------------------------------------- DataExtractor::DataExtractor(const void *data, offset_t length, ByteOrder endian, uint32_t addr_size, @@ -143,11 +143,10 @@ DataExtractor::DataExtractor(const void *data, offset_t length, } //---------------------------------------------------------------------- -// Make a shared pointer reference to the shared data in "data_sp" and -// set the endian swapping setting to "swap", and the address size to -// "addr_size". The shared data reference will ensure the data lives -// as long as any DataExtractor objects exist that have a reference to -// this data. +// Make a shared pointer reference to the shared data in "data_sp" and set the +// endian swapping setting to "swap", and the address size to "addr_size". The +// shared data reference will ensure the data lives as long as any +// DataExtractor objects exist that have a reference to this data. //---------------------------------------------------------------------- DataExtractor::DataExtractor(const DataBufferSP &data_sp, ByteOrder endian, uint32_t addr_size, @@ -162,11 +161,11 @@ DataExtractor::DataExtractor(const DataBufferSP &data_sp, ByteOrder endian, } //---------------------------------------------------------------------- -// Initialize this object with a subset of the data bytes in "data". -// If "data" contains shared data, then a reference to this shared -// data will added and the shared data will stay around as long -// as any object contains a reference to that data. The endian -// swap and address size settings are copied from "data". +// Initialize this object with a subset of the data bytes in "data". If "data" +// contains shared data, then a reference to this shared data will added and +// the shared data will stay around as long as any object contains a reference +// to that data. The endian swap and address size settings are copied from +// "data". //---------------------------------------------------------------------- DataExtractor::DataExtractor(const DataExtractor &data, offset_t offset, offset_t length, uint32_t target_byte_size /*=1*/) @@ -210,9 +209,8 @@ const DataExtractor &DataExtractor::operator=(const DataExtractor &rhs) { DataExtractor::~DataExtractor() = default; //------------------------------------------------------------------ -// Clears the object contents back to a default invalid state, and -// release any references to shared data that this object may -// contain. +// Clears the object contents back to a default invalid state, and release any +// references to shared data that this object may contain. //------------------------------------------------------------------ void DataExtractor::Clear() { m_start = nullptr; @@ -223,8 +221,8 @@ void DataExtractor::Clear() { } //------------------------------------------------------------------ -// If this object contains shared data, this function returns the -// offset into that shared data. Else zero is returned. +// If this object contains shared data, this function returns the offset into +// that shared data. Else zero is returned. //------------------------------------------------------------------ size_t DataExtractor::GetSharedDataOffset() const { if (m_start != nullptr) { @@ -241,13 +239,12 @@ size_t DataExtractor::GetSharedDataOffset() const { } //---------------------------------------------------------------------- -// Set the data with which this object will extract from to data -// starting at BYTES and set the length of the data to LENGTH bytes -// long. The data is externally owned must be around at least as -// long as this object points to the data. No copy of the data is -// made, this object just refers to this data and can extract from -// it. If this object refers to any shared data upon entry, the -// reference to that data will be released. Is SWAP is set to true, +// Set the data with which this object will extract from to data starting at +// BYTES and set the length of the data to LENGTH bytes long. The data is +// externally owned must be around at least as long as this object points to +// the data. No copy of the data is made, this object just refers to this data +// and can extract from it. If this object refers to any shared data upon +// entry, the reference to that data will be released. Is SWAP is set to true, // any data extracted will be endian swapped. //---------------------------------------------------------------------- lldb::offset_t DataExtractor::SetData(const void *bytes, offset_t length, @@ -265,18 +262,16 @@ lldb::offset_t DataExtractor::SetData(const void *bytes, offset_t length, } //---------------------------------------------------------------------- -// Assign the data for this object to be a subrange in "data" -// starting "data_offset" bytes into "data" and ending "data_length" -// bytes later. If "data_offset" is not a valid offset into "data", -// then this object will contain no bytes. If "data_offset" is -// within "data" yet "data_length" is too large, the length will be -// capped at the number of bytes remaining in "data". If "data" -// contains a shared pointer to other data, then a ref counted -// pointer to that data will be made in this object. If "data" -// doesn't contain a shared pointer to data, then the bytes referred -// to in "data" will need to exist at least as long as this object -// refers to those bytes. The address size and endian swap settings -// are copied from the current values in "data". +// Assign the data for this object to be a subrange in "data" starting +// "data_offset" bytes into "data" and ending "data_length" bytes later. If +// "data_offset" is not a valid offset into "data", then this object will +// contain no bytes. If "data_offset" is within "data" yet "data_length" is too +// large, the length will be capped at the number of bytes remaining in "data". +// If "data" contains a shared pointer to other data, then a ref counted +// pointer to that data will be made in this object. If "data" doesn't contain +// a shared pointer to data, then the bytes referred to in "data" will need to +// exist at least as long as this object refers to those bytes. The address +// size and endian swap settings are copied from the current values in "data". //---------------------------------------------------------------------- lldb::offset_t DataExtractor::SetData(const DataExtractor &data, offset_t data_offset, @@ -303,18 +298,17 @@ lldb::offset_t DataExtractor::SetData(const DataExtractor &data, } //---------------------------------------------------------------------- -// Assign the data for this object to be a subrange of the shared -// data in "data_sp" starting "data_offset" bytes into "data_sp" -// and ending "data_length" bytes later. If "data_offset" is not -// a valid offset into "data_sp", then this object will contain no -// bytes. If "data_offset" is within "data_sp" yet "data_length" is -// too large, the length will be capped at the number of bytes -// remaining in "data_sp". A ref counted pointer to the data in -// "data_sp" will be made in this object IF the number of bytes this -// object refers to in greater than zero (if at least one byte was -// available starting at "data_offset") to ensure the data stays -// around as long as it is needed. The address size and endian swap -// settings will remain unchanged from their current settings. +// Assign the data for this object to be a subrange of the shared data in +// "data_sp" starting "data_offset" bytes into "data_sp" and ending +// "data_length" bytes later. If "data_offset" is not a valid offset into +// "data_sp", then this object will contain no bytes. If "data_offset" is +// within "data_sp" yet "data_length" is too large, the length will be capped +// at the number of bytes remaining in "data_sp". A ref counted pointer to the +// data in "data_sp" will be made in this object IF the number of bytes this +// object refers to in greater than zero (if at least one byte was available +// starting at "data_offset") to ensure the data stays around as long as it is +// needed. The address size and endian swap settings will remain unchanged from +// their current settings. //---------------------------------------------------------------------- lldb::offset_t DataExtractor::SetData(const DataBufferSP &data_sp, offset_t data_offset, @@ -340,8 +334,8 @@ lldb::offset_t DataExtractor::SetData(const DataBufferSP &data_sp, size_t new_size = GetByteSize(); - // Don't hold a shared pointer to the data buffer if we don't share - // any valid bytes in the shared buffer. + // Don't hold a shared pointer to the data buffer if we don't share any valid + // bytes in the shared buffer. if (new_size == 0) m_data_sp.reset(); @@ -349,8 +343,8 @@ lldb::offset_t DataExtractor::SetData(const DataBufferSP &data_sp, } //---------------------------------------------------------------------- -// Extract a single unsigned char from the binary data and update -// the offset pointed to by "offset_ptr". +// Extract a single unsigned char from the binary data and update the offset +// pointed to by "offset_ptr". // // RETURNS the byte that was extracted, or zero on failure. //---------------------------------------------------------------------- @@ -362,13 +356,12 @@ uint8_t DataExtractor::GetU8(offset_t *offset_ptr) const { } //---------------------------------------------------------------------- -// Extract "count" unsigned chars from the binary data and update the -// offset pointed to by "offset_ptr". The extracted data is copied into -// "dst". +// Extract "count" unsigned chars from the binary data and update the offset +// pointed to by "offset_ptr". The extracted data is copied into "dst". // // RETURNS the non-nullptr buffer pointer upon successful extraction of -// all the requested bytes, or nullptr when the data is not available in -// the buffer due to being out of bounds, or insufficient data. +// all the requested bytes, or nullptr when the data is not available in the +// buffer due to being out of bounds, or insufficient data. //---------------------------------------------------------------------- void *DataExtractor::GetU8(offset_t *offset_ptr, void *dst, uint32_t count) const { @@ -384,8 +377,8 @@ void *DataExtractor::GetU8(offset_t *offset_ptr, void *dst, } //---------------------------------------------------------------------- -// Extract a single uint16_t from the data and update the offset -// pointed to by "offset_ptr". +// Extract a single uint16_t from the data and update the offset pointed to by +// "offset_ptr". // // RETURNS the uint16_t that was extracted, or zero on failure. //---------------------------------------------------------------------- @@ -432,13 +425,12 @@ uint64_t DataExtractor::GetU64_unchecked(offset_t *offset_ptr) const { } //---------------------------------------------------------------------- -// Extract "count" uint16_t values from the binary data and update -// the offset pointed to by "offset_ptr". The extracted data is -// copied into "dst". +// Extract "count" uint16_t values from the binary data and update the offset +// pointed to by "offset_ptr". The extracted data is copied into "dst". // // RETURNS the non-nullptr buffer pointer upon successful extraction of -// all the requested bytes, or nullptr when the data is not available -// in the buffer due to being out of bounds, or insufficient data. +// all the requested bytes, or nullptr when the data is not available in the +// buffer due to being out of bounds, or insufficient data. //---------------------------------------------------------------------- void *DataExtractor::GetU16(offset_t *offset_ptr, void *void_dst, uint32_t count) const { @@ -465,8 +457,8 @@ void *DataExtractor::GetU16(offset_t *offset_ptr, void *void_dst, } //---------------------------------------------------------------------- -// Extract a single uint32_t from the data and update the offset -// pointed to by "offset_ptr". +// Extract a single uint32_t from the data and update the offset pointed to by +// "offset_ptr". // // RETURNS the uint32_t that was extracted, or zero on failure. //---------------------------------------------------------------------- @@ -484,13 +476,12 @@ uint32_t DataExtractor::GetU32(offset_t *offset_ptr) const { } //---------------------------------------------------------------------- -// Extract "count" uint32_t values from the binary data and update -// the offset pointed to by "offset_ptr". The extracted data is -// copied into "dst". +// Extract "count" uint32_t values from the binary data and update the offset +// pointed to by "offset_ptr". The extracted data is copied into "dst". // // RETURNS the non-nullptr buffer pointer upon successful extraction of -// all the requested bytes, or nullptr when the data is not available -// in the buffer due to being out of bounds, or insufficient data. +// all the requested bytes, or nullptr when the data is not available in the +// buffer due to being out of bounds, or insufficient data. //---------------------------------------------------------------------- void *DataExtractor::GetU32(offset_t *offset_ptr, void *void_dst, uint32_t count) const { @@ -517,8 +508,8 @@ void *DataExtractor::GetU32(offset_t *offset_ptr, void *void_dst, } //---------------------------------------------------------------------- -// Extract a single uint64_t from the data and update the offset -// pointed to by "offset_ptr". +// Extract a single uint64_t from the data and update the offset pointed to by +// "offset_ptr". // // RETURNS the uint64_t that was extracted, or zero on failure. //---------------------------------------------------------------------- @@ -538,9 +529,9 @@ uint64_t DataExtractor::GetU64(offset_t *offset_ptr) const { //---------------------------------------------------------------------- // GetU64 // -// Get multiple consecutive 64 bit values. Return true if the entire -// read succeeds and increment the offset pointed to by offset_ptr, else -// return false and leave the offset pointed to by offset_ptr unchanged. +// Get multiple consecutive 64 bit values. Return true if the entire read +// succeeds and increment the offset pointed to by offset_ptr, else return +// false and leave the offset pointed to by offset_ptr unchanged. //---------------------------------------------------------------------- void *DataExtractor::GetU64(offset_t *offset_ptr, void *void_dst, uint32_t count) const { @@ -708,10 +699,10 @@ long double DataExtractor::GetLongDouble(offset_t *offset_ptr) const { } //------------------------------------------------------------------ -// Extract a single address from the data and update the offset -// pointed to by "offset_ptr". The size of the extracted address -// comes from the "this->m_addr_size" member variable and should be -// set correctly prior to extracting any address values. +// Extract a single address from the data and update the offset pointed to by +// "offset_ptr". The size of the extracted address comes from the +// "this->m_addr_size" member variable and should be set correctly prior to +// extracting any address values. // // RETURNS the address that was extracted, or zero on failure. //------------------------------------------------------------------ @@ -730,10 +721,10 @@ uint64_t DataExtractor::GetAddress_unchecked(offset_t *offset_ptr) const { } //------------------------------------------------------------------ -// Extract a single pointer from the data and update the offset -// pointed to by "offset_ptr". The size of the extracted pointer -// comes from the "this->m_addr_size" member variable and should be -// set correctly prior to extracting any pointer values. +// Extract a single pointer from the data and update the offset pointed to by +// "offset_ptr". The size of the extracted pointer comes from the +// "this->m_addr_size" member variable and should be set correctly prior to +// extracting any pointer values. // // RETURNS the pointer that was extracted, or zero on failure. //------------------------------------------------------------------ @@ -804,9 +795,9 @@ DataExtractor::CopyByteOrderedData(offset_t src_offset, offset_t src_len, const uint8_t *src = (const uint8_t *)PeekData(src_offset, src_len); if (src) { if (dst_len >= src_len) { - // We are copying the entire value from src into dst. - // Calculate how many, if any, zeroes we need for the most - // significant bytes if "dst_len" is greater than "src_len"... + // We are copying the entire value from src into dst. Calculate how many, + // if any, zeroes we need for the most significant bytes if "dst_len" is + // greater than "src_len"... const size_t num_zeroes = dst_len - src_len; if (dst_byte_order == eByteOrderBig) { // Big endian, so we lead with zeroes... @@ -863,15 +854,13 @@ DataExtractor::CopyByteOrderedData(offset_t src_offset, offset_t src_len, } //---------------------------------------------------------------------- -// Extracts a variable length NULL terminated C string from -// the data at the offset pointed to by "offset_ptr". The -// "offset_ptr" will be updated with the offset of the byte that -// follows the NULL terminator byte. +// Extracts a variable length NULL terminated C string from the data at the +// offset pointed to by "offset_ptr". The "offset_ptr" will be updated with +// the offset of the byte that follows the NULL terminator byte. // -// If the offset pointed to by "offset_ptr" is out of bounds, or if -// "length" is non-zero and there aren't enough available -// bytes, nullptr will be returned and "offset_ptr" will not be -// updated. +// If the offset pointed to by "offset_ptr" is out of bounds, or if "length" is +// non-zero and there aren't enough available bytes, nullptr will be returned +// and "offset_ptr" will not be updated. //---------------------------------------------------------------------- const char *DataExtractor::GetCStr(offset_t *offset_ptr) const { const char *cstr = (const char *)PeekData(*offset_ptr, 1); @@ -890,23 +879,21 @@ const char *DataExtractor::GetCStr(offset_t *offset_ptr) const { } // We reached the end of the data without finding a NULL C string - // terminator. Fall through and return nullptr otherwise anyone that - // would have used the result as a C string can wander into - // unknown memory... + // terminator. Fall through and return nullptr otherwise anyone that would + // have used the result as a C string can wander into unknown memory... } return nullptr; } //---------------------------------------------------------------------- -// Extracts a NULL terminated C string from the fixed length field of -// length "len" at the offset pointed to by "offset_ptr". -// The "offset_ptr" will be updated with the offset of the byte that -// follows the fixed length field. +// Extracts a NULL terminated C string from the fixed length field of length +// "len" at the offset pointed to by "offset_ptr". The "offset_ptr" will be +// updated with the offset of the byte that follows the fixed length field. // -// If the offset pointed to by "offset_ptr" is out of bounds, or if -// the offset plus the length of the field is out of bounds, or if the -// field does not contain a NULL terminator byte, nullptr will be returned -// and "offset_ptr" will not be updated. +// If the offset pointed to by "offset_ptr" is out of bounds, or if the offset +// plus the length of the field is out of bounds, or if the field does not +// contain a NULL terminator byte, nullptr will be returned and "offset_ptr" +// will not be updated. //---------------------------------------------------------------------- const char *DataExtractor::GetCStr(offset_t *offset_ptr, offset_t len) const { const char *cstr = (const char *)PeekData(*offset_ptr, len); @@ -921,22 +908,22 @@ const char *DataExtractor::GetCStr(offset_t *offset_ptr, offset_t len) const { } //------------------------------------------------------------------ -// Peeks at a string in the contained data. No verification is done -// to make sure the entire string lies within the bounds of this -// object's data, only "offset" is verified to be a valid offset. +// Peeks at a string in the contained data. No verification is done to make +// sure the entire string lies within the bounds of this object's data, only +// "offset" is verified to be a valid offset. // -// Returns a valid C string pointer if "offset" is a valid offset in -// this object's data, else nullptr is returned. +// Returns a valid C string pointer if "offset" is a valid offset in this +// object's data, else nullptr is returned. //------------------------------------------------------------------ const char *DataExtractor::PeekCStr(offset_t offset) const { return (const char *)PeekData(offset, 1); } //---------------------------------------------------------------------- -// Extracts an unsigned LEB128 number from this object's data -// starting at the offset pointed to by "offset_ptr". The offset -// pointed to by "offset_ptr" will be updated with the offset of the -// byte following the last extracted byte. +// Extracts an unsigned LEB128 number from this object's data starting at the +// offset pointed to by "offset_ptr". The offset pointed to by "offset_ptr" +// will be updated with the offset of the byte following the last extracted +// byte. // // Returned the extracted integer value. //---------------------------------------------------------------------- @@ -968,10 +955,10 @@ uint64_t DataExtractor::GetULEB128(offset_t *offset_ptr) const { } //---------------------------------------------------------------------- -// Extracts an signed LEB128 number from this object's data -// starting at the offset pointed to by "offset_ptr". The offset -// pointed to by "offset_ptr" will be updated with the offset of the -// byte following the last extracted byte. +// Extracts an signed LEB128 number from this object's data starting at the +// offset pointed to by "offset_ptr". The offset pointed to by "offset_ptr" +// will be updated with the offset of the byte following the last extracted +// byte. // // Returned the extracted integer value. //---------------------------------------------------------------------- @@ -1010,10 +997,10 @@ int64_t DataExtractor::GetSLEB128(offset_t *offset_ptr) const { } //---------------------------------------------------------------------- -// Skips a ULEB128 number (signed or unsigned) from this object's -// data starting at the offset pointed to by "offset_ptr". The -// offset pointed to by "offset_ptr" will be updated with the offset -// of the byte following the last extracted byte. +// Skips a ULEB128 number (signed or unsigned) from this object's data starting +// at the offset pointed to by "offset_ptr". The offset pointed to by +// "offset_ptr" will be updated with the offset of the byte following the last +// extracted byte. // // Returns the number of bytes consumed during the extraction. //---------------------------------------------------------------------- @@ -1036,15 +1023,14 @@ uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) const { //---------------------------------------------------------------------- // Dumps bytes from this object's data to the stream "s" starting -// "start_offset" bytes into this data, and ending with the byte -// before "end_offset". "base_addr" will be added to the offset -// into the dumped data when showing the offset into the data in the -// output information. "num_per_line" objects of type "type" will -// be dumped with the option to override the format for each object -// with "type_format". "type_format" is a printf style formatting -// string. If "type_format" is nullptr, then an appropriate format -// string will be used for the supplied "type". If the stream "s" -// is nullptr, then the output will be send to Log(). +// "start_offset" bytes into this data, and ending with the byte before +// "end_offset". "base_addr" will be added to the offset into the dumped data +// when showing the offset into the data in the output information. +// "num_per_line" objects of type "type" will be dumped with the option to +// override the format for each object with "type_format". "type_format" is a +// printf style formatting string. If "type_format" is nullptr, then an +// appropriate format string will be used for the supplied "type". If the +// stream "s" is nullptr, then the output will be send to Log(). //---------------------------------------------------------------------- lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset, offset_t length, uint64_t base_addr, diff --git a/lldb/source/Utility/FastDemangle.cpp b/lldb/source/Utility/FastDemangle.cpp index 90326c5..cc04526 100644 --- a/lldb/source/Utility/FastDemangle.cpp +++ b/lldb/source/Utility/FastDemangle.cpp @@ -200,8 +200,7 @@ private: if (growth > 1 << 20) growth = 1 << 20; - // ... but never grow by less than requested, - // or 1K, whichever is greater + // ... but never grow by less than requested, or 1K, whichever is greater if (min_growth < 1024) min_growth = 1024; if (growth < min_growth) @@ -282,9 +281,8 @@ private: if (index == m_rewrite_ranges_size) break; - // Affected ranges are either shuffled forward when after the - // insertion but before the source, or backward when inside the - // source + // Affected ranges are either shuffled forward when after the insertion + // but before the source, or backward when inside the source int candidate_offset = m_rewrite_ranges[index].offset; if (candidate_offset >= insertion_point_cookie) { if (candidate_offset < source_range.offset) { @@ -402,8 +400,7 @@ private: //---------------------------------------------------- // Rewrite methods // - // Write another copy of content already present - // earlier in the output buffer + // Write another copy of content already present earlier in the output buffer //---------------------------------------------------- void RewriteRange(BufferRange range) { @@ -436,11 +433,11 @@ private: //---------------------------------------------------- // TryParse methods // - // Provide information with return values instead of - // writing to the output buffer + // Provide information with return values instead of writing to the output + // buffer // - // Values indicating failure guarantee that the pre- - // call m_read_ptr is unchanged + // Values indicating failure guarantee that the pre- call m_read_ptr is + // unchanged //---------------------------------------------------- int TryParseNumber() { @@ -820,8 +817,8 @@ private: } // <CV-qualifiers> ::= [r] [V] [K] - // <ref-qualifier> ::= R # & ref-qualifier - // <ref-qualifier> ::= O # && ref-qualifier + // <ref-qualifier> ::= R # & ref-qualifier <ref-qualifier> + // ::= O # && ref-qualifier int TryParseQualifiers(bool allow_cv, bool allow_ro) { int qualifiers = QualifierNone; @@ -890,11 +887,10 @@ private: //---------------------------------------------------- // Parse methods // - // Consume input starting from m_read_ptr and produce - // buffered output at m_write_ptr + // Consume input starting from m_read_ptr and produce buffered output at + // m_write_ptr // - // Failures return false and may leave m_read_ptr in an - // indeterminate state + // Failures return false and may leave m_read_ptr in an indeterminate state //---------------------------------------------------- bool Parse(char character) { @@ -932,17 +928,14 @@ private: // <substitution> ::= S <seq-id> _ // ::= S_ - // <substitution> ::= Sa # ::std::allocator - // <substitution> ::= Sb # ::std::basic_string - // <substitution> ::= Ss # ::std::basic_string < char, + // <substitution> ::= Sa # ::std::allocator <substitution> ::= Sb # + // ::std::basic_string <substitution> ::= Ss # ::std::basic_string < char, // ::std::char_traits<char>, // ::std::allocator<char> > // <substitution> ::= Si # ::std::basic_istream<char, std::char_traits<char> - // > - // <substitution> ::= So # ::std::basic_ostream<char, std::char_traits<char> - // > - // <substitution> ::= Sd # ::std::basic_iostream<char, std::char_traits<char> - // > + // > <substitution> ::= So # ::std::basic_ostream<char, + // std::char_traits<char> > <substitution> ::= Sd # + // ::std::basic_iostream<char, std::char_traits<char> > bool ParseSubstitution() { const char *substitution; @@ -967,7 +960,8 @@ private: break; default: // A failed attempt to parse a number will return -1 which turns out to be - // perfect here as S_ is the first substitution, S0_ the next and so forth + // perfect here as S_ is the first substitution, S0_ the next and so + // forth int substitution_index = TryParseBase36Number(); if (*m_read_ptr++ != '_') { #ifdef DEBUG_FAILURES @@ -984,17 +978,17 @@ private: // <function-type> ::= F [Y] <bare-function-type> [<ref-qualifier>] E // - // <bare-function-type> ::= <signature type>+ # types are possible return - // type, then parameter types + // <bare-function-type> ::= <signature type>+ # types are possible + // return type, then parameter types bool ParseFunctionType(int inner_qualifiers = QualifierNone) { #ifdef DEBUG_FAILURES printf("*** Function types not supported\n"); #endif // TODO: first steps toward an implementation follow, but they're far - // from complete. Function types tend to bracket other types eg: - // int (*)() when used as the type for "name" becomes int (*name)(). - // This makes substitution et al ... interesting. + // from complete. Function types tend to bracket other types eg: int (*)() + // when used as the type for "name" becomes int (*name)(). This makes + // substitution et al ... interesting. return false; #if 0 // TODO @@ -1154,8 +1148,8 @@ private: if (!Parse('_')) return false; - // When no number is present we get -1, which is convenient since - // T_ is the zeroth element T0_ is element 1, and so on + // When no number is present we get -1, which is convenient since T_ is the + // zeroth element T0_ is element 1, and so on return RewriteTemplateArg(count + 1); } @@ -1193,13 +1187,13 @@ private: // ::= G <type> # imaginary (C 2000) // ::= Dp <type> # pack expansion (C++0x) // ::= U <source-name> <type> # vendor extended type qualifier - // extension := U <objc-name> <objc-type> # objc-type<identifier> - // extension := <vector-type> # <vector-type> starts with Dv + // extension := U <objc-name> <objc-type> # objc-type<identifier> extension + // := <vector-type> # <vector-type> starts with Dv // <objc-name> ::= <k0 number> objcproto <k1 number> <identifier> # k0 = 9 + - // <number of digits in k1> + k1 - // <objc-type> := <source-name> # PU<11+>objcproto 11objc_object<source-name> - // 11objc_object -> id<source-name> + // <number of digits in k1> + k1 <objc-type> := <source-name> # + // PU<11+>objcproto 11objc_object<source-name> 11objc_object -> id<source- + // name> bool ParseType() { #ifdef DEBUG_FAILURES @@ -1476,8 +1470,8 @@ private: // ::= <unnamed-type-name> bool ParseUnqualifiedName(NameState &name_state) { - // Note that these are detected directly in ParseNestedName for - // performance rather than switching on the same options twice + // Note that these are detected directly in ParseNestedName for performance + // rather than switching on the same options twice char next = *m_read_ptr; switch (next) { case 'C': @@ -1943,7 +1937,8 @@ private: break; } - // Record a substitution candidate for all prefixes, but not the full name + // Record a substitution candidate for all prefixes, but not the full + // name if (suppress_substitution) suppress_substitution = false; else @@ -2247,9 +2242,9 @@ private: if (next == 'E' || next == '\0' || next == '.') return true; - // Clang has a bad habit of making unique manglings by just sticking numbers - // on the end of a symbol, - // which is ambiguous with malformed source name manglings + // Clang has a bad habit of making unique manglings by just sticking + // numbers on the end of a symbol, which is ambiguous with malformed source + // name manglings const char *before_clang_uniquing_test = m_read_ptr; if (TryParseNumber()) { if (*m_read_ptr == '\0') diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp index 0a10fca..2168948 100644 --- a/lldb/source/Utility/FileSpec.cpp +++ b/lldb/source/Utility/FileSpec.cpp @@ -166,8 +166,7 @@ void FileSpec::Resolve(llvm::SmallVectorImpl<char> &path) { FileSpec::FileSpec() : m_syntax(GetNativeSyntax()) {} //------------------------------------------------------------------ -// Default constructor that can take an optional full path to a -// file on disk. +// Default constructor that can take an optional full path to a file on disk. //------------------------------------------------------------------ FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, PathSyntax syntax) : m_syntax(syntax) { @@ -307,15 +306,15 @@ const FileSpec &FileSpec::operator=(const FileSpec &rhs) { } //------------------------------------------------------------------ -// Update the contents of this object with a new path. The path will -// be split up into a directory and filename and stored as uniqued -// string values for quick comparison and efficient memory usage. +// Update the contents of this object with a new path. The path will be split +// up into a directory and filename and stored as uniqued string values for +// quick comparison and efficient memory usage. //------------------------------------------------------------------ void FileSpec::SetFile(llvm::StringRef pathname, bool resolve, PathSyntax syntax) { // CLEANUP: Use StringRef for string handling. This function is kind of a - // mess and the unclear semantics of RootDirStart and ParentPathEnd make - // it very difficult to understand this function. There's no reason this + // mess and the unclear semantics of RootDirStart and ParentPathEnd make it + // very difficult to understand this function. There's no reason this // function should be particularly complicated or difficult to understand. m_filename.Clear(); m_directory.Clear(); @@ -369,8 +368,8 @@ void FileSpec::SetFile(llvm::StringRef path, bool resolve, } //---------------------------------------------------------------------- -// Convert to pointer operator. This allows code to check any FileSpec -// objects to see if they contain anything valid using code such as: +// Convert to pointer operator. This allows code to check any FileSpec objects +// to see if they contain anything valid using code such as: // // if (file_spec) // {} @@ -378,8 +377,8 @@ void FileSpec::SetFile(llvm::StringRef path, bool resolve, FileSpec::operator bool() const { return m_filename || m_directory; } //---------------------------------------------------------------------- -// Logical NOT operator. This allows code to check any FileSpec -// objects to see if they are invalid using code such as: +// Logical NOT operator. This allows code to check any FileSpec objects to see +// if they are invalid using code such as: // // if (!file_spec) // {} @@ -406,12 +405,10 @@ bool FileSpec::operator==(const FileSpec &rhs) const { return true; // TODO: determine if we want to keep this code in here. - // The code below was added to handle a case where we were - // trying to set a file and line breakpoint and one path - // was resolved, and the other not and the directory was - // in a mount point that resolved to a more complete path: - // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling - // this out... + // The code below was added to handle a case where we were trying to set a + // file and line breakpoint and one path was resolved, and the other not and + // the directory was in a mount point that resolved to a more complete path: + // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling this out... if (IsResolved() && rhs.IsResolved()) { // Both paths are resolved, no need to look further... return false; @@ -423,8 +420,8 @@ bool FileSpec::operator==(const FileSpec &rhs) const { if (!IsResolved()) { if (resolved_lhs.ResolvePath()) { // This path wasn't resolved but now it is. Check if the resolved - // directory is the same as our unresolved directory, and if so, - // we can mark this object as resolved to avoid more future resolves + // directory is the same as our unresolved directory, and if so, we can + // mark this object as resolved to avoid more future resolves m_is_resolved = (m_directory == resolved_lhs.m_directory); } else return false; @@ -434,16 +431,16 @@ bool FileSpec::operator==(const FileSpec &rhs) const { if (!rhs.IsResolved()) { if (resolved_rhs.ResolvePath()) { // rhs's path wasn't resolved but now it is. Check if the resolved - // directory is the same as rhs's unresolved directory, and if so, - // we can mark this object as resolved to avoid more future resolves + // directory is the same as rhs's unresolved directory, and if so, we can + // mark this object as resolved to avoid more future resolves rhs.m_is_resolved = (rhs.m_directory == resolved_rhs.m_directory); } else return false; } - // If we reach this point in the code we were able to resolve both paths - // and since we only resolve the paths if the basenames are equal, then - // we can just check if both directories are equal... + // If we reach this point in the code we were able to resolve both paths and + // since we only resolve the paths if the basenames are equal, then we can + // just check if both directories are equal... return DirectoryEquals(rhs); } @@ -468,8 +465,8 @@ Stream &lldb_private::operator<<(Stream &s, const FileSpec &f) { } //------------------------------------------------------------------ -// Clear this object by releasing both the directory and filename -// string values and making them both the empty string. +// Clear this object by releasing both the directory and filename string values +// and making them both the empty string. //------------------------------------------------------------------ void FileSpec::Clear() { m_directory.Clear(); @@ -477,15 +474,14 @@ void FileSpec::Clear() { } //------------------------------------------------------------------ -// Compare two FileSpec objects. If "full" is true, then both -// the directory and the filename must match. If "full" is false, -// then the directory names for "a" and "b" are only compared if -// they are both non-empty. This allows a FileSpec object to only -// contain a filename and it can match FileSpec objects that have -// matching filenames with different paths. +// Compare two FileSpec objects. If "full" is true, then both the directory and +// the filename must match. If "full" is false, then the directory names for +// "a" and "b" are only compared if they are both non-empty. This allows a +// FileSpec object to only contain a filename and it can match FileSpec objects +// that have matching filenames with different paths. // -// Return -1 if the "a" is less than "b", 0 if "a" is equal to "b" -// and "1" if "a" is greater than "b". +// Return -1 if the "a" is less than "b", 0 if "a" is equal to "b" and "1" if +// "a" is greater than "b". //------------------------------------------------------------------ int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) { int result = 0; @@ -495,10 +491,10 @@ int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) { // If full is true, then we must compare both the directory and filename. - // If full is false, then if either directory is empty, then we match on - // the basename only, and if both directories have valid values, we still - // do a full compare. This allows for matching when we just have a filename - // in one of the FileSpec objects. + // If full is false, then if either directory is empty, then we match on the + // basename only, and if both directories have valid values, we still do a + // full compare. This allows for matching when we just have a filename in one + // of the FileSpec objects. if (full || (a.m_directory && b.m_directory)) { result = ConstString::Compare(a.m_directory, b.m_directory, case_sensitive); @@ -527,9 +523,9 @@ bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full) { } //------------------------------------------------------------------ -// Dump the object to the supplied stream. If the object contains -// a valid directory name, it will be displayed followed by a -// directory delimiter, and the filename. +// Dump the object to the supplied stream. If the object contains a valid +// directory name, it will be displayed followed by a directory delimiter, and +// the filename. //------------------------------------------------------------------ void FileSpec::Dump(Stream *s) const { if (s) { @@ -572,8 +568,7 @@ bool FileSpec::ResolveExecutableLocation() { return true; else { // If FindProgramByName found the file, it returns the directory + - // filename in its return results. - // We need to separate them. + // filename in its return results. We need to separate them. FileSpec tmp_file(dir_ref.data(), false); if (tmp_file.Exists()) { m_directory = tmp_file.m_directory; @@ -635,9 +630,8 @@ ConstString &FileSpec::GetFilename() { return m_filename; } const ConstString &FileSpec::GetFilename() const { return m_filename; } //------------------------------------------------------------------ -// Extract the directory and path into a fixed buffer. This is -// needed as the directory and path are stored in separate string -// values. +// Extract the directory and path into a fixed buffer. This is needed as the +// directory and path are stored in separate string values. //------------------------------------------------------------------ size_t FileSpec::GetPath(char *path, size_t path_max_len, bool denormalize) const { @@ -698,9 +692,8 @@ ConstString FileSpec::GetFileNameStrippingExtension() const { } //------------------------------------------------------------------ -// Return the size in bytes that this object takes in memory. This -// returns the size in bytes of this object, not any shared string -// values it may refer to. +// Return the size in bytes that this object takes in memory. This returns the +// size in bytes of this object, not any shared string values it may refer to. //------------------------------------------------------------------ size_t FileSpec::MemorySize() const { return m_filename.MemorySize() + m_directory.MemorySize(); @@ -961,10 +954,9 @@ void llvm::format_provider<FileSpec>::format(const FileSpec &F, // Style is either D or empty, either way we need to print the directory. if (!dir.empty()) { - // Directory is stored in normalized form, which might be different - // than preferred form. In order to handle this, we need to cut off - // the filename, then denormalize, then write the entire denorm'ed - // directory. + // Directory is stored in normalized form, which might be different than + // preferred form. In order to handle this, we need to cut off the + // filename, then denormalize, then write the entire denorm'ed directory. llvm::SmallString<64> denormalized_dir = dir; Denormalize(denormalized_dir, F.GetPathSyntax()); Stream << denormalized_dir; diff --git a/lldb/source/Utility/JSON.cpp b/lldb/source/Utility/JSON.cpp index 9049f59..7d70034 100644 --- a/lldb/source/Utility/JSON.cpp +++ b/lldb/source/Utility/JSON.cpp @@ -449,8 +449,7 @@ int JSONParser::GetEscapedChar(bool &was_escaped) { JSONValue::SP JSONParser::ParseJSONObject() { // The "JSONParser::Token::ObjectStart" token should have already been - // consumed - // by the time this function is called + // consumed by the time this function is called std::unique_ptr<JSONObject> dict_up(new JSONObject()); std::string value; @@ -481,8 +480,7 @@ JSONValue::SP JSONParser::ParseJSONObject() { JSONValue::SP JSONParser::ParseJSONArray() { // The "JSONParser::Token::ObjectStart" token should have already been - // consumed - // by the time this function is called + // consumed by the time this function is called std::unique_ptr<JSONArray> array_up(new JSONArray()); std::string value; diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp index 16396fb..abc022a 100644 --- a/lldb/source/Utility/Log.cpp +++ b/lldb/source/Utility/Log.cpp @@ -121,9 +121,9 @@ void Log::Printf(const char *format, ...) { } //---------------------------------------------------------------------- -// All logging eventually boils down to this function call. If we have -// a callback registered, then we call the logging callback. If we have -// a valid file handle, we also log to the file. +// All logging eventually boils down to this function call. If we have a +// callback registered, then we call the logging callback. If we have a valid +// file handle, we also log to the file. //---------------------------------------------------------------------- void Log::VAPrintf(const char *format, va_list args) { llvm::SmallString<64> FinalMessage; @@ -156,8 +156,7 @@ void Log::VAError(const char *format, va_list args) { } //---------------------------------------------------------------------- -// Printing of warnings that are not fatal only if verbose mode is -// enabled. +// Printing of warnings that are not fatal only if verbose mode is enabled. //---------------------------------------------------------------------- void Log::Verbose(const char *format, ...) { if (!GetVerbose()) @@ -302,8 +301,8 @@ void Log::WriteHeader(llvm::raw_ostream &OS, llvm::StringRef file, } void Log::WriteMessage(const std::string &message) { - // Make a copy of our stream shared pointer in case someone disables our - // log while we are logging and releases the stream + // Make a copy of our stream shared pointer in case someone disables our log + // while we are logging and releases the stream auto stream_sp = GetStream(); if (!stream_sp) return; diff --git a/lldb/source/Utility/RegularExpression.cpp b/lldb/source/Utility/RegularExpression.cpp index d58b315..54f7733 100644 --- a/lldb/source/Utility/RegularExpression.cpp +++ b/lldb/source/Utility/RegularExpression.cpp @@ -14,9 +14,8 @@ #include <string> //---------------------------------------------------------------------- -// Enable enhanced mode if it is available. This allows for things like -// \d for digit, \s for space, and many more, but it isn't available -// everywhere. +// Enable enhanced mode if it is available. This allows for things like \d for +// digit, \s for space, and many more, but it isn't available everywhere. //---------------------------------------------------------------------- #if defined(REG_ENHANCED) #define DEFAULT_COMPILE_FLAGS (REG_ENHANCED | REG_EXTENDED) @@ -31,8 +30,8 @@ RegularExpression::RegularExpression() : m_re(), m_comp_err(1), m_preg() { } //---------------------------------------------------------------------- -// Constructor that compiles "re" using "flags" and stores the -// resulting compiled regular expression into this object. +// Constructor that compiles "re" using "flags" and stores the resulting +// compiled regular expression into this object. //---------------------------------------------------------------------- RegularExpression::RegularExpression(llvm::StringRef str) : m_re(), m_comp_err(1), m_preg() { @@ -55,17 +54,16 @@ operator=(const RegularExpression &rhs) { //---------------------------------------------------------------------- // Destructor // -// Any previously compiled regular expression contained in this -// object will be freed. +// Any previously compiled regular expression contained in this object will be +// freed. //---------------------------------------------------------------------- RegularExpression::~RegularExpression() { Free(); } //---------------------------------------------------------------------- -// Compile a regular expression using the supplied regular -// expression text and flags. The compiled regular expression lives -// in this object so that it can be readily used for regular -// expression matches. Execute() can be called after the regular -// expression is compiled. Any previously compiled regular +// Compile a regular expression using the supplied regular expression text and +// flags. The compiled regular expression lives in this object so that it can +// be readily used for regular expression matches. Execute() can be called +// after the regular expression is compiled. Any previously compiled regular // expression contained in this object will be freed. // // RETURNS @@ -75,20 +73,19 @@ RegularExpression::~RegularExpression() { Free(); } bool RegularExpression::Compile(llvm::StringRef str) { Free(); - // regcomp() on darwin does not recognize "" as a valid regular expression, so - // we substitute it with an equivalent non-empty one. + // regcomp() on darwin does not recognize "" as a valid regular expression, + // so we substitute it with an equivalent non-empty one. m_re = str.empty() ? "()" : str; m_comp_err = ::regcomp(&m_preg, m_re.c_str(), DEFAULT_COMPILE_FLAGS); return m_comp_err == 0; } //---------------------------------------------------------------------- -// Execute a regular expression match using the compiled regular -// expression that is already in this object against the match -// string "s". If any parens are used for regular expression -// matches "match_count" should indicate the number of regmatch_t -// values that are present in "match_ptr". The regular expression -// will be executed using the "execute_flags". +// Execute a regular expression match using the compiled regular expression +// that is already in this object against the match string "s". If any parens +// are used for regular expression matches "match_count" should indicate the +// number of regmatch_t values that are present in "match_ptr". The regular +// expression will be executed using the "execute_flags". //--------------------------------------------------------------------- bool RegularExpression::Execute(llvm::StringRef str, Match *match) const { int err = 1; @@ -159,14 +156,12 @@ bool RegularExpression::Match::GetMatchSpanningIndices( } //---------------------------------------------------------------------- -// Returns true if the regular expression compiled and is ready -// for execution. +// Returns true if the regular expression compiled and is ready for execution. //---------------------------------------------------------------------- bool RegularExpression::IsValid() const { return m_comp_err == 0; } //---------------------------------------------------------------------- -// Returns the text that was used to compile the current regular -// expression. +// Returns the text that was used to compile the current regular expression. //---------------------------------------------------------------------- llvm::StringRef RegularExpression::GetText() const { return m_re; } diff --git a/lldb/source/Utility/SelectHelper.cpp b/lldb/source/Utility/SelectHelper.cpp index 200b2ae..8fc3fad 100644 --- a/lldb/source/Utility/SelectHelper.cpp +++ b/lldb/source/Utility/SelectHelper.cpp @@ -236,8 +236,9 @@ lldb_private::Status SelectHelper::Select() { error.SetErrorString("timed out"); return error; } else { - // One or more descriptors were set, update the FDInfo::select_is_set mask - // so users can ask the SelectHelper class so clients can call one of: + // One or more descriptors were set, update the FDInfo::select_is_set + // mask so users can ask the SelectHelper class so clients can call one + // of: for (auto &pair : m_fd_map) { const int fd = pair.first; diff --git a/lldb/source/Utility/SharingPtr.cpp b/lldb/source/Utility/SharingPtr.cpp index cf32b21..bdaedfb 100644 --- a/lldb/source/Utility/SharingPtr.cpp +++ b/lldb/source/Utility/SharingPtr.cpp @@ -11,8 +11,8 @@ #if defined(ENABLE_SP_LOGGING) -// If ENABLE_SP_LOGGING is defined, then log all shared pointer assignments -// and allow them to be queried using a pointer by a call to: +// If ENABLE_SP_LOGGING is defined, then log all shared pointer assignments and +// allow them to be queried using a pointer by a call to: #include <assert.h> #include <execinfo.h> @@ -96,8 +96,8 @@ extern "C" void track_sp(void *sp_this, void *ptr, long use_count) { namespace lldb { void dump_sp_refs(void *ptr) { - // Use a specially crafted call to "track_sp" which will - // dump info on all live shared pointers that reference "ptr" + // Use a specially crafted call to "track_sp" which will dump info on all + // live shared pointers that reference "ptr" track_sp(NULL, ptr, 0); } } diff --git a/lldb/source/Utility/Status.cpp b/lldb/source/Utility/Status.cpp index a6a889a..e686204 100644 --- a/lldb/source/Utility/Status.cpp +++ b/lldb/source/Utility/Status.cpp @@ -107,9 +107,9 @@ const Status &Status::operator=(const Status &rhs) { Status::~Status() = default; //---------------------------------------------------------------------- -// Get the error value as a NULL C string. The error string will be -// fetched and cached on demand. The cached error string value will -// remain until the error value is changed or cleared. +// Get the error value as a NULL C string. The error string will be fetched and +// cached on demand. The cached error string value will remain until the error +// value is changed or cleared. //---------------------------------------------------------------------- const char *Status::AsCString(const char *default_error_str) const { if (Success()) @@ -161,8 +161,8 @@ Status::ValueType Status::GetError() const { return m_code; } ErrorType Status::GetType() const { return m_type; } //---------------------------------------------------------------------- -// Returns true if this object contains a value that describes an -// error or otherwise non-success result. +// Returns true if this object contains a value that describes an error or +// otherwise non-success result. //---------------------------------------------------------------------- bool Status::Fail() const { return m_code != 0; } @@ -210,8 +210,7 @@ void Status::SetError(ValueType err, ErrorType type) { } //---------------------------------------------------------------------- -// Update the error value to be "errno" and update the type to -// be "POSIX". +// Update the error value to be "errno" and update the type to be "POSIX". //---------------------------------------------------------------------- void Status::SetErrorToErrno() { m_code = errno; @@ -220,8 +219,8 @@ void Status::SetErrorToErrno() { } //---------------------------------------------------------------------- -// Update the error value to be LLDB_GENERIC_ERROR and update the type -// to be "Generic". +// Update the error value to be LLDB_GENERIC_ERROR and update the type to be +// "Generic". //---------------------------------------------------------------------- void Status::SetErrorToGenericError() { m_code = LLDB_GENERIC_ERROR; @@ -230,15 +229,15 @@ void Status::SetErrorToGenericError() { } //---------------------------------------------------------------------- -// Set accessor for the error string value for a specific error. -// This allows any string to be supplied as an error explanation. -// The error string value will remain until the error value is -// cleared or a new error value/type is assigned. +// Set accessor for the error string value for a specific error. This allows +// any string to be supplied as an error explanation. The error string value +// will remain until the error value is cleared or a new error value/type is +// assigned. //---------------------------------------------------------------------- void Status::SetErrorString(llvm::StringRef err_str) { if (!err_str.empty()) { - // If we have an error string, we should always at least have an error - // set to a generic value. + // If we have an error string, we should always at least have an error set + // to a generic value. if (Success()) SetErrorToGenericError(); } @@ -266,8 +265,8 @@ int Status::SetErrorStringWithFormat(const char *format, ...) { int Status::SetErrorStringWithVarArg(const char *format, va_list args) { if (format != nullptr && format[0]) { - // If we have an error string, we should always at least have - // an error set to a generic value. + // If we have an error string, we should always at least have an error set + // to a generic value. if (Success()) SetErrorToGenericError(); @@ -282,8 +281,8 @@ int Status::SetErrorStringWithVarArg(const char *format, va_list args) { } //---------------------------------------------------------------------- -// Returns true if the error code in this object is considered a -// successful return value. +// Returns true if the error code in this object is considered a successful +// return value. //---------------------------------------------------------------------- bool Status::Success() const { return m_code == 0; } diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index 04edc25..647a0c0 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -41,14 +41,12 @@ ByteOrder Stream::SetByteOrder(ByteOrder byte_order) { } //------------------------------------------------------------------ -// Put an offset "uval" out to the stream using the printf format -// in "format". +// Put an offset "uval" out to the stream using the printf format in "format". //------------------------------------------------------------------ void Stream::Offset(uint32_t uval, const char *format) { Printf(format, uval); } //------------------------------------------------------------------ -// Put an SLEB128 "uval" out to the stream using the printf format -// in "format". +// Put an SLEB128 "uval" out to the stream using the printf format in "format". //------------------------------------------------------------------ size_t Stream::PutSLEB128(int64_t sval) { size_t bytes_written = 0; @@ -73,8 +71,7 @@ size_t Stream::PutSLEB128(int64_t sval) { } //------------------------------------------------------------------ -// Put an ULEB128 "uval" out to the stream using the printf format -// in "format". +// Put an ULEB128 "uval" out to the stream using the printf format in "format". //------------------------------------------------------------------ size_t Stream::PutULEB128(uint64_t uval) { size_t bytes_written = 0; @@ -109,16 +106,16 @@ size_t Stream::PutCString(llvm::StringRef str) { } //------------------------------------------------------------------ -// Print a double quoted NULL terminated C string to the stream -// using the printf format in "format". +// Print a double quoted NULL terminated C string to the stream using the +// printf format in "format". //------------------------------------------------------------------ void Stream::QuotedCString(const char *cstr, const char *format) { Printf(format, cstr); } //------------------------------------------------------------------ -// Put an address "addr" out to the stream with optional prefix -// and suffix strings. +// Put an address "addr" out to the stream with optional prefix and suffix +// strings. //------------------------------------------------------------------ void Stream::Address(uint64_t addr, uint32_t addr_size, const char *prefix, const char *suffix) { @@ -132,8 +129,8 @@ void Stream::Address(uint64_t addr, uint32_t addr_size, const char *prefix, } //------------------------------------------------------------------ -// Put an address range out to the stream with optional prefix -// and suffix strings. +// Put an address range out to the stream with optional prefix and suffix +// strings. //------------------------------------------------------------------ void Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix, @@ -179,8 +176,8 @@ size_t Stream::PrintfVarArg(const char *format, va_list args) { size_t Stream::EOL() { return PutChar('\n'); } //------------------------------------------------------------------ -// Indent the current line using the current indentation level and -// print an optional string following the indentation spaces. +// Indent the current line using the current indentation level and print an +// optional string following the indentation spaces. //------------------------------------------------------------------ size_t Stream::Indent(const char *s) { return Printf("%*.*s%s", m_indent_level, m_indent_level, "", s ? s : ""); diff --git a/lldb/source/Utility/StringExtractor.cpp b/lldb/source/Utility/StringExtractor.cpp index cf5c7e2..7528350 100644 --- a/lldb/source/Utility/StringExtractor.cpp +++ b/lldb/source/Utility/StringExtractor.cpp @@ -74,9 +74,8 @@ char StringExtractor::GetChar(char fail_value) { } //---------------------------------------------------------------------- -// If a pair of valid hex digits exist at the head of the -// StringExtractor they are decoded into an unsigned byte and returned -// by this function +// If a pair of valid hex digits exist at the head of the StringExtractor they +// are decoded into an unsigned byte and returned by this function // // If there is not a pair of valid hex digits at the head of the // StringExtractor, it is left unchanged and -1 is returned @@ -96,12 +95,12 @@ int StringExtractor::DecodeHexU8() { } //---------------------------------------------------------------------- -// Extract an unsigned character from two hex ASCII chars in the packet -// string, or return fail_value on failure +// Extract an unsigned character from two hex ASCII chars in the packet string, +// or return fail_value on failure //---------------------------------------------------------------------- uint8_t StringExtractor::GetHexU8(uint8_t fail_value, bool set_eof_on_fail) { - // On success, fail_value will be overwritten with the next - // character in the stream + // On success, fail_value will be overwritten with the next character in the + // stream GetHexU8Ex(fail_value, set_eof_on_fail); return fail_value; } @@ -307,8 +306,8 @@ size_t StringExtractor::GetHexBytes(llvm::MutableArrayRef<uint8_t> dest, } //---------------------------------------------------------------------- -// Decodes all valid hex encoded bytes at the head of the -// StringExtractor, limited by dst_len. +// Decodes all valid hex encoded bytes at the head of the StringExtractor, +// limited by dst_len. // // Returns the number of bytes successfully decoded //---------------------------------------------------------------------- @@ -390,9 +389,9 @@ size_t StringExtractor::GetHexByteStringTerminatedBy(std::string &str, bool StringExtractor::GetNameColonValue(llvm::StringRef &name, llvm::StringRef &value) { - // Read something in the form of NNNN:VVVV; where NNNN is any character - // that is not a colon, followed by a ':' character, then a value (one or - // more ';' chars), followed by a ';' + // Read something in the form of NNNN:VVVV; where NNNN is any character that + // is not a colon, followed by a ':' character, then a value (one or more ';' + // chars), followed by a ';' if (m_index >= m_packet.size()) return fail(); diff --git a/lldb/source/Utility/StringExtractorGDBRemote.cpp b/lldb/source/Utility/StringExtractorGDBRemote.cpp index 204ce61..3cae06d 100644 --- a/lldb/source/Utility/StringExtractorGDBRemote.cpp +++ b/lldb/source/Utility/StringExtractorGDBRemote.cpp @@ -482,10 +482,9 @@ lldb_private::Status StringExtractorGDBRemote::GetStatus() { size_t StringExtractorGDBRemote::GetEscapedBinaryData(std::string &str) { // Just get the data bytes in the string as - // GDBRemoteCommunication::CheckForPacket() - // already removes any 0x7d escaped characters. If any 0x7d characters are - // left in - // the packet, then they are supposed to be there... + // GDBRemoteCommunication::CheckForPacket() already removes any 0x7d escaped + // characters. If any 0x7d characters are left in the packet, then they are + // supposed to be there... str.clear(); const size_t bytes_left = GetBytesLeft(); if (bytes_left > 0) { @@ -526,9 +525,9 @@ static bool JSONResponseValidator(void *, case StringExtractorGDBRemote::eResponse: // JSON that is returned in from JSON query packets is currently always - // either a dictionary which starts with a '{', or an array which - // starts with a '['. This is a quick validator to just make sure the - // response could be valid JSON without having to validate all of the + // either a dictionary which starts with a '{', or an array which starts + // with a '['. This is a quick validator to just make sure the response + // could be valid JSON without having to validate all of the // JSON content. switch (response.GetStringRef()[0]) { case '{': diff --git a/lldb/source/Utility/StructuredData.cpp b/lldb/source/Utility/StructuredData.cpp index 492fc58..55f003f 100644 --- a/lldb/source/Utility/StructuredData.cpp +++ b/lldb/source/Utility/StructuredData.cpp @@ -85,8 +85,7 @@ static StructuredData::ObjectSP ParseJSONObject(JSONParser &json_parser) { static StructuredData::ObjectSP ParseJSONArray(JSONParser &json_parser) { // The "JSONParser::Token::ObjectStart" token should have already been - // consumed - // by the time this function is called + // consumed by the time this function is called auto array_up = llvm::make_unique<StructuredData::Array>(); std::string value; @@ -162,8 +161,8 @@ StructuredData::Object::GetObjectForDotSeparatedPath(llvm::StringRef path) { std::string key = match.first.str(); ObjectSP value = this->GetAsDictionary()->GetValueForKey(key); if (value.get()) { - // Do we have additional words to descend? If not, return the - // value we're at right now. + // Do we have additional words to descend? If not, return the value + // we're at right now. if (match.second.empty()) { return value; } else { diff --git a/lldb/source/Utility/UUID.cpp b/lldb/source/Utility/UUID.cpp index 98d4c30..0972432 100644 --- a/lldb/source/Utility/UUID.cpp +++ b/lldb/source/Utility/UUID.cpp @@ -133,8 +133,8 @@ llvm::StringRef UUID::DecodeUUIDBytesFromString(llvm::StringRef p, // Skip both hex digits p = p.drop_front(2); - // Increment the byte that we are decoding within the UUID value - // and break out if we are done + // Increment the byte that we are decoding within the UUID value and + // break out if we are done if (++uuid_byte_idx == num_uuid_bytes) break; } else if (p.front() == '-') { diff --git a/lldb/source/Utility/VASprintf.cpp b/lldb/source/Utility/VASprintf.cpp index e950fb7..900d975 100644 --- a/lldb/source/Utility/VASprintf.cpp +++ b/lldb/source/Utility/VASprintf.cpp @@ -36,8 +36,8 @@ bool lldb_private::VASprintf(llvm::SmallVectorImpl<char> &buf, const char *fmt, } if (size_t(length) >= buf.size()) { - // The error formatted string didn't fit into our buffer, resize it - // to the exact needed size, and retry + // The error formatted string didn't fit into our buffer, resize it to the + // exact needed size, and retry buf.resize(length + 1); length = ::vsnprintf(buf.data(), buf.size(), fmt, copy_args); if (length < 0) { |