From: Douglas Gregor Date: Tue, 22 Jun 2010 14:45:56 +0000 (+0000) Subject: When we ask for the enumerators of an EnumDecl, make sure we get them even if we... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e5abbe065ab7fb9e3b03b4d25fac3f2dd4b2389;p=clang When we ask for the enumerators of an EnumDecl, make sure we get them even if we have a EnumDecl that is not the definition of the enumeration git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106541 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 0561f75365..187b88d836 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -2011,11 +2011,17 @@ public: typedef specific_decl_iterator enumerator_iterator; enumerator_iterator enumerator_begin() const { - return enumerator_iterator(this->decls_begin()); + const EnumDecl *E = cast_or_null(getDefinition()); + if (!E) + E = this; + return enumerator_iterator(E->decls_begin()); } enumerator_iterator enumerator_end() const { - return enumerator_iterator(this->decls_end()); + const EnumDecl *E = cast_or_null(getDefinition()); + if (!E) + E = this; + return enumerator_iterator(E->decls_end()); } /// getPromotionType - Return the integer type that enumerators