* [PATCH] declare get_range_query attribute returns_nonnull
@ 2021-08-25 23:01 Martin Sebor
2021-08-25 23:03 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Martin Sebor @ 2021-08-25 23:01 UTC (permalink / raw)
To: Andrew MacLeod, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
Andrew, based on your remarks in our discussion Re: enable ranger
and caching in pass_waccess, I've added some comments to struct
function and get_range_query() and declared the latter with
attribute returns_nonnull to make it explicit both to readers
and to GCC that the x_range_query member is never null.
Tested on x86_64-linux.
Martin
[-- Attachment #2: gcc-get_range_query.diff --]
[-- Type: text/x-patch, Size: 1164 bytes --]
gcc/ChangeLog:
* function.h (function): Add comments.
(get_range_query): Same. Add attribute returns nonnull.
diff --git a/gcc/function.h b/gcc/function.h
index 0db51775e7c..36003e7576a 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -312,7 +312,8 @@ struct GTY(()) function {
/* Range query mechanism for functions. The default is to pick up
global ranges. If a pass wants on-demand ranges OTOH, it must
- call enable/disable_ranger(). */
+ call enable/disable_ranger(). The pointer is never null. It
+ should be queried by calling get_range_query(). */
range_query * GTY ((skip)) x_range_query;
/* Last statement uid. */
@@ -719,10 +720,10 @@ extern const char *current_function_name (void);
extern void used_types_insert (tree);
/* Returns the currently active range access class. When there is no active
- range class, global ranges are used. */
+ range class, global ranges are used. Never returns null. */
-inline range_query *
-get_range_query (struct function *fun)
+ATTRIBUTE_RETURNS_NONNULL inline range_query *
+get_range_query (const struct function *fun)
{
return fun->x_range_query;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] declare get_range_query attribute returns_nonnull
2021-08-25 23:01 [PATCH] declare get_range_query attribute returns_nonnull Martin Sebor
@ 2021-08-25 23:03 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-08-25 23:03 UTC (permalink / raw)
To: Martin Sebor, Andrew MacLeod, gcc-patches
On 8/25/2021 5:01 PM, Martin Sebor via Gcc-patches wrote:
> Andrew, based on your remarks in our discussion Re: enable ranger
> and caching in pass_waccess, I've added some comments to struct
> function and get_range_query() and declared the latter with
> attribute returns_nonnull to make it explicit both to readers
> and to GCC that the x_range_query member is never null.
>
> Tested on x86_64-linux.
>
> Martin
>
> gcc-get_range_query.diff
>
> gcc/ChangeLog:
> * function.h (function): Add comments.
> (get_range_query): Same. Add attribute returns nonnull.
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-25 23:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 23:01 [PATCH] declare get_range_query attribute returns_nonnull Martin Sebor
2021-08-25 23:03 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).