mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 17:31:07 +01:00
Refactor TryEvaluateMacroToConstant to simplify and dedup code (#6820)
For integral and float types, `TryEvaluateMacroToConstant` now calls `MapAPValueToConstant` to directly convert from an APValue, rather than converting the `APValue` to an expression and importing it with `MapConstant`. `MapConstant` is still used, but only for string literals and nullptrs. Since it's only used by `TryEvaluateMacroToConstant`, moved it to `macros.cpp` and removed the code for other types of expressions.
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
// TODO: dedup with code in `MapConstant` and `TryEvaluateMacroToConstant`.
|
||||
auto MapAPValueToConstant(Context& context, SemIR::LocId loc_id,
|
||||
const clang::APValue& ap_value, clang::QualType type)
|
||||
-> SemIR::ConstantId {
|
||||
|
||||
Reference in New Issue
Block a user