@@ -850,6 +850,24 @@ class NewOrNewArrayExpr extends Expr, @any_new_expr {
850
850
this .getAllocatorCall ( )
851
851
.getArgument ( this .getAllocator ( ) .( OperatorNewAllocationFunction ) .getPlacementArgument ( ) )
852
852
}
853
+
854
+ /**
855
+ * For `operator new`, this gets the call or expression that initializes the allocated object, if any.
856
+ *
857
+ * As examples, for `new int(4)`, this will be `4`, and for `new std::vector(4)`, this will
858
+ * be a call to the constructor `std::vector::vector(size_t)` with `4` as an argument.
859
+ *
860
+ * For `operator new[]`, this gets the call or expression that initializes the first element of the
861
+ * array, if any.
862
+ *
863
+ * This will either be a call to the default constructor for the array's element type (as
864
+ * in `new std::string[10]`), or a literal zero for arrays of scalars which are zero-initialized
865
+ * due to extra parentheses (as in `new int[10]()`).
866
+ *
867
+ * At runtime, the constructor will be called once for each element in the array, but the
868
+ * constructor call only exists once in the AST.
869
+ */
870
+ final Expr getInitializer ( ) { result = this .getChild ( 1 ) }
853
871
}
854
872
855
873
/**
@@ -871,14 +889,6 @@ class NewExpr extends NewOrNewArrayExpr, @new_expr {
871
889
override Type getAllocatedType ( ) {
872
890
new_allocated_type ( underlyingElement ( this ) , unresolveElement ( result ) )
873
891
}
874
-
875
- /**
876
- * Gets the call or expression that initializes the allocated object, if any.
877
- *
878
- * As examples, for `new int(4)`, this will be `4`, and for `new std::vector(4)`, this will
879
- * be a call to the constructor `std::vector::vector(size_t)` with `4` as an argument.
880
- */
881
- Expr getInitializer ( ) { result = this .getChild ( 1 ) }
882
892
}
883
893
884
894
/**
@@ -909,18 +919,6 @@ class NewArrayExpr extends NewOrNewArrayExpr, @new_array_expr {
909
919
result = getType ( ) .getUnderlyingType ( ) .( PointerType ) .getBaseType ( )
910
920
}
911
921
912
- /**
913
- * Gets the call or expression that initializes the first element of the array, if any.
914
- *
915
- * This will either be a call to the default constructor for the array's element type (as
916
- * in `new std::string[10]`), or a literal zero for arrays of scalars which are zero-initialized
917
- * due to extra parentheses (as in `new int[10]()`).
918
- *
919
- * At runtime, the constructor will be called once for each element in the array, but the
920
- * constructor call only exists once in the AST.
921
- */
922
- Expr getInitializer ( ) { result = this .getChild ( 1 ) }
923
-
924
922
/**
925
923
* Gets the extent of the non-constant array dimension, if any.
926
924
*
0 commit comments