From 9f2b49c5219ff512d3033d6cbaa2467621d03e26 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 27 Mar 2015 00:34:10 +0000 Subject: [PATCH] DIBuilder: Change a few helpers to return downcasted MDNodes 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 981e3fd3062..9677de47f7b 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -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(N)) return nullptr; - return N; + return cast(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;