diff --git a/llvm/include/llvm/ADT/None.h b/llvm/include/llvm/ADT/None.h index 5793bd2faef4..c78db78597cc 100644 --- a/llvm/include/llvm/ADT/None.h +++ b/llvm/include/llvm/ADT/None.h @@ -19,9 +19,8 @@ namespace llvm { /// \brief A simple null object to allow implicit construction of Optional /// and similar types without having to spell out the specialization's name. -enum NoneType { - None -}; +enum class NoneType { None }; +static NoneType None; } #endif diff --git a/llvm/lib/ProfileData/CoverageMapping.cpp b/llvm/lib/ProfileData/CoverageMapping.cpp index a124d792e875..da619e1bf9f8 100644 --- a/llvm/lib/ProfileData/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/CoverageMapping.cpp @@ -361,7 +361,9 @@ static Optional findMainViewFileID(StringRef SourceFile, IsNotExpandedFile[CR.ExpandedFileID] = false; IsNotExpandedFile &= FilenameEquivalence; int I = IsNotExpandedFile.find_first(); - return I != -1 ? I : None; + if (I == -1) + return None; + return I; } static Optional findMainViewFileID(const FunctionRecord &Function) { @@ -370,7 +372,9 @@ static Optional findMainViewFileID(const FunctionRecord &Function) { if (CR.Kind == CounterMappingRegion::ExpansionRegion) IsNotExpandedFile[CR.ExpandedFileID] = false; int I = IsNotExpandedFile.find_first(); - return I != -1 ? I : None; + if (I == -1) + return None; + return I; } /// Sort a nested sequence of regions from a single file.