Files
carbon-lang/toolchain/sem_ir/entry_point.cpp
T
Jon Ross-Perkins 7e9d644e1f Switch File functions, classes, and types to ValueStores (#3316)
Building on #3313, start using ValueStore on File. Functions and classes
are straightforward. Types here I present as a borderline case where
maybe we want a more bespoke API, but maybe this is okay? Most other
things probably need a slightly different API, which although I might do
that for a consistent interface, felt more out-of-scope for this change.
2023-10-20 22:40:18 +00:00

23 lines
755 B
C++

// 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
#include "toolchain/sem_ir/entry_point.h"
#include "llvm/ADT/StringRef.h"
namespace Carbon::SemIR {
static constexpr llvm::StringLiteral EntryPointFunction = "Run";
auto IsEntryPoint(const SemIR::File& file, SemIR::FunctionId function_id)
-> bool {
// TODO: Check if `file` is in the `Main` package.
const auto& function = file.functions().Get(function_id);
// TODO: Check if `function` is in a namespace.
return function.name_id.is_valid() &&
file.strings().Get(function.name_id) == EntryPointFunction;
}
} // namespace Carbon::SemIR