macros.h 953 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. #ifndef CARBON_TOOLCHAIN_CHECK_CPP_MACROS_H_
  5. #define CARBON_TOOLCHAIN_CHECK_CPP_MACROS_H_
  6. #include "toolchain/check/context.h"
  7. namespace Carbon::Check {
  8. // Tries to evaluate the given macro to a constant expression. Returns the
  9. // evaluated expression on success or nullptr otherwise. Currently supports only
  10. // simple object-like macros with a single replacement token that is a numeric
  11. // literal token.
  12. // TODO: Add support for multiple tokens and other literal types.
  13. auto TryEvaluateMacroToConstant(Context& context, SemIR::LocId loc_id,
  14. SemIR::NameId name_id,
  15. clang::MacroInfo* macro_info) -> clang::Expr*;
  16. } // namespace Carbon::Check
  17. #endif // CARBON_TOOLCHAIN_CHECK_CPP_MACROS_H_