This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Make NamespaceEndCommentFixer add at most one comment
ClosedPublic

Authored by krasimir on Mar 6 2017, 8:39 AM.

Details

Summary

Until now, NamespaceEndCommentFixer was adding missing comments for every run,
which results in multiple end comments for:

namespace {
  int i;
  int j;
}
#if A
  int a = 1;
#else
  int a = 2;
#endif

result before:

namespace {
  int i;
  int j;
}// namespace // namespace
#if A
  int a = 1;
#else
  int a = 2;
#endif

result after:

namespace {
  int i;
  int j;
}// namespace
#if A
  int a = 1;
#else
  int a = 2;
#endif

Diff Detail

Repository
rL LLVM

Event Timeline

krasimir created this revision.Mar 6 2017, 8:39 AM
djasper accepted this revision.Mar 6 2017, 8:44 AM

Would probably be interesting to add these test cases:

#if A
namespace A {
#else
namespace B {
#endif
int i;
int j;
}//namespace A

and:

namespace A {
int i;
int j;
#if A
}//namespace A
#else
}//namespace A
#endif
lib/Format/NamespaceEndCommentsFixer.cpp
139 ↗(On Diff #90713)

Use clang-format :). (there should be a linebreak before "continue".

This revision is now accepted and ready to land.Mar 6 2017, 8:44 AM
krasimir updated this revision to Diff 90715.Mar 6 2017, 8:54 AM
  • Added missing newline
This revision was automatically updated to reflect the committed changes.