File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 33
33
34
34
namespace swift {
35
35
36
- typedef const void *OpaqueSyntaxNode;
37
36
class SyntaxParsingContext ;
38
37
39
38
// / Represents a raw syntax node formed by the parser.
Original file line number Diff line number Diff line change 20
20
21
21
#include " swift/Basic/LLVM.h"
22
22
#include " swift/Basic/SourceLoc.h"
23
+ #include " swift/Subsystems.h"
24
+ #include " llvm/ADT/PointerIntPair.h"
23
25
#include " llvm/Support/Allocator.h"
24
26
25
27
namespace swift {
@@ -34,8 +36,6 @@ class SourceFileSyntax;
34
36
enum class SyntaxKind : uint16_t ;
35
37
}
36
38
37
- typedef const void *OpaqueSyntaxNode;
38
-
39
39
// MARK: - Helper types
40
40
41
41
// / A syntax node that can either be deferred or recorded. The actual data is
@@ -51,15 +51,14 @@ class RecordedOrDeferredNode {
51
51
};
52
52
53
53
private:
54
- OpaqueSyntaxNode Opaque;
55
- Kind NodeKind;
54
+ llvm::PointerIntPair<OpaqueSyntaxNode, 2 , Kind> Data;
56
55
57
56
public:
58
57
RecordedOrDeferredNode (OpaqueSyntaxNode Node, Kind NodeKind)
59
- : Opaque (Node), NodeKind( NodeKind) {}
58
+ : Data (Node, NodeKind) {}
60
59
61
- OpaqueSyntaxNode getOpaque () const { return Opaque ; }
62
- Kind getKind () const { return NodeKind ; }
60
+ OpaqueSyntaxNode getOpaque () const { return Data. getPointer () ; }
61
+ Kind getKind () const { return Data. getInt () ; }
63
62
};
64
63
65
64
// / Data returned from \c getDeferredChild. This is enough data to construct
Original file line number Diff line number Diff line change @@ -53,6 +53,12 @@ namespace swift {
53
53
class IRGenOptions ;
54
54
class LangOptions ;
55
55
class ModuleDecl ;
56
+ // / A opaque syntax node created by a \c SyntaxParseAction, whose contents
57
+ // / must be interpreted by the \c SyntaxParseAction which created it.
58
+ // / Requires the two low bits to be 0, so that it can be stored in an
59
+ // / \c llvm::PointerIntPair. This is in particular guaranteed for pointers
60
+ // / to C/C++ objects and for pointers that were generated by Swift and passed
61
+ // / to the compiler via a C API (in particular \c CLibParseActions ).
56
62
typedef const void *OpaqueSyntaxNode;
57
63
class Parser ;
58
64
class SerializationOptions ;
You can’t perform that action at this time.
0 commit comments