ASTPrinter: never synthesize extensions for raw types of enum decls.

Even thought raw types are specified in inheritance clauses, their
members are not usable through an enum instance. Thus, there is no
point to synthesize their members.
This commit is contained in:
Xi Ge
2016-04-22 22:46:35 -07:00
parent d39e7d9416
commit c4d7b1a185
3 changed files with 2779 additions and 7643 deletions

View File

@@ -528,6 +528,14 @@ struct SynthesizedExtensionAnalyzer::Implementation {
return InfoMap; return InfoMap;
} }
static bool isEnumRawType(const Decl* D, TypeLoc TL) {
assert (TL.getType());
if (auto ED = dyn_cast<EnumDecl>(D)) {
return ED->hasRawType() && ED->getRawType()->isEqual(TL.getType());
}
return false;
}
std::unique_ptr<ExtensionInfoMap> std::unique_ptr<ExtensionInfoMap>
collectSynthesizedExtensionInfo(MergeGroupVector &AllGroups) { collectSynthesizedExtensionInfo(MergeGroupVector &AllGroups) {
if (Target->getKind() == DeclKind::Protocol) { if (Target->getKind() == DeclKind::Protocol) {
@@ -544,6 +552,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
} }
}; };
for (auto TL : Target->getInherited()) { for (auto TL : Target->getInherited()) {
if (!isEnumRawType(Target, TL))
addTypeLocNominal(TL); addTypeLocNominal(TL);
} }
while (!Unhandled.empty()) { while (!Unhandled.empty()) {
@@ -558,6 +567,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
MergeInfoMap.insert({E, Pair.second}); MergeInfoMap.insert({E, Pair.second});
} }
for (auto TL : Back->getInherited()) { for (auto TL : Back->getInherited()) {
if (!isEnumRawType(Target, TL))
addTypeLocNominal(TL); addTypeLocNominal(TL);
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff