diff --git a/.clang-format b/.clang-format index 72ee101e..04397ee3 100644 --- a/.clang-format +++ b/.clang-format @@ -35,7 +35,7 @@ BreakBeforeBraces: Custom BreakBeforeTernaryOperators: false BreakConstructorInitializers: BeforeComma BreakTemplateDeclarations: Yes -ColumnLimit: 120 +ColumnLimit: 0 ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 @@ -48,13 +48,8 @@ IndentCaseLabels: true IndentWidth: 4 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: "" -MacroBlockEnd: "" -MaxEmptyLinesToKeep: 3 +MaxEmptyLinesToKeep: 1 NamespaceIndentation: None -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true PenaltyBreakAssignment: 500 PointerAlignment: Left ReflowComments: false diff --git a/src/ccc/ast.h b/src/ccc/ast.h index c5cc6414..2079f731 100644 --- a/src/ccc/ast.h +++ b/src/ccc/ast.h @@ -3,7 +3,6 @@ #pragma once -#include "int128.h" #include "symbol_database.h" namespace ccc::ast { diff --git a/src/ccc/ast_json.h b/src/ccc/ast_json.h index fe02b940..3675ff38 100644 --- a/src/ccc/ast_json.h +++ b/src/ccc/ast_json.h @@ -3,13 +3,13 @@ #pragma once +#include "ast.h" +#include "symbol_database.h" + #define RAPIDJSON_HAS_STDSTRING 1 #include #include -#include "ast.h" -#include "symbol_database.h" - namespace ccc::ast { template diff --git a/src/ccc/data_refinement.cpp b/src/ccc/data_refinement.cpp index 5c7a80ed..9b934511 100644 --- a/src/ccc/data_refinement.cpp +++ b/src/ccc/data_refinement.cpp @@ -3,9 +3,10 @@ #include "data_refinement.h" -#include - #include "ast.h" +#include "int128.h" + +#include namespace ccc { diff --git a/src/ccc/dwarf_section.cpp b/src/ccc/dwarf_section.cpp index 5a7e9d83..48505e64 100644 --- a/src/ccc/dwarf_section.cpp +++ b/src/ccc/dwarf_section.cpp @@ -3,8 +3,6 @@ #include "dwarf_section.h" -#include "importer_flags.h" - namespace ccc::dwarf { Result> DIE::parse(std::span debug, u32 offset, u32 importer_flags) diff --git a/src/ccc/elf_symtab.cpp b/src/ccc/elf_symtab.cpp index 7b0e4afd..a0fb8c39 100644 --- a/src/ccc/elf_symtab.cpp +++ b/src/ccc/elf_symtab.cpp @@ -102,7 +102,8 @@ Result import_symbols(SymbolDatabase& database, // and aren't extremely useful, so we want to mark them to // prevent them from possibly being used as function names. (*label)->is_junk = (*label)->name() == "__gnu_compiled_c" - || (*label)->name() == "__gnu_compiled_cplusplus" || (*label)->name() == "gcc2_compiled."; + || (*label)->name() == "__gnu_compiled_cplusplus" + || (*label)->name() == "gcc2_compiled."; break; } diff --git a/src/ccc/mdebug_analysis.cpp b/src/ccc/mdebug_analysis.cpp index 288f6cdc..6dd5f82d 100644 --- a/src/ccc/mdebug_analysis.cpp +++ b/src/ccc/mdebug_analysis.cpp @@ -35,9 +35,9 @@ Result LocalSymbolTableAnalyser::data_type(const ParsedSymbol& symbol) } bool is_struct = (*node)->descriptor == ast::STRUCT_OR_UNION && (*node)->as().is_struct; - bool force_typedef = ((m_context.importer_flags & TYPEDEF_ALL_ENUMS) && (*node)->descriptor == ast::ENUM) - || ((m_context.importer_flags & TYPEDEF_ALL_STRUCTS) && (*node)->descriptor == ast::STRUCT_OR_UNION - && is_struct) + bool force_typedef = + ((m_context.importer_flags & TYPEDEF_ALL_ENUMS) && (*node)->descriptor == ast::ENUM) + || ((m_context.importer_flags & TYPEDEF_ALL_STRUCTS) && (*node)->descriptor == ast::STRUCT_OR_UNION && is_struct) || ((m_context.importer_flags & TYPEDEF_ALL_UNIONS) && (*node)->descriptor == ast::STRUCT_OR_UNION && !is_struct); diff --git a/src/ccc/mdebug_symbols.h b/src/ccc/mdebug_symbols.h index dd466679..d880b274 100644 --- a/src/ccc/mdebug_symbols.h +++ b/src/ccc/mdebug_symbols.h @@ -3,9 +3,9 @@ #pragma once -#include "util.h" -#include "stabs.h" #include "mdebug_section.h" +#include "stabs.h" +#include "util.h" namespace ccc::mdebug { diff --git a/src/ccc/print_cpp.cpp b/src/ccc/print_cpp.cpp index dee4b8fa..3bcce01c 100644 --- a/src/ccc/print_cpp.cpp +++ b/src/ccc/print_cpp.cpp @@ -3,12 +3,13 @@ #include "print_cpp.h" -#include -#include - #include "ast.h" #include "registers.h" +#include +#include +#include + namespace ccc { enum VariableNamePrintFlags @@ -102,7 +103,6 @@ void CppPrinter::comment_block_file(const char* path) m_has_anything_been_printed = true; } - void CppPrinter::begin_include_guard(const char* macro) { if (m_has_anything_been_printed) { diff --git a/src/ccc/stabs_to_ast.cpp b/src/ccc/stabs_to_ast.cpp index 086fe7c9..fdc53f3e 100644 --- a/src/ccc/stabs_to_ast.cpp +++ b/src/ccc/stabs_to_ast.cpp @@ -82,8 +82,8 @@ Result> stabs_type_to_ast(const StabsType& type, // This prevents infinite recursion when an automatically generated member // function references an unnamed type. - bool can_compare_type_numbers = type.type_number.valid() && enclosing_struct - && enclosing_struct->type_number.valid(); + bool can_compare_type_numbers = type.type_number.valid() + && enclosing_struct && enclosing_struct->type_number.valid(); if (force_substitute && can_compare_type_numbers && type.type_number == enclosing_struct->type_number) { // It's probably a this parameter (or return type) for an unnamed type. auto type_name = std::make_unique(); diff --git a/src/ccc/symbol_database.h b/src/ccc/symbol_database.h index 3317b576..ea9714f4 100644 --- a/src/ccc/symbol_database.h +++ b/src/ccc/symbol_database.h @@ -3,13 +3,13 @@ #pragma once -#include +#include "util.h" + #include #include +#include #include -#include "util.h" - namespace ccc { // An X macro for all the symbol types. diff --git a/src/ccc/symbol_json.h b/src/ccc/symbol_json.h index ede34f08..bb1c5f9e 100644 --- a/src/ccc/symbol_json.h +++ b/src/ccc/symbol_json.h @@ -3,12 +3,12 @@ #pragma once +#include "symbol_database.h" + #define RAPIDJSON_HAS_STDSTRING 1 #include #include -#include "symbol_database.h" - namespace ccc { extern const u32 JSON_FORMAT_VERSION; diff --git a/src/ccc/symbol_table.cpp b/src/ccc/symbol_table.cpp index 182c1c01..dcc1bceb 100644 --- a/src/ccc/symbol_table.cpp +++ b/src/ccc/symbol_table.cpp @@ -3,10 +3,10 @@ #include "symbol_table.h" -#include "elf.h" -#include "elf_symtab.h" #include "dwarf_importer.h" #include "dwarf_printer.h" +#include "elf.h" +#include "elf_symtab.h" #include "mdebug_importer.h" #include "mdebug_section.h" #include "sndll.h" diff --git a/src/ccc/symbol_table.h b/src/ccc/symbol_table.h index 24b1fc40..595f3542 100644 --- a/src/ccc/symbol_table.h +++ b/src/ccc/symbol_table.h @@ -3,10 +3,10 @@ #pragma once -#include - #include "symbol_database.h" +#include + namespace ccc { // Determine which symbol tables are present in a given file. diff --git a/src/ccc/util.h b/src/ccc/util.h index 5a6b1575..d274749c 100644 --- a/src/ccc/util.h +++ b/src/ccc/util.h @@ -3,17 +3,17 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include #include +#include +#include #include #include +#include #include +#include +#include +#include +#include namespace ccc { diff --git a/src/stdump.cpp b/src/stdump.cpp index a97d8d09..347e0026 100644 --- a/src/stdump.cpp +++ b/src/stdump.cpp @@ -61,30 +61,103 @@ struct StdumpCommand }; static const StdumpCommand commands[] = { - {identify_symbol_tables, "identify", - {"Identify the symbol table(s) present in the input file(s). If the input path", - "is a directory, it will be walked recursively."}}, - {print_functions, "functions", {"Print all the functions defined in the input symbol table(s) as C++."}}, - {print_globals, "globals", {"Print all the global variables defined in the input symbol table(s) as C++."}}, - {print_types, "types", {"Print all the types defined in the input symbol table(s) as C++."}}, - {print_type_graph, "type_graph", {"Print a dependency graph of all the types as a graphviz DOT file."}}, - {print_labels, "labels", - {"Print all the labels defined in the input symbol table(s). Note that this", - "may include other symbols where their type is not recoverable."}}, - {print_json, "json", - {"Print all of the above as JSON.", "", - "--compact Omit whitespace and newlines from the output."}}, - {print_symbols, "symbols", - {"Print the raw symbols in the input symbol table(s). If no additional options", + { + identify_symbol_tables, + "identify", + { + "Identify the symbol table(s) present in the input file(s). If the input path", + "is a directory, it will be walked recursively.", + }, + }, + { + print_functions, + "functions", + { + "Print all the functions defined in the input symbol table(s) as C++.", + }, + }, + { + print_globals, + "globals", + { + "Print all the global variables defined in the input symbol table(s) as C++.", + }, + }, + { + print_types, + "types", + { + "Print all the types defined in the input symbol table(s) as C++.", + }, + }, + { + print_type_graph, + "type_graph", + { + "Print a dependency graph of all the types as a graphviz DOT file.", + }, + }, + { + print_labels, + "labels", + { + "Print all the labels defined in the input symbol table(s). Note that this", + "may include other symbols where their type is not recoverable.", + }, + }, + { + print_json, + "json", + { + "Print all of the above as JSON.", + "", + "--compact Omit whitespace and newlines from the output.", + }, + }, + { + print_symbols, + "symbols", + { + "Print the raw symbols in the input symbol table(s). If no additional options", "are passed, the default behaviour is to print the local and external .mdebug", - "symbols, but not the procedure descriptors.", "", - "--locals Print local .mdebug symbols.", "", - "--procedures Print .mdebug procedure descriptors.", "", - "--externals Print external .mdebug symbols."}}, - {print_headers, "headers", {"Print the contents of the .mdebug header."}}, - {print_files, "files", {"Print a list of all the source files."}}, - {print_includes, "includes", {"Print a list of the include paths stored with .mdebug inlining information."}}, - {print_sections, "sections", {"List the names of the source files associated with each ELF section."}}}; + "symbols, but not the procedure descriptors.", + "", + "--locals Print local .mdebug symbols.", + "", + "--procedures Print .mdebug procedure descriptors.", + "", + "--externals Print external .mdebug symbols.", + }, + }, + { + print_headers, + "headers", + { + "Print the contents of the .mdebug header.", + }, + }, + { + print_files, + "files", + { + "Print a list of all the source files.", + }, + }, + { + print_includes, + "includes", + { + "Print a list of the include paths stored with .mdebug inlining information.", + }, + }, + { + print_sections, + "sections", + { + "List the names of the source files associated with each ELF section.", + }, + }, +}; int main(int argc, char** argv) {