DIBuilder: Change a few helpers to return downcasted MDNodes
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 27 Mar 2015 00:34:10 +0000 (00:34 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 27 Mar 2015 00:34:10 +0000 (00:34 +0000)
Change `getNonCompileUnitScope()` to return `MDScope` and
`getConstantAsMetadata()` to return `ConstantAsMetadata`.  This will
make it easier to start requiring more type safety in the debug info
hierarchy.

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

lib/IR/DIBuilder.cpp

index 981e3fd306290a7f4dbc06c9845f8756992085c4..9677de47f7b03e4c8a8fe94697b256a80ec84058 100644 (file)
@@ -121,10 +121,10 @@ void DIBuilder::finalize() {
 }
 
 /// If N is compile unit return NULL otherwise return N.
-static MDNode *getNonCompileUnitScope(MDNode *N) {
-  if (DIDescriptor(N).isCompileUnit())
+static MDScope *getNonCompileUnitScope(MDNode *N) {
+  if (!N || isa<MDCompileUnit>(N))
     return nullptr;
-  return N;
+  return cast<MDScope>(N);
 }
 
 DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
@@ -304,7 +304,7 @@ DIDerivedType DIBuilder::createMemberType(DIDescriptor Scope, StringRef Name,
       AlignInBits, OffsetInBits, Flags);
 }
 
-static Metadata *getConstantOrNull(Constant *C) {
+static ConstantAsMetadata *getConstantOrNull(Constant *C) {
   if (C)
     return ConstantAsMetadata::get(C);
   return nullptr;