This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix preprocessor nesting after commit 529aa4b011c4ae808d658022ef643c44dd9b2c9c
ClosedPublic

Authored by krasimir on Feb 22 2022, 3:22 AM.

Details

Summary

In https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c
by setting the identifier info to nullptr, we started to subtly
interfere with the parts in the beginning of the function,
https://github.com/llvm/llvm-project/blob/529aa4b011c4ae808d658022ef643c44dd9b2c9c/clang/lib/Format/UnwrappedLineParser.cpp#L991
causing the preprocessor nesting to change in some cases. E.g., for the
added regression test, clang-format started incorrectly guessing the
language as C++.

This tries to address this by introducing an internal identifier info
element to use instead.

Diff Detail

Event Timeline

krasimir requested review of this revision.Feb 22 2022, 3:22 AM
krasimir created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2022, 3:22 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
krasimir added a project: Restricted Project.
MyDeveloperDay added inline comments.
clang/unittests/Format/FormatTest.cpp
22727

Only only

MyDeveloperDay added inline comments.Feb 22 2022, 5:47 AM
clang/lib/Format/FormatToken.h
1077

I'd be ok with just

kw_internal_ident_after_define

MyDeveloperDay accepted this revision.Feb 22 2022, 5:48 AM

Just a few nits, but LGTM

This revision is now accepted and ready to land.Feb 22 2022, 5:48 AM
curdeius retitled this revision from [clang-format] fix preprocessor nesting after https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c to [clang-format] Fix preprocessor nesting after commit 529aa4b011c4ae808d658022ef643c44dd9b2c9c.Feb 22 2022, 6:12 AM
curdeius accepted this revision.Feb 22 2022, 6:18 AM

LGTM with other comments addressed.

krasimir updated this revision to Diff 410521.Feb 22 2022, 6:41 AM
krasimir marked an inline comment as done.
  • address review comments
krasimir marked an inline comment as done.Feb 22 2022, 6:42 AM
This revision was landed with ongoing or failed builds.Feb 22 2022, 6:44 AM
This revision was automatically updated to reflect the committed changes.