ASTPrinter: Pass the bracket options to pre and post printing callbacks.

Need this for rdar://24912860
This commit is contained in:
Xi Ge
2016-03-22 11:34:15 -07:00
parent f79a741a7d
commit 33c53a12eb
9 changed files with 69 additions and 51 deletions

View File

@@ -46,8 +46,8 @@ public:
ClangLoader(ClangLoader) {}
private:
void printDeclPre(const Decl *D) override;
void printDeclPost(const Decl *D) override;
void printDeclPre(const Decl *D, Optional<BracketOptions> Bracket) override;
void printDeclPost(const Decl *D, Optional<BracketOptions> Bracket) override;
void avoidPrintDeclPost(const Decl *D) override;
// Forwarding implementations.
@@ -76,13 +76,15 @@ private:
return OtherPrinter.printModuleRef(Mod, Name);
}
void printSynthesizedExtensionPre(const ExtensionDecl *ED,
const NominalTypeDecl *NTD) override {
return OtherPrinter.printSynthesizedExtensionPre(ED, NTD);
const NominalTypeDecl *NTD,
Optional<BracketOptions> Bracket) override {
return OtherPrinter.printSynthesizedExtensionPre(ED, NTD, Bracket);
}
void printSynthesizedExtensionPost(const ExtensionDecl *ED,
const NominalTypeDecl *NTD) override {
return OtherPrinter.printSynthesizedExtensionPost(ED, NTD);
const NominalTypeDecl *NTD,
Optional<BracketOptions> Bracket) override {
return OtherPrinter.printSynthesizedExtensionPost(ED, NTD, Bracket);
}
void printStructurePre(PrintStructureKind Kind, const Decl *D) override {
@@ -706,7 +708,8 @@ void ClangCommentPrinter::avoidPrintDeclPost(const Decl *D) {
setResumeOffset(FID, SM.getFileOffset(Loc));
}
void ClangCommentPrinter::printDeclPre(const Decl *D) {
void ClangCommentPrinter::printDeclPre(const Decl *D,
Optional<BracketOptions> Bracket) {
// Skip parameters, since we do not gracefully handle nested declarations on a
// single line.
// FIXME: we should fix that, since it also affects struct members, etc.
@@ -720,11 +723,12 @@ void ClangCommentPrinter::printDeclPre(const Decl *D) {
updateLastEntityLine(ClangN.getSourceRange().getBegin());
}
}
return OtherPrinter.printDeclPre(D);
return OtherPrinter.printDeclPre(D, Bracket);
}
void ClangCommentPrinter::printDeclPost(const Decl *D) {
OtherPrinter.printDeclPost(D);
void ClangCommentPrinter::printDeclPost(const Decl *D,
Optional<BracketOptions> Bracket) {
OtherPrinter.printDeclPost(D, Bracket);
// Skip parameters; see printDeclPre().
if (isa<ParamDecl>(D))