Skip to content

mozcpp: refresh the list of Mozilla annotation macros #1267

Open

Description

@marco-c

Part of #1142 (upstream tree-sitter/tree-sitter-cpp#310: an annotation macro before a declaration produces an ERROR node).

tree-sitter-mozcpp handles this for Mozilla code with a hard-coded list of annotation macros (macro_annotation in tree-sitter-mozcpp/grammar.js). That list hasn't been updated in years. Several macros on it no longer exist in mozilla-central (MOZ_MUST_USE, MOZ_FALLTHROUGH, MOZ_ASAN_BLACKLIST, ...). They're harmless to keep for older code, but many annotation macros added since are missing. Every one of these currently produces an ERROR node:

MFBT_API void f();
class A { MOZ_KNOWN_LIVE RefPtr<B> mB; };
MOZ_RUNINIT static Foo sFoo;
class NS_NO_VTABLE nsIFoo : public nsISupports {};

They're widely used: GitHub code search finds MOZ_UNANNOTATED, MOZ_RUNINIT and MFBT_API in 100–200 files each. NS_NO_VTABLE is also in every generated XPIDL header.

Object-like macros from mfbt/Attributes.h, mfbt/Types.h, mfbt/MemoryChecking.h, mfbt/ThreadSafety.h, xpcom/base/nscore.h and js/src/jstypes.h that expand to an attribute, __declspec or visibility specifier, and are missing from the list:

  • visibility/linkage: MFBT_API, MFBT_DATA, MOZ_EXPORT, MOZ_IMPORT_API, MOZ_IMPORT_DATA, MOZ_ASAN_VISIBILITY, JS_PUBLIC_DATA, NS_EXPORT, NS_IMPORT, NS_HIDDEN, NS_EXTERNAL_VIS, NS_VISIBILITY_DEFAULT, NS_VISIBILITY_HIDDEN
  • class annotations: NS_NO_VTABLE, MOZ_EMPTY_BASES, MOZ_TRIVIAL_ABI, MOZ_GSL_OWNER, MOZ_GSL_POINTER, MOZ_SCOPED_CAPABILITY
  • function annotations: MOZ_NAKED, MOZ_NOINSTRUMENT, MOZ_NOPROFILE, MOZ_NOMERGE, MOZ_ASAN_IGNORE, MOZ_TSAN_IGNORE, MOZ_NO_STACK_PROTECTOR, MOZ_STANDALONE_DEBUG, MOZ_REINITIALIZES, MOZ_NO_THREAD_SAFETY_ANALYSIS, MOZ_INFALLIBLE_ALLOCATOR, MOZ_LIFETIME_BOUND, MOZ_LIFETIME_CAPTURE_BY_THIS, MOZ_CAN_RUN_SCRIPT_BOUNDARY_LAMBDA
  • variable/member annotations: MOZ_RUNINIT, MOZ_GLOBINIT, MOZ_RELEASE_CONSTINIT, MOZ_GLIBCXX_CONSTINIT, MOZ_KNOWN_LIVE, MOZ_NO_UNIQUE_ADDRESS, MOZ_UNANNOTATED, MOZ_ANNOTATED, MOZ_GUARDED_VAR, MOZ_PT_GUARDED_VAR, MOZ_NON_TERMINATED_STRING, MOZ_NULL_AFTER_MOVE

Not included on purpose: macros that expand to a type (NS_IMETHOD, NS_IMETHODIMP), calling conventions that sit after the return type (NS_FASTCALL, NS_STDCALL, ...), feature tests (MOZ_HAVE_*), and function-like macros (MOZ_GUARDED_BY(...), ...).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions