diff options
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index c2ae5d91ab..4b4aa65f90 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -160,6 +160,18 @@ RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC, return new (Mem) RecordDecl(DK, DC, L, Id, PrevDecl); } +/// getDefinitionDecl - Returns the RecordDecl for the struct/union that +/// represents the actual definition (i.e., not a forward declaration). +/// This method returns NULL if no such RecordDecl exists. +const RecordDecl* RecordDecl::getDefinitionDecl() const { + const RecordDecl* R = this; + + for (RecordDecl* N = R->NextDecl; N; N = R->NextDecl) + R = N; + + return R->Members ? R : 0; +} + FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, SourceLocation L, |