[clang-tools-extra] 67854f9 - Use value_or instead of getValueOr. NFC

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 29 21:55:08 PDT 2022


Author: Fangrui Song
Date: 2022-06-29T21:55:02-07:00
New Revision: 67854f9ed0cd512f59736730f4c05de25501ae54

URL: https://github.com/llvm/llvm-project/commit/67854f9ed0cd512f59736730f4c05de25501ae54
DIFF: https://github.com/llvm/llvm-project/commit/67854f9ed0cd512f59736730f4c05de25501ae54.diff

LOG: Use value_or instead of getValueOr. NFC

Added: 
    

Modified: 
    clang-tools-extra/clangd/unittests/support/FileCacheTests.cpp
    clang-tools-extra/clangd/xpc/XPCTransport.cpp
    lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
    lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
    llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
    llvm/lib/Support/Windows/Threading.inc
    llvm/unittests/Support/UnicodeTest.cpp
    mlir/lib/TableGen/AttrOrTypeDef.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/unittests/support/FileCacheTests.cpp b/clang-tools-extra/clangd/unittests/support/FileCacheTests.cpp
index 1f554806def08..8d2bc4d15d7b9 100644
--- a/clang-tools-extra/clangd/unittests/support/FileCacheTests.cpp
+++ b/clang-tools-extra/clangd/unittests/support/FileCacheTests.cpp
@@ -42,7 +42,7 @@ class TestCache : public FileCache {
         FS, FreshTime,
         [&](llvm::Optional<llvm::StringRef> Data) {
           GotParse = true;
-          Value = Data.getValueOr("").str();
+          Value = Data.value_or("").str();
         },
         [&]() {
           GotRead = true;

diff  --git a/clang-tools-extra/clangd/xpc/XPCTransport.cpp b/clang-tools-extra/clangd/xpc/XPCTransport.cpp
index 4c6308b3acae7..9c43647c3c767 100644
--- a/clang-tools-extra/clangd/xpc/XPCTransport.cpp
+++ b/clang-tools-extra/clangd/xpc/XPCTransport.cpp
@@ -38,7 +38,7 @@ json::Object encodeError(Error E) {
 
 Error decodeError(const json::Object &O) {
   std::string Msg =
-      std::string(O.getString("message").getValueOr("Unspecified error"));
+      std::string(O.getString("message").value_or("Unspecified error"));
   if (auto Code = O.getInteger("code"))
     return make_error<LSPError>(std::move(Msg), ErrorCode(*Code));
   return error("{0}", Msg);

diff  --git a/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
index 3620be6f274d9..a9c7af145338e 100644
--- a/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
+++ b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
@@ -154,7 +154,7 @@ bool ABISysV_arc::IsRegisterFileReduced(RegisterContext &reg_ctx) const {
     m_is_reg_file_reduced = (reg_value | rf_entries_bit) != 0;
   }
 
-  return m_is_reg_file_reduced.getValueOr(false);
+  return m_is_reg_file_reduced.value_or(false);
 }
 
 //------------------------------------------------------------------
@@ -458,7 +458,7 @@ ABISysV_arc::GetReturnValueObjectSimple(Thread &thread,
   const uint32_t type_flags = compiler_type.GetTypeInfo();
   // Integer return type.
   if (type_flags & eTypeIsInteger) {
-    const size_t byte_size = compiler_type.GetByteSize(&thread).getValueOr(0);
+    const size_t byte_size = compiler_type.GetByteSize(&thread).value_or(0);
     auto raw_value = ReadRawValue(reg_ctx, byte_size);
 
     const bool is_signed = (type_flags & eTypeIsSigned) != 0;
@@ -482,7 +482,7 @@ ABISysV_arc::GetReturnValueObjectSimple(Thread &thread,
 
     if (compiler_type.IsFloatingPointType(float_count, is_complex) &&
         1 == float_count && !is_complex) {
-      const size_t byte_size = compiler_type.GetByteSize(&thread).getValueOr(0);
+      const size_t byte_size = compiler_type.GetByteSize(&thread).value_or(0);
       auto raw_value = ReadRawValue(reg_ctx, byte_size);
 
       if (!SetSizedFloat(value.GetScalar(), raw_value, byte_size))

diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
index 7962302aeb327..3715e46c659cf 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
@@ -92,7 +92,7 @@ Expected<TraceIntelPTBundleLoader::ParsedProcess>
 TraceIntelPTBundleLoader::ParseProcess(const JSONProcess &process) {
   TargetSP target_sp;
   Status error = m_debugger.GetTargetList().CreateTarget(
-      m_debugger, /*user_exe_path*/ StringRef(), process.triple.getValueOr(""),
+      m_debugger, /*user_exe_path*/ StringRef(), process.triple.value_or(""),
       eLoadDependentsNo,
       /*platform_options*/ nullptr, target_sp);
 

diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 5e5ca96aeb552..93b07fc0db302 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3144,11 +3144,10 @@ Error BitcodeReader::parseConstants() {
         return error("Explicit gep operator type does not match pointee type "
                      "of pointer operand");
 
-      V = BitcodeConstant::create(
-          Alloc, CurTy,
-          {Instruction::GetElementPtr, InBounds, InRangeIndex.getValueOr(-1),
-           PointeeType},
-          Elts);
+      V = BitcodeConstant::create(Alloc, CurTy,
+                                  {Instruction::GetElementPtr, InBounds,
+                                   InRangeIndex.value_or(-1), PointeeType},
+                                  Elts);
       break;
     }
     case bitc::CST_CODE_CE_SELECT: {  // CE_SELECT: [opval#, opval#, opval#]

diff  --git a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
index 42719ddbef4c6..3363fe5e531fa 100644
--- a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
@@ -25,7 +25,7 @@ using namespace llvm;
 using namespace llvm::symbolize;
 
 MarkupFilter::MarkupFilter(raw_ostream &OS, Optional<bool> ColorsEnabled)
-    : OS(OS), ColorsEnabled(ColorsEnabled.getValueOr(
+    : OS(OS), ColorsEnabled(ColorsEnabled.value_or(
                   WithColor::defaultAutoDetectFunction()(OS))) {}
 
 void MarkupFilter::beginLine(StringRef Line) {

diff  --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index 26f690e0f5a31..11f34817dbbfc 100644
--- a/llvm/lib/Support/Windows/Threading.inc
+++ b/llvm/lib/Support/Windows/Threading.inc
@@ -27,8 +27,8 @@ namespace llvm {
 HANDLE
 llvm_execute_on_thread_impl(unsigned(__stdcall *ThreadFunc)(void *), void *Arg,
                             llvm::Optional<unsigned> StackSizeInBytes) {
-  HANDLE hThread = (HANDLE)::_beginthreadex(
-      NULL, StackSizeInBytes.getValueOr(0), ThreadFunc, Arg, 0, NULL);
+  HANDLE hThread = (HANDLE)::_beginthreadex(NULL, StackSizeInBytes.value_or(0),
+                                            ThreadFunc, Arg, 0, NULL);
 
   if (!hThread) {
     ReportLastErrorFatal("_beginthreadex failed");

diff  --git a/llvm/unittests/Support/UnicodeTest.cpp b/llvm/unittests/Support/UnicodeTest.cpp
index 89fbb5a710993..7bb62de204d96 100644
--- a/llvm/unittests/Support/UnicodeTest.cpp
+++ b/llvm/unittests/Support/UnicodeTest.cpp
@@ -106,7 +106,7 @@ TEST(Unicode, isPrintable) {
 
 TEST(Unicode, nameToCodepointStrict) {
   auto map = [](StringRef Str) {
-    return nameToCodepointStrict(Str).getValueOr(0xFFFF'FFFF);
+    return nameToCodepointStrict(Str).value_or(0xFFFF'FFFF);
   };
 
   // generated codepoints

diff  --git a/mlir/lib/TableGen/AttrOrTypeDef.cpp b/mlir/lib/TableGen/AttrOrTypeDef.cpp
index a202cb5d47d34..17f329502c8f2 100644
--- a/mlir/lib/TableGen/AttrOrTypeDef.cpp
+++ b/mlir/lib/TableGen/AttrOrTypeDef.cpp
@@ -244,8 +244,7 @@ StringRef AttrOrTypeParameter::getCppStorageType() const {
 }
 
 StringRef AttrOrTypeParameter::getConvertFromStorage() const {
-  return getDefValue<llvm::StringInit>("convertFromStorage")
-      .getValueOr("$_self");
+  return getDefValue<llvm::StringInit>("convertFromStorage").value_or("$_self");
 }
 
 Optional<StringRef> AttrOrTypeParameter::getParser() const {


        


More information about the cfe-commits mailing list