diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-12-06 20:50:05 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-12-06 20:50:05 +0000 |
commit | 71a26d8f82e0fed809441852ba13ff630e438dff (patch) | |
tree | 5951a2e6a22591bb34dc7790d8c567355a8cc346 | |
parent | 05e7ca3659157d4b81ed172ea2df123044de41ed (diff) | |
download | bcm5719-llvm-71a26d8f82e0fed809441852ba13ff630e438dff.tar.gz bcm5719-llvm-71a26d8f82e0fed809441852ba13ff630e438dff.zip |
Move helper onto CXXMethodDecl.
llvm-svn: 90716
-rw-r--r-- | clang/include/clang/AST/DeclCXX.h | 2 | ||||
-rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 19 | ||||
-rw-r--r-- | clang/lib/AST/RecordLayoutBuilder.cpp | 19 |
3 files changed, 23 insertions, 17 deletions
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 340096c9dc3..083284c9083 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -870,6 +870,8 @@ public: return getType()->getAs<FunctionProtoType>()->getTypeQuals(); } + bool hasInlineBody() const; + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= CXXMethod && D->getKind() <= CXXConversion; diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 5064ec5c737..766cb018145 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -644,6 +644,25 @@ QualType CXXMethodDecl::getThisType(ASTContext &C) const { return C.getPointerType(ClassTy); } +static bool MethodHasBody(const CXXMethodDecl *MD, const FunctionDecl *&fn) { + // Simple case: function has a body + if (MD->getBody(fn)) + return true; + + // Complex case: function is an instantiation of a function which has a + // body, but the definition hasn't been instantiated. + const FunctionDecl *PatternDecl = MD->getTemplateInstantiationPattern(); + if (PatternDecl && PatternDecl->getBody(fn)) + return true; + + return false; +} + +bool CXXMethodDecl::hasInlineBody() const { + const FunctionDecl *fn; + return MethodHasBody(this, fn) && !fn->isOutOfLine(); +} + CXXBaseOrMemberInitializer:: CXXBaseOrMemberInitializer(ASTContext &Context, DeclaratorInfo *DInfo, CXXConstructorDecl *C, diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 4c7b9119348..088673916f8 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -663,20 +663,6 @@ void ASTRecordLayoutBuilder::UpdateAlignment(unsigned NewAlignment) { Alignment = NewAlignment; } -static bool MethodHasBody(const CXXMethodDecl *MD, const FunctionDecl *&fn) { - // Simple case: function has a body - if (MD->getBody(fn)) - return true; - - // Complex case: function is an instantiation of a function which has a - // body, but the definition hasn't been instantiated. - const FunctionDecl *PatternDecl = MD->getTemplateInstantiationPattern(); - if (PatternDecl && PatternDecl->getBody(fn)) - return true; - - return false; -} - static const CXXMethodDecl *GetKeyFunction(const CXXRecordDecl *RD) { if (!RD->isDynamicClass()) return 0; @@ -695,9 +681,8 @@ static const CXXMethodDecl *GetKeyFunction(const CXXRecordDecl *RD) { // they don't have a body until they're defined. if (MD->isImplicit()) continue; - - const FunctionDecl *fn; - if (MethodHasBody(MD, fn) && !fn->isOutOfLine()) + + if (MD->hasInlineBody()) continue; // We found it. |