[Lldb-commits] [PATCH] D53530: Fix (and improve) the support for C99 variable length array types

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 1 11:24:34 PDT 2018


aprantl added a comment.

> I didn't realize that the string int [] is produced by ValueObject itself; I think this makes this option more palatable to me. I'll give it a try.

So, it turns out it isn't. The only way to get the length into the typename is to hack ClangASTContext::GetTypeName to replace the training "[]" of what clang returns as the typename with a different string. The main problem with this is that this will only work for outermost types.

Something that has been requested in the past is to support C structs with trailing array members, such as

  struct variable_size {
    unsigned length;
    int __attribute__((size=.length)) elements[]; // I just made up this attribute, but you get the basic idea.
  };

in a similar fashion. When printing such a struct, there's no way of safely injecting the size into array type string any more.
If we dynamically created the correctly-sized array type instead, this would work just fine.

I haven't yet understood the motivation behind why overriding GetNumChildren/GetTypeName/GetChildAtIndex is preferable over creating a dynamic type in the language runtime. Is there something that I need to know?


https://reviews.llvm.org/D53530





More information about the lldb-commits mailing list