Skip to content

Commit daef0fd

Browse files
authored
Rollup merge of #123437 - Zalathar:clang-format, r=cuviper
Manually run `clang-format` on `CoverageMappingWrapper.cpp` In the current version of #123409, there are several unrelated changes to `CoverageMappingWrapper.cpp` that seem to be the result of running `clang-format` on that file. Instead of asking for those changes to be undone, I figure it's easier to just make them myself as a separate PR, since I was vaguely intending to do that at some point anyway. In a few cases I've strategically added comments to make the grouping of parameters a little nicer, but mostly it doesn't matter much.
2 parents 50603cb + f6b97ef commit daef0fd

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp

+20-28
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "LLVMWrapper.h"
2+
#include "llvm/ADT/ArrayRef.h"
23
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
34
#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h"
45
#include "llvm/ProfileData/InstrProf.h"
5-
#include "llvm/ADT/ArrayRef.h"
66

77
#include <iostream>
88

@@ -103,35 +103,30 @@ fromRust(LLVMRustCounterExprKind Kind) {
103103
}
104104

105105
extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer(
106-
const char *const Filenames[],
107-
size_t FilenamesLen,
108-
const size_t *const Lengths,
109-
size_t LengthsLen,
106+
const char *const Filenames[], size_t FilenamesLen, // String start pointers
107+
const size_t *const Lengths, size_t LengthsLen, // Corresponding lengths
110108
RustStringRef BufferOut) {
111109
if (FilenamesLen != LengthsLen) {
112110
report_fatal_error(
113111
"Mismatched lengths in LLVMRustCoverageWriteFilenamesSectionToBuffer");
114112
}
115113

116-
SmallVector<std::string,32> FilenameRefs;
114+
SmallVector<std::string, 32> FilenameRefs;
117115
FilenameRefs.reserve(FilenamesLen);
118116
for (size_t i = 0; i < FilenamesLen; i++) {
119117
FilenameRefs.emplace_back(Filenames[i], Lengths[i]);
120118
}
121-
auto FilenamesWriter =
122-
coverage::CoverageFilenamesSectionWriter(ArrayRef<std::string>(FilenameRefs));
119+
auto FilenamesWriter = coverage::CoverageFilenamesSectionWriter(
120+
ArrayRef<std::string>(FilenameRefs));
123121
auto OS = RawRustStringOstream(BufferOut);
124122
FilenamesWriter.write(OS);
125123
}
126124

127125
extern "C" void LLVMRustCoverageWriteMappingToBuffer(
128-
const unsigned *VirtualFileMappingIDs,
129-
unsigned NumVirtualFileMappingIDs,
130-
const LLVMRustCounterExpression *RustExpressions,
131-
unsigned NumExpressions,
126+
const unsigned *VirtualFileMappingIDs, unsigned NumVirtualFileMappingIDs,
127+
const LLVMRustCounterExpression *RustExpressions, unsigned NumExpressions,
132128
const LLVMRustCounterMappingRegion *RustMappingRegions,
133-
unsigned NumMappingRegions,
134-
RustStringRef BufferOut) {
129+
unsigned NumMappingRegions, RustStringRef BufferOut) {
135130
// Convert from FFI representation to LLVM representation.
136131
SmallVector<coverage::CounterMappingRegion, 0> MappingRegions;
137132
MappingRegions.reserve(NumMappingRegions);
@@ -142,7 +137,7 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
142137
#if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
143138
coverage::CounterMappingRegion::MCDCParameters{},
144139
#endif
145-
Region.FileID, Region.ExpandedFileID,
140+
Region.FileID, Region.ExpandedFileID, // File IDs, then region info.
146141
Region.LineStart, Region.ColumnStart, Region.LineEnd, Region.ColumnEnd,
147142
fromRust(Region.Kind));
148143
}
@@ -158,29 +153,25 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
158153

159154
auto CoverageMappingWriter = coverage::CoverageMappingWriter(
160155
ArrayRef<unsigned>(VirtualFileMappingIDs, NumVirtualFileMappingIDs),
161-
Expressions,
162-
MappingRegions);
156+
Expressions, MappingRegions);
163157
auto OS = RawRustStringOstream(BufferOut);
164158
CoverageMappingWriter.write(OS);
165159
}
166160

167-
extern "C" LLVMValueRef LLVMRustCoverageCreatePGOFuncNameVar(
168-
LLVMValueRef F,
169-
const char *FuncName,
170-
size_t FuncNameLen) {
161+
extern "C" LLVMValueRef
162+
LLVMRustCoverageCreatePGOFuncNameVar(LLVMValueRef F, const char *FuncName,
163+
size_t FuncNameLen) {
171164
auto FuncNameRef = StringRef(FuncName, FuncNameLen);
172165
return wrap(createPGOFuncNameVar(*cast<Function>(unwrap(F)), FuncNameRef));
173166
}
174167

175-
extern "C" uint64_t LLVMRustCoverageHashByteArray(
176-
const char *Bytes,
177-
size_t NumBytes) {
168+
extern "C" uint64_t LLVMRustCoverageHashByteArray(const char *Bytes,
169+
size_t NumBytes) {
178170
auto StrRef = StringRef(Bytes, NumBytes);
179171
return IndexedInstrProf::ComputeHash(StrRef);
180172
}
181173

182-
static void WriteSectionNameToString(LLVMModuleRef M,
183-
InstrProfSectKind SK,
174+
static void WriteSectionNameToString(LLVMModuleRef M, InstrProfSectKind SK,
184175
RustStringRef Str) {
185176
auto TargetTriple = Triple(unwrap(M)->getTargetTriple());
186177
auto name = getInstrProfSectionName(SK, TargetTriple.getObjectFormat());
@@ -193,8 +184,9 @@ extern "C" void LLVMRustCoverageWriteMapSectionNameToString(LLVMModuleRef M,
193184
WriteSectionNameToString(M, IPSK_covmap, Str);
194185
}
195186

196-
extern "C" void LLVMRustCoverageWriteFuncSectionNameToString(LLVMModuleRef M,
197-
RustStringRef Str) {
187+
extern "C" void
188+
LLVMRustCoverageWriteFuncSectionNameToString(LLVMModuleRef M,
189+
RustStringRef Str) {
198190
WriteSectionNameToString(M, IPSK_covfun, Str);
199191
}
200192

0 commit comments

Comments
 (0)