entry_point.cpp 786 B

1234567891011121314151617181920212223
  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 SemIR::File& file, SemIR::FunctionId function_id)
  9. -> bool {
  10. // TODO: Check if `file` is in the `Main` package.
  11. const auto& function = file.functions().Get(function_id);
  12. // TODO: Check if `function` is in a namespace.
  13. return function.name_id.is_valid() &&
  14. file.names().GetAsStringIfIdentifier(function.name_id) ==
  15. EntryPointFunction;
  16. }
  17. } // namespace Carbon::SemIR