From 442ec0223ba0c129526530bb11d872977a600b70 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 2 Feb 2015 19:54:05 +0000 Subject: IR: Separate helpers for string operands, NFC llvm-svn: 227846 --- llvm/lib/IR/DebugInfoMetadata.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'llvm/lib/IR/DebugInfoMetadata.cpp') diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 9daf7857ba6..66dcc8e8055 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -71,6 +71,13 @@ MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line, Storage, Context.pImpl->MDLocations); } +/// \brief Get the MDString, or nullptr if the string is empty. +static MDString *getCanonicalMDString(LLVMContext &Context, StringRef S) { + if (S.empty()) + return nullptr; + return MDString::get(Context, S); +} + GenericDebugNode *GenericDebugNode::getImpl(LLVMContext &Context, unsigned Tag, StringRef Header, ArrayRef DwarfOps, @@ -89,8 +96,7 @@ GenericDebugNode *GenericDebugNode::getImpl(LLVMContext &Context, unsigned Tag, } // Use a nullptr for empty headers. - Metadata *PreOps[] = {Header.empty() ? nullptr - : MDString::get(Context, Header)}; + Metadata *PreOps[] = {getCanonicalMDString(Context, Header)}; return storeImpl(new (DwarfOps.size() + 1) GenericDebugNode( Context, Storage, Hash, Tag, PreOps, DwarfOps), Storage, Context.pImpl->GenericDebugNodes); -- cgit v1.2.3