@@ -154,8 +154,8 @@ class ABIDependencyEvaluator {
154
154
llvm::DenseSet<ModuleDecl *> visited;
155
155
156
156
// / Helper function to handle invariant violations as crashes in debug mode.
157
- void crashOnInvariantViolation (
158
- llvm::function_ref<void (llvm::raw_string_ostream &)> f) const ;
157
+ void
158
+ crashOnInvariantViolation ( llvm::function_ref<void (raw_ostream &)> f) const ;
159
159
160
160
// / Computes the ABI exports for \p importedModule and adds them to
161
161
// / \p module's ABI exports.
@@ -223,13 +223,13 @@ class ABIDependencyEvaluator {
223
223
// See [NOTE: Bailing-vs-crashing-in-trace-emission].
224
224
// TODO: Use PrettyStackTrace instead?
225
225
void ABIDependencyEvaluator::crashOnInvariantViolation (
226
- llvm::function_ref<void (llvm::raw_string_ostream &)> f) const {
226
+ llvm::function_ref<void (raw_ostream &)> f) const {
227
227
#ifndef NDEBUG
228
- std::string msg;
229
- llvm::raw_string_ostream os (msg);
228
+ SmallVector< char , 0 > msg;
229
+ llvm::raw_svector_ostream os (msg);
230
230
os << " error: invariant violation: " ;
231
231
f (os);
232
- llvm::report_fatal_error (os. str () );
232
+ llvm::report_fatal_error (msg );
233
233
#endif
234
234
}
235
235
@@ -256,7 +256,7 @@ void ABIDependencyEvaluator::reexposeImportedABI(ModuleDecl *module,
256
256
ModuleDecl *importedModule,
257
257
bool includeImportedModule) {
258
258
if (module == importedModule) {
259
- crashOnInvariantViolation ([&](llvm::raw_string_ostream &os) {
259
+ crashOnInvariantViolation ([&](raw_ostream &os) {
260
260
os << " module " ;
261
261
printModule (module, os);
262
262
os << " imports itself!\n " ;
@@ -266,7 +266,7 @@ void ABIDependencyEvaluator::reexposeImportedABI(ModuleDecl *module,
266
266
267
267
auto addToABIExportMap = [this ](ModuleDecl *module, ModuleDecl *reexport) {
268
268
if (module == reexport) {
269
- crashOnInvariantViolation ([&](llvm::raw_string_ostream &os) {
269
+ crashOnInvariantViolation ([&](raw_ostream &os) {
270
270
os << " expected module " ;
271
271
printModule (reexport, os);
272
272
os << " to not re-export itself\n " ;
@@ -409,7 +409,7 @@ void ABIDependencyEvaluator::computeABIDependenciesForModule(
409
409
if (moduleIter != searchStack.end ()) {
410
410
if (isFakeCycleThroughOverlay (moduleIter))
411
411
return ;
412
- crashOnInvariantViolation ([&](llvm::raw_string_ostream &os) {
412
+ crashOnInvariantViolation ([&](raw_ostream &os) {
413
413
os << " unexpected cycle in import graph!\n " ;
414
414
for (auto m : searchStack) {
415
415
printModule (m, os);
@@ -557,21 +557,6 @@ static void computeSwiftModuleTraceInfo(
557
557
const llvm::DenseMap<StringRef, ModuleDecl *> &pathToModuleDecl,
558
558
const DependencyTracker &depTracker, StringRef prebuiltCachePath,
559
559
std::vector<SwiftModuleTraceInfo> &traceInfo) {
560
-
561
- SmallString<256 > buffer;
562
-
563
- std::string errMsg;
564
- llvm::raw_string_ostream err (errMsg);
565
-
566
- // FIXME: Use PrettyStackTrace instead.
567
- auto errorUnexpectedPath =
568
- [&pathToModuleDecl](llvm::raw_string_ostream &errStream) {
569
- errStream << " The module <-> path mapping we have is:\n " ;
570
- for (auto &m : pathToModuleDecl)
571
- errStream << m.second ->getName () << " <-> " << m.first << ' \n ' ;
572
- llvm::report_fatal_error (errStream.str ());
573
- };
574
-
575
560
using namespace llvm ::sys;
576
561
577
562
auto computeAdjacentInterfacePath = [](SmallVectorImpl<char > &modPath) {
@@ -580,6 +565,7 @@ static void computeSwiftModuleTraceInfo(
580
565
path::replace_extension (modPath, swiftInterfaceExt);
581
566
};
582
567
568
+ SmallString<256 > buffer;
583
569
auto deps = depTracker.getDependencies ();
584
570
SmallVector<std::string, 16 > dependencies{deps.begin (), deps.end ()};
585
571
auto incrDeps = depTracker.getIncrementalDependencyPaths ();
@@ -643,8 +629,14 @@ static void computeSwiftModuleTraceInfo(
643
629
// built a swiftmodule from that interface, so we should have that
644
630
// filename available.
645
631
if (isSwiftinterface) {
632
+ // FIXME: Use PrettyStackTrace instead.
633
+ SmallVector<char , 0 > errMsg;
634
+ llvm::raw_svector_ostream err (errMsg);
646
635
err << " Unexpected path for swiftinterface file:\n " << depPath << " \n " ;
647
- errorUnexpectedPath (err);
636
+ err << " The module <-> path mapping we have is:\n " ;
637
+ for (auto &m : pathToModuleDecl)
638
+ err << m.second ->getName () << " <-> " << m.first << ' \n ' ;
639
+ llvm::report_fatal_error (errMsg);
648
640
}
649
641
650
642
// Skip cached modules in the prebuilt cache. We will add the corresponding
0 commit comments