@@ -564,25 +564,11 @@ class ASTWriter : public ASTDeserializationListener,
564
564
unsigned DeclEnumAbbrev = 0 ;
565
565
unsigned DeclObjCIvarAbbrev = 0 ;
566
566
unsigned DeclCXXMethodAbbrev = 0 ;
567
- unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0 ;
568
- unsigned DeclTemplateCXXMethodAbbrev = 0 ;
569
- unsigned DeclMemberSpecializedCXXMethodAbbrev = 0 ;
570
- unsigned DeclTemplateSpecializedCXXMethodAbbrev = 0 ;
571
- unsigned DeclDependentSpecializationCXXMethodAbbrev = 0 ;
572
- unsigned DeclTemplateTypeParmAbbrev = 0 ;
573
- unsigned DeclUsingShadowAbbrev = 0 ;
574
567
575
568
unsigned DeclRefExprAbbrev = 0 ;
576
569
unsigned CharacterLiteralAbbrev = 0 ;
577
570
unsigned IntegerLiteralAbbrev = 0 ;
578
571
unsigned ExprImplicitCastAbbrev = 0 ;
579
- unsigned BinaryOperatorAbbrev = 0 ;
580
- unsigned CompoundAssignOperatorAbbrev = 0 ;
581
- unsigned CallExprAbbrev = 0 ;
582
- unsigned CXXOperatorCallExprAbbrev = 0 ;
583
- unsigned CXXMemberCallExprAbbrev = 0 ;
584
-
585
- unsigned CompoundStmtAbbrev = 0 ;
586
572
587
573
void WriteDeclAbbrevs ();
588
574
void WriteDecl (ASTContext &Context, Decl *D);
@@ -749,42 +735,12 @@ class ASTWriter : public ASTDeserializationListener,
749
735
unsigned getDeclFieldAbbrev () const { return DeclFieldAbbrev; }
750
736
unsigned getDeclEnumAbbrev () const { return DeclEnumAbbrev; }
751
737
unsigned getDeclObjCIvarAbbrev () const { return DeclObjCIvarAbbrev; }
752
- unsigned getDeclCXXMethodAbbrev (FunctionDecl::TemplatedKind Kind) const {
753
- switch (Kind) {
754
- case FunctionDecl::TK_NonTemplate:
755
- return DeclCXXMethodAbbrev;
756
- case FunctionDecl::TK_FunctionTemplate:
757
- return DeclTemplateCXXMethodAbbrev;
758
- case FunctionDecl::TK_MemberSpecialization:
759
- return DeclMemberSpecializedCXXMethodAbbrev;
760
- case FunctionDecl::TK_FunctionTemplateSpecialization:
761
- return DeclTemplateSpecializedCXXMethodAbbrev;
762
- case FunctionDecl::TK_DependentNonTemplate:
763
- return DeclDependentNonTemplateCXXMethodAbbrev;
764
- case FunctionDecl::TK_DependentFunctionTemplateSpecialization:
765
- return DeclDependentSpecializationCXXMethodAbbrev;
766
- default :
767
- llvm_unreachable (" Unknwon Template Kind!" );
768
- }
769
- }
770
- unsigned getDeclTemplateTypeParmAbbrev () const {
771
- return DeclTemplateTypeParmAbbrev;
772
- }
773
- unsigned getDeclUsingShadowAbbrev () const { return DeclUsingShadowAbbrev; }
738
+ unsigned getDeclCXXMethodAbbrev () const { return DeclCXXMethodAbbrev; }
774
739
775
740
unsigned getDeclRefExprAbbrev () const { return DeclRefExprAbbrev; }
776
741
unsigned getCharacterLiteralAbbrev () const { return CharacterLiteralAbbrev; }
777
742
unsigned getIntegerLiteralAbbrev () const { return IntegerLiteralAbbrev; }
778
743
unsigned getExprImplicitCastAbbrev () const { return ExprImplicitCastAbbrev; }
779
- unsigned getBinaryOperatorAbbrev () const { return BinaryOperatorAbbrev; }
780
- unsigned getCompoundAssignOperatorAbbrev () const {
781
- return CompoundAssignOperatorAbbrev;
782
- }
783
- unsigned getCallExprAbbrev () const { return CallExprAbbrev; }
784
- unsigned getCXXOperatorCallExprAbbrev () { return CXXOperatorCallExprAbbrev; }
785
- unsigned getCXXMemberCallExprAbbrev () { return CXXMemberCallExprAbbrev; }
786
-
787
- unsigned getCompoundStmtAbbrev () const { return CompoundStmtAbbrev; }
788
744
789
745
bool hasChain () const { return Chain; }
790
746
ASTReader *getChain () const { return Chain; }
@@ -885,33 +841,46 @@ class BitsPacker {
885
841
BitsPacker (BitsPacker &&) = delete ;
886
842
BitsPacker operator =(const BitsPacker &) = delete ;
887
843
BitsPacker operator =(BitsPacker &&) = delete ;
888
- ~BitsPacker () = default ;
889
-
890
- bool canWriteNextNBits (uint32_t BitsWidth) const {
891
- return CurrentBitIndex + BitsWidth < BitIndexUpbound;
892
- }
893
-
894
- void reset (uint32_t Value) {
895
- UnderlyingValue = Value;
896
- CurrentBitIndex = 0 ;
844
+ ~BitsPacker () {
845
+ assert (!hasUnconsumedValues () && " There are unprocessed bits!" );
897
846
}
898
847
899
848
void addBit (bool Value) { addBits (Value, 1 ); }
900
849
void addBits (uint32_t Value, uint32_t BitsWidth) {
901
850
assert (BitsWidth < BitIndexUpbound);
902
851
assert ((Value < (1u << BitsWidth)) && " Passing narrower bit width!" );
903
- assert (canWriteNextNBits (BitsWidth) &&
904
- " Inserting too much bits into a value!" );
905
852
906
- UnderlyingValue |= Value << CurrentBitIndex;
853
+ if (CurrentBitIndex + BitsWidth >= BitIndexUpbound) {
854
+ Values.push_back (0 );
855
+ CurrentBitIndex = 0 ;
856
+ }
857
+
858
+ assert (CurrentBitIndex < BitIndexUpbound);
859
+ Values.back () |= Value << CurrentBitIndex;
907
860
CurrentBitIndex += BitsWidth;
908
861
}
909
862
910
- operator uint32_t () { return UnderlyingValue; }
863
+ bool hasUnconsumedValues () const {
864
+ return ConsumingValueIndex < Values.size ();
865
+ }
866
+ uint32_t getNextValue () {
867
+ assert (hasUnconsumedValues ());
868
+ return Values[ConsumingValueIndex++];
869
+ }
870
+
871
+ // We can convert the packer to an uint32_t if there is only one values.
872
+ operator uint32_t () {
873
+ assert (Values.size () == 1 );
874
+ return getNextValue ();
875
+ }
911
876
912
877
private:
913
- uint32_t UnderlyingValue = 0 ;
914
- uint32_t CurrentBitIndex = 0 ;
878
+ SmallVector<uint64_t , 4 > Values;
879
+ uint16_t ConsumingValueIndex = 0 ;
880
+ // Initialize CurrentBitIndex with an invalid value
881
+ // to make it easier to update Values. See the implementation
882
+ // of `addBits` to see the details.
883
+ uint16_t CurrentBitIndex = BitIndexUpbound;
915
884
};
916
885
917
886
} // namespace clang
0 commit comments