mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
DebugInfo: Gut DINamespace and DITemplate*Parameter
Continue gutting `DIDescriptor` subclasses, turning them into as-bare-as-possible pointer wrappers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234843 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
32cb99437e
commit
41ed49389b
@ -519,58 +519,42 @@ public:
|
||||
unsigned getDiscriminator() const { return get()->getDiscriminator(); }
|
||||
};
|
||||
|
||||
/// \brief A wrapper for a C++ style name space.
|
||||
class DINameSpace : public DIScope {
|
||||
class DINameSpace {
|
||||
MDNamespace *N;
|
||||
|
||||
public:
|
||||
DINameSpace() = default;
|
||||
DINameSpace(const MDNamespace *N) : DIScope(N) {}
|
||||
DINameSpace(const MDNamespace *N = nullptr)
|
||||
: N(const_cast<MDNamespace *>(N)) {}
|
||||
|
||||
MDNamespace *get() const {
|
||||
return cast_or_null<MDNamespace>(DIDescriptor::get());
|
||||
}
|
||||
operator MDNamespace *() const { return get(); }
|
||||
MDNamespace *operator->() const { return get(); }
|
||||
MDNamespace &operator*() const { return *get(); }
|
||||
|
||||
StringRef getName() const { return get()->getName(); }
|
||||
unsigned getLineNumber() const { return get()->getLine(); }
|
||||
DIScope getContext() const { return DIScope(get()->getScope()); }
|
||||
operator DIDescriptor() const { return N; }
|
||||
operator DIScope() const { return N; }
|
||||
operator MDNamespace *() const { return N; }
|
||||
MDNamespace *operator->() const { return N; }
|
||||
MDNamespace &operator*() const { return *N; }
|
||||
};
|
||||
|
||||
/// \brief This is a wrapper for template type parameter.
|
||||
class DITemplateTypeParameter : public DIDescriptor {
|
||||
class DITemplateTypeParameter {
|
||||
MDTemplateTypeParameter *N;
|
||||
|
||||
public:
|
||||
DITemplateTypeParameter() = default;
|
||||
DITemplateTypeParameter(const MDTemplateTypeParameter *N) : DIDescriptor(N) {}
|
||||
DITemplateTypeParameter(const MDTemplateTypeParameter *N = nullptr)
|
||||
: N(const_cast<MDTemplateTypeParameter *>(N)) {}
|
||||
|
||||
MDTemplateTypeParameter *get() const {
|
||||
return cast_or_null<MDTemplateTypeParameter>(DIDescriptor::get());
|
||||
}
|
||||
operator MDTemplateTypeParameter *() const { return get(); }
|
||||
MDTemplateTypeParameter *operator->() const { return get(); }
|
||||
MDTemplateTypeParameter &operator*() const { return *get(); }
|
||||
|
||||
StringRef getName() const { return get()->getName(); }
|
||||
DITypeRef getType() const { return get()->getType(); }
|
||||
operator MDTemplateTypeParameter *() const { return N; }
|
||||
MDTemplateTypeParameter *operator->() const { return N; }
|
||||
MDTemplateTypeParameter &operator*() const { return *N; }
|
||||
};
|
||||
|
||||
/// \brief This is a wrapper for template value parameter.
|
||||
class DITemplateValueParameter : public DIDescriptor {
|
||||
class DITemplateValueParameter {
|
||||
MDTemplateValueParameter *N;
|
||||
|
||||
public:
|
||||
DITemplateValueParameter() = default;
|
||||
DITemplateValueParameter(const MDTemplateValueParameter *N)
|
||||
: DIDescriptor(N) {}
|
||||
DITemplateValueParameter(const MDTemplateValueParameter *N = nullptr)
|
||||
: N(const_cast<MDTemplateValueParameter *>(N)) {}
|
||||
|
||||
MDTemplateValueParameter *get() const {
|
||||
return cast_or_null<MDTemplateValueParameter>(DIDescriptor::get());
|
||||
}
|
||||
operator MDTemplateValueParameter *() const { return get(); }
|
||||
MDTemplateValueParameter *operator->() const { return get(); }
|
||||
MDTemplateValueParameter &operator*() const { return *get(); }
|
||||
|
||||
StringRef getName() const { return get()->getName(); }
|
||||
DITypeRef getType() const { return get()->getType(); }
|
||||
Metadata *getValue() const { return get()->getValue(); }
|
||||
operator MDTemplateValueParameter *() const { return N; }
|
||||
MDTemplateValueParameter *operator->() const { return N; }
|
||||
MDTemplateValueParameter &operator*() const { return *N; }
|
||||
};
|
||||
|
||||
class DIGlobalVariable {
|
||||
@ -598,7 +582,6 @@ public:
|
||||
MDLocalVariable &operator*() const { return *N; }
|
||||
};
|
||||
|
||||
|
||||
class DIExpression {
|
||||
MDExpression *N;
|
||||
|
||||
|
@ -438,7 +438,7 @@ void DwarfUnit::addSourceLine(DIE &Die, DIObjCProperty Ty) {
|
||||
/// addSourceLine - Add location information to specified debug information
|
||||
/// entry.
|
||||
void DwarfUnit::addSourceLine(DIE &Die, DINameSpace NS) {
|
||||
addSourceLine(Die, NS.getLineNumber(), NS.getFilename(), NS.getDirectory());
|
||||
addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
|
||||
}
|
||||
|
||||
/// addRegisterOp - Add register operand.
|
||||
@ -1145,10 +1145,10 @@ void DwarfUnit::constructTemplateTypeParameterDIE(DIE &Buffer,
|
||||
DIE &ParamDIE =
|
||||
createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer);
|
||||
// Add the type if it exists, it could be void and therefore no type.
|
||||
if (TP.getType())
|
||||
addType(ParamDIE, resolve(TP.getType()));
|
||||
if (!TP.getName().empty())
|
||||
addString(ParamDIE, dwarf::DW_AT_name, TP.getName());
|
||||
if (TP->getType())
|
||||
addType(ParamDIE, resolve(TP->getType()));
|
||||
if (!TP->getName().empty())
|
||||
addString(ParamDIE, dwarf::DW_AT_name, TP->getName());
|
||||
}
|
||||
|
||||
/// constructTemplateValueParameterDIE - Construct new DIE for the given
|
||||
@ -1156,17 +1156,17 @@ void DwarfUnit::constructTemplateTypeParameterDIE(DIE &Buffer,
|
||||
void
|
||||
DwarfUnit::constructTemplateValueParameterDIE(DIE &Buffer,
|
||||
DITemplateValueParameter VP) {
|
||||
DIE &ParamDIE = createAndAddDIE(VP.getTag(), Buffer);
|
||||
DIE &ParamDIE = createAndAddDIE(VP->getTag(), Buffer);
|
||||
|
||||
// Add the type if there is one, template template and template parameter
|
||||
// packs will not have a type.
|
||||
if (VP.getTag() == dwarf::DW_TAG_template_value_parameter)
|
||||
addType(ParamDIE, resolve(VP.getType()));
|
||||
if (!VP.getName().empty())
|
||||
addString(ParamDIE, dwarf::DW_AT_name, VP.getName());
|
||||
if (Metadata *Val = VP.getValue()) {
|
||||
if (VP->getTag() == dwarf::DW_TAG_template_value_parameter)
|
||||
addType(ParamDIE, resolve(VP->getType()));
|
||||
if (!VP->getName().empty())
|
||||
addString(ParamDIE, dwarf::DW_AT_name, VP->getName());
|
||||
if (Metadata *Val = VP->getValue()) {
|
||||
if (ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Val))
|
||||
addConstantValue(ParamDIE, CI, resolve(VP.getType()));
|
||||
addConstantValue(ParamDIE, CI, resolve(VP->getType()));
|
||||
else if (GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
|
||||
// For declaration non-type template parameters (such as global values and
|
||||
// functions)
|
||||
@ -1176,11 +1176,11 @@ DwarfUnit::constructTemplateValueParameterDIE(DIE &Buffer,
|
||||
// parameter, rather than a pointer to it.
|
||||
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
|
||||
addBlock(ParamDIE, dwarf::DW_AT_location, Loc);
|
||||
} else if (VP.getTag() == dwarf::DW_TAG_GNU_template_template_param) {
|
||||
} else if (VP->getTag() == dwarf::DW_TAG_GNU_template_template_param) {
|
||||
assert(isa<MDString>(Val));
|
||||
addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
|
||||
cast<MDString>(Val)->getString());
|
||||
} else if (VP.getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
|
||||
} else if (VP->getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
|
||||
addTemplateParams(ParamDIE, cast<MDTuple>(Val));
|
||||
}
|
||||
}
|
||||
@ -1190,19 +1190,19 @@ DwarfUnit::constructTemplateValueParameterDIE(DIE &Buffer,
|
||||
DIE *DwarfUnit::getOrCreateNameSpace(DINameSpace NS) {
|
||||
// Construct the context before querying for the existence of the DIE in case
|
||||
// such construction creates the DIE.
|
||||
DIE *ContextDIE = getOrCreateContextDIE(NS.getContext());
|
||||
DIE *ContextDIE = getOrCreateContextDIE(NS->getScope());
|
||||
|
||||
if (DIE *NDie = getDIE(NS))
|
||||
return NDie;
|
||||
DIE &NDie = createAndAddDIE(dwarf::DW_TAG_namespace, *ContextDIE, NS);
|
||||
|
||||
StringRef Name = NS.getName();
|
||||
StringRef Name = NS->getName();
|
||||
if (!Name.empty())
|
||||
addString(NDie, dwarf::DW_AT_name, NS.getName());
|
||||
addString(NDie, dwarf::DW_AT_name, NS->getName());
|
||||
else
|
||||
Name = "(anonymous namespace)";
|
||||
DD->addAccelNamespace(Name, NDie);
|
||||
addGlobalName(Name, NDie, NS.getContext());
|
||||
addGlobalName(Name, NDie, NS->getScope());
|
||||
addSourceLine(NDie, NS);
|
||||
return &NDie;
|
||||
}
|
||||
|
@ -224,8 +224,8 @@ void DebugInfoFinder::processScope(DIScope Scope) {
|
||||
return;
|
||||
if (DILexicalBlock LB = dyn_cast<MDLexicalBlockBase>(Scope)) {
|
||||
processScope(LB.getContext());
|
||||
} else if (DINameSpace NS = dyn_cast<MDNamespace>(Scope)) {
|
||||
processScope(NS.getContext());
|
||||
} else if (auto *NS = dyn_cast<MDNamespace>(Scope)) {
|
||||
processScope(NS->getScope());
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,12 +235,10 @@ void DebugInfoFinder::processSubprogram(DISubprogram SP) {
|
||||
processScope(SP.getContext().resolve(TypeIdentifierMap));
|
||||
processType(SP.getType());
|
||||
for (auto *Element : SP.getTemplateParams()) {
|
||||
if (DITemplateTypeParameter TType =
|
||||
dyn_cast<MDTemplateTypeParameter>(Element)) {
|
||||
processType(TType.getType().resolve(TypeIdentifierMap));
|
||||
} else if (DITemplateValueParameter TVal =
|
||||
dyn_cast<MDTemplateValueParameter>(Element)) {
|
||||
processType(TVal.getType().resolve(TypeIdentifierMap));
|
||||
if (auto *TType = dyn_cast<MDTemplateTypeParameter>(Element)) {
|
||||
processType(TType->getType().resolve(TypeIdentifierMap));
|
||||
} else if (auto *TVal = dyn_cast<MDTemplateValueParameter>(Element)) {
|
||||
processType(TVal->getType().resolve(TypeIdentifierMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ struct BreakpointPrinter : public ModulePass {
|
||||
BreakpointPrinter(raw_ostream &out) : ModulePass(ID), Out(out) {}
|
||||
|
||||
void getContextName(DIDescriptor Context, std::string &N) {
|
||||
if (DINameSpace NS = dyn_cast<MDNamespace>(Context)) {
|
||||
if (!NS.getName().empty()) {
|
||||
getContextName(NS.getContext(), N);
|
||||
N = N + NS.getName().str() + "::";
|
||||
if (auto *NS = dyn_cast<MDNamespace>(Context)) {
|
||||
if (!NS->getName().empty()) {
|
||||
getContextName(NS->getScope(), N);
|
||||
N = N + NS->getName().str() + "::";
|
||||
}
|
||||
} else if (DIType TY = dyn_cast<MDType>(Context)) {
|
||||
if (!TY.getName().empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user