From e4b6669027d78d4b5195bfe70fe471158aab1b98 Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Fri, 15 Apr 2022 15:43:10 +0000 Subject: [PATCH] Bug 1762537 - Omit some annotations when compiling under sixgill to avoid incompatibilities between what clang and gcc allow for lambda annotations r=firefox-static-analysis-reviewers,andi Differential Revision: https://phabricator.services.mozilla.com/D142714 --- mfbt/Attributes.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/mfbt/Attributes.h b/mfbt/Attributes.h index 23c5f60b2181..0323e117031f 100644 --- a/mfbt/Attributes.h +++ b/mfbt/Attributes.h @@ -841,15 +841,28 @@ # define MOZ_RAII MOZ_NON_TEMPORARY_CLASS MOZ_STACK_CLASS -// gcc has different rules governing attribute placement. Since none of these -// attributes are actually used by the gcc-based static analysis, just -// eliminate them rather than updating all of the code. +// XGILL_PLUGIN is used for the GC rooting hazard analysis, which compiles with +// gcc. gcc has different rules governing __attribute__((...)) placement, so +// some attributes will error out when used in the source code where clang +// expects them to be. Remove the problematic annotations when needed. +// +// The placement of c++11 [[...]] attributes is more flexible and defined by a +// spec, so it would be nice to switch to those for the problematic +// cases. Unfortunately, the official spec provides *no* way to annotate a +// lambda function, which is one source of the difficulty here. It appears that +// this will be fixed in c++23: https://github.com/cplusplus/papers/issues/882 # ifdef XGILL_PLUGIN + # undef MOZ_MUST_OVERRIDE -# define MOZ_MUST_OVERRIDE /* nothing */ # undef MOZ_CAN_RUN_SCRIPT_FOR_DEFINITION +# undef MOZ_CAN_RUN_SCRIPT +# undef MOZ_CAN_RUN_SCRIPT_BOUNDARY +# define MOZ_MUST_OVERRIDE /* nothing */ # define MOZ_CAN_RUN_SCRIPT_FOR_DEFINITION /* nothing */ +# define MOZ_CAN_RUN_SCRIPT /* nothing */ +# define MOZ_CAN_RUN_SCRIPT_BOUNDARY /* nothing */ + # endif #endif /* __cplusplus */