Remove IfConfigDecl from the AST

The swift-syntax tree retains information about the parsed #if
regions. Drop it from the semantic AST.
This commit is contained in:
Doug Gregor
2024-09-18 20:46:57 -07:00
parent d762dd53f8
commit 5b2520e379
38 changed files with 16 additions and 476 deletions

View File

@@ -2284,10 +2284,6 @@ bool ShouldPrintChecker::shouldPrint(const Decl *D,
return false;
}
if (isa<IfConfigDecl>(D)) {
return false;
}
return true;
}
@@ -3373,10 +3369,6 @@ void PrintAST::visitTopLevelCodeDecl(TopLevelCodeDecl *decl) {
printASTNodes(decl->getBody()->getElements(), /*NeedIndent=*/false);
}
void PrintAST::visitIfConfigDecl(IfConfigDecl *ICD) {
// Never printed
}
void PrintAST::visitPoundDiagnosticDecl(PoundDiagnosticDecl *PDD) {
/// TODO: Should we even print #error/#warning?
if (PDD->isError()) {
@@ -5533,8 +5525,6 @@ void PrintAST::visitSwitchStmt(SwitchStmt *stmt) {
for (auto N : stmt->getRawCases()) {
if (N.is<Stmt*>())
visit(cast<CaseStmt>(N.get<Stmt*>()));
else
visit(cast<IfConfigDecl>(N.get<Decl*>()));
Printer.printNewline();
}
indent();
@@ -5633,10 +5623,6 @@ bool Decl::shouldPrintInContext(const PrintOptions &PO) const {
}
}
if (isa<IfConfigDecl>(this)) {
return false;
}
// Print everything else.
return true;
}