[llvm] r233658 - Verifier: Check reference flags in debug info

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Mar 30 18:28:58 PDT 2015


Author: dexonsmith
Date: Mon Mar 30 20:28:58 2015
New Revision: 233658

URL: http://llvm.org/viewvc/llvm-project?rev=233658&view=rev
Log:
Verifier: Check reference flags in debug info

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

Modified:
    llvm/trunk/lib/IR/DebugInfo.cpp
    llvm/trunk/lib/IR/Verifier.cpp

Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=233658&r1=233657&r2=233658&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Mar 30 20:28:58 2015
@@ -252,32 +252,16 @@ static bool isDescriptorRef(const Metada
 }
 #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()) {

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=233658&r1=233657&r2=233658&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Mon Mar 30 20:28:58 2015
@@ -796,6 +796,11 @@ void Verifier::visitMDDerivedType(const
   }
 }
 
+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(cons
          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(con
       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 M
              Op);
     }
   }
+  Assert(!hasConflictingReferenceFlags(N.getFlags()), "invalid reference flags",
+         &N);
 }
 
 void Verifier::visitMDLexicalBlockBase(const MDLexicalBlockBase &N) {





More information about the llvm-commits mailing list