Manually run clang-format
on CoverageMappingWrapper.cpp
This commit is contained in:
parent
4fd4797c26
commit
f6b97ef5e5
@ -1,8 +1,8 @@
|
|||||||
#include "LLVMWrapper.h"
|
#include "LLVMWrapper.h"
|
||||||
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
|
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
|
||||||
#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h"
|
#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h"
|
||||||
#include "llvm/ProfileData/InstrProf.h"
|
#include "llvm/ProfileData/InstrProf.h"
|
||||||
#include "llvm/ADT/ArrayRef.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -103,35 +103,30 @@ fromRust(LLVMRustCounterExprKind Kind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer(
|
extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer(
|
||||||
const char *const Filenames[],
|
const char *const Filenames[], size_t FilenamesLen, // String start pointers
|
||||||
size_t FilenamesLen,
|
const size_t *const Lengths, size_t LengthsLen, // Corresponding lengths
|
||||||
const size_t *const Lengths,
|
|
||||||
size_t LengthsLen,
|
|
||||||
RustStringRef BufferOut) {
|
RustStringRef BufferOut) {
|
||||||
if (FilenamesLen != LengthsLen) {
|
if (FilenamesLen != LengthsLen) {
|
||||||
report_fatal_error(
|
report_fatal_error(
|
||||||
"Mismatched lengths in LLVMRustCoverageWriteFilenamesSectionToBuffer");
|
"Mismatched lengths in LLVMRustCoverageWriteFilenamesSectionToBuffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallVector<std::string,32> FilenameRefs;
|
SmallVector<std::string, 32> FilenameRefs;
|
||||||
FilenameRefs.reserve(FilenamesLen);
|
FilenameRefs.reserve(FilenamesLen);
|
||||||
for (size_t i = 0; i < FilenamesLen; i++) {
|
for (size_t i = 0; i < FilenamesLen; i++) {
|
||||||
FilenameRefs.emplace_back(Filenames[i], Lengths[i]);
|
FilenameRefs.emplace_back(Filenames[i], Lengths[i]);
|
||||||
}
|
}
|
||||||
auto FilenamesWriter =
|
auto FilenamesWriter = coverage::CoverageFilenamesSectionWriter(
|
||||||
coverage::CoverageFilenamesSectionWriter(ArrayRef<std::string>(FilenameRefs));
|
ArrayRef<std::string>(FilenameRefs));
|
||||||
auto OS = RawRustStringOstream(BufferOut);
|
auto OS = RawRustStringOstream(BufferOut);
|
||||||
FilenamesWriter.write(OS);
|
FilenamesWriter.write(OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustCoverageWriteMappingToBuffer(
|
extern "C" void LLVMRustCoverageWriteMappingToBuffer(
|
||||||
const unsigned *VirtualFileMappingIDs,
|
const unsigned *VirtualFileMappingIDs, unsigned NumVirtualFileMappingIDs,
|
||||||
unsigned NumVirtualFileMappingIDs,
|
const LLVMRustCounterExpression *RustExpressions, unsigned NumExpressions,
|
||||||
const LLVMRustCounterExpression *RustExpressions,
|
|
||||||
unsigned NumExpressions,
|
|
||||||
const LLVMRustCounterMappingRegion *RustMappingRegions,
|
const LLVMRustCounterMappingRegion *RustMappingRegions,
|
||||||
unsigned NumMappingRegions,
|
unsigned NumMappingRegions, RustStringRef BufferOut) {
|
||||||
RustStringRef BufferOut) {
|
|
||||||
// Convert from FFI representation to LLVM representation.
|
// Convert from FFI representation to LLVM representation.
|
||||||
SmallVector<coverage::CounterMappingRegion, 0> MappingRegions;
|
SmallVector<coverage::CounterMappingRegion, 0> MappingRegions;
|
||||||
MappingRegions.reserve(NumMappingRegions);
|
MappingRegions.reserve(NumMappingRegions);
|
||||||
@ -142,7 +137,7 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
|
|||||||
#if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
|
#if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
|
||||||
coverage::CounterMappingRegion::MCDCParameters{},
|
coverage::CounterMappingRegion::MCDCParameters{},
|
||||||
#endif
|
#endif
|
||||||
Region.FileID, Region.ExpandedFileID,
|
Region.FileID, Region.ExpandedFileID, // File IDs, then region info.
|
||||||
Region.LineStart, Region.ColumnStart, Region.LineEnd, Region.ColumnEnd,
|
Region.LineStart, Region.ColumnStart, Region.LineEnd, Region.ColumnEnd,
|
||||||
fromRust(Region.Kind));
|
fromRust(Region.Kind));
|
||||||
}
|
}
|
||||||
@ -158,29 +153,25 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
|
|||||||
|
|
||||||
auto CoverageMappingWriter = coverage::CoverageMappingWriter(
|
auto CoverageMappingWriter = coverage::CoverageMappingWriter(
|
||||||
ArrayRef<unsigned>(VirtualFileMappingIDs, NumVirtualFileMappingIDs),
|
ArrayRef<unsigned>(VirtualFileMappingIDs, NumVirtualFileMappingIDs),
|
||||||
Expressions,
|
Expressions, MappingRegions);
|
||||||
MappingRegions);
|
|
||||||
auto OS = RawRustStringOstream(BufferOut);
|
auto OS = RawRustStringOstream(BufferOut);
|
||||||
CoverageMappingWriter.write(OS);
|
CoverageMappingWriter.write(OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMValueRef LLVMRustCoverageCreatePGOFuncNameVar(
|
extern "C" LLVMValueRef
|
||||||
LLVMValueRef F,
|
LLVMRustCoverageCreatePGOFuncNameVar(LLVMValueRef F, const char *FuncName,
|
||||||
const char *FuncName,
|
size_t FuncNameLen) {
|
||||||
size_t FuncNameLen) {
|
|
||||||
auto FuncNameRef = StringRef(FuncName, FuncNameLen);
|
auto FuncNameRef = StringRef(FuncName, FuncNameLen);
|
||||||
return wrap(createPGOFuncNameVar(*cast<Function>(unwrap(F)), FuncNameRef));
|
return wrap(createPGOFuncNameVar(*cast<Function>(unwrap(F)), FuncNameRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uint64_t LLVMRustCoverageHashByteArray(
|
extern "C" uint64_t LLVMRustCoverageHashByteArray(const char *Bytes,
|
||||||
const char *Bytes,
|
size_t NumBytes) {
|
||||||
size_t NumBytes) {
|
|
||||||
auto StrRef = StringRef(Bytes, NumBytes);
|
auto StrRef = StringRef(Bytes, NumBytes);
|
||||||
return IndexedInstrProf::ComputeHash(StrRef);
|
return IndexedInstrProf::ComputeHash(StrRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteSectionNameToString(LLVMModuleRef M,
|
static void WriteSectionNameToString(LLVMModuleRef M, InstrProfSectKind SK,
|
||||||
InstrProfSectKind SK,
|
|
||||||
RustStringRef Str) {
|
RustStringRef Str) {
|
||||||
auto TargetTriple = Triple(unwrap(M)->getTargetTriple());
|
auto TargetTriple = Triple(unwrap(M)->getTargetTriple());
|
||||||
auto name = getInstrProfSectionName(SK, TargetTriple.getObjectFormat());
|
auto name = getInstrProfSectionName(SK, TargetTriple.getObjectFormat());
|
||||||
@ -193,8 +184,9 @@ extern "C" void LLVMRustCoverageWriteMapSectionNameToString(LLVMModuleRef M,
|
|||||||
WriteSectionNameToString(M, IPSK_covmap, Str);
|
WriteSectionNameToString(M, IPSK_covmap, Str);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustCoverageWriteFuncSectionNameToString(LLVMModuleRef M,
|
extern "C" void
|
||||||
RustStringRef Str) {
|
LLVMRustCoverageWriteFuncSectionNameToString(LLVMModuleRef M,
|
||||||
|
RustStringRef Str) {
|
||||||
WriteSectionNameToString(M, IPSK_covfun, Str);
|
WriteSectionNameToString(M, IPSK_covfun, Str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user