Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-106649

Provide a Clazy fixit for marking statics/thread_locals as Q_CONSTINIT when possible

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • None
    • Core: Other
    • None
    • 13
    • Foundation PM Staging, Foundations Sprint 99, Foundation Sprint 100, Foundation Sprint 101, Foundations Sprint 102, Foundation Sprint 103, Foundation Sprint 104, Foundation Sprint 105, Foundation Sprint 106, Foundation Sprint 107, Foundation Sprint 108, Foundation Sprint 109, Foundation Sprint 110, Foundation Sprint 111, Foundation Sprint 112, Foundation Sprint 113, Foundation Sprint 114, Foundation Sprint 115, Foundation Sprint 116, Foundation Sprint 117, Foundation Sprint 118, Foundation Sprint 119, Foundation Sprint 120, Foundation Sprint 121, Foundation Sprint 122, Foundation Sprint 123, Foundation Sprint 124, Foundation Sprint 125, Foundation Sprint 126, Foundation Sprint 127, Foundation Sprint 128, Foundation Sprint 129, Foundation Sprint 130, Foundation Sprint 131, Foundation Sprint 132, Foundation Sprint 133, Foundation Sprint 134, Foundation Sprint 135, Foundation Sprint 136, Foundation Sprint 137

      The idea behind  QTBUG-100485 and QTBUG-100486 is:

      The idea behind the Q_CONSTINIT and constexpr epics was to mark every static and thread_local variable constexpr, if it can be. Failing that, mark it Q_CONSTINIT const. Failing that, mark it as Q_CONSTINIT. Failing that, mark it as intended dynamic initialization (where we're still missing a standard marker for this).

      Then have Clazy or similar do static checks and complain about unmarked statics or thread_locals.

      Along the way, try to bring variables into higher categories.

      I acknowledge that a Q_CONSTINIT variable may still be expensive to destruct, and therefore construct, because of the required registration of the dtor with the runtime, but we shouldn't let the perfect be the enemy of the good here. Don't try to be clever with PODs and Core Generalized Constant Expressions. These are things for the compiler to check, not for reviewers and other code readers to fuss about. The job of the developer is to express intent, which means exactly one of constexpr, constinit, or Q_DYNINIT should be marking up every static or thread_local variable. No exceptions.

       (quote from mmutz

       Providing a Clazy fixit will help to automate marking everything that can be constinit with Q_CONSTINIT.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            cnn Qt Core & Network
            sonakur Sona Kurazyan
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes