Skip to content

[6.0][Caching] Teach libSwiftScan to replay all diagnostics kinds #74819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions include/swift/Frontend/DiagnosticHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//===--- DiagnosticHelper.h - Diagnostic Helper -----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file exposes helper class to emit diagnostics from swift-frontend.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_FRONTEND_DIAGNOSTIC_HELPER_H
#define SWIFT_FRONTEND_DIAGNOSTIC_HELPER_H

#include "swift/Basic/LLVM.h"
#include "llvm/Support/raw_ostream.h"

namespace swift {
class CompilerInstance;
class CompilerInvocation;

class DiagnosticHelper {
private:
class Implementation;
Implementation &Impl;

public:
/// Create a DiagnosticHelper class to emit diagnostics from frontend actions.
/// OS is the stream to print diagnostics. useQuasiPID determines if using
/// real PID when priting parseable output.
static DiagnosticHelper create(CompilerInstance &instance,
llvm::raw_pwrite_stream &OS = llvm::errs(),
bool useQuasiPID = false);

/// Initialized all DiagConsumers and add to the CompilerInstance.
void initDiagConsumers(CompilerInvocation &invocation);

/// Begin emitting the message, specifically the parseable output message.
void beginMessage(CompilerInvocation &invocation,
ArrayRef<const char *> args);

/// End emitting all diagnostics. This has to be called if beginMessage() is
/// called.
void endMessage(int retCode);

/// Set if printing output should be suppressed.
void setSuppressOutput(bool suppressOutput);

/// Helper function to emit fatal error.
void diagnoseFatalError(const char *reason, bool shouldCrash);

DiagnosticHelper(const DiagnosticHelper &) = delete;
DiagnosticHelper(DiagnosticHelper &&) = delete;
DiagnosticHelper &operator=(const DiagnosticHelper &) = delete;
DiagnosticHelper &operator=(DiagnosticHelper &&) = delete;
~DiagnosticHelper();

private:
DiagnosticHelper(CompilerInstance &instance, llvm::raw_pwrite_stream &OS,
bool useQuasiPID);
};

} // namespace swift

#endif
1 change: 1 addition & 0 deletions lib/Frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_swift_host_library(swiftFrontend STATIC
CompileJobCacheResult.cpp
CompilerInvocation.cpp
DependencyVerifier.cpp
DiagnosticHelper.cpp
DiagnosticVerifier.cpp
Frontend.cpp
FrontendInputsAndOutputs.cpp
Expand Down
Loading