[llvm] r233662 - DebugInfo: Rewrite llvm::getDISubprogram(), NFC

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


Author: dexonsmith
Date: Mon Mar 30 21:06:28 2015
New Revision: 233662

URL: http://llvm.org/viewvc/llvm-project?rev=233662&view=rev
Log:
DebugInfo: Rewrite llvm::getDISubprogram(), NFC

Simplify implementation of `llvm::getDISubprogram()`.  I might go
through and see how difficult it is to update the users, since this
function doesn't really seem necessary anymore.

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

Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=233662&r1=233661&r2=233662&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Mar 30 21:06:28 2015
@@ -461,17 +461,9 @@ DIVariable llvm::cleanseInlinedVariable(
 }
 
 DISubprogram llvm::getDISubprogram(const MDNode *Scope) {
-  DIDescriptor D(Scope);
-  if (D.isSubprogram())
-    return DISubprogram(Scope);
-
-  if (D.isLexicalBlockFile())
-    return getDISubprogram(DILexicalBlockFile(Scope).getContext());
-
-  if (D.isLexicalBlock())
-    return getDISubprogram(DILexicalBlock(Scope).getContext());
-
-  return DISubprogram();
+  if (auto *LocalScope = dyn_cast_or_null<MDLocalScope>(Scope))
+    return LocalScope->getSubprogram();
+  return nullptr;
 }
 
 DISubprogram llvm::getDISubprogram(const Function *F) {





More information about the llvm-commits mailing list