@@ -654,50 +654,38 @@ bool DWARFUnit::DW_AT_decl_file_attributes_are_invalid() {
654
654
}
655
655
656
656
bool DWARFUnit::Supports_unnamed_objc_bitfields () {
657
- if (GetProducer () == eProducerClang) {
658
- const uint32_t major_version = GetProducerVersionMajor ();
659
- return major_version > 425 ||
660
- (major_version == 425 && GetProducerVersionUpdate () >= 13 );
661
- }
662
- return true ; // Assume all other compilers didn't have incorrect ObjC bitfield
663
- // info
657
+ if (GetProducer () == eProducerClang)
658
+ return GetProducerVersion () >= llvm::VersionTuple (425 , 0 , 13 );
659
+ // Assume all other compilers didn't have incorrect ObjC bitfield info.
660
+ return true ;
664
661
}
665
662
666
663
void DWARFUnit::ParseProducerInfo () {
667
- m_producer_version_major = UINT32_MAX;
668
- m_producer_version_minor = UINT32_MAX;
669
- m_producer_version_update = UINT32_MAX;
670
-
671
664
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly ();
672
665
if (die) {
673
-
674
666
const char *producer_cstr =
675
667
die->GetAttributeValueAsString (this , DW_AT_producer, nullptr );
676
- if (producer_cstr) {
668
+ llvm::StringRef producer (producer_cstr);
669
+ if (!producer.empty ()) {
677
670
RegularExpression llvm_gcc_regex (
678
671
llvm::StringRef (" ^4\\ .[012]\\ .[01] \\ (Based on Apple "
679
672
" Inc\\ . build [0-9]+\\ ) \\ (LLVM build "
680
673
" [\\ .0-9]+\\ )$" ));
681
- if (llvm_gcc_regex.Execute (llvm::StringRef (producer_cstr) )) {
674
+ if (llvm_gcc_regex.Execute (producer )) {
682
675
m_producer = eProducerLLVMGCC;
683
- } else if (strstr (producer_cstr, " clang" )) {
676
+ } else if (producer. contains ( " clang" )) {
684
677
static RegularExpression g_clang_version_regex (
685
- llvm::StringRef (" clang-([0-9]+) \\ .( [0-9]+) \\ .( [0-9]+)" ));
678
+ llvm::StringRef (R"( clang-([0-9]+\. [0-9]+\.[0-9]+(\. [0-9]+)?) )" ));
686
679
llvm::SmallVector<llvm::StringRef, 4 > matches;
687
- if (g_clang_version_regex.Execute (llvm::StringRef (producer_cstr),
688
- &matches)) {
689
- // FIXME: improve error handling
690
- llvm::to_integer (matches[1 ], m_producer_version_major);
691
- llvm::to_integer (matches[2 ], m_producer_version_minor);
692
- llvm::to_integer (matches[3 ], m_producer_version_update);
693
- }
680
+ if (g_clang_version_regex.Execute (producer, &matches))
681
+ m_producer_version.tryParse (matches[1 ]);
694
682
m_producer = eProducerClang;
695
- } else if (strstr (producer_cstr, " GNU" ))
683
+ } else if (producer. contains ( " GNU" ))
696
684
m_producer = eProducerGCC;
697
685
}
698
686
}
699
687
if (m_producer == eProducerInvalid)
700
- m_producer = eProcucerOther ;
688
+ m_producer = eProducerOther ;
701
689
}
702
690
703
691
DWARFProducer DWARFUnit::GetProducer () {
@@ -706,22 +694,10 @@ DWARFProducer DWARFUnit::GetProducer() {
706
694
return m_producer;
707
695
}
708
696
709
- uint32_t DWARFUnit::GetProducerVersionMajor () {
710
- if (m_producer_version_major == 0 )
711
- ParseProducerInfo ();
712
- return m_producer_version_major;
713
- }
714
-
715
- uint32_t DWARFUnit::GetProducerVersionMinor () {
716
- if (m_producer_version_minor == 0 )
717
- ParseProducerInfo ();
718
- return m_producer_version_minor;
719
- }
720
-
721
- uint32_t DWARFUnit::GetProducerVersionUpdate () {
722
- if (m_producer_version_update == 0 )
697
+ llvm::VersionTuple DWARFUnit::GetProducerVersion () {
698
+ if (m_producer_version.empty ())
723
699
ParseProducerInfo ();
724
- return m_producer_version_update ;
700
+ return m_producer_version ;
725
701
}
726
702
727
703
uint64_t DWARFUnit::GetDWARFLanguageType () {
0 commit comments