| Issue |
55443
|
| Summary |
clang-format: Incorrect formatting of WhitespaceSensitiveMacros
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Hedede
|
Clang 14.0.0
When WhitespaceSensitiveMacros is enabled, multiline macros that are used as arguments get incorrectly aligned.
Sample code:
#define SIGNAL(...) 0
#define SLOT(...) 0
void connect(...);
class QObject;
int main(QObject *something, QObject *other)
{
connect(something, SIGNAL(currentSelectionChanged(QModelIndex,QModelIndex)),
other, SLOT(onCurrentSelectionChanged(QModelIndex,QModelIndex)));
}
Result without `WhitespaceSensitiveMacros` (inserts spaces inside the SIGNAL and SLOT macros which is undesirable because it negatively affects performance, see qt normalized signature):
#define SIGNAL(...) 0
#define SLOT(...) 0
void connect(...);
class QObject;
int func(QObject *something, QObject *other) {
connect(something, SIGNAL(currentSelectionChanged(QModelIndex, QModelIndex)),
other, SLOT(onCurrentSelectionChanged(QModelIndex, QModelIndex)));
}
Result with `WhitespaceSensitiveMacros` (everything that goes after the SIGNAL macro gets aligned as though it is inside of `SIGNAL()`)
#define SIGNAL(...) 0
#define SLOT(...) 0
void connect(...);
class QObject;
int func(QObject *something, QObject *other) {
connect(something,
SIGNAL(currentSelectionChanged(QModelIndex,QModelIndex)), other,
SLOT(onCurrentSelectionChanged(QModelIndex,QModelIndex)));
}
Expected result:
#define SIGNAL(...) 0
#define SLOT(...) 0
void connect(...);
class QObject;
int func(QObject *something, QObject *other) {
connect(something, SIGNAL(currentSelectionChanged(QModelIndex,QModelIndex)),
other, SLOT(onCurrentSelectionChanged(QModelIndex,QModelIndex)));
}
Configuration file:
Language: Cpp
IndentWidth: 4
WhitespaceSensitiveMacros:
- SIGNAL
- SLOT
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs