Add support for & operator. (#3055)

Refactor type canonicalization so that we can reuse the same code for
building a `T*` expression and for forming the type of an `&x`
expression.

Add basic computation of expression category in order to check that we
only take the address of durable reference expressions. This is
currently computed on demand rather than being tracked as part of the
semantics node, but in most cases can be determined by looking at only a
single expression, so caching it in the node doesn't seem worthwhile
yet. This decision should be revisited if we start doing more complex
category calculations.

Also add trivial lowering support, but it doesn't work properly yet
because lowering doesn't yet take the expression category into account.
This commit is contained in:
Richard Smith
2023-08-08 20:53:50 +00:00
committed by GitHub
parent 212188a922
commit 62205763a5
17 changed files with 879 additions and 80 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ static auto PrintArgs(llvm::raw_ostream& out, std::pair<T0, T1> args) -> void {
out << ", arg1: " << args.second;
}
void SemanticsNode::Print(llvm::raw_ostream& out) const {
auto SemanticsNode::Print(llvm::raw_ostream& out) const -> void {
out << "{kind: " << kind_;
switch (kind_) {
#define CARBON_SEMANTICS_NODE_KIND(Name) \