https://bugs.llvm.org/show_bug.cgi?id=44967

            Bug ID: 44967
           Summary: clang-format misinterprets binary operator & as
                    reference in boost serialization
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangb...@nondot.org
          Reporter: andre.br...@mailbox.org
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@lists.llvm.org

This is a common (simplified) pattern for boost serialization:

      struct Vec2d {
        float x;
        float y;
      };

      template <class Archive>
      void serialize(Archive& a, Vec2d& v) {
        a & v.x;
        a & v.y;
      }

There are different implementations of Archive that define the binary operator
&. But clang-format tends to interpret it as a reference:

$ clang-format myvector.h -style="{BasedOnStyle: llvm, PointerAlignment: Left}"
      struct Vec2d {
        float x;
        float y;
      };

      template <class Archive>
      void serialize(Archive& a, Vec2d& v) {
        a& v.x;
        a& v.y;
      }

$ clang-format myvector.h -style="{BasedOnStyle: llvm, PointerAlignment:
Right}"
      struct Vec2d {
        float x;
        float y;
      }

      template <class Archive>
      void serialize(Archive &a, Vec2d &v) {
        a &v.x;
        a &v.y;
      }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to