This is an archive of the discontinued LLVM Phabricator instance.

[clang-format][NFC] Fix a bug in setting type FunctionLBrace
ClosedPublic

Authored by owenpan on Feb 3 2022, 9:49 PM.

Details

Summary

The l_brace token in a macro definition should not be set to TT_FunctionLBrace.

This patch could have fixed https://github.com/llvm/llvm-project/issues/42087.

Diff Detail

Event Timeline

owenpan requested review of this revision.Feb 3 2022, 9:49 PM
owenpan created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2022, 9:49 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Well, I thought about this approach but actually a macro line should never be merged together with a preceding line, so I went for a generic approach.
That's because one never knows what's in a macro, it can well be a function brace after all depending on what goes before...
Apart from that, could you add an annotator test please?

owenpan updated this revision to Diff 405881.Feb 4 2022, 12:21 AM

Added a test case.

Well, I thought about this approach but actually a macro line should never be merged together with a preceding line, so I went for a generic approach.

That's why I didn't say yours would be obsolete. :)

That's because one never knows what's in a macro, it can well be a function brace after all depending on what goes before...

This is exactly why we should not set the type to FunctionLBrace.

Apart from that, could you add an annotator test please?

Done.

curdeius accepted this revision.Feb 4 2022, 12:50 AM

LGTM!

This revision is now accepted and ready to land.Feb 4 2022, 12:50 AM
This revision was landed with ongoing or failed builds.Feb 4 2022, 11:37 AM
This revision was automatically updated to reflect the committed changes.

LGTM, since when can't I post an empty comment?

Ah because of a race condition, I couldn't accept anymore. :)

Ah because of a race condition, I couldn't accept anymore. :)

Sorry! I should have waited a little longer. :D