From e3b557809604d036af6e00c60f012c2025b59a5e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 11 Feb 2023 13:38:04 +0100 Subject: Vendor import of llvm-project main llvmorg-16-init-18548-gb0daacf58f41, the last commit before the upstream release/17.x branch was created. --- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 25 ++++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp') diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 8c1eadbe8271..6113f78aeb4e 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -14,8 +14,6 @@ #include "llvm/ProfileData/Coverage/CoverageMapping.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -33,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -455,10 +454,10 @@ class SegmentBuilder { /// Emit segments for active regions which end before \p Loc. /// - /// \p Loc: The start location of the next region. If None, all active + /// \p Loc: The start location of the next region. If std::nullopt, all active /// regions are completed. /// \p FirstCompletedRegion: Index of the first completed region. - void completeRegionsUntil(Optional Loc, + void completeRegionsUntil(std::optional Loc, unsigned FirstCompletedRegion) { // Sort the completed regions by end location. This makes it simple to // emit closing segments in sorted order. @@ -557,7 +556,7 @@ class SegmentBuilder { // Complete any remaining active regions. if (!ActiveRegions.empty()) - completeRegionsUntil(None, 0); + completeRegionsUntil(std::nullopt, 0); } /// Sort a nested sequence of regions from a single file. @@ -676,25 +675,27 @@ static SmallBitVector gatherFileIDs(StringRef SourceFile, } /// Return the ID of the file where the definition of the function is located. -static Optional findMainViewFileID(const FunctionRecord &Function) { +static std::optional +findMainViewFileID(const FunctionRecord &Function) { SmallBitVector IsNotExpandedFile(Function.Filenames.size(), true); for (const auto &CR : Function.CountedRegions) if (CR.Kind == CounterMappingRegion::ExpansionRegion) IsNotExpandedFile[CR.ExpandedFileID] = false; int I = IsNotExpandedFile.find_first(); if (I == -1) - return None; + return std::nullopt; return I; } /// Check if SourceFile is the file that contains the definition of -/// the Function. Return the ID of the file in that case or None otherwise. -static Optional findMainViewFileID(StringRef SourceFile, - const FunctionRecord &Function) { - Optional I = findMainViewFileID(Function); +/// the Function. Return the ID of the file in that case or std::nullopt +/// otherwise. +static std::optional +findMainViewFileID(StringRef SourceFile, const FunctionRecord &Function) { + std::optional I = findMainViewFileID(Function); if (I && SourceFile == Function.Filenames[*I]) return I; - return None; + return std::nullopt; } static bool isExpansion(const CountedRegion &R, unsigned FileID) { -- cgit v1.2.3