Verifier: Add simple checks for MDLocation
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 10 Feb 2015 01:32:56 +0000 (01:32 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 10 Feb 2015 01:32:56 +0000 (01:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228647 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Verifier.cpp

index e1b6f944f8aef83b6a76983a9a692c7d9a197303..ab3a2735df3388de240d95c747a80fc58bea07a3 100644 (file)
@@ -678,7 +678,13 @@ void Verifier::visitMetadataAsValue(const MetadataAsValue &MDV, Function *F) {
     visitValueAsMetadata(*V, F);
 }
 
-void Verifier::visitMDLocation(const MDLocation &) {}
+void Verifier::visitMDLocation(const MDLocation &N) {
+  Assert1(N.getScope(), "location requires a valid scope", &N);
+  if (N.getInlinedAt())
+    Assert2(isa<MDLocation>(N.getInlinedAt()),
+            "inlined-at should be a location", &N, N.getInlinedAt());
+}
+
 void Verifier::visitGenericDebugNode(const GenericDebugNode &) {}
 void Verifier::visitMDSubrange(const MDSubrange &) {}
 void Verifier::visitMDEnumerator(const MDEnumerator &) {}