function.h 1.3 KB

12345678910111213141516171819202122232425262728293031
  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. #ifndef CARBON_TOOLCHAIN_CHECK_FUNCTION_H_
  5. #define CARBON_TOOLCHAIN_CHECK_FUNCTION_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/sem_ir/function.h"
  8. namespace Carbon::Check {
  9. // Checks that `new_function_id` does not differ from `prev_function_id`.
  10. // Prints a suitable diagnostic and returns false if not.
  11. auto CheckFunctionRedecl(Context& context, SemIR::FunctionId new_function_id,
  12. SemIR::FunctionId prev_function_id) -> bool;
  13. // Tries to merge new_function into prev_function_id. Since new_function won't
  14. // have a definition even if one is upcoming, set is_definition to indicate the
  15. // planned result.
  16. //
  17. // If merging is successful, updates the FunctionId on new_function and returns
  18. // true. Otherwise, returns false. Prints a diagnostic when appropriate.
  19. auto MergeFunctionRedecl(Context& context, Parse::NodeId parse_node,
  20. SemIR::Function& new_function,
  21. SemIR::FunctionId prev_function_id, bool is_definition)
  22. -> bool;
  23. } // namespace Carbon::Check
  24. #endif // CARBON_TOOLCHAIN_CHECK_FUNCTION_H_