[Lldb-commits] [PATCH] D11388: Make stream::operator<< take "const" void *

Pavel Labath labath at google.com
Tue Jul 21 06:29:49 PDT 2015


labath created this revision.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.

This enables us to avoid casts to "void *" in some cases and avoids a couple of "casts off const
qualifiers" warnings.

http://reviews.llvm.org/D11388

Files:
  include/lldb/Core/Stream.h
  source/Core/Stream.cpp
  source/Symbol/SymbolContext.cpp

Index: source/Symbol/SymbolContext.cpp
===================================================================
--- source/Symbol/SymbolContext.cpp
+++ source/Symbol/SymbolContext.cpp
@@ -391,24 +391,24 @@
 void
 SymbolContext::Dump(Stream *s, Target *target) const
 {
-    *s << (void *)this << ": ";
+    *s << this << ": ";
     s->Indent();
     s->PutCString("SymbolContext");
     s->IndentMore();
     s->EOL();
     s->IndentMore();
     s->Indent();
-    *s << "Module       = " << (void *)module_sp.get() << ' ';
+    *s << "Module       = " << module_sp.get() << ' ';
     if (module_sp)
         module_sp->GetFileSpec().Dump(s);
     s->EOL();
     s->Indent();
-    *s << "CompileUnit  = " << (void *)comp_unit;
+    *s << "CompileUnit  = " << comp_unit;
     if (comp_unit != nullptr)
         *s << " {0x" << comp_unit->GetID() << "} " << *(static_cast<FileSpec*> (comp_unit));
     s->EOL();
     s->Indent();
-    *s << "Function     = " << (void *)function;
+    *s << "Function     = " << function;
     if (function != nullptr)
     {
         *s << " {0x" << function->GetID() << "} " << function->GetType()->GetName() << ", address-range = ";
@@ -424,7 +424,7 @@
     }
     s->EOL();
     s->Indent();
-    *s << "Block        = " << (void *)block;
+    *s << "Block        = " << block;
     if (block != nullptr)
         *s << " {0x" << block->GetID() << '}';
     // Dump the block and pass it a negative depth to we print all the parent blocks
@@ -436,11 +436,11 @@
     line_entry.Dump (s, target, true, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, true);
     s->EOL();
     s->Indent();
-    *s << "Symbol       = " << (void *)symbol;
+    *s << "Symbol       = " << symbol;
     if (symbol != nullptr && symbol->GetMangled())
         *s << ' ' << symbol->GetName().AsCString();
     s->EOL();
-    *s << "Variable     = " << (void *)variable;
+    *s << "Variable     = " << variable;
     if (variable != nullptr)
     {
         *s << " {0x" << variable->GetID() << "} " << variable->GetType()->GetName();
@@ -1178,7 +1178,7 @@
 SymbolContextList::Dump(Stream *s, Target *target) const
 {
 
-    *s << (void *)this << ": ";
+    *s << this << ": ";
     s->Indent();
     s->PutCString("SymbolContextList");
     s->EOL();
Index: source/Core/Stream.cpp
===================================================================
--- source/Core/Stream.cpp
+++ source/Core/Stream.cpp
@@ -284,9 +284,9 @@
 // Stream the pointer value out to this stream.
 //------------------------------------------------------------------
 Stream&
-Stream::operator<< (void *p)
+Stream::operator<< (const void *p)
 {
-    Printf ("0x%.*tx", (int)sizeof(void*) * 2, (ptrdiff_t)p);
+    Printf ("0x%.*tx", (int)sizeof(const void*) * 2, (ptrdiff_t)p);
     return *this;
 }
 
Index: include/lldb/Core/Stream.h
===================================================================
--- include/lldb/Core/Stream.h
+++ include/lldb/Core/Stream.h
@@ -221,7 +221,7 @@
     ///     in one statement.
     //------------------------------------------------------------------
     Stream&
-    operator<< (void *p);
+    operator<< (const void *p);
 
     //------------------------------------------------------------------
     /// Output a character \a ch to the stream \a s.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11388.30250.patch
Type: text/x-patch
Size: 3298 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150721/32af6760/attachment.bin>


More information about the lldb-commits mailing list