Skip to content

Commit 6dea6b7

Browse files
Merge pull request #74819 from cachemeifyoucan/eng/PR-129015959-swift-6.0
[6.0][Caching] Teach libSwiftScan to replay all diagnostics kinds
2 parents b691cce + 8322f5f commit 6dea6b7

File tree

9 files changed

+767
-463
lines changed

9 files changed

+767
-463
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//===--- DiagnosticHelper.h - Diagnostic Helper -----------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file exposes helper class to emit diagnostics from swift-frontend.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_FRONTEND_DIAGNOSTIC_HELPER_H
18+
#define SWIFT_FRONTEND_DIAGNOSTIC_HELPER_H
19+
20+
#include "swift/Basic/LLVM.h"
21+
#include "llvm/Support/raw_ostream.h"
22+
23+
namespace swift {
24+
class CompilerInstance;
25+
class CompilerInvocation;
26+
27+
class DiagnosticHelper {
28+
private:
29+
class Implementation;
30+
Implementation &Impl;
31+
32+
public:
33+
/// Create a DiagnosticHelper class to emit diagnostics from frontend actions.
34+
/// OS is the stream to print diagnostics. useQuasiPID determines if using
35+
/// real PID when priting parseable output.
36+
static DiagnosticHelper create(CompilerInstance &instance,
37+
llvm::raw_pwrite_stream &OS = llvm::errs(),
38+
bool useQuasiPID = false);
39+
40+
/// Initialized all DiagConsumers and add to the CompilerInstance.
41+
void initDiagConsumers(CompilerInvocation &invocation);
42+
43+
/// Begin emitting the message, specifically the parseable output message.
44+
void beginMessage(CompilerInvocation &invocation,
45+
ArrayRef<const char *> args);
46+
47+
/// End emitting all diagnostics. This has to be called if beginMessage() is
48+
/// called.
49+
void endMessage(int retCode);
50+
51+
/// Set if printing output should be suppressed.
52+
void setSuppressOutput(bool suppressOutput);
53+
54+
/// Helper function to emit fatal error.
55+
void diagnoseFatalError(const char *reason, bool shouldCrash);
56+
57+
DiagnosticHelper(const DiagnosticHelper &) = delete;
58+
DiagnosticHelper(DiagnosticHelper &&) = delete;
59+
DiagnosticHelper &operator=(const DiagnosticHelper &) = delete;
60+
DiagnosticHelper &operator=(DiagnosticHelper &&) = delete;
61+
~DiagnosticHelper();
62+
63+
private:
64+
DiagnosticHelper(CompilerInstance &instance, llvm::raw_pwrite_stream &OS,
65+
bool useQuasiPID);
66+
};
67+
68+
} // namespace swift
69+
70+
#endif

lib/Frontend/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ add_swift_host_library(swiftFrontend STATIC
1010
CompileJobCacheResult.cpp
1111
CompilerInvocation.cpp
1212
DependencyVerifier.cpp
13+
DiagnosticHelper.cpp
1314
DiagnosticVerifier.cpp
1415
Frontend.cpp
1516
FrontendInputsAndOutputs.cpp

0 commit comments

Comments
 (0)