|
26 | 26 | // can be reflected as source-breaking changes for API users. If they are,
|
27 | 27 | // the output of api-digester will include such changes.
|
28 | 28 |
|
| 29 | +#include "swift/Frontend/PrintingDiagnosticConsumer.h" |
29 | 30 | #include "swift/AST/DiagnosticsModuleDiffer.h"
|
30 | 31 | #include "swift/IDE/APIDigesterData.h"
|
31 | 32 | #include <functional>
|
@@ -209,6 +210,11 @@ static llvm::cl::opt<std::string>
|
209 | 210 | LocationFilter("location",
|
210 | 211 | llvm::cl::desc("Filter nodes with the given location."),
|
211 | 212 | llvm::cl::cat(Category));
|
| 213 | + |
| 214 | +static llvm::cl::opt<bool> |
| 215 | +CompilerStyleDiags("compiler-style-diags", |
| 216 | + llvm::cl::desc("Print compiler style diagnostics to stderr."), |
| 217 | + llvm::cl::cat(Category)); |
212 | 218 | } // namespace options
|
213 | 219 |
|
214 | 220 | namespace {
|
@@ -2114,9 +2120,11 @@ static int diagnoseModuleChange(SDKContext &Ctx, SDKNodeRoot *LeftModule,
|
2114 | 2120 | FileOS.reset(new llvm::raw_fd_ostream(OutputPath, EC, llvm::sys::fs::F_None));
|
2115 | 2121 | OS = FileOS.get();
|
2116 | 2122 | }
|
2117 |
| - ModuleDifferDiagsConsumer PDC(true, *OS); |
| 2123 | + std::unique_ptr<DiagnosticConsumer> pConsumer = options::CompilerStyleDiags ? |
| 2124 | + llvm::make_unique<PrintingDiagnosticConsumer>(): |
| 2125 | + llvm::make_unique<ModuleDifferDiagsConsumer>(true, *OS); |
2118 | 2126 |
|
2119 |
| - Ctx.getDiags().addConsumer(PDC); |
| 2127 | + Ctx.getDiags().addConsumer(*pConsumer); |
2120 | 2128 | TypeAliasDiffFinder(LeftModule, RightModule,
|
2121 | 2129 | Ctx.getTypeAliasUpdateMap()).search();
|
2122 | 2130 | PrunePass Prune(Ctx, std::move(ProtocolReqWhitelist));
|
@@ -2185,10 +2193,11 @@ static int generateMigrationScript(StringRef LeftPath, StringRef RightPath,
|
2185 | 2193 | return 1;
|
2186 | 2194 | }
|
2187 | 2195 | llvm::errs() << "Diffing: " << LeftPath << " and " << RightPath << "\n";
|
2188 |
| - |
2189 |
| - ModuleDifferDiagsConsumer PDC(false); |
| 2196 | + std::unique_ptr<DiagnosticConsumer> pConsumer = options::CompilerStyleDiags ? |
| 2197 | + llvm::make_unique<PrintingDiagnosticConsumer>(): |
| 2198 | + llvm::make_unique<ModuleDifferDiagsConsumer>(false); |
2190 | 2199 | SDKContext Ctx(Opts);
|
2191 |
| - Ctx.getDiags().addConsumer(PDC); |
| 2200 | + Ctx.getDiags().addConsumer(*pConsumer); |
2192 | 2201 |
|
2193 | 2202 | SwiftDeclCollector LeftCollector(Ctx);
|
2194 | 2203 | LeftCollector.deSerialize(LeftPath);
|
|
0 commit comments