entry_point.cpp 769 B

12345678910111213141516171819202122
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/sem_ir/entry_point.h"
  5. #include "llvm/ADT/StringRef.h"
  6. namespace Carbon::SemIR {
  7. static constexpr llvm::StringLiteral EntryPointFunction = "Run";
  8. auto IsEntryPoint(const File& file, FunctionId function_id) -> bool {
  9. // TODO: Check if `file` is in the `Main` package.
  10. const auto& function = file.functions().Get(function_id);
  11. // TODO: Check if `function` is in a namespace.
  12. return function.name_id.has_value() &&
  13. file.names().GetAsStringIfIdentifier(function.name_id) ==
  14. EntryPointFunction;
  15. }
  16. } // namespace Carbon::SemIR