When parsing a function body, add it to the crash stack, giving us something
like:

Stack dump:
0.	t.c:5:10: in compound statement ('{}')
1.	t.c:3:12: in compound statement ('{}')
2.	t.c:3:12: parsing function body 'foo'
3.	clang t.c 
Abort



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66118 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 31a8c38..de9b4cd 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -290,6 +290,11 @@
   //===--------------------------------------------------------------------===//
   // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
   //
+
+  /// getDeclName - Return a pretty name for the specified decl if possible, or
+  /// an empty string if not.  This is used for pretty crash reporting. 
+  virtual std::string getDeclName(DeclTy *D);
+  
   virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc, 
                               Scope *S, const CXXScopeSpec *SS);
   virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup){
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index e1b27c6..97002ef 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -30,6 +30,15 @@
 #include <functional>
 using namespace clang;
 
+/// getDeclName - Return a pretty name for the specified decl if possible, or
+/// an empty string if not.  This is used for pretty crash reporting. 
+std::string Sema::getDeclName(DeclTy *d) {
+  Decl *D = static_cast<Decl *>(d);
+  if (NamedDecl *DN = dyn_cast_or_null<NamedDecl>(D))
+    return DN->getQualifiedNameAsString();
+  return "";
+}
+
 /// \brief If the identifier refers to a type name within this scope,
 /// return the declaration of that type.
 ///