GP-2985 Remove "using namespace" directives

This commit is contained in:
caheckman 2023-01-05 16:11:42 -05:00
parent 79c0f3f1de
commit 8b442eac0b
20 changed files with 127 additions and 42 deletions

View file

@ -22,6 +22,7 @@
#endif #endif
#ifdef CPUI_STATISTICS #ifdef CPUI_STATISTICS
#include <cmath> #include <cmath>
using std::sqrt;
#endif #endif
vector<ArchitectureCapability *> ArchitectureCapability::thelist; vector<ArchitectureCapability *> ArchitectureCapability::thelist;

View file

@ -22,7 +22,8 @@
#include <vector> #include <vector>
#include <string> #include <string>
using namespace std; using std::vector;
using std::string;
/// \brief Class for automatically registering extension points to the decompiler /// \brief Class for automatically registering extension points to the decompiler
/// ///

View file

@ -16,6 +16,10 @@
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
using std::cin;
using std::cout;
using std::cerr;
#include "libdecomp.hh" #include "libdecomp.hh"
class IfcLoadFile : public IfaceDecompCommand { class IfcLoadFile : public IfaceDecompCommand {

View file

@ -33,7 +33,35 @@
#include <cstring> #include <cstring>
#include <cctype> #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 /// \brief The lowest level error generated by the decompiler
/// ///

View file

@ -24,7 +24,10 @@
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
using namespace std; using std::vector;
using std::string;
using std::ifstream;
using std::ostringstream;
class FileManage { class FileManage {
vector<string> pathlist; // List of paths to search for files vector<string> pathlist; // List of paths to search for files

View file

@ -15,10 +15,20 @@
* limitations under the License. * limitations under the License.
*/ */
#include "float.hh" #include "float.hh"
#include <sstream>
#include <cmath>
#include "address.hh" #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 /// Set format for a given encoding size according to IEEE 754 standards
/// \param sz is the size of the encoding in bytes /// \param sz is the size of the encoding in bytes
FloatFormat::FloatFormat(int4 sz) FloatFormat::FloatFormat(int4 sz)
@ -79,10 +89,10 @@ FloatFormat::floatclass FloatFormat::extractExpSig(double x,bool *sgn,uintb *sig
{ {
int4 e; int4 e;
*sgn = std::signbit(x); *sgn = signbit(x);
if (x == 0.0) return zero; if (x == 0.0) return zero;
if (std::isinf(x)) return infinity; if (isinf(x)) return infinity;
if (std::isnan(x)) return nan; if (isnan(x)) return nan;
if (*sgn) if (*sgn)
x = -x; x = -x;
double norm = frexp(x,&e); // norm is between 1/2 and 1 double norm = frexp(x,&e); // norm is between 1/2 and 1
@ -232,11 +242,13 @@ double FloatFormat::getHostFloat(uintb encoding,floatclass *type) const
else if (exp == maxexponent) { else if (exp == maxexponent) {
if ( frac == 0 ) { // Floating point infinity if ( frac == 0 ) { // Floating point infinity
*type = infinity; *type = infinity;
return sgn ? -INFINITY : +INFINITY; double infinity = std::numeric_limits<double>::infinity();
return sgn ? -infinity : +infinity;
} }
*type = nan; *type = nan;
// encoding is "Not a Number" 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 else
*type = normalized; *type = normalized;

View file

@ -27,6 +27,9 @@
#include <iostream> #include <iostream>
#include <csignal> #include <csignal>
using std::cin;
using std::cout;
class GhidraCommand; class GhidraCommand;
extern ElementId ELEM_DOC; ///< Marshaling element \<doc> extern ElementId ELEM_DOC; ///< Marshaling element \<doc>

View file

@ -20,14 +20,21 @@
#define __INTERFACE__ #define __INTERFACE__
#include "capability.hh" #include "capability.hh"
#include <string>
#include <map> #include <map>
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <cstdio> #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__ #ifdef __REMOTE_SOCKET__

View file

@ -20,7 +20,8 @@
#include <list> #include <list>
#include <unordered_map> #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 /// \brief An annotation for a data element to being transferred to/from a stream
/// ///

View file

@ -21,7 +21,7 @@
#include <string> #include <string>
using namespace std; using std::string;
/// \brief The op-code defining a specific p-code operation (PcodeOp) /// \brief The op-code defining a specific p-code operation (PcodeOp)
/// ///

View file

@ -199,7 +199,7 @@ template<typename _linetype,typename _valuetype>
#if 0 #if 0
#include <iostream> #include <iostream>
using namespace std; using std::cout;
int main(int argc,char **argv) int main(int argc,char **argv)

View file

@ -22,6 +22,10 @@
#include <iostream> #include <iostream>
#include <sstream> #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 /// \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 main /// A Constructor can contain multiple named sections of p-code. There is a \e main

View file

@ -16,6 +16,7 @@
#include "slghsymbol.hh" #include "slghsymbol.hh"
#include "sleighbase.hh" #include "sleighbase.hh"
#include <cmath> #include <cmath>
using std::log;
SleighSymbol *SymbolScope::addSymbol(SleighSymbol *a) SleighSymbol *SymbolScope::addSymbol(SleighSymbol *a)

View file

@ -32,17 +32,17 @@ int UnitTest::run(set<string> &testNames)
if (testNames.size() > 0 && testNames.find(t->name) == testNames.end()) { if (testNames.size() > 0 && testNames.find(t->name) == testNames.end()) {
continue; continue;
} }
std::cerr << "testing : " << t->name << " ..." << std::endl; cerr << "testing : " << t->name << " ..." << endl;
++total; ++total;
try { try {
t->func(); t->func();
++passed; ++passed;
std::cerr << " passed." << std::endl; cerr << " passed." << endl;
} catch(...) { } catch(...) {
} }
} }
std::cerr << "==============================" << std::endl; cerr << "==============================" << endl;
std::cerr << passed << "/" << total << " tests passed." << std::endl; cerr << passed << "/" << total << " tests passed." << endl;
return total - passed; return total - passed;
} }

View file

@ -30,8 +30,17 @@
#include <vector> #include <vector>
#include <set> #include <set>
#include <string> #include <string>
#include <sstream>
#include <iostream> #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 typedef void (*testfunc_t)(); ///< A unit-test function
/// \brief Simple unit test class /// \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 /// The static run() method calls all the function pointers of all instantiated
/// objects. /// objects.
struct UnitTest { struct UnitTest {
static std::vector<UnitTest *> tests; ///< The collection of test objects static vector<UnitTest *> tests; ///< The collection of test objects
std::string name; ///< Name of the test string name; ///< Name of the test
testfunc_t func; ///< Call-back function executing the test testfunc_t func; ///< Call-back function executing the test
/// \brief Constructor /// \brief Constructor
/// ///
/// \param name is the identifier for the test /// \param name is the identifier for the test
/// \param func is a call-back function that executes 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) name(name), func(func)
{ {
tests.push_back(this); 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 /// \brief Assert that a boolean is \b true for a unit test
#define ASSERT(test) \ #define ASSERT(test) \
if (!(test)) { \ if (!(test)) { \
std::cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << #test << "\"." << std::endl; \ cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << #test << "\"." << endl; \
throw 0; \ throw 0; \
} }
/// \brief Assert that two values are equal for a unit test /// \brief Assert that two values are equal for a unit test
#define ASSERT_EQUALS(a, b) \ #define ASSERT_EQUALS(a, b) \
if ((a) != (b)) { \ if ((a) != (b)) { \
std::stringstream ssa, ssb; \ ostringstream ssa, ssb; \
ssa << (a); \ ssa << (a); \
ssb << (b); \ ssb << (b); \
std::cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << ssa.str() \ cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << ssa.str() \
<< " == " << ssb.str() << "\"." << std::endl; \ << " == " << ssb.str() << "\"." << endl; \
throw 0; \ throw 0; \
} }
/// \brief Assert that two values are not equal for a unit test /// \brief Assert that two values are not equal for a unit test
#define ASSERT_NOT_EQUALS(a, b) \ #define ASSERT_NOT_EQUALS(a, b) \
if ((a) == (b)) { \ if ((a) == (b)) { \
std::stringstream ssa, ssb; \ ostringstream ssa, ssb; \
ssa << (a); \ ssa << (a); \
ssb << (b); \ ssb << (b); \
std::cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << ssa.str() \ cerr << " failed at " << __FILE__ << ":" << __LINE__ << " asserting \"" << ssa.str() \
<< " != " << ssb.str() << "\"." << std::endl; \ << " != " << ssb.str() << "\"." << endl; \
throw 0; \ throw 0; \
} }

View file

@ -24,7 +24,7 @@ void FunctionTestProperty::startTest(void) const
void FunctionTestProperty::processLine(const string &line) const void FunctionTestProperty::processLine(const string &line) const
{ {
if (regex_search(line,pattern)) if (std::regex_search(line,pattern))
count += 1; count += 1;
} }
@ -42,7 +42,7 @@ void FunctionTestProperty::restoreXml(const Element *el)
s1 >> minimumMatch; s1 >> minimumMatch;
istringstream s2(el->getAttributeValue("max")); istringstream s2(el->getAttributeValue("max"));
s2 >> maximumMatch; s2 >> maximumMatch;
pattern = regex(el->getContent()); pattern = std::regex(el->getContent());
} }
void ConsoleCommands::readLine(string &line) void ConsoleCommands::readLine(string &line)

View file

@ -34,7 +34,7 @@ class FunctionTestProperty {
int4 minimumMatch; ///< Minimum number of times property is expected to match int4 minimumMatch; ///< Minimum number of times property is expected to match
int4 maximumMatch; ///< Maximum number of times property is expected to match int4 maximumMatch; ///< Maximum number of times property is expected to match
string name; ///< Name of the test, to be printed in test summaries string 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 output
mutable uint4 count; ///< Number of times regular expression has been seen mutable uint4 count; ///< Number of times regular expression has been seen
public: public:
string getName(void) const { return name; } ///< Get the name of the property string getName(void) const { return name; } ///< Get the name of the property

View file

@ -15,7 +15,6 @@
*/ */
#include "typeop.hh" #include "typeop.hh"
#include "funcdata.hh" #include "funcdata.hh"
#include <cmath>
/// \param inst will hold the array of TypeOp objects, indexed on op-code /// \param inst will hold the array of TypeOp objects, indexed on op-code
/// \param tlst is the corresponding TypeFactory for the Architecture /// \param tlst is the corresponding TypeFactory for the Architecture

View file

@ -25,7 +25,14 @@
#include <vector> #include <vector>
#include <map> #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 /// \brief The \e attributes for a single XML element
/// ///

View file

@ -25,7 +25,12 @@
#include <cstring> #include <cstring>
#include <limits> #include <limits>
#include <vector> using std::isnan;
using std::sqrt;
using std::floor;
using std::ceil;
using std::round;
using std::abs;
// utility functions // utility functions
float floatFromRawBits(uintb e) { float floatFromRawBits(uintb e) {
@ -75,7 +80,7 @@ uintb doubleToRawBits(double f) {
//// FloatFormat tests //// FloatFormat tests
static std::vector<float> float_test_values{ static vector<float> float_test_values{
-0.0f, -0.0f,
+0.0f, +0.0f,
-1.0f, -1.0f,
@ -103,7 +108,7 @@ static std::vector<float> float_test_values{
std::numeric_limits<float>::infinity() 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() 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); FloatFormat format(4);
for(float f:float_test_values) { for(float f:float_test_values) {
uintb true_result = floatToRawBits(sqrtf(f)); uintb true_result = floatToRawBits(sqrt(f));
uintb encoding = format.getEncoding(f); uintb encoding = format.getEncoding(f);
uintb result = format.opSqrt(encoding); uintb result = format.opSqrt(encoding);
@ -269,7 +274,7 @@ TEST(float_opCeil) {
FloatFormat format(4); FloatFormat format(4);
for(float f:float_test_values) { for(float f:float_test_values) {
uintb true_result = floatToRawBits(ceilf(f)); uintb true_result = floatToRawBits(ceil(f));
uintb encoding = format.getEncoding(f); uintb encoding = format.getEncoding(f);
uintb result = format.opCeil(encoding); uintb result = format.opCeil(encoding);
@ -282,7 +287,7 @@ TEST(float_opFloor) {
FloatFormat format(4); FloatFormat format(4);
for(float f:float_test_values) { for(float f:float_test_values) {
uintb true_result = floatToRawBits(floorf(f)); uintb true_result = floatToRawBits(floor(f));
uintb encoding = format.getEncoding(f); uintb encoding = format.getEncoding(f);
uintb result = format.opFloor(encoding); uintb result = format.opFloor(encoding);
@ -295,7 +300,7 @@ TEST(float_opRound) {
FloatFormat format(4); FloatFormat format(4);
for(float f:float_test_values) { for(float f:float_test_values) {
uintb true_result = floatToRawBits(roundf(f)); uintb true_result = floatToRawBits(round(f));
uintb encoding = format.getEncoding(f); uintb encoding = format.getEncoding(f);
uintb result = format.opRound(encoding); uintb result = format.opRound(encoding);