Decl::getTranslationUnitDecl() should return itself when the Decl is a TranslationUnitDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74502 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index d872eae..3d92331 100644
--- a/lib/AST/DeclBase.cpp
+++ b/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!");