style(ir): 纠正代码位置

This commit is contained in:
jing
2026-03-11 22:08:27 +08:00
parent 62dde8d7ab
commit fab6983d40
17 changed files with 193 additions and 88 deletions

View File

@@ -36,12 +36,11 @@ void IRGenImpl::GenDecl(SysYParser::DeclContext& decl) {
}
void IRGenImpl::GenVarDecl(SysYParser::VarDeclContext& decl) {
const std::string name = decl.Ident()->getText();
if (locals_.find(name) != locals_.end()) {
throw std::runtime_error("[irgen] 重复定义变量: " + name);
if (storage_map_.find(&decl) != storage_map_.end()) {
throw std::runtime_error("[irgen] 声明重复生成存储槽位");
}
auto* slot = builder_.CreateAllocaI32(ir::DefaultContext().NextTemp());
locals_[name] = slot;
storage_map_[&decl] = slot;
ir::Value* init = nullptr;
if (decl.exp()) {