Skip to content

Commit

Permalink
fix variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmeinhold committed Apr 6, 2020
1 parent 2da54af commit d5a4e9a
Show file tree
Hide file tree
Showing 85 changed files with 2,332 additions and 2,340 deletions.
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ CheckOptions:
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
# - key: readability-identifier-naming.VariableCase
# value: CamelCase
- key: readability-identifier-naming.VariableCase
value: CamelCase
1 change: 0 additions & 1 deletion .clang-tidy-ignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Checks: '-*'
WarningsAsErrors: ''
4 changes: 2 additions & 2 deletions include/phasar/Config/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PhasarConfig {
}

/// Specifies the directory in which Phasar is located.
static const std::string PhasarDirectory() { return phasar_directory; }
static const std::string PhasarDirectory() { return PhasarDir; }

/// Name of the file storing all standard header search paths used for
/// compilation.
Expand Down Expand Up @@ -129,7 +129,7 @@ class PhasarConfig {
}();

/// Specifies the directory in which Phasar is located.
static const std::string phasar_directory;
static const std::string PhasarDir;

/// Name of the file storing all glibc function names.
const std::string GLIBCFunctionListFileName =
Expand Down
28 changes: 14 additions & 14 deletions include/phasar/DB/Queries.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@

namespace psr {

extern const std::string SPO_INSERT;
extern const std::string SPOInsert;

extern const std::string SOP_INSERT;
extern const std::string SOPInsert;

extern const std::string PSO_INSERT;
extern const std::string PSOInsert;

extern const std::string POS_INSERT;
extern const std::string POSInsert;

extern const std::string OSP_INSERT;
extern const std::string OSPInsert;

extern const std::string OPS_INSERT;
extern const std::string OPSInsert;

extern const std::string SEARCH_SPO;
extern const std::string SearchSPO;

extern const std::string SEARCH_SPX;
extern const std::string SearchSPX;

extern const std::string SEARCH_SXO;
extern const std::string SearchSXO;

extern const std::string SEARCH_XPO;
extern const std::string SearchXPO;

extern const std::string SEARCH_SXX;
extern const std::string SearchSXX;

extern const std::string SEARCH_XPX;
extern const std::string SearchXPX;

extern const std::string SEARCH_XXO;
extern const std::string SearchXXO;

extern const std::string SEARCH_XXX;
extern const std::string SearchXXX;

extern const std::string INIT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class IDELinearConstantAnalysis
int64_t, LLVMBasedICFG> {
private:
// For debug purpose only
static unsigned CurrGenConstant_Id;
static unsigned CurrLCAID_Id;
static unsigned CurrBinary_Id;
static unsigned CurrGenConstantId;
static unsigned CurrLCAIDId;
static unsigned CurrBinaryId;

public:
typedef const llvm::Value *d_t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CSTDFILEIOTypeStateDescription : public TypeStateDescription {

static const std::map<std::string, std::set<int>> StdFileIOFuncs;
// delta matrix to implement the state machine's delta function
static const CSTDFILEIOState delta[3][5];
static const CSTDFILEIOState Delta[3][5];
CSTDFILEIOToken funcNameToToken(const std::string &F) const;

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class OpenSSLEVPKeyDerivationTypeStateDescription
OpenSSLEVPKeyDerivationFuncs;

// delta matrix to implement the state machine's delta function
static const OpenSSLEVPKeyDerivationState delta[6][7];
static const OpenSSLEVPKeyDerivationState Delta[6][7];

OpenSSLEVPKeyDerivationToken funcNameToToken(const std::string &F) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace psr {

extern const std::shared_ptr<AllBottom<BinaryDomain>> ALL_BOTTOM;
extern const std::shared_ptr<AllBottom<BinaryDomain>> ALLBOTTOM;

/**
* This class promotes a given IFDSTabulationProblem to an IDETabulationProblem
Expand Down Expand Up @@ -101,7 +101,7 @@ class IFDSToIDETabulationProblem
std::shared_ptr<EdgeFunction<BinaryDomain>>
getNormalEdgeFunction(N src, D srcNode, N tgt, D tgtNode) override {
if (Problem.isZeroValue(srcNode))
return ALL_BOTTOM;
return ALLBOTTOM;
else
return EdgeIdentity<BinaryDomain>::getInstance();
}
Expand All @@ -110,7 +110,7 @@ class IFDSToIDETabulationProblem
getCallEdgeFunction(N callStmt, D srcNode, F destinationFunction,
D destNode) override {
if (Problem.isZeroValue(srcNode))
return ALL_BOTTOM;
return ALLBOTTOM;
else
return EdgeIdentity<BinaryDomain>::getInstance();
}
Expand All @@ -119,7 +119,7 @@ class IFDSToIDETabulationProblem
getReturnEdgeFunction(N callSite, F calleeFunction, N exitStmt, D exitNode,
N returnSite, D retNode) override {
if (Problem.isZeroValue(exitNode))
return ALL_BOTTOM;
return ALLBOTTOM;
else
return EdgeIdentity<BinaryDomain>::getInstance();
}
Expand All @@ -128,7 +128,7 @@ class IFDSToIDETabulationProblem
getCallToRetEdgeFunction(N callStmt, D callNode, N returnSite,
D returnSideNode, std::set<F> callees) override {
if (Problem.isZeroValue(callNode))
return ALL_BOTTOM;
return ALLBOTTOM;
else
return EdgeIdentity<BinaryDomain>::getInstance();
}
Expand Down
2 changes: 1 addition & 1 deletion include/phasar/PhasarLLVM/Passes/ValueAnnotationPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ValueAnnotationPass
private:
friend llvm::AnalysisInfoMixin<ValueAnnotationPass>;
static llvm::AnalysisKey Key;
static size_t unique_value_id;
static size_t UniqueValueId;

public:
explicit ValueAnnotationPass();
Expand Down
2 changes: 1 addition & 1 deletion include/phasar/Utils/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern const std::map<std::string, severity_level> StringToSeverityLevel;

extern const std::map<severity_level, std::string> SeverityLevelToString;

extern severity_level logFilterLevel;
extern severity_level LogFilterLevel;

std::ostream &operator<<(std::ostream &os, enum severity_level l);

Expand Down
42 changes: 21 additions & 21 deletions lib/Config/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ std::string PhasarConfig::readConfigFile(const std::string &Path) {
// other phasar libraries.
if (boost::filesystem::exists(Path) &&
!boost::filesystem::is_directory(Path)) {
std::ifstream ifs(Path, std::ios::binary);
if (ifs.is_open()) {
ifs.seekg(0, ifs.end);
size_t file_size = ifs.tellg();
ifs.seekg(0, ifs.beg);
std::string content(file_size + 1, '\0');
ifs.read(const_cast<char *>(content.data()), file_size);
return content;
std::ifstream Ifs(Path, std::ios::binary);
if (Ifs.is_open()) {
Ifs.seekg(0, Ifs.end);
size_t FileSize = Ifs.tellg();
Ifs.seekg(0, Ifs.beg);
std::string Content(FileSize + 1, '\0');
Ifs.read(const_cast<char *>(Content.data()), FileSize);
return Content;
}
}
throw std::ios_base::failure("could not read file: " + Path);
Expand All @@ -59,13 +59,13 @@ void PhasarConfig::loadGlibcSpecialFunctionNames() {

if (boost::filesystem::exists(GLIBCFunctionListFilePath)) {
// Load glibc function names specified in the config file
std::vector<std::string> glibcfunctions;
std::string glibc = readConfigFile(GLIBCFunctionListFilePath);
std::vector<std::string> GlibcFunctions;
std::string Glibc = readConfigFile(GLIBCFunctionListFilePath);
// Insert glibc function names
boost::split(glibcfunctions, glibc, boost::is_any_of("\n"),
boost::split(GlibcFunctions, Glibc, boost::is_any_of("\n"),
boost::token_compress_on);

special_function_names.insert(glibcfunctions.begin(), glibcfunctions.end());
special_function_names.insert(GlibcFunctions.begin(), GlibcFunctions.end());
} else {
// Add default glibc function names
special_function_names.insert({"_exit"});
Expand All @@ -77,25 +77,25 @@ void PhasarConfig::loadLLVMSpecialFunctionNames() {
ConfigurationDirectory() + LLVMIntrinsicFunctionListFileName;
if (boost::filesystem::exists(LLVMFunctionListFilePath)) {
// Load LLVM function names specified in the config file
std::string llvmintrinsics = readConfigFile(LLVMFunctionListFilePath);
std::string LLVMIntrinsics = readConfigFile(LLVMFunctionListFilePath);

std::vector<std::string> llvmintrinsicfunctions;
boost::split(llvmintrinsicfunctions, llvmintrinsics, boost::is_any_of("\n"),
std::vector<std::string> LLVMIntrinsicFunctions;
boost::split(LLVMIntrinsicFunctions, LLVMIntrinsics, boost::is_any_of("\n"),
boost::token_compress_on);

// Insert llvm intrinsic function names
special_function_names.insert(llvmintrinsicfunctions.begin(),
llvmintrinsicfunctions.end());
special_function_names.insert(LLVMIntrinsicFunctions.begin(),
LLVMIntrinsicFunctions.end());
} else {
// Add default LLVM function names
special_function_names.insert({"llvm.va_start"});
}
}

const std::string PhasarConfig::phasar_directory = std::string([]() {
std::string curr_path = boost::filesystem::current_path().string();
size_t i = curr_path.rfind("build", curr_path.length());
return curr_path.substr(0, i);
const std::string PhasarConfig::PhasarDir = std::string([]() {
std::string CurrPath = boost::filesystem::current_path().string();
size_t I = CurrPath.rfind("build", CurrPath.length());
return CurrPath.substr(0, I);
}());

PhasarConfig &PhasarConfig::getPhasarConfig() {
Expand Down
10 changes: 5 additions & 5 deletions lib/Controller/AnalysisController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ namespace std {

template <> struct hash<pair<const llvm::Value *, unsigned>> {
size_t operator()(const pair<const llvm::Value *, unsigned> &P) const {
std::hash<const llvm::Value *> hash_ptr;
std::hash<unsigned> hash_unsigned;
size_t hp = hash_ptr(P.first);
size_t hu = hash_unsigned(P.second);
return hp ^ (hu << 1);
std::hash<const llvm::Value *> HashPtr;
std::hash<unsigned> HashUnsigned;
size_t Hp = HashPtr(P.first);
size_t Hu = HashUnsigned(P.second);
return Hp ^ (Hu << 1);
}
};

Expand Down
82 changes: 41 additions & 41 deletions lib/DB/Hexastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,91 +19,91 @@ namespace psr {

Hexastore::Hexastore(string Filename) {
sqlite3_open(Filename.c_str(), &hs_internal_db);
const string query = INIT;
char *err;
sqlite3_exec(hs_internal_db, query.c_str(), callback, 0, &err);
if (err != NULL)
cout << err << "\n\n";
const string Query = INIT;
char *Err;
sqlite3_exec(hs_internal_db, Query.c_str(), callback, 0, &Err);
if (Err != NULL)
cout << Err << "\n\n";
}

Hexastore::~Hexastore() { sqlite3_close(hs_internal_db); }

int Hexastore::callback(void *NotUsed, int Argc, char **Argv,
char **AzColName) {
for (int i = 0; i < Argc; ++i) {
cout << AzColName[i] << " " << (Argv[i] ? Argv[i] : "NULL") << endl;
for (int Idx = 0; Idx < Argc; ++Idx) {
cout << AzColName[Idx] << " " << (Argv[Idx] ? Argv[Idx] : "NULL") << endl;
}
return 0;
}

void Hexastore::put(array<string, 3> Edge) {
doPut(SPO_INSERT, Edge);
doPut(SOP_INSERT, Edge);
doPut(PSO_INSERT, Edge);
doPut(POS_INSERT, Edge);
doPut(OSP_INSERT, Edge);
doPut(OPS_INSERT, Edge);
doPut(SPOInsert, Edge);
doPut(SOPInsert, Edge);
doPut(PSOInsert, Edge);
doPut(POSInsert, Edge);
doPut(OSPInsert, Edge);
doPut(OPSInsert, Edge);
}

void Hexastore::doPut(string Query, array<string, 3> Edge) {
string compiled_query = str(format(Query) % Edge[0] % Edge[1] % Edge[2]);
char *err;
sqlite3_exec(hs_internal_db, compiled_query.c_str(), callback, 0, &err);
if (err != NULL)
cout << err;
string CompiledQuery = str(format(Query) % Edge[0] % Edge[1] % Edge[2]);
char *Err;
sqlite3_exec(hs_internal_db, CompiledQuery.c_str(), callback, 0, &Err);
if (Err != NULL)
cout << Err;
}

vector<hs_result> Hexastore::get(array<string, 3> EdgeQuery,
size_t ResultSizeHint) {
vector<hs_result> result;
result.reserve(ResultSizeHint);
string querystring;
vector<hs_result> Result;
Result.reserve(ResultSizeHint);
string QueryString;
if (EdgeQuery[0] == "?") {
if (EdgeQuery[1] == "?") {
if (EdgeQuery[2] == "?") {
querystring = SEARCH_XXX;
QueryString = SearchXXX;
} else {
querystring = SEARCH_XXO;
QueryString = SearchXXO;
}
} else {
if (EdgeQuery[2] == "?") {
querystring = SEARCH_XPX;
QueryString = SearchXPX;
} else {
querystring = SEARCH_XPO;
QueryString = SearchXPO;
}
}
} else {
if (EdgeQuery[1] == "?") {
if (EdgeQuery[2] == "?") {
querystring = SEARCH_SXX;
QueryString = SearchSXX;
} else {
querystring = SEARCH_SXO;
QueryString = SearchSXO;
}
} else {
if (EdgeQuery[2] == "?") {
querystring = SEARCH_SPX;
QueryString = SearchSPX;
} else {
querystring = SEARCH_SPO;
QueryString = SearchSPO;
}
}
}
string compiled_query =
str(format(querystring) % EdgeQuery[0] % EdgeQuery[1] % EdgeQuery[2]);
string CompiledQuery =
str(format(QueryString) % EdgeQuery[0] % EdgeQuery[1] % EdgeQuery[2]);
// this lambda will collect all of our results, since it is called on every
// row of the result set
auto sqlite_cb_result_collector = [](void *CB, int Argc, char **Argv,
char **AzColName) {
vector<hs_result> *res = static_cast<vector<hs_result> *>(CB);
res->emplace_back(Argv[0], Argv[1], Argv[2]);
auto SqliteCBResultCollector = [](void *CB, int Argc, char **Argv,
char **AzColName) {
vector<hs_result> *Res = static_cast<vector<hs_result> *>(CB);
Res->emplace_back(Argv[0], Argv[1], Argv[2]);
return 0;
};
char *err;
sqlite3_exec(hs_internal_db, compiled_query.c_str(),
sqlite_cb_result_collector, &result, &err);
if (err != NULL) {
cout << err;
char *Err;
sqlite3_exec(hs_internal_db, CompiledQuery.c_str(), SqliteCBResultCollector,
&Result, &Err);
if (Err != NULL) {
cout << Err;
}
return result;
return Result;
}

} // namespace psr
Loading

0 comments on commit d5a4e9a

Please sign in to comment.