From ab067ae8b00e4d6eea68e94f2bc06e126d538bd8 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 30 Apr 2013 22:45:09 +0000 Subject: [PATCH] Revert 180817 because 180816 was reverted. llvm-svn: 180823 --- clang/lib/CodeGen/CGDebugInfo.cpp | 16 ++++++++++++++++ clang/test/CodeGen/debug-info-vla.c | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index bb2c300ed8b3..6beba66c79a4 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2506,6 +2506,22 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag, VD->getName(), Unit, Line, Ty, addr, ArgNo); + // Insert an llvm.dbg.declare into the current block. + llvm::Instruction *Call = + DBuilder.insertDeclare(Storage, D, Builder.GetInsertBlock()); + Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); + return; + } else if (isa(VD->getType())) { + // These are "complex" variables in that they need an op_deref. + // Create the descriptor for the variable. + llvm::Value *Addr = llvm::ConstantInt::get(CGM.Int64Ty, + llvm::DIBuilder::OpDeref); + llvm::DIVariable D = + DBuilder.createComplexVariable(Tag, + llvm::DIDescriptor(Scope), + Name, Unit, Line, Ty, + Addr, ArgNo); + // Insert an llvm.dbg.declare into the current block. llvm::Instruction *Call = DBuilder.insertDeclare(Storage, D, Builder.GetInsertBlock()); diff --git a/clang/test/CodeGen/debug-info-vla.c b/clang/test/CodeGen/debug-info-vla.c index 2e173e4a3f66..20fb6aace41f 100644 --- a/clang/test/CodeGen/debug-info-vla.c +++ b/clang/test/CodeGen/debug-info-vla.c @@ -1,8 +1,9 @@ // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s +// CHECK: metadata !{i32 {{.*}}, metadata {{.*}}, metadata !"vla", metadata {{.*}}, i32 7, metadata {{.*}}, i32 0, i32 0, i64 2} ; [ DW_TAG_auto_variable ] + void testVLAwithSize(int s) { -// CHECK: metadata !{i32 {{.*}}, metadata {{.*}}, metadata !"vla", metadata {{.*}}, i32 [[@LINE+1]], metadata {{.*}}, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [vla] [line [[@LINE+1]]] int vla[s]; int i; for (i = 0; i < s; i++) {