Skip to content

Commit

Permalink
Apply clang-format 18
Browse files Browse the repository at this point in the history
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
  • Loading branch information
zertosh authored and facebook-github-bot committed Apr 14, 2024
1 parent 8bb16e2 commit 9e49824
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 87 deletions.
3 changes: 1 addition & 2 deletions libredex/ControlFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2504,8 +2504,7 @@ void ControlFlowGraph::delete_pred_edges(Block* b) {
ControlFlowGraph::EdgeSet ControlFlowGraph::remove_edges_between(Block* p,
Block* s,
bool cleanup) {
return remove_edge_if(
p, s, [](const Edge*) { return true; }, cleanup);
return remove_edge_if(p, s, [](const Edge*) { return true; }, cleanup);
}

void ControlFlowGraph::delete_edges_between(Block* p, Block* s) {
Expand Down
6 changes: 3 additions & 3 deletions libredex/IRTypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1402,9 +1402,9 @@ void IRTypeChecker::check_instruction(IRInstruction* insn,
(insn->opcode() != OPCODE_INVOKE_STATIC ? 1 : 0) + arg_types->size();
if (insn->srcs_size() != expected_args) {
std::ostringstream out;
out << SHOW(insn) << ": argument count mismatch; "
<< "expected " << expected_args << ", "
<< "but found " << insn->srcs_size() << " instead";
out << SHOW(insn) << ": argument count mismatch; " << "expected "
<< expected_args << ", " << "but found " << insn->srcs_size()
<< " instead";
throw TypeCheckingException(out.str());
}
size_t src_idx{0};
Expand Down
2 changes: 1 addition & 1 deletion libredex/JarLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ bool load_jar_file(const DexLocation* location,
return true;
}

//#define LOCAL_MAIN
// #define LOCAL_MAIN
#ifdef LOCAL_MAIN
int main(int argc, char* argv[]) {
if (argc < 2) {
Expand Down
5 changes: 2 additions & 3 deletions libredex/RedexMappedFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ RedexMappedFile& RedexMappedFile::operator=(RedexMappedFile&& rhs) noexcept {

RedexMappedFile RedexMappedFile::open(std::string path, bool read_only) {
auto map = std::make_unique<boost::iostreams::mapped_file>();
std::ios_base::openmode mode =
(std::ios_base::openmode)(std::ios_base::in |
(read_only ? 0 : std::ios_base::out));
std::ios_base::openmode mode = (std::ios_base::openmode)(
std::ios_base::in | (read_only ? 0 : std::ios_base::out));
map->open(path, mode);
if (!map->is_open()) {
throw std::runtime_error(std::string("Could not map ") + path);
Expand Down
8 changes: 4 additions & 4 deletions libredex/Show.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,7 @@ std::string vshow(const DexMethod* p, bool include_annotations /*=true*/) {
if (p->get_param_anno() != nullptr) {
for (auto const& pair : *p->get_param_anno()) {
if (first) {
ss << "\n param annotations:"
<< "\n";
ss << "\n param annotations:" << "\n";
first = false;
}
ss << " " << pair.first << ": " << show(pair.second) << "\n";
Expand Down Expand Up @@ -1222,9 +1221,10 @@ std::string show(DexOpcode opcode) {
#define OP(op, ...) \
case DOPCODE_##op: \
return #op;
DOPS
DOPS
#undef OP
case FOPCODE_PACKED_SWITCH : return "PACKED_SWITCH_DATA";
case FOPCODE_PACKED_SWITCH:
return "PACKED_SWITCH_DATA";
case FOPCODE_SPARSE_SWITCH:
return "SPARSE_SWITCH_DATA";
case FOPCODE_FILLED_ARRAY:
Expand Down
18 changes: 10 additions & 8 deletions opt/instrument/BlockInstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1385,14 +1385,16 @@ MethodInfo instrument_basic_blocks(

// When there are too many blocks, collect all source blocks into the entry
// block to track them conservatively.
info.entry_source_blocks = too_many_blocks ? [&]() {
std::vector<SourceBlock*> all;
for (auto* b : cfg.blocks()) {
auto tmp = source_blocks::gather_source_blocks(b);
all.insert(all.end(), tmp.begin(), tmp.end());
}
return all;
}() : source_blocks::gather_source_blocks(cfg.entry_block());
info.entry_source_blocks =
too_many_blocks ? [&]() {
std::vector<SourceBlock*> all;
for (auto* b : cfg.blocks()) {
auto tmp = source_blocks::gather_source_blocks(b);
all.insert(all.end(), tmp.begin(), tmp.end());
}
return all;
}()
: source_blocks::gather_source_blocks(cfg.entry_block());
info.too_many_blocks = too_many_blocks;
info.num_too_many_blocks = too_many_blocks ? 1 : 0;
info.offset = method_offset;
Expand Down
8 changes: 4 additions & 4 deletions opt/instrument/Instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ void do_simple_method_tracing(DexClass* analysis_cls,
method == analysis_cls->get_clinit()) {
++excluded;
TRACE(INSTRUMENT, 2, "Excluding analysis method: %s", SHOW(method));
ofs << "M,-1," << name << "," << sum_opcode_sizes << ",\""
<< "MYSELF " << vshow(method->get_access(), true) << "\"\n";
ofs << "M,-1," << name << "," << sum_opcode_sizes << ",\"" << "MYSELF "
<< vshow(method->get_access(), true) << "\"\n";
return 0;
}

Expand All @@ -201,8 +201,8 @@ void do_simple_method_tracing(DexClass* analysis_cls,
if (InstrumentPass::is_included(method, options.blocklist)) {
++excluded;
TRACE(INSTRUMENT, 8, "Blocklist: excluded: %s", SHOW(method));
ofs << "M,-1," << name << "," << sum_opcode_sizes << ",\""
<< "BLOCKLIST " << vshow(method->get_access(), true) << "\"\n";
ofs << "M,-1," << name << "," << sum_opcode_sizes << ",\"" << "BLOCKLIST "
<< vshow(method->get_access(), true) << "\"\n";
return 0;
}

Expand Down
7 changes: 3 additions & 4 deletions opt/outliner/OutlinerTypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,9 @@ const DexType* OutlinerTypeAnalysis::get_const_insns_type_demand(
// 1. Let's see if we can get something out of the constant-uses analysis.
constant_uses::TypeDemand type_demand{constant_uses::TypeDemand::None};
for (auto insn : const_insns) {
type_demand =
(constant_uses::TypeDemand)(type_demand &
m_constant_uses->get_constant_type_demand(
const_cast<IRInstruction*>(insn)));
type_demand = (constant_uses::TypeDemand)(
type_demand & m_constant_uses->get_constant_type_demand(
const_cast<IRInstruction*>(insn)));
if (type_demand == constant_uses::TypeDemand::Error) {
return nullptr;
}
Expand Down
8 changes: 3 additions & 5 deletions service/class-merging/ApproximateShapeMerging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,9 @@ void print_edge(const Shape& from_shape,
always_assert(num_mergeables.find(from_shape) != num_mergeables.end() &&
num_mergeables.find(to_shape) != num_mergeables.end());

os << " "
<< "\"" << from_shape.to_string() << "\\n"
<< num_mergeables.at(from_shape) << "\""
<< " -> "
<< "\"" << to_shape.to_string() << "\\n"
os << " " << "\"" << from_shape.to_string() << "\\n"
<< num_mergeables.at(from_shape) << "\"" << " -> " << "\""
<< to_shape.to_string() << "\\n"
<< num_mergeables.at(to_shape) << "\""
<< " [label=\"dist=" << distance(to_shape, from_shape) << "\"]"
<< std::endl;
Expand Down
3 changes: 1 addition & 2 deletions service/regalloc/Interference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ std::ostream& Graph::write_dot_format(std::ostream& o) const {
for (const auto& pair : nodes()) {
auto reg = pair.first;
auto& node = pair.second;
o << reg << "[label=\"" << reg << " (" << node.weight() << ")\"]"
<< "\n";
o << reg << "[label=\"" << reg << " (" << node.weight() << ")\"]" << "\n";
for (auto adj : node.adjacent()) {
if (pair.first < adj) {
o << reg << " -- " << adj << "\n";
Expand Down
3 changes: 1 addition & 2 deletions test/unit/ResourceSerializationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ struct ParsedAaptOutput {
for (auto& entry_pair : config_pair.second) {
auto& e = entry_pair.second;
std::cerr << " 0x" << std::hex << entry_pair.first << " (" << e.name
<< "): "
<< "t=0x" << unsigned(e.value.dataType) << " d=0x"
<< "): " << "t=0x" << unsigned(e.value.dataType) << " d=0x"
<< e.value.data << std::dec << std::endl;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tools/oatmeal/OatmealUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include <utility>
#include <vector>

//#define DEBUG_LOG
//#define PERF_LOG
// #define DEBUG_LOG
// #define PERF_LOG

#define PACK __attribute__((packed))

Expand Down
14 changes: 7 additions & 7 deletions tools/redex-tool/DexSqlDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@ class DexSqlDump : public Tool {
options.add_options()(
"proguard-map,p",
po::value<std::string>()->value_name("redex-rename-map.txt"),
"path to a rename map")(
"output,o",
po::value<std::string>()->value_name("dex.sql"),
"path to output sql dump file (defaults to "
"stdout)")("table-prefix,t",
po::value<std::string>()->value_name("pre_"),
"prefix to use on all table names");
"path to a rename map")("output,o",
po::value<std::string>()->value_name("dex.sql"),
"path to output sql dump file (defaults to "
"stdout)")(
"table-prefix,t",
po::value<std::string>()->value_name("pre_"),
"prefix to use on all table names");
}

void run(const po::variables_map& options) override {
Expand Down
31 changes: 15 additions & 16 deletions tools/redex-tool/DiffMethodSizes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ DexMethodInfoMap load_dex_method_move_info(const std::string& dir) {
}

void dump_method_sizes_from_dexen_dir(const std::string& dexen_dir) {
std::cout << "INFO: "
<< "Loading directory " << dexen_dir << " ... " << std::endl;
std::cout << "INFO: " << "Loading directory " << dexen_dir << " ... "
<< std::endl;
auto info = load_dex_method_info(dexen_dir);
std::cout << "INFO: " << info.size() << " method information loaded"
<< std::endl;
Expand All @@ -208,16 +208,16 @@ void dump_method_sizes_from_dexen_dir(const std::string& dexen_dir) {
void diff_from_two_dexen_dirs(const std::string& dexen_dir_A,
const std::string& dexen_dir_B,
bool is_comparing_dex_size) {
std::cout << "INFO: "
<< "Loading directory " << dexen_dir_A << " ... " << std::endl;
std::cout << "INFO: " << "Loading directory " << dexen_dir_A << " ... "
<< std::endl;
RedexContext* A_context = g_redex;
auto A_info = is_comparing_dex_size ? load_dex_method_info(dexen_dir_A)
: load_dex_method_move_info(dexen_dir_A);
std::cout << "INFO: " << A_info.size() << " method information loaded"
<< std::endl;

std::cout << "INFO: "
<< "Loading directory " << dexen_dir_B << " ... " << std::endl;
std::cout << "INFO: " << "Loading directory " << dexen_dir_B << " ... "
<< std::endl;
std::unique_ptr<RedexContext> B_context(new RedexContext());
g_redex = B_context.get();
auto B_info = is_comparing_dex_size ? load_dex_method_info(dexen_dir_B)
Expand Down Expand Up @@ -274,8 +274,8 @@ void diff_from_two_dexen_dirs(const std::string& dexen_dir_A,
}

void dump_method_move_info_from_dex_dir(const std::string& dex_dir) {
std::cout << "INFO: "
<< "Loading directory " << dex_dir << " ... " << std::endl;
std::cout << "INFO: " << "Loading directory " << dex_dir << " ... "
<< std::endl;
auto info = load_dex_method_move_info(dex_dir);
std::cout << "INFO: " << info.size() << " method information loaded"
<< std::endl;
Expand All @@ -298,14 +298,13 @@ class DiffMethodSizes : public Tool {
"dexendir,d",
po::value<std::vector<std::string>>()->multitoken(),
"dump all method sizes in the given dexen directory; if two dexen "
"directories are given, compare the method sizes")("show-moves,s",
po::value<std::vector<
std::string>>()
->multitoken(),
"show number of "
"move code and "
"their size for "
"each methods");
"directories are given, compare the method sizes")(
"show-moves,s",
po::value<std::vector<std::string>>()->multitoken(),
"show number of "
"move code and "
"their size for "
"each methods");
}

void run(const po::variables_map& options) override {
Expand Down
20 changes: 8 additions & 12 deletions tools/redexdump/DumpTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ static std::string get_class_def(ddump_data* rd,
ss << "<no_file>";
}
if (cls_def->annotations_off) {
ss << ", anno: "
<< "0x" << std::hex << cls_def->annotations_off;
ss << ", anno: " << "0x" << std::hex << cls_def->annotations_off;
}
ss << ", data: "
<< "0x" << std::hex << cls_def->class_data_offset;
ss << ", data: " << "0x" << std::hex << cls_def->class_data_offset;
if (cls_def->static_values_off) {
ss << ", static values: "
<< "0x" << std::hex << cls_def->static_values_off;
ss << ", static values: " << "0x" << std::hex
<< cls_def->static_values_off;
}
}
return ss.str();
Expand Down Expand Up @@ -213,8 +211,7 @@ static std::string get_class_data_item(ddump_data* rd, uint32_t idx) {
auto flags = read_uleb128(&class_data);
auto code = read_uleb128(&class_data);
ss << get_flags(flags, false, true) << "- " << get_method(rd, meth_idx)
<< " - "
<< "0x" << std::hex << code << "\n";
<< " - " << "0x" << std::hex << code << "\n";
}
ss << "vmethods: " << vmethod_count << "\n";
meth_idx = 0;
Expand All @@ -223,8 +220,7 @@ static std::string get_class_data_item(ddump_data* rd, uint32_t idx) {
auto flags = read_uleb128(&class_data);
auto code = read_uleb128(&class_data);
ss << get_flags(flags, false, true) << "- " << get_method(rd, meth_idx)
<< " - "
<< "0x" << std::hex << code << "\n";
<< " - " << "0x" << std::hex << code << "\n";
}
return ss.str();
}
Expand All @@ -235,8 +231,8 @@ static std::string get_code_item(dex_code_item** pcode_item) {
ss << "registers_size: " << code_item->registers_size << ", "
<< "ins_size: " << code_item->ins_size << ", "
<< "outs_size: " << code_item->outs_size << ", "
<< "tries_size: " << code_item->tries_size << ", "
<< "debug_info_off: 0x" << std::hex << code_item->debug_info_off << ", "
<< "tries_size: " << code_item->tries_size << ", " << "debug_info_off: 0x"
<< std::hex << code_item->debug_info_off << ", "
<< "insns_size: " << std::dec << code_item->insns_size << "\n";
const uint16_t* dexptr =
(const uint16_t*)(code_item + 1) + code_item->insns_size;
Expand Down
18 changes: 9 additions & 9 deletions tools/tool/Tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ void Tool::add_standard_options(po::options_description& options) const {
po::value<std::string>()
->value_name("/tmp/redex_extracted_apk")
->required(),
"path of an apk dir obtained from redex.py -u")("dexendir,d",
po::value<std::string>()
->value_name(
"/tmp/"
"redex_dexen")
->required(),
"path of a dexen dir "
"obtained from redex.py "
"-u");
"path of an apk dir obtained from redex.py -u")(
"dexendir,d",
po::value<std::string>()
->value_name("/tmp/"
"redex_dexen")
->required(),
"path of a dexen dir "
"obtained from redex.py "
"-u");
}

DexStoresVector Tool::init(const std::string& system_jar_paths,
Expand Down
7 changes: 4 additions & 3 deletions util/Sha1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ static void sha_decode32(unsigned int* output,

/* W[i]
*/
#define W(i) \
(tmp = x[((i)-3) & 15] ^ x[((i)-8) & 15] ^ x[((i)-14) & 15] ^ x[(i)&15], \
(x[(i)&15] = ROTATE_LEFT(tmp, 1)))
#define W(i) \
(tmp = x[((i) - 3) & 15] ^ x[((i) - 8) & 15] ^ x[((i) - 14) & 15] ^ \
x[(i) & 15], \
(x[(i) & 15] = ROTATE_LEFT(tmp, 1)))

/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
*/
Expand Down

0 comments on commit 9e49824

Please sign in to comment.