From: Argyrios Kyrtzidis Date: Tue, 30 Jun 2009 02:34:53 +0000 (+0000) Subject: Decl::getTranslationUnitDecl() should return itself when the Decl is a TranslationUni... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b34669c672e776a24616eb01cffcf7061356d26;p=clang 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 d872eae084..3d92331792 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -158,6 +158,9 @@ void Decl::setLexicalDeclContext(DeclContext *DC) { } TranslationUnitDecl *Decl::getTranslationUnitDecl() { + if (TranslationUnitDecl *TUD = dyn_cast(this)) + return TUD; + DeclContext *DC = getDeclContext(); assert(DC && "This decl is not contained in a translation unit!");