Verifier: Check reference flags in debug info
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 31 Mar 2015 01:28:58 +0000 (01:28 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 31 Mar 2015 01:28:58 +0000 (01:28 +0000)
Move over checks of `&` and `&&` flags.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233658 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/DebugInfo.cpp
lib/IR/Verifier.cpp

index 91823773212b442d90216e81c1928fdaa0944f82..9381a5b580e50b2a081d4e1e23228da27d6df479 100644 (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()) {
index 19897d4c0308faa6a0082da78f48dc6d6d9a53d1..171c16bc76bb0fa50aefe35d8ef58e0f20edd3b9 100644 (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) {