[llvm] r234836 - DebugInfo: Gut DIObjCProperty and DIImportedEntity
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 13 18:46:44 PDT 2015
Author: dexonsmith
Date: Mon Apr 13 20:46:44 2015
New Revision: 234836
URL: http://llvm.org/viewvc/llvm-project?rev=234836&view=rev
Log:
DebugInfo: Gut DIObjCProperty and DIImportedEntity
Gut a couple more classes in the DIDescriptor hierarchy. Leave behind
an implicit conversion to `DIDescriptor`, the old base class.
Modified:
llvm/trunk/include/llvm/IR/DebugInfo.h
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/lib/IR/DIBuilder.cpp
llvm/trunk/lib/IR/DebugInfo.cpp
Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234836&r1=234835&r2=234836&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 13 20:46:44 2015
@@ -674,50 +674,29 @@ public:
MDLocation &operator*() const { return *N; }
};
-class DIObjCProperty : public DIDescriptor {
+class DIObjCProperty {
+ MDObjCProperty *N;
+
public:
- DIObjCProperty() = default;
- DIObjCProperty(const MDObjCProperty *N) : DIDescriptor(N) {}
+ DIObjCProperty(const MDObjCProperty *N = nullptr)
+ : N(const_cast<MDObjCProperty *>(N)) {}
- MDObjCProperty *get() const {
- return cast_or_null<MDObjCProperty>(DIDescriptor::get());
- }
- operator MDObjCProperty *() const { return get(); }
- MDObjCProperty *operator->() const { return get(); }
- MDObjCProperty &operator*() const { return *get(); }
-
- StringRef getObjCPropertyName() const { return get()->getName(); }
- DIFile getFile() const { return get()->getFile(); }
- unsigned getLineNumber() const { return get()->getLine(); }
-
- StringRef getObjCPropertyGetterName() const { return get()->getGetterName(); }
- StringRef getObjCPropertySetterName() const { return get()->getSetterName(); }
- unsigned getAttributes() const { return get()->getAttributes(); }
-
- /// \brief Get the type.
- ///
- /// \note Objective-C doesn't have an ODR, so there is no benefit in storing
- /// the type as a DITypeRef here.
- DIType getType() const { return get()->getType(); }
+ operator MDObjCProperty *() const { return N; }
+ MDObjCProperty *operator->() const { return N; }
+ MDObjCProperty &operator*() const { return *N; }
};
-/// \brief An imported module (C++ using directive or similar).
-class DIImportedEntity : public DIDescriptor {
+class DIImportedEntity {
+ MDImportedEntity *N;
+
public:
- DIImportedEntity() = default;
- DIImportedEntity(const MDImportedEntity *N) : DIDescriptor(N) {}
+ DIImportedEntity(const MDImportedEntity *N = nullptr)
+ : N(const_cast<MDImportedEntity *>(N)) {}
- MDImportedEntity *get() const {
- return cast_or_null<MDImportedEntity>(DIDescriptor::get());
- }
- operator MDImportedEntity *() const { return get(); }
- MDImportedEntity *operator->() const { return get(); }
- MDImportedEntity &operator*() const { return *get(); }
-
- DIScope getContext() const { return get()->getScope(); }
- DIDescriptorRef getEntity() const { return get()->getEntity(); }
- unsigned getLineNumber() const { return get()->getLine(); }
- StringRef getName() const { return get()->getName(); }
+ operator DIDescriptor() const { return N; }
+ operator MDImportedEntity *() const { return N; }
+ MDImportedEntity *operator->() const { return N; }
+ MDImportedEntity &operator*() const { return *N; }
};
#define SIMPLIFY_DESCRIPTOR(DESC) \
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234836&r1=234835&r2=234836&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Apr 13 20:46:44 2015
@@ -2136,6 +2136,11 @@ public:
MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
StringRef getGetterName() const { return getStringOperand(2); }
StringRef getSetterName() const { return getStringOperand(3); }
+
+ /// \brief Get the type.
+ ///
+ /// \note Objective-C doesn't have an ODR, so there is no benefit in storing
+ /// the type as a DITypeRef here.
MDType *getType() const { return cast_or_null<MDType>(getRawType()); }
StringRef getFilename() const {
@@ -2160,6 +2165,7 @@ public:
}
};
+/// \brief An imported module (C++ using directive or similar).
class MDImportedEntity : public DebugNode {
friend class LLVMContextImpl;
friend class MDNode;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=234836&r1=234835&r2=234836&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Apr 13 20:46:44 2015
@@ -633,10 +633,10 @@ DwarfCompileUnit::constructAbstractSubpr
std::unique_ptr<DIE>
DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity &Module) {
- std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module.getTag());
+ std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module->getTag());
insertDIE(Module, IMDie.get());
DIE *EntityDie;
- DIDescriptor Entity = resolve(Module.getEntity());
+ auto *Entity = resolve(Module->getEntity());
if (auto *NS = dyn_cast<MDNamespace>(Entity))
EntityDie = getOrCreateNameSpace(NS);
else if (auto *SP = dyn_cast<MDSubprogram>(Entity))
@@ -648,11 +648,10 @@ DwarfCompileUnit::constructImportedEntit
else
EntityDie = getDIE(Entity);
assert(EntityDie);
- addSourceLine(*IMDie, Module.getLineNumber(),
- Module.getContext().getFilename(),
- Module.getContext().getDirectory());
+ addSourceLine(*IMDie, Module->getLine(), Module->getScope()->getFilename(),
+ Module->getScope()->getDirectory());
addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);
- StringRef Name = Module.getName();
+ StringRef Name = Module->getName();
if (!Name.empty())
addString(*IMDie, dwarf::DW_AT_name, Name);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=234836&r1=234835&r2=234836&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Apr 13 20:46:44 2015
@@ -420,7 +420,7 @@ DwarfCompileUnit &DwarfDebug::constructD
void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
const MDNode *N) {
DIImportedEntity Module = cast<MDImportedEntity>(N);
- if (DIE *D = TheCU.getOrCreateContextDIE(Module.getContext()))
+ if (DIE *D = TheCU.getOrCreateContextDIE(Module->getScope()))
D->addChild(TheCU.constructImportedEntityDIE(Module));
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=234836&r1=234835&r2=234836&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Mon Apr 13 20:46:44 2015
@@ -432,9 +432,7 @@ void DwarfUnit::addSourceLine(DIE &Die,
void DwarfUnit::addSourceLine(DIE &Die, DIObjCProperty Ty) {
assert(Ty);
- DIFile File = Ty.getFile();
- addSourceLine(Die, Ty.getLineNumber(), File.getFilename(),
- File.getDirectory());
+ addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
}
/// addSourceLine - Add location information to specified debug information
@@ -1060,19 +1058,19 @@ void DwarfUnit::constructTypeDIE(DIE &Bu
constructMemberDIE(Buffer, DDTy);
}
} else if (DIObjCProperty Property = dyn_cast<MDObjCProperty>(Element)) {
- DIE &ElemDie = createAndAddDIE(Property.getTag(), Buffer);
- StringRef PropertyName = Property.getObjCPropertyName();
+ DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer);
+ StringRef PropertyName = Property->getName();
addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
- if (Property.getType())
- addType(ElemDie, Property.getType());
+ if (Property->getType())
+ addType(ElemDie, Property->getType());
addSourceLine(ElemDie, Property);
- StringRef GetterName = Property.getObjCPropertyGetterName();
+ StringRef GetterName = Property->getGetterName();
if (!GetterName.empty())
addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
- StringRef SetterName = Property.getObjCPropertySetterName();
+ StringRef SetterName = Property->getSetterName();
if (!SetterName.empty())
addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
- if (unsigned PropertyAttributes = Property.getAttributes())
+ if (unsigned PropertyAttributes = Property->getAttributes())
addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, None,
PropertyAttributes);
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=234836&r1=234835&r2=234836&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Mon Apr 13 20:46:44 2015
@@ -177,7 +177,7 @@ createImportedModule(LLVMContext &C, dwa
SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
DIImportedEntity M =
MDImportedEntity::get(C, Tag, Context, DebugNodeRef(NS), Line, Name);
- AllImportedModules.emplace_back(M.get());
+ AllImportedModules.emplace_back(M);
return M;
}
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=234836&r1=234835&r2=234836&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Apr 13 20:46:44 2015
@@ -163,7 +163,7 @@ void DebugInfoFinder::processModule(cons
for (auto *RT : CU->getRetainedTypes())
processType(RT);
for (DIImportedEntity Import : CU->getImportedEntities()) {
- DIDescriptor Entity = Import.getEntity().resolve(TypeIdentifierMap);
+ auto *Entity = Import->getEntity().resolve(TypeIdentifierMap);
if (auto *T = dyn_cast<MDType>(Entity))
processType(T);
else if (auto *SP = dyn_cast<MDSubprogram>(Entity))
More information about the llvm-commits
mailing list