mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[cursor-info] Fix crash due to invalid base type in the PrintOptions passed to the AST printer
Resolves rdar://problem/30248264 Also added test cases for rdar://problem/30292429 (already fixed)
This commit is contained in:
@@ -455,7 +455,7 @@ template <typename FnTy>
|
||||
void walkRelatedDecls(const ValueDecl *VD, const FnTy &Fn) {
|
||||
llvm::SmallDenseMap<DeclName, unsigned, 16> NamesSeen;
|
||||
++NamesSeen[VD->getFullName()];
|
||||
SmallVector<ValueDecl *, 8> RelatedDecls;
|
||||
SmallVector<UnqualifiedLookupResult, 8> RelatedDecls;
|
||||
|
||||
if (isa<ParamDecl>(VD))
|
||||
return; // Parameters don't have interesting related declarations.
|
||||
@@ -473,13 +473,16 @@ void walkRelatedDecls(const ValueDecl *VD, const FnTy &Fn) {
|
||||
|
||||
if (RelatedVD != VD) {
|
||||
++NamesSeen[RelatedVD->getFullName()];
|
||||
RelatedDecls.push_back(RelatedVD);
|
||||
RelatedDecls.push_back(result);
|
||||
}
|
||||
}
|
||||
|
||||
// Now provide the results along with whether the name is duplicate or not.
|
||||
for (auto RelatedVD : RelatedDecls) {
|
||||
Fn(RelatedVD, NamesSeen[RelatedVD->getFullName()] > 1);
|
||||
ValueDecl *OriginalBase = VD->getDeclContext()->getAsNominalTypeOrNominalTypeExtensionContext();
|
||||
for (auto Related : RelatedDecls) {
|
||||
ValueDecl *RelatedVD = Related.getValueDecl();
|
||||
bool SameBase = Related.getBaseDecl() && Related.getBaseDecl() == OriginalBase;
|
||||
Fn(RelatedVD, SameBase, NamesSeen[RelatedVD->getFullName()] > 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -741,7 +744,7 @@ static bool passCursorInfoForDecl(const ValueDecl *VD,
|
||||
});
|
||||
|
||||
DelayedStringRetriever RelDeclsStream(SS);
|
||||
walkRelatedDecls(VD, [&](const ValueDecl *RelatedDecl, bool DuplicateName) {
|
||||
walkRelatedDecls(VD, [&](const ValueDecl *RelatedDecl, bool UseOriginalBase, bool DuplicateName) {
|
||||
RelDeclsStream.startPiece();
|
||||
{
|
||||
RelDeclsStream<<"<RelatedName usr=\"";
|
||||
@@ -755,7 +758,7 @@ static bool passCursorInfoForDecl(const ValueDecl *VD,
|
||||
PO.SkipIntroducerKeywords = true;
|
||||
PO.ArgAndParamPrinting = PrintOptions::ArgAndParamPrintingMode::ArgumentOnly;
|
||||
XMLEscapingPrinter Printer(RelDeclsStream);
|
||||
if (BaseType) {
|
||||
if (UseOriginalBase && BaseType) {
|
||||
PO.setBaseType(BaseType);
|
||||
PO.PrintAsMember = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user