entry_point.cpp 815 B

123456789101112131415161718192021222324
  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. #include "toolchain/sem_ir/ids.h"
  7. namespace Carbon::SemIR {
  8. static constexpr llvm::StringLiteral EntryPointFunction = "Run";
  9. auto IsEntryPoint(const File& file, FunctionId function_id) -> bool {
  10. const auto& function = file.functions().Get(function_id);
  11. return function.parent_scope_id == NameScopeId::Package &&
  12. file.package_id() == PackageNameId::None &&
  13. function.name_id.has_value() &&
  14. file.names().GetAsStringIfIdentifier(function.name_id) ==
  15. EntryPointFunction;
  16. }
  17. } // namespace Carbon::SemIR