[Lldb-commits] [PATCH] Work around for Visual Studio 2013 compiler crash

Zachary Turner zturner at google.com
Wed Dec 17 09:55:51 PST 2014


Looks good, I will commit for you.


================
Comment at: include/lldb/Utility/ProcessStructReader.h:66-67
@@ -65,1 +65,4 @@
                     return;
+#if 1
+                /* work around VS2013 compiler crash */
+                ConstString a_ = ConstString(name.c_str( ));
----------------
Remove the #if and the comment.  The code stands on its own, so I don't think this adds much value.

================
Comment at: include/lldb/Utility/ProcessStructReader.h:68-71
@@ +67,6 @@
+                /* work around VS2013 compiler crash */
+                ConstString a_ = ConstString(name.c_str( ));
+                size_t b_ = static_cast<size_t>(bit_offset/8);
+                size_t c_ = static_cast<size_t>(size);
+                m_fields[a_] = FieldImpl{field_type,b_,c_};
+#else
----------------
Local variable naming conventions are all lowercase, underscores between words.  But no underscore at the end of the word.  And we prefer to have meaningful variable names instead of letters like a, b, and c.  So let's re-write this (including a few lines prior to where this patch starts) as:

    size_t size = static_cast<size_t>(field_type.GetByteSize());
    // no support for things larger than a uint64_t (yet)
    if (size > 8)
        return;
    size_t byte_index = static_cast<size_t>(bit_offset/8);
    m_fields[ConstString(name.c_str()))] = FieldImpl {field_type, byte_index, size};

Note that the reason this ICE'd in the first place is because MSVC doesn't have good support for brace initialization.  So even if the fix here solves the ICE, MSVC might have code generation errors.  So perhaps an even better fix is to write it like this:

    size_t size = static_cast<size_t>(field_type.GetByteSize());
    // no support for things larger than a uint64_t (yet)
    if (size > 8)
        return;
    FieldImpl &field = m_fields[ConstString(name.c_str()))];
    field.type = field_type;
    field.offset = static_cast<size_t>(bit_offset/8);
    field.size = size;

http://reviews.llvm.org/D6702

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the lldb-commits mailing list