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 3333
3434namespace swift {
3535
36- typedef const void *OpaqueSyntaxNode;
3736class SyntaxParsingContext ;
3837
3938// / Represents a raw syntax node formed by the parser.
Original file line number Diff line number Diff line change 2020
2121#include " swift/Basic/LLVM.h"
2222#include " swift/Basic/SourceLoc.h"
23+ #include " swift/Subsystems.h"
24+ #include " llvm/ADT/PointerIntPair.h"
2325#include " llvm/Support/Allocator.h"
2426
2527namespace swift {
@@ -34,8 +36,6 @@ class SourceFileSyntax;
3436enum class SyntaxKind : uint16_t ;
3537}
3638
37- typedef const void *OpaqueSyntaxNode;
38-
3939// MARK: - Helper types
4040
4141// / A syntax node that can either be deferred or recorded. The actual data is
@@ -51,15 +51,14 @@ class RecordedOrDeferredNode {
5151 };
5252
5353private:
54- OpaqueSyntaxNode Opaque;
55- Kind NodeKind;
54+ llvm::PointerIntPair<OpaqueSyntaxNode, 2 , Kind> Data;
5655
5756public:
5857 RecordedOrDeferredNode (OpaqueSyntaxNode Node, Kind NodeKind)
59- : Opaque (Node), NodeKind( NodeKind) {}
58+ : Data (Node, NodeKind) {}
6059
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 () ; }
6362};
6463
6564// / 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 {
5353 class IRGenOptions ;
5454 class LangOptions ;
5555 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 ).
5662 typedef const void *OpaqueSyntaxNode;
5763 class Parser ;
5864 class SerializationOptions ;
You can’t perform that action at this time.
0 commit comments