diff options
author | Devang Patel <dpatel@apple.com> | 2009-04-17 21:35:15 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-04-17 21:35:15 +0000 |
commit | 4f6fa233be8e7d1d10445c704c8cfb1869ce8c4c (patch) | |
tree | c7cb5b55a05f664462bc782db09a077afe7aad22 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 8a81e1e858f9bb75c295c12b5b05e17b49fcd279 (diff) |
Use PresumedLoc to record line number in debug info entries.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 83719e4681..e7a4a45573 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -194,7 +194,8 @@ llvm::DIType CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DICompileUnit DefUnit = getOrCreateCompileUnit(DefLoc); SourceManager &SM = M->getContext().getSourceManager(); - uint64_t Line = SM.getInstantiationLineNumber(DefLoc); + PresumedLoc PLoc = SM.getPresumedLoc(DefLoc); + unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine(); return DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_typedef, Unit, TyName, DefUnit, Line, 0, 0, 0, 0, Src); @@ -246,8 +247,8 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, std::string Name = Decl->getNameAsString(); llvm::DICompileUnit DefUnit = getOrCreateCompileUnit(Decl->getLocation()); - unsigned Line = SM.getInstantiationLineNumber(Decl->getLocation()); - + PresumedLoc PLoc = SM.getPresumedLoc(Decl->getLocation()); + unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine(); // Records and classes and unions can all be recursive. To handle them, we // first generate a debug descriptor for the struct as a forward declaration. @@ -284,7 +285,9 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, // Get the location for the field. SourceLocation FieldDefLoc = Field->getLocation(); llvm::DICompileUnit FieldDefUnit = getOrCreateCompileUnit(FieldDefLoc); - unsigned FieldLine = SM.getInstantiationLineNumber(FieldDefLoc); + PresumedLoc PLoc = SM.getPresumedLoc(FieldDefLoc); + unsigned FieldLine = PLoc.isInvalid() ? 0 : PLoc.getLine(); + QualType FType = Field->getType(); uint64_t FieldSize = 0; @@ -344,8 +347,9 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, std::string Name = Decl->getNameAsString(); llvm::DICompileUnit DefUnit = getOrCreateCompileUnit(Decl->getLocation()); - unsigned Line = SM.getInstantiationLineNumber(Decl->getLocation()); - + PresumedLoc PLoc = SM.getPresumedLoc(Decl->getLocation()); + unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine(); + // To handle recursive interface, we // first generate a debug descriptor for the struct as a forward declaration. @@ -392,7 +396,9 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, // Get the location for the field. SourceLocation FieldDefLoc = Field->getLocation(); llvm::DICompileUnit FieldDefUnit = getOrCreateCompileUnit(FieldDefLoc); - unsigned FieldLine = SM.getInstantiationLineNumber(FieldDefLoc); + PresumedLoc PLoc = SM.getPresumedLoc(FieldDefLoc); + unsigned FieldLine = PLoc.isInvalid() ? 0 : PLoc.getLine(); + QualType FType = Field->getType(); uint64_t FieldSize = 0; @@ -470,7 +476,9 @@ llvm::DIType CGDebugInfo::CreateType(const EnumType *Ty, SourceLocation DefLoc = Decl->getLocation(); llvm::DICompileUnit DefUnit = getOrCreateCompileUnit(DefLoc); SourceManager &SM = M->getContext().getSourceManager(); - unsigned Line = SM.getInstantiationLineNumber(DefLoc); + PresumedLoc PLoc = SM.getPresumedLoc(DefLoc); + unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine(); + // Size and align of the type. uint64_t Size = M->getContext().getTypeSize(Ty); @@ -686,7 +694,8 @@ void CGDebugInfo::EmitDeclare(const VarDecl *Decl, unsigned Tag, // Get location information. SourceManager &SM = M->getContext().getSourceManager(); - unsigned Line = SM.getInstantiationLineNumber(Decl->getLocation()); + PresumedLoc PLoc = SM.getPresumedLoc(Decl->getLocation()); + unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine(); llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation()); // Create the descriptor for the variable. @@ -727,7 +736,8 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, // Create global variable debug descriptor. llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation()); SourceManager &SM = M->getContext().getSourceManager(); - unsigned LineNo = SM.getInstantiationLineNumber(Decl->getLocation()); + PresumedLoc PLoc = SM.getPresumedLoc(Decl->getLocation()); + unsigned LineNo = PLoc.isInvalid() ? 0 : PLoc.getLine(); std::string Name = Decl->getNameAsString(); @@ -756,7 +766,8 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, // Create global variable debug descriptor. llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation()); SourceManager &SM = M->getContext().getSourceManager(); - unsigned LineNo = SM.getInstantiationLineNumber(Decl->getLocation()); + PresumedLoc PLoc = SM.getPresumedLoc(Decl->getLocation()); + unsigned LineNo = PLoc.isInvalid() ? 0 : PLoc.getLine(); std::string Name = Decl->getNameAsString(); |