@@ -282,13 +282,16 @@ class MDScope : public DebugNode {
282
282
~MDScope () {}
283
283
284
284
public:
285
- // / \brief Return the underlying file.
285
+ // FIXME: Downcast to MDFile once we've verified all subclasses.
286
+ Metadata *getFile () const { return getRawFile (); }
287
+
288
+ // / \brief Return the raw underlying file.
286
289
// /
287
290
// / An \a MDFile is an \a MDScope, but it doesn't point at a separate file
288
291
// / (it\em is the file). If \c this is an \a MDFile, we need to return \c
289
292
// / this. Otherwise, return the first operand, which is where all other
290
293
// / subclasses store their file pointer.
291
- Metadata *getFile () const {
294
+ Metadata *getRawFile () const {
292
295
return isa<MDFile>(this ) ? const_cast <MDScope *>(this )
293
296
: static_cast <Metadata *>(getOperand (0 ));
294
297
}
@@ -390,9 +393,14 @@ class MDType : public MDScope {
390
393
uint64_t getOffsetInBits () const { return OffsetInBits; }
391
394
unsigned getFlags () const { return Flags; }
392
395
393
- Metadata *getScope () const { return getOperand (1 ); }
396
+ // FIXME: Remove this once MDScope::getFile() does the same.
397
+ MDFile *getFile () const { return cast_or_null<MDFile>(getRawFile ()); }
398
+
399
+ Metadata *getScope () const { return getRawScope (); }
394
400
StringRef getName () const { return getStringOperand (2 ); }
395
401
402
+
403
+ Metadata *getRawScope () const { return getOperand (1 ); }
396
404
MDString *getRawName () const { return getOperandAs<MDString>(2 ); }
397
405
398
406
void setFlags (unsigned NewFlags) {
@@ -483,7 +491,8 @@ class MDDerivedTypeBase : public MDType {
483
491
~MDDerivedTypeBase () {}
484
492
485
493
public:
486
- Metadata *getBaseType () const { return getOperand (3 ); }
494
+ Metadata *getBaseType () const { return getRawBaseType (); }
495
+ Metadata *getRawBaseType () const { return getOperand (3 ); }
487
496
488
497
static bool classof (const Metadata *MD) {
489
498
return MD->getMetadataID () == MDDerivedTypeKind ||
@@ -510,7 +519,7 @@ class MDDerivedType : public MDDerivedTypeBase {
510
519
~MDDerivedType () {}
511
520
512
521
static MDDerivedType *getImpl (LLVMContext &Context, unsigned Tag,
513
- StringRef Name, Metadata *File, unsigned Line,
522
+ StringRef Name, MDFile *File, unsigned Line,
514
523
Metadata *Scope, Metadata *BaseType,
515
524
uint64_t SizeInBits, uint64_t AlignInBits,
516
525
uint64_t OffsetInBits, unsigned Flags,
@@ -545,7 +554,7 @@ class MDDerivedType : public MDDerivedTypeBase {
545
554
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
546
555
AlignInBits, OffsetInBits, Flags, ExtraData))
547
556
DEFINE_MDNODE_GET (MDDerivedType,
548
- (unsigned Tag, StringRef Name, Metadata *File,
557
+ (unsigned Tag, StringRef Name, MDFile *File,
549
558
unsigned Line, Metadata *Scope, Metadata *BaseType,
550
559
uint64_t SizeInBits, uint64_t AlignInBits,
551
560
uint64_t OffsetInBits, unsigned Flags,
@@ -562,7 +571,8 @@ class MDDerivedType : public MDDerivedTypeBase {
562
571
// /
563
572
// / TODO: Separate out types that need this extra operand: pointer-to-member
564
573
// / types and member fields (static members and ivars).
565
- Metadata *getExtraData () const { return getOperand (4 ); }
574
+ Metadata *getExtraData () const { return getRawExtraData (); }
575
+ Metadata *getRawExtraData () const { return getOperand (4 ); }
566
576
567
577
static bool classof (const Metadata *MD) {
568
578
return MD->getMetadataID () == MDDerivedTypeKind;
@@ -587,12 +597,19 @@ class MDCompositeTypeBase : public MDDerivedTypeBase {
587
597
~MDCompositeTypeBase () {}
588
598
589
599
public:
590
- Metadata *getElements () const { return getOperand (4 ); }
591
- Metadata *getVTableHolder () const { return getOperand (5 ); }
592
- Metadata *getTemplateParams () const { return getOperand (6 ); }
600
+ MDTuple *getElements () const {
601
+ return cast_or_null<MDTuple>(getRawElements ());
602
+ }
603
+ Metadata *getVTableHolder () const { return getRawVTableHolder (); }
604
+ MDTuple *getTemplateParams () const {
605
+ return cast_or_null<MDTuple>(getRawTemplateParams ());
606
+ }
593
607
StringRef getIdentifier () const { return getStringOperand (7 ); }
594
608
unsigned getRuntimeLang () const { return RuntimeLang; }
595
609
610
+ Metadata *getRawElements () const { return getOperand (4 ); }
611
+ Metadata *getRawVTableHolder () const { return getOperand (5 ); }
612
+ Metadata *getRawTemplateParams () const { return getOperand (6 ); }
596
613
MDString *getRawIdentifier () const { return getOperandAs<MDString>(7 ); }
597
614
598
615
// / \brief Replace operands.
@@ -730,7 +747,8 @@ class MDSubroutineType : public MDCompositeTypeBase {
730
747
731
748
TempMDSubroutineType clone () const { return cloneImpl (); }
732
749
733
- Metadata *getTypeArray () const { return getElements (); }
750
+ MDTuple *getTypeArray () const { return getElements (); }
751
+ Metadata *getRawTypeArray () const { return getRawElements (); }
734
752
735
753
static bool classof (const Metadata *MD) {
736
754
return MD->getMetadataID () == MDSubroutineTypeKind;
@@ -756,12 +774,12 @@ class MDCompileUnit : public MDScope {
756
774
~MDCompileUnit () {}
757
775
758
776
static MDCompileUnit *
759
- getImpl (LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
777
+ getImpl (LLVMContext &Context, unsigned SourceLanguage, MDFile *File,
760
778
StringRef Producer, bool IsOptimized, StringRef Flags,
761
779
unsigned RuntimeVersion, StringRef SplitDebugFilename,
762
- unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
763
- Metadata *Subprograms, Metadata *GlobalVariables,
764
- Metadata *ImportedEntities, StorageType Storage,
780
+ unsigned EmissionKind, MDTuple *EnumTypes, MDTuple *RetainedTypes,
781
+ MDTuple *Subprograms, MDTuple *GlobalVariables,
782
+ MDTuple *ImportedEntities, StorageType Storage,
765
783
bool ShouldCreate = true ) {
766
784
return getImpl (Context, SourceLanguage, File,
767
785
getCanonicalMDString (Context, Producer), IsOptimized,
@@ -789,12 +807,12 @@ class MDCompileUnit : public MDScope {
789
807
790
808
public:
791
809
DEFINE_MDNODE_GET (MDCompileUnit,
792
- (unsigned SourceLanguage, Metadata *File,
793
- StringRef Producer, bool IsOptimized, StringRef Flags,
794
- unsigned RuntimeVersion, StringRef SplitDebugFilename ,
795
- unsigned EmissionKind, Metadata *EnumTypes ,
796
- Metadata *RetainedTypes, Metadata *Subprograms ,
797
- Metadata *GlobalVariables, Metadata *ImportedEntities),
810
+ (unsigned SourceLanguage, MDFile *File, StringRef Producer ,
811
+ bool IsOptimized, StringRef Flags, unsigned RuntimeVersion ,
812
+ StringRef SplitDebugFilename, unsigned EmissionKind ,
813
+ MDTuple *EnumTypes, MDTuple *RetainedTypes ,
814
+ MDTuple *Subprograms, MDTuple *GlobalVariables ,
815
+ MDTuple *ImportedEntities),
798
816
(SourceLanguage, File, Producer, IsOptimized, Flags,
799
817
RuntimeVersion, SplitDebugFilename, EmissionKind,
800
818
EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
@@ -813,24 +831,42 @@ class MDCompileUnit : public MDScope {
813
831
814
832
TempMDCompileUnit clone () const { return cloneImpl (); }
815
833
834
+ // FIXME: Remove this once MDScope::getFile() does the same.
835
+ MDFile *getFile () const { return cast_or_null<MDFile>(getRawFile ()); }
836
+
816
837
unsigned getSourceLanguage () const { return SourceLanguage; }
817
838
bool isOptimized () const { return IsOptimized; }
818
839
unsigned getRuntimeVersion () const { return RuntimeVersion; }
819
840
unsigned getEmissionKind () const { return EmissionKind; }
820
841
StringRef getProducer () const { return getStringOperand (1 ); }
821
842
StringRef getFlags () const { return getStringOperand (2 ); }
822
843
StringRef getSplitDebugFilename () const { return getStringOperand (3 ); }
823
- Metadata *getEnumTypes () const { return getOperand (4 ); }
824
- Metadata *getRetainedTypes () const { return getOperand (5 ); }
825
- Metadata *getSubprograms () const { return getOperand (6 ); }
826
- Metadata *getGlobalVariables () const { return getOperand (7 ); }
827
- Metadata *getImportedEntities () const { return getOperand (8 ); }
844
+ MDTuple *getEnumTypes () const {
845
+ return cast_or_null<MDTuple>(getRawEnumTypes ());
846
+ }
847
+ MDTuple *getRetainedTypes () const {
848
+ return cast_or_null<MDTuple>(getRawRetainedTypes ());
849
+ }
850
+ MDTuple *getSubprograms () const {
851
+ return cast_or_null<MDTuple>(getRawSubprograms ());
852
+ }
853
+ MDTuple *getGlobalVariables () const {
854
+ return cast_or_null<MDTuple>(getRawGlobalVariables ());
855
+ }
856
+ MDTuple *getImportedEntities () const {
857
+ return cast_or_null<MDTuple>(getRawImportedEntities ());
858
+ }
828
859
829
860
MDString *getRawProducer () const { return getOperandAs<MDString>(1 ); }
830
861
MDString *getRawFlags () const { return getOperandAs<MDString>(2 ); }
831
862
MDString *getRawSplitDebugFilename () const {
832
863
return getOperandAs<MDString>(3 );
833
864
}
865
+ Metadata *getRawEnumTypes () const { return getOperand (4 ); }
866
+ Metadata *getRawRetainedTypes () const { return getOperand (5 ); }
867
+ Metadata *getRawSubprograms () const { return getOperand (6 ); }
868
+ Metadata *getRawGlobalVariables () const { return getOperand (7 ); }
869
+ Metadata *getRawImportedEntities () const { return getOperand (8 ); }
834
870
835
871
// / \brief Replace arrays.
836
872
// /
0 commit comments