D20572: RFC: Add .clang-format
Vlad Zagorodniy <[email protected]>
| Newsgroups | gmane.comp.kde.devel.kwin |
|---|---|
| Message-ID | <[email protected]> |
zzag added a comment.
Before:
#include "raw.h"
#include "abstract_client.h"
#include <algorithm>
#include <QComboBox>
#include <QWidget>
#include <QAbstractEventDispatcher>
#include <KWayland/Server/xdgshell_interface.h>
#include <KWayland/Client/xdgshell.h>
#include "cursor.h"
// Another block.
#include "workspace.h"
namespace KWin {
static inline void foo() { qDebug( )<< "Foo!";}
static inline void foo() {
qDebug( )<< "Foo!";}
class Client : public QObject {
Q_OBJECT
public:
explicit Client(QObject* parent=nullptr);
~Client() override;
Client(Client&&other);
Client(Client&& other);
Client(Client& &other);
Client(const Client& other);
Group* group( ) const;
int id() const { return m_id; }
int id() const {
return m_id;
}
protected:
void crash();
private:
void leakMemory();
void corruptData();
private:
int m_id;
};
void Client::crash ()
{
int* x = nullptr;
*x=42;
}
void Client::leakMemory() {
int x = 42;
switch(x)
{
case 0:
case 1: new int; break;
case 2: new int[2]; break;
case 42: new int[42]; break;
default:
crash();
break;
}
if(2 + 2 == 5)
{
foo ();
}
else
{
crash();
}
connect(this, &Client::foobared,
this, &QObject::deleteLater);
disconnect(this, &Client::foobared,
this, &QObject::deleteLater);
const int expr = 1 + 2 +
3;
const int expr = 1 + 2
+ 3;
const int expr =
1 + 2 + 3;
if (2 + 2 == 4)
crash();
connect(this, &Client::foobared, this, [this] {
qDebug() << "foobared";
});
connect(this, &Client::foobared, this,
[this] {
qDebug() << "foobared";
}
);
}
}
After running clang-format:
#include "raw.h"
#include "abstract_client.h"
#include "cursor.h"
#include <KWayland/Client/xdgshell.h>
#include <KWayland/Server/xdgshell_interface.h>
#include <QAbstractEventDispatcher>
#include <QComboBox>
#include <QWidget>
#include <algorithm>
// Another block.
#include "workspace.h"
namespace KWin
{
static inline void foo() { qDebug() << "Foo!"; }
static inline void foo()
{
qDebug() << "Foo!";
}
class Client : public QObject
{
Q_OBJECT
public:
explicit Client(QObject *parent = nullptr);
~Client() override;
Client(Client &&other);
Client(Client &&other);
Client(Client &&other);
Client(const Client &other);
Group *group() const;
int id() const { return m_id; }
int id() const
{
return m_id;
}
protected:
void crash();
private:
void leakMemory();
void corruptData();
private:
int m_id;
};
void Client::crash()
{
int *x = nullptr;
*x = 42;
}
void Client::leakMemory()
{
int x = 42;
switch (x) {
case 0:
case 1:
new int;
break;
case 2:
new int[2];
break;
case 42:
new int[42];
break;
default:
crash();
break;
}
if (2 + 2 == 5) {
foo();
} else {
crash();
}
connect(this, &Client::foobared,
this, &QObject::deleteLater);
disconnect(this, &Client::foobared,
this, &QObject::deleteLater);
const int expr = 1 + 2 + 3;
const int expr = 1 + 2
+ 3;
const int expr =
1 + 2 + 3;
if (2 + 2 == 4)
crash();
connect(this, &Client::foobared, this, [this] {
qDebug() << "foobared";
});
connect(this, &Client::foobared, this,
[this] {
qDebug() << "foobared";
});
}
}
REPOSITORY
R108 KWin
REVISION DETAIL
https://phabricator.kde.org/D20572
To: zzag, #kwin
Cc: kwin, jraleigh, GB_2, mkulinski, ragreen, jackyalcine, Pitel, iodelay, bwowk, ZrenBot, ngraham, alexeymin, lesliezhai, ali-mohamed, hardening, jensreuterberg, abetts, sebas, apol, mart