mozcpp: refresh the list of Mozilla annotation macros

Offen Anfängerfreundlich
#1,267 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@marco-c arbeitet bereits daran.

Seit 21.11.2026.

  • #1270 von @marco-c — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
80/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
cpp, javascript
Bereich
tooling

Rechercherichtung

Die Änderung betrifft tree-sitter-mozcpp/grammar.js, und zwar das fest codierte Array der Regel macro_annotation. Füge die aufgeführten objektartigen Makros diesem Array hinzu und behalte die vorhandenen Einträge bei. Erzeuge den Parser mit tree-sitter generate neu und bestätige mit den mozcpp-Corpus-Tests, dass die vier Snippets aus dem Issue ohne ERROR-Knoten geparst werden. Fertig ist, wenn die aufgeführten Annotationen für Sichtbarkeit, Klassen, Funktionen und Variablen akzeptiert werden und die bestehenden Grammatiktests weiterhin bestehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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(...), ...).

Vorherrschende Sprache
Rust
Sterne
469
Forks
74
Ø Merge
17 Std. 16 Min.
Gemergte PRs (30 T.)
10

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus mozilla/rust-code-analysis

Alle Issues in mozilla/rust-code-analysis

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.