Resolve printf formatting warnings on Linux:
- use macros from inttypes.h for format strings instead of OS-specific types

Patch from Matt Kopec!



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@168945 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index 81400ff..2bce509 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -1431,14 +1431,14 @@
     {
         log->Printf("LRT[%u] returned:", current_id);
         log->Printf("LRT[%u]   Original = (RecordDecl*)%p", current_id, origin_record.decl);
-        log->Printf("LRT[%u]   Size = %lld", current_id, size);
-        log->Printf("LRT[%u]   Alignment = %lld", current_id, alignment);
+        log->Printf("LRT[%u]   Size = %" PRId64, current_id, size);
+        log->Printf("LRT[%u]   Alignment = %" PRId64, current_id, alignment);
         log->Printf("LRT[%u]   Fields:", current_id);
         for (RecordDecl::field_iterator fi = record->field_begin(), fe = record->field_end();
              fi != fe;
              ++fi)
         {
-            log->Printf("LRT[%u]     (FieldDecl*)%p, Name = '%s', Offset = %lld bits",
+            log->Printf("LRT[%u]     (FieldDecl*)%p, Name = '%s', Offset = %" PRId64 " bits",
                         current_id,
                         *fi,
                         fi->getNameAsString().c_str(),
@@ -1459,7 +1459,7 @@
                 DeclFromParser <RecordDecl> base_record(base_record_type->getDecl());
                 DeclFromParser <CXXRecordDecl> base_cxx_record = DynCast<CXXRecordDecl>(base_record);
                 
-                log->Printf("LRT[%u]     %s(CXXRecordDecl*)%p, Name = '%s', Offset = %lld chars",
+                log->Printf("LRT[%u]     %s(CXXRecordDecl*)%p, Name = '%s', Offset = %" PRId64 " chars",
                             current_id,
                             (is_virtual ? "Virtual " : ""),
                             base_cxx_record.decl,
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index dd39fa1..cdbffbf 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -1499,7 +1499,7 @@
         
         if (mem == LLDB_INVALID_ADDRESS)
         {
-            err.SetErrorStringWithFormat("Couldn't allocate 0x%llx bytes for materialized argument struct", 
+            err.SetErrorStringWithFormat("Couldn't allocate 0x%llx bytes for materialized argument struct",
                                          (unsigned long long)(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size));
             return false;
         }
@@ -1683,7 +1683,7 @@
                 mem = var_sp->m_live_sp->GetValue().GetScalar().ULongLong();
                 
                 if (log)
-                    log->Printf("Dematerializing %s from 0x%llx (size = %u)", var_sp->GetName().GetCString(), (uint64_t)mem, (unsigned)pvar_byte_size);
+                    log->Printf("Dematerializing %s from 0x%" PRIx64 " (size = %u)", var_sp->GetName().GetCString(), (uint64_t)mem, (unsigned)pvar_byte_size);
                 
                 // Read the contents of the spare memory area
                                 
@@ -1758,7 +1758,7 @@
             }
             
             if (log)
-                log->Printf("Allocated %s (0x%llx) sucessfully", var_sp->GetName().GetCString(), mem);
+                log->Printf("Allocated %s (0x%" PRIx64 ") sucessfully", var_sp->GetName().GetCString(), mem);
             
             // Put the location of the spare memory into the live data of the ValueObject.
             
@@ -3398,7 +3398,7 @@
             // We failed to copy the type we found
             if (log)
             {
-                log->Printf ("  Failed to import the function type '%s' {0x%8.8llx} into the expression parser AST contenxt",
+                log->Printf ("  Failed to import the function type '%s' {0x%8.8" PRIx64 "} into the expression parser AST contenxt",
                              fun_type->GetName().GetCString(), 
                              fun_type->GetID());
             }
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 5acd4b6..6904bca 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -733,7 +733,7 @@
     }
     
     if (log)
-        log->Printf("Found function, has local address 0x%llx and remote address 0x%llx", (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
+        log->Printf("Found function, has local address 0x%" PRIx64 " and remote address 0x%" PRIx64, (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
     
     std::pair <lldb::addr_t, lldb::addr_t> func_range;
     
@@ -747,7 +747,7 @@
     }
     
     if (log)
-        log->Printf("Function's code range is [0x%llx+0x%llx]", func_range.first, func_range.second);
+        log->Printf("Function's code range is [0x%" PRIx64 "+0x%" PRIx64 "]", func_range.first, func_range.second);
     
     Target *target = exe_ctx.GetTargetPtr();
     if (!target)
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index 1909dc2..988bad5 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -186,7 +186,7 @@
         char arg_buf[32];
         args_buffer.append ("    ");
         args_buffer.append (type_name);
-        snprintf(arg_buf, 31, "arg_%llu", (uint64_t)i);
+        snprintf(arg_buf, 31, "arg_%" PRIu64, (uint64_t)i);
         args_buffer.push_back (' ');
         args_buffer.append (arg_buf);
         args_buffer.append (";\n");
@@ -389,7 +389,7 @@
 
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
     if (log)
-        log->Printf ("Call Address: 0x%llx Struct Address: 0x%llx.\n", m_jit_start_addr, args_addr_ref);
+        log->Printf ("Call Address: 0x%" PRIx64 " Struct Address: 0x%" PRIx64 ".\n", m_jit_start_addr, args_addr_ref);
         
     return true;
 }
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index 9dfd099..91cb886 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -463,19 +463,19 @@
 #if 0
 		// jingham: look here
         StreamFile logfile ("/tmp/exprs.txt", "a");
-        logfile.Printf("0x%16.16llx: thread = 0x%4.4x, expr = '%s'\n", m_jit_start_addr, exe_ctx.thread ? exe_ctx.thread->GetID() : -1, m_expr_text.c_str());
+        logfile.Printf("0x%16.16" PRIx64 ": thread = 0x%4.4x, expr = '%s'\n", m_jit_start_addr, exe_ctx.thread ? exe_ctx.thread->GetID() : -1, m_expr_text.c_str());
 #endif
         
         if (log)
         {
             log->Printf("-- [ClangUserExpression::PrepareToExecuteJITExpression] Materializing for execution --");
             
-            log->Printf("  Function address  : 0x%llx", (uint64_t)m_jit_start_addr);
+            log->Printf("  Function address  : 0x%" PRIx64, (uint64_t)m_jit_start_addr);
             
             if (m_needs_object_ptr)
-                log->Printf("  Object pointer    : 0x%llx", (uint64_t)object_ptr);
+                log->Printf("  Object pointer    : 0x%" PRIx64, (uint64_t)object_ptr);
             
-            log->Printf("  Structure address : 0x%llx", (uint64_t)struct_address);
+            log->Printf("  Structure address : 0x%" PRIx64, (uint64_t)struct_address);
                     
             StreamString args;
             
diff --git a/source/Expression/ClangUtilityFunction.cpp b/source/Expression/ClangUtilityFunction.cpp
index b2f13f1..fd78f6e 100644
--- a/source/Expression/ClangUtilityFunction.cpp
+++ b/source/Expression/ClangUtilityFunction.cpp
@@ -153,7 +153,7 @@
 #if 0
 	// jingham: look here
     StreamFile logfile ("/tmp/exprs.txt", "a");
-    logfile.Printf ("0x%16.16llx: func = %s, source =\n%s\n", 
+    logfile.Printf ("0x%16.16" PRIx64 ": func = %s, source =\n%s\n",
                     m_jit_start_addr, 
                     m_function_name.c_str(), 
                     m_function_text.c_str());
diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp
index b044143..538afb7 100644
--- a/source/Expression/DWARFExpression.cpp
+++ b/source/Expression/DWARFExpression.cpp
@@ -322,10 +322,10 @@
         case DW_OP_const2s: s->Printf("DW_OP_const2s(0x%4.4x) ", m_data.GetU16(&offset)); break;      // 0x0b 1 2-byte constant
         case DW_OP_const4u: s->Printf("DW_OP_const4u(0x%8.8x) ", m_data.GetU32(&offset)); break;      // 0x0c 1 4-byte constant
         case DW_OP_const4s: s->Printf("DW_OP_const4s(0x%8.8x) ", m_data.GetU32(&offset)); break;      // 0x0d 1 4-byte constant
-        case DW_OP_const8u: s->Printf("DW_OP_const8u(0x%16.16llx) ", m_data.GetU64(&offset)); break;  // 0x0e 1 8-byte constant
-        case DW_OP_const8s: s->Printf("DW_OP_const8s(0x%16.16llx) ", m_data.GetU64(&offset)); break;  // 0x0f 1 8-byte constant
-        case DW_OP_constu:  s->Printf("DW_OP_constu(0x%llx) ", m_data.GetULEB128(&offset)); break;    // 0x10 1 ULEB128 constant
-        case DW_OP_consts:  s->Printf("DW_OP_consts(0x%lld) ", m_data.GetSLEB128(&offset)); break;    // 0x11 1 SLEB128 constant
+        case DW_OP_const8u: s->Printf("DW_OP_const8u(0x%16.16" PRIx64 ") ", m_data.GetU64(&offset)); break;  // 0x0e 1 8-byte constant
+        case DW_OP_const8s: s->Printf("DW_OP_const8s(0x%16.16" PRIx64 ") ", m_data.GetU64(&offset)); break;  // 0x0f 1 8-byte constant
+        case DW_OP_constu:  s->Printf("DW_OP_constu(0x%" PRIx64 ") ", m_data.GetULEB128(&offset)); break;    // 0x10 1 ULEB128 constant
+        case DW_OP_consts:  s->Printf("DW_OP_consts(0x%" PRId64 ") ", m_data.GetSLEB128(&offset)); break;    // 0x11 1 SLEB128 constant
         case DW_OP_dup:     s->PutCString("DW_OP_dup"); break;                                        // 0x12
         case DW_OP_drop:    s->PutCString("DW_OP_drop"); break;                                       // 0x13
         case DW_OP_over:    s->PutCString("DW_OP_over"); break;                                       // 0x14
@@ -344,7 +344,7 @@
         case DW_OP_or:      s->PutCString("DW_OP_or"); break;                                         // 0x21
         case DW_OP_plus:    s->PutCString("DW_OP_plus"); break;                                       // 0x22
         case DW_OP_plus_uconst:                                                                 // 0x23 1 ULEB128 addend
-            s->Printf("DW_OP_plus_uconst(0x%llx) ", m_data.GetULEB128(&offset));
+            s->Printf("DW_OP_plus_uconst(0x%" PRIx64 ") ", m_data.GetULEB128(&offset));
             break;
 
         case DW_OP_shl:     s->PutCString("DW_OP_shl"); break;                                        // 0x24
@@ -490,17 +490,17 @@
                     {
                         if (reg_info.name)
                         {
-                            s->Printf("[%s%+lli]", reg_info.name, reg_offset); 
+                            s->Printf("[%s%+" PRIi64 "]", reg_info.name, reg_offset);
                             break;
                         }
                         else if (reg_info.alt_name)
                         {
-                            s->Printf("[%s%+lli]", reg_info.alt_name, reg_offset); 
+                            s->Printf("[%s%+" PRIi64 "]", reg_info.alt_name, reg_offset);
                             break;
                         }
                     }
                 }
-                s->Printf("DW_OP_breg%i(0x%llx)", reg_num, reg_offset); 
+                s->Printf("DW_OP_breg%i(0x%" PRIx64 ")", reg_num, reg_offset);
             }
             break;
 
@@ -524,11 +524,11 @@
                         }
                     }
                 }
-                s->Printf("DW_OP_regx(%llu)", reg_num); break; 
+                s->Printf("DW_OP_regx(%" PRIu64 ")", reg_num); break;
             }
             break;
         case DW_OP_fbreg:                                                   // 0x91 1 SLEB128 offset
-            s->Printf("DW_OP_fbreg(%lli)",m_data.GetSLEB128(&offset));
+            s->Printf("DW_OP_fbreg(%" PRIi64 ")",m_data.GetSLEB128(&offset));
             break;
         case DW_OP_bregx:                                                   // 0x92 2 ULEB128 register followed by SLEB128 offset
             {
@@ -541,21 +541,21 @@
                     {
                         if (reg_info.name)
                         {
-                            s->Printf("[%s%+lli]", reg_info.name, reg_offset); 
+                            s->Printf("[%s%+" PRIi64 "]", reg_info.name, reg_offset);
                             break;
                         }
                         else if (reg_info.alt_name)
                         {
-                            s->Printf("[%s%+lli]", reg_info.alt_name, reg_offset); 
+                            s->Printf("[%s%+" PRIi64 "]", reg_info.alt_name, reg_offset);
                             break;
                         }
                     }
                 }
-                s->Printf("DW_OP_bregx(reg=%u,offset=%lli)", reg_num, reg_offset); 
+                s->Printf("DW_OP_bregx(reg=%u,offset=%" PRIi64 ")", reg_num, reg_offset);
             }
             break;
         case DW_OP_piece:                                                   // 0x93 1 ULEB128 size of piece addressed
-            s->Printf("DW_OP_piece(0x%llx)", m_data.GetULEB128(&offset));
+            s->Printf("DW_OP_piece(0x%" PRIx64 ")", m_data.GetULEB128(&offset));
             break;
         case DW_OP_deref_size:                                              // 0x94 1 1-byte size of data retrieved
             s->Printf("DW_OP_deref_size(0x%2.2x)", m_data.GetU8(&offset));
@@ -572,7 +572,7 @@
             s->Printf("DW_OP_call4(0x%8.8x)", m_data.GetU32(&offset));
             break;
         case DW_OP_call_ref:                                                // 0x9a DWARF3 1 4- or 8-byte offset of DIE
-            s->Printf("DW_OP_call_ref(0x%8.8llx)", m_data.GetAddress(&offset));
+            s->Printf("DW_OP_call_ref(0x%8.8" PRIx64 ")", m_data.GetAddress(&offset));
             break;
 //      case DW_OP_form_tls_address: s << "form_tls_address"; break;        // 0x9b DWARF3
 //      case DW_OP_call_frame_cfa: s << "call_frame_cfa"; break;            // 0x9c DWARF3
@@ -582,7 +582,7 @@
 //      case DW_OP_lo_user:     s->PutCString("DW_OP_lo_user"); break;                        // 0xe0
 //      case DW_OP_hi_user:     s->PutCString("DW_OP_hi_user"); break;                        // 0xff
 //        case DW_OP_APPLE_extern:
-//            s->Printf("DW_OP_APPLE_extern(%llu)", m_data.GetULEB128(&offset));
+//            s->Printf("DW_OP_APPLE_extern(%" PRIu64 ")", m_data.GetULEB128(&offset));
 //            break;
 //        case DW_OP_APPLE_array_ref:
 //            s->PutCString("DW_OP_APPLE_array_ref");
@@ -603,7 +603,7 @@
 //            s->PutCString("DW_OP_APPLE_deref_type");
 //            break;
 //        case DW_OP_APPLE_expr_local:    // 0xF5 - ULEB128 expression local index
-//            s->Printf("DW_OP_APPLE_expr_local(%llu)", m_data.GetULEB128(&offset));
+//            s->Printf("DW_OP_APPLE_expr_local(%" PRIu64 ")", m_data.GetULEB128(&offset));
 //            break;
 //        case DW_OP_APPLE_constf:        // 0xF6 - 1 byte float size, followed by constant float data
 //            {
@@ -1345,7 +1345,7 @@
             for (size_t i=0; i<count; ++i)
             {
                 StreamString new_value;
-                new_value.Printf("[%llu]", (uint64_t)i);
+                new_value.Printf("[%" PRIu64 "]", (uint64_t)i);
                 stack[i].Dump(&new_value);
                 log->Printf("  %s", new_value.GetData());
             }
@@ -1438,7 +1438,7 @@
                             else
                             {
                                 if (error_ptr)
-                                    error_ptr->SetErrorStringWithFormat ("Failed to dereference pointer from 0x%llx for DW_OP_deref: %s\n", 
+                                    error_ptr->SetErrorStringWithFormat ("Failed to dereference pointer from 0x%" PRIx64 " for DW_OP_deref: %s\n",
                                                                          pointer_addr,
                                                                          error.AsCString());
                                 return false;
@@ -1536,7 +1536,7 @@
                             else
                             {
                                 if (error_ptr)
-                                    error_ptr->SetErrorStringWithFormat ("Failed to dereference pointer from 0x%llx for DW_OP_deref: %s\n", 
+                                    error_ptr->SetErrorStringWithFormat ("Failed to dereference pointer from 0x%" PRIx64 " for DW_OP_deref: %s\n",
                                                                          pointer_addr,
                                                                          error.AsCString());
                                 return false;
@@ -2709,7 +2709,7 @@
                 if (size && (index >= size || index < 0))
                 {
                     if (error_ptr)
-                        error_ptr->SetErrorStringWithFormat("Out of bounds array access.  %lld is not in [0, %llu]", index, size);
+                        error_ptr->SetErrorStringWithFormat("Out of bounds array access.  %" PRId64 " is not in [0, %" PRIu64 "]", index, size);
                     return false;
                 }
                 
@@ -2892,7 +2892,7 @@
                                                                           new_value))
                                     {
                                         if (error_ptr)
-                                            error_ptr->SetErrorStringWithFormat ("Failed to write value to memory at 0x%llx.\n", addr);
+                                            error_ptr->SetErrorStringWithFormat ("Failed to write value to memory at 0x%" PRIx64 ".\n", addr);
                                         return false;
                                     }
                                 }
@@ -3186,7 +3186,7 @@
         for (size_t i=0; i<count; ++i)
         {
             StreamString new_value;
-            new_value.Printf("[%llu]", (uint64_t)i);
+            new_value.Printf("[%" PRIu64 "]", (uint64_t)i);
             stack[i].Dump(&new_value);
             log->Printf("  %s", new_value.GetData());
         }
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index ef76b9d..1217871 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -294,7 +294,7 @@
     }
     
     if (log)
-        log->Printf("Found \"%s\" at 0x%llx", name.GetCString(), fun_addr);
+        log->Printf("Found \"%s\" at 0x%" PRIx64, name.GetCString(), fun_addr);
     
     return true;
 }
@@ -869,7 +869,7 @@
         }
             
         if (log)
-            log->Printf("Found CFStringCreateWithBytes at 0x%llx", CFStringCreateWithBytes_addr);
+            log->Printf("Found CFStringCreateWithBytes at 0x%" PRIx64, CFStringCreateWithBytes_addr);
         
         // Build the function type:
         //
@@ -1262,7 +1262,7 @@
             return false;
         
         if (log)
-            log->Printf("Found sel_registerName at 0x%llx", sel_registerName_addr);
+            log->Printf("Found sel_registerName at 0x%" PRIx64, sel_registerName_addr);
         
         // Build the function type: struct objc_selector *sel_registerName(uint8_t*)
         
@@ -1678,7 +1678,7 @@
         off_t value_alignment = (ast_context->getTypeAlign(qual_type) + 7) / 8;
         
         if (log)
-            log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %lu, align %lld]", 
+            log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %lu, align %" PRId64 "]",
                         name.c_str(), 
                         qual_type.getAsString().c_str(), 
                         PrintType(value_type).c_str(), 
@@ -1728,7 +1728,7 @@
     }
 
     if (log)
-        log->Printf("Found \"%s\" at 0x%llx", name.GetCString(), symbol_addr);
+        log->Printf("Found \"%s\" at 0x%" PRIx64, name.GetCString(), symbol_addr);
     
     Type *symbol_type = symbol->getType();
     IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(),
@@ -2529,7 +2529,7 @@
         }
             
         if (log)
-            log->Printf("  \"%s\" (\"%s\") placed at %lld",
+            log->Printf("  \"%s\" (\"%s\") placed at %" PRId64,
                         name.GetCString(),
                         decl->getNameAsString().c_str(),
                         offset);
@@ -2573,7 +2573,7 @@
     }
     
     if (log)
-        log->Printf("Total structure [align %lld, size %lu]", alignment, size);
+        log->Printf("Total structure [align %" PRId64 ", size %lu]", alignment, size);
     
     return true;
 }
diff --git a/source/Expression/IRInterpreter.cpp b/source/Expression/IRInterpreter.cpp
index 4211c87..b30b066 100644
--- a/source/Expression/IRInterpreter.cpp
+++ b/source/Expression/IRInterpreter.cpp
@@ -389,7 +389,7 @@
 
         lldb_private::Value base = GetAccessTarget(region.m_base);
         
-        ss.Printf("%llx [%s - %s %llx]",
+        ss.Printf("%" PRIx64 " [%s - %s %llx]",
                   region.m_base,
                   lldb_private::Value::GetValueTypeAsCString(base.GetValueType()),
                   lldb_private::Value::GetContextTypeAsCString(base.GetContextType()),
diff --git a/source/Expression/RecordingMemoryManager.cpp b/source/Expression/RecordingMemoryManager.cpp
index 4d9c721..6dc2029 100644
--- a/source/Expression/RecordingMemoryManager.cpp
+++ b/source/Expression/RecordingMemoryManager.cpp
@@ -89,7 +89,7 @@
     
     if (m_log)
     {
-        m_log->Printf("RecordingMemoryManager::allocateSpace(Size=%llu, Alignment=%u) = %p",
+        m_log->Printf("RecordingMemoryManager::allocateSpace(Size=%" PRIu64 ", Alignment=%u) = %p",
                       (uint64_t)Size, Alignment, return_value);
         allocation.dump(m_log);
     }
@@ -113,7 +113,7 @@
     
     if (m_log)
     {
-        m_log->Printf("RecordingMemoryManager::allocateCodeSection(Size=0x%llx, Alignment=%u, SectionID=%u) = %p",
+        m_log->Printf("RecordingMemoryManager::allocateCodeSection(Size=0x%" PRIx64 ", Alignment=%u, SectionID=%u) = %p",
                       (uint64_t)Size, Alignment, SectionID, return_value);
         allocation.dump(m_log);
     }
@@ -136,7 +136,7 @@
     
     if (m_log)
     {
-        m_log->Printf("RecordingMemoryManager::allocateDataSection(Size=0x%llx, Alignment=%u, SectionID=%u) = %p",
+        m_log->Printf("RecordingMemoryManager::allocateDataSection(Size=0x%" PRIx64 ", Alignment=%u, SectionID=%u) = %p",
                       (uint64_t)Size, Alignment, SectionID, return_value);
         allocation.dump(m_log);
     }
@@ -158,7 +158,7 @@
     
     if (m_log)
     {
-        m_log->Printf("RecordingMemoryManager::allocateGlobal(Size=0x%llx, Alignment=%u) = %p",
+        m_log->Printf("RecordingMemoryManager::allocateGlobal(Size=0x%" PRIx64 ", Alignment=%u) = %p",
                       (uint64_t)Size, Alignment, return_value);
         allocation.dump(m_log);
     }