Unexpected interaction between clang-format and modularity attributes

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • ALL
    • Programmability 2025-10-27, Programmability 2025-11-24, Programmability 2025-12-08
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Using clang-format to format the following is not successful:

      class MONGO_MOD_OPEN DBConnectionHook {
      public:
          virtual ~DBConnectionHook() {}
          virtual void onCreate(DBClientBase* conn) {}
          virtual void onHandedOut(DBClientBase* conn) {}
          virtual void onRelease(DBClientBase* conn) {}
          virtual void onDestroy(DBClientBase* conn) {}
      };
      

      The output for applying clang-format to the above is:

      class MONGO_MOD_OPEN DBConnectionHook{
          public : virtual ~DBConnectionHook(){} virtual void onCreate(DBClientBase * conn){} virtual void
              onHandedOut(DBClientBase * conn){} virtual void onRelease(
                  DBClientBase * conn){} virtual void onDestroy(DBClientBase * conn){}
      };
      

      Changing the code to use the default destructor appears to fix this issue:

      virtual ~DBConnectionHook() = default;
      

            Assignee:
            Mathias Stearn
            Reporter:
            Amirsaman Memaripour
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: