diff options
author | Dan Gohman <gohman@apple.com> | 2008-03-13 01:48:32 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-03-13 01:48:32 +0000 |
commit | 0961ec1afe336a0a4f523455c25f5d5edc8d3ee1 (patch) | |
tree | b2e8c2ce6c6d72c79366cc7c9eb94c2dcbc172af /lib/VMCore/PassManager.cpp | |
parent | c2f12ab5e5258a949c0cfff074bf57fe0c08d4e5 (diff) | |
download | external_llvm-0961ec1afe336a0a4f523455c25f5d5edc8d3ee1.zip external_llvm-0961ec1afe336a0a4f523455c25f5d5edc8d3ee1.tar.gz external_llvm-0961ec1afe336a0a4f523455c25f5d5edc8d3ee1.tar.bz2 |
Change PMTopLevelManager's PassManagers vector element type from
Pass* to PMDataManager*. PMDataManager is more specific than Pass,
so this more accurately describes the objects that are being stored.
This eliminates the need for several dynamic_casts to PMDataManager*.
It does introduce one dynamic_cast though, in dumpPasses(). Give
this one a comment describing why a dynamic_cast is being used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48315 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/PassManager.cpp')
-rw-r--r-- | lib/VMCore/PassManager.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 275e0ae..614ace3 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -455,10 +455,9 @@ Pass *PMTopLevelManager::findAnalysisPass(AnalysisID AID) { Pass *P = NULL; // Check pass managers - for (std::vector<Pass *>::iterator I = PassManagers.begin(), + for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(), E = PassManagers.end(); P == NULL && I != E; ++I) { - PMDataManager *PMD = dynamic_cast<PMDataManager *>(*I); - assert(PMD && "This is not a PassManager"); + PMDataManager *PMD = *I; P = PMD->findAnalysisPass(AID, false); } @@ -496,9 +495,13 @@ void PMTopLevelManager::dumpPasses() const { ImmutablePasses[i]->dumpPassStructure(0); } - for (std::vector<Pass *>::const_iterator I = PassManagers.begin(), + // Every class that derives from PMDataManager also derives from Pass + // (sometimes indirectly), but there's no inheritance relationship + // between PMDataManager and Pass, so we have to dynamic_cast to get + // from a PMDataManager* to a Pass*. + for (std::vector<PMDataManager *>::const_iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) - (*I)->dumpPassStructure(1); + dynamic_cast<Pass *>(*I)->dumpPassStructure(1); } void PMTopLevelManager::dumpArguments() const { @@ -507,10 +510,9 @@ void PMTopLevelManager::dumpArguments() const { return; cerr << "Pass Arguments: "; - for (std::vector<Pass *>::const_iterator I = PassManagers.begin(), + for (std::vector<PMDataManager *>::const_iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) { - PMDataManager *PMD = dynamic_cast<PMDataManager *>(*I); - assert(PMD && "This is not a PassManager"); + PMDataManager *PMD = *I; PMD->dumpPassArguments(); } cerr << "\n"; @@ -518,10 +520,9 @@ void PMTopLevelManager::dumpArguments() const { void PMTopLevelManager::initializeAllAnalysisInfo() { - for (std::vector<Pass *>::iterator I = PassManagers.begin(), + for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) { - PMDataManager *PMD = dynamic_cast<PMDataManager *>(*I); - assert(PMD && "This is not a PassManager"); + PMDataManager *PMD = *I; PMD->initializeAnalysisInfo(); } @@ -533,7 +534,7 @@ void PMTopLevelManager::initializeAllAnalysisInfo() { /// Destructor PMTopLevelManager::~PMTopLevelManager() { - for (std::vector<Pass *>::iterator I = PassManagers.begin(), + for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) delete *I; |