diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index 3eaf91d491d..73d2a7f9e37 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -174,6 +174,10 @@ public: MDNode *get() const { return const_cast(DbgNode); } operator MDNode *() const { return get(); } MDNode *operator->() const { return get(); } + MDNode &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } // An explicit operator bool so that we can do testing of DI values // easily. @@ -268,34 +272,39 @@ public: #define RETURN_FROM_RAW(VALID, UNUSED) \ do { \ - assert(this->DbgNode && "Expected non-null in accessor"); \ - auto *N = getRaw(); \ - assert(N && "Expected correct subclass in accessor"); \ + auto *N = get(); \ + assert(N && "Expected non-null in accessor"); \ return VALID; \ } while (false) #define RETURN_DESCRIPTOR_FROM_RAW(DESC, VALID) \ do { \ - assert(this->DbgNode && "Expected non-null in accessor"); \ - auto *N = getRaw(); \ - assert(N && "Expected correct subclass in accessor"); \ + auto *N = get(); \ + assert(N && "Expected non-null in accessor"); \ return DESC(dyn_cast_or_null(VALID)); \ } while (false) #define RETURN_REF_FROM_RAW(REF, VALID) \ do { \ - assert(this->DbgNode && "Expected non-null in accessor"); \ - auto *N = getRaw(); \ - assert(N && "Expected correct subclass in accessor"); \ + auto *N = get(); \ + assert(N && "Expected non-null in accessor"); \ return REF::get(VALID); \ } while (false) /// \brief This is used to represent ranges, for array bounds. class DISubrange : public DIDescriptor { - MDSubrange *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DISubrange(const MDNode *N = nullptr) : DIDescriptor(N) {} DISubrange(const MDSubrange *N) : DIDescriptor(N) {} + MDSubrange *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDSubrange *() const { return get(); } + MDSubrange *operator->() const { return get(); } + MDSubrange &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + int64_t getLo() const { RETURN_FROM_RAW(N->getLo(), 0); } int64_t getCount() const { RETURN_FROM_RAW(N->getCount(), 0); } bool Verify() const; @@ -318,12 +327,20 @@ typedef DITypedArray DIArray; /// FIXME: it seems strange that this doesn't have either a reference to the /// type/precision or a file/line pair for location info. class DIEnumerator : public DIDescriptor { - MDEnumerator *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DIEnumerator(const MDNode *N = nullptr) : DIDescriptor(N) {} DIEnumerator(const MDEnumerator *N) : DIDescriptor(N) {} + MDEnumerator *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDEnumerator *() const { return get(); } + MDEnumerator *operator->() const { return get(); } + MDEnumerator &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); } int64_t getEnumValue() const { RETURN_FROM_RAW(N->getValue(), 0); } bool Verify() const; @@ -344,13 +361,18 @@ typedef DITypedArray DITypeArray; /// DIScopes that are scopes in the strict lexical scope sense /// (DICompileUnit, DISubprogram, etc.), but not for, e.g., a DIType. class DIScope : public DIDescriptor { -protected: - MDScope *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DIScope(const MDNode *N = nullptr) : DIDescriptor(N) {} DIScope(const MDScope *N) : DIDescriptor(N) {} + MDScope *get() const { return cast_or_null(DIDescriptor::get()); } + operator MDScope *() const { return get(); } + MDScope *operator->() const { return get(); } + MDScope &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + /// \brief Get the parent scope. /// /// Gets the parent scope for this scope node or returns a default @@ -443,12 +465,18 @@ template <> DIRef::DIRef(const Metadata *V); /// FIXME: Types should be factored much better so that CV qualifiers and /// others do not require a huge and empty descriptor full of zeros. class DIType : public DIScope { - MDType *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DIType(const MDNode *N = nullptr) : DIScope(N) {} DIType(const MDType *N) : DIScope(N) {} + MDType *get() const { return cast_or_null(DIDescriptor::get()); } + operator MDType *() const { return get(); } + MDType *operator->() const { return get(); } + MDType &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + operator DITypeRef() const { assert(isType() && "constructing DITypeRef from an MDNode that is not a type"); @@ -503,12 +531,20 @@ public: /// \brief A basic type, like 'int' or 'float'. class DIBasicType : public DIType { - MDBasicType *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DIBasicType(const MDNode *N = nullptr) : DIType(N) {} DIBasicType(const MDBasicType *N) : DIType(N) {} + MDBasicType *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDBasicType *() const { return get(); } + MDBasicType *operator->() const { return get(); } + MDBasicType &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + unsigned getEncoding() const { RETURN_FROM_RAW(N->getEncoding(), 0); } bool Verify() const; @@ -519,35 +555,41 @@ public: /// Like a const qualified type, a typedef, a pointer or reference, et cetera. /// Or, a data member of a class/struct/union. class DIDerivedType : public DIType { - MDDerivedTypeBase *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DIDerivedType(const MDNode *N = nullptr) : DIType(N) {} DIDerivedType(const MDDerivedTypeBase *N) : DIType(N) {} + MDDerivedTypeBase *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDDerivedTypeBase *() const { return get(); } + MDDerivedTypeBase *operator->() const { return get(); } + MDDerivedTypeBase &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + DITypeRef getTypeDerivedFrom() const { RETURN_REF_FROM_RAW(DITypeRef, N->getBaseType()); } /// \brief Return property node, if this ivar is associated with one. MDNode *getObjCProperty() const { - if (auto *N = dyn_cast_or_null(get())) + if (auto *N = dyn_cast(get())) return dyn_cast_or_null(N->getExtraData()); return nullptr; } DITypeRef getClassType() const { assert(getTag() == dwarf::DW_TAG_ptr_to_member_type); - if (auto *N = dyn_cast_or_null(get())) + if (auto *N = dyn_cast(get())) return DITypeRef::get(N->getExtraData()); return DITypeRef::get(nullptr); } Constant *getConstant() const { assert((getTag() == dwarf::DW_TAG_member) && isStaticMember()); - if (auto *N = dyn_cast_or_null(get())) + if (auto *N = dyn_cast(get())) if (auto *C = dyn_cast_or_null(N->getExtraData())) return C->getValue(); @@ -572,14 +614,20 @@ class DICompositeType : public DIDerivedType { /// \brief Set the array of member DITypes. void setArraysHelper(MDNode *Elements, MDNode *TParams); - MDCompositeTypeBase *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DICompositeType(const MDNode *N = nullptr) : DIDerivedType(N) {} DICompositeType(const MDCompositeTypeBase *N) : DIDerivedType(N) {} + MDCompositeTypeBase *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDCompositeTypeBase *() const { return get(); } + MDCompositeTypeBase *operator->() const { return get(); } + MDCompositeTypeBase &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + DIArray getElements() const { assert(!isSubroutineType() && "no elements for DISubroutineType"); RETURN_DESCRIPTOR_FROM_RAW(DIArray, N->getElements()); @@ -617,14 +665,20 @@ public: }; class DISubroutineType : public DICompositeType { - MDSubroutineType *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DISubroutineType(const MDNode *N = nullptr) : DICompositeType(N) {} DISubroutineType(const MDSubroutineType *N) : DICompositeType(N) {} + MDSubroutineType *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDSubroutineType *() const { return get(); } + MDSubroutineType *operator->() const { return get(); } + MDSubroutineType &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + DITypedArray getTypeArray() const { RETURN_DESCRIPTOR_FROM_RAW(DITypedArray, N->getTypeArray()); } @@ -632,12 +686,18 @@ public: /// \brief This is a wrapper for a file. class DIFile : public DIScope { - MDFile *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DIFile(const MDNode *N = nullptr) : DIScope(N) {} DIFile(const MDFile *N) : DIScope(N) {} + MDFile *get() const { return cast_or_null(DIDescriptor::get()); } + operator MDFile *() const { return get(); } + MDFile *operator->() const { return get(); } + MDFile &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + /// \brief Retrieve the MDNode for the directory/file pair. MDNode *getFileNode() const { return get(); } bool Verify() const; @@ -645,14 +705,20 @@ public: /// \brief A wrapper for a compile unit. class DICompileUnit : public DIScope { - MDCompileUnit *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DICompileUnit(const MDNode *N = nullptr) : DIScope(N) {} DICompileUnit(const MDCompileUnit *N) : DIScope(N) {} + MDCompileUnit *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDCompileUnit *() const { return get(); } + MDCompileUnit *operator->() const { return get(); } + MDCompileUnit &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + dwarf::SourceLanguage getLanguage() const { RETURN_FROM_RAW(static_cast(N->getSourceLanguage()), static_cast(0)); @@ -693,12 +759,20 @@ public: /// \brief This is a wrapper for a subprogram (e.g. a function). class DISubprogram : public DIScope { - MDSubprogram *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DISubprogram(const MDNode *N = nullptr) : DIScope(N) {} DISubprogram(const MDSubprogram *N) : DIScope(N) {} + MDSubprogram *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDSubprogram *() const { return get(); } + MDSubprogram *operator->() const { return get(); } + MDSubprogram &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); } StringRef getDisplayName() const { RETURN_FROM_RAW(N->getDisplayName(), ""); } StringRef getLinkageName() const { RETURN_FROM_RAW(N->getLinkageName(), ""); } @@ -737,7 +811,7 @@ public: Function *getFunction() const; void replaceFunction(Function *F) { - if (auto *N = getRaw()) + if (auto *N = get()) N->replaceFunction(F); } DIArray getTemplateParams() const { @@ -788,24 +862,30 @@ public: /// \brief This is a wrapper for a lexical block. class DILexicalBlock : public DIScope { - MDLexicalBlockBase *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DILexicalBlock(const MDNode *N = nullptr) : DIScope(N) {} DILexicalBlock(const MDLexicalBlock *N) : DIScope(N) {} + MDLexicalBlockBase *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDLexicalBlockBase *() const { return get(); } + MDLexicalBlockBase *operator->() const { return get(); } + MDLexicalBlockBase &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + DIScope getContext() const { RETURN_DESCRIPTOR_FROM_RAW(DIScope, N->getScope()); } unsigned getLineNumber() const { - if (auto *N = dyn_cast_or_null(get())) + if (auto *N = dyn_cast(get())) return N->getLine(); return 0; } unsigned getColumnNumber() const { - if (auto *N = dyn_cast_or_null(get())) + if (auto *N = dyn_cast(get())) return N->getColumn(); return 0; } @@ -814,14 +894,20 @@ public: /// \brief This is a wrapper for a lexical block with a filename change. class DILexicalBlockFile : public DIScope { - MDLexicalBlockFile *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DILexicalBlockFile(const MDNode *N = nullptr) : DIScope(N) {} DILexicalBlockFile(const MDLexicalBlockFile *N) : DIScope(N) {} + MDLexicalBlockFile *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDLexicalBlockFile *() const { return get(); } + MDLexicalBlockFile *operator->() const { return get(); } + MDLexicalBlockFile &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + DIScope getContext() const { // FIXME: This logic is horrible. getScope() returns a DILexicalBlock, but // then we check if it's a subprogram? WHAT?!? @@ -842,12 +928,20 @@ public: /// \brief A wrapper for a C++ style name space. class DINameSpace : public DIScope { - MDNamespace *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DINameSpace(const MDNode *N = nullptr) : DIScope(N) {} DINameSpace(const MDNamespace *N) : DIScope(N) {} + MDNamespace *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDNamespace *() const { return get(); } + MDNamespace *operator->() const { return get(); } + MDNamespace &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); } unsigned getLineNumber() const { RETURN_FROM_RAW(N->getLine(), 0); } DIScope getContext() const { @@ -858,15 +952,21 @@ public: /// \brief This is a wrapper for template type parameter. class DITemplateTypeParameter : public DIDescriptor { - MDTemplateTypeParameter *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DITemplateTypeParameter(const MDNode *N = nullptr) : DIDescriptor(N) {} DITemplateTypeParameter(const MDTemplateTypeParameter *N) : DIDescriptor(N) {} + MDTemplateTypeParameter *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDTemplateTypeParameter *() const { return get(); } + MDTemplateTypeParameter *operator->() const { return get(); } + MDTemplateTypeParameter &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); } DITypeRef getType() const { RETURN_REF_FROM_RAW(DITypeRef, N->getType()); } @@ -875,16 +975,22 @@ public: /// \brief This is a wrapper for template value parameter. class DITemplateValueParameter : public DIDescriptor { - MDTemplateValueParameter *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DITemplateValueParameter(const MDNode *N = nullptr) : DIDescriptor(N) {} DITemplateValueParameter(const MDTemplateValueParameter *N) : DIDescriptor(N) {} + MDTemplateValueParameter *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDTemplateValueParameter *() const { return get(); } + MDTemplateValueParameter *operator->() const { return get(); } + MDTemplateValueParameter &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); } DITypeRef getType() const { RETURN_REF_FROM_RAW(DITypeRef, N->getType()); } Metadata *getValue() const { RETURN_FROM_RAW(N->getValue(), nullptr); } @@ -893,16 +999,22 @@ public: /// \brief This is a wrapper for a global variable. class DIGlobalVariable : public DIDescriptor { - MDGlobalVariable *getRaw() const { - return dyn_cast_or_null(get()); - } - DIFile getFile() const { RETURN_DESCRIPTOR_FROM_RAW(DIFile, N->getFile()); } public: explicit DIGlobalVariable(const MDNode *N = nullptr) : DIDescriptor(N) {} DIGlobalVariable(const MDGlobalVariable *N) : DIDescriptor(N) {} + MDGlobalVariable *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDGlobalVariable *() const { return get(); } + MDGlobalVariable *operator->() const { return get(); } + MDGlobalVariable &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); } StringRef getDisplayName() const { RETURN_FROM_RAW(N->getDisplayName(), ""); } StringRef getLinkageName() const { RETURN_FROM_RAW(N->getLinkageName(), ""); } @@ -919,7 +1031,7 @@ public: GlobalVariable *getGlobal() const; Constant *getConstant() const { - if (auto *N = getRaw()) + if (auto *N = get()) if (auto *C = dyn_cast_or_null(N->getVariable())) return C->getValue(); return nullptr; @@ -934,16 +1046,22 @@ public: /// \brief This is a wrapper for a variable (e.g. parameter, local, global etc). class DIVariable : public DIDescriptor { - MDLocalVariable *getRaw() const { - return dyn_cast_or_null(get()); - } - unsigned getFlags() const { RETURN_FROM_RAW(N->getFlags(), 0); } public: explicit DIVariable(const MDNode *N = nullptr) : DIDescriptor(N) {} DIVariable(const MDLocalVariable *N) : DIDescriptor(N) {} + MDLocalVariable *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDLocalVariable *() const { return get(); } + MDLocalVariable *operator->() const { return get(); } + MDLocalVariable &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); } unsigned getLineNumber() const { RETURN_FROM_RAW(N->getLine(), 0); } unsigned getArgNumber() const { RETURN_FROM_RAW(N->getArg(), 0); } @@ -1001,6 +1119,10 @@ public: } operator MDExpression *() const { return get(); } MDExpression *operator->() const { return get(); } + MDExpression &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } // Don't call this. Call isValid() directly. bool Verify() const = delete; @@ -1083,11 +1205,19 @@ public: /// /// This object is not associated with any DWARF tag. class DILocation : public DIDescriptor { - MDLocation *getRaw() const { return dyn_cast_or_null(get()); } - public: explicit DILocation(const MDNode *N) : DIDescriptor(N) {} + MDLocation *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDLocation *() const { return get(); } + MDLocation *operator->() const { return get(); } + MDLocation &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + unsigned getLineNumber() const { RETURN_FROM_RAW(N->getLine(), 0); } unsigned getColumnNumber() const { RETURN_FROM_RAW(N->getColumn(), 0); } DIScope getScope() const { @@ -1130,14 +1260,20 @@ public: }; class DIObjCProperty : public DIDescriptor { - MDObjCProperty *getRaw() const { - return dyn_cast_or_null(get()); - } - public: explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) {} DIObjCProperty(const MDObjCProperty *N) : DIDescriptor(N) {} + MDObjCProperty *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDObjCProperty *() const { return get(); } + MDObjCProperty *operator->() const { return get(); } + MDObjCProperty &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + StringRef getObjCPropertyName() const { RETURN_FROM_RAW(N->getName(), ""); } DIFile getFile() const { RETURN_DESCRIPTOR_FROM_RAW(DIFile, N->getFile()); } unsigned getLineNumber() const { RETURN_FROM_RAW(N->getLine(), 0); } @@ -1179,15 +1315,21 @@ public: /// \brief An imported module (C++ using directive or similar). class DIImportedEntity : public DIDescriptor { - MDImportedEntity *getRaw() const { - return dyn_cast_or_null(get()); - } - public: DIImportedEntity() = default; explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) {} DIImportedEntity(const MDImportedEntity *N) : DIDescriptor(N) {} + MDImportedEntity *get() const { + return cast_or_null(DIDescriptor::get()); + } + operator MDImportedEntity *() const { return get(); } + MDImportedEntity *operator->() const { return get(); } + MDImportedEntity &operator*() const { + assert(get() && "Expected valid pointer"); + return *get(); + } + DIScope getContext() const { RETURN_DESCRIPTOR_FROM_RAW(DIScope, N->getScope()); } diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 28244d67429..ad0b98e90c0 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -260,7 +260,7 @@ static bool isDescriptorRef(const Metadata *MD) { #endif bool DIType::Verify() const { - auto *N = getRaw(); + auto *N = dyn_cast_or_null(DbgNode); if (!N) return false; if (!isScopeRef(N->getScope())) @@ -294,10 +294,12 @@ bool DIType::Verify() const { return false; } -bool DIBasicType::Verify() const { return getRaw(); } +bool DIBasicType::Verify() const { + return dyn_cast_or_null(DbgNode); +} bool DIDerivedType::Verify() const { - auto *N = getRaw(); + auto *N = dyn_cast_or_null(DbgNode); if (!N) return false; if (getTag() == dwarf::DW_TAG_ptr_to_member_type) { @@ -311,13 +313,13 @@ bool DIDerivedType::Verify() const { } bool DICompositeType::Verify() const { - auto *N = getRaw(); + auto *N = dyn_cast_or_null(DbgNode); return N && isTypeRef(N->getBaseType()) && isTypeRef(N->getVTableHolder()) && !(isLValueReference() && isRValueReference()); } bool DISubprogram::Verify() const { - auto *N = getRaw(); + auto *N = dyn_cast_or_null(DbgNode); if (!N) return false; @@ -370,7 +372,7 @@ bool DISubprogram::Verify() const { } bool DIGlobalVariable::Verify() const { - auto *N = getRaw(); + auto *N = dyn_cast_or_null(DbgNode); if (!N) return false; @@ -390,7 +392,7 @@ bool DIGlobalVariable::Verify() const { } bool DIVariable::Verify() const { - auto *N = getRaw(); + auto *N = dyn_cast_or_null(DbgNode); if (!N) return false; @@ -402,19 +404,37 @@ bool DIVariable::Verify() const { return isTypeRef(N->getType()); } -bool DILocation::Verify() const { return getRaw(); } -bool DINameSpace::Verify() const { return getRaw(); } -bool DIFile::Verify() const { return getRaw(); } -bool DIEnumerator::Verify() const { return getRaw(); } -bool DISubrange::Verify() const { return getRaw(); } -bool DILexicalBlock::Verify() const { return getRaw(); } -bool DILexicalBlockFile::Verify() const { return getRaw(); } -bool DITemplateTypeParameter::Verify() const { return getRaw(); } -bool DITemplateValueParameter::Verify() const { return getRaw(); } -bool DIImportedEntity::Verify() const { return getRaw(); } +bool DILocation::Verify() const { + return dyn_cast_or_null(DbgNode); +} +bool DINameSpace::Verify() const { + return dyn_cast_or_null(DbgNode); +} +bool DIFile::Verify() const { return dyn_cast_or_null(DbgNode); } +bool DIEnumerator::Verify() const { + return dyn_cast_or_null(DbgNode); +} +bool DISubrange::Verify() const { + return dyn_cast_or_null(DbgNode); +} +bool DILexicalBlock::Verify() const { + return dyn_cast_or_null(DbgNode); +} +bool DILexicalBlockFile::Verify() const { + return dyn_cast_or_null(DbgNode); +} +bool DITemplateTypeParameter::Verify() const { + return dyn_cast_or_null(DbgNode); +} +bool DITemplateValueParameter::Verify() const { + return dyn_cast_or_null(DbgNode); +} +bool DIImportedEntity::Verify() const { + return dyn_cast_or_null(DbgNode); +} void DICompositeType::setArraysHelper(MDNode *Elements, MDNode *TParams) { - TypedTrackingMDRef N(getRaw()); + TypedTrackingMDRef N(get()); if (Elements) N->replaceElements(cast(Elements)); if (TParams) @@ -432,7 +452,7 @@ DIScopeRef DIScope::getRef() const { } void DICompositeType::setContainingType(DICompositeType ContainingType) { - TypedTrackingMDRef N(getRaw()); + TypedTrackingMDRef N(get()); N->replaceVTableHolder(ContainingType.getRef()); DbgNode = N; } @@ -447,7 +467,7 @@ bool DIVariable::isInlinedFnArgument(const Function *CurFn) { } Function *DISubprogram::getFunction() const { - if (auto *N = getRaw()) + if (auto *N = get()) if (auto *C = dyn_cast_or_null(N->getFunction())) return dyn_cast(C->getValue()); return nullptr; @@ -504,26 +524,25 @@ StringRef DIScope::getName() const { } StringRef DIScope::getFilename() const { - if (auto *N = getRaw()) + if (auto *N = get()) return ::getStringField(dyn_cast_or_null(N->getFile()), 0); return ""; } StringRef DIScope::getDirectory() const { - if (auto *N = getRaw()) + if (auto *N = get()) return ::getStringField(dyn_cast_or_null(N->getFile()), 1); return ""; } void DICompileUnit::replaceSubprograms(DIArray Subprograms) { assert(Verify() && "Expected compile unit"); - getRaw()->replaceSubprograms(cast_or_null(Subprograms.get())); + get()->replaceSubprograms(cast_or_null(Subprograms.get())); } void DICompileUnit::replaceGlobalVariables(DIArray GlobalVariables) { assert(Verify() && "Expected compile unit"); - getRaw()->replaceGlobalVariables( - cast_or_null(GlobalVariables.get())); + get()->replaceGlobalVariables(cast_or_null(GlobalVariables.get())); } DILocation DILocation::copyWithNewScope(LLVMContext &Ctx, diff --git a/test/CodeGen/X86/2012-11-30-misched-dbg.ll b/test/CodeGen/X86/2012-11-30-misched-dbg.ll index 1147e5c0aaa..1e265eefb15 100644 --- a/test/CodeGen/X86/2012-11-30-misched-dbg.ll +++ b/test/CodeGen/X86/2012-11-30-misched-dbg.ll @@ -77,7 +77,7 @@ declare i32 @__sprintf_chk(i8*, i32, i64, i8*, ...) !10 = distinct !MDLexicalBlock(line: 434, column: 0, file: !14, scope: !11) !11 = distinct !MDLexicalBlock(line: 250, column: 0, file: !14, scope: !12) !12 = distinct !MDLexicalBlock(line: 249, column: 0, file: !14, scope: !13) -!13 = distinct !MDLexicalBlock(line: 221, column: 0, file: !14, scope: !2) +!13 = distinct !MDLexicalBlock(line: 221, column: 0, file: !14, scope: !21) !14 = !MDFile(filename: "MultiSource/Benchmarks/MiBench/consumer-typeset/z19.c", directory: "MultiSource/Benchmarks/MiBench/consumer-typeset") !15 = !MDCompositeType(tag: DW_TAG_array_type, size: 160, align: 8, baseType: !16, elements: !17) !16 = !MDBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) diff --git a/test/Transforms/Inline/debug-invoke.ll b/test/Transforms/Inline/debug-invoke.ll index 0c5dfa4c7fd..c35300c7671 100644 --- a/test/Transforms/Inline/debug-invoke.ll +++ b/test/Transforms/Inline/debug-invoke.ll @@ -4,9 +4,9 @@ ; CHECK: invoke void @test() ; CHECK-NEXT: to label {{.*}} unwind label {{.*}}, !dbg [[INL_LOC:!.*]] -; CHECK: [[EMPTY:.*]] = !{} -; CHECK: [[INL_LOC]] = !MDLocation(line: 1, scope: [[EMPTY]], inlinedAt: [[INL_AT:.*]]) -; CHECK: [[INL_AT]] = distinct !MDLocation(line: 2, scope: [[EMPTY]]) +; CHECK: [[SP:.*]] = !MDSubprogram( +; CHECK: [[INL_LOC]] = !MDLocation(line: 1, scope: [[SP]], inlinedAt: [[INL_AT:.*]]) +; CHECK: [[INL_AT]] = distinct !MDLocation(line: 2, scope: [[SP]]) declare void @test() declare i32 @__gxx_personality_v0(...) @@ -32,6 +32,6 @@ lpad: !llvm.module.flags = !{!1} !1 = !{i32 2, !"Debug Info Version", i32 3} -!2 = !{} +!2 = !MDSubprogram() !3 = !MDLocation(line: 1, scope: !2) !4 = !MDLocation(line: 2, scope: !2)