From 650cea9cc5ceb9fbcf8897db0e252e5bdb5c5179 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 5 May 2009 04:57:08 +0000 Subject: Fix generated debug info for decls with no location (which include self/_cmd in ObjC) to not emit file/line location information. Previously we would output a file with bogus line information. This fixes: rdar://6852814 - Clang generates incorrect file & line info for automatic/understood formal parameters for objc-programs git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70965 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/CodeGen/CGDebugInfo.cpp') diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index c11e8ce0ad..9715337970 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -734,17 +734,23 @@ void CGDebugInfo::EmitDeclare(const VarDecl *Decl, unsigned Tag, if (CO.OptimizationLevel) return; + llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation()); + llvm::DIType Ty = getOrCreateType(Decl->getType(), Unit); + // Get location information. SourceManager &SM = M->getContext().getSourceManager(); PresumedLoc PLoc = SM.getPresumedLoc(Decl->getLocation()); - unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine(); - llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation()); + unsigned Line = 0; + if (!PLoc.isInvalid()) + Line = PLoc.getLine(); + else + Unit = llvm::DICompileUnit(); + // Create the descriptor for the variable. llvm::DIVariable D = DebugFactory.CreateVariable(Tag, RegionStack.back(),Decl->getNameAsString(), - Unit, Line, - getOrCreateType(Decl->getType(), Unit)); + Unit, Line, Ty); // Insert an llvm.dbg.declare into the current block. DebugFactory.InsertDeclare(Storage, D, Builder.GetInsertBlock()); } -- cgit v1.2.3