Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/CodeGen/CGDebugInfo.cpp
Show First 20 Lines • Show All 4,234 Lines • ▼ Show 20 Lines | void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, | ||||
// Insert an llvm.dbg.declare into the current block. | // Insert an llvm.dbg.declare into the current block. | ||||
DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(), | DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(), | ||||
llvm::DebugLoc::get(line, column, scope, CurInlinedAt), | llvm::DebugLoc::get(line, column, scope, CurInlinedAt), | ||||
Builder.GetInsertBlock()); | Builder.GetInsertBlock()); | ||||
} | } | ||||
llvm::DIDerivedType * | llvm::DIDerivedType * | ||||
CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D) { | CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D) { | ||||
if (!D->isStaticDataMember()) | if (!D || !D->isStaticDataMember()) | ||||
return nullptr; | return nullptr; | ||||
auto MI = StaticDataMemberCache.find(D->getCanonicalDecl()); | auto MI = StaticDataMemberCache.find(D->getCanonicalDecl()); | ||||
if (MI != StaticDataMemberCache.end()) { | if (MI != StaticDataMemberCache.end()) { | ||||
assert(MI->second && "Static data member declaration should still exist"); | assert(MI->second && "Static data member declaration should still exist"); | ||||
return MI->second; | return MI->second; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { | ||||
if (VD->hasAttr<NoDebugAttr>()) | if (VD->hasAttr<NoDebugAttr>()) | ||||
return; | return; | ||||
auto Align = getDeclAlignIfRequired(VD, CGM.getContext()); | auto Align = getDeclAlignIfRequired(VD, CGM.getContext()); | ||||
// Create the descriptor for the variable. | // Create the descriptor for the variable. | ||||
llvm::DIFile *Unit = getOrCreateFile(VD->getLocation()); | llvm::DIFile *Unit = getOrCreateFile(VD->getLocation()); | ||||
StringRef Name = VD->getName(); | StringRef Name = VD->getName(); | ||||
llvm::DIType *Ty = getOrCreateType(VD->getType(), Unit); | llvm::DIType *Ty = getOrCreateType(VD->getType(), Unit); | ||||
// Do not use global variables for enums. | // Do not use global variables for enums, unless for CodeView. | ||||
if (const auto *ECD = dyn_cast<EnumConstantDecl>(VD)) { | if (const auto *ECD = dyn_cast<EnumConstantDecl>(VD)) { | ||||
const auto *ED = cast<EnumDecl>(ECD->getDeclContext()); | const auto *ED = cast<EnumDecl>(ECD->getDeclContext()); | ||||
assert(isa<EnumType>(ED->getTypeForDecl()) && "Enum without EnumType?"); | assert(isa<EnumType>(ED->getTypeForDecl()) && "Enum without EnumType?"); | ||||
(void)ED; | (void)ED; | ||||
if (!CGM.getCodeGenOpts().EmitCodeView) | |||||
return; | return; | ||||
} | } | ||||
llvm::DIScope *DContext = nullptr; | llvm::DIScope *DContext = nullptr; | ||||
// Do not emit separate definitions for function local consts. | // Do not emit separate definitions for function local consts. | ||||
if (isa<FunctionDecl>(VD->getDeclContext())) | if (isa<FunctionDecl>(VD->getDeclContext())) | ||||
return; | return; | ||||
// Emit definition for static members in CodeView. | // Emit definition for static members in CodeView. | ||||
VD = cast<ValueDecl>(VD->getCanonicalDecl()); | VD = cast<ValueDecl>(VD->getCanonicalDecl()); | ||||
auto *VarD = cast<VarDecl>(VD); | auto *VarD = dyn_cast<VarDecl>(VD); | ||||
if (VarD->isStaticDataMember()) { | if (VarD && VarD->isStaticDataMember()) { | ||||
auto *RD = cast<RecordDecl>(VarD->getDeclContext()); | auto *RD = cast<RecordDecl>(VarD->getDeclContext()); | ||||
getDeclContextDescriptor(VarD); | getDeclContextDescriptor(VarD); | ||||
// Ensure that the type is retained even though it's otherwise unreferenced. | // Ensure that the type is retained even though it's otherwise unreferenced. | ||||
// | // | ||||
// FIXME: This is probably unnecessary, since Ty should reference RD | // FIXME: This is probably unnecessary, since Ty should reference RD | ||||
// through its scope. | // through its scope. | ||||
RetainedTypes.push_back( | RetainedTypes.push_back( | ||||
CGM.getContext().getRecordType(RD).getAsOpaquePtr()); | CGM.getContext().getRecordType(RD).getAsOpaquePtr()); | ||||
▲ Show 20 Lines • Show All 256 Lines • Show Last 20 Lines |