fix function objects that were deprecate in C++ 11 and removed in C++ 17 - replace mem_fun with mem_fn - eliminate binary_function and unary_function base classes - use const iterator when constructing boost::transform_iterato Signed-off-by: WizardHowl <liuwenyu7@huawei.com>
266 lines
12 KiB
Diff
266 lines
12 KiB
Diff
From 6436c734eef50d55ed6c562aa3fabf0c7039c50c Mon Sep 17 00:00:00 2001
|
|
From: "James A. Kupsch" <kupsch@cs.wisc.edu>
|
|
Date: Wed, 7 Dec 2022 13:28:08 -0600
|
|
Subject: [PATCH] eliminate deprecated C++ function objects (#1331)
|
|
|
|
fix function objects that were deprecate in C++ 11 and removed in C++ 17
|
|
|
|
- replace mem_fun with mem_fn
|
|
- eliminate binary_function and unary_function base classes
|
|
- use const iterator when constructing boost::transform_iterator
|
|
---
|
|
dyninstAPI/h/BPatch_basicBlock.h | 4 +++-
|
|
dyninstAPI/src/StackMod/StackLocation.h | 5 +++--
|
|
dyninstAPI/src/addressSpace.C | 10 +++++-----
|
|
.../AMDGPU/cdna2/InstructionDecoder-amdgpu-cdna2.C | 2 +-
|
|
.../src/AMDGPU/vega/InstructionDecoder-amdgpu-vega.C | 4 ++--
|
|
instructionAPI/src/InstructionDecoder-aarch64.C | 2 +-
|
|
instructionAPI/src/InstructionDecoder-power.C | 6 +++---
|
|
symtabAPI/h/Aggregate.h | 2 +-
|
|
symtabAPI/src/Aggregate.C | 12 ++++++------
|
|
symtabAPI/src/Object-elf.C | 4 ++--
|
|
10 files changed, 27 insertions(+), 24 deletions(-)
|
|
|
|
diff --git a/dyninstAPI/h/BPatch_basicBlock.h b/dyninstAPI/h/BPatch_basicBlock.h
|
|
index 37547d40c..de26fd81f 100644
|
|
--- a/dyninstAPI/h/BPatch_basicBlock.h
|
|
+++ b/dyninstAPI/h/BPatch_basicBlock.h
|
|
@@ -89,8 +89,10 @@ struct comparison <BPatch_basicBlock *> {
|
|
*/
|
|
class BPatch_flowGraph;
|
|
|
|
-struct BPATCH_DLL_EXPORT insnPredicate : public std::unary_function<Dyninst::InstructionAPI::Instruction, bool>
|
|
+struct BPATCH_DLL_EXPORT insnPredicate
|
|
{
|
|
+ using result_type = bool;
|
|
+ using argument_type = Dyninst::InstructionAPI::Instruction;
|
|
virtual result_type operator()(argument_type arg) = 0;
|
|
virtual ~insnPredicate() {}
|
|
|
|
diff --git a/dyninstAPI/src/StackMod/StackLocation.h b/dyninstAPI/src/StackMod/StackLocation.h
|
|
index 4b1d731e6..51775e261 100644
|
|
--- a/dyninstAPI/src/StackMod/StackLocation.h
|
|
+++ b/dyninstAPI/src/StackMod/StackLocation.h
|
|
@@ -132,7 +132,8 @@ class StackLocation {
|
|
ValidPCRange* _valid;
|
|
};
|
|
|
|
-struct less_StackLocation: public std::binary_function<StackLocation*, StackLocation*, bool> {
|
|
+struct less_StackLocation
|
|
+{
|
|
bool operator()(StackLocation* a, StackLocation* b) const {
|
|
if (a->isStackMemory() && b->isStackMemory()) {
|
|
if (a->off().height() == b->off().height()) {
|
|
@@ -178,7 +179,7 @@ class tmpObject
|
|
ValidPCRange* _valid;
|
|
};
|
|
|
|
-struct less_tmpObject: public std::binary_function<tmpObject, tmpObject, bool>
|
|
+struct less_tmpObject
|
|
{
|
|
bool operator()(tmpObject a, tmpObject b) const {
|
|
if (a.offset() < b.offset()) {
|
|
diff --git a/dyninstAPI/src/addressSpace.C b/dyninstAPI/src/addressSpace.C
|
|
index 3b4cf9eba..8978262f6 100644
|
|
--- a/dyninstAPI/src/addressSpace.C
|
|
+++ b/dyninstAPI/src/addressSpace.C
|
|
@@ -284,7 +284,7 @@ void AddressSpace::inferiorFreeCompact() {
|
|
unsigned i, nbuf = freeList.size();
|
|
|
|
/* sort buffers by address */
|
|
- std::sort(freeList.begin(), freeList.end(), ptr_fun(heapItemLessByAddr));
|
|
+ std::sort(freeList.begin(), freeList.end(), heapItemLessByAddr);
|
|
|
|
/* combine adjacent buffers */
|
|
bool needToCompact = false;
|
|
@@ -371,7 +371,7 @@ void AddressSpace::addHeap(heapItem *h) {
|
|
heap_.heapFree.push_back(h2);
|
|
|
|
/* When we add an item to heapFree, make sure it remains in sorted order */
|
|
- std::sort(heap_.heapFree.begin(), heap_.heapFree.end(), ptr_fun(heapItemLessByAddr));
|
|
+ std::sort(heap_.heapFree.begin(), heap_.heapFree.end(), heapItemLessByAddr);
|
|
|
|
heap_.totalFreeMemAvailable += h2->length;
|
|
}
|
|
@@ -425,7 +425,7 @@ Address AddressSpace::inferiorMallocInternal(unsigned size,
|
|
}
|
|
|
|
/* When we update an item in heapFree, make sure it remains in sorted order */
|
|
- std::sort(heap_.heapFree.begin(), heap_.heapFree.end(), ptr_fun(heapItemLessByAddr));
|
|
+ std::sort(heap_.heapFree.begin(), heap_.heapFree.end(), heapItemLessByAddr);
|
|
|
|
// add allocated block to active list
|
|
h->length = size;
|
|
@@ -455,7 +455,7 @@ void AddressSpace::inferiorFreeInternal(Address block) {
|
|
heap_.heapFree.push_back(h);
|
|
|
|
/* When we add an item to heapFree, make sure it remains in sorted order */
|
|
- std::sort(heap_.heapFree.begin(), heap_.heapFree.end(), ptr_fun(heapItemLessByAddr));
|
|
+ std::sort(heap_.heapFree.begin(), heap_.heapFree.end(), heapItemLessByAddr);
|
|
|
|
heap_.totalFreeMemAvailable += h->length;
|
|
heap_.freed += h->length;
|
|
@@ -561,7 +561,7 @@ bool AddressSpace::inferiorShrinkBlock(heapItem *h,
|
|
heap_.heapFree.push_back(freeEnd);
|
|
|
|
/* When we add an item to heapFree, make sure it remains sorted */
|
|
- std::sort(heap_.heapFree.begin(), heap_.heapFree.end(), ptr_fun(heapItemLessByAddr));
|
|
+ std::sort(heap_.heapFree.begin(), heap_.heapFree.end(), heapItemLessByAddr);
|
|
}
|
|
|
|
heap_.totalFreeMemAvailable += shrink;
|
|
diff --git a/instructionAPI/src/AMDGPU/cdna2/InstructionDecoder-amdgpu-cdna2.C b/instructionAPI/src/AMDGPU/cdna2/InstructionDecoder-amdgpu-cdna2.C
|
|
index f62b1f546..daf7a4b7d 100644
|
|
--- a/instructionAPI/src/AMDGPU/cdna2/InstructionDecoder-amdgpu-cdna2.C
|
|
+++ b/instructionAPI/src/AMDGPU/cdna2/InstructionDecoder-amdgpu-cdna2.C
|
|
@@ -235,7 +235,7 @@ namespace Dyninst {
|
|
mainDecode();
|
|
if(entryToCategory(insn_in_progress->getOperation().getID())==c_BranchInsn){
|
|
//cout << "Is Branch Instruction !! , name = " << insn_in_progress -> getOperation().mnemonic << endl;
|
|
- //std::mem_fun(decode_lookup_table[instr_family])(this);
|
|
+ //std::mem_fn(decode_lookup_table[instr_family])(this);
|
|
}
|
|
b.start += insn_in_progress->size();
|
|
return *insn_in_progress;
|
|
diff --git a/instructionAPI/src/AMDGPU/vega/InstructionDecoder-amdgpu-vega.C b/instructionAPI/src/AMDGPU/vega/InstructionDecoder-amdgpu-vega.C
|
|
index 3093ece41..ed7cbed78 100644
|
|
--- a/instructionAPI/src/AMDGPU/vega/InstructionDecoder-amdgpu-vega.C
|
|
+++ b/instructionAPI/src/AMDGPU/vega/InstructionDecoder-amdgpu-vega.C
|
|
@@ -552,7 +552,7 @@ namespace Dyninst {
|
|
bool InstructionDecoder_amdgpu_vega::decodeOperands(const amdgpu_vega_insn_entry & insn_entry) {
|
|
if(insn_entry.operandCnt!=0){
|
|
for (std::size_t i =0 ; i < insn_entry.operandCnt; i++){
|
|
- std::mem_fun(insn_entry.operands[i])(this);
|
|
+ std::mem_fn(insn_entry.operands[i])(this);
|
|
}
|
|
}
|
|
return true;
|
|
@@ -721,7 +721,7 @@ namespace Dyninst {
|
|
setupInsnWord(b);
|
|
mainDecodeOpcode(b);
|
|
if(entryToCategory(insn_in_progress->getOperation().getID())==c_BranchInsn){
|
|
- std::mem_fun(decode_lookup_table[instr_family])(this);
|
|
+ std::mem_fn(decode_lookup_table[instr_family])(this);
|
|
}
|
|
b.start += insn_in_progress->size();
|
|
return *insn_in_progress;
|
|
diff --git a/instructionAPI/src/InstructionDecoder-aarch64.C b/instructionAPI/src/InstructionDecoder-aarch64.C
|
|
index 53a831c3c..2e8935923 100644
|
|
--- a/instructionAPI/src/InstructionDecoder-aarch64.C
|
|
+++ b/instructionAPI/src/InstructionDecoder-aarch64.C
|
|
@@ -2960,7 +2960,7 @@ Expression::Ptr InstructionDecoder_aarch64::makeMemRefExPair2(){
|
|
skipRm = true;
|
|
|
|
for (std::size_t i = 0; i < insn_table_entry.operandCnt; i++) {
|
|
- std::mem_fun(insn_table_entry.operands[i])(this);
|
|
+ std::mem_fn(insn_table_entry.operands[i])(this);
|
|
}
|
|
|
|
if (insn_table_index == 0)
|
|
diff --git a/instructionAPI/src/InstructionDecoder-power.C b/instructionAPI/src/InstructionDecoder-power.C
|
|
index ffd38bcf3..34b903d11 100644
|
|
--- a/instructionAPI/src/InstructionDecoder-power.C
|
|
+++ b/instructionAPI/src/InstructionDecoder-power.C
|
|
@@ -297,7 +297,7 @@ namespace Dyninst
|
|
const power_entry* current = &power_entry::main_opcode_table[field<0,5>(insn)];
|
|
while(current->next_table)
|
|
{
|
|
- current = &(std::mem_fun(current->next_table)(this));
|
|
+ current = &(std::mem_fn(current->next_table)(this));
|
|
}
|
|
if (findRAAndRS(current)) {
|
|
isRAWritten = true;
|
|
@@ -314,7 +314,7 @@ namespace Dyninst
|
|
curFn != current->operands.end();
|
|
++curFn)
|
|
{
|
|
- std::mem_fun(*curFn)(this);
|
|
+ std::mem_fn(*curFn)(this);
|
|
}
|
|
if(current->op == power_op_bclr)
|
|
{
|
|
@@ -1429,7 +1429,7 @@ using namespace boost::assign;
|
|
const power_entry* current = &power_entry::main_opcode_table[field<0,5>(insn)];
|
|
while(current->next_table)
|
|
{
|
|
- current = &(std::mem_fun(current->next_table)(this));
|
|
+ current = &(std::mem_fn(current->next_table)(this));
|
|
}
|
|
insn_in_progress = makeInstruction(current->op, current->mnemonic, 4, reinterpret_cast<unsigned char*>(&insn));
|
|
if(current->op == power_op_b ||
|
|
diff --git a/symtabAPI/h/Aggregate.h b/symtabAPI/h/Aggregate.h
|
|
index bcc930252..80caeb34b 100644
|
|
--- a/symtabAPI/h/Aggregate.h
|
|
+++ b/symtabAPI/h/Aggregate.h
|
|
@@ -86,7 +86,7 @@ class SYMTAB_EXPORT Aggregate
|
|
//std::vector<std::string> getAllMangledNames();
|
|
//std::vector<std::string> getAllPrettyNames();
|
|
//std::vector<std::string> getAllTypedNames();
|
|
- typedef boost::transform_iterator<std::const_mem_fun_t<std::string, Symbol>, std::vector<Symbol*>::const_iterator> name_iter;
|
|
+ using name_iter = boost::transform_iterator<decltype(std::mem_fn(&Symbol::getPrettyName)), std::vector<Symbol*>::const_iterator>;
|
|
name_iter mangled_names_begin() const;
|
|
name_iter mangled_names_end() const;
|
|
name_iter pretty_names_begin() const;
|
|
diff --git a/symtabAPI/src/Aggregate.C b/symtabAPI/src/Aggregate.C
|
|
index 2fc69358d..f0de0b841 100644
|
|
--- a/symtabAPI/src/Aggregate.C
|
|
+++ b/symtabAPI/src/Aggregate.C
|
|
@@ -307,26 +307,26 @@ bool Aggregate::operator==(const Aggregate &a)
|
|
|
|
Aggregate::name_iter Aggregate::mangled_names_begin() const
|
|
{
|
|
- return boost::make_transform_iterator(symbols_.begin(), std::mem_fun(&Symbol::getMangledName));
|
|
+ return boost::make_transform_iterator(symbols_.cbegin(), std::mem_fn(&Symbol::getMangledName));
|
|
}
|
|
|
|
Aggregate::name_iter Aggregate::mangled_names_end() const
|
|
{
|
|
- return boost::make_transform_iterator(symbols_.end(), std::mem_fun(&Symbol::getMangledName));
|
|
+ return boost::make_transform_iterator(symbols_.cend(), std::mem_fn(&Symbol::getMangledName));
|
|
}
|
|
Aggregate::name_iter Aggregate::pretty_names_begin() const
|
|
{
|
|
- return boost::make_transform_iterator(symbols_.begin(), std::mem_fun(&Symbol::getPrettyName));
|
|
+ return boost::make_transform_iterator(symbols_.cbegin(), std::mem_fn(&Symbol::getPrettyName));
|
|
}
|
|
Aggregate::name_iter Aggregate::pretty_names_end() const
|
|
{
|
|
- return boost::make_transform_iterator(symbols_.end(), std::mem_fun(&Symbol::getPrettyName));
|
|
+ return boost::make_transform_iterator(symbols_.cend(), std::mem_fn(&Symbol::getPrettyName));
|
|
}
|
|
Aggregate::name_iter Aggregate::typed_names_begin() const
|
|
{
|
|
- return boost::make_transform_iterator(symbols_.begin(), std::mem_fun(&Symbol::getTypedName));
|
|
+ return boost::make_transform_iterator(symbols_.cbegin(), std::mem_fn(&Symbol::getTypedName));
|
|
}
|
|
Aggregate::name_iter Aggregate::typed_names_end() const
|
|
{
|
|
- return boost::make_transform_iterator(symbols_.end(), std::mem_fun(&Symbol::getTypedName));
|
|
+ return boost::make_transform_iterator(symbols_.cend(), std::mem_fn(&Symbol::getTypedName));
|
|
}
|
|
diff --git a/symtabAPI/src/Object-elf.C b/symtabAPI/src/Object-elf.C
|
|
index 9eb7a1dc8..4e73e7a13 100644
|
|
--- a/symtabAPI/src/Object-elf.C
|
|
+++ b/symtabAPI/src/Object-elf.C
|
|
@@ -129,7 +129,7 @@ const char *pdelf_get_shnames(Elf_X *elf) {
|
|
//
|
|
// Compare function for use with the Vector<T> sort method.
|
|
//
|
|
-struct SectionHeaderSortFunction : public binary_function<Elf_X_Shdr *, Elf_X_Shdr *, bool> {
|
|
+struct SectionHeaderSortFunction {
|
|
bool operator()(Elf_X_Shdr *hdr1, Elf_X_Shdr *hdr2) {
|
|
return (hdr1->sh_addr() < hdr2->sh_addr());
|
|
}
|
|
@@ -3122,7 +3122,7 @@ int read_except_table_gcc3(
|
|
}
|
|
|
|
|
|
-struct exception_compare : public binary_function<const ExceptionBlock &, const ExceptionBlock &, bool> {
|
|
+struct exception_compare {
|
|
bool operator()(const ExceptionBlock &e1, const ExceptionBlock &e2) const {
|
|
if (e1.tryStart() < e2.tryStart())
|
|
return true;
|
|
--
|
|
2.33.0
|
|
|