]> granicus.if.org Git - clang/commitdiff
When we ask for the enumerators of an EnumDecl, make sure we get them even if we...
authorDouglas Gregor <dgregor@apple.com>
Tue, 22 Jun 2010 14:45:56 +0000 (14:45 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 22 Jun 2010 14:45:56 +0000 (14:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106541 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h

index 0561f75365907448e02836ff71f5d03c40104dcf..187b88d8364dd0de49fd61e9fed997bf0af4391e 100644 (file)
@@ -2011,11 +2011,17 @@ public:
   typedef specific_decl_iterator<EnumConstantDecl> enumerator_iterator;
 
   enumerator_iterator enumerator_begin() const {
-    return enumerator_iterator(this->decls_begin());
+    const EnumDecl *E = cast_or_null<EnumDecl>(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<EnumDecl>(getDefinition());
+    if (!E)
+      E = this;
+    return enumerator_iterator(E->decls_end());
   }
 
   /// getPromotionType - Return the integer type that enumerators