Skip to content

Introduce separate header for SwiftCompilerSupport library. #813

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
merged 1 commit into from
Sep 18, 2022
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
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ let package = Package(
.target(
name: "SwiftCompilerSupport",
dependencies: [
"SwiftSyntax", "SwiftParser", "SwiftDiagnostics", "SwiftOperators"]
"SwiftSyntax", "SwiftParser", "SwiftDiagnostics", "SwiftOperators"],
exclude: [
"CMakeLists.txt",
"SwiftCompilerSupport.h"
]
),
.executableTarget(
name: "lit-test-helper",
Expand Down
52 changes: 52 additions & 0 deletions Sources/SwiftCompilerSupport/SwiftCompilerSupport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*===----------------------- SwiftCompilerSupport.h -------------------------===

This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2022 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

===----------------------------------------------------------------------===*/
#ifndef SWIFT_COMPILER_SUPPORT_H
#define SWIFT_COMPILER_SUPPORT_H

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

/// Flags used to describe consistency checks that can be performed by
/// the
enum SwiftConsistencyCheckFlags {
/// Ensure that the syntax tree produced by the parser fully reproduces the
/// input source.
SCC_RoundTrip = 0x01,

/// Check for the presence of parsing diagnostics.
SCC_ParseDiagnostics = 0x02,

/// Perform sequence folding on the syntax tree.
SCC_FoldSequences = 0x04,
};

/// Entry point for the Swift compiler to use for consistency checking.
///
/// - Parameters:
/// - bufferPtr: Pointer to the input buffer.
/// - bufferLength: Length of the input buffer.
/// - filename: The name of the source file, which is used only for diagnostics
/// - flags: Flags that indicate what checks should be performed.
/// 0x01: Perform round-trip checking.
/// - Returns: 0 if all requested consistency checks passed, nonzero otherwise.
int swift_parser_consistencyCheck(
const char *buffer, ptrdiff_t bufferLength, const char *filename,
unsigned int flags);

#ifdef __cplusplus
}
#endif

#endif /* SWIFT_COMPILER_SUPPORT_H */