Ghidra is a software reverse engineering (SRE) framework
GP-2985 Remove "using namespace" directives
caheckman8b442eac0b76
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.ccindex 2bd660889c..fdd607cc22 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc@@ -22,6 +22,7 @@#endif#ifdef CPUI_STATISTICS#include <cmath>+using std::sqrt;#endifvector<ArchitectureCapability *> ArchitectureCapability::thelist;diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/capability.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/capability.hhindex 9ed07195d5..a4d58691d6 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/capability.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/capability.hh@@ -22,7 +22,8 @@#include <vector>#include <string>-using namespace std;+using std::vector;+using std::string;/// \brief Class for automatically registering extension points to the decompiler///diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/consolemain.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/consolemain.ccindex f40f3dd669..29d2bd63b7 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/consolemain.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/consolemain.cc@@ -16,6 +16,10 @@#include <iostream>#include <cstdlib>+using std::cin;+using std::cout;+using std::cerr;+#include "libdecomp.hh"class IfcLoadFile : public IfaceDecompCommand {diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/error.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/error.hhindex 788b2421d4..6cb1c11563 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/error.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/error.hh@@ -33,7 +33,35 @@#include <cstring>#include <cctype>-using namespace std;+using std::string;+using std::map;+using std::set;+using std::list;+using std::vector;+using std::pair;+using std::make_pair;+using std::ostream;+using std::istream;+using std::ifstream;+using std::ofstream;+using std::istringstream;+using std::ostringstream;+using std::ios;+using std::dec;+using std::hex;+using std::oct;+using std::setfill;+using std::fixed;+using std::setprecision;+using std::setw;+using std::endl;+using std::ws;+using std::min;+using std::max;+using std::to_string;+using std::piecewise_construct;+using std::forward_as_tuple;+/// \brief The lowest level error generated by the decompiler///diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/filemanage.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/filemanage.hhindex 9cd6f4e8fa..9393802a48 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/filemanage.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/filemanage.hh@@ -24,7 +24,10 @@#include <sstream>#include <fstream>-using namespace std;+using std::vector;+using std::string;+using std::ifstream;+using std::ostringstream;class FileManage {vector<string> pathlist; // List of paths to search for filesdiff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/float.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/float.ccindex 068c7e991c..23bd6b385d 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/float.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/float.cc@@ -15,10 +15,20 @@* limitations under the License.*/#include "float.hh"-#include <sstream>-#include <cmath>#include "address.hh"+#include <cmath>+using std::ldexp;+using std::frexp;+using std::signbit;+using std::isnan;+using std::isinf;+using std::sqrt;+using std::floor;+using std::ceil;+using std::round;+using std::fabs;+/// Set format for a given encoding size according to IEEE 754 standards/// \param sz is the size of the encoding in bytesFloatFormat::FloatFormat(int4 sz)@@ -79,10 +89,10 @@ FloatFormat::floatclass FloatFormat::extractExpSig(double x,bool *sgn,uintb *sig{int4 e;- *sgn = std::signbit(x);+ *sgn = signbit(x);if (x == 0.0) return zero;- if (std::isinf(x)) return infinity;- if (std::isnan(x)) return nan;+ if (isinf(x)) return infinity;+ if (isnan(x)) return nan;if (*sgn)x = -x;double norm = frexp(x,&e); // norm is between 1/2 and 1@@ -232,11 +242,13 @@ double FloatFormat::getHostFloat(uintb encoding,floatclass *type) constelse if (exp == maxexponent) {if ( frac == 0 ) { // Floating point infinity*type = infinity;- return sgn ? -INFINITY : +INFINITY;+ double infinity = std::numeric_limits<double>::infinity();+ return sgn ? -infinity : +infinity;}*type = nan;// encoding is "Not a Number" NaN- return sgn ? -NAN : +NAN; // Sign is usually ignored+ double nan = std::numeric_limits<double>::quiet_NaN();+ return sgn ? -nan : +nan; // Sign is usually ignored}else*type = normalized;diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hhindex 8c682d80dc..6ee255caa4 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hh@@ -27,6 +27,9 @@#include <iostream>#include <csignal>+using std::cin;+using std::cout;+class GhidraCommand;extern ElementId ELEM_DOC; ///< Marshaling element \<doc>diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/interface.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/interface.hhindex 0771e74289..03755410b7 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/interface.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/interface.hh@@ -20,14 +20,21 @@#define __INTERFACE__#include "capability.hh"-#include <string>#include <map>#include <algorithm>#include <fstream>#include <sstream>#include <cstdio>-using namespace std;+using std::map;+using std::istream;+using std::ostream;+using std::ifstream;+using std::ofstream;+using std::istringstream;+using std::endl;+using std::ws;+using std::ios_base;#ifdef __REMOTE_SOCKET__diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/marshal.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/marshal.hhindex a6cf0fb260..bdaa70e916 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/marshal.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/marshal.hh@@ -20,7 +20,8 @@#include <list>#include <unordered_map>-using namespace std;+using std::list;+using std::unordered_map;/// \brief An annotation for a data element to being transferred to/from a stream///diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/opcodes.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/opcodes.hhindex 14ec997724..7c5cc64c54 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/opcodes.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/opcodes.hh@@ -21,7 +21,7 @@#include <string>-using namespace std;+using std::string;/// \brief The op-code defining a specific p-code operation (PcodeOp)///diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/partmap.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/partmap.hhindex 41abc55a0e..4573f4960a 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/partmap.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/partmap.hh@@ -199,7 +199,7 @@ template<typename _linetype,typename _valuetype>#if 0#include <iostream>-using namespace std;+using std::cout;int main(int argc,char **argv)diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hhindex e7ab191853..91e12244b4 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh@@ -22,6 +22,10 @@#include <iostream>#include <sstream>+using std::cout;+using std::cerr;+using std::out_of_range;+/// \brief A helper class to associate a \e named Constructor section with its symbol scope////// A Constructor can contain multiple named sections of p-code. There is a \e maindiff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.ccindex dbb8f9e51c..8516dbf107 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc@@ -16,6 +16,7 @@#include "slghsymbol.hh"#include "sleighbase.hh"#include <cmath>+using std::log;SleighSymbol *SymbolScope::addSymbol(SleighSymbol *a)diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/test.ccindex 4d9b612d0e..e1b6a04c7e 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc@@ -32,17 +32,17 @@ int UnitTest::run(set<string> &testNames)if (testNames.size() > 0 && testNames.find(t->name) == testNames.end()) {continue;}- std::cerr << "testing : " << t->name << " ..." << std::endl;+ cerr << "testing : " << t->name << " ..." << endl;++total;try {t->func();++passed;- std::cerr << " passed." << std::endl;+ cerr << " passed." << endl;} catch(...) {}}- std::cerr << "==============================" << std::endl;- std::cerr << passed << "/" << total << " tests passed." << std::endl;+ cerr << "==============================" << endl;+ cerr << passed << "/" << total << " tests passed." << endl;return total - passed;}diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/test.hhindex a138f511d0..b593db91fc 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh@@ -30,8 +30,17 @@#include <vector>#include <set>#include <string>+#include <sstream>#include <iostream>+using std::vector;+using std::set;+using std::string;+using std::ostringstream;+using std::cout;+using std::cerr;+using std::endl;+typedef void (*testfunc_t)(); ///< A unit-test function/// \brief Simple unit test class@@ -40,21 +49,21 @@ typedef void (*testfunc_t)(); ///< A unit-test function/// The static run() method calls all the function pointers of all instantiated/// objects.struct UnitTest {- static std::vector<UnitTest *> tests; ///< The collection of test objects- std::string name; ///< Name of the test+ static vector<UnitTest *> tests; ///< The collection of test objects+ string name; ///< Name of the testtestfunc_t func; ///< Call-back function executing the test/// \brief Constructor////// \param name is the identifier for the test/// \param func is a call-back function that executes the test- UnitTest(const std::string &name,testfunc_t func) :+ UnitTest(const string &name,testfunc_t func) :name(name), func(func){tests.push_back(this);}- static int run(std::set<std::string> &testNames); ///< Run all the instantiated tests+ static int run(set<string> &testNames); ///< Run all the instantiated tests};@@ -67,28 +76,28 @@ struct UnitTest {/// \brief Assert that a boolean is \b true for a unit test#define ASSERT(test) \if (!(test)) { \- std::cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << #test << "\"." << std::endl; \+ cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << #test << "\"." << endl; \throw 0; \}/// \brief Assert that two values are equal for a unit test#define ASSERT_EQUALS(a, b) \if ((a) != (b)) { \- std::stringstream ssa, ssb; \+ ostringstream ssa, ssb; \ssa << (a); \ssb << (b); \- std::cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << ssa.str() \- << " == " << ssb.str() << "\"." << std::endl; \+ cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << ssa.str() \+ << " == " << ssb.str() << "\"." << endl; \throw 0; \}/// \brief Assert that two values are not equal for a unit test#define ASSERT_NOT_EQUALS(a, b) \if ((a) == (b)) { \- std::stringstream ssa, ssb; \+ ostringstream ssa, ssb; \ssa << (a); \ssb << (b); \- std::cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << ssa.str() \- << " != " << ssb.str() << "\"." << std::endl; \+ cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << ssa.str() \+ << " != " << ssb.str() << "\"." << endl; \throw 0; \}diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.ccindex 4f7110bb41..38137ffd43 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc@@ -24,7 +24,7 @@ void FunctionTestProperty::startTest(void) constvoid FunctionTestProperty::processLine(const string &line) const{- if (regex_search(line,pattern))+ if (std::regex_search(line,pattern))count += 1;}@@ -42,7 +42,7 @@ void FunctionTestProperty::restoreXml(const Element *el)s1 >> minimumMatch;istringstream s2(el->getAttributeValue("max"));s2 >> maximumMatch;- pattern = regex(el->getContent());+ pattern = std::regex(el->getContent());}void ConsoleCommands::readLine(string &line)diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hhindex 46abd6bce8..43801047a4 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh@@ -34,7 +34,7 @@ class FunctionTestProperty {int4 minimumMatch; ///< Minimum number of times property is expected to matchint4 maximumMatch; ///< Maximum number of times property is expected to matchstring name; ///< Name of the test, to be printed in test summaries- regex pattern; ///< Regular expression to match against a line of output+ std::regex pattern; ///< Regular expression to match against a line of outputmutable uint4 count; ///< Number of times regular expression has been seenpublic:string getName(void) const { return name; } ///< Get the name of the propertydiff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.ccindex 0a00521f77..704950e036 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc@@ -15,7 +15,6 @@*/#include "typeop.hh"#include "funcdata.hh"-#include <cmath>/// \param inst will hold the array of TypeOp objects, indexed on op-code/// \param tlst is the corresponding TypeFactory for the Architecturediff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/xml.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/xml.hhindex a1c763a3e0..21884553cd 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/xml.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/xml.hh@@ -25,7 +25,14 @@#include <vector>#include <map>-using namespace std;+using std::string;+using std::vector;+using std::map;+using std::istream;+using std::ostream;+using std::ifstream;+using std::dec;+using std::hex;/// \brief The \e attributes for a single XML element///diff --git a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.ccindex ab99382a3c..f88b4d0002 100644--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc+++ b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc@@ -25,7 +25,12 @@#include <cstring>#include <limits>-#include <vector>+using std::isnan;+using std::sqrt;+using std::floor;+using std::ceil;+using std::round;+using std::abs;// utility functionsfloat floatFromRawBits(uintb e) {@@ -75,7 +80,7 @@ uintb doubleToRawBits(double f) {//// FloatFormat tests-static std::vector<float> float_test_values{+static vector<float> float_test_values{-0.0f,+0.0f,-1.0f,@@ -103,7 +108,7 @@ static std::vector<float> float_test_values{std::numeric_limits<float>::infinity()};-static std::vector<int> int_test_values = {+static vector<int> int_test_values = {0, -1, 1, 1234, -1234, std::numeric_limits<int>::min(), std::numeric_limits<int>::max()};@@ -256,7 +261,7 @@ TEST(float_opSqrt) {FloatFormat format(4);for(float f:float_test_values) {- uintb true_result = floatToRawBits(sqrtf(f));+ uintb true_result = floatToRawBits(sqrt(f));uintb encoding = format.getEncoding(f);uintb result = format.opSqrt(encoding);@@ -269,7 +274,7 @@ TEST(float_opCeil) {FloatFormat format(4);for(float f:float_test_values) {- uintb true_result = floatToRawBits(ceilf(f));+ uintb true_result = floatToRawBits(ceil(f));uintb encoding = format.getEncoding(f);uintb result = format.opCeil(encoding);@@ -282,7 +287,7 @@ TEST(float_opFloor) {FloatFormat format(4);for(float f:float_test_values) {- uintb true_result = floatToRawBits(floorf(f));+ uintb true_result = floatToRawBits(floor(f));uintb encoding = format.getEncoding(f);uintb result = format.opFloor(encoding);@@ -295,7 +300,7 @@ TEST(float_opRound) {FloatFormat format(4);for(float f:float_test_values) {- uintb true_result = floatToRawBits(roundf(f));+ uintb true_result = floatToRawBits(round(f));uintb encoding = format.getEncoding(f);uintb result = format.opRound(encoding);