summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-05-16 23:58:37 +0000
committerAnders Carlsson <andersca@mac.com>2009-05-16 23:58:37 +0000
commit36d87e179aaa2d4b0af403a81c4fb5747ba277b7 (patch)
tree824f8112357f3aaae1d7d2e5d62780dc220362d8 /clang/lib/AST
parent15af3ee6a9f145332b29cb5d3d40746df17a5f07 (diff)
downloadbcm5719-llvm-36d87e179aaa2d4b0af403a81c4fb5747ba277b7.tar.gz
bcm5719-llvm-36d87e179aaa2d4b0af403a81c4fb5747ba277b7.zip
Add setters/getters to CXXMethodDecl so it can keep track of which virtual member functions it overrides (if any)
llvm-svn: 71968
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/DeclCXX.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 361fef0325d..30d76cb9e3d 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -194,6 +194,47 @@ CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
return new (C) CXXMethodDecl(CXXMethod, RD, L, N, T, isStatic, isInline);
}
+
+typedef llvm::DenseMap<const CXXMethodDecl*,
+ std::vector<const CXXMethodDecl *> *>
+ OverriddenMethodsMapTy;
+
+static OverriddenMethodsMapTy *OverriddenMethods = 0;
+
+void CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *MD) {
+ // FIXME: The CXXMethodDecl dtor needs to remove and free the entry.
+
+ if (!OverriddenMethods)
+ OverriddenMethods = new OverriddenMethodsMapTy();
+
+ std::vector<const CXXMethodDecl *> *&Methods = (*OverriddenMethods)[this];
+ if (!Methods)
+ Methods = new std::vector<const CXXMethodDecl *>;
+
+ Methods->push_back(MD);
+}
+
+CXXMethodDecl::method_iterator CXXMethodDecl::begin_overridden_methods() const {
+ if (!OverriddenMethods)
+ return 0;
+
+ OverriddenMethodsMapTy::iterator it = OverriddenMethods->find(this);
+ if (it == OverriddenMethods->end())
+ return 0;
+ return &(*it->second)[0];
+}
+
+CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const {
+ if (!OverriddenMethods)
+ return 0;
+
+ OverriddenMethodsMapTy::iterator it = OverriddenMethods->find(this);
+ if (it == OverriddenMethods->end())
+ return 0;
+
+ return &(*it->second)[it->second->size()];
+}
+
QualType CXXMethodDecl::getThisType(ASTContext &C) const {
// C++ 9.3.2p1: The type of this in a member function of a class X is X*.
// If the member function is declared const, the type of this is const X*,
OpenPOWER on IntegriCloud