Add helper for extracting the CXXRecordDecl for the implicit argument to
a member call expression. This has proved to be a common pattern for users of
RecursiveASTVisitor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117439 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 0cdf8dd..1e06918 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -385,6 +385,17 @@
   return 0;
 }
 
+CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() {
+  Expr* ThisArg = getImplicitObjectArgument();
+  if (!ThisArg)
+    return 0;
+
+  if (ThisArg->getType()->isAnyPointerType())
+    return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl();
+
+  return ThisArg->getType()->getAsCXXRecordDecl();
+}
+
 SourceRange CXXMemberCallExpr::getSourceRange() const {
   SourceLocation LocStart = getCallee()->getLocStart();
   if (LocStart.isInvalid() && getNumArgs() > 0)