This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] support nested inline namespace in c++20 for modernize-concat-nested-namespaces
ClosedPublic

Authored by HerrCai0907 on Apr 10 2023, 8:38 AM.

Details

Summary

Fixed https://github.com/llvm/llvm-project/issues/56022
c++20 support namespace like namespace a::inline b {}.
If an inline namespace is not the first, it can be concatened.

Diff Detail

Event Timeline

HerrCai0907 created this revision.Apr 10 2023, 8:38 AM
Herald added a project: Restricted Project. · View Herald Transcript
HerrCai0907 requested review of this revision.Apr 10 2023, 8:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2023, 8:38 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
HerrCai0907 retitled this revision from [clang-tidy] support inline namespace in c++20 to [clang-tidy] support nested inline namespace in c++20 for modernize-concat-nested-namespaces.Apr 10 2023, 8:43 AM

remove lamda

PiotrZSL accepted this revision.Apr 10 2023, 11:50 PM

LGTM, just some style comments.

clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
84–86
if (ND->isInlineNamespace()) {
     Str.append("inline ");
   }
Str.append(ND->getName());
106

You could extract `ND.isAnonymousNamespace()` and `!ND.attrs().empty();` before if.
Like

if (ND.isAnonymousNamespace() || !ND.attrs().empty())
  return true;
This revision is now accepted and ready to land.Apr 10 2023, 11:50 PM

update acc. comments