diff --git a/include/llvm/IR/IntrinsicInst.h b/include/llvm/IR/IntrinsicInst.h index 72ab46d8af9..bf0adc39347 100644 --- a/include/llvm/IR/IntrinsicInst.h +++ b/include/llvm/IR/IntrinsicInst.h @@ -82,8 +82,12 @@ namespace llvm { class DbgDeclareInst : public DbgInfoIntrinsic { public: Value *getAddress() const; - MDNode *getVariable() const { return cast(getRawVariable()); } - MDNode *getExpression() const { return cast(getRawExpression()); } + MDLocalVariable *getVariable() const { + return cast(getRawVariable()); + } + MDExpression *getExpression() const { + return cast(getRawExpression()); + } Metadata *getRawVariable() const { return cast(getArgOperand(1))->getMetadata(); @@ -111,8 +115,12 @@ namespace llvm { return cast( const_cast(getArgOperand(1)))->getZExtValue(); } - MDNode *getVariable() const { return cast(getRawVariable()); } - MDNode *getExpression() const { return cast(getRawExpression()); } + MDLocalVariable *getVariable() const { + return cast(getRawVariable()); + } + MDExpression *getExpression() const { + return cast(getRawExpression()); + } Metadata *getRawVariable() const { return cast(getArgOperand(2))->getMetadata(); diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index c01cc7c92ee..6ba0fd41730 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -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 { \ + 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; diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index f0071060276..084bfb81a97 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -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(DII.getVariable())); - visitMDExpression(*cast(DII.getExpression())); + visitMDLocalVariable(*DII.getVariable()); + visitMDExpression(*DII.getExpression()); } void DebugInfoVerifier::verifyDebugInfo() {