1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Verifier: Check reference flags in debug info

Move over checks of `&` and `&&` flags.

llvm-svn: 233658
This commit is contained in:
Duncan P. N. Exon Smith 2015-03-31 01:28:58 +00:00
parent 4993b1f8fa
commit 15805b3fb9
2 changed files with 13 additions and 18 deletions

View File

@ -252,32 +252,16 @@ static bool isDescriptorRef(const Metadata *MD) {
}
#endif
bool DIType::Verify() const {
auto *N = dyn_cast_or_null<MDType>(DbgNode);
if (!N)
return false;
if (isCompositeType())
return DICompositeType(DbgNode).Verify();
return true;
}
bool DIType::Verify() const { return isType(); }
bool DIBasicType::Verify() const { return isBasicType(); }
bool DIDerivedType::Verify() const { return isDerivedType(); }
bool DICompositeType::Verify() const {
auto *N = dyn_cast_or_null<MDCompositeTypeBase>(DbgNode);
return N && !(isLValueReference() && isRValueReference());
}
bool DICompositeType::Verify() const { return isCompositeType(); }
bool DISubprogram::Verify() const {
auto *N = dyn_cast_or_null<MDSubprogram>(DbgNode);
if (!N)
return false;
if (isLValueReference() && isRValueReference())
return false;
// If a DISubprogram has an llvm::Function*, then scope chains from all
// instructions within the function should lead to this DISubprogram.
if (auto *F = getFunction()) {

View File

@ -796,6 +796,11 @@ void Verifier::visitMDDerivedType(const MDDerivedType &N) {
}
}
static bool hasConflictingReferenceFlags(unsigned Flags) {
return (Flags & DebugNode::FlagLValueReference) &&
(Flags & DebugNode::FlagRValueReference);
}
void Verifier::visitMDCompositeType(const MDCompositeType &N) {
// Common derived type checks.
visitMDDerivedTypeBase(N);
@ -814,6 +819,8 @@ void Verifier::visitMDCompositeType(const MDCompositeType &N) {
N.getRawVTableHolder());
Assert(!N.getRawElements() || isa<MDTuple>(N.getRawElements()),
"invalid composite elements", &N, N.getRawElements());
Assert(!hasConflictingReferenceFlags(N.getFlags()), "invalid reference flags",
&N);
}
void Verifier::visitMDSubroutineType(const MDSubroutineType &N) {
@ -824,6 +831,8 @@ void Verifier::visitMDSubroutineType(const MDSubroutineType &N) {
Assert(isTypeRef(Ty), "invalid subroutine type ref", &N, Types, Ty);
}
}
Assert(!hasConflictingReferenceFlags(N.getFlags()), "invalid reference flags",
&N);
}
void Verifier::visitMDFile(const MDFile &N) {
@ -910,6 +919,8 @@ void Verifier::visitMDSubprogram(const MDSubprogram &N) {
Op);
}
}
Assert(!hasConflictingReferenceFlags(N.getFlags()), "invalid reference flags",
&N);
}
void Verifier::visitMDLexicalBlockBase(const MDLexicalBlockBase &N) {