aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-09-02 20:25:22 +0000
committerTed Kremenek <kremenek@apple.com>2008-09-02 20:25:22 +0000
commita39da065766bdfeee3421a2e71f60ae579170fef (patch)
treee081e84f806683bc54b907a1823d73ae61ae3c17 /lib/AST/Decl.cpp
parentdf91eca19bd9738abd9a3b84791f39750e27ad36 (diff)
RecordDecl:
- Added method 'isForwardDeclaration', a predicate method that returns true if a RecordDecl represents a forward declaration. - Added method 'getDefinitionDecl', a query method that returns a pointer to the RecordDecl that provides the actual definition of a struct/union. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55642 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp12
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,