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

            Bug ID: 46969
           Summary: clang-format splits >> (bitshift) into > > (and thus
                    breaks code)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

Consider this code:

class MyClass
{
public:
  MyClass();
  ~MyClass();
  short z;
};

MyClass::MyClass(){}
MyClass::~MyClass(){}

int main(int, const char**)
{
  MyClass* s = new MyClass;
  s->z = 5;
  for (int j = 0; j < (int)s->z >> 1; ++j) // HERE IS THE IMPORTANT PART
  {
    // do nothing
  }
  return 0;
}


clang-format, with default settings, formats this into:

class MyClass {
public:
  MyClass();
  ~MyClass();
  short z;
};

MyClass::MyClass() {}
MyClass::~MyClass() {}

int main(int, const char **) {
  MyClass *s = new MyClass;
  s->z = 5;
  for (int j = 0; j<(int)s->z> > 1; ++j) { // HERE IS THE IMPORTANT PART
    // do nothing
  }
  return 0;
}


After the formatting, it does no longer compile.

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

Reply via email to