-
- // Lazily allocate to avoid nasty initialization order dependencies
- if (AnalysisGroupInfoMap == 0)
- AnalysisGroupInfoMap = new std::map<const PassInfo *,AnalysisGroupInfo>();
-
- AnalysisGroupInfo &AGI = (*AnalysisGroupInfoMap)[InterfaceInfo];
- assert(AGI.Implementations.count(ImplementationInfo) == 0 &&
- "Cannot add a pass to the same analysis group more than once!");
- AGI.Implementations.insert(ImplementationInfo);
- if (isDefault) {
- assert(AGI.DefaultImpl == 0 && InterfaceInfo->getNormalCtor() == 0 &&
- "Default implementation for analysis group already specified!");
- assert(ImplementationInfo->getNormalCtor() &&
- "Cannot specify pass as default if it does not have a default ctor");
- AGI.DefaultImpl = ImplementationInfo;
- InterfaceInfo->setNormalCtor(ImplementationInfo->getNormalCtor());
- }
- }
-}
-
-void RegisterAGBase::setGroupName(const char *Name) {
- assert(InterfaceInfo->getPassName()[0] == 0 && "Interface Name already set!");
- InterfaceInfo->setPassName(Name);
-}
-
-RegisterAGBase::~RegisterAGBase() {
- if (ImplementationInfo) {
- assert(AnalysisGroupInfoMap && "Inserted into map, but map doesn't exist?");
- AnalysisGroupInfo &AGI = (*AnalysisGroupInfoMap)[InterfaceInfo];
-
- assert(AGI.Implementations.count(ImplementationInfo) &&
- "Pass not a member of analysis group?");
-
- if (AGI.DefaultImpl == ImplementationInfo)
- AGI.DefaultImpl = 0;
-
- AGI.Implementations.erase(ImplementationInfo);
-
- // Last member of this analysis group? Unregister PassInfo, delete map entry
- if (AGI.Implementations.empty()) {
- assert(AGI.DefaultImpl == 0 &&
- "Default implementation didn't unregister?");
- AnalysisGroupInfoMap->erase(InterfaceInfo);
- if (AnalysisGroupInfoMap->empty()) { // Delete map if empty
- delete AnalysisGroupInfoMap;
- AnalysisGroupInfoMap = 0;
- }
- }