check.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/value_store.h"
  8. #include "toolchain/diagnostics/diagnostic_emitter.h"
  9. #include "toolchain/lex/tokenized_buffer.h"
  10. #include "toolchain/parse/tree.h"
  11. #include "toolchain/sem_ir/file.h"
  12. namespace Carbon::Check {
  13. // Constructs builtins. A single instance should be reused with CheckParseTree
  14. // calls associated with a given compilation.
  15. inline auto MakeBuiltins(SharedValueStores& value_stores) -> SemIR::File {
  16. return SemIR::File(value_stores);
  17. }
  18. // Checking information that's tracked per file.
  19. struct Unit {
  20. SharedValueStores* value_stores;
  21. const Lex::TokenizedBuffer* tokens;
  22. const Parse::Tree* parse_tree;
  23. DiagnosticConsumer* consumer;
  24. // The generated IR. Unset on input, set on output.
  25. std::optional<SemIR::File>* sem_ir;
  26. };
  27. // Checks a group of parse trees. This will use imports to decide the order of
  28. // checking.
  29. auto CheckParseTrees(const SemIR::File& builtin_ir,
  30. llvm::MutableArrayRef<Unit> units,
  31. llvm::raw_ostream* vlog_stream) -> void;
  32. } // namespace Carbon::Check
  33. #endif // CARBON_TOOLCHAIN_CHECK_CHECK_H_