diff options
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
| -rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 7d5d260304..f6ad8f2cc5 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1220,9 +1220,11 @@ CollectTemplateParams(const TemplateParameterList *TPList, V = CGM.GetAddrOfGlobalVar(VD); // Member function pointers have special support for building them, though // this is currently unsupported in LLVM CodeGen. - if (InstanceMember) + if (InstanceMember) { if (const CXXMethodDecl *method = dyn_cast<CXXMethodDecl>(D)) V = CGM.getCXXABI().EmitMemberPointer(method); + } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) + V = CGM.GetAddrOfFunction(FD); // Member data pointers have special handling too to compute the fixed // offset within the object. if (isa<FieldDecl>(D)) { @@ -2172,8 +2174,21 @@ llvm::DIType CGDebugInfo::CreateMemberType(llvm::DIFile Unit, QualType FType, } llvm::DIDescriptor CGDebugInfo::getDeclarationOrDefinition(const Decl *D) { - if (const TypeDecl *RD = dyn_cast<TypeDecl>(D)) - return CreatePointeeType(QualType(RD->getTypeForDecl(), 0), llvm::DIFile()); + // We only need a declaration (not a definition) of the type - so use whatever + // we would otherwise do to get a type for a pointee. (forward declarations in + // limited debug info, full definitions (if the type definition is available) + // in unlimited debug info) + if (const TypeDecl *TD = dyn_cast<TypeDecl>(D)) { + llvm::DIFile DefUnit = getOrCreateFile(TD->getLocation()); + return CreatePointeeType(CGM.getContext().getTypeDeclType(TD), DefUnit); + } + // Otherwise fall back to a fairly rudimentary cache of existing declarations. + // This doesn't handle providing declarations (for functions or variables) for + // entities without definitions in this TU, nor when the definition proceeds + // the call to this function. + // FIXME: This should be split out into more specific maps with support for + // emitting forward declarations and merging definitions with declarations, + // the same way as we do for types. llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator I = DeclCache.find(D->getCanonicalDecl()); if (I == DeclCache.end()) |
