Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356690

Summary: Macro use after for loop formats incorrectly
Product: [Tools] CDT Reporter: Geoff Alexander <gdlxn>
Component: cdt-editorAssignee: Anton Leherbauer <aleherb+eclipse>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, gdlxn
Version: 8.0   
Target Milestone: 8.0.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Eclipse workspace containing small example illustrating the problem none

Description Geoff Alexander CLA 2011-09-04 17:42:12 EDT
Build Identifier: 20110615-0604

I've attached an Eclipse workspace containing a small example illustrating the
problem.  In ExampleClassXXXXXX.cpp the nsxxxxxx::ExampleClassXXXXXX::add(const MyClassX& aa, const MyClassX& bb) method format incorrectly:

bool nsxxxxxx::ExampleClassXXXXXX::add(const MyClassX& aa, const MyClassX& bb) {
  for (myIntXXXXXXXXXXXX_type i = 0; i < _bbbb; ++i) {
    const InnerClassXXXXXXXXXX & ccc = _ccc;
    if (ccc._aa == aa) {
      if (ccc._bb == bb) {
        return true;
      } else {
        return false;
      }
    } else if (ccc._bb == bb) {
      return false;
    }
  }NSXXXXXX_XXXXXXX(_bbbb < _aaaaaaaa);
  return true;
}

If should format as

bool nsxxxxxx::ExampleClassXXXXXX::add(const MyClassX& aa, const MyClassX& bb) {
  for (myIntXXXXXXXXXXXX_type i = 0; i < _bbbb; ++i) {
    const InnerClassXXXXXXXXXX & ccc = _ccc;
    if (ccc._aa == aa) {
      if (ccc._bb == bb) {
        return true;
      } else {
        return false;
      }
    } else if (ccc._bb == bb) {
      return false;
    }
  }
  NSXXXXXX_XXXXXXX(_bbbb < _aaaaaaaa);
  return true;
}


Reproducible: Always

Steps to Reproduce:
See the example.
Comment 1 Geoff Alexander CLA 2011-09-04 17:53:22 EDT
Created attachment 202726 [details]
Eclipse workspace containing small example illustrating the problem

Adding example
Comment 2 Anton Leherbauer CLA 2011-09-06 07:29:28 EDT
It's too late for 8.0.1, but I have a fix ready for 8.0.2.
Comment 3 Anton Leherbauer CLA 2011-09-19 05:11:56 EDT
Fixed in master and cdt_8_0.
Comment 4 CDT Genie CLA 2011-09-19 05:23:06 EDT
*** cdt git genie on behalf of Anton Leherbauer ***

    Bug 356690 - Macro use after for loop formats incorrectly

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=01b24ceba436b57970ceac00c9b2c22c48bd52a3
Comment 5 CDT Genie CLA 2011-09-19 05:23:09 EDT
*** cdt git genie on behalf of Anton Leherbauer ***

    Bug 356690 - Macro use after for loop formats incorrectly

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=d52d24ecbe5f5d05d220a93375f93933f9e77852