[Lldb-commits] [lldb] r242874 - Make stream::operator<< take "const" void *

Pavel Labath labath at google.com
Wed Jul 22 00:58:18 PDT 2015


Author: labath
Date: Wed Jul 22 02:58:17 2015
New Revision: 242874

URL: http://llvm.org/viewvc/llvm-project?rev=242874&view=rev
Log:
Make stream::operator<< take "const" void *

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

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D11388

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

Modified: lldb/trunk/include/lldb/Core/Stream.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Stream.h?rev=242874&r1=242873&r2=242874&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Stream.h (original)
+++ lldb/trunk/include/lldb/Core/Stream.h Wed Jul 22 02:58:17 2015
@@ -221,7 +221,7 @@ public:
     ///     in one statement.
     //------------------------------------------------------------------
     Stream&
-    operator<< (void *p);
+    operator<< (const void *p);
 
     //------------------------------------------------------------------
     /// Output a character \a ch to the stream \a s.

Modified: lldb/trunk/source/Core/Stream.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Stream.cpp?rev=242874&r1=242873&r2=242874&view=diff
==============================================================================
--- lldb/trunk/source/Core/Stream.cpp (original)
+++ lldb/trunk/source/Core/Stream.cpp Wed Jul 22 02:58:17 2015
@@ -284,9 +284,9 @@ Stream::operator<<  (const char *s)
 // 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;
 }
 

Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=242874&r1=242873&r2=242874&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Wed Jul 22 02:58:17 2015
@@ -391,24 +391,24 @@ SymbolContext::GetResolvedMask () const
 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 @@ SymbolContext::Dump(Stream *s, Target *t
     }
     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 @@ SymbolContext::Dump(Stream *s, Target *t
     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 @@ void
 SymbolContextList::Dump(Stream *s, Target *target) const
 {
 
-    *s << (void *)this << ": ";
+    *s << this << ": ";
     s->Indent();
     s->PutCString("SymbolContextList");
     s->EOL();





More information about the lldb-commits mailing list