summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-09-13 21:54:20 +0000
committerReid Kleckner <rnk@google.com>2017-09-13 21:54:20 +0000
commit89af112cf590e76fbb1fd964086a3882b7f935f9 (patch)
treedc78d36091bb9fd87f5161b311f992fca4acbcf4 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parentbe707f2930ceceb001557834b0e6940a5a81ce7b (diff)
downloadbcm5719-llvm-89af112cf590e76fbb1fd964086a3882b7f935f9.tar.gz
bcm5719-llvm-89af112cf590e76fbb1fd964086a3882b7f935f9.zip
[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
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index ed2dfa6906f..6eba00be00e 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;
OpenPOWER on IntegriCloud