diff options
author | Devang Patel <dpatel@apple.com> | 2010-04-24 00:40:35 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-04-24 00:40:35 +0000 |
commit | f0bf4d554f2513cbb4bec952c81ced59279ad91e (patch) | |
tree | a55e670cb3171f2439953d4edd84ce22da15ab09 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 8a4377697161c5087e27cc40d6e0682f0cd1fa20 (diff) |
Revert r102215. This causes clang crash while compiling a test case from gdb testsuite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102224 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 2a5b7af712..7a9961b37f 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1333,9 +1333,21 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, llvm::StringRef Name; MangleBuffer LinkageName; + // It is expected that CurLoc is set before using EmitFunctionStart. + // Usually, CurLoc points to the left bracket location of compound + // statement representing function body. + llvm::DIFile Unit = getOrCreateFile(CurLoc); + llvm::DIDescriptor Context(Unit.getNode()); const Decl *D = GD.getDecl(); if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { + if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) { + if (MD->isStatic()) { + QualType RTy = CGM.getContext().getTypeDeclType(MD->getParent()); + Context = CreateType(RTy->getAs<RecordType>(), getOrCreateFile(CurLoc)); + } + } + // If there is a DISubprogram for this function available then use it. llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator FI = SPCache.find(FD); @@ -1360,15 +1372,11 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, Name = Name.substr(1); } - // It is expected that CurLoc is set before using EmitFunctionStart. - // Usually, CurLoc points to the left bracket location of compound - // statement representing function body. - llvm::DIFile Unit = getOrCreateFile(CurLoc); SourceManager &SM = CGM.getContext().getSourceManager(); unsigned LineNo = SM.getPresumedLoc(CurLoc).getLine(); llvm::DISubprogram SP = - DebugFactory.CreateSubprogram(Unit, Name, Name, LinkageName, Unit, LineNo, + DebugFactory.CreateSubprogram(Context, Name, Name, LinkageName, Unit, LineNo, getOrCreateType(FnType, Unit), Fn->hasInternalLinkage(), true/*definition*/); |