https://bugs.llvm.org/show_bug.cgi?id=41483
Bug ID: 41483
Summary: clang-format: /**/ before macro removes line breaks
and runs 200x slower
Product: clang
Version: 8.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangb...@nondot.org
Reporter: bjehl...@gmail.com
CC: djas...@google.com, kli...@google.com,
llvm-bugs@lists.llvm.org
Created attachment 21770
--> https://bugs.llvm.org/attachment.cgi?id=21770&action=edit
Code to repo the issue
Given this code (C++):
#define FOO(a, b, c) class a { static const char* b() const { return c; } };
/**/ FOO(a, aa, "aaa")
FOO(aah, aahed, "aahing")
FOO(aahs, aal, "aalii")
FOO(aaliis, aals, "aam")
FOO(aani, aardvark, "aardvarks")
The comment block /**/ before the first FOO() causes all subsequent calls to
FOO() to be merged into a single line:
/**/ FOO(a, aa, "aaa") FOO(aah, aahed, "aahing") FOO(aahs, aal, "aalii")
FOO(aaliis, aals, "aam") FOO(aani, aardvark, "aardvarks")
When a file contains ~1000 of these calls to FOO(), the results are completely
unreadable as it generates lines which are several thousand columns wide.
Simply removing the /**/ fixes the issue, leaving each FOO() on its own line
but removes all the extra spaces.
Additionally, when run on a file with ~1000 calls to FOO(), clang-format takes
200x longer to run when the file contains a /**/ before the first call to FOO()
(0.20 vs. 40 seconds on i7-5820K).
I've attached a file containing a repro which is the above code with 1000 calls
to FOO() each on their own line. Removing the /**/ before the first call to
FOO() on line 4 to see the behavior changes.
Repro: clang-format -style=llvm foo1000.cpp
The behavior I'd expect is each call to FOO() remain on its own line, with the
first one still containing the comment block and the performance to be
generally equivalent.
Expected:
/**/ FOO(a, aa, "aaa")
FOO(aah, aahed, "aahing")
FOO(aahs, aal, "aalii")
FOO(aaliis, aals, "aam")
FOO(aani, aardvark, "aardvarks")
First noticed this issue on 7.0.0, still occurs on 8.0.0.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs