diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-08-01 04:09:58 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-08-01 04:09:58 +0000 |
| commit | ab47ae3381aa2372009a9054260461c20324b555 (patch) | |
| tree | f5ccadad006085883dcc817623e97b79498d67da /utils/TableGen/Record.cpp | |
| parent | 7296fb04211123339473494d28807661b4fef9ff (diff) | |
Factor code out into a new getAllDerivedDefinitions method, which is generally useful
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7461 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
| -rw-r--r-- | utils/TableGen/Record.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index a54f8e238b..6dc409b1c2 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -468,3 +468,23 @@ std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK) { OS << "def " << *I->second; return OS; } + + +/// getAllDerivedDefinitions - This method returns all concrete definitions +/// that derive from the specified class name. If a class with the specified +/// name does not exist, an error is printed and true is returned. +bool RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName, + std::vector<Record*> &Defs) const { + Record *Class = Records.getClass(ClassName); + if (!Class) { + std::cerr << "ERROR: Couldn't find the '" << ClassName << "' class!\n"; + return true; + } + + for (std::map<std::string, Record*>::const_iterator I = getDefs().begin(), + E = getDefs().end(); I != E; ++I) + if (I->second->isSubClassOf(Class)) + Defs.push_back(I->second); + + return false; +} |
