Start converting usages of off_t to other types.
off_t is a type which is used for file offsets. Even more
specifically, it is only used by a limited number of C APIs that
deal with files. Any usage of off_t where the variable is not
intended to be used with one of these APIs is a bug, by definition.
This patch corrects some easy mis-uses of off_t, generally by
converting them to lldb::offset_t, but sometimes by using other
types such as size_t, when appropriate.
The use of off_t to represent these offsets has worked fine in
practice on linux-y platforms, since we used _FILE_OFFSET_64 to
guarantee that off_t was a uint64. On Windows, however,
_FILE_OFFSET_64 is unrecognized, and off_t will always be 32-bit.
So the usage of off_t on Windows actually leads to legitimate bugs.
Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D4358
llvm-svn: 212192
diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp
index c4b776d..7571c25 100644
--- a/lldb/source/Expression/IRForTarget.cpp
+++ b/lldb/source/Expression/IRForTarget.cpp
@@ -1519,11 +1519,11 @@
}
const uint64_t value_size = clang_type.GetByteSize();
- off_t value_alignment = (clang_type.GetTypeBitAlign() + 7ull) / 8ull;
+ lldb::offset_t value_alignment = (clang_type.GetTypeBitAlign() + 7ull) / 8ull;
if (log)
{
- log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRId64 "]",
+ log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRIu64 "]",
name.c_str(),
clang_type.GetQualType().getAsString().c_str(),
PrintType(value_type).c_str(),
@@ -2258,7 +2258,7 @@
uint32_t element_index;
size_t size;
- off_t alignment;
+ lldb::offset_t alignment;
if (!m_decl_map->GetStructInfo (num_elements, size, alignment))
return false;
@@ -2359,7 +2359,7 @@
{
const clang::NamedDecl *decl = NULL;
Value *value = NULL;
- off_t offset;
+ lldb::offset_t offset;
lldb_private::ConstString name;
if (!m_decl_map->GetStructElement (decl, value, offset, name, element_index))
@@ -2371,7 +2371,7 @@
}
if (log)
- log->Printf(" \"%s\" (\"%s\") placed at %" PRId64,
+ log->Printf(" \"%s\" (\"%s\") placed at %" PRIu64,
name.GetCString(),
decl->getNameAsString().c_str(),
offset);