diff options
| author | John McCall <rjmccall@apple.com> | 2010-05-21 01:17:40 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-05-21 01:17:40 +0000 |
| commit | 61925b03ccae097ec6516667d02d6838a2ec7181 (patch) | |
| tree | 45fa7a21ad9d99be7c35857b5338488716fd4206 /clang/lib/AST/Decl.cpp | |
| parent | b3b9c8ac483697cdd178ecfe814f31e85b912698 (diff) | |
| download | bcm5719-llvm-61925b03ccae097ec6516667d02d6838a2ec7181.tar.gz bcm5719-llvm-61925b03ccae097ec6516667d02d6838a2ec7181.zip | |
Introduce a method to get from an anonymous struct or union record declaration
to the associated object declaration.
llvm-svn: 104309
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 695a8b8b514..ffdcb471d08 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1627,6 +1627,17 @@ void RecordDecl::completeDefinition() { TagDecl::completeDefinition(); } +ValueDecl *RecordDecl::getAnonymousStructOrUnionObject() { + // Force the decl chain to come into existence properly. + if (!getNextDeclInContext()) getParent()->decls_begin(); + + assert(isAnonymousStructOrUnion()); + ValueDecl *D = cast<ValueDecl>(getNextDeclInContext()); + assert(D->getType()->isRecordType()); + assert(D->getType()->getAs<RecordType>()->getDecl() == this); + return D; +} + //===----------------------------------------------------------------------===// // BlockDecl Implementation //===----------------------------------------------------------------------===// |

