]> granicus.if.org Git - clang/commitdiff
Simplify FunctionDecl::getBody.
authorRafael Espindola <rafael.espindola@gmail.com>
Sat, 19 Oct 2013 01:37:17 +0000 (01:37 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sat, 19 Oct 2013 01:37:17 +0000 (01:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193025 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp

index c3a462defc414ce3a76117f0f5f16960a7628d84..484248f09f4885d037f39cfa756f2ce7776fbb3a 100644 (file)
@@ -2233,15 +2233,11 @@ bool FunctionDecl::isDefined(const FunctionDecl *&Definition) const {
 }
 
 Stmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const {
-  for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) {
-    if (I->Body) {
-      Definition = *I;
-      return I->Body.get(getASTContext().getExternalSource());
-    } else if (I->IsLateTemplateParsed) {
-      Definition = *I;
-      return 0;
-    }
-  }
+  if (!hasBody(Definition))
+    return 0;
+
+  if (Definition->Body)
+    return Definition->Body.get(getASTContext().getExternalSource());
 
   return 0;
 }