<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 23, 2015 at 2:54 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dexonsmith<br>
Date: Mon Mar 23 16:54:07 2015<br>
New Revision: 233030<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=233030&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=233030&view=rev</a><br>
Log:<br>
DebugInfo: Overload get() in DIDescriptor subclasses<br>
<br>
Continue to simplify the `DIDescriptor` subclasses, so that they behave<br>
more like raw pointers. Remove `getRaw()`, replace it with an<br>
overloaded `get()`, and overload the arrow and cast operators. Two<br>
testcases started to crash on the arrow operators with this change<br>
because of `scope:` references that weren't real scopes. I fixed them.<br>
Soon I'll add verifier checks for them too.<br>
<br>
This also adds explicit dereference operators. Previously, the builtin<br>
dereference against `operator MDNode *()` would have worked, but now the<br>
builtins are ambiguous.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/IR/DebugInfo.h<br>
llvm/trunk/lib/IR/DebugInfo.cpp<br>
llvm/trunk/test/CodeGen/X86/2012-11-30-misched-dbg.ll<br>
llvm/trunk/test/Transforms/Inline/debug-invoke.ll<br>
<br>
Modified: llvm/trunk/include/llvm/IR/DebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=233030&r1=233029&r2=233030&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=233030&r1=233029&r2=233030&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)<br>
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Mar 23 16:54:07 2015<br>
@@ -174,6 +174,10 @@ public:<br>
MDNode *get() const { return const_cast<MDNode *>(DbgNode); }<br>
operator MDNode *() const { return get(); }<br>
MDNode *operator->() const { return get(); }<br>
+ MDNode &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
<br>
// An explicit operator bool so that we can do testing of DI values<br>
// easily.<br>
@@ -268,34 +272,39 @@ public:<br>
<br>
#define RETURN_FROM_RAW(VALID, UNUSED) \<br>
do { \<br>
- assert(this->DbgNode && "Expected non-null in accessor"); \<br>
- auto *N = getRaw(); \<br>
- assert(N && "Expected correct subclass in accessor"); \<br>
+ auto *N = get(); \<br>
+ assert(N && "Expected non-null in accessor"); \<br>
return VALID; \<br>
} while (false)<br>
#define RETURN_DESCRIPTOR_FROM_RAW(DESC, VALID) \<br>
do { \<br>
- assert(this->DbgNode && "Expected non-null in accessor"); \<br>
- auto *N = getRaw(); \<br>
- assert(N && "Expected correct subclass in accessor"); \<br>
+ auto *N = get(); \<br>
+ assert(N && "Expected non-null in accessor"); \<br>
return DESC(dyn_cast_or_null<MDNode>(VALID)); \<br>
} while (false)<br>
#define RETURN_REF_FROM_RAW(REF, VALID) \<br>
do { \<br>
- assert(this->DbgNode && "Expected non-null in accessor"); \<br>
- auto *N = getRaw(); \<br>
- assert(N && "Expected correct subclass in accessor"); \<br>
+ auto *N = get(); \<br>
+ assert(N && "Expected non-null in accessor"); \<br>
return REF::get(VALID); \<br>
} while (false)<br>
<br>
/// \brief This is used to represent ranges, for array bounds.<br>
class DISubrange : public DIDescriptor {<br>
- MDSubrange *getRaw() const { return dyn_cast_or_null<MDSubrange>(get()); }<br>
-<br>
public:<br>
explicit DISubrange(const MDNode *N = nullptr) : DIDescriptor(N) {}<br>
DISubrange(const MDSubrange *N) : DIDescriptor(N) {}<br>
<br>
+ MDSubrange *get() const {<br>
+ return cast_or_null<MDSubrange>(DIDescriptor::get());<br>
+ }<br>
+ operator MDSubrange *() const { return get(); }<br>
+ MDSubrange *operator->() const { return get(); }<br>
+ MDSubrange &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
int64_t getLo() const { RETURN_FROM_RAW(N->getLo(), 0); }<br>
int64_t getCount() const { RETURN_FROM_RAW(N->getCount(), 0); }<br>
bool Verify() const;<br>
@@ -318,12 +327,20 @@ typedef DITypedArray<DIDescriptor> DIArr<br>
/// FIXME: it seems strange that this doesn't have either a reference to the<br>
/// type/precision or a file/line pair for location info.<br>
class DIEnumerator : public DIDescriptor {<br>
- MDEnumerator *getRaw() const { return dyn_cast_or_null<MDEnumerator>(get()); }<br>
-<br>
public:<br>
explicit DIEnumerator(const MDNode *N = nullptr) : DIDescriptor(N) {}<br>
DIEnumerator(const MDEnumerator *N) : DIDescriptor(N) {}<br>
<br>
+ MDEnumerator *get() const {<br>
+ return cast_or_null<MDEnumerator>(DIDescriptor::get());<br>
+ }<br>
+ operator MDEnumerator *() const { return get(); }<br>
+ MDEnumerator *operator->() const { return get(); }<br>
+ MDEnumerator &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); }<br>
int64_t getEnumValue() const { RETURN_FROM_RAW(N->getValue(), 0); }<br>
bool Verify() const;<br>
@@ -344,13 +361,18 @@ typedef DITypedArray<DITypeRef> DITypeAr<br>
/// DIScopes that are scopes in the strict lexical scope sense<br>
/// (DICompileUnit, DISubprogram, etc.), but not for, e.g., a DIType.<br>
class DIScope : public DIDescriptor {<br>
-protected:<br>
- MDScope *getRaw() const { return dyn_cast_or_null<MDScope>(get()); }<br>
-<br>
public:<br>
explicit DIScope(const MDNode *N = nullptr) : DIDescriptor(N) {}<br>
DIScope(const MDScope *N) : DIDescriptor(N) {}<br>
<br>
+ MDScope *get() const { return cast_or_null<MDScope>(DIDescriptor::get()); }<br>
+ operator MDScope *() const { return get(); }<br>
+ MDScope *operator->() const { return get(); }<br>
+ MDScope &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
/// \brief Get the parent scope.<br>
///<br>
/// Gets the parent scope for this scope node or returns a default<br>
@@ -443,12 +465,18 @@ template <> DIRef<DIType>::DIRef(const M<br>
/// FIXME: Types should be factored much better so that CV qualifiers and<br>
/// others do not require a huge and empty descriptor full of zeros.<br>
class DIType : public DIScope {<br>
- MDType *getRaw() const { return dyn_cast_or_null<MDType>(get()); }<br>
-<br>
public:<br>
explicit DIType(const MDNode *N = nullptr) : DIScope(N) {}<br>
DIType(const MDType *N) : DIScope(N) {}<br>
<br>
+ MDType *get() const { return cast_or_null<MDType>(DIDescriptor::get()); }<br>
+ operator MDType *() const { return get(); }<br>
+ MDType *operator->() const { return get(); }<br>
+ MDType &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
operator DITypeRef() const {<br>
assert(isType() &&<br>
"constructing DITypeRef from an MDNode that is not a type");<br>
@@ -503,12 +531,20 @@ public:<br>
<br>
/// \brief A basic type, like 'int' or 'float'.<br>
class DIBasicType : public DIType {<br>
- MDBasicType *getRaw() const { return dyn_cast_or_null<MDBasicType>(get()); }<br>
-<br>
public:<br>
explicit DIBasicType(const MDNode *N = nullptr) : DIType(N) {}<br>
DIBasicType(const MDBasicType *N) : DIType(N) {}<br>
<br>
+ MDBasicType *get() const {<br>
+ return cast_or_null<MDBasicType>(DIDescriptor::get());<br>
+ }<br>
+ operator MDBasicType *() const { return get(); }<br>
+ MDBasicType *operator->() const { return get(); }<br>
+ MDBasicType &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
unsigned getEncoding() const { RETURN_FROM_RAW(N->getEncoding(), 0); }<br>
<br>
bool Verify() const;<br>
@@ -519,35 +555,41 @@ public:<br>
/// Like a const qualified type, a typedef, a pointer or reference, et cetera.<br>
/// Or, a data member of a class/struct/union.<br>
class DIDerivedType : public DIType {<br>
- MDDerivedTypeBase *getRaw() const {<br>
- return dyn_cast_or_null<MDDerivedTypeBase>(get());<br>
- }<br>
-<br>
public:<br>
explicit DIDerivedType(const MDNode *N = nullptr) : DIType(N) {}<br>
DIDerivedType(const MDDerivedTypeBase *N) : DIType(N) {}<br>
<br>
+ MDDerivedTypeBase *get() const {<br>
+ return cast_or_null<MDDerivedTypeBase>(DIDescriptor::get());<br>
+ }<br>
+ operator MDDerivedTypeBase *() const { return get(); }<br>
+ MDDerivedTypeBase *operator->() const { return get(); }<br>
+ MDDerivedTypeBase &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
DITypeRef getTypeDerivedFrom() const {<br>
RETURN_REF_FROM_RAW(DITypeRef, N->getBaseType());<br>
}<br>
<br>
/// \brief Return property node, if this ivar is associated with one.<br>
MDNode *getObjCProperty() const {<br>
- if (auto *N = dyn_cast_or_null<MDDerivedType>(get()))<br>
+ if (auto *N = dyn_cast<MDDerivedType>(get()))<br>
return dyn_cast_or_null<MDNode>(N->getExtraData());<br>
return nullptr;<br>
}<br>
<br>
DITypeRef getClassType() const {<br>
assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);<br>
- if (auto *N = dyn_cast_or_null<MDDerivedType>(get()))<br>
+ if (auto *N = dyn_cast<MDDerivedType>(get()))<br>
return DITypeRef::get(N->getExtraData());<br>
return DITypeRef::get(nullptr);<br>
}<br>
<br>
Constant *getConstant() const {<br>
assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());<br>
- if (auto *N = dyn_cast_or_null<MDDerivedType>(get()))<br>
+ if (auto *N = dyn_cast<MDDerivedType>(get()))<br>
if (auto *C = dyn_cast_or_null<ConstantAsMetadata>(N->getExtraData()))<br>
return C->getValue();<br>
<br>
@@ -572,14 +614,20 @@ class DICompositeType : public DIDerived<br>
/// \brief Set the array of member DITypes.<br>
void setArraysHelper(MDNode *Elements, MDNode *TParams);<br>
<br>
- MDCompositeTypeBase *getRaw() const {<br>
- return dyn_cast_or_null<MDCompositeTypeBase>(get());<br>
- }<br>
-<br>
public:<br>
explicit DICompositeType(const MDNode *N = nullptr) : DIDerivedType(N) {}<br>
DICompositeType(const MDCompositeTypeBase *N) : DIDerivedType(N) {}<br>
<br>
+ MDCompositeTypeBase *get() const {<br>
+ return cast_or_null<MDCompositeTypeBase>(DIDescriptor::get());<br>
+ }<br>
+ operator MDCompositeTypeBase *() const { return get(); }<br>
+ MDCompositeTypeBase *operator->() const { return get(); }<br>
+ MDCompositeTypeBase &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
DIArray getElements() const {<br>
assert(!isSubroutineType() && "no elements for DISubroutineType");<br>
RETURN_DESCRIPTOR_FROM_RAW(DIArray, N->getElements());<br>
@@ -617,14 +665,20 @@ public:<br>
};<br>
<br>
class DISubroutineType : public DICompositeType {<br>
- MDSubroutineType *getRaw() const {<br>
- return dyn_cast_or_null<MDSubroutineType>(get());<br>
- }<br>
-<br>
public:<br>
explicit DISubroutineType(const MDNode *N = nullptr) : DICompositeType(N) {}<br>
DISubroutineType(const MDSubroutineType *N) : DICompositeType(N) {}<br>
<br>
+ MDSubroutineType *get() const {<br>
+ return cast_or_null<MDSubroutineType>(DIDescriptor::get());<br>
+ }<br>
+ operator MDSubroutineType *() const { return get(); }<br>
+ MDSubroutineType *operator->() const { return get(); }<br>
+ MDSubroutineType &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
DITypedArray<DITypeRef> getTypeArray() const {<br>
RETURN_DESCRIPTOR_FROM_RAW(DITypedArray<DITypeRef>, N->getTypeArray());<br>
}<br>
@@ -632,12 +686,18 @@ public:<br>
<br>
/// \brief This is a wrapper for a file.<br>
class DIFile : public DIScope {<br>
- MDFile *getRaw() const { return dyn_cast_or_null<MDFile>(get()); }<br>
-<br>
public:<br>
explicit DIFile(const MDNode *N = nullptr) : DIScope(N) {}<br>
DIFile(const MDFile *N) : DIScope(N) {}<br>
<br>
+ MDFile *get() const { return cast_or_null<MDFile>(DIDescriptor::get()); }<br>
+ operator MDFile *() const { return get(); }<br>
+ MDFile *operator->() const { return get(); }<br>
+ MDFile &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
/// \brief Retrieve the MDNode for the directory/file pair.<br>
MDNode *getFileNode() const { return get(); }<br>
bool Verify() const;<br>
@@ -645,14 +705,20 @@ public:<br>
<br>
/// \brief A wrapper for a compile unit.<br>
class DICompileUnit : public DIScope {<br>
- MDCompileUnit *getRaw() const {<br>
- return dyn_cast_or_null<MDCompileUnit>(get());<br>
- }<br>
-<br>
public:<br>
explicit DICompileUnit(const MDNode *N = nullptr) : DIScope(N) {}<br>
DICompileUnit(const MDCompileUnit *N) : DIScope(N) {}<br>
<br>
+ MDCompileUnit *get() const {<br>
+ return cast_or_null<MDCompileUnit>(DIDescriptor::get());<br>
+ }<br>
+ operator MDCompileUnit *() const { return get(); }<br>
+ MDCompileUnit *operator->() const { return get(); }<br>
+ MDCompileUnit &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
dwarf::SourceLanguage getLanguage() const {<br>
RETURN_FROM_RAW(static_cast<dwarf::SourceLanguage>(N->getSourceLanguage()),<br>
static_cast<dwarf::SourceLanguage>(0));<br>
@@ -693,12 +759,20 @@ public:<br>
<br>
/// \brief This is a wrapper for a subprogram (e.g. a function).<br>
class DISubprogram : public DIScope {<br>
- MDSubprogram *getRaw() const { return dyn_cast_or_null<MDSubprogram>(get()); }<br>
-<br>
public:<br>
explicit DISubprogram(const MDNode *N = nullptr) : DIScope(N) {}<br>
DISubprogram(const MDSubprogram *N) : DIScope(N) {}<br>
<br>
+ MDSubprogram *get() const {<br>
+ return cast_or_null<MDSubprogram>(DIDescriptor::get());<br>
+ }<br>
+ operator MDSubprogram *() const { return get(); }<br>
+ MDSubprogram *operator->() const { return get(); }<br>
+ MDSubprogram &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); }<br>
StringRef getDisplayName() const { RETURN_FROM_RAW(N->getDisplayName(), ""); }<br>
StringRef getLinkageName() const { RETURN_FROM_RAW(N->getLinkageName(), ""); }<br>
@@ -737,7 +811,7 @@ public:<br>
Function *getFunction() const;<br>
<br>
void replaceFunction(Function *F) {<br>
- if (auto *N = getRaw())<br>
+ if (auto *N = get())<br></blockquote><div><br>Can we just write that as "auto *N = *this" (not sure if that's better - but I'm wondering how much we need the 'get()' function?)?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
N->replaceFunction(F);<br>
}<br>
DIArray getTemplateParams() const {<br>
@@ -788,24 +862,30 @@ public:<br>
<br>
/// \brief This is a wrapper for a lexical block.<br>
class DILexicalBlock : public DIScope {<br>
- MDLexicalBlockBase *getRaw() const {<br>
- return dyn_cast_or_null<MDLexicalBlockBase>(get());<br>
- }<br>
-<br>
public:<br>
explicit DILexicalBlock(const MDNode *N = nullptr) : DIScope(N) {}<br>
DILexicalBlock(const MDLexicalBlock *N) : DIScope(N) {}<br>
<br>
+ MDLexicalBlockBase *get() const {<br>
+ return cast_or_null<MDLexicalBlockBase>(DIDescriptor::get());<br>
+ }<br>
+ operator MDLexicalBlockBase *() const { return get(); }<br>
+ MDLexicalBlockBase *operator->() const { return get(); }<br>
+ MDLexicalBlockBase &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
DIScope getContext() const {<br>
RETURN_DESCRIPTOR_FROM_RAW(DIScope, N->getScope());<br>
}<br>
unsigned getLineNumber() const {<br>
- if (auto *N = dyn_cast_or_null<MDLexicalBlock>(get()))<br>
+ if (auto *N = dyn_cast<MDLexicalBlock>(get()))<br>
return N->getLine();<br>
return 0;<br>
}<br>
unsigned getColumnNumber() const {<br>
- if (auto *N = dyn_cast_or_null<MDLexicalBlock>(get()))<br>
+ if (auto *N = dyn_cast<MDLexicalBlock>(get()))<br>
return N->getColumn();<br>
return 0;<br>
}<br>
@@ -814,14 +894,20 @@ public:<br>
<br>
/// \brief This is a wrapper for a lexical block with a filename change.<br>
class DILexicalBlockFile : public DIScope {<br>
- MDLexicalBlockFile *getRaw() const {<br>
- return dyn_cast_or_null<MDLexicalBlockFile>(get());<br>
- }<br>
-<br>
public:<br>
explicit DILexicalBlockFile(const MDNode *N = nullptr) : DIScope(N) {}<br>
DILexicalBlockFile(const MDLexicalBlockFile *N) : DIScope(N) {}<br>
<br>
+ MDLexicalBlockFile *get() const {<br>
+ return cast_or_null<MDLexicalBlockFile>(DIDescriptor::get());<br>
+ }<br>
+ operator MDLexicalBlockFile *() const { return get(); }<br>
+ MDLexicalBlockFile *operator->() const { return get(); }<br>
+ MDLexicalBlockFile &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
DIScope getContext() const {<br>
// FIXME: This logic is horrible. getScope() returns a DILexicalBlock, but<br>
// then we check if it's a subprogram? WHAT?!?<br>
@@ -842,12 +928,20 @@ public:<br>
<br>
/// \brief A wrapper for a C++ style name space.<br>
class DINameSpace : public DIScope {<br>
- MDNamespace *getRaw() const { return dyn_cast_or_null<MDNamespace>(get()); }<br>
-<br>
public:<br>
explicit DINameSpace(const MDNode *N = nullptr) : DIScope(N) {}<br>
DINameSpace(const MDNamespace *N) : DIScope(N) {}<br>
<br>
+ MDNamespace *get() const {<br>
+ return cast_or_null<MDNamespace>(DIDescriptor::get());<br>
+ }<br>
+ operator MDNamespace *() const { return get(); }<br>
+ MDNamespace *operator->() const { return get(); }<br>
+ MDNamespace &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); }<br>
unsigned getLineNumber() const { RETURN_FROM_RAW(N->getLine(), 0); }<br>
DIScope getContext() const {<br>
@@ -858,15 +952,21 @@ public:<br>
<br>
/// \brief This is a wrapper for template type parameter.<br>
class DITemplateTypeParameter : public DIDescriptor {<br>
- MDTemplateTypeParameter *getRaw() const {<br>
- return dyn_cast_or_null<MDTemplateTypeParameter>(get());<br>
- }<br>
-<br>
public:<br>
explicit DITemplateTypeParameter(const MDNode *N = nullptr)<br>
: DIDescriptor(N) {}<br>
DITemplateTypeParameter(const MDTemplateTypeParameter *N) : DIDescriptor(N) {}<br>
<br>
+ MDTemplateTypeParameter *get() const {<br>
+ return cast_or_null<MDTemplateTypeParameter>(DIDescriptor::get());<br>
+ }<br>
+ operator MDTemplateTypeParameter *() const { return get(); }<br>
+ MDTemplateTypeParameter *operator->() const { return get(); }<br>
+ MDTemplateTypeParameter &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); }<br>
<br>
DITypeRef getType() const { RETURN_REF_FROM_RAW(DITypeRef, N->getType()); }<br>
@@ -875,16 +975,22 @@ public:<br>
<br>
/// \brief This is a wrapper for template value parameter.<br>
class DITemplateValueParameter : public DIDescriptor {<br>
- MDTemplateValueParameter *getRaw() const {<br>
- return dyn_cast_or_null<MDTemplateValueParameter>(get());<br>
- }<br>
-<br>
public:<br>
explicit DITemplateValueParameter(const MDNode *N = nullptr)<br>
: DIDescriptor(N) {}<br>
DITemplateValueParameter(const MDTemplateValueParameter *N)<br>
: DIDescriptor(N) {}<br>
<br>
+ MDTemplateValueParameter *get() const {<br>
+ return cast_or_null<MDTemplateValueParameter>(DIDescriptor::get());<br>
+ }<br>
+ operator MDTemplateValueParameter *() const { return get(); }<br>
+ MDTemplateValueParameter *operator->() const { return get(); }<br>
+ MDTemplateValueParameter &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); }<br>
DITypeRef getType() const { RETURN_REF_FROM_RAW(DITypeRef, N->getType()); }<br>
Metadata *getValue() const { RETURN_FROM_RAW(N->getValue(), nullptr); }<br>
@@ -893,16 +999,22 @@ public:<br>
<br>
/// \brief This is a wrapper for a global variable.<br>
class DIGlobalVariable : public DIDescriptor {<br>
- MDGlobalVariable *getRaw() const {<br>
- return dyn_cast_or_null<MDGlobalVariable>(get());<br>
- }<br>
-<br>
DIFile getFile() const { RETURN_DESCRIPTOR_FROM_RAW(DIFile, N->getFile()); }<br>
<br>
public:<br>
explicit DIGlobalVariable(const MDNode *N = nullptr) : DIDescriptor(N) {}<br>
DIGlobalVariable(const MDGlobalVariable *N) : DIDescriptor(N) {}<br>
<br>
+ MDGlobalVariable *get() const {<br>
+ return cast_or_null<MDGlobalVariable>(DIDescriptor::get());<br>
+ }<br>
+ operator MDGlobalVariable *() const { return get(); }<br>
+ MDGlobalVariable *operator->() const { return get(); }<br>
+ MDGlobalVariable &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); }<br>
StringRef getDisplayName() const { RETURN_FROM_RAW(N->getDisplayName(), ""); }<br>
StringRef getLinkageName() const { RETURN_FROM_RAW(N->getLinkageName(), ""); }<br>
@@ -919,7 +1031,7 @@ public:<br>
<br>
GlobalVariable *getGlobal() const;<br>
Constant *getConstant() const {<br>
- if (auto *N = getRaw())<br>
+ if (auto *N = get())<br>
if (auto *C = dyn_cast_or_null<ConstantAsMetadata>(N->getVariable()))<br>
return C->getValue();<br>
return nullptr;<br>
@@ -934,16 +1046,22 @@ public:<br>
<br>
/// \brief This is a wrapper for a variable (e.g. parameter, local, global etc).<br>
class DIVariable : public DIDescriptor {<br>
- MDLocalVariable *getRaw() const {<br>
- return dyn_cast_or_null<MDLocalVariable>(get());<br>
- }<br>
-<br>
unsigned getFlags() const { RETURN_FROM_RAW(N->getFlags(), 0); }<br>
<br>
public:<br>
explicit DIVariable(const MDNode *N = nullptr) : DIDescriptor(N) {}<br>
DIVariable(const MDLocalVariable *N) : DIDescriptor(N) {}<br>
<br>
+ MDLocalVariable *get() const {<br>
+ return cast_or_null<MDLocalVariable>(DIDescriptor::get());<br>
+ }<br>
+ operator MDLocalVariable *() const { return get(); }<br>
+ MDLocalVariable *operator->() const { return get(); }<br>
+ MDLocalVariable &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
StringRef getName() const { RETURN_FROM_RAW(N->getName(), ""); }<br>
unsigned getLineNumber() const { RETURN_FROM_RAW(N->getLine(), 0); }<br>
unsigned getArgNumber() const { RETURN_FROM_RAW(N->getArg(), 0); }<br>
@@ -1001,6 +1119,10 @@ public:<br>
}<br>
operator MDExpression *() const { return get(); }<br>
MDExpression *operator->() const { return get(); }<br>
+ MDExpression &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
<br>
// Don't call this. Call isValid() directly.<br>
bool Verify() const = delete;<br>
@@ -1083,11 +1205,19 @@ public:<br>
///<br>
/// This object is not associated with any DWARF tag.<br>
class DILocation : public DIDescriptor {<br>
- MDLocation *getRaw() const { return dyn_cast_or_null<MDLocation>(get()); }<br>
-<br>
public:<br>
explicit DILocation(const MDNode *N) : DIDescriptor(N) {}<br>
<br>
+ MDLocation *get() const {<br>
+ return cast_or_null<MDLocation>(DIDescriptor::get());<br>
+ }<br>
+ operator MDLocation *() const { return get(); }<br>
+ MDLocation *operator->() const { return get(); }<br>
+ MDLocation &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
unsigned getLineNumber() const { RETURN_FROM_RAW(N->getLine(), 0); }<br>
unsigned getColumnNumber() const { RETURN_FROM_RAW(N->getColumn(), 0); }<br>
DIScope getScope() const {<br>
@@ -1130,14 +1260,20 @@ public:<br>
};<br>
<br>
class DIObjCProperty : public DIDescriptor {<br>
- MDObjCProperty *getRaw() const {<br>
- return dyn_cast_or_null<MDObjCProperty>(get());<br>
- }<br>
-<br>
public:<br>
explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) {}<br>
DIObjCProperty(const MDObjCProperty *N) : DIDescriptor(N) {}<br>
<br>
+ MDObjCProperty *get() const {<br>
+ return cast_or_null<MDObjCProperty>(DIDescriptor::get());<br>
+ }<br>
+ operator MDObjCProperty *() const { return get(); }<br>
+ MDObjCProperty *operator->() const { return get(); }<br>
+ MDObjCProperty &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
StringRef getObjCPropertyName() const { RETURN_FROM_RAW(N->getName(), ""); }<br>
DIFile getFile() const { RETURN_DESCRIPTOR_FROM_RAW(DIFile, N->getFile()); }<br>
unsigned getLineNumber() const { RETURN_FROM_RAW(N->getLine(), 0); }<br>
@@ -1179,15 +1315,21 @@ public:<br>
<br>
/// \brief An imported module (C++ using directive or similar).<br>
class DIImportedEntity : public DIDescriptor {<br>
- MDImportedEntity *getRaw() const {<br>
- return dyn_cast_or_null<MDImportedEntity>(get());<br>
- }<br>
-<br>
public:<br>
DIImportedEntity() = default;<br>
explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) {}<br>
DIImportedEntity(const MDImportedEntity *N) : DIDescriptor(N) {}<br>
<br>
+ MDImportedEntity *get() const {<br>
+ return cast_or_null<MDImportedEntity>(DIDescriptor::get());<br>
+ }<br>
+ operator MDImportedEntity *() const { return get(); }<br>
+ MDImportedEntity *operator->() const { return get(); }<br>
+ MDImportedEntity &operator*() const {<br>
+ assert(get() && "Expected valid pointer");<br>
+ return *get();<br>
+ }<br>
+<br>
DIScope getContext() const {<br>
RETURN_DESCRIPTOR_FROM_RAW(DIScope, N->getScope());<br>
}<br>
<br>
Modified: llvm/trunk/lib/IR/DebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=233030&r1=233029&r2=233030&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=233030&r1=233029&r2=233030&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Mar 23 16:54:07 2015<br>
@@ -260,7 +260,7 @@ static bool isDescriptorRef(const Metada<br>
#endif<br>
<br>
bool DIType::Verify() const {<br>
- auto *N = getRaw();<br>
+ auto *N = dyn_cast_or_null<MDType>(DbgNode);<br>
if (!N)<br>
return false;<br>
if (!isScopeRef(N->getScope()))<br>
@@ -294,10 +294,12 @@ bool DIType::Verify() const {<br>
return false;<br>
}<br>
<br>
-bool DIBasicType::Verify() const { return getRaw(); }<br>
+bool DIBasicType::Verify() const {<br>
+ return dyn_cast_or_null<MDBasicType>(DbgNode);<br>
+}<br>
<br>
bool DIDerivedType::Verify() const {<br>
- auto *N = getRaw();<br>
+ auto *N = dyn_cast_or_null<MDDerivedTypeBase>(DbgNode);<br>
if (!N)<br>
return false;<br>
if (getTag() == dwarf::DW_TAG_ptr_to_member_type) {<br>
@@ -311,13 +313,13 @@ bool DIDerivedType::Verify() const {<br>
}<br>
<br>
bool DICompositeType::Verify() const {<br>
- auto *N = getRaw();<br>
+ auto *N = dyn_cast_or_null<MDCompositeTypeBase>(DbgNode);<br>
return N && isTypeRef(N->getBaseType()) && isTypeRef(N->getVTableHolder()) &&<br>
!(isLValueReference() && isRValueReference());<br>
}<br>
<br>
bool DISubprogram::Verify() const {<br>
- auto *N = getRaw();<br>
+ auto *N = dyn_cast_or_null<MDSubprogram>(DbgNode);<br>
if (!N)<br>
return false;<br>
<br>
@@ -370,7 +372,7 @@ bool DISubprogram::Verify() const {<br>
}<br>
<br>
bool DIGlobalVariable::Verify() const {<br>
- auto *N = getRaw();<br>
+ auto *N = dyn_cast_or_null<MDGlobalVariable>(DbgNode);<br>
<br>
if (!N)<br>
return false;<br>
@@ -390,7 +392,7 @@ bool DIGlobalVariable::Verify() const {<br>
}<br>
<br>
bool DIVariable::Verify() const {<br>
- auto *N = getRaw();<br>
+ auto *N = dyn_cast_or_null<MDLocalVariable>(DbgNode);<br>
<br>
if (!N)<br>
return false;<br>
@@ -402,19 +404,37 @@ bool DIVariable::Verify() const {<br>
return isTypeRef(N->getType());<br>
}<br>
<br>
-bool DILocation::Verify() const { return getRaw(); }<br>
-bool DINameSpace::Verify() const { return getRaw(); }<br>
-bool DIFile::Verify() const { return getRaw(); }<br>
-bool DIEnumerator::Verify() const { return getRaw(); }<br>
-bool DISubrange::Verify() const { return getRaw(); }<br>
-bool DILexicalBlock::Verify() const { return getRaw(); }<br>
-bool DILexicalBlockFile::Verify() const { return getRaw(); }<br>
-bool DITemplateTypeParameter::Verify() const { return getRaw(); }<br>
-bool DITemplateValueParameter::Verify() const { return getRaw(); }<br>
-bool DIImportedEntity::Verify() const { return getRaw(); }<br>
+bool DILocation::Verify() const {<br>
+ return dyn_cast_or_null<MDLocation>(DbgNode);<br>
+}<br>
+bool DINameSpace::Verify() const {<br>
+ return dyn_cast_or_null<MDNamespace>(DbgNode);<br>
+}<br>
+bool DIFile::Verify() const { return dyn_cast_or_null<MDFile>(DbgNode); }<br>
+bool DIEnumerator::Verify() const {<br>
+ return dyn_cast_or_null<MDEnumerator>(DbgNode);<br>
+}<br>
+bool DISubrange::Verify() const {<br>
+ return dyn_cast_or_null<MDSubrange>(DbgNode);<br>
+}<br>
+bool DILexicalBlock::Verify() const {<br>
+ return dyn_cast_or_null<MDLexicalBlock>(DbgNode);<br>
+}<br>
+bool DILexicalBlockFile::Verify() const {<br>
+ return dyn_cast_or_null<MDLexicalBlockFile>(DbgNode);<br>
+}<br>
+bool DITemplateTypeParameter::Verify() const {<br>
+ return dyn_cast_or_null<MDTemplateTypeParameter>(DbgNode);<br>
+}<br>
+bool DITemplateValueParameter::Verify() const {<br>
+ return dyn_cast_or_null<MDTemplateValueParameter>(DbgNode);<br>
+}<br>
+bool DIImportedEntity::Verify() const {<br>
+ return dyn_cast_or_null<MDImportedEntity>(DbgNode);<br>
+}<br>
<br>
void DICompositeType::setArraysHelper(MDNode *Elements, MDNode *TParams) {<br>
- TypedTrackingMDRef<MDCompositeTypeBase> N(getRaw());<br>
+ TypedTrackingMDRef<MDCompositeTypeBase> N(get());<br>
if (Elements)<br>
N->replaceElements(cast<MDTuple>(Elements));<br>
if (TParams)<br>
@@ -432,7 +452,7 @@ DIScopeRef DIScope::getRef() const {<br>
}<br>
<br>
void DICompositeType::setContainingType(DICompositeType ContainingType) {<br>
- TypedTrackingMDRef<MDCompositeTypeBase> N(getRaw());<br>
+ TypedTrackingMDRef<MDCompositeTypeBase> N(get());<br>
N->replaceVTableHolder(ContainingType.getRef());<br>
DbgNode = N;<br>
}<br>
@@ -447,7 +467,7 @@ bool DIVariable::isInlinedFnArgument(con<br>
}<br>
<br>
Function *DISubprogram::getFunction() const {<br>
- if (auto *N = getRaw())<br>
+ if (auto *N = get())<br>
if (auto *C = dyn_cast_or_null<ConstantAsMetadata>(N->getFunction()))<br>
return dyn_cast<Function>(C->getValue());<br>
return nullptr;<br>
@@ -504,26 +524,25 @@ StringRef DIScope::getName() const {<br>
}<br>
<br>
StringRef DIScope::getFilename() const {<br>
- if (auto *N = getRaw())<br>
+ if (auto *N = get())<br>
return ::getStringField(dyn_cast_or_null<MDNode>(N->getFile()), 0);<br>
return "";<br>
}<br>
<br>
StringRef DIScope::getDirectory() const {<br>
- if (auto *N = getRaw())<br>
+ if (auto *N = get())<br>
return ::getStringField(dyn_cast_or_null<MDNode>(N->getFile()), 1);<br>
return "";<br>
}<br>
<br>
void DICompileUnit::replaceSubprograms(DIArray Subprograms) {<br>
assert(Verify() && "Expected compile unit");<br>
- getRaw()->replaceSubprograms(cast_or_null<MDTuple>(Subprograms.get()));<br>
+ get()->replaceSubprograms(cast_or_null<MDTuple>(Subprograms.get()));<br>
}<br>
<br>
void DICompileUnit::replaceGlobalVariables(DIArray GlobalVariables) {<br>
assert(Verify() && "Expected compile unit");<br>
- getRaw()->replaceGlobalVariables(<br>
- cast_or_null<MDTuple>(GlobalVariables.get()));<br>
+ get()->replaceGlobalVariables(cast_or_null<MDTuple>(GlobalVariables.get()));<br>
}<br>
<br>
DILocation DILocation::copyWithNewScope(LLVMContext &Ctx,<br>
<br>
Modified: llvm/trunk/test/CodeGen/X86/2012-11-30-misched-dbg.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2012-11-30-misched-dbg.ll?rev=233030&r1=233029&r2=233030&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2012-11-30-misched-dbg.ll?rev=233030&r1=233029&r2=233030&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/X86/2012-11-30-misched-dbg.ll (original)<br>
+++ llvm/trunk/test/CodeGen/X86/2012-11-30-misched-dbg.ll Mon Mar 23 16:54:07 2015<br>
@@ -77,7 +77,7 @@ declare i32 @__sprintf_chk(i8*, i32, i64<br>
!10 = distinct !MDLexicalBlock(line: 434, column: 0, file: !14, scope: !11)<br>
!11 = distinct !MDLexicalBlock(line: 250, column: 0, file: !14, scope: !12)<br>
!12 = distinct !MDLexicalBlock(line: 249, column: 0, file: !14, scope: !13)<br>
-!13 = distinct !MDLexicalBlock(line: 221, column: 0, file: !14, scope: !2)<br>
+!13 = distinct !MDLexicalBlock(line: 221, column: 0, file: !14, scope: !21)<br>
!14 = !MDFile(filename: "MultiSource/Benchmarks/MiBench/consumer-typeset/z19.c", directory: "MultiSource/Benchmarks/MiBench/consumer-typeset")<br>
!15 = !MDCompositeType(tag: DW_TAG_array_type, size: 160, align: 8, baseType: !16, elements: !17)<br>
!16 = !MDBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)<br>
<br>
Modified: llvm/trunk/test/Transforms/Inline/debug-invoke.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/debug-invoke.ll?rev=233030&r1=233029&r2=233030&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/debug-invoke.ll?rev=233030&r1=233029&r2=233030&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/Inline/debug-invoke.ll (original)<br>
+++ llvm/trunk/test/Transforms/Inline/debug-invoke.ll Mon Mar 23 16:54:07 2015<br>
@@ -4,9 +4,9 @@<br>
<br>
; CHECK: invoke void @test()<br>
; CHECK-NEXT: to label {{.*}} unwind label {{.*}}, !dbg [[INL_LOC:!.*]]<br>
-; CHECK: [[EMPTY:.*]] = !{}<br>
-; CHECK: [[INL_LOC]] = !MDLocation(line: 1, scope: [[EMPTY]], inlinedAt: [[INL_AT:.*]])<br>
-; CHECK: [[INL_AT]] = distinct !MDLocation(line: 2, scope: [[EMPTY]])<br>
+; CHECK: [[SP:.*]] = !MDSubprogram(<br>
+; CHECK: [[INL_LOC]] = !MDLocation(line: 1, scope: [[SP]], inlinedAt: [[INL_AT:.*]])<br>
+; CHECK: [[INL_AT]] = distinct !MDLocation(line: 2, scope: [[SP]])<br>
<br>
declare void @test()<br>
declare i32 @__gxx_personality_v0(...)<br>
@@ -32,6 +32,6 @@ lpad:<br>
<br>
!llvm.module.flags = !{!1}<br>
!1 = !{i32 2, !"Debug Info Version", i32 3}<br>
-!2 = !{}<br>
+!2 = !MDSubprogram()<br>
!3 = !MDLocation(line: 1, scope: !2)<br>
!4 = !MDLocation(line: 2, scope: !2)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>