|
51 | 51 | using namespace swift; |
52 | 52 | using namespace Lowering; |
53 | 53 |
|
| 54 | +llvm::cl::list<std::string> PrintFunctionAST( |
| 55 | + "print-function-ast", llvm::cl::CommaSeparated, |
| 56 | + llvm::cl::desc("Only print out the ast for this function")); |
| 57 | + |
54 | 58 | //===----------------------------------------------------------------------===// |
55 | 59 | // SILGenModule Class implementation |
56 | 60 | //===----------------------------------------------------------------------===// |
@@ -879,6 +883,22 @@ void SILGenModule::visit(Decl *D) { |
879 | 883 | ASTVisitor::visit(D); |
880 | 884 | } |
881 | 885 |
|
| 886 | +static bool isInPrintFunctionList(AbstractFunctionDecl *fd) { |
| 887 | + if (PrintFunctionAST.empty()) { |
| 888 | + return false; |
| 889 | + } |
| 890 | + auto fnName = SILDeclRef(fd).mangle(); |
| 891 | + for (const std::string &printFnName : PrintFunctionAST) { |
| 892 | + if (printFnName == fnName) |
| 893 | + return true; |
| 894 | + if (!printFnName.empty() && printFnName[0] != '$' && !fnName.empty() && |
| 895 | + fnName[0] == '$' && printFnName == fnName.substr(1)) { |
| 896 | + return true; |
| 897 | + } |
| 898 | + } |
| 899 | + return false; |
| 900 | +} |
| 901 | + |
882 | 902 | void SILGenModule::visitFuncDecl(FuncDecl *fd) { emitFunction(fd); } |
883 | 903 |
|
884 | 904 | void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) { |
@@ -1477,6 +1497,11 @@ void SILGenModule::emitDifferentiabilityWitness( |
1477 | 1497 | } |
1478 | 1498 |
|
1479 | 1499 | void SILGenModule::emitAbstractFuncDecl(AbstractFunctionDecl *AFD) { |
| 1500 | + if (isInPrintFunctionList(AFD)) { |
| 1501 | + auto &out = llvm::errs(); |
| 1502 | + AFD->dump(out); |
| 1503 | + } |
| 1504 | + |
1480 | 1505 | // Emit default arguments and property wrapper initializers. |
1481 | 1506 | emitArgumentGenerators(AFD, AFD->getParameters()); |
1482 | 1507 |
|
|
0 commit comments