mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Support assigning to a variable through an imported macro
Example:
```carbon
import Cpp inline '''
int v = 1;
#define m v
''';
fn F() {
Cpp.m = 2;
}
```
22 lines
758 B
C++
22 lines
758 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_CHECK_CPP_MACROS_H_
|
|
#define CARBON_TOOLCHAIN_CHECK_CPP_MACROS_H_
|
|
|
|
#include "toolchain/check/context.h"
|
|
|
|
namespace Carbon::Check {
|
|
|
|
// Tries to evaluate the given macro. The macro will be evaluated as a
|
|
// constant if possible. Returns an `InstId` on success or
|
|
// `SemIR::ErrorInst::InstId` otherwise.
|
|
auto TryEvaluateMacro(Context& context, SemIR::LocId loc_id,
|
|
SemIR::NameId name_id, clang::MacroInfo* macro_info)
|
|
-> SemIR::InstId;
|
|
|
|
} // namespace Carbon::Check
|
|
|
|
#endif // CARBON_TOOLCHAIN_CHECK_CPP_MACROS_H_
|