Skip to content

Commit

Permalink
Also autoformat Protobuf files with pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Robbins authored and eschulte committed Feb 24, 2020
1 parent 0a3cb7e commit 2bf508c
Show file tree
Hide file tree
Showing 28 changed files with 220 additions and 242 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@ SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
---
Language: Proto
...
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: clang-format
name: clang-format
language: system
files: \.(c|h|cpp|hpp)$
files: \.(c|h|cpp|hpp|proto)$
entry: clang-format -i
- repo: https://github.com/eschulte/lisp-format
rev: master
Expand All @@ -28,6 +28,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
args: ["--chars"," \t"]
- id: check-merge-conflict
- repo: https://github.com/iconmaster5326/cmake-format-pre-commit-hook
rev: v0.6.2
hooks:
Expand Down
2 changes: 1 addition & 1 deletion proto/AuxData.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- AuxData.proto ----------------------------------------------*- C++ -*-===//
//===- AuxData.proto ------------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand Down
26 changes: 13 additions & 13 deletions proto/ByteInterval.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ByteInterval.proto ---------------------------------------*- C++ -*-===//
//===- ByteInterval.proto -------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -20,19 +20,19 @@ import "DataBlock.proto";
import "SymbolicExpression.proto";

message Block {
uint64 offset = 1;
oneof value {
CodeBlock code = 2;
DataBlock data = 3;
}
uint64 offset = 1;
oneof value {
CodeBlock code = 2;
DataBlock data = 3;
}
}

message ByteInterval {
bytes uuid = 1;
repeated Block blocks = 2;
map<uint64, SymbolicExpression> symbolic_expressions = 3;
bool has_address = 4;
uint64 address = 5;
uint64 size = 6;
bytes contents = 7;
bytes uuid = 1;
repeated Block blocks = 2;
map<uint64, SymbolicExpression> symbolic_expressions = 3;
bool has_address = 4;
uint64 address = 5;
uint64 size = 6;
bytes contents = 7;
}
44 changes: 21 additions & 23 deletions proto/CFG.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- CFG.proto ------------------------------------------------*- C++ -*-===//
//===- CFG.proto ----------------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -16,35 +16,33 @@ syntax = "proto3";
package proto;

enum EdgeType {
Type_Branch = 0;
Type_Call = 1;
Type_Fallthrough = 2;
Type_Return = 3;
Type_Syscall = 4;
Type_Sysret = 5;
Type_Branch = 0;
Type_Call = 1;
Type_Fallthrough = 2;
Type_Return = 3;
Type_Syscall = 4;
Type_Sysret = 5;
}

message EdgeLabel {
bool conditional = 1;
bool direct = 2;
EdgeType type = 3;
bool conditional = 1;
bool direct = 2;
EdgeType type = 3;
}

message Edge
{
reserved 3, 4;
reserved "boolean", "integer";
message Edge {
reserved 3, 4;
reserved "boolean", "integer";

bytes source_uuid = 1;
bytes target_uuid = 2;
EdgeLabel label = 5;
bytes source_uuid = 1;
bytes target_uuid = 2;
EdgeLabel label = 5;
}

message CFG
{
reserved 1;
reserved "blocks";
message CFG {
reserved 1;
reserved "blocks";

repeated bytes vertices = 3;
repeated Edge edges = 2;
repeated bytes vertices = 3;
repeated Edge edges = 2;
}
12 changes: 6 additions & 6 deletions proto/CodeBlock.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- CodeBlock.proto ------------------------------------------*- C++ -*-===//
//===- CodeBlock.proto ----------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -16,10 +16,10 @@ syntax = "proto3";
package proto;

message CodeBlock {
reserved "address";
reserved 2;
reserved "address";
reserved 2;

bytes uuid = 1;
uint64 size = 3;
uint64 decode_mode = 4;
bytes uuid = 1;
uint64 size = 3;
uint64 decode_mode = 4;
}
10 changes: 5 additions & 5 deletions proto/DataBlock.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- DataBlock.proto ------------------------------------------*- C++ -*-===//
//===- DataBlock.proto ----------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -16,9 +16,9 @@ syntax = "proto3";
package proto;

message DataBlock {
reserved "address";
reserved 2;
reserved "address";
reserved 2;

bytes uuid = 1;
uint64 size = 3;
bytes uuid = 1;
uint64 size = 3;
}
24 changes: 12 additions & 12 deletions proto/IR.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- IR.proto -------------------------------------------------*- C++ -*-===//
//===- IR.proto -----------------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -20,16 +20,16 @@ import "CFG.proto";
import "Module.proto";

message IR {
// slot 4 has been used for multiple fields in the past
// (more specifically, main_module_id and aux_data_container),
// which is a Protobuf compatibility violation, but explains why we
// reserve more field names than field numbers.
reserved "tables", "main_module_id", "aux_data_container";
reserved 2, 4;
// slot 4 has been used for multiple fields in the past
// (more specifically, main_module_id and aux_data_container),
// which is a Protobuf compatibility violation, but explains why we
// reserve more field names than field numbers.
reserved "tables", "main_module_id", "aux_data_container";
reserved 2, 4;

bytes uuid = 1;
repeated Module modules = 3;
map<string, AuxData> aux_data = 5;
uint32 version = 6;
CFG cfg = 7;
bytes uuid = 1;
repeated Module modules = 3;
map<string, AuxData> aux_data = 5;
uint32 version = 6;
CFG cfg = 7;
}
32 changes: 16 additions & 16 deletions proto/Module.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- Module.proto ---------------------------------------------*- C++ -*-===//
//===- Module.proto -------------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand Down Expand Up @@ -42,20 +42,20 @@ enum ISA {
};

message Module {
reserved "image_byte_map", "data", "symbolic_operands",
"aux_data_container", "blocks", "cfg";
reserved 8, 10, 11, 13, 14, 15;
reserved "image_byte_map", "data", "symbolic_operands", "aux_data_container",
"blocks", "cfg";
reserved 8, 10, 11, 13, 14, 15;

bytes uuid = 1;
string binary_path = 2;
uint64 preferred_addr = 3;
int64 rebase_delta = 4;
FileFormat file_format = 5;
ISA isa = 6;
string name = 7;
repeated Symbol symbols = 9;
repeated ProxyBlock proxies = 16;
repeated Section sections = 12;
map<string, AuxData> aux_data = 17;
bytes entry_point = 18;
bytes uuid = 1;
string binary_path = 2;
uint64 preferred_addr = 3;
int64 rebase_delta = 4;
FileFormat file_format = 5;
ISA isa = 6;
string name = 7;
repeated Symbol symbols = 9;
repeated ProxyBlock proxies = 16;
repeated Section sections = 12;
map<string, AuxData> aux_data = 17;
bytes entry_point = 18;
}
5 changes: 2 additions & 3 deletions proto/Offset.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- Offset.proto -------------------------------------*- C++ -*-===//
//===- Offset.proto -------------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -15,8 +15,7 @@
syntax = "proto3";
package proto;

message Offset
{
message Offset {
bytes element_id = 1;
uint64 displacement = 2;
}
6 changes: 2 additions & 4 deletions proto/ProxyBlock.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- ProxyBlock.proto -----------------------------------------*- C++ -*-===//
//===- ProxyBlock.proto ---------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -15,6 +15,4 @@
syntax = "proto3";
package proto;

message ProxyBlock {
bytes uuid = 1;
}
message ProxyBlock { bytes uuid = 1; }
14 changes: 7 additions & 7 deletions proto/Section.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- Section.proto --------------------------------------------*- C++ -*-===//
//===- Section.proto ------------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand Down Expand Up @@ -28,11 +28,11 @@ enum SectionFlag {
}

message Section {
reserved "address", "size";
reserved 3, 4;
reserved "address", "size";
reserved 3, 4;

bytes uuid = 1;
string name = 2;
repeated ByteInterval byte_intervals = 5;
repeated SectionFlag section_flags = 6;
bytes uuid = 1;
string name = 2;
repeated ByteInterval byte_intervals = 5;
repeated SectionFlag section_flags = 6;
}
18 changes: 9 additions & 9 deletions proto/Symbol.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- Symbol.proto ---------------------------------------------*- C++ -*-===//
//===- Symbol.proto -------------------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -16,13 +16,13 @@ syntax = "proto3";
package proto;

message Symbol {
reserved 4;
reserved "storage_kind";
reserved 4;
reserved "storage_kind";

bytes uuid = 1;
oneof optional_payload {
uint64 value = 2;
bytes referent_uuid = 5;
}
string name = 3;
bytes uuid = 1;
oneof optional_payload {
uint64 value = 2;
bytes referent_uuid = 5;
}
string name = 3;
}
40 changes: 18 additions & 22 deletions proto/SymbolicExpression.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- SymbolicExpression.proto ---------------------------------*- C++ -*-===//
//===- SymbolicExpression.proto -------------------------------*- Proto -*-===//
//
// Copyright (C) 2020 GrammaTech, Inc.
//
Expand All @@ -15,31 +15,27 @@
syntax = "proto3";
package proto;

message SymStackConst
{
int32 offset = 1;
bytes symbol_uuid = 2;
message SymStackConst {
int32 offset = 1;
bytes symbol_uuid = 2;
}

message SymAddrConst
{
int64 offset = 1;
bytes symbol_uuid = 2;
message SymAddrConst {
int64 offset = 1;
bytes symbol_uuid = 2;
}

message SymAddrAddr
{
int64 scale = 1;
int64 offset = 2;
bytes symbol1_uuid = 3;
bytes symbol2_uuid = 4;
message SymAddrAddr {
int64 scale = 1;
int64 offset = 2;
bytes symbol1_uuid = 3;
bytes symbol2_uuid = 4;
}

message SymbolicExpression
{
oneof value {
SymStackConst stack_const = 1;
SymAddrConst addr_const = 2;
SymAddrAddr addr_addr = 3;
}
message SymbolicExpression {
oneof value {
SymStackConst stack_const = 1;
SymAddrConst addr_const = 2;
SymAddrAddr addr_addr = 3;
}
}
2 changes: 1 addition & 1 deletion proto/v0/AuxData.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- AuxData.proto ----------------------------------------------*- C++ -*-===//
//===- AuxData.proto ------------------------------------------*- Proto -*-===//
//
// Copyright (C) 2018 GrammaTech, Inc.
//
Expand Down
4 changes: 1 addition & 3 deletions proto/v0/AuxDataContainer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ package protoV0;

import "AuxData.proto";

message AuxDataContainer {
map<string, AuxData> aux_data = 1;
}
message AuxDataContainer { map<string, AuxData> aux_data = 1; }
Loading

0 comments on commit 2bf508c

Please sign in to comment.