mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-19 17:06:41 +00: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:
1 parent
6359e3f550
commit
069c6f4447
5 files changed
+142
-245
No files matched your search
@@ -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