Skip to content

Commit

Permalink
Enforce cpplint
Browse files Browse the repository at this point in the history
  • Loading branch information
mephi42 committed Aug 17, 2024
1 parent 7afd9bd commit 31741df
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
black
ccache
cmake
cpplint
g++
gcc
git
Expand Down Expand Up @@ -57,7 +58,7 @@ jobs:
- name: Show ccache stats
run: ccache --show-stats --verbose

- name: Check formatting
- name: Check code style
run: ./fmt --check

- name: Build a source distribution
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
black
ccache
cmake
cpplint
g++
gcc
git
Expand All @@ -67,7 +68,7 @@ jobs:
- name: Show ccache stats
run: ccache --show-stats --verbose

- name: Check formatting
- name: Check code style
run: ./fmt --check

- name: Build a source distribution
Expand Down
14 changes: 12 additions & 2 deletions fmt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ def main(check):
black_args = []
clang_format_args = ["-i"]
subprocess.check_call(["black", *git_ls_py_files(), *black_args])
memtrace_ext_sources = [
*glob("memtrace_ext/*.cc"),
*glob("memtrace_ext/*.h"),
]
subprocess.check_call(
[
"clang-format",
*glob("memtrace_ext/*.cc"),
*glob("memtrace_ext/*.h"),
*memtrace_ext_sources,
*clang_format_args,
]
)
subprocess.check_call(
[
"cpplint",
"--root=memtrace_ext",
*memtrace_ext_sources,
]
)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion memtrace_ext/align.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <cstddef>
#include <cstdint>

namespace { // NOLINT(build/namespaces)
namespace { // NOLINT(build/namespaces_headers)

template <size_t N>
struct Int;
Expand Down
12 changes: 9 additions & 3 deletions memtrace_ext/debuginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
#include <stdio.h>
#include <string.h>

#include <boost/optional.hpp>
#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <utility>

// clang-format off
#include <boost/optional.hpp>
// clang-format on

namespace { // NOLINT(build/namespaces)
namespace { // NOLINT(build/namespaces_headers)

struct DwflDeleter {
void operator()(Dwfl* dwfl) { dwfl_end(dwfl); }
Expand All @@ -29,7 +35,7 @@ DwflPtr DwflBegin() { return DwflPtr(dwfl_begin(&kDwflCallbacks)); }

class SymbolIndex {
public:
SymbolIndex(Dwfl* dwfl) {
explicit SymbolIndex(Dwfl* dwfl) {
dwfl_getmodules(dwfl, &SymbolIndex::Callback, this, 0);
}

Expand Down
2 changes: 1 addition & 1 deletion memtrace_ext/disasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "./endian.h"
#include "./machine.h"

namespace { // NOLINT(build/namespaces)
namespace { // NOLINT(build/namespaces_headers)

class CsFree {
public:
Expand Down
2 changes: 1 addition & 1 deletion memtrace_ext/endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <cstdint>

namespace { // NOLINT(build/namespaces)
namespace { // NOLINT(build/namespaces_headers)

enum class Endianness {
Little,
Expand Down
2 changes: 1 addition & 1 deletion memtrace_ext/entries.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "./endian.h"
#include "./machine.h"

namespace { // NOLINT(build/namespaces)
namespace { // NOLINT(build/namespaces_headers)

enum class Tag {
MT_HEADER32 = 0x4d34,
Expand Down
2 changes: 1 addition & 1 deletion memtrace_ext/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <elf.h>

namespace { // NOLINT(build/namespaces)
namespace { // NOLINT(build/namespaces_headers)

enum class MachineType {
X_EM_386 = EM_386,
Expand Down
5 changes: 3 additions & 2 deletions memtrace_ext/memtrace_ext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ template <Endianness E, typename W>
class Trace;

template <Endianness E, typename W>
void DisasmInsnEntry(FILE* f, Disasm& disasmEngine, InsnEntry<E, W> entry) {
void DisasmInsnEntry(FILE* f, const Disasm& disasmEngine,
InsnEntry<E, W> entry) {
HexDump(f, entry.GetValue(), entry.GetSize());
std::unique_ptr<cs_insn, CsFree> insn = disasmEngine.DoDisasm(
entry.GetValue(), entry.GetSize(), entry.GetPc(), 0);
Expand Down Expand Up @@ -676,7 +677,7 @@ struct InsnIndexHeader {
using RegMeta = std::map<std::pair<std::uint16_t, std::uint16_t>, const char*>;

struct HeaderVisitor {
HeaderVisitor(RegMeta* regMeta) : regMeta(regMeta), proceed(true) {}
explicit HeaderVisitor(RegMeta* regMeta) : regMeta(regMeta), proceed(true) {}

template <Endianness E, typename W>
int operator()(size_t /* i */, RegMetaEntry<E, W> entry) {
Expand Down
2 changes: 1 addition & 1 deletion memtrace_ext/mmvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "./align.h"

namespace { // NOLINT(build/namespaces)
namespace { // NOLINT(build/namespaces_headers)

enum class InitMode {
CreateTemporary,
Expand Down

0 comments on commit 31741df

Please sign in to comment.