mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] Fix cursor-info crash with mismatched pre/post callbacks
The problem was that shouldPrint returned true, but shouldPrintInContext returned false, so we called printDeclPost without ever printing anything and therefore never calling the pending printDeclPre. Also remove the avoidPrintDeclPost in the annotation printer, since it was incorrectly assuming that avoidPrintDeclPost was paired with printDeclPre (it's not clear to me that it isn't sometimes paired though...). Future work: remove or properly document the difference between the two shouldPrint* variants; and ensure that callbacks will always be paired even if we don't end up printing anything. Also verify that avoidPrintDeclPost behaves correctly with respect to printDeclPre being called (or not).
This commit is contained in:
@@ -122,10 +122,6 @@ private:
|
||||
DeclStack.pop_back();
|
||||
closeTag(getTagForDecl(D, /*isRef=*/false));
|
||||
}
|
||||
void avoidPrintDeclPost(const Decl *D) override {
|
||||
assert(DeclStack.back() == D && "unmatched printDeclPre");
|
||||
DeclStack.pop_back();
|
||||
}
|
||||
|
||||
void printDeclLoc(const Decl *D) override {
|
||||
openTag(getDeclNameTagForDecl(D));
|
||||
|
||||
Reference in New Issue
Block a user