@@ -773,103 +773,6 @@ llvm::DenseMap<Expr *, unsigned> Expr::getPreorderIndexMap() {
773
773
// Support methods for Exprs.
774
774
// ===----------------------------------------------------------------------===//
775
775
776
- static LiteralExpr *
777
- shallowCloneImpl (const NilLiteralExpr *E, ASTContext &Ctx,
778
- llvm::function_ref<Type(const Expr *)> getType) {
779
- return new (Ctx) NilLiteralExpr (E->getLoc ());
780
- }
781
-
782
- static LiteralExpr *
783
- shallowCloneImpl (const IntegerLiteralExpr *E, ASTContext &Ctx,
784
- llvm::function_ref<Type(const Expr *)> getType) {
785
- auto res = new (Ctx) IntegerLiteralExpr (E->getDigitsText (),
786
- E->getSourceRange ().End );
787
- if (E->isNegative ())
788
- res->setNegative (E->getSourceRange ().Start );
789
- return res;
790
- }
791
-
792
- static LiteralExpr *
793
- shallowCloneImpl (const FloatLiteralExpr *E, ASTContext &Ctx,
794
- llvm::function_ref<Type(const Expr *)> getType) {
795
- auto res = new (Ctx) FloatLiteralExpr (E->getDigitsText (),
796
- E->getSourceRange ().End );
797
- if (E->isNegative ())
798
- res->setNegative (E->getSourceRange ().Start );
799
- return res;
800
- }
801
- static LiteralExpr *
802
- shallowCloneImpl (const BooleanLiteralExpr *E, ASTContext &Ctx,
803
- llvm::function_ref<Type(const Expr *)> getType) {
804
- return new (Ctx) BooleanLiteralExpr (E->getValue (), E->getLoc ());
805
- }
806
- static LiteralExpr *
807
- shallowCloneImpl (const StringLiteralExpr *E, ASTContext &Ctx,
808
- llvm::function_ref<Type(const Expr *)> getType) {
809
- auto res = new (Ctx) StringLiteralExpr (E->getValue (), E->getSourceRange ());
810
- res->setEncoding (E->getEncoding ());
811
- return res;
812
- }
813
-
814
- static LiteralExpr *
815
- shallowCloneImpl (const InterpolatedStringLiteralExpr *E, ASTContext &Ctx,
816
- llvm::function_ref<Type(const Expr *)> getType) {
817
- auto res = new (Ctx) InterpolatedStringLiteralExpr (E->getLoc (),
818
- E->getTrailingQuoteLoc (),
819
- E->getLiteralCapacity (),
820
- E->getInterpolationCount (),
821
- E->getAppendingExpr ());
822
- res->setSemanticExpr (E->getSemanticExpr ());
823
- return res;
824
- }
825
-
826
- static LiteralExpr *
827
- shallowCloneImpl (const MagicIdentifierLiteralExpr *E, ASTContext &Ctx,
828
- llvm::function_ref<Type(const Expr *)> getType) {
829
- auto res = new (Ctx) MagicIdentifierLiteralExpr (E->getKind (),
830
- E->getSourceRange ().End );
831
- if (res->isString ())
832
- res->setStringEncoding (E->getStringEncoding ());
833
- return res;
834
- }
835
-
836
- static LiteralExpr *
837
- shallowCloneImpl (const ObjectLiteralExpr *E, ASTContext &Ctx,
838
- llvm::function_ref<Type(const Expr *)> getType) {
839
- auto res =
840
- ObjectLiteralExpr::create (Ctx, E->getStartLoc (), E->getLiteralKind (),
841
- E->getArg (), E->isImplicit (), getType);
842
- return res;
843
- }
844
-
845
- // Make an exact copy of this AST node.
846
- LiteralExpr *LiteralExpr::shallowClone (
847
- ASTContext &Ctx, llvm::function_ref<void (Expr *, Type)> setType,
848
- llvm::function_ref<Type(const Expr *)> getType) const {
849
- LiteralExpr *Result = nullptr ;
850
- switch (getKind ()) {
851
- default : llvm_unreachable (" Unknown literal type!" );
852
- #define DISPATCH_CLONE (KIND ) \
853
- case ExprKind::KIND: \
854
- Result = shallowCloneImpl (cast<KIND##Expr>(this ), Ctx, getType); \
855
- break ;
856
-
857
- DISPATCH_CLONE (NilLiteral)
858
- DISPATCH_CLONE (IntegerLiteral)
859
- DISPATCH_CLONE (FloatLiteral)
860
- DISPATCH_CLONE (BooleanLiteral)
861
- DISPATCH_CLONE (StringLiteral)
862
- DISPATCH_CLONE (InterpolatedStringLiteral)
863
- DISPATCH_CLONE (ObjectLiteral)
864
- DISPATCH_CLONE (MagicIdentifierLiteral)
865
- #undef DISPATCH_CLONE
866
- }
867
-
868
- setType (Result, getType (this ));
869
- Result->setImplicit (isImplicit ());
870
- return Result;
871
- }
872
-
873
776
IntegerLiteralExpr * IntegerLiteralExpr::createFromUnsigned (ASTContext &C, unsigned value) {
874
777
llvm::SmallString<8 > Scratch;
875
778
llvm::APInt (sizeof (unsigned )*8 , value).toString (Scratch, 10 , /* signed*/ false );
0 commit comments