diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-07-04 17:03:33 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-07-04 17:03:33 +0000 |
commit | ee3096a2d3092892d4c6f607a6323d9409714ed5 (patch) | |
tree | 6a556ebb22a4b8eaeb391e2e3c76abf416b7daa1 | |
parent | 2c7886ddec1e2cee68daee9866637d2e02f434ef (diff) |
CXXRecordDecl: Split getBases/getVBases into a slow and a fast path.
This avoids costly computation of getASTContext() and drops the header
dependency from DeclCXX.h to ASTContext.h.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159716 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/DeclCXX.h | 12 | ||||
-rw-r--r-- | lib/AST/DeclCXX.cpp | 8 |
2 files changed, 18 insertions, 2 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 8fde3ed257..b7854feae1 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -541,13 +541,21 @@ class CXXRecordDecl : public RecordDecl { /// \brief Retrieve the set of direct base classes. CXXBaseSpecifier *getBases() const { - return Bases.get(Definition->getASTContext().getExternalSource()); + if (!Bases.isOffset()) + return Bases.get(0); + return getBasesSlowCase(); } /// \brief Retrieve the set of virtual base classes. CXXBaseSpecifier *getVBases() const { - return VBases.get(Definition->getASTContext().getExternalSource()); + if (!VBases.isOffset()) + return VBases.get(0); + return getVBasesSlowCase(); } + + private: + CXXBaseSpecifier *getBasesSlowCase() const; + CXXBaseSpecifier *getVBasesSlowCase() const; } *DefinitionData; /// \brief Describes a C++ closure type (generated by a lambda expression). diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 4de157e9f5..11a5260836 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -60,6 +60,14 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D) NumVBases(0), Bases(), VBases(), Definition(D), FirstFriend(0) { } +CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getBasesSlowCase() const { + return Bases.get(Definition->getASTContext().getExternalSource()); +} + +CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getVBasesSlowCase() const { + return VBases.get(Definition->getASTContext().getExternalSource()); +} + CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl) |