[cfe-commits] r61116 - in /cfe/trunk: Driver/ASTConsumers.cpp lib/AST/Decl.cpp lib/Sema/SemaDecl.cpp
Douglas Gregor
dgregor at apple.com
Tue Dec 16 18:04:31 PST 2008
Author: dgregor
Date: Tue Dec 16 20:04:30 2008
New Revision: 61116
URL: http://llvm.org/viewvc/llvm-project?rev=61116&view=rev
Log:
Make sure that enumerators show up within the enumeration declaration. Fixes. PR clang/3220
Modified:
cfe/trunk/Driver/ASTConsumers.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=61116&r1=61115&r2=61116&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Tue Dec 16 20:04:30 2008
@@ -107,6 +107,13 @@
Out << D->getNameAsString();
}
Out << ";\n";
+ } else if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
+ Out << "enum " << ED->getNameAsString() << " {\n";
+ for (EnumDecl::enumerator_iterator E = ED->enumerator_begin(),
+ EEnd = ED->enumerator_end();
+ E != EEnd; ++E)
+ Out << " " << (*E)->getNameAsString() << ",\n";
+ Out << "};\n";
} else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
Out << "Read top-level tag decl: '" << TD->getNameAsString() << "'\n";
} else if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) {
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=61116&r1=61115&r2=61116&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Dec 16 20:04:30 2008
@@ -121,7 +121,6 @@
}
void EnumDecl::Destroy(ASTContext& C) {
- DeclContext::DestroyDecls(C);
Decl::Destroy(C);
}
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=61116&r1=61115&r2=61116&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec 16 20:04:30 2008
@@ -3185,6 +3185,12 @@
// Register this decl in the current scope stack.
PushOnScopeChains(New, S);
+
+ // Add this enumerator into the enum itself.
+ // FIXME: This means that the enumerator is stored in two
+ // DeclContexts. This is not a long-term solution.
+ New->setLexicalDeclContext(TheEnumDecl);
+ TheEnumDecl->addDecl(Context, New, true);
return New;
}
More information about the cfe-commits
mailing list