Files
carbon-lang/toolchain/semantics/semantics_node_kind.def
T
Richard Smith 4b69264cb1 Add implied return; at end of non-value-returning functions. (#2942)
Add validation that every code block in a function is terminated by a sequence of terminating instructions, and that terminators don't appear anywhere else in code blocks.

This required tracking whether we're in a reachable code block. That's done on the fly when we create a new code block; the new `SemanticsNodeBlockId::Unreachable` is used to represent the case where we're not actually creating a code block because we're in unreachable code.
2023-06-26 15:17:47 -07:00

66 lines
2.5 KiB
Modula-2

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// This is an X-macro header. It does not use `#include` guards, and instead is
// designed to be `#include`ed after the x-macro is defined in order for its
// inclusion to expand to the desired output. Macro definitions are cleaned up
// at the end of this file.
//
// Supported x-macros are:
// - CARBON_SEMANTICS_NODE_KIND(Name)
// Defines a node kind.
// - CARBON_SEMANTICS_TERMINATOR_SEQUENCE_KIND(Name)
// Defines a node kind for a node in the terminator sequence, such as
// BranchIf. These nodes can only appear at the end of a block, after all
// nodes that are not in the terminator sequence, before the terminator.
// - CARBON_SEMANTICS_TERMINATOR_KIND(Name)
// Defines a node kind for a terminator node.
#ifndef CARBON_SEMANTICS_NODE_KIND
#error "Must define the x-macro to use this file."
#endif
#ifndef CARBON_SEMANTICS_TERMINATOR_SEQUENCE_KIND
#define CARBON_SEMANTICS_TERMINATOR_SEQUENCE_KIND(Name) \
CARBON_SEMANTICS_NODE_KIND(Name)
#endif
#ifndef CARBON_SEMANTICS_TERMINATOR_KIND
#define CARBON_SEMANTICS_TERMINATOR_KIND(Name) \
CARBON_SEMANTICS_TERMINATOR_SEQUENCE_KIND(Name)
#endif
CARBON_SEMANTICS_NODE_KIND(Invalid)
// A cross-reference between IRs.
CARBON_SEMANTICS_NODE_KIND(CrossReference)
CARBON_SEMANTICS_NODE_KIND(Assign)
CARBON_SEMANTICS_NODE_KIND(BinaryOperatorAdd)
CARBON_SEMANTICS_NODE_KIND(BindName)
CARBON_SEMANTICS_NODE_KIND(BlockArg)
CARBON_SEMANTICS_NODE_KIND(BoolLiteral)
CARBON_SEMANTICS_TERMINATOR_KIND(Branch)
CARBON_SEMANTICS_TERMINATOR_SEQUENCE_KIND(BranchIf)
CARBON_SEMANTICS_TERMINATOR_KIND(BranchWithArg)
CARBON_SEMANTICS_NODE_KIND(Builtin)
CARBON_SEMANTICS_NODE_KIND(Call)
CARBON_SEMANTICS_NODE_KIND(FunctionDeclaration)
CARBON_SEMANTICS_NODE_KIND(IntegerLiteral)
CARBON_SEMANTICS_NODE_KIND(RealLiteral)
CARBON_SEMANTICS_TERMINATOR_KIND(Return)
CARBON_SEMANTICS_TERMINATOR_KIND(ReturnExpression)
CARBON_SEMANTICS_NODE_KIND(StringLiteral)
CARBON_SEMANTICS_NODE_KIND(StructMemberAccess)
CARBON_SEMANTICS_NODE_KIND(StructType)
CARBON_SEMANTICS_NODE_KIND(StructTypeField)
CARBON_SEMANTICS_NODE_KIND(StructValue)
CARBON_SEMANTICS_NODE_KIND(StubReference)
CARBON_SEMANTICS_NODE_KIND(UnaryOperatorNot)
CARBON_SEMANTICS_NODE_KIND(VarStorage)
#undef CARBON_SEMANTICS_TERMINATOR_SEQUENCE_KIND
#undef CARBON_SEMANTICS_TERMINATOR_KIND
#undef CARBON_SEMANTICS_NODE_KIND