Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proper indention for goto destination point #24492

Open
llvmbot opened this issue Jul 14, 2015 · 8 comments · May be fixed by #65140
Open

proper indention for goto destination point #24492

llvmbot opened this issue Jul 14, 2015 · 8 comments · May be fixed by #65140
Assignees
Labels
awaiting-review Has pending Phabricator review bugzilla Issues migrated from bugzilla clang-format enhancement Improving things as opposed to bug fixing, e.g. new or missing feature good first issue https://github.com/llvm/llvm-project/contribute

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 14, 2015

Bugzilla Link 24118
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @mitchblank,@tromey

Extended Description

When using clang format based on google style.

It reformat the following code to

int main() {
  for (int i = 1; i < 10; i++)
    for (int j = 0; j < 5; j++) {
      // do something
      goto end_double_loop;
    }
end_double_loop : {}

  return 0;
}

Could someone add a clang format style options so the "end_double_loop" will be aligned to the first for loop instead of int main? Meaning the desired format is

int main() {
  for (int i = 1; i < 10; i++)
    for (int j = 0; j < 5; j++) {
      // do something
      goto end_double_loop;
    }
  end_double_loop : {}

  return 0;
}

Thanks,
Jason

@mitchblank
Copy link
Mannequin

mitchblank mannequin commented Oct 31, 2015

I'd also like better control over this. In my personal code I put labels on their own line a HALF indent back to make them stick out a bit:

int foo()
{
    /* ... */
    goto label;

    /* ... */
    abc();
  label:
    xyz();
}

...but I don't think there's a way to make clang-format do that, either.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 31, 2015

Yeah, our handling of goto labels isn't ideal.

That being said, I am not aware of major codebases using them enough to be worth spending time on it. If you (or someone else) wants to provide a patch, I am very happy to review it, but otherwise, I don't see any of the existing contributors working on this any time soon.

@tromey
Copy link
Mannequin

tromey mannequin commented May 8, 2021

I'd also like better control over this. In my personal code I put labels on
their own line a HALF indent back to make them stick out a bit:

FWIW this is typical in the GNU style as well.
This is one of the issues we found trying to use
clang-format on gdb.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@mydeveloperday
Copy link
Contributor

I confirm this is still an issue in clang-format v13

@mydeveloperday mydeveloperday added enhancement Improving things as opposed to bug fixing, e.g. new or missing feature good first issue https://github.com/llvm/llvm-project/contribute labels Dec 13, 2021
@varshneydevansh
Copy link

varshneydevansh commented Aug 11, 2023

Can I pick this issue? Since I am beginning my learning all over again and recently used clang-format in another open-source project. @MacDue

@Endilll
Copy link
Contributor

Endilll commented Aug 11, 2023

@varshneydevansh Sure!

@varshneydevansh
Copy link

varshneydevansh commented Aug 29, 2023

Hi @Endilll do I have to start working from the directory https://github.com/llvm/llvm-project/tree/main/clang

clang/lib/Format

@Endilll
Copy link
Contributor

Endilll commented Aug 29, 2023

Yes, that's where Clang subproject lives.

@varshneydevansh varshneydevansh linked a pull request Aug 31, 2023 that will close this issue
3 tasks
@xgupta xgupta added the awaiting-review Has pending Phabricator review label Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Has pending Phabricator review bugzilla Issues migrated from bugzilla clang-format enhancement Improving things as opposed to bug fixing, e.g. new or missing feature good first issue https://github.com/llvm/llvm-project/contribute
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants