Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356690 - Macro use after for loop formats incorrectly
Summary: Macro use after for loop formats incorrectly
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.0.2   Edit
Assignee: Anton Leherbauer CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-04 17:42 EDT by Geoff Alexander CLA
Modified: 2011-09-19 05:23 EDT (History)
2 users (show)

See Also:


Attachments
Eclipse workspace containing small example illustrating the problem (448.73 KB, application/x-compressed-tar)
2011-09-04 17:53 EDT, Geoff Alexander CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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