mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
This adds a RawStringOstream. Versus TestRawOstream, which is
consolidated over to RawStringOstream, it uses a string for storage
instead of a vector, mainly to support move-to-string semantics. Versus
llvm::raw_string_ostream, it owns the string and supports pwrite (which
is needed for driver and its fd_ostream compatibility requirement).
This converts most uses of llvm::raw_string_ostream, leaving behind a
few in InstNamer that explicitly cannot own the string, such as:
```
llvm::raw_string_ostream(name)
<< "_" << tree.tokens().GetColumnNumber(token);
```
I have this as its own library so that it can use CHECK.
Yes this doesn't save much code, but it's code we repeatedly write.
---------
Co-authored-by: Geoff Romer <gromer@google.com>
63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
# 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
|
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_library")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
filegroup(
|
|
name = "testdata",
|
|
data = glob(["testdata/**/*.carbon"]),
|
|
)
|
|
|
|
cc_library(
|
|
name = "lower",
|
|
srcs = ["lower.cpp"],
|
|
hdrs = ["lower.h"],
|
|
deps = [
|
|
":context",
|
|
"//toolchain/check:sem_ir_diagnostic_converter",
|
|
"//toolchain/sem_ir:file",
|
|
"//toolchain/sem_ir:inst_namer",
|
|
"@llvm-project//llvm:Core",
|
|
"@llvm-project//llvm:Support",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "context",
|
|
srcs = [
|
|
"constant.cpp",
|
|
"constant.h",
|
|
"file_context.cpp",
|
|
"function_context.cpp",
|
|
"mangler.cpp",
|
|
"mangler.h",
|
|
] +
|
|
# Glob handler files to avoid missing any.
|
|
glob([
|
|
"handle*.cpp",
|
|
]),
|
|
hdrs = [
|
|
"file_context.h",
|
|
"function_context.h",
|
|
],
|
|
deps = [
|
|
"//common:check",
|
|
"//common:map",
|
|
"//common:raw_string_ostream",
|
|
"//common:vlog",
|
|
"//toolchain/base:kind_switch",
|
|
"//toolchain/check:sem_ir_diagnostic_converter",
|
|
"//toolchain/sem_ir:entry_point",
|
|
"//toolchain/sem_ir:file",
|
|
"//toolchain/sem_ir:inst",
|
|
"//toolchain/sem_ir:inst_namer",
|
|
"//toolchain/sem_ir:typed_insts",
|
|
"@llvm-project//llvm:Core",
|
|
"@llvm-project//llvm:Support",
|
|
"@llvm-project//llvm:TransformUtils",
|
|
],
|
|
)
|