This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Add StatementAttributeLikeMacros option
ClosedPublic

Authored by HazardyKnusperkeks on Dec 23 2020, 1:16 PM.

Details

Summary

This allows to ignore for example Qts emit when
AlignConsecutiveDeclarations is set, otherwise it is parsed as a type
and it results in some misformating:

unsigned char MyChar = 'x';
emit          signal(MyChar);

For those who don't know what emit (or Q_EMIT) is in Qt: A macro which is defined as nothing. But it is often used to display that a function call is a signal which is then "emitted". Technically emit could stand anywhere in the code, but if used right it is only before a signal emission.

I added Q_EMIT unconditionally because this is also done with Q_UNUSED and QT_REQUIRE_VERSION. I did not add emit because it's all lower case and could be used as actual identifier in non Qt code, or even in Qt code when the Qt keywords are deactivated.

Diff Detail

Event Timeline

HazardyKnusperkeks requested review of this revision.Dec 23 2020, 1:16 PM
HazardyKnusperkeks created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 23 2020, 1:16 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
clang/lib/Format/FormatToken.h
54

This one I will move down, it was named differently before and I forgot to resort it after renaming.

Seems okay at the first glance. I'm wondering if we can find a better name though.

Seems okay at the first glance. I'm wondering if we can find a better name though.

I'm all in for a better name. :) I could not think of any (my first shot was IgnoredMacros, but that's way worse in my opinion).

*ping*
And I don't have a better name.

curdeius accepted this revision.Jan 16 2021, 12:02 AM

LGTM apart from the minor comment.
But I'd like @MyDeveloperDay to have a look too.

clang/lib/Format/FormatToken.h
54

Please sort it.

This revision is now accepted and ready to land.Jan 16 2021, 12:02 AM
MyDeveloperDay accepted this revision.Jan 17 2021, 3:16 AM

Please address the "not done" comment (regarding the sorting), but other than that its LGTM

HazardyKnusperkeks marked an inline comment as done.

Sorting corrected.

This revision was landed with ongoing or failed builds.Jan 17 2021, 10:02 PM
This revision was automatically updated to reflect the committed changes.

Fix documentation.

This revision was landed with ongoing or failed builds.Jan 18 2021, 2:03 AM