Convert std::endl to newlines.
Currently the codebase sometimes uses `\n` and sometimes uses
`std::endl`. This CL converts the remaining `std::endl` usages to just
use the `\n` form directly. This removes the need to go through the
`std::endl` and removes the calls to `flush` which it adds.
(This is in line with the cppcoreguidlines SL.io.50)
Change-Id: Icc8b3c99e9a96c8b6fd504ce47e80d7f307b7633
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/191020
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp b/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
index 3edd384..905f505 100644
--- a/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
+++ b/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
@@ -83,8 +83,8 @@
std::ostringstream clearValueUniformBufferDeclarationStream;
std::ostringstream assignOutputColorStream;
- outputColorDeclarationStream << "struct OutputColor {" << std::endl;
- clearValueUniformBufferDeclarationStream << "struct ClearColors {" << std::endl;
+ outputColorDeclarationStream << "struct OutputColor {\n";
+ clearValueUniformBufferDeclarationStream << "struct ClearColors {\n";
// Only generate the assignments we need.
for (auto i : IterateBitSet(key.colorTargetsToApplyClearColorValue)) {
@@ -100,8 +100,8 @@
assignOutputColorStream << absl::StrFormat(
" outputColor.output%u = clearColors.color%u;\n", i, i);
}
- outputColorDeclarationStream << "}" << std::endl;
- clearValueUniformBufferDeclarationStream << "}" << std::endl;
+ outputColorDeclarationStream << "}\n";
+ clearValueUniformBufferDeclarationStream << "}\n";
std::ostringstream fragmentShaderStream;
fragmentShaderStream << outputColorDeclarationStream.str()
diff --git a/src/dawn/native/BlitColorToColorWithDraw.cpp b/src/dawn/native/BlitColorToColorWithDraw.cpp
index 9c78f70..d2115b7 100644
--- a/src/dawn/native/BlitColorToColorWithDraw.cpp
+++ b/src/dawn/native/BlitColorToColorWithDraw.cpp
@@ -75,7 +75,7 @@
"\toutputColor.output%u = textureLoad(srcTex%u, vec2u(position.xy), 0);\n", i, i);
}
- finalStream << "struct OutputColor {\n" << outputStructStream.str() << "}\n" << std::endl;
+ finalStream << "struct OutputColor {\n" << outputStructStream.str() << "}\n\n";
finalStream << R"(
@fragment fn blit_to_color(@builtin(position) position : vec4f) -> OutputColor {
var outputColor : OutputColor;
diff --git a/src/dawn/native/CompilationMessages.cpp b/src/dawn/native/CompilationMessages.cpp
index 64f23c5..11a7bd0 100644
--- a/src/dawn/native/CompilationMessages.cpp
+++ b/src/dawn/native/CompilationMessages.cpp
@@ -270,7 +270,7 @@
if (warningCount > 0) {
t << warningCount << " warning(s) ";
}
- t << "generated while compiling the shader:" << std::endl
+ t << "generated while compiling the shader:\n"
<< tint::diag::Formatter{style}.Format(messageList).Plain();
mFormattedTintMessages.push_back(t.str());
}
diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp
index b3e66bd..c8e6fb4 100644
--- a/src/dawn/native/ShaderModule.cpp
+++ b/src/dawn/native/ShaderModule.cpp
@@ -1117,7 +1117,7 @@
if (device->IsToggleEnabled(Toggle::DumpShaders)) {
std::ostringstream dumpedMsg;
- dumpedMsg << "// Dumped WGSL:" << std::endl << wgslDesc->code << std::endl;
+ dumpedMsg << "// Dumped WGSL:\n" << wgslDesc->code << "\n";
device->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str());
}
diff --git a/src/dawn/native/SpirvValidation.cpp b/src/dawn/native/SpirvValidation.cpp
index 01420bf..5e45b70 100644
--- a/src/dawn/native/SpirvValidation.cpp
+++ b/src/dawn/native/SpirvValidation.cpp
@@ -62,7 +62,7 @@
}
std::ostringstream ss;
- ss << "SPIRV line " << position.index << ": " << message << std::endl;
+ ss << "SPIRV line " << position.index << ": " << message << "\n";
device->EmitLog(wgpuLogLevel, ss.str().c_str());
});
@@ -73,7 +73,7 @@
if (spirvTools.Disassemble(
spirv, wordCount, &disassembly,
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES | SPV_BINARY_TO_TEXT_OPTION_INDENT)) {
- dumpedMsg << "/* Dumped generated SPIRV disassembly */" << std::endl << disassembly;
+ dumpedMsg << "/* Dumped generated SPIRV disassembly */\n" << disassembly;
} else {
dumpedMsg << "/* Failed to disassemble generated SPIRV */";
}
diff --git a/src/dawn/native/d3d/ShaderUtils.cpp b/src/dawn/native/d3d/ShaderUtils.cpp
index e1937ca..89c0b19 100644
--- a/src/dawn/native/d3d/ShaderUtils.cpp
+++ b/src/dawn/native/d3d/ShaderUtils.cpp
@@ -191,7 +191,7 @@
std::string* remappedEntryPointName,
CompiledShader* compiledShader) {
std::ostringstream errorStream;
- errorStream << "Tint HLSL failure:" << std::endl;
+ errorStream << "Tint HLSL failure:\n";
tint::ast::transform::Manager transformManager;
tint::ast::transform::DataMap transformInputs;
@@ -381,16 +381,14 @@
std::ostringstream dumpedMsg;
// The HLSL may be empty if compilation failed.
if (!compiledShader.hlslSource.empty()) {
- dumpedMsg << "/* Dumped generated HLSL */" << std::endl
- << compiledShader.hlslSource << std::endl;
+ dumpedMsg << "/* Dumped generated HLSL */\n" << compiledShader.hlslSource << "\n";
}
// The blob may be empty if FXC compilation failed.
const Blob& shaderBlob = compiledShader.shaderBlob;
if (!shaderBlob.Empty()) {
- dumpedMsg << "/* FXC compile flags */ " << std::endl
- << CompileFlagsToString(compileFlags) << std::endl;
- dumpedMsg << "/* Dumped disassembled DXBC */" << std::endl;
+ dumpedMsg << "/* FXC compile flags */\n" << CompileFlagsToString(compileFlags) << "\n";
+ dumpedMsg << "/* Dumped disassembled DXBC */\n";
ComPtr<ID3DBlob> disassembly;
UINT flags =
// Some literals are printed as floats with precision(6) which is not enough
@@ -398,7 +396,7 @@
D3D_DISASM_PRINT_HEX_LITERALS;
if (FAILED(device->GetFunctions()->d3dDisassemble(shaderBlob.Data(), shaderBlob.Size(),
flags, nullptr, &disassembly))) {
- dumpedMsg << "D3D disassemble failed" << std::endl;
+ dumpedMsg << "D3D disassemble failed\n";
} else {
dumpedMsg << std::string_view(static_cast<const char*>(disassembly->GetBufferPointer()),
disassembly->GetBufferSize());
diff --git a/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp b/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp
index 4b0a879..b914f15 100644
--- a/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp
+++ b/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp
@@ -356,7 +356,7 @@
// TODO(crbug.com/1512318): Add some telemetry so we log how often/when this happens.
std::ostringstream messageStream;
if (error) {
- messageStream << static_cast<const char*>(error->GetBufferPointer()) << std::endl;
+ messageStream << static_cast<const char*>(error->GetBufferPointer()) << "\n";
}
HRESULT hr = SerializeRootParameter1_0(device, versionedRootSignatureDescriptor,
&mRootSignatureBlob, &error);
@@ -364,7 +364,7 @@
return {};
}
if (error) {
- messageStream << static_cast<const char*>(error->GetBufferPointer()) << std::endl;
+ messageStream << static_cast<const char*>(error->GetBufferPointer()) << "\n";
}
messageStream << "D3D12 serialize root signature";
DAWN_TRY(CheckHRESULT(hr, messageStream.str().c_str()));
diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
index d9c48e8..c5b7401 100644
--- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
@@ -61,16 +61,15 @@
std::ostringstream dumpedMsg;
// The HLSL may be empty if compilation failed.
if (!compiledShader.hlslSource.empty()) {
- dumpedMsg << "/* Dumped generated HLSL */" << std::endl
- << compiledShader.hlslSource << std::endl;
+ dumpedMsg << "/* Dumped generated HLSL */\n" << compiledShader.hlslSource << "\n";
}
// The blob may be empty if DXC compilation failed.
const Blob& shaderBlob = compiledShader.shaderBlob;
if (!shaderBlob.Empty()) {
- dumpedMsg << "/* DXC compile flags */ " << std::endl
- << dawn::native::d3d::CompileFlagsToString(compileFlags) << std::endl;
- dumpedMsg << "/* Dumped disassembled DXIL */" << std::endl;
+ dumpedMsg << "/* DXC compile flags */\n"
+ << dawn::native::d3d::CompileFlagsToString(compileFlags) << "\n";
+ dumpedMsg << "/* Dumped disassembled DXIL */\n";
DxcBuffer dxcBuffer;
dxcBuffer.Encoding = DXC_CP_UTF8;
dxcBuffer.Ptr = shaderBlob.Data();
@@ -86,7 +85,7 @@
dumpedMsg << std::string_view(static_cast<const char*>(disassembly->GetBufferPointer()),
disassembly->GetBufferSize());
} else {
- dumpedMsg << "DXC disassemble failed" << std::endl;
+ dumpedMsg << "DXC disassemble failed\n";
ComPtr<IDxcBlobEncoding> errors;
if (dxcResult && dxcResult->HasOutput(DXC_OUT_ERRORS) &&
SUCCEEDED(dxcResult->GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&errors), nullptr))) {
diff --git a/src/dawn/native/metal/ShaderModuleMTL.mm b/src/dawn/native/metal/ShaderModuleMTL.mm
index 084385b..2e6f5ee 100644
--- a/src/dawn/native/metal/ShaderModuleMTL.mm
+++ b/src/dawn/native/metal/ShaderModuleMTL.mm
@@ -125,7 +125,7 @@
ScopedTintICEHandler scopedICEHandler(device);
std::ostringstream errorStream;
- errorStream << "Tint MSL failure:" << std::endl;
+ errorStream << "Tint MSL failure:\n";
tint::msl::writer::ArrayLengthFromUniformOptions arrayLengthFromUniform;
arrayLengthFromUniform.ubo_binding = kBufferLengthBufferSlot;
@@ -391,7 +391,7 @@
if (device->IsToggleEnabled(Toggle::DumpShaders)) {
std::ostringstream dumpedMsg;
- dumpedMsg << "/* Dumped generated MSL */" << std::endl << mslCompilation->msl;
+ dumpedMsg << "/* Dumped generated MSL */\n" << mslCompilation->msl;
device->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str());
}
diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp
index 8d9e026..2e2bc0e 100644
--- a/src/dawn/native/opengl/ShaderModuleGL.cpp
+++ b/src/dawn/native/opengl/ShaderModuleGL.cpp
@@ -457,7 +457,7 @@
if (GetDevice()->IsToggleEnabled(Toggle::DumpShaders)) {
std::ostringstream dumpedMsg;
- dumpedMsg << "/* Dumped generated GLSL */" << std::endl << compilationResult->glsl;
+ dumpedMsg << "/* Dumped generated GLSL */\n" << compilationResult->glsl;
GetDevice()->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str());
}
diff --git a/src/dawn/node/binding/GPU.cpp b/src/dawn/node/binding/GPU.cpp
index d10ef91..24df11c 100644
--- a/src/dawn/node/binding/GPU.cpp
+++ b/src/dawn/node/binding/GPU.cpp
@@ -185,8 +185,7 @@
nativeOptions.backendType = parsed.value();
} else {
std::stringstream msg;
- msg << "unrecognised backend '" + forceBackend + "'" << std::endl
- << "Possible backends: ";
+ msg << "unrecognised backend '" << forceBackend << "'\nPossible backends : ";
for (auto& info : kBackends) {
if (&info != &kBackends[0]) {
msg << ", ";
@@ -243,12 +242,11 @@
} else {
msg << "no suitable backends found";
}
- msg << std::endl << "Available adapters:";
+ msg << "\nAvailable adapters:";
for (auto& a : adapters) {
wgpu::AdapterProperties props;
a.GetProperties(&props);
- msg << std::endl
- << " * backend: '" << BackendName(props.backendType) << "', name: '" << props.name
+ msg << "\n * backend: '" << BackendName(props.backendType) << "', name: '" << props.name
<< "'";
}
promise.Reject(msg.str());
diff --git a/src/dawn/node/interop/WebGPU.cpp.tmpl b/src/dawn/node/interop/WebGPU.cpp.tmpl
index a7f9815..1e87c73 100644
--- a/src/dawn/node/interop/WebGPU.cpp.tmpl
+++ b/src/dawn/node/interop/WebGPU.cpp.tmpl
@@ -299,7 +299,7 @@
o << {{if $i}}", "{{else}}" "{{end}} << "{{$m.Name}}: ";
utils::Write(o, dict.{{$m.Name}});
{{- end }}
- o << "}" << std::endl;
+ o << "}\n";
return o;
}
{{ end}}
diff --git a/src/dawn/node/utils/Debug.h b/src/dawn/node/utils/Debug.h
index 5953dc8..c1f5288 100644
--- a/src/dawn/node/utils/Debug.h
+++ b/src/dawn/node/utils/Debug.h
@@ -130,7 +130,7 @@
msg << " ";
Write(msg, std::forward<MSG_ARGS>(msg_args)...);
}
- std::cout << msg.str() << std::endl;
+ std::cout << msg.str() << "\n";
abort();
}
@@ -139,7 +139,7 @@
#define LOG(...) \
::wgpu::utils::Write(std::cout << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << ": ", \
##__VA_ARGS__) \
- << std::endl
+ << "\n";
// UNIMPLEMENTED(env) raises a JS exception. Used to stub code that has not yet been implemented.
#define UNIMPLEMENTED(env, ...) \
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp
index 4c1457a..55885b4 100644
--- a/src/dawn/tests/DawnTest.cpp
+++ b/src/dawn/tests/DawnTest.cpp
@@ -90,7 +90,7 @@
result << buf;
}
}
- result << std::endl;
+ result << "\n";
}
// A helper class to create DawnTogglesDescriptor from test params
@@ -1785,7 +1785,7 @@
testing::AssertionResult result = expectation.expectation->Check(data, size);
if (!result) {
result << " Expectation created at " << expectation.file << ":" << expectation.line
- << std::endl;
+ << "\n";
result << expectation.message->str();
}
@@ -1932,7 +1932,7 @@
if (actual[i] != mConstant) {
return testing::AssertionFailure()
<< "Expected data[" << i << "] to match constant value " << mConstant
- << ", actual " << actual[i] << std::endl;
+ << ", actual " << actual[i] << "\n";
}
}
@@ -1951,13 +1951,13 @@
if (!check) {
testing::AssertionResult result = testing::AssertionFailure()
<< "Expected data[" << i << "] to be "
- << check.message() << std::endl;
+ << check.message() << "\n";
if (mExpected.size() <= 1024) {
- result << "Expected:" << std::endl;
+ result << "Expected:\n";
printBuffer(result, mExpected.data(), mExpected.size());
- result << "Actual:" << std::endl;
+ result << "Actual:\n";
printBuffer(result, actual, mExpected.size());
}
@@ -2010,15 +2010,15 @@
testing::AssertionResult result = testing::AssertionFailure()
<< "Expected data[" << i << "] to be between "
<< mValues0[i] << " and " << mValues1[i]
- << ", actual " << actual[i] << std::endl;
+ << ", actual " << actual[i] << "\n";
if (mLowerColorChannels.size() <= 1024) {
- result << "Expected between:" << std::endl;
+ result << "Expected between:\n";
printBuffer(result, mValues0.data(), mLowerColorChannels.size());
- result << "and" << std::endl;
+ result << "and\n";
printBuffer(result, mValues1.data(), mLowerColorChannels.size());
- result << "Actual:" << std::endl;
+ result << "Actual:\n";
printBuffer(result, actual, mLowerColorChannels.size());
}
diff --git a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp
index 0ac52df..003e475 100644
--- a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp
+++ b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp
@@ -697,8 +697,7 @@
RunComputeShaderWithBuffers(device, queue, shader, {inputBuf, outputBuf, statusBuf});
// Check the status
- EXPECT_BUFFER_U32_EQ(kStatusOk, statusBuf, 0) << "status code error" << std::endl
- << "Shader: " << shader;
+ EXPECT_BUFFER_U32_EQ(kStatusOk, statusBuf, 0) << "status code error\nShader: " << shader;
// Check the data. Note that MemoryDataBuilder avoid generating NaN and Inf floating point data,
// whose bit pattern will not get preserved when reading from buffer (arbitrary NaNs may be
diff --git a/src/dawn/tests/end2end/CopyTests.cpp b/src/dawn/tests/end2end/CopyTests.cpp
index 4c2b356..eabf0e5 100644
--- a/src/dawn/tests/end2end/CopyTests.cpp
+++ b/src/dawn/tests/end2end/CopyTests.cpp
@@ -399,7 +399,7 @@
<< textureSpec.textureSize.width << " x " << textureSpec.textureSize.height
<< " texture at mip level " << textureSpec.copyLevel << " layer " << layer << " to "
<< bufferSpec.size << "-byte buffer with offset " << bufferOffset
- << " and bytes per row " << bufferSpec.bytesPerRow << std::endl;
+ << " and bytes per row " << bufferSpec.bytesPerRow << "\n";
bufferOffset += bufferSpec.bytesPerRow * bufferSpec.rowsPerImage;
}
@@ -488,8 +488,7 @@
<< textureSpec.copyOrigin.y << "), (" << textureSpec.copyOrigin.x + copySize.width
<< ", " << textureSpec.copyOrigin.y + copySize.height << ")) region of "
<< textureSpec.textureSize.width << " x " << textureSpec.textureSize.height
- << " texture at mip level " << textureSpec.copyLevel << " layer " << layer
- << std::endl;
+ << " texture at mip level " << textureSpec.copyLevel << " layer " << layer << "\n";
bufferOffset += copyLayout.bytesPerImage;
}
}
diff --git a/src/dawn/tests/end2end/MaxLimitTests.cpp b/src/dawn/tests/end2end/MaxLimitTests.cpp
index 928452d..1741cf6 100644
--- a/src/dawn/tests/end2end/MaxLimitTests.cpp
+++ b/src/dawn/tests/end2end/MaxLimitTests.cpp
@@ -895,14 +895,13 @@
std::string GetInterStageVariableDeclarations(uint32_t interStageVariableCount) {
std::stringstream stream;
- stream << "struct VertexOut {" << std::endl;
+ stream << "struct VertexOut {\n";
for (uint32_t location = 0; location < interStageVariableCount; ++location) {
- stream << "@location(" << location << ") color" << location << " : vec4f, "
- << std::endl;
+ stream << "@location(" << location << ") color" << location << " : vec4f, \n";
}
- stream << "@builtin(position) pos : vec4f" << std::endl << "}" << std::endl;
+ stream << "@builtin(position) pos : vec4f\n}\n";
return stream.str();
}
@@ -911,9 +910,9 @@
std::stringstream stream;
uint32_t interStageVariableCount = GetInterStageVariableCount(spec);
- stream << GetInterStageVariableDeclarations(interStageVariableCount) << std::endl
- << GetVertexShaderForTest(interStageVariableCount) << std::endl
- << GetFragmentShaderForTest(interStageVariableCount, spec) << std::endl;
+ stream << GetInterStageVariableDeclarations(interStageVariableCount) << "\n"
+ << GetVertexShaderForTest(interStageVariableCount) << "\n"
+ << GetFragmentShaderForTest(interStageVariableCount, spec) << "\n";
return utils::CreateShaderModule(device, stream.str().c_str());
}
@@ -939,9 +938,9 @@
stream << ", ";
}
}
- stream << ");" << std::endl;
+ stream << ");\n";
}
- stream << "return output;" << std::endl << "}" << std::endl;
+ stream << "return output;\n}\n";
return stream.str();
}
@@ -961,7 +960,7 @@
}
// Ensure every inter-stage shader variable and built-in variable is used instead of being
// optimized out.
- stream << ") -> @location(0) vec4f {" << std::endl << "return input.pos";
+ stream << ") -> @location(0) vec4f {\nreturn input.pos";
if (spec.hasFrontFacing) {
stream << " + vec4f(f32(isFront), 0, 0, 1)";
}
@@ -1142,15 +1141,15 @@
wgpu::ShaderModule GetShaderModuleForTest(uint32_t maxVertexAttributes, const TestSpec& spec) {
std::ostringstream sstream;
- sstream << "struct VertexIn {" << std::endl;
+ sstream << "struct VertexIn {\n";
for (uint32_t i = 0; i < maxVertexAttributes; ++i) {
- sstream << " @location(" << i << ") input" << i << " : vec4f," << std::endl;
+ sstream << " @location(" << i << ") input" << i << " : vec4f,\n";
}
if (spec.hasVertexIndex) {
- sstream << " @builtin(vertex_index) VertexIndex : u32," << std::endl;
+ sstream << " @builtin(vertex_index) VertexIndex : u32,\n";
}
if (spec.hasInstanceIndex) {
- sstream << " @builtin(instance_index) InstanceIndex : u32," << std::endl;
+ sstream << " @builtin(instance_index) InstanceIndex : u32,\n";
}
sstream << R"(
}
@@ -1168,7 +1167,7 @@
if (spec.hasInstanceIndex) {
sstream << " + vec4f(f32(input.InstanceIndex))";
}
- sstream << ";}" << std::endl;
+ sstream << ";}\n";
sstream << R"(
@fragment
diff --git a/src/dawn/tests/end2end/MultithreadTests.cpp b/src/dawn/tests/end2end/MultithreadTests.cpp
index 008e0fe..6a2fbea 100644
--- a/src/dawn/tests/end2end/MultithreadTests.cpp
+++ b/src/dawn/tests/end2end/MultithreadTests.cpp
@@ -1478,7 +1478,7 @@
for (size_t i = 0; i < size / sizeof(uint64_t); i++) {
if (timestamps[i] == 0) {
return testing::AssertionFailure()
- << "Expected data[" << i << "] to be greater than 0." << std::endl;
+ << "Expected data[" << i << "] to be greater than 0.\n";
}
}
diff --git a/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp b/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp
index 009d02e..71be710 100644
--- a/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp
+++ b/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp
@@ -68,13 +68,13 @@
T value = *actual;
if (value == T(0)) {
return testing::AssertionFailure()
- << "Expected data to be non-zero, was " << value << std::endl;
+ << "Expected data to be non-zero, was " << value << "\n";
}
for (size_t i = 0; i < size / DataSize(); ++i) {
if (actual[i] != value) {
return testing::AssertionFailure()
<< "Expected data[" << i << "] to match non-zero value " << value
- << ", actual " << actual[i] << std::endl;
+ << ", actual " << actual[i] << "\n";
}
}
diff --git a/src/dawn/tests/end2end/QueryTests.cpp b/src/dawn/tests/end2end/QueryTests.cpp
index c4286a3..ca26430 100644
--- a/src/dawn/tests/end2end/QueryTests.cpp
+++ b/src/dawn/tests/end2end/QueryTests.cpp
@@ -77,16 +77,15 @@
if (actual[i] == kSentinelValue) {
return testing::AssertionFailure()
<< "Data[" << i << "] was not written (it kept the sentinel value of "
- << kSentinelValue << ")." << std::endl;
+ << kSentinelValue << ").\n";
}
if (mExpected == Result::Zero && actual[i] != 0) {
return testing::AssertionFailure()
- << "Expected data[" << i << "] to be zero, actual: " << actual[i] << "."
- << std::endl;
+ << "Expected data[" << i << "] to be zero, actual: " << actual[i] << ".\n";
}
if (mExpected == Result::NonZero && actual[i] == 0) {
return testing::AssertionFailure()
- << "Expected data[" << i << "] to be non-zero." << std::endl;
+ << "Expected data[" << i << "] to be non-zero.\n";
}
}
@@ -614,7 +613,7 @@
for (size_t i = 0; i < size / sizeof(uint64_t); i++) {
if (timestamps[i] == 0) {
return testing::AssertionFailure()
- << "Expected data[" << i << "] to be greater than 0." << std::endl;
+ << "Expected data[" << i << "] to be greater than 0.\n";
}
}
diff --git a/src/dawn/tests/end2end/QueueTests.cpp b/src/dawn/tests/end2end/QueueTests.cpp
index be0ce5c..d0b6038 100644
--- a/src/dawn/tests/end2end/QueueTests.cpp
+++ b/src/dawn/tests/end2end/QueueTests.cpp
@@ -368,7 +368,7 @@
<< textureSpec.copyOrigin.x + copySize.width << ", "
<< textureSpec.copyOrigin.y + copySize.height << ")) region of "
<< textureSpec.textureSize.width << " x " << textureSpec.textureSize.height
- << " texture at mip level " << textureSpec.level << " layer " << slice << std::endl;
+ << " texture at mip level " << textureSpec.level << " layer " << slice << "\n";
dataOffset += bytesPerImage;
}
diff --git a/src/dawn/tests/end2end/TextureFormatTests.cpp b/src/dawn/tests/end2end/TextureFormatTests.cpp
index 77e7134..be65888 100644
--- a/src/dawn/tests/end2end/TextureFormatTests.cpp
+++ b/src/dawn/tests/end2end/TextureFormatTests.cpp
@@ -67,7 +67,7 @@
testing::AssertionResult result = testing::AssertionFailure()
<< "Expected data[" << i << "] to be close to "
<< expectedValue << ", actual " << actualValue
- << std::endl;
+ << "\n";
return result;
}
}
@@ -114,7 +114,7 @@
testing::AssertionResult result = testing::AssertionFailure()
<< "Expected data[" << i << "] to be "
<< expectedValue << ", actual " << actualValue
- << std::endl;
+ << "\n";
return result;
}
}
@@ -151,7 +151,7 @@
testing::AssertionResult result = testing::AssertionFailure()
<< "Expected data[" << i << "] to be "
<< expectedValue << ", actual " << actualValue
- << std::endl;
+ << "\n";
return result;
}
}
diff --git a/src/dawn/tests/end2end/VideoViewsTests.cpp b/src/dawn/tests/end2end/VideoViewsTests.cpp
index 23dab6b..00a0c41 100644
--- a/src/dawn/tests/end2end/VideoViewsTests.cpp
+++ b/src/dawn/tests/end2end/VideoViewsTests.cpp
@@ -1650,11 +1650,11 @@
std::string outputStruct;
{
std::ostringstream result;
- result << "struct Output {" << std::endl;
+ result << "struct Output {\n";
for (size_t i = 0; i < destVideoWGPUTextures.size(); ++i) {
- result << " @location(" << i << ") color" << i << " : vec4f," << std::endl;
+ result << " @location(" << i << ") color" << i << " : vec4f,\n";
}
- result << "};" << std::endl;
+ result << "};\n";
outputStruct = std::move(result).str();
}
@@ -1662,24 +1662,23 @@
std::string returnOutput;
{
std::ostringstream result;
- result << " var output : Output;" << std::endl;
+ result << " var output : Output;\n";
for (size_t i = 0; i < destVideoWGPUTextures.size(); ++i) {
- result << " output.color" << i << " = outputColor;" << std::endl;
+ result << " output.color" << i << " = outputColor;\n";
}
- result << " return output;" << std::endl;
+ result << " return output;\n";
returnOutput = std::move(result).str();
}
std::ostringstream fsSource;
- fsSource << "@group(0) @binding(0) var sampler0 : sampler;" << std::endl;
- fsSource << "@group(0) @binding(1) var texture : texture_2d<f32>;" << std::endl;
- fsSource << outputStruct << std::endl;
- fsSource << "@fragment" << std::endl;
- fsSource << "fn main(@location(0) texCoord : vec2f) -> Output {" << std::endl;
- fsSource << " let outputColor = textureSample(texture, sampler0, texCoord);"
- << std::endl;
- fsSource << returnOutput << std::endl;
- fsSource << "}" << std::endl;
+ fsSource << "@group(0) @binding(0) var sampler0 : sampler;\n";
+ fsSource << "@group(0) @binding(1) var texture : texture_2d<f32>;\n";
+ fsSource << outputStruct << "\n";
+ fsSource << "@fragment\n";
+ fsSource << "fn main(@location(0) texCoord : vec2f) -> Output {\n";
+ fsSource << " let outputColor = textureSample(texture, sampler0, texCoord);\n";
+ fsSource << returnOutput << "\n";
+ fsSource << "}\n";
auto fsModule = utils::CreateShaderModule(device, std::move(fsSource).str());
diff --git a/src/dawn/tests/perf_tests/DawnPerfTest.cpp b/src/dawn/tests/perf_tests/DawnPerfTest.cpp
index 8e45625..a78c66a 100644
--- a/src/dawn/tests/perf_tests/DawnPerfTest.cpp
+++ b/src/dawn/tests/perf_tests/DawnPerfTest.cpp
@@ -163,8 +163,7 @@
std::ofstream outFile;
outFile.open(mTraceFile, std::ios_base::app);
- outFile << "]}";
- outFile << std::endl;
+ outFile << "]}\n";
outFile.close();
}
diff --git a/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp b/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp
index c5d3b3b..00cfe0d 100644
--- a/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp
+++ b/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp
@@ -268,16 +268,15 @@
}
std::ostream& operator<<(std::ostream& os, const TextureCopySubresource& copySplit) {
- os << "CopySplit" << std::endl;
+ os << "CopySplit\n";
for (uint32_t i = 0; i < copySplit.count; ++i) {
const auto& copy = copySplit.copies[i];
os << " " << i << ": Texture at (" << copy.textureOffset.x << ", " << copy.textureOffset.y
<< ", " << copy.textureOffset.z << "), size (" << copy.copySize.width << ", "
- << copy.copySize.height << ", " << copy.copySize.depthOrArrayLayers << ")" << std::endl;
+ << copy.copySize.height << ", " << copy.copySize.depthOrArrayLayers << ")\n";
os << " " << i << ": Buffer at (" << copy.bufferOffset.x << ", " << copy.bufferOffset.y
<< ", " << copy.bufferOffset.z << "), footprint (" << copy.bufferSize.width << ", "
- << copy.bufferSize.height << ", " << copy.bufferSize.depthOrArrayLayers << ")"
- << std::endl;
+ << copy.bufferSize.height << ", " << copy.bufferSize.depthOrArrayLayers << ")\n";
}
return os;
}
@@ -418,9 +417,8 @@
if (HasFatalFailure()) {
std::ostringstream message;
- message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
- << std::endl
- << dimension << " " << copySplit << std::endl;
+ message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << "\n"
+ << dimension << " " << copySplit << "\n";
FAIL() << message.str();
}
}
diff --git a/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp
index c83130c..2ecb1c5 100644
--- a/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp
@@ -2028,8 +2028,7 @@
std::string interfaceDeclaration;
{
std::ostringstream sstream;
- sstream << "struct A { @location(0) @interpolate(flat) a: " << kTypes[i] << ","
- << std::endl;
+ sstream << "struct A { @location(0) @interpolate(flat) a: " << kTypes[i] << ",\n";
interfaceDeclaration = sstream.str();
}
@@ -2130,7 +2129,7 @@
}
sstream << ")";
}
- sstream << " a : vec4f," << std::endl;
+ sstream << " a : vec4f,\n";
interfaceDeclaration = sstream.str();
}
{
diff --git a/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp b/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp
index fce0dc9..d2709b4 100644
--- a/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp
@@ -324,9 +324,9 @@
wgpu::ShaderStage failingShaderStage) {
// Build the ShaderIO struct containing variables up to maximumOutputLocation.
std::ostringstream stream;
- stream << "struct ShaderIO {" << std::endl;
+ stream << "struct ShaderIO {\n";
for (uint32_t location = 1; location <= maximumOutputLocation; ++location) {
- stream << "@location(" << location << ") var" << location << ": f32," << std::endl;
+ stream << "@location(" << location << ") var" << location << ": f32,\n";
}
if (failingShaderStage == wgpu::ShaderStage::Vertex) {
@@ -427,11 +427,11 @@
// components. Components are added in two parts, a bunch of vec4s, then one additional
// variable for the remaining components.
std::ostringstream stream;
- stream << "struct ShaderIO {" << std::endl << extraBuiltInDeclarations << std::endl;
+ stream << "struct ShaderIO {\n" << extraBuiltInDeclarations << "\n";
uint32_t vec4InputLocations = totalUserDefinedInterStageShaderComponentCount / 4;
for (uint32_t location = 0; location < vec4InputLocations; ++location) {
- stream << "@location(" << location << ") var" << location << ": vec4f," << std::endl;
+ stream << "@location(" << location << ") var" << location << ": vec4f,\n";
}
uint32_t lastComponentCount = totalUserDefinedInterStageShaderComponentCount % 4;
@@ -442,13 +442,13 @@
} else {
stream << " vec" << lastComponentCount << "f,";
}
- stream << std::endl;
+ stream << "\n";
}
if (failingShaderStage == wgpu::ShaderStage::Vertex) {
- stream << " @builtin(position) pos: vec4f," << std::endl;
+ stream << " @builtin(position) pos: vec4f,\n";
}
- stream << "}" << std::endl;
+ stream << "}\n";
std::string ioStruct = stream.str();
diff --git a/src/dawn/tests/white_box/GPUTimestampCalibrationTests.cpp b/src/dawn/tests/white_box/GPUTimestampCalibrationTests.cpp
index fcf60c1..f5d17f3 100644
--- a/src/dawn/tests/white_box/GPUTimestampCalibrationTests.cpp
+++ b/src/dawn/tests/white_box/GPUTimestampCalibrationTests.cpp
@@ -83,7 +83,7 @@
if (actual[i] < mMinValue || actual[i] > mMaxValue) {
return testing::AssertionFailure()
<< "Expected data[" << i << "] to be between " << mMinValue << " and "
- << mMaxValue << ", actual " << actual[i] << std::endl;
+ << mMaxValue << ", actual " << actual[i] << "\n";
}
}
diff --git a/src/dawn/tests/white_box/QueryInternalShaderTests.cpp b/src/dawn/tests/white_box/QueryInternalShaderTests.cpp
index 469f9b0..c4a70c1 100644
--- a/src/dawn/tests/white_box/QueryInternalShaderTests.cpp
+++ b/src/dawn/tests/white_box/QueryInternalShaderTests.cpp
@@ -75,8 +75,7 @@
if (mExpected[i] == 0) {
if (actual[i] != 0) {
return testing::AssertionFailure()
- << "Expected data[" << i << "] to be 0, actual " << actual[i]
- << std::endl;
+ << "Expected data[" << i << "] to be 0, actual " << actual[i] << "\n";
}
continue;
}
@@ -96,13 +95,13 @@
<< "Expected data[" << i << "] to be " << expected << ", actual "
<< actual[i] << ". Error rate is larger than " << kErrorToleranceRatio
<< ". Upper limit is " << upperLimit << ". Lower limit is " << lowerLimit
- << std::endl;
+ << "\n";
}
if ((actual[i] & ~quantizationMask64) != 0) {
return testing::AssertionFailure() << "Actual data 0x" << std::hex << actual[i]
<< " does not match quantization mask 0x"
- << std::hex << mQuantizationMask << std::endl;
+ << std::hex << mQuantizationMask << "\n";
}
}
diff --git a/src/tint/cmd/bench/bench.cc b/src/tint/cmd/bench/bench.cc
index f8736e1..5114ada 100644
--- a/src/tint/cmd/bench/bench.cc
+++ b/src/tint/cmd/bench/bench.cc
@@ -116,7 +116,7 @@
bool Initialize() {
if (!FindBenchmarkInputDir()) {
- std::cerr << "failed to locate benchmark input files" << std::endl;
+ std::cerr << "failed to locate benchmark input files\n";
return false;
}
return true;
diff --git a/src/tint/cmd/common/helper.cc b/src/tint/cmd/common/helper.cc
index 606dd69..498865e 100644
--- a/src/tint/cmd/common/helper.cc
+++ b/src/tint/cmd/common/helper.cc
@@ -96,20 +96,15 @@
void PrintBindings(tint::inspector::Inspector& inspector, const std::string& ep_name) {
auto bindings = inspector.GetResourceBindings(ep_name);
if (!inspector.error().empty()) {
- std::cerr << "Failed to get bindings from Inspector: " << inspector.error() << std::endl;
+ std::cerr << "Failed to get bindings from Inspector: " << inspector.error() << "\n";
exit(1);
}
for (auto& binding : bindings) {
- std::cout << "\t[" << binding.bind_group << "][" << binding.binding << "]:" << std::endl;
- std::cout << "\t\t resource_type = " << ResourceTypeToString(binding.resource_type)
- << std::endl;
- std::cout << "\t\t dim = " << TextureDimensionToString(binding.dim) << std::endl;
- std::cout << "\t\t sampled_kind = " << SampledKindToString(binding.sampled_kind)
- << std::endl;
- std::cout << "\t\t image_format = " << TexelFormatToString(binding.image_format)
- << std::endl;
-
- std::cout << std::endl;
+ std::cout << "\t[" << binding.bind_group << "][" << binding.binding << "]:\n"
+ << "\t\t resource_type = " << ResourceTypeToString(binding.resource_type) << "\n"
+ << "\t\t dim = " << TextureDimensionToString(binding.dim) << "\n"
+ << "\t\t sampled_kind = " << SampledKindToString(binding.sampled_kind) << "\n"
+ << "\t\t image_format = " << TexelFormatToString(binding.image_format) << "\n\n";
}
}
@@ -138,7 +133,7 @@
return prog_result.Move();
#else
- std::cerr << "Tint not built with the WGSL writer enabled" << std::endl;
+ std::cerr << "Tint not built with the WGSL writer enabled\n";
exit(1);
#endif // TINT_BUILD_WGSL_READER
} else {
@@ -169,9 +164,9 @@
tint::wgsl::writer::Options options;
auto result = tint::wgsl::writer::Generate(program, options);
if (result == Success) {
- out << std::endl << result->wgsl << std::endl;
+ out << "\n" << result->wgsl << "\n";
} else {
- out << result.Failure() << std::endl;
+ out << result.Failure() << "\n";
}
#else
(void)out;
@@ -205,7 +200,7 @@
/* source_file */ std::move(file),
};
#else
- std::cerr << "Tint not built with the WGSL reader enabled" << std::endl;
+ std::cerr << "Tint not built with the WGSL reader enabled\n";
exit(1);
#endif // TINT_BUILD_WGSL_READER
}
@@ -221,7 +216,7 @@
/* source_file */ nullptr,
};
#else
- std::cerr << "Tint not built with the SPIR-V reader enabled" << std::endl;
+ std::cerr << "Tint not built with the SPIR-V reader enabled\n";
exit(1);
#endif // TINT_BUILD_SPV_READER
}
@@ -235,8 +230,7 @@
spvtools::SpirvTools tools(SPV_ENV_VULKAN_1_1);
tools.SetMessageConsumer([](spv_message_level_t, const char*,
const spv_position_t& pos, const char* msg) {
- std::cerr << (pos.line + 1) << ":" << (pos.column + 1) << ": " << msg
- << std::endl;
+ std::cerr << (pos.line + 1) << ":" << (pos.column + 1) << ": " << msg << "\n";
});
std::vector<uint32_t> data;
if (!tools.Assemble(text.data(), text.size(), &data,
@@ -252,13 +246,13 @@
/* source_file */ std::move(file),
};
#else
- std::cerr << "Tint not built with the SPIR-V reader enabled" << std::endl;
+ std::cerr << "Tint not built with the SPIR-V reader enabled\n";
exit(1);
#endif // TINT_BUILD_SPV_READER
}
}
- std::cerr << "Unknown input format: " << input_format << std::endl;
+ std::cerr << "Unknown input format: " << input_format << "\n";
exit(1);
};
@@ -293,23 +287,22 @@
void PrintInspectorData(tint::inspector::Inspector& inspector) {
auto entry_points = inspector.GetEntryPoints();
if (!inspector.error().empty()) {
- std::cerr << "Failed to get entry points from Inspector: " << inspector.error()
- << std::endl;
+ std::cerr << "Failed to get entry points from Inspector: " << inspector.error() << "\n";
exit(1);
}
for (auto& entry_point : entry_points) {
std::cout << "Entry Point = " << entry_point.name << " ("
- << EntryPointStageToString(entry_point.stage) << ")" << std::endl;
+ << EntryPointStageToString(entry_point.stage) << ")\n";
if (entry_point.workgroup_size) {
std::cout << " Workgroup Size (" << entry_point.workgroup_size->x << ", "
<< entry_point.workgroup_size->y << ", " << entry_point.workgroup_size->z
- << ")" << std::endl;
+ << ")\n";
}
if (!entry_point.input_variables.empty()) {
- std::cout << " Input Variables:" << std::endl;
+ std::cout << " Input Variables:\n";
for (const auto& var : entry_point.input_variables) {
std::cout << "\t";
@@ -321,11 +314,11 @@
if (auto color = var.attributes.color) {
std::cout << "@color(" << color.value() << ") ";
}
- std::cout << var.name << std::endl;
+ std::cout << var.name << "\n";
}
}
if (!entry_point.output_variables.empty()) {
- std::cout << " Output Variables:" << std::endl;
+ std::cout << " Output Variables:\n";
for (const auto& var : entry_point.output_variables) {
std::cout << "\t";
@@ -333,49 +326,47 @@
if (auto location = var.attributes.location) {
std::cout << "@location(" << location.value() << ") ";
}
- std::cout << var.name << std::endl;
+ std::cout << var.name << "\n";
}
}
if (!entry_point.overrides.empty()) {
- std::cout << " Overrides:" << std::endl;
+ std::cout << " Overrides:\n";
for (const auto& var : entry_point.overrides) {
- std::cout << "\tname: " << var.name << std::endl;
- std::cout << "\tid: " << var.id.value << std::endl;
+ std::cout << "\tname: " << var.name << "\n";
+ std::cout << "\tid: " << var.id.value << "\n";
}
}
auto bindings = inspector.GetResourceBindings(entry_point.name);
if (!inspector.error().empty()) {
- std::cerr << "Failed to get bindings from Inspector: " << inspector.error()
- << std::endl;
+ std::cerr << "Failed to get bindings from Inspector: " << inspector.error() << "\n";
exit(1);
}
if (!bindings.empty()) {
- std::cout << " Bindings:" << std::endl;
+ std::cout << " Bindings:\n";
PrintBindings(inspector, entry_point.name);
- std::cout << std::endl;
+ std::cout << "\n";
}
- std::cout << std::endl;
+ std::cout << "\n";
}
}
void PrintInspectorBindings(tint::inspector::Inspector& inspector) {
- std::cout << std::string(80, '-') << std::endl;
+ std::cout << std::string(80, '-') << "\n";
auto entry_points = inspector.GetEntryPoints();
if (!inspector.error().empty()) {
- std::cerr << "Failed to get entry points from Inspector: " << inspector.error()
- << std::endl;
+ std::cerr << "Failed to get entry points from Inspector: " << inspector.error() << "\n";
exit(1);
}
for (auto& entry_point : entry_points) {
- std::cout << "Entry Point = " << entry_point.name << std::endl;
+ std::cout << "Entry Point = " << entry_point.name << "\n";
PrintBindings(inspector, entry_point.name);
}
- std::cout << std::string(80, '-') << std::endl;
+ std::cout << std::string(80, '-') << "\n";
}
std::string EntryPointStageToString(tint::inspector::PipelineStage stage) {
diff --git a/src/tint/cmd/common/helper.h b/src/tint/cmd/common/helper.h
index 0bfb820..7be30eb 100644
--- a/src/tint/cmd/common/helper.h
+++ b/src/tint/cmd/common/helper.h
@@ -140,7 +140,7 @@
template <typename T>
bool ReadFile(const std::string& input_file, std::vector<T>* buffer) {
if (!buffer) {
- std::cerr << "The buffer pointer was null" << std::endl;
+ std::cerr << "The buffer pointer was null\n";
return false;
}
@@ -151,7 +151,7 @@
file = fopen(input_file.c_str(), "rb");
#endif
if (!file) {
- std::cerr << "Failed to open " << input_file << std::endl;
+ std::cerr << "Failed to open " << input_file << "\n";
return false;
}
@@ -160,8 +160,7 @@
if (0 != (file_size % sizeof(T))) {
std::cerr << "File " << input_file
<< " does not contain an integral number of objects: " << file_size
- << " bytes in the file, require " << sizeof(T) << " bytes per object"
- << std::endl;
+ << " bytes in the file, require " << sizeof(T) << " bytes per object\n";
fclose(file);
return false;
}
@@ -173,7 +172,7 @@
size_t bytes_read = fread(buffer->data(), 1, file_size, file);
fclose(file);
if (bytes_read != file_size) {
- std::cerr << "Failed to read " << input_file << std::endl;
+ std::cerr << "Failed to read " << input_file << "\n";
return false;
}
diff --git a/src/tint/cmd/fuzz/wgsl/fuzz.cc b/src/tint/cmd/fuzz/wgsl/fuzz.cc
index b5467bc..04c362e 100644
--- a/src/tint/cmd/fuzz/wgsl/fuzz.cc
+++ b/src/tint/cmd/fuzz/wgsl/fuzz.cc
@@ -67,8 +67,8 @@
thread_local std::string_view currently_running;
[[noreturn]] void TintInternalCompilerErrorReporter(const tint::InternalCompilerError& err) {
- std::cerr << "ICE while running fuzzer: '" << currently_running << "'" << std::endl;
- std::cerr << err.Error() << std::endl;
+ std::cerr << "ICE while running fuzzer: '" << currently_running << "'\n";
+ std::cerr << err.Error() << "\n";
__builtin_trap();
}
@@ -154,8 +154,7 @@
auto program = tint::wgsl::reader::Parse(&file, parse_options);
if (!program.IsValid()) {
if (options.verbose) {
- std::cerr << "invalid WGSL program: " << std::endl
- << program.Diagnostics() << std::endl;
+ std::cerr << "invalid WGSL program:\n" << program.Diagnostics() << "\n";
}
return;
}
@@ -178,7 +177,7 @@
auto& fuzzer = Fuzzers()[i];
currently_running = fuzzer.name;
if (context.options.verbose) {
- std::cout << " • [" << i << "] Running: " << currently_running << std::endl;
+ std::cout << " • [" << i << "] Running: " << currently_running << "\n";
}
fuzzer.fn(program, context, data);
}));
@@ -195,7 +194,7 @@
currently_running = fuzzer.name;
if (options.verbose) {
- std::cout << " • Running: " << currently_running << std::endl;
+ std::cout << " • Running: " << currently_running << "\n";
}
fuzzer.fn(program, context, data);
}
diff --git a/src/tint/cmd/fuzz/wgsl/main_fuzz.cc b/src/tint/cmd/fuzz/wgsl/main_fuzz.cc
index 06489f1..733190d 100644
--- a/src/tint/cmd/fuzz/wgsl/main_fuzz.cc
+++ b/src/tint/cmd/fuzz/wgsl/main_fuzz.cc
@@ -61,9 +61,10 @@
}
auto show_help = [&] {
- std::cerr << "Custom fuzzer options:" << std::endl;
+ std::cerr << "Custom fuzzer options:\n";
opts.ShowHelp(std::cerr);
- std::cerr << std::endl;
+ std::cerr << "\n";
+
// Change args to show libfuzzer help
std::cerr << "Standard libfuzzer "; // libfuzzer will print 'Usage:'
static char help[] = "-help=1";
diff --git a/src/tint/cmd/info/main.cc b/src/tint/cmd/info/main.cc
index 26f6df2..97623d0 100644
--- a/src/tint/cmd/info/main.cc
+++ b/src/tint/cmd/info/main.cc
@@ -72,12 +72,12 @@
opts->emit_json = true;
} else if (!arg.empty()) {
if (arg[0] == '-') {
- std::cerr << "Unrecognized option: " << arg << std::endl;
+ std::cerr << "Unrecognized option: " << arg << "\n";
return false;
}
if (!opts->input_filename.empty()) {
std::cerr << "More than one input file specified: '" << opts->input_filename
- << "' and '" << arg << "'" << std::endl;
+ << "' and '" << arg << "'\n";
return false;
}
opts->input_filename = arg;
@@ -89,8 +89,7 @@
void EmitJson(const tint::Program& program) {
tint::inspector::Inspector inspector(program);
- std::cout << "{" << std::endl;
- std::cout << "\"extensions\": [" << std::endl;
+ std::cout << "{\n\"extensions\": [\n";
if (!inspector.GetUsedExtensionNames().empty()) {
bool first = true;
@@ -99,38 +98,32 @@
std::cout << ",";
}
first = false;
- std::cout << "\"" << name << "\"" << std::endl;
+ std::cout << "\"" << name << "\"\n";
}
}
- std::cout << "]," << std::endl;
-
+ std::cout << "],\n";
std::cout << "\"entry_points\": [";
auto stage_var = [&](const tint::inspector::StageVariable& var) {
- std::cout << std::endl;
- std::cout << "{" << std::endl;
- std::cout << "\"name\": \"" << var.name << "\"";
- std::cout << "," << std::endl;
+ std::cout << "\n{\n\"name\": \"" << var.name << "\",\n";
if (auto location = var.attributes.location) {
- std::cout << "\"location\": " << location.value() << "," << std::endl;
- std::cout << "\"interpolation\": {" << std::endl;
- std::cout << "\"type\": \""
- << tint::cmd::InterpolationTypeToString(var.interpolation_type) << "\","
- << std::endl;
- std::cout << "\"sampling\": \""
+ std::cout << "\"location\": " << location.value() << ",\n"
+ << "\"interpolation\": {\n"
+ << "\"type\": \""
+ << tint::cmd::InterpolationTypeToString(var.interpolation_type) << "\",\n"
+ << "\"sampling\": \""
<< tint::cmd::InterpolationSamplingToString(var.interpolation_sampling)
- << "\"" << std::endl;
- std::cout << "}," << std::endl;
+ << "\"\n"
+ << "},\n";
}
if (auto color = var.attributes.color) {
- std::cout << "\"color\": " << color.value() << "," << std::endl;
+ std::cout << "\"color\": " << color.value() << ",\n";
}
std::cout << "\"component_type\": \""
- << tint::cmd::ComponentTypeToString(var.component_type) << "\"," << std::endl;
- std::cout << "\"composition_type\": \""
- << tint::cmd::CompositionTypeToString(var.composition_type) << "\"" << std::endl;
- std::cout << std::endl;
- std::cout << "}";
+ << tint::cmd::ComponentTypeToString(var.component_type) << "\",\n"
+ << "\"composition_type\": \""
+ << tint::cmd::CompositionTypeToString(var.composition_type) << "\"\n\n"
+ << "}";
};
auto entry_points = inspector.GetEntryPoints();
@@ -141,20 +134,15 @@
}
first = false;
- std::cout << std::endl;
- std::cout << "{" << std::endl;
-
- std::cout << "\"name\": \"" << entry_point.name << "\""
- << "," << std::endl;
- std::cout << "\"stage\": \"" << tint::cmd::EntryPointStageToString(entry_point.stage)
- << "\""
- << "," << std::endl;
+ std::cout << "\n{\n"
+ << "\"name\": \"" << entry_point.name << "\",\n"
+ << "\"stage\": \"" << tint::cmd::EntryPointStageToString(entry_point.stage)
+ << "\",\n";
if (entry_point.workgroup_size) {
std::cout << "\"workgroup_size\": [";
std::cout << entry_point.workgroup_size->x << ", " << entry_point.workgroup_size->y
- << ", " << entry_point.workgroup_size->z << "]"
- << "," << std::endl;
+ << ", " << entry_point.workgroup_size->z << "],\n";
}
std::cout << "\"input_variables\": [";
@@ -166,10 +154,7 @@
input_first = false;
stage_var(var);
}
- std::cout << std::endl
- << "]"
- << "," << std::endl;
-
+ std::cout << "\n],\n";
std::cout << "\"output_variables\": [";
bool output_first = true;
for (const auto& var : entry_point.output_variables) {
@@ -179,10 +164,7 @@
output_first = false;
stage_var(var);
}
- std::cout << std::endl
- << "]"
- << "," << std::endl;
-
+ std::cout << "\n],\n";
std::cout << "\"overrides\": [";
bool override_first = true;
@@ -192,21 +174,15 @@
}
override_first = false;
- std::cout << std::endl;
- std::cout << "{" << std::endl;
- std::cout << "\"name\": \"" << var.name << "\"," << std::endl;
- std::cout << "\"id\": " << var.id.value << "," << std::endl;
- std::cout << "\"type\": \"" << tint::cmd::OverrideTypeToString(var.type) << "\","
- << std::endl;
- std::cout << "\"is_initialized\": " << (var.is_initialized ? "true" : "false") << ","
- << std::endl;
- std::cout << "\"is_id_specified\": " << (var.is_id_specified ? "true" : "false")
- << std::endl;
- std::cout << "}";
+ std::cout << "\n{\n"
+ << "\"name\": \"" << var.name << "\",\n"
+ << "\"id\": " << var.id.value << ",\n"
+ << "\"type\": \"" << tint::cmd::OverrideTypeToString(var.type) << "\",\n"
+ << "\"is_initialized\": " << (var.is_initialized ? "true" : "false") << ",\n"
+ << "\"is_id_specified\": " << (var.is_id_specified ? "true" : "false")
+ << "\n}";
}
- std::cout << std::endl
- << "]"
- << "," << std::endl;
+ std::cout << "\n],\n";
std::cout << "\"bindings\": [";
auto bindings = inspector.GetResourceBindings(entry_point.name);
@@ -217,26 +193,24 @@
}
ep_first = false;
- std::cout << std::endl;
- std::cout << "{" << std::endl;
- std::cout << "\"binding\": " << binding.binding << "," << std::endl;
- std::cout << "\"group\": " << binding.bind_group << "," << std::endl;
- std::cout << "\"size\": " << binding.size << "," << std::endl;
- std::cout << "\"resource_type\": \""
- << tint::cmd::ResourceTypeToString(binding.resource_type) << "\","
- << std::endl;
- std::cout << "\"dimemsions\": \"" << tint::cmd::TextureDimensionToString(binding.dim)
- << "\"," << std::endl;
- std::cout << "\"sampled_kind\": \""
- << tint::cmd::SampledKindToString(binding.sampled_kind) << "\"," << std::endl;
- std::cout << "\"image_format\": \""
- << tint::cmd::TexelFormatToString(binding.image_format) << "\"" << std::endl;
- std::cout << "}";
+ std::cout << "\n{\n"
+ << "\"binding\": " << binding.binding << ",\n"
+ << "\"group\": " << binding.bind_group << ",\n"
+ << "\"size\": " << binding.size << ",\n"
+ << "\"resource_type\": \""
+ << tint::cmd::ResourceTypeToString(binding.resource_type) << "\",\n"
+ << "\"dimemsions\": \"" << tint::cmd::TextureDimensionToString(binding.dim)
+ << "\",\n"
+ << "\"sampled_kind\": \""
+ << tint::cmd::SampledKindToString(binding.sampled_kind) << "\",\n"
+ << "\"image_format\": \""
+ << tint::cmd::TexelFormatToString(binding.image_format) << "\"\n"
+ << "}";
}
- std::cout << std::endl << "]" << std::endl;
+ std::cout << "\n]\n";
std::cout << "}";
}
- std::cout << std::endl << "]," << std::endl;
+ std::cout << "\n],\n";
std::cout << "\"structures\": [";
bool struct_first = true;
@@ -251,19 +225,18 @@
}
struct_first = false;
- std::cout << std::endl;
- std::cout << "{" << std::endl;
- std::cout << "\"name\": \"" << s->FriendlyName() << "\"," << std::endl;
- std::cout << "\"align\": " << s->Align() << "," << std::endl;
- std::cout << "\"size\": " << s->Size() << "," << std::endl;
- std::cout << "\"members\": [";
+ std::cout << "\n{\n"
+ << "\"name\": \"" << s->FriendlyName() << "\",\n"
+ << "\"align\": " << s->Align() << ",\n"
+ << "\"size\": " << s->Size() << ",\n"
+ << "\"members\": [";
for (size_t i = 0; i < s->Members().Length(); ++i) {
auto* const m = s->Members()[i];
if (i != 0) {
std::cout << ",";
}
- std::cout << std::endl;
+ std::cout << "\n";
// Output field alignment padding, if any
auto* const prev_member = (i == 0) ? nullptr : s->Members()[i - 1];
@@ -271,39 +244,35 @@
uint32_t padding = m->Offset() - (prev_member->Offset() + prev_member->Size());
if (padding > 0) {
size_t padding_offset = m->Offset() - padding;
- std::cout << "{" << std::endl;
- std::cout << "\"name\": \"implicit_padding\"," << std::endl;
- std::cout << "\"offset\": " << padding_offset << "," << std::endl;
- std::cout << "\"align\": 1," << std::endl;
- std::cout << "\"size\": " << padding << std::endl;
- std::cout << "}," << std::endl;
+ std::cout << "{\n"
+ << "\"name\": \"implicit_padding\",\n"
+ << "\"offset\": " << padding_offset << ",\n"
+ << "\"align\": 1,\n"
+ << "\"size\": " << padding << "\n},\n";
}
}
- std::cout << "{" << std::endl;
- std::cout << "\"name\": \"" << m->Name().Name() << "\"," << std::endl;
- std::cout << "\"offset\": " << m->Offset() << "," << std::endl;
- std::cout << "\"align\": " << m->Align() << "," << std::endl;
- std::cout << "\"size\": " << m->Size() << std::endl;
- std::cout << "}";
+ std::cout << "{\n"
+ << "\"name\": \"" << m->Name().Name() << "\",\n"
+ << "\"offset\": " << m->Offset() << ",\n"
+ << "\"align\": " << m->Align() << ",\n"
+ << "\"size\": " << m->Size() << "\n}";
}
- std::cout << std::endl << "]" << std::endl;
- std::cout << "}";
+ std::cout << "\n]\n}";
}
- std::cout << std::endl << "]" << std::endl;
- std::cout << "}" << std::endl;
+ std::cout << "\n]\n}\n";
}
void EmitText(const tint::Program& program) {
auto printer = tint::StyledTextPrinter::Create(stdout);
tint::inspector::Inspector inspector(program);
if (!inspector.GetUsedExtensionNames().empty()) {
- std::cout << "Extensions:" << std::endl;
+ std::cout << "Extensions:\n";
for (const auto& name : inspector.GetUsedExtensionNames()) {
- std::cout << "\t" << name << std::endl;
+ std::cout << "\t" << name << "\n";
}
}
- std::cout << std::endl;
+ std::cout << "\n";
tint::cmd::PrintInspectorData(inspector);
@@ -317,7 +286,7 @@
}
if (has_struct) {
- std::cout << "Structures" << std::endl;
+ std::cout << "Structures\n";
for (const auto* ty : program.Types()) {
if (!ty->Is<tint::core::type::Struct>()) {
continue;
@@ -337,12 +306,12 @@
tint::SetInternalCompilerErrorReporter(&tint::cmd::TintInternalCompilerErrorReporter);
if (!ParseArgs(args, &options)) {
- std::cerr << "Failed to parse arguments." << std::endl;
+ std::cerr << "Failed to parse arguments.\n";
return 1;
}
if (options.show_help) {
- std::cout << kUsage << std::endl;
+ std::cout << kUsage << "\n";
return 0;
}
diff --git a/src/tint/cmd/loopy/main.cc b/src/tint/cmd/loopy/main.cc
index 7703f7a..37a6b4b 100644
--- a/src/tint/cmd/loopy/main.cc
+++ b/src/tint/cmd/loopy/main.cc
@@ -147,13 +147,13 @@
if (arg == "--format") {
++i;
if (i >= args.size()) {
- std::cerr << "Missing value for --format argument." << std::endl;
+ std::cerr << "Missing value for --format argument.\n";
return false;
}
opts->format = parse_format(args[i]);
if (opts->format == Format::kUnknown) {
- std::cerr << "Unknown output format: " << args[i] << std::endl;
+ std::cerr << "Unknown output format: " << args[i] << "\n";
return false;
}
} else if (arg == "-h" || arg == "--help") {
@@ -161,7 +161,7 @@
} else if (arg == "--loop") {
++i;
if (i >= args.size()) {
- std::cerr << "Missing value for --loop argument." << std::endl;
+ std::cerr << "Missing value for --loop argument.\n";
return false;
}
if (args[i] == "load") {
@@ -171,29 +171,29 @@
} else if (args[i] == "writer") {
opts->loop = Looper::kWriter;
} else {
- std::cerr << "Invalid loop value" << std::endl;
+ std::cerr << "Invalid loop value\n";
return false;
}
} else if (arg == "--loop-count") {
++i;
if (i >= args.size()) {
- std::cerr << "Missing value for --loop-count argument." << std::endl;
+ std::cerr << "Missing value for --loop-count argument.\n";
return false;
}
int32_t val = atoi(args[i].c_str());
if (val <= 0) {
- std::cerr << "Loop count must be greater then 0" << std::endl;
+ std::cerr << "Loop count must be greater then 0\n";
return false;
}
opts->loop_count = static_cast<uint32_t>(val);
} else if (!arg.empty()) {
if (arg[0] == '-') {
- std::cerr << "Unrecognized option: " << arg << std::endl;
+ std::cerr << "Unrecognized option: " << arg << "\n";
return false;
}
if (!opts->input_filename.empty()) {
std::cerr << "More than one input file specified: '" << opts->input_filename
- << "' and '" << arg << "'" << std::endl;
+ << "' and '" << arg << "'\n";
return false;
}
opts->input_filename = arg;
@@ -212,13 +212,13 @@
auto result = tint::spirv::writer::Generate(program, gen_options);
if (result != tint::Success) {
tint::cmd::PrintWGSL(std::cerr, program);
- std::cerr << "Failed to generate: " << result.Failure() << std::endl;
+ std::cerr << "Failed to generate: " << result.Failure() << "\n";
return false;
}
return true;
#else
(void)program;
- std::cerr << "SPIR-V writer not enabled in tint build" << std::endl;
+ std::cerr << "SPIR-V writer not enabled in tint build\n";
return false;
#endif // TINT_BUILD_SPV_WRITER
}
@@ -231,14 +231,14 @@
tint::wgsl::writer::Options gen_options;
auto result = tint::wgsl::writer::Generate(program, gen_options);
if (result != tint::Success) {
- std::cerr << "Failed to generate: " << result.Failure() << std::endl;
+ std::cerr << "Failed to generate: " << result.Failure() << "\n";
return false;
}
return true;
#else
(void)program;
- std::cerr << "WGSL writer not enabled in tint build" << std::endl;
+ std::cerr << "WGSL writer not enabled in tint build\n";
return false;
#endif // TINT_BUILD_WGSL_WRITER
}
@@ -248,7 +248,7 @@
/// @returns true on success
bool GenerateMsl([[maybe_unused]] const tint::Program& program) {
#if !TINT_BUILD_MSL_WRITER
- std::cerr << "MSL writer not enabled in tint build" << std::endl;
+ std::cerr << "MSL writer not enabled in tint build\n";
return false;
#else
// Remap resource numbers to a flat namespace.
@@ -269,7 +269,7 @@
auto result = tint::msl::writer::Generate(*input_program, gen_options);
if (result != tint::Success) {
tint::cmd::PrintWGSL(std::cerr, program);
- std::cerr << "Failed to generate: " << result.Failure() << std::endl;
+ std::cerr << "Failed to generate: " << result.Failure() << "\n";
return false;
}
@@ -287,14 +287,14 @@
auto result = tint::hlsl::writer::Generate(program, gen_options);
if (result != tint::Success) {
tint::cmd::PrintWGSL(std::cerr, program);
- std::cerr << "Failed to generate: " << result.Failure() << std::endl;
+ std::cerr << "Failed to generate: " << result.Failure() << "\n";
return false;
}
return true;
#else
(void)program;
- std::cerr << "HLSL writer not enabled in tint build" << std::endl;
+ std::cerr << "HLSL writer not enabled in tint build\n";
return false;
#endif // TINT_BUILD_HLSL_WRITER
}
@@ -310,7 +310,7 @@
auto result = tint::glsl::writer::Generate(program, gen_options, "");
if (result == tint::Success) {
tint::cmd::PrintWGSL(std::cerr, program);
- std::cerr << "Failed to generate: " << result.Failure() << std::endl;
+ std::cerr << "Failed to generate: " << result.Failure() << "\n";
return false;
}
@@ -318,7 +318,7 @@
#else
(void)program;
- std::cerr << "GLSL writer not enabled in tint build" << std::endl;
+ std::cerr << "GLSL writer not enabled in tint build\n";
return false;
#endif // TINT_BUILD_GLSL_WRITER
}
@@ -333,12 +333,12 @@
tint::SetInternalCompilerErrorReporter(&tint::cmd::TintInternalCompilerErrorReporter);
if (!ParseArgs(args, &options)) {
- std::cerr << "Failed to parse arguments." << std::endl;
+ std::cerr << "Failed to parse arguments.\n";
return 1;
}
if (options.show_help) {
- std::cout << kUsage << std::endl;
+ std::cout << kUsage << "\n";
return 0;
}
@@ -367,7 +367,7 @@
std::make_unique<tint::Program>(tint::wgsl::reader::Parse(source_file.get()));
}
#else
- std::cerr << "Tint not built with the WGSL reader enabled" << std::endl;
+ std::cerr << "Tint not built with the WGSL reader enabled\n";
exit(1);
#endif // TINT_BUILD_WGSL_READER
} else {
@@ -382,7 +382,7 @@
program = std::make_unique<tint::Program>(tint::spirv::reader::Read(data, {}));
}
#else
- std::cerr << "Tint not built with the SPIR-V reader enabled" << std::endl;
+ std::cerr << "Tint not built with the SPIR-V reader enabled\n";
exit(1);
#endif // TINT_BUILD_SPV_READER
}
@@ -402,7 +402,7 @@
for (uint32_t i = 0; i < loop_count; ++i) {
auto result = tint::wgsl::reader::ProgramToIR(info.program);
if (result != tint::Success) {
- std::cerr << "Failed to build IR from program: " << result.Failure() << std::endl;
+ std::cerr << "Failed to build IR from program: " << result.Failure() << "\n";
}
}
}
@@ -444,7 +444,7 @@
case Format::kNone:
break;
default:
- std::cerr << "Unknown output format specified" << std::endl;
+ std::cerr << "Unknown output format specified\n";
return 1;
}
}
diff --git a/src/tint/cmd/tint/main.cc b/src/tint/cmd/tint/main.cc
index 5203fec..b2dc66c 100644
--- a/src/tint/cmd/tint/main.cc
+++ b/src/tint/cmd/tint/main.cc
@@ -638,13 +638,13 @@
auto values = tint::Split(binding_format, "=");
if (values.Length() != 2) {
std::cerr << "Invalid binding format " << pixel_local_attachment_formats.name
- << ": " << binding_format << std::endl;
+ << ": " << binding_format << "\n";
return false;
}
auto member_index = tint::strconv::ParseUint32(values[0]);
if (member_index != tint::Success) {
std::cerr << "Invalid member index for " << pixel_local_attachment_formats.name
- << ": " << values[0] << std::endl;
+ << ": " << values[0] << "\n";
return false;
}
auto format = values[1];
@@ -658,7 +658,7 @@
texel_format = tint::PixelLocalOptions::TexelFormat::kR32Float;
} else {
std::cerr << "Invalid texel format for " << pixel_local_attachments.name << ": "
- << format << std::endl;
+ << format << "\n";
return false;
}
opts->pixel_local_options.attachment_formats.emplace(member_index.Get(), texel_format);
@@ -669,8 +669,7 @@
if (hlsl_shader_model.value.has_value()) {
uint32_t shader_model = *hlsl_shader_model.value;
if (shader_model < kMinShaderModelForDXC || shader_model > kMaxSupportedShaderModelForDXC) {
- std::cerr << "Invalid HLSL shader model "
- << ": " << shader_model << std::endl;
+ std::cerr << "Invalid HLSL shader model: " << shader_model << "\n";
return false;
}
opts->hlsl_shader_model = shader_model;
@@ -837,7 +836,7 @@
#else
(void)program;
(void)options;
- std::cerr << "SPIR-V writer not enabled in tint build" << std::endl;
+ std::cerr << "SPIR-V writer not enabled in tint build\n";
return false;
#endif // TINT_BUILD_SPV_WRITER
}
@@ -883,7 +882,7 @@
return true;
#else
- std::cerr << "WGSL writer not enabled in tint build" << std::endl;
+ std::cerr << "WGSL writer not enabled in tint build\n";
return false;
#endif // TINT_BUILD_WGSL_WRITER
}
@@ -895,7 +894,7 @@
bool GenerateMsl([[maybe_unused]] const tint::Program& program,
[[maybe_unused]] const Options& options) {
#if !TINT_BUILD_MSL_WRITER
- std::cerr << "MSL writer not enabled in tint build" << std::endl;
+ std::cerr << "MSL writer not enabled in tint build\n";
return false;
#else
// Remap resource numbers to a flat namespace.
@@ -1021,7 +1020,7 @@
auto result = tint::hlsl::writer::Generate(program, gen_options);
if (result != tint::Success) {
tint::cmd::PrintWGSL(std::cerr, program);
- std::cerr << "Failed to generate: " << result.Failure() << std::endl;
+ std::cerr << "Failed to generate: " << result.Failure() << "\n";
return false;
}
@@ -1092,28 +1091,24 @@
}
if (fxc_res.failed) {
- std::cerr << "FXC validation failure:" << std::endl << fxc_res.output << std::endl;
+ std::cerr << "FXC validation failure:\n" << fxc_res.output << "\n";
}
if (dxc_res.failed) {
- std::cerr << "DXC validation failure:" << std::endl << dxc_res.output << std::endl;
+ std::cerr << "DXC validation failure:\n" << dxc_res.output << "\n";
}
if (fxc_res.failed || dxc_res.failed) {
return false;
}
if (!fxc_found && !dxc_found) {
- std::cerr << "Couldn't find FXC or DXC. Cannot validate" << std::endl;
+ std::cerr << "Couldn't find FXC or DXC. Cannot validate\n";
return false;
}
if (options.verbose) {
if (fxc_found && !fxc_res.failed) {
- std::cout << "Passed FXC validation" << std::endl;
- std::cout << fxc_res.output;
- std::cout << std::endl;
+ std::cout << "Passed FXC validation\n" << fxc_res.output << "\n";
}
if (dxc_found && !dxc_res.failed) {
- std::cout << "Passed DXC validation" << std::endl;
- std::cout << dxc_res.output;
- std::cout << std::endl;
+ std::cout << "Passed DXC validation\n" << dxc_res.output << "\n";
}
}
}
@@ -1134,7 +1129,7 @@
bool GenerateGlsl([[maybe_unused]] const tint::Program& program,
[[maybe_unused]] const Options& options) {
#if !TINT_BUILD_GLSL_WRITER
- std::cerr << "GLSL writer not enabled in tint build" << std::endl;
+ std::cerr << "GLSL writer not enabled in tint build\n";
return false;
#else
tint::inspector::Inspector inspector(program);
@@ -1196,7 +1191,7 @@
if (options.validate && options.skip_hash.count(hash) == 0) {
#if !TINT_BUILD_GLSL_VALIDATOR
- std::cerr << "GLSL validator not enabled in tint build" << std::endl;
+ std::cerr << "GLSL validator not enabled in tint build\n";
return false;
#else
// If there is no entry point name there is nothing to validate
@@ -1245,7 +1240,7 @@
bool GenerateIr([[maybe_unused]] const tint::Program& program,
[[maybe_unused]] const Options& options) {
#if !TINT_BUILD_WGSL_READER
- std::cerr << "WGSL reader not enabled in tint build" << std::endl;
+ std::cerr << "WGSL reader not enabled in tint build\n";
return false;
#else
auto result = tint::wgsl::reader::ProgramToLoweredIR(program);
@@ -1299,10 +1294,10 @@
bool GenerateIrProtoBinary([[maybe_unused]] const tint::Program& program,
[[maybe_unused]] const Options& options) {
#if !TINT_BUILD_WGSL_READER
- std::cerr << "WGSL reader not enabled in tint build" << std::endl;
+ std::cerr << "WGSL reader not enabled in tint build\n";
return false;
#elif !TINT_BUILD_IR_BINARY
- std::cerr << "IR binary not enabled in tint build" << std::endl;
+ std::cerr << "IR binary not enabled in tint build\n";
return false;
#else
auto module = GenerateIrModule(program, options);
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc
index 34906d4..512ccc6 100644
--- a/src/tint/lang/core/ir/validator.cc
+++ b/src/tint/lang/core/ir/validator.cc
@@ -1609,9 +1609,9 @@
[[maybe_unused]] Capabilities capabilities) {
#if TINT_DUMP_IR_WHEN_VALIDATING
auto printer = StyledTextPrinter::Create(stdout);
- std::cout << "=========================================================" << std::endl;
- std::cout << "== IR dump before " << msg << ":" << std::endl;
- std::cout << "=========================================================" << std::endl;
+ std::cout << "=========================================================\n";
+ std::cout << "== IR dump before " << msg << ":\n";
+ std::cout << "=========================================================\n";
printer->Print(Disassemble(ir).Text());
#endif
diff --git a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
index 2345c72..c292f98 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
@@ -3603,7 +3603,7 @@
}
out << std::to_string(wgsize[i].value());
}
- out << ")]" << std::endl;
+ out << ")]\n";
}
if (!EmitTypeAndName(out, func_sem->ReturnType(), core::AddressSpace::kUndefined,
diff --git a/src/tint/lang/msl/writer/printer/printer.cc b/src/tint/lang/msl/writer/printer/printer.cc
index 71b31a0..f3c0d79 100644
--- a/src/tint/lang/msl/writer/printer/printer.cc
+++ b/src/tint/lang/msl/writer/printer/printer.cc
@@ -127,7 +127,7 @@
}
StringStream ss;
- ss << preamble_buffer_.String() << std::endl << main_buffer_.String();
+ ss << preamble_buffer_.String() << "\n" << main_buffer_.String();
result_.msl = ss.str();
return std::move(result_);
diff --git a/src/tint/lang/spirv/reader/ast_parser/function_cfg_test.cc b/src/tint/lang/spirv/reader/ast_parser/function_cfg_test.cc
index 015ffc8..4878a7f 100644
--- a/src/tint/lang/spirv/reader/ast_parser/function_cfg_test.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/function_cfg_test.cc
@@ -2613,7 +2613,7 @@
EXPECT_FALSE(fe.VerifyHeaderContinueMergeOrder());
tint::StringStream result;
- result << *fe.GetBlockInfo(50) << std::endl << *fe.GetBlockInfo(20) << std::endl;
+ result << *fe.GetBlockInfo(50) << "\n" << *fe.GetBlockInfo(20) << "\n";
EXPECT_THAT(p->error(), Eq("Header 50 does not strictly dominate its merge block 20"))
<< result.str() << Dump(fe.block_order());
}
@@ -2649,7 +2649,7 @@
fe.RegisterMerges();
EXPECT_FALSE(fe.VerifyHeaderContinueMergeOrder());
tint::StringStream str;
- str << *fe.GetBlockInfo(50) << std::endl << *fe.GetBlockInfo(20) << std::endl;
+ str << *fe.GetBlockInfo(50) << "\n" << *fe.GetBlockInfo(20) << "\n";
EXPECT_THAT(p->error(), Eq("Loop header 50 does not dominate its continue target 20"))
<< str.str() << Dump(fe.block_order());
}
diff --git a/src/tint/lang/spirv/reader/ast_parser/function_var_test.cc b/src/tint/lang/spirv/reader/ast_parser/function_var_test.cc
index 6b678e3..e8e562c 100644
--- a/src/tint/lang/spirv/reader/ast_parser/function_var_test.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/function_var_test.cc
@@ -465,8 +465,7 @@
OpFunctionEnd
)";
auto p = parser(test::Assemble(assembly));
- ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
- << assembly << p->error() << std::endl;
+ ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error() << "\n";
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables());
diff --git a/src/tint/lang/spirv/reader/ast_parser/handle_test.cc b/src/tint/lang/spirv/reader/ast_parser/handle_test.cc
index dd05ded..31f9a12 100644
--- a/src/tint/lang/spirv/reader/ast_parser/handle_test.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/handle_test.cc
@@ -956,9 +956,9 @@
OpFunctionEnd
)";
auto p = parser(test::Assemble(assembly));
- ASSERT_TRUE(p->BuildInternalModule()) << p->error() << assembly << std::endl;
- EXPECT_TRUE(p->RegisterHandleUsage()) << p->error() << assembly << std::endl;
- EXPECT_TRUE(p->error().empty()) << p->error() << assembly << std::endl;
+ ASSERT_TRUE(p->BuildInternalModule()) << p->error() << assembly << "\n";
+ EXPECT_TRUE(p->RegisterHandleUsage()) << p->error() << assembly << "\n";
+ EXPECT_TRUE(p->error().empty()) << p->error() << assembly << "\n";
Usage su = p->GetHandleUsage(10);
Usage iu = p->GetHandleUsage(20);
@@ -3087,7 +3087,7 @@
for (auto e : c.expected_expressions) {
out << e << ",";
}
- out << ")" << std::endl;
+ out << ")\n";
return out;
}
diff --git a/src/tint/lang/spirv/reader/ast_parser/helper_test.cc b/src/tint/lang/spirv/reader/ast_parser/helper_test.cc
index 5091bbe..e497d98 100644
--- a/src/tint/lang/spirv/reader/ast_parser/helper_test.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/helper_test.cc
@@ -44,7 +44,7 @@
if (dump_successfully_converted_spirv_ && !skip_dumping_spirv_ && !impl_.spv_binary().empty() &&
impl_.success()) {
std::string disassembly = Disassemble(impl_.spv_binary());
- std::cout << "BEGIN ConvertedOk:\n" << disassembly << "\nEND ConvertedOk" << std::endl;
+ std::cout << "BEGIN ConvertedOk:\n" << disassembly << "\nEND ConvertedOk\n";
}
}
diff --git a/src/tint/lang/wgsl/ast/transform/manager.cc b/src/tint/lang/wgsl/ast/transform/manager.cc
index 741a302..a641c1a 100644
--- a/src/tint/lang/wgsl/ast/transform/manager.cc
+++ b/src/tint/lang/wgsl/ast/transform/manager.cc
@@ -53,18 +53,16 @@
#if TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM
auto print_program = [&](const char* msg, const Transform* transform) {
auto wgsl = Program::printer(*program);
- std::cout << "=========================================================" << std::endl;
+ std::cout << "=========================================================\n";
std::cout << "== " << msg << " "
- << (transform ? transform->TypeInfo().name : "transform manager") << ":"
- << std::endl;
- std::cout << "=========================================================" << std::endl;
- std::cout << wgsl << std::endl;
+ << (transform ? transform->TypeInfo().name : "transform manager") << ":\n";
+ std::cout << "=========================================================\n";
+ std::cout << wgsl << "\n";
if (!program->IsValid()) {
- std::cout << "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" << std::endl;
- std::cout << program->Diagnostics() << std::endl;
+ std::cout << "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n"
+ << program->Diagnostics() << "\n";
}
- std::cout << "=========================================================" << std::endl
- << std::endl;
+ std::cout << "=========================================================\n\n";
};
#endif
@@ -84,8 +82,7 @@
TINT_IF_PRINT_PROGRAM(print_program("Output of", transform.get()));
} else {
- TINT_IF_PRINT_PROGRAM(std::cout << "Skipped " << transform->TypeInfo().name
- << std::endl);
+ TINT_IF_PRINT_PROGRAM(std::cout << "Skipped " << transform->TypeInfo().name << "\n");
}
}
diff --git a/src/tint/lang/wgsl/ir_roundtrip_fuzz.cc b/src/tint/lang/wgsl/ir_roundtrip_fuzz.cc
index 0dfc83d..16efce4 100644
--- a/src/tint/lang/wgsl/ir_roundtrip_fuzz.cc
+++ b/src/tint/lang/wgsl/ir_roundtrip_fuzz.cc
@@ -47,9 +47,9 @@
program_options.allowed_features = AllowedFeatures::Everything();
auto dst = tint::wgsl::writer::IRToProgram(ir, program_options);
if (!dst.IsValid()) {
- std::cerr << "IR:\n" << core::ir::Disassemble(ir).Plain() << std::endl;
+ std::cerr << "IR:\n" << core::ir::Disassemble(ir).Plain() << "\n";
if (auto result = tint::wgsl::writer::Generate(dst, {}); result == Success) {
- std::cerr << "WGSL:\n" << result->wgsl << std::endl << std::endl;
+ std::cerr << "WGSL:\n" << result->wgsl << "\n\n";
}
TINT_ICE() << dst.Diagnostics();
}
diff --git a/src/tint/lang/wgsl/ir_roundtrip_test.cc b/src/tint/lang/wgsl/ir_roundtrip_test.cc
index 35308c6..52e8abb 100644
--- a/src/tint/lang/wgsl/ir_roundtrip_test.cc
+++ b/src/tint/lang/wgsl/ir_roundtrip_test.cc
@@ -118,32 +118,28 @@
std::ostream& operator<<(std::ostream& o, const IRToProgramRoundtripTest::Result& res) {
if (!res.err.empty()) {
- o << "============================" << std::endl
- << "== Error ==" << std::endl
- << "============================" << std::endl
- << res.err << std::endl
- << std::endl;
+ o << "============================\n"
+ << "== Error ==\n"
+ << "============================\n"
+ << res.err << "\n\n";
}
if (!res.ir_pre_raise.empty()) {
- o << "============================" << std::endl
- << "== IR (pre-raise) ==" << std::endl
- << "============================" << std::endl
- << res.ir_pre_raise << std::endl
- << std::endl;
+ o << "============================\n"
+ << "== IR (pre-raise) ==\n"
+ << "============================\n"
+ << res.ir_pre_raise << "\n\n";
}
if (!res.ir_post_raise.empty()) {
- o << "============================" << std::endl
- << "== IR (post-raise) ==" << std::endl
- << "============================" << std::endl
- << res.ir_post_raise << std::endl
- << std::endl;
+ o << "============================\n"
+ << "== IR (post-raise) ==\n"
+ << "============================\n"
+ << res.ir_post_raise << "\n\n";
}
if (!res.ast.empty()) {
- o << "============================" << std::endl
- << "== AST ==" << std::endl
- << "============================" << std::endl
- << res.ast << std::endl
- << std::endl;
+ o << "============================\n"
+ << "== AST ==\n"
+ << "============================\n"
+ << res.ast << "\n\n";
}
return o;
}
diff --git a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.h b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.h
index f7a1338..92cbdd8 100644
--- a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.h
+++ b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.h
@@ -99,19 +99,17 @@
}
};
-#define EXPECT_WGSL(expected_wgsl) \
- do { \
- if (auto got = Run(); got.err.empty()) { \
- auto expected = std::string(tint::TrimSpace(expected_wgsl)); \
- if (!expected.empty()) { \
- expected = "\n" + expected + "\n"; \
- } \
- EXPECT_EQ(expected, got.wgsl) << "IR: " << got.ir; \
- } else { \
- FAIL() << got.err << std::endl \
- << "IR: " << got.ir << std::endl \
- << "AST: " << got.ast << std::endl; \
- } \
+#define EXPECT_WGSL(expected_wgsl) \
+ do { \
+ if (auto got = Run(); got.err.empty()) { \
+ auto expected = std::string(tint::TrimSpace(expected_wgsl)); \
+ if (!expected.empty()) { \
+ expected = "\n" + expected + "\n"; \
+ } \
+ EXPECT_EQ(expected, got.wgsl) << "IR: " << got.ir; \
+ } else { \
+ FAIL() << got.err << "\nIR: " << got.ir << "\nAST: " << got.ast << "\n"; \
+ } \
} while (false)
} // namespace tint::wgsl::writer
diff --git a/src/tint/lang/wgsl/writer/writer_test.cc b/src/tint/lang/wgsl/writer/writer_test.cc
index d9e573c..3477d2a 100644
--- a/src/tint/lang/wgsl/writer/writer_test.cc
+++ b/src/tint/lang/wgsl/writer/writer_test.cc
@@ -108,32 +108,28 @@
std::ostream& operator<<(std::ostream& o, const WgslIRWriterTest::Result& res) {
if (!res.err.empty()) {
- o << "============================" << std::endl
- << "== Error ==" << std::endl
- << "============================" << std::endl
- << res.err << std::endl
- << std::endl;
+ o << "============================\n"
+ << "== Error ==\n"
+ << "============================\n"
+ << res.err << "\n\n";
}
if (!res.ir_pre_raise.empty()) {
- o << "============================" << std::endl
- << "== IR (pre-raise) ==" << std::endl
- << "============================" << std::endl
- << res.ir_pre_raise << std::endl
- << std::endl;
+ o << "============================\n"
+ << "== IR (pre-raise) ==\n"
+ << "============================\n"
+ << res.ir_pre_raise << "\n\n";
}
if (!res.ir_post_raise.empty()) {
- o << "============================" << std::endl
- << "== IR (post-raise) ==" << std::endl
- << "============================" << std::endl
- << res.ir_post_raise << std::endl
- << std::endl;
+ o << "============================\n"
+ << "== IR (post-raise) ==\n"
+ << "============================\n"
+ << res.ir_post_raise << "\n\n";
}
if (!res.ast.empty()) {
- o << "============================" << std::endl
- << "== AST ==" << std::endl
- << "============================" << std::endl
- << res.ast << std::endl
- << std::endl;
+ o << "============================\n"
+ << "== AST ==\n"
+ << "============================\n"
+ << res.ast << "\n\n";
}
return o;
}
diff --git a/src/tint/utils/cli/cli.cc b/src/tint/utils/cli/cli.cc
index 6b00638..b1a98e2 100644
--- a/src/tint/utils/cli/cli.cc
+++ b/src/tint/utils/cli/cli.cc
@@ -115,7 +115,7 @@
if (left_lines[i].length() > left_width) {
// Left exceeds column width.
// Insert a new line and indent to the right
- s_out << std::endl;
+ s_out << "\n";
pad(left_width);
} else {
pad(left_width - left_lines[i].length());
@@ -127,7 +127,7 @@
if (has_right) {
s_out << " " << right_lines[i];
}
- s_out << std::endl;
+ s_out << "\n";
}
}
}
diff --git a/src/tint/utils/cli/cli_test.cc b/src/tint/utils/cli/cli_test.cc
index 470a3b7..5f38c65 100644
--- a/src/tint/utils/cli/cli_test.cc
+++ b/src/tint/utils/cli/cli_test.cc
@@ -51,7 +51,7 @@
opts.Add<ValueOption<int>>("my_option", "sets the awesome value");
std::stringstream out;
- out << std::endl;
+ out << "\n";
opts.ShowHelp(out);
EXPECT_EQ(out.str(), R"(
--my_option <value> sets the awesome value
@@ -63,7 +63,7 @@
opts.Add<ValueOption<int>>("my_option", "sets the awesome value", Alias{"alias"});
std::stringstream out;
- out << std::endl;
+ out << "\n";
opts.ShowHelp(out);
EXPECT_EQ(out.str(), R"(
--my_option <value> sets the awesome value
@@ -75,7 +75,7 @@
opts.Add<ValueOption<int>>("my_option", "sets the awesome value", ShortName{"a"});
std::stringstream out;
- out << std::endl;
+ out << "\n";
opts.ShowHelp(out);
EXPECT_EQ(out.str(), R"(
--my_option <value> sets the awesome value
@@ -91,7 +91,7 @@
)");
std::stringstream out;
- out << std::endl;
+ out << "\n";
opts.ShowHelp(out);
EXPECT_EQ(out.str(), R"(
--an-option <value> this is a
@@ -107,7 +107,7 @@
"this is an option that has a silly long name", ShortName{"a"});
std::stringstream out;
- out << std::endl;
+ out << "\n";
opts.ShowHelp(out);
EXPECT_EQ(out.str(), R"(
--an-option-with-a-really-really-long-name <value>
@@ -128,7 +128,7 @@
});
std::stringstream out;
- out << std::endl;
+ out << "\n";
opts.ShowHelp(out);
EXPECT_EQ(out.str(), R"(
--my_enum_option <X|Y|Z> sets the awesome value
@@ -150,7 +150,7 @@
});
std::stringstream out;
- out << std::endl;
+ out << "\n";
opts.ShowHelp(out);
EXPECT_EQ(out.str(), R"(
--option-a <value> an integer
diff --git a/src/tint/utils/diagnostic/source.cc b/src/tint/utils/diagnostic/source.cc
index 47d8831..8f07d77 100644
--- a/src/tint/utils/diagnostic/source.cc
+++ b/src/tint/utils/diagnostic/source.cc
@@ -151,7 +151,7 @@
}
if (source.file) {
- out << std::endl << std::endl;
+ out << "\n\n";
auto repeat = [&](char c, size_t n) {
while (n--) {
@@ -163,9 +163,7 @@
if (line < source.file->content.lines.size() + 1) {
auto len = source.file->content.lines[line - 1].size();
- out << source.file->content.lines[line - 1];
-
- out << std::endl;
+ out << source.file->content.lines[line - 1] << "\n";
if (line == rng.begin.line && line == rng.end.line) {
// Single line
@@ -183,7 +181,7 @@
repeat('^', len);
}
- out << std::endl;
+ out << "\n";
}
}
}
diff --git a/src/tint/utils/generator/text_generator.cc b/src/tint/utils/generator/text_generator.cc
index e1ea901..00e022d 100644
--- a/src/tint/utils/generator/text_generator.cc
+++ b/src/tint/utils/generator/text_generator.cc
@@ -109,7 +109,7 @@
}
ss << line.content;
}
- ss << std::endl;
+ ss << "\n";
}
return ss.str();
}
diff --git a/src/tint/utils/ice/ice.cc b/src/tint/utils/ice/ice.cc
index aac1eb9..c36b207 100644
--- a/src/tint/utils/ice/ice.cc
+++ b/src/tint/utils/ice/ice.cc
@@ -53,7 +53,7 @@
if (ice_reporter) {
ice_reporter(*this);
} else {
- std::cerr << Error() << std::endl << std::endl;
+ std::cerr << Error() << "\n\n";
}
debugger::Break();