check.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_CHECK_H_
  5. #define CARBON_TOOLCHAIN_CHECK_CHECK_H_
  6. #include "common/ostream.h"
  7. #include "toolchain/base/shared_value_stores.h"
  8. #include "toolchain/check/sem_ir_diagnostic_converter.h"
  9. #include "toolchain/diagnostics/diagnostic_emitter.h"
  10. #include "toolchain/lex/tokenized_buffer.h"
  11. #include "toolchain/parse/tree.h"
  12. #include "toolchain/parse/tree_and_subtrees.h"
  13. #include "toolchain/sem_ir/file.h"
  14. namespace Carbon::Check {
  15. // Checking information that's tracked per file.
  16. struct Unit {
  17. SharedValueStores* value_stores;
  18. const Lex::TokenizedBuffer* tokens;
  19. const Parse::Tree* parse_tree;
  20. DiagnosticConsumer* consumer;
  21. // Returns a lazily constructed TreeAndSubtrees.
  22. std::function<const Parse::TreeAndSubtrees&()> get_parse_tree_and_subtrees;
  23. // The generated IR. Unset on input, set on output.
  24. std::optional<SemIR::File>* sem_ir;
  25. };
  26. // Checks a group of parse trees. This will use imports to decide the order of
  27. // checking.
  28. auto CheckParseTrees(
  29. llvm::MutableArrayRef<Unit> units,
  30. llvm::MutableArrayRef<Parse::NodeLocConverter> node_converters,
  31. bool prelude_import, llvm::raw_ostream* vlog_stream) -> void;
  32. } // namespace Carbon::Check
  33. #endif // CARBON_TOOLCHAIN_CHECK_CHECK_H_