aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-06-30 02:34:53 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-06-30 02:34:53 +0000
commit9b34669c672e776a24616eb01cffcf7061356d26 (patch)
tree893a8451cc4251349d8370c3b52800ca93b16836 /lib/AST/DeclBase.cpp
parent40b598eea1310ec9ed554d56ce3e25b34c585458 (diff)
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
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp3
1 files changed, 3 insertions, 0 deletions
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<TranslationUnitDecl>(this))
+ return TUD;
+
DeclContext *DC = getDeclContext();
assert(DC && "This decl is not contained in a translation unit!");