[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:
Ben Langmuir
2016-02-25 19:31:38 -08:00
parent 0448b73e8c
commit e9211c8e4f
3 changed files with 20 additions and 4 deletions

View File

@@ -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));