forked from OSchip/llvm-project
DbgIntrinsicInst: Downcast to specialized MDNodes in accessors
Change accessors to downcast to `MDLocalVariable` and `MDExpression`, now that we have -verify checks in place to confirm that it's safe. llvm-svn: 232299
This commit is contained in:
parent
c3f2d3faa3
commit
25cf28fd7b
|
@ -82,8 +82,12 @@ namespace llvm {
|
|||
class DbgDeclareInst : public DbgInfoIntrinsic {
|
||||
public:
|
||||
Value *getAddress() const;
|
||||
MDNode *getVariable() const { return cast<MDNode>(getRawVariable()); }
|
||||
MDNode *getExpression() const { return cast<MDNode>(getRawExpression()); }
|
||||
MDLocalVariable *getVariable() const {
|
||||
return cast<MDLocalVariable>(getRawVariable());
|
||||
}
|
||||
MDExpression *getExpression() const {
|
||||
return cast<MDExpression>(getRawExpression());
|
||||
}
|
||||
|
||||
Metadata *getRawVariable() const {
|
||||
return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
|
||||
|
@ -111,8 +115,12 @@ namespace llvm {
|
|||
return cast<ConstantInt>(
|
||||
const_cast<Value*>(getArgOperand(1)))->getZExtValue();
|
||||
}
|
||||
MDNode *getVariable() const { return cast<MDNode>(getRawVariable()); }
|
||||
MDNode *getExpression() const { return cast<MDNode>(getRawExpression()); }
|
||||
MDLocalVariable *getVariable() const {
|
||||
return cast<MDLocalVariable>(getRawVariable());
|
||||
}
|
||||
MDExpression *getExpression() const {
|
||||
return cast<MDExpression>(getRawExpression());
|
||||
}
|
||||
|
||||
Metadata *getRawVariable() const {
|
||||
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
|
||||
|
|
|
@ -128,6 +128,16 @@ public:
|
|||
#define HANDLE_METADATA(CLASS) class CLASS;
|
||||
#include "llvm/IR/Metadata.def"
|
||||
|
||||
// Provide specializations of isa so that we don't need definitions of
|
||||
// subclasses to see if the metadata is a subclass.
|
||||
#define HANDLE_METADATA_LEAF(CLASS) \
|
||||
template <> struct isa_impl<CLASS, Metadata> { \
|
||||
static inline bool doit(const Metadata &MD) { \
|
||||
return MD.getMetadataID() == Metadata::CLASS##Kind; \
|
||||
} \
|
||||
};
|
||||
#include "llvm/IR/Metadata.def"
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const Metadata &MD) {
|
||||
MD.print(OS);
|
||||
return OS;
|
||||
|
|
|
@ -3032,8 +3032,8 @@ void Verifier::visitDbgIntrinsic(StringRef Kind, DbgIntrinsicTy &DII) {
|
|||
DII.getRawExpression());
|
||||
|
||||
// Don't call visitMDNode(), since that will recurse through operands.
|
||||
visitMDLocalVariable(*cast<MDLocalVariable>(DII.getVariable()));
|
||||
visitMDExpression(*cast<MDExpression>(DII.getExpression()));
|
||||
visitMDLocalVariable(*DII.getVariable());
|
||||
visitMDExpression(*DII.getExpression());
|
||||
}
|
||||
|
||||
void DebugInfoVerifier::verifyDebugInfo() {
|
||||
|
|
Loading…
Reference in New Issue