[Lldb-commits] [lldb] 2edb905 - Simplify control flow (NFC)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 6 14:56:31 PDT 2021


Author: Adrian Prantl
Date: 2021-10-06T14:56:17-07:00
New Revision: 2edb9058ea635f950f67bf7cb52f76588d362dfc

URL: https://github.com/llvm/llvm-project/commit/2edb9058ea635f950f67bf7cb52f76588d362dfc
DIFF: https://github.com/llvm/llvm-project/commit/2edb9058ea635f950f67bf7cb52f76588d362dfc.diff

LOG: Simplify control flow (NFC)

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 3140fb62d1b7..17417f7a5326 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -661,31 +661,31 @@ bool DWARFUnit::Supports_unnamed_objc_bitfields() {
 }
 
 void DWARFUnit::ParseProducerInfo() {
+  m_producer = eProducerOther;
   const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
-  if (die) {
-    const char *producer_cstr =
-        die->GetAttributeValueAsString(this, DW_AT_producer, nullptr);
-    llvm::StringRef producer(producer_cstr);
-    if (!producer.empty()) {
-      RegularExpression llvm_gcc_regex(
-          llvm::StringRef("^4\\.[012]\\.[01] \\(Based on Apple "
-                          "Inc\\. build [0-9]+\\) \\(LLVM build "
-                          "[\\.0-9]+\\)$"));
-      if (llvm_gcc_regex.Execute(producer)) {
-        m_producer = eProducerLLVMGCC;
-      } else if (producer.contains("clang")) {
-        static RegularExpression g_clang_version_regex(
-            llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
-        llvm::SmallVector<llvm::StringRef, 4> matches;
-        if (g_clang_version_regex.Execute(producer, &matches))
-          m_producer_version.tryParse(matches[1]);
-        m_producer = eProducerClang;
-      } else if (producer.contains("GNU"))
-        m_producer = eProducerGCC;
-    }
-  }
-  if (m_producer == eProducerInvalid)
-    m_producer = eProducerOther;
+  if (!die)
+    return;
+
+  llvm::StringRef producer(
+      die->GetAttributeValueAsString(this, DW_AT_producer, nullptr));
+  if (producer.empty())
+    return;
+
+  static RegularExpression llvm_gcc_regex(
+      llvm::StringRef("^4\\.[012]\\.[01] \\(Based on Apple "
+                      "Inc\\. build [0-9]+\\) \\(LLVM build "
+                      "[\\.0-9]+\\)$"));
+  if (llvm_gcc_regex.Execute(producer)) {
+    m_producer = eProducerLLVMGCC;
+  } else if (producer.contains("clang")) {
+    static RegularExpression g_clang_version_regex(
+        llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
+    llvm::SmallVector<llvm::StringRef, 4> matches;
+    if (g_clang_version_regex.Execute(producer, &matches))
+      m_producer_version.tryParse(matches[1]);
+    m_producer = eProducerClang;
+  } else if (producer.contains("GNU"))
+    m_producer = eProducerGCC;
 }
 
 DWARFProducer DWARFUnit::GetProducer() {


        


More information about the lldb-commits mailing list