Decl::getTranslationUnitDecl() should return itself when the Decl is a TranslationUnitDecl.

llvm-svn: 74502
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index d872eae..3d92331 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -158,6 +158,9 @@
 }
 
 TranslationUnitDecl *Decl::getTranslationUnitDecl() {
+  if (TranslationUnitDecl *TUD = dyn_cast<TranslationUnitDecl>(this))
+    return TUD;
+
   DeclContext *DC = getDeclContext();
   assert(DC && "This decl is not contained in a translation unit!");