Skip to contentSkip to conversation

Recognize and ignore __alias__ and __visibility__

PATCH In review Pavel Roskin 2 participants 4 messages Aug 13, 2006 – Sep 11, 2006 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Recognize and ignore __alias__ and __visibility__

From: Pavel Roskin <[email protected]>

They are equivalent to "alias" and "visibility" except that gcc won't complain about them in ANSI programs.

---

 ident-list.h |    4 ++--
 parse.c      |    4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)
ident-list.h +2 -2
index 95bb96a..ecdce6d 100644
@@ -56,8 +56,8 @@ IDENT(__const); IDENT(__const__); IDENT(
 IDENT(__noreturn__); IDENT(regparm); IDENT(weak); IDENT(__weak__);
 IDENT(__no_instrument_function__); IDENT(no_instrument_function);
 IDENT(__sentinel__); IDENT(sentinel);
-IDENT(alias); IDENT(pure); IDENT(always_inline);
-IDENT(syscall_linkage); IDENT(visibility);
+IDENT(alias); IDENT(__alias__); IDENT(pure); IDENT(always_inline);
+IDENT(syscall_linkage); IDENT(visibility); IDENT(__visibility__);
 IDENT(bitwise); IDENT(__bitwise__);
 IDENT(model); IDENT(__model__);
 IDENT(__format_arg__);
parse.c +4 -0
index c536ec2..1c9aab8 100644
@@ -530,6 +530,8 @@ static const char * handle_attribute(str
 		return NULL;
 	if (attribute == &alias_ident)
 		return NULL;
+	if (attribute == &__alias___ident)
+		return NULL;
 	if (attribute == &pure_ident ||
 	    attribute == &__pure___ident)
 		return NULL;
@@ -539,6 +541,8 @@ static const char * handle_attribute(str
 		return NULL;
 	if (attribute == &visibility_ident)
 		return NULL;
+	if (attribute == &__visibility___ident)
+		return NULL;
 	if (attribute == &deprecated_ident ||
 	    attribute == &__deprecated___ident)
 		return NULL;
#1 lore raw
Quoted 14 lines · Pavel Roskin
parse.c +2 -0
index c536ec2..1c9aab8 100644
@@ -530,6 +530,8 @@ static const char * handle_attribute(str
 		return NULL;
 	if (attribute == &alias_ident)
 		return NULL;
+	if (attribute == &__alias___ident)
+		return NULL;
 	if (attribute == &pure_ident ||
 	    attribute == &__pure___ident)
 		return NULL;

parse.c static const char * handle_attribute(str · line 548

Quoted 8 lines
parse.c +2 -0
@@ -539,6 +541,8 @@ static const char * handle_attribute(str
 		return NULL;
 	if (attribute == &visibility_ident)
 		return NULL;
+	if (attribute == &__visibility___ident)
+		return NULL;
 	if (attribute == &deprecated_ident ||
 	    attribute == &__deprecated___ident)
 		return NULL;

Stylistically, it looks like all of the existing ignored keywords in this function use a single combined if condition for the underscored and non-underscored versions of a given keyword, rather than two separate if conditions. For consistency, what about something like the following instead:

ident-list.h +2 -2
index 95bb96a..ecdce6d 100644
@@ -56,8 +56,8 @@ IDENT(__const); IDENT(__const__); IDENT(
 IDENT(__noreturn__); IDENT(regparm); IDENT(weak); IDENT(__weak__);
 IDENT(__no_instrument_function__); IDENT(no_instrument_function);
 IDENT(__sentinel__); IDENT(sentinel);
-IDENT(alias); IDENT(pure); IDENT(always_inline);
-IDENT(syscall_linkage); IDENT(visibility);
+IDENT(alias); IDENT(__alias__); IDENT(pure); IDENT(always_inline);
+IDENT(syscall_linkage); IDENT(visibility); IDENT(__visibility__);
 IDENT(bitwise); IDENT(__bitwise__);
 IDENT(model); IDENT(__model__);
 IDENT(__format_arg__);
parse.c +4 -2
index c536ec2..6857541 100644
@@ -528,7 +528,8 @@ static const char * handle_attribute(str
 	if (attribute == &weak_ident ||
 	    attribute == &__weak___ident)
 		return NULL;
-	if (attribute == &alias_ident)
+	if (attribute == &alias_ident ||
+	    attribute == &__alias___ident)
 		return NULL;
 	if (attribute == &pure_ident ||
 	    attribute == &__pure___ident)
@@ -537,7 +538,8 @@ static const char * handle_attribute(str
 		return NULL;
 	if (attribute == &syscall_linkage_ident)
 		return NULL;
-	if (attribute == &visibility_ident)
+	if (attribute == &visibility_ident ||
+	    attribute == &__visibility___ident)
 		return NULL;
 	if (attribute == &deprecated_ident ||
 	    attribute == &__deprecated___ident)

- Josh Triplett

#2 lore raw
Quoted 5 lines · Josh Triplett

Stylistically, it looks like all of the existing ignored keywords in this function use a single combined if condition for the underscored and non-underscored versions of a given keyword, rather than two separate if conditions. For consistency, what about something like the following instead:

Thanks for this improvement!

Signature · 2 lines
Regards,
Pavel Roskin
#3 lore raw

PATCH RESEND 1/1 Recognize and ignore __alias__ and __visibility__

In reply to Pavel Roskin

Sparse currently parses and ignores the alias and visibility attributes, but not the variants __alias__ and __visibility__, which GCC permits even in ANSI C to allow for use in headers. Add support for these variants.

---
Original patch by Pavel Roskin; modified version with consolidated if statements by me, with signoff from Pavel.

 parse.c      |    6 ++++--
 ident-list.h |    4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)
ident-list.h +2 -2
index 95bb96a..ecdce6d 100644
@@ -56,8 +56,8 @@ IDENT(__const); IDENT(__const__); IDENT(
 IDENT(__noreturn__); IDENT(regparm); IDENT(weak); IDENT(__weak__);
 IDENT(__no_instrument_function__); IDENT(no_instrument_function);
 IDENT(__sentinel__); IDENT(sentinel);
-IDENT(alias); IDENT(pure); IDENT(always_inline);
-IDENT(syscall_linkage); IDENT(visibility);
+IDENT(alias); IDENT(__alias__); IDENT(pure); IDENT(always_inline);
+IDENT(syscall_linkage); IDENT(visibility); IDENT(__visibility__);
 IDENT(bitwise); IDENT(__bitwise__);
 IDENT(model); IDENT(__model__);
 IDENT(__format_arg__);
parse.c +4 -2
index c536ec2..6857541 100644
@@ -528,7 +528,8 @@ static const char * handle_attribute(str
 	if (attribute == &weak_ident ||
 	    attribute == &__weak___ident)
 		return NULL;
-	if (attribute == &alias_ident)
+	if (attribute == &alias_ident ||
+	    attribute == &__alias___ident)
 		return NULL;
 	if (attribute == &pure_ident ||
 	    attribute == &__pure___ident)
@@ -537,7 +538,8 @@ static const char * handle_attribute(str
 		return NULL;
 	if (attribute == &syscall_linkage_ident)
 		return NULL;
-	if (attribute == &visibility_ident)
+	if (attribute == &visibility_ident ||
+	    attribute == &__visibility___ident)
 		return NULL;
 	if (attribute == &deprecated_ident ||
 	    attribute == &__deprecated___ident)