@@ -402,7 +402,7 @@ class APValue {
402
402
403
403
APSInt &getInt () {
404
404
assert (isInt () && " Invalid accessor" );
405
- return *(APSInt*)(char *) Data. buffer ;
405
+ return *(APSInt *)(char *)& Data;
406
406
}
407
407
const APSInt &getInt () const {
408
408
return const_cast <APValue*>(this )->getInt ();
@@ -416,47 +416,47 @@ class APValue {
416
416
417
417
APFloat &getFloat () {
418
418
assert (isFloat () && " Invalid accessor" );
419
- return *(APFloat*)(char *) Data. buffer ;
419
+ return *(APFloat *)(char *)& Data;
420
420
}
421
421
const APFloat &getFloat () const {
422
422
return const_cast <APValue*>(this )->getFloat ();
423
423
}
424
424
425
425
APFixedPoint &getFixedPoint () {
426
426
assert (isFixedPoint () && " Invalid accessor" );
427
- return *(APFixedPoint *)(char *)Data. buffer ;
427
+ return *(APFixedPoint *)(char *)& Data;
428
428
}
429
429
const APFixedPoint &getFixedPoint () const {
430
430
return const_cast <APValue *>(this )->getFixedPoint ();
431
431
}
432
432
433
433
APSInt &getComplexIntReal () {
434
434
assert (isComplexInt () && " Invalid accessor" );
435
- return ((ComplexAPSInt*)(char *) Data. buffer )->Real ;
435
+ return ((ComplexAPSInt *)(char *)& Data)->Real ;
436
436
}
437
437
const APSInt &getComplexIntReal () const {
438
438
return const_cast <APValue*>(this )->getComplexIntReal ();
439
439
}
440
440
441
441
APSInt &getComplexIntImag () {
442
442
assert (isComplexInt () && " Invalid accessor" );
443
- return ((ComplexAPSInt*)(char *) Data. buffer )->Imag ;
443
+ return ((ComplexAPSInt *)(char *)& Data)->Imag ;
444
444
}
445
445
const APSInt &getComplexIntImag () const {
446
446
return const_cast <APValue*>(this )->getComplexIntImag ();
447
447
}
448
448
449
449
APFloat &getComplexFloatReal () {
450
450
assert (isComplexFloat () && " Invalid accessor" );
451
- return ((ComplexAPFloat*)(char *) Data. buffer )->Real ;
451
+ return ((ComplexAPFloat *)(char *)& Data)->Real ;
452
452
}
453
453
const APFloat &getComplexFloatReal () const {
454
454
return const_cast <APValue*>(this )->getComplexFloatReal ();
455
455
}
456
456
457
457
APFloat &getComplexFloatImag () {
458
458
assert (isComplexFloat () && " Invalid accessor" );
459
- return ((ComplexAPFloat*)(char *) Data. buffer )->Imag ;
459
+ return ((ComplexAPFloat *)(char *)& Data)->Imag ;
460
460
}
461
461
const APFloat &getComplexFloatImag () const {
462
462
return const_cast <APValue*>(this )->getComplexFloatImag ();
@@ -477,20 +477,20 @@ class APValue {
477
477
APValue &getVectorElt (unsigned I) {
478
478
assert (isVector () && " Invalid accessor" );
479
479
assert (I < getVectorLength () && " Index out of range" );
480
- return ((Vec*)(char *) Data. buffer )->Elts [I];
480
+ return ((Vec *)(char *)& Data)->Elts [I];
481
481
}
482
482
const APValue &getVectorElt (unsigned I) const {
483
483
return const_cast <APValue*>(this )->getVectorElt (I);
484
484
}
485
485
unsigned getVectorLength () const {
486
486
assert (isVector () && " Invalid accessor" );
487
- return ((const Vec*)(const void *)Data. buffer )->NumElts ;
487
+ return ((const Vec *)(const void *)& Data)->NumElts ;
488
488
}
489
489
490
490
APValue &getArrayInitializedElt (unsigned I) {
491
491
assert (isArray () && " Invalid accessor" );
492
492
assert (I < getArrayInitializedElts () && " Index out of range" );
493
- return ((Arr*)(char *) Data. buffer )->Elts [I];
493
+ return ((Arr *)(char *)& Data)->Elts [I];
494
494
}
495
495
const APValue &getArrayInitializedElt (unsigned I) const {
496
496
return const_cast <APValue*>(this )->getArrayInitializedElt (I);
@@ -501,35 +501,35 @@ class APValue {
501
501
APValue &getArrayFiller () {
502
502
assert (isArray () && " Invalid accessor" );
503
503
assert (hasArrayFiller () && " No array filler" );
504
- return ((Arr*)(char *) Data. buffer )->Elts [getArrayInitializedElts ()];
504
+ return ((Arr *)(char *)& Data)->Elts [getArrayInitializedElts ()];
505
505
}
506
506
const APValue &getArrayFiller () const {
507
507
return const_cast <APValue*>(this )->getArrayFiller ();
508
508
}
509
509
unsigned getArrayInitializedElts () const {
510
510
assert (isArray () && " Invalid accessor" );
511
- return ((const Arr*)(const void *)Data. buffer )->NumElts ;
511
+ return ((const Arr *)(const void *)& Data)->NumElts ;
512
512
}
513
513
unsigned getArraySize () const {
514
514
assert (isArray () && " Invalid accessor" );
515
- return ((const Arr*)(const void *)Data. buffer )->ArrSize ;
515
+ return ((const Arr *)(const void *)& Data)->ArrSize ;
516
516
}
517
517
518
518
unsigned getStructNumBases () const {
519
519
assert (isStruct () && " Invalid accessor" );
520
- return ((const StructData*)(const char *) Data. buffer )->NumBases ;
520
+ return ((const StructData *)(const char *)& Data)->NumBases ;
521
521
}
522
522
unsigned getStructNumFields () const {
523
523
assert (isStruct () && " Invalid accessor" );
524
- return ((const StructData*)(const char *) Data. buffer )->NumFields ;
524
+ return ((const StructData *)(const char *)& Data)->NumFields ;
525
525
}
526
526
APValue &getStructBase (unsigned i) {
527
527
assert (isStruct () && " Invalid accessor" );
528
- return ((StructData*)(char *) Data. buffer )->Elts [i];
528
+ return ((StructData *)(char *)& Data)->Elts [i];
529
529
}
530
530
APValue &getStructField (unsigned i) {
531
531
assert (isStruct () && " Invalid accessor" );
532
- return ((StructData*)(char *) Data. buffer )->Elts [getStructNumBases () + i];
532
+ return ((StructData *)(char *)& Data)->Elts [getStructNumBases () + i];
533
533
}
534
534
const APValue &getStructBase (unsigned i) const {
535
535
return const_cast <APValue*>(this )->getStructBase (i);
@@ -540,11 +540,11 @@ class APValue {
540
540
541
541
const FieldDecl *getUnionField () const {
542
542
assert (isUnion () && " Invalid accessor" );
543
- return ((const UnionData*)(const char *) Data. buffer )->Field ;
543
+ return ((const UnionData *)(const char *)& Data)->Field ;
544
544
}
545
545
APValue &getUnionValue () {
546
546
assert (isUnion () && " Invalid accessor" );
547
- return *((UnionData*)(char *) Data. buffer )->Value ;
547
+ return *((UnionData *)(char *)& Data)->Value ;
548
548
}
549
549
const APValue &getUnionValue () const {
550
550
return const_cast <APValue*>(this )->getUnionValue ();
@@ -556,24 +556,24 @@ class APValue {
556
556
557
557
const AddrLabelExpr* getAddrLabelDiffLHS () const {
558
558
assert (isAddrLabelDiff () && " Invalid accessor" );
559
- return ((const AddrLabelDiffData*)(const char *) Data. buffer )->LHSExpr ;
559
+ return ((const AddrLabelDiffData *)(const char *)& Data)->LHSExpr ;
560
560
}
561
561
const AddrLabelExpr* getAddrLabelDiffRHS () const {
562
562
assert (isAddrLabelDiff () && " Invalid accessor" );
563
- return ((const AddrLabelDiffData*)(const char *) Data. buffer )->RHSExpr ;
563
+ return ((const AddrLabelDiffData *)(const char *)& Data)->RHSExpr ;
564
564
}
565
565
566
566
void setInt (APSInt I) {
567
567
assert (isInt () && " Invalid accessor" );
568
- *(APSInt *)(char *)Data. buffer = std::move (I);
568
+ *(APSInt *)(char *)& Data = std::move (I);
569
569
}
570
570
void setFloat (APFloat F) {
571
571
assert (isFloat () && " Invalid accessor" );
572
- *(APFloat *)(char *)Data. buffer = std::move (F);
572
+ *(APFloat *)(char *)& Data = std::move (F);
573
573
}
574
574
void setFixedPoint (APFixedPoint FX) {
575
575
assert (isFixedPoint () && " Invalid accessor" );
576
- *(APFixedPoint *)(char *)Data. buffer = std::move (FX);
576
+ *(APFixedPoint *)(char *)& Data = std::move (FX);
577
577
}
578
578
void setVector (const APValue *E, unsigned N) {
579
579
MutableArrayRef<APValue> InternalElts = setVectorUninit (N);
@@ -584,15 +584,15 @@ class APValue {
584
584
assert (R.getBitWidth () == I.getBitWidth () &&
585
585
" Invalid complex int (type mismatch)." );
586
586
assert (isComplexInt () && " Invalid accessor" );
587
- ((ComplexAPSInt *)(char *)Data. buffer )->Real = std::move (R);
588
- ((ComplexAPSInt *)(char *)Data. buffer )->Imag = std::move (I);
587
+ ((ComplexAPSInt *)(char *)& Data)->Real = std::move (R);
588
+ ((ComplexAPSInt *)(char *)& Data)->Imag = std::move (I);
589
589
}
590
590
void setComplexFloat (APFloat R, APFloat I) {
591
591
assert (&R.getSemantics () == &I.getSemantics () &&
592
592
" Invalid complex float (type mismatch)." );
593
593
assert (isComplexFloat () && " Invalid accessor" );
594
- ((ComplexAPFloat *)(char *)Data. buffer )->Real = std::move (R);
595
- ((ComplexAPFloat *)(char *)Data. buffer )->Imag = std::move (I);
594
+ ((ComplexAPFloat *)(char *)& Data)->Real = std::move (R);
595
+ ((ComplexAPFloat *)(char *)& Data)->Imag = std::move (I);
596
596
}
597
597
void setLValue (LValueBase B, const CharUnits &O, NoLValuePath,
598
598
bool IsNullPtr);
@@ -602,59 +602,59 @@ class APValue {
602
602
void setUnion (const FieldDecl *Field, const APValue &Value);
603
603
void setAddrLabelDiff (const AddrLabelExpr* LHSExpr,
604
604
const AddrLabelExpr* RHSExpr) {
605
- ((AddrLabelDiffData*)(char *) Data. buffer )->LHSExpr = LHSExpr;
606
- ((AddrLabelDiffData*)(char *) Data. buffer )->RHSExpr = RHSExpr;
605
+ ((AddrLabelDiffData *)(char *)& Data)->LHSExpr = LHSExpr;
606
+ ((AddrLabelDiffData *)(char *)& Data)->RHSExpr = RHSExpr;
607
607
}
608
608
609
609
private:
610
610
void DestroyDataAndMakeUninit ();
611
611
void MakeInt () {
612
612
assert (isAbsent () && " Bad state change" );
613
- new ((void *) Data. buffer ) APSInt (1 );
613
+ new ((void *)& Data) APSInt (1 );
614
614
Kind = Int;
615
615
}
616
616
void MakeFloat () {
617
617
assert (isAbsent () && " Bad state change" );
618
- new ((void *)(char *) Data. buffer ) APFloat (0.0 );
618
+ new ((void *)(char *)& Data) APFloat (0.0 );
619
619
Kind = Float;
620
620
}
621
621
void MakeFixedPoint (APFixedPoint &&FX) {
622
622
assert (isAbsent () && " Bad state change" );
623
- new ((void *)(char *)Data. buffer ) APFixedPoint (std::move (FX));
623
+ new ((void *)(char *)& Data) APFixedPoint (std::move (FX));
624
624
Kind = FixedPoint;
625
625
}
626
626
void MakeVector () {
627
627
assert (isAbsent () && " Bad state change" );
628
- new ((void *)(char *) Data. buffer ) Vec ();
628
+ new ((void *)(char *)& Data) Vec ();
629
629
Kind = Vector;
630
630
}
631
631
void MakeComplexInt () {
632
632
assert (isAbsent () && " Bad state change" );
633
- new ((void *)(char *) Data. buffer ) ComplexAPSInt ();
633
+ new ((void *)(char *)& Data) ComplexAPSInt ();
634
634
Kind = ComplexInt;
635
635
}
636
636
void MakeComplexFloat () {
637
637
assert (isAbsent () && " Bad state change" );
638
- new ((void *)(char *) Data. buffer ) ComplexAPFloat ();
638
+ new ((void *)(char *)& Data) ComplexAPFloat ();
639
639
Kind = ComplexFloat;
640
640
}
641
641
void MakeLValue ();
642
642
void MakeArray (unsigned InitElts, unsigned Size);
643
643
void MakeStruct (unsigned B, unsigned M) {
644
644
assert (isAbsent () && " Bad state change" );
645
- new ((void *)(char *) Data. buffer ) StructData (B, M);
645
+ new ((void *)(char *)& Data) StructData (B, M);
646
646
Kind = Struct;
647
647
}
648
648
void MakeUnion () {
649
649
assert (isAbsent () && " Bad state change" );
650
- new ((void *)(char *) Data. buffer ) UnionData ();
650
+ new ((void *)(char *)& Data) UnionData ();
651
651
Kind = Union;
652
652
}
653
653
void MakeMemberPointer (const ValueDecl *Member, bool IsDerivedMember,
654
654
ArrayRef<const CXXRecordDecl*> Path);
655
655
void MakeAddrLabelDiff () {
656
656
assert (isAbsent () && " Bad state change" );
657
- new ((void *)(char *) Data. buffer ) AddrLabelDiffData ();
657
+ new ((void *)(char *)& Data) AddrLabelDiffData ();
658
658
Kind = AddrLabelDiff;
659
659
}
660
660
@@ -664,7 +664,7 @@ class APValue {
664
664
// / filled in by those steps.
665
665
MutableArrayRef<APValue> setVectorUninit (unsigned N) {
666
666
assert (isVector () && " Invalid accessor" );
667
- Vec *V = ((Vec *)(char *)Data. buffer );
667
+ Vec *V = ((Vec *)(char *)& Data);
668
668
V->Elts = new APValue[N];
669
669
V->NumElts = N;
670
670
return {V->Elts , V->NumElts };
0 commit comments