mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 19:01:05 +01:00
Remove FunctionDefinition's default constructor (#735)
This opens up a path for switching `int line_num` to a `Location loc`, which I want to do for tracking filenames of code. But I don't think we should have a default constructor on `Location` to avoid mistakes, and switching FunctionDefinition to an arena alloc seems more consistent anyways.
This commit is contained in:
@@ -72,18 +72,18 @@ class Declaration {
|
||||
|
||||
class FunctionDeclaration : public Declaration {
|
||||
public:
|
||||
FunctionDeclaration(FunctionDefinition definition)
|
||||
: Declaration(Kind::FunctionDeclaration, definition.line_num),
|
||||
definition(std::move(definition)) {}
|
||||
FunctionDeclaration(const FunctionDefinition* definition)
|
||||
: Declaration(Kind::FunctionDeclaration, definition->line_num),
|
||||
definition(definition) {}
|
||||
|
||||
static auto classof(const Declaration* decl) -> bool {
|
||||
return decl->Tag() == Kind::FunctionDeclaration;
|
||||
}
|
||||
|
||||
auto Definition() const -> const FunctionDefinition& { return definition; }
|
||||
auto Definition() const -> const FunctionDefinition& { return *definition; }
|
||||
|
||||
private:
|
||||
FunctionDefinition definition;
|
||||
const FunctionDefinition* definition;
|
||||
};
|
||||
|
||||
class StructDeclaration : public Declaration {
|
||||
|
||||
@@ -21,7 +21,6 @@ struct GenericBinding {
|
||||
};
|
||||
|
||||
struct FunctionDefinition {
|
||||
FunctionDefinition() = default;
|
||||
FunctionDefinition(int line_num, std::string name,
|
||||
std::vector<GenericBinding> deduced_params,
|
||||
const TuplePattern* param_pattern,
|
||||
|
||||
Reference in New Issue
Block a user