24 T->prependChildLowLevel(Child, R);
28 T->appendChildLowLevel(Child, R);
31 static std::pair<FileID, ArrayRef<Token>>
33 std::unique_ptr<llvm::MemoryBuffer> Buffer) {
34 return TBTM.lexBuffer(std::move(Buffer));
46 assert(Tokens.size() == 1);
47 assert(Tokens.front().kind() == K &&
48 "spelling is not lexed into the expected kind of token");
64 "Cannot infer the spelling of the token from its token kind.");
72 case syntax::NodeKind::Leaf:
75 case syntax::NodeKind::TranslationUnit:
77 case syntax::NodeKind::UnknownExpression:
79 case syntax::NodeKind::ParenExpression:
81 case syntax::NodeKind::ThisExpression:
83 case syntax::NodeKind::IntegerLiteralExpression:
84 return new (A.
getAllocator()) syntax::IntegerLiteralExpression;
85 case syntax::NodeKind::CharacterLiteralExpression:
86 return new (A.
getAllocator()) syntax::CharacterLiteralExpression;
87 case syntax::NodeKind::FloatingLiteralExpression:
88 return new (A.
getAllocator()) syntax::FloatingLiteralExpression;
89 case syntax::NodeKind::StringLiteralExpression:
90 return new (A.
getAllocator()) syntax::StringLiteralExpression;
91 case syntax::NodeKind::BoolLiteralExpression:
92 return new (A.
getAllocator()) syntax::BoolLiteralExpression;
93 case syntax::NodeKind::CxxNullPtrExpression:
94 return new (A.
getAllocator()) syntax::CxxNullPtrExpression;
95 case syntax::NodeKind::IntegerUserDefinedLiteralExpression:
96 return new (A.
getAllocator()) syntax::IntegerUserDefinedLiteralExpression;
97 case syntax::NodeKind::FloatUserDefinedLiteralExpression:
98 return new (A.
getAllocator()) syntax::FloatUserDefinedLiteralExpression;
99 case syntax::NodeKind::CharUserDefinedLiteralExpression:
100 return new (A.
getAllocator()) syntax::CharUserDefinedLiteralExpression;
101 case syntax::NodeKind::StringUserDefinedLiteralExpression:
102 return new (A.
getAllocator()) syntax::StringUserDefinedLiteralExpression;
103 case syntax::NodeKind::PrefixUnaryOperatorExpression:
105 case syntax::NodeKind::PostfixUnaryOperatorExpression:
107 case syntax::NodeKind::BinaryOperatorExpression:
109 case syntax::NodeKind::UnqualifiedId:
111 case syntax::NodeKind::IdExpression:
113 case syntax::NodeKind::CallExpression:
115 case syntax::NodeKind::UnknownStatement:
117 case syntax::NodeKind::DeclarationStatement:
119 case syntax::NodeKind::EmptyStatement:
121 case syntax::NodeKind::SwitchStatement:
123 case syntax::NodeKind::CaseStatement:
125 case syntax::NodeKind::DefaultStatement:
127 case syntax::NodeKind::IfStatement:
129 case syntax::NodeKind::ForStatement:
131 case syntax::NodeKind::WhileStatement:
133 case syntax::NodeKind::ContinueStatement:
135 case syntax::NodeKind::BreakStatement:
137 case syntax::NodeKind::ReturnStatement:
139 case syntax::NodeKind::RangeBasedForStatement:
141 case syntax::NodeKind::ExpressionStatement:
143 case syntax::NodeKind::CompoundStatement:
145 case syntax::NodeKind::UnknownDeclaration:
147 case syntax::NodeKind::EmptyDeclaration:
149 case syntax::NodeKind::StaticAssertDeclaration:
151 case syntax::NodeKind::LinkageSpecificationDeclaration:
153 case syntax::NodeKind::SimpleDeclaration:
155 case syntax::NodeKind::TemplateDeclaration:
157 case syntax::NodeKind::ExplicitTemplateInstantiation:
159 case syntax::NodeKind::NamespaceDefinition:
161 case syntax::NodeKind::NamespaceAliasDefinition:
163 case syntax::NodeKind::UsingNamespaceDirective:
165 case syntax::NodeKind::UsingDeclaration:
167 case syntax::NodeKind::TypeAliasDeclaration:
169 case syntax::NodeKind::SimpleDeclarator:
171 case syntax::NodeKind::ParenDeclarator:
173 case syntax::NodeKind::ArraySubscript:
175 case syntax::NodeKind::TrailingReturnType:
177 case syntax::NodeKind::ParametersAndQualifiers:
179 case syntax::NodeKind::MemberPointer:
181 case syntax::NodeKind::GlobalNameSpecifier:
182 return new (A.
getAllocator()) syntax::GlobalNameSpecifier;
183 case syntax::NodeKind::DecltypeNameSpecifier:
184 return new (A.
getAllocator()) syntax::DecltypeNameSpecifier;
185 case syntax::NodeKind::IdentifierNameSpecifier:
186 return new (A.
getAllocator()) syntax::IdentifierNameSpecifier;
187 case syntax::NodeKind::SimpleTemplateNameSpecifier:
188 return new (A.
getAllocator()) syntax::SimpleTemplateNameSpecifier;
189 case syntax::NodeKind::NestedNameSpecifier:
191 case syntax::NodeKind::MemberExpression:
193 case syntax::NodeKind::CallArguments:
195 case syntax::NodeKind::ParameterDeclarationList:
197 case syntax::NodeKind::DeclaratorList:
200 llvm_unreachable(
"unknown node kind");
208 auto *
T = allocateTree(A, K);
213 T->assertInvariants();