From 89af112cf590e76fbb1fd964086a3882b7f935f9 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 13 Sep 2017 21:54:20 +0000 Subject: [codeview] VLAs and unsized arrays should use a size of zero Previously we used a size of '1' for VLAs because we weren't sure what MSVC did. However, MSVC does support declaring an array without a size, for which it emits an array type with a size of zero. Clang emits the same DI metadata for VLAs and arrays without bound, so we would describe arrays without bound as having one element. This lead to Microsoft debuggers only printing a single element. Emitting a size of zero appears to cause these debuggers to search the symbol information to find a definition of the variable with accurate array bounds. Fixes http://crbug.com/763580 llvm-svn: 313203 --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index ed2dfa6..6eba00b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1277,11 +1277,12 @@ TypeIndex CodeViewDebug::lowerTypeArray(const DICompositeType *Ty) { "codeview doesn't support subranges with lower bounds"); int64_t Count = Subrange->getCount(); - // Variable Length Array (VLA) has Count equal to '-1'. - // Replace with Count '1', assume it is the minimum VLA length. + // Variable length arrays and forward declarations of arrays without a size + // use a count of -1. Emit a count (and overall size) or zero in these cases + // to match what MSVC does for array declarations with no count. // FIXME: Make front-end support VLA subrange and emit LF_DIMVARLU. if (Count == -1) - Count = 1; + Count = 0; // Update the element size and element type index for subsequent subranges. ElementSize *= Count; -- cgit v1.1