diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-30 14:31:07 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-30 14:31:07 +0000 |
| commit | 0cf54b4f77ccf8376341950b02ceb7c1d1268ed7 (patch) | |
| tree | eebbba01063451c28f0a2e1cc048215f50beb98f /lib/CodeGen/ConstantGen.cc | |
| parent | 4cb0d9b196008bc55dbfcdac1f9211dbbc879895 (diff) | |
refactor(strings): construct string values implicitly from raw literals
Keep double-quoted literals and text constants as C_STRING values. Use
marked STRING constructors for text and CHAR conversion, preserving
string operations and I/O through the existing class machinery.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ConstantGen.cc')
| -rw-r--r-- | lib/CodeGen/ConstantGen.cc | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/lib/CodeGen/ConstantGen.cc b/lib/CodeGen/ConstantGen.cc index a512490..66919d2 100644 --- a/lib/CodeGen/ConstantGen.cc +++ b/lib/CodeGen/ConstantGen.cc @@ -64,31 +64,8 @@ void CodeGen::emitConstantStmt(ConstantStmtAST *Stmt) { return; } if (!prepareSymbolDeclaration(Name, true)) return; - auto Existing = StringConstants.find(Stmt); - if (Existing != StringConstants.end()) { - Symbols[Name] = Existing->second; - return; - } const TypeInfo *Type = getExprTypeInfo(Stmt->getValue()); Value *Val = emitExpr(Stmt->getValue()); - if (Type && Type->isString() && Val) { - Value *Storage; - bool TopLevel = ConstantScopes.back().ID == 0; - if (TopLevel) { - Storage = new GlobalVariable(*TheModule, Type->LLVMType, false, - GlobalValue::InternalLinkage, Types->getZeroValue(Type->Name), "__cps_constant." + Name); - } else { - Storage = CreateEntryBlockAlloca(Builder->GetInsertBlock()->getParent(), Type->LLVMType, Name); - } - size_t Lifetime = registerStackObject(Storage, Type->Name, DiagnosticLine); - Builder->CreateStore(Val, Storage); - activateStackObject(Lifetime); - SymbolInfo Info{Storage, Type->Name, false, nullptr, ConstantScopes.back().ID}; - Info.ReadOnly = true; - Symbols[Name] = Info; - if (TopLevel) StringConstants.emplace(Stmt, Info); - return; - } auto *Literal = dyn_cast_or_null<Constant>(Val); if (!Type || !Literal) { reportError("CONSTANT initializer must be a literal"); |
