Skip to content

Commit 624c9ea

Browse files
committed
Introduce separate header for SwiftCompilerSupport library.
This is more staging to move the compiler over to SwiftCompilerSupport.
1 parent 007e8f1 commit 624c9ea

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

Package.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ let package = Package(
127127
.target(
128128
name: "SwiftCompilerSupport",
129129
dependencies: [
130-
"SwiftSyntax", "SwiftParser", "SwiftDiagnostics", "SwiftOperators"]
130+
"SwiftSyntax", "SwiftParser", "SwiftDiagnostics", "SwiftOperators"],
131+
exclude: [
132+
"CMakeLists.txt",
133+
"SwiftCompilerSupport.h"
134+
]
131135
),
132136
.executableTarget(
133137
name: "lit-test-helper",
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*===----------------------- SwiftCompilerSupport.h -------------------------===
2+
3+
This source file is part of the Swift.org open source project
4+
5+
Copyright (c) 2014 - 2022 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+
#ifndef SWIFT_COMPILER_SUPPORT_H
13+
#define SWIFT_COMPILER_SUPPORT_H
14+
15+
#include <stddef.h>
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
/// Flags used to describe consistency checks that can be performed by
22+
/// the
23+
enum SwiftConsistencyCheckFlags {
24+
/// Ensure that the syntax tree produced by the parser fully reproduces the
25+
/// input source.
26+
SCC_RoundTrip = 0x01,
27+
28+
/// Check for the presence of parsing diagnostics.
29+
SCC_ParseDiagnostics = 0x02,
30+
31+
/// Perform sequence folding on the syntax tree.
32+
SCC_FoldSequences = 0x04,
33+
};
34+
35+
/// Entry point for the Swift compiler to use for consistency checking.
36+
///
37+
/// - Parameters:
38+
/// - bufferPtr: Pointer to the input buffer.
39+
/// - bufferLength: Length of the input buffer.
40+
/// - filename: The name of the source file, which is used only for diagnostics
41+
/// - flags: Flags that indicate what checks should be performed.
42+
/// 0x01: Perform round-trip checking.
43+
/// - Returns: 0 if all requested consistency checks passed, nonzero otherwise.
44+
int swift_parser_consistencyCheck(
45+
const char *buffer, ptrdiff_t bufferLength, const char *filename,
46+
unsigned int flags);
47+
48+
#ifdef __cplusplus
49+
}
50+
#endif
51+
52+
#endif /* SWIFT_COMPILER_SUPPORT_H */

0 commit comments

Comments
 (0)