Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Mark library functions whose return value depends solely on its argum…
Browse files Browse the repository at this point in the history
…ents ECF_CONST.
  • Loading branch information
ibuclaw committed Feb 11, 2018
1 parent 6e28e5a commit 14d376d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
7 changes: 7 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2018-02-11 Iain Buclaw <ibuclaw@gdcproject.org>

* runtime.def (DYNAMIC_CAST, INTERFACE_CAST): Set ECF_CONST.
(ADEQ2, ADCMP2, ARRAYCAST): Likewise.
(AAEQUAL, AAINX, AAGETRVALUEX): Likewise.
(SWITCH_STRING, SWITCH_USTRING, SWITCH_DSTRING): Likewise.

2018-02-11 Iain Buclaw <ibuclaw@gdcproject.org>

* runtime.def (BEGIN_CATCH): Set ECF_NOTHROW.
Expand Down
23 changes: 12 additions & 11 deletions gcc/d/runtime.def
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ DEF_D_RUNTIME (CALLINTERFACEFINALIZER, "_d_callinterfacefinalizer", RT(VOID),

/* Used for casting to a class or interface. */
DEF_D_RUNTIME (DYNAMIC_CAST, "_d_dynamic_cast", RT(OBJECT),
P2(OBJECT, CLASSINFO), ECF_LEAF)
P2(OBJECT, CLASSINFO), ECF_LEAF | ECF_CONST)
DEF_D_RUNTIME (INTERFACE_CAST, "_d_interface_cast", RT(OBJECT),
P2(OBJECT, CLASSINFO), ECF_LEAF)
P2(OBJECT, CLASSINFO), ECF_LEAF | ECF_CONST)

/* Used when calling new on a pointer. The `i' variant is for when the
initialiser is non-zero. */
Expand Down Expand Up @@ -104,14 +104,14 @@ DEF_D_RUNTIME (DELARRAYT, "_d_delarray_t", RT(VOID),
/* Used for value equality (x == y) and comparisons (x < y) of non-trivial
arrays. Such as an array of structs or classes. */
DEF_D_RUNTIME (ADEQ2, "_adEq2", RT(INT),
P3(ARRAY_VOID, ARRAY_VOID, CONST_TYPEINFO), 0)
P3(ARRAY_VOID, ARRAY_VOID, CONST_TYPEINFO), ECF_CONST)
DEF_D_RUNTIME (ADCMP2, "_adCmp2", RT(INT),
P3(ARRAY_VOID, ARRAY_VOID, CONST_TYPEINFO), 0)
P3(ARRAY_VOID, ARRAY_VOID, CONST_TYPEINFO), ECF_CONST)

/* Used when casting from one array type to another where the index type
sizes differ. Such as from int[] to short[]. */
DEF_D_RUNTIME (ARRAYCAST, "_d_arraycast", RT(ARRAY_VOID),
P3(SIZE_T, SIZE_T, ARRAY_VOID), ECF_LEAF)
P3(SIZE_T, SIZE_T, ARRAY_VOID), ECF_LEAF | ECF_CONST)

/* Used for (array.length = n) expressions. The `i' variant is for when the
initialiser is non-zero. */
Expand Down Expand Up @@ -175,19 +175,20 @@ DEF_D_RUNTIME (ASSOCARRAYLITERALTX, "_d_assocarrayliteralTX", RT(VOIDPTR),

/* Used for value equality of two associative arrays. */
DEF_D_RUNTIME (AAEQUAL, "_aaEqual", RT(INT),
P3(CONST_TYPEINFO, ASSOCARRAY, ASSOCARRAY), 0)
P3(CONST_TYPEINFO, ASSOCARRAY, ASSOCARRAY), ECF_CONST)

/* Used to determine is a key exists in an associative array. */
DEF_D_RUNTIME (AAINX, "_aaInX", RT(VOIDPTR),
P3(ASSOCARRAY, CONST_TYPEINFO, VOIDPTR), ECF_LEAF)
P3(ASSOCARRAY, CONST_TYPEINFO, VOIDPTR), ECF_CONST | ECF_LEAF)

/* Used to retrieve a value from an associative array index by a key. The
`Rvalue' variant returns null if the key is not found, where as aaGetY
will create new key entry for assignment. */
DEF_D_RUNTIME (AAGETY, "_aaGetY", RT(VOIDPTR),
P4(POINTER_ASSOCARRAY, CONST_TYPEINFO, SIZE_T, VOIDPTR), 0)
DEF_D_RUNTIME (AAGETRVALUEX, "_aaGetRvalueX", RT(VOIDPTR),
P4(ASSOCARRAY, CONST_TYPEINFO, SIZE_T, VOIDPTR), ECF_LEAF)
P4(ASSOCARRAY, CONST_TYPEINFO, SIZE_T, VOIDPTR),
ECF_CONST | ECF_LEAF)

/* Used when calling delete on a key entry in an associative array. */
DEF_D_RUNTIME (AADELX, "_aaDelX", RT(BOOL),
Expand All @@ -211,11 +212,11 @@ DEF_D_RUNTIME (INVARIANT, "_D9invariant12_d_invariantFC6ObjectZv", RT(VOID),
/* Used when performing a switch/cases on a string. The `u' and `d' variants
are for UTF-16 and UTF-32 strings respectively. */
DEF_D_RUNTIME (SWITCH_STRING, "_d_switch_string", RT(INT),
P2(ARRAY_STRING, STRING), ECF_LEAF)
P2(ARRAY_STRING, STRING), ECF_CONST | ECF_LEAF)
DEF_D_RUNTIME (SWITCH_USTRING, "_d_switch_ustring", RT(INT),
P2(ARRAY_WSTRING, WSTRING), ECF_LEAF)
P2(ARRAY_WSTRING, WSTRING), ECF_CONST | ECF_LEAF)
DEF_D_RUNTIME (SWITCH_DSTRING, "_d_switch_dstring", RT(INT),
P2(ARRAY_DSTRING, DSTRING), ECF_LEAF)
P2(ARRAY_DSTRING, DSTRING), ECF_CONST | ECF_LEAF)

/* Used when throwing an error that a switch statement has no default case,
and yet none of the existing cases matched. */
Expand Down

0 comments on commit 14d376d

Please sign in to comment.