[DebugInfo] Use DbgEntityKind in DbgEntity interface (NFC)

It was being used occasionally already, and using it on the constructor
and getDbgEntityID has obvious type safety benefits.

Also use llvm_unreachable in the switch as usual, but since only these
two values are used in constructor calls I think it's still NFC.

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D113862
This commit is contained in:
Aaron Puchert 2021-11-16 23:56:21 +01:00
parent 8b8e8704ce
commit 86b3100cde
1 changed files with 11 additions and 10 deletions

View File

@ -65,18 +65,20 @@ class Module;
/// such that it could levarage polymorphism to extract common code for
/// DbgVariable and DbgLabel.
class DbgEntity {
const DINode *Entity;
const DILocation *InlinedAt;
DIE *TheDIE = nullptr;
unsigned SubclassID;
public:
enum DbgEntityKind {
DbgVariableKind,
DbgLabelKind
};
DbgEntity(const DINode *N, const DILocation *IA, unsigned ID)
private:
const DINode *Entity;
const DILocation *InlinedAt;
DIE *TheDIE = nullptr;
const DbgEntityKind SubclassID;
public:
DbgEntity(const DINode *N, const DILocation *IA, DbgEntityKind ID)
: Entity(N), InlinedAt(IA), SubclassID(ID) {}
virtual ~DbgEntity() {}
@ -85,19 +87,18 @@ public:
const DINode *getEntity() const { return Entity; }
const DILocation *getInlinedAt() const { return InlinedAt; }
DIE *getDIE() const { return TheDIE; }
unsigned getDbgEntityID() const { return SubclassID; }
DbgEntityKind getDbgEntityID() const { return SubclassID; }
/// @}
void setDIE(DIE &D) { TheDIE = &D; }
static bool classof(const DbgEntity *N) {
switch (N->getDbgEntityID()) {
default:
return false;
case DbgVariableKind:
case DbgLabelKind:
return true;
}
llvm_unreachable("Invalid DbgEntityKind");
}
};