[Lldb-commits] [lldb] r348996 - [NFC] Small code cleanups in utility.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 12 16:15:17 PST 2018


Author: jdevlieghere
Date: Wed Dec 12 16:15:17 2018
New Revision: 348996

URL: http://llvm.org/viewvc/llvm-project?rev=348996&view=rev
Log:
[NFC] Small code cleanups in utility.

Fix a few small annoyances in Utility I ran into.

Modified:
    lldb/trunk/source/Utility/FileSpec.cpp
    lldb/trunk/source/Utility/Stream.cpp
    lldb/trunk/source/Utility/StringList.cpp
    lldb/trunk/source/Utility/StructuredData.cpp
    lldb/trunk/source/Utility/TildeExpressionResolver.cpp
    lldb/trunk/source/Utility/UUID.cpp

Modified: lldb/trunk/source/Utility/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=348996&r1=348995&r2=348996&view=diff
==============================================================================
--- lldb/trunk/source/Utility/FileSpec.cpp (original)
+++ lldb/trunk/source/Utility/FileSpec.cpp Wed Dec 12 16:15:17 2018
@@ -424,7 +424,7 @@ std::string FileSpec::GetPath(bool denor
 }
 
 const char *FileSpec::GetCString(bool denormalize) const {
-  return ConstString{GetPath(denormalize)}.AsCString(NULL);
+  return ConstString{GetPath(denormalize)}.AsCString(nullptr);
 }
 
 void FileSpec::GetPath(llvm::SmallVectorImpl<char> &path,

Modified: lldb/trunk/source/Utility/Stream.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Stream.cpp?rev=348996&r1=348995&r2=348996&view=diff
==============================================================================
--- lldb/trunk/source/Utility/Stream.cpp (original)
+++ lldb/trunk/source/Utility/Stream.cpp Wed Dec 12 16:15:17 2018
@@ -93,9 +93,9 @@ void Stream::QuotedCString(const char *c
 //------------------------------------------------------------------
 void Stream::Address(uint64_t addr, uint32_t addr_size, const char *prefix,
                      const char *suffix) {
-  if (prefix == NULL)
+  if (prefix == nullptr)
     prefix = "";
-  if (suffix == NULL)
+  if (suffix == nullptr)
     suffix = "";
   //    int addr_width = m_addr_size << 1;
   //    Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_width, addr, suffix);

Modified: lldb/trunk/source/Utility/StringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringList.cpp?rev=348996&r1=348995&r2=348996&view=diff
==============================================================================
--- lldb/trunk/source/Utility/StringList.cpp (original)
+++ lldb/trunk/source/Utility/StringList.cpp Wed Dec 12 16:15:17 2018
@@ -83,7 +83,7 @@ size_t StringList::GetMaxStringLength()
 const char *StringList::GetStringAtIndex(size_t idx) const {
   if (idx < m_strings.size())
     return m_strings[idx].c_str();
-  return NULL;
+  return nullptr;
 }
 
 void StringList::Join(const char *separator, Stream &strm) {

Modified: lldb/trunk/source/Utility/StructuredData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StructuredData.cpp?rev=348996&r1=348995&r2=348996&view=diff
==============================================================================
--- lldb/trunk/source/Utility/StructuredData.cpp (original)
+++ lldb/trunk/source/Utility/StructuredData.cpp Wed Dec 12 16:15:17 2018
@@ -144,7 +144,7 @@ static StructuredData::ObjectSP ParseJSO
 }
 
 StructuredData::ObjectSP StructuredData::ParseJSON(std::string json_text) {
-  JSONParser json_parser(json_text.c_str());
+  JSONParser json_parser(json_text);
   StructuredData::ObjectSP object_sp = ParseJSONValue(json_parser);
   return object_sp;
 }
@@ -169,11 +169,11 @@ StructuredData::Object::GetObjectForDotS
 
   if (this->GetType() == lldb::eStructuredDataTypeArray) {
     std::pair<llvm::StringRef, llvm::StringRef> match = path.split('[');
-    if (match.second.size() == 0) {
+    if (match.second.empty()) {
       return this->shared_from_this();
     }
     errno = 0;
-    uint64_t val = strtoul(match.second.str().c_str(), NULL, 10);
+    uint64_t val = strtoul(match.second.str().c_str(), nullptr, 10);
     if (errno == 0) {
       return this->GetAsArray()->GetItemAtIndex(val);
     }

Modified: lldb/trunk/source/Utility/TildeExpressionResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/TildeExpressionResolver.cpp?rev=348996&r1=348995&r2=348996&view=diff
==============================================================================
--- lldb/trunk/source/Utility/TildeExpressionResolver.cpp (original)
+++ lldb/trunk/source/Utility/TildeExpressionResolver.cpp Wed Dec 12 16:15:17 2018
@@ -59,7 +59,7 @@ bool StandardTildeExpressionResolver::Re
   struct passwd *user_entry;
   Expr = Expr.drop_front();
 
-  while ((user_entry = getpwent()) != NULL) {
+  while ((user_entry = getpwent()) != nullptr) {
     StringRef ThisName(user_entry->pw_name);
     if (!ThisName.startswith(Expr))
       continue;

Modified: lldb/trunk/source/Utility/UUID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/UUID.cpp?rev=348996&r1=348995&r2=348996&view=diff
==============================================================================
--- lldb/trunk/source/Utility/UUID.cpp (original)
+++ lldb/trunk/source/Utility/UUID.cpp Wed Dec 12 16:15:17 2018
@@ -51,9 +51,7 @@ std::string UUID::GetAsString(llvm::Stri
   return result;
 }
 
-void UUID::Dump(Stream *s) const {
-  s->PutCString(GetAsString().c_str());
-}
+void UUID::Dump(Stream *s) const { s->PutCString(GetAsString()); }
 
 static inline int xdigit_to_int(char ch) {
   ch = tolower(ch);




More information about the lldb-commits mailing list