Commit 27d33dbd authored by rmrf's avatar rmrf
Browse files

Resolve many warnings, and coding guideline violations.

There seems to be some issue with editor formatting with
one of the authors of the code, which has made the code somewhat
difficult to read.

The first set of goals should be to remove all warnings, and while doing
that try to clean up some of the code formatting.
parent 09830e18
......@@ -17,10 +17,10 @@ add_library (libsystemc-clang
SystemCClang.cpp
FindNetlist.cpp
FindArgument.cpp
Automata.cpp
SuspensionAutomata.cpp
SCuitable/GlobalSuspensionAutomata.cpp
SCuitable/FindGPUMacro.cpp
Automata.cpp
SuspensionAutomata.cpp
# SCuitable/GlobalSuspensionAutomata.cpp
# SCuitable/FindGPUMacro.cpp
####################################
#From here the files are for the reflection database
####################################
......
......@@ -2,12 +2,15 @@
using namespace scpar;
FindArgument::FindArgument (Expr * e):_e (e)
{
FindArgument::FindArgument (Expr * e):_e (e) {
TraverseStmt (e);
}
FindArgument::~FindArgument() {
_e = nullptr;
}
bool FindArgument::VisitMemberExpr (MemberExpr * me)
{
......
......@@ -12,22 +12,18 @@ namespace scpar {
class FindArgument:public RecursiveASTVisitor < FindArgument > {
public:
FindArgument (Expr * ce
);
virtual bool VisitMemberExpr (MemberExpr * me
);
virtual bool VisitDeclRefExpr (DeclRefExpr * de
);
virtual bool VisitIntegerLiteral (IntegerLiteral * il
);
virtual bool VisitCXXBoolLiteralExpr (CXXBoolLiteralExpr * bl
);
FindArgument(Expr * ce);
virtual ~FindArgument();
virtual bool VisitMemberExpr (MemberExpr * me);
virtual bool VisitDeclRefExpr (DeclRefExpr * de);
virtual bool VisitIntegerLiteral (IntegerLiteral * il);
virtual bool VisitCXXBoolLiteralExpr (CXXBoolLiteralExpr * bl);
string getArgumentName (
);
private:
Expr * _e;
Expr * _e;
string _argumentName;
};
}
......
......@@ -3,16 +3,20 @@ using namespace scpar;
FindConstructor::FindConstructor(CXXRecordDecl * d, llvm::raw_ostream & os):_os(os),
_d(d),
_constructorStmt(NULL), pass(1)
{
_constructorStmt(nullptr),
pass(1) {
TraverseDecl(_d);
pass = 2;
TraverseStmt(_constructorStmt);
}
bool FindConstructor::VisitCXXMethodDecl(CXXMethodDecl * md)
{
FindConstructor::~FindConstructor() {
_d = nullptr;
_constructorStmt = nullptr;
}
bool FindConstructor::VisitCXXMethodDecl(CXXMethodDecl * md) {
switch (pass) {
case 1:
......@@ -41,13 +45,11 @@ bool FindConstructor::VisitCXXMethodDecl(CXXMethodDecl * md)
return true;
}
Stmt *FindConstructor::returnConstructorStmt()
{
Stmt *FindConstructor::returnConstructorStmt() {
return _constructorStmt;
}
void FindConstructor::dump()
{
void FindConstructor::dump() {
_os << "\n Module constructor statement dump ";
_constructorStmt->dump();
}
......@@ -17,6 +17,7 @@ namespace scpar {
public:
FindConstructor(CXXRecordDecl * d, llvm::raw_ostream & os);
virtual ~FindConstructor();
virtual bool VisitCXXMethodDecl(CXXMethodDecl * d);
......
......@@ -6,9 +6,9 @@ FindEntryFunctions::FindEntryFunctions (CXXRecordDecl * d, llvm::raw_ostream & o
_d (d),
_isEntryFunction (false),
_procType (NONE),
_entryCXXRecordDecl (NULL),
_entryMethodDecl (NULL),
_foundEntryDeclaration (false), _constructorStmt (NULL), pass (1)
_entryCXXRecordDecl (nullptr),
_entryMethodDecl (nullptr),
_foundEntryDeclaration (false), _constructorStmt (nullptr), pass (1)
{
/// Pass 1:
......@@ -33,6 +33,12 @@ _foundEntryDeclaration (false), _constructorStmt (NULL), pass (1)
}
FindEntryFunctions::~FindEntryFunctions() {
_entryCXXRecordDecl = nullptr;
_entryMethodDecl = nullptr;
_constructorStmt = nullptr;
}
bool FindEntryFunctions::VisitMemberExpr (MemberExpr * e)
{
//_os << "\tVisitMemberExpr";
......@@ -145,7 +151,7 @@ bool FindEntryFunctions::VisitCXXMethodDecl (CXXMethodDecl * md)
{
/// Check if name is the same as _entryFunction.
//_os <<"\n md name : " <<md->getNameAsString();
for (int i = 0; i < _entryFunctions.size (); i++)
for (size_t i = 0; i < _entryFunctions.size (); i++)
{
if (md->getNameAsString () == _entryFunctions.at (i)->getName ())
{
......@@ -190,10 +196,9 @@ void
_os << "\n ============== FindEntryFunction ===============\n";
_os << "\n:> Print Entry Function informtion for : " <<
_d->getNameAsString () << "\n";
for (unsigned int i = 0; i < _entryFunctions.size (); i++)
for (size_t i = 0; i < _entryFunctions.size (); i++)
{
EntryFunctionContainer *
ef = _entryFunctions[i];
EntryFunctionContainer * ef = _entryFunctions[i];
_os << "\n:> Entry function name: " << ef->getName () <<
", process type: ";
......
......@@ -13,45 +13,36 @@ namespace scpar {
using namespace clang;
using namespace std;
class FindEntryFunctions:public RecursiveASTVisitor < FindEntryFunctions > {
class FindEntryFunctions : public RecursiveASTVisitor < FindEntryFunctions > {
public:
/// Typedefs
typedef vector < EntryFunctionContainer * >entryFunctionVectorType;
typedef vector < EntryFunctionContainer * > entryFunctionVectorType;
typedef pair < string, vector < string > >entryFunctionLHSPairType;
typedef map < string, vector < string > >entryFunctionLHSMapType;
typedef pair < string, vector < string > > entryFunctionLHSPairType;
typedef map < string, vector < string > > entryFunctionLHSMapType;
FindEntryFunctions (CXXRecordDecl * d, llvm::raw_ostream & os
);
FindEntryFunctions(CXXRecordDecl * d, llvm::raw_ostream & os);
virtual ~FindEntryFunctions();
/// Virtual methods from RecursiveASTVisitor
virtual bool VisitStringLiteral (StringLiteral * l
);
virtual bool VisitCXXMethodDecl (CXXMethodDecl * d
);
virtual bool VisitMemberExpr (MemberExpr * e
);
virtual bool VisitStringLiteral (StringLiteral * l);
virtual bool VisitCXXMethodDecl (CXXMethodDecl * d);
virtual bool VisitMemberExpr (MemberExpr * e);
// Access Methods
CXXRecordDecl *getEntryCXXRecordDecl (
);
CXXMethodDecl *getEntryMethodDecl (
);
string getEntryName (
);
entryFunctionVectorType *getEntryFunctions (
);
vector < CXXMethodDecl * >getOtherFunctions (
);
CXXRecordDecl *getEntryCXXRecordDecl();
CXXMethodDecl *getEntryMethodDecl();
string getEntryName();
entryFunctionVectorType *getEntryFunctions();
vector < CXXMethodDecl * > getOtherFunctions();
void dump (
);
void dump ();
private:
CXXRecordDecl * _d;
llvm::raw_ostream & _os;
llvm::raw_ostream & _os;
CXXRecordDecl * _d;
bool _isEntryFunction;
PROCESS_TYPE _procType;
string _entryName;
......@@ -63,11 +54,11 @@ namespace scpar {
int pass;
entryFunctionVectorType _entryFunctions;
entryFunctionLHSMapType _entryFunctionLHSMap;
vector < CXXMethodDecl * >_otherFunctions;
vector < CXXMethodDecl * >_otherFunctions;
// Disallow constructor with no argument
FindEntryFunctions (llvm::raw_ostream & os
);
FindEntryFunctions (llvm::raw_ostream & os
);
};
}
......
......@@ -13,36 +13,29 @@ namespace scpar {
using namespace clang;
using namespace std;
class FindEvents:public RecursiveASTVisitor < FindEvents > {
class FindEvents : public RecursiveASTVisitor < FindEvents > {
public:
/// typedefs
typedef map < string, FieldDecl * >classEventMapType;
typedef pair < string, FieldDecl * >kvType;
FindEvents (CXXRecordDecl *, llvm::raw_ostream &
);
FindEvents (const FindEvents &
);
~FindEvents (
);
typedef map < string, FieldDecl * > classEventMapType;
typedef pair < string, FieldDecl * > kvType;
FindEvents(CXXRecordDecl *, llvm::raw_ostream &);
FindEvents(const FindEvents &);
virtual ~FindEvents();
/// RecursiveASTVisitor methods
virtual bool VisitFieldDecl (FieldDecl *
);
virtual bool VisitFieldDecl (FieldDecl *);
/// Access methods
classEventMapType getInClassEvents (
);
vector < string > getEventNames (
);
classEventMapType getInClassEvents();
vector < string > getEventNames();
/// Print methods
void dump (
);
void dump();
private:
llvm::raw_ostream & _os;
llvm::raw_ostream & _os;
classEventMapType _inClassEvents;
// reflectionDataStructure * _reflectionMap;
// reflectionDataStructure * _reflectionMap;
};
}
......
......@@ -8,6 +8,9 @@ _os
TraverseDecl(d);
}
FindGlobalEvents::~FindGlobalEvents() {
}
bool FindGlobalEvents::VisitVarDecl(VarDecl * vd)
{
QualType q = vd->getType();
......
......@@ -19,6 +19,7 @@ namespace scpar {
typedef pair < string, VarDecl * >kvType;
FindGlobalEvents(TranslationUnitDecl *, llvm::raw_ostream &);
~FindGlobalEvents();
virtual bool VisitVarDecl(VarDecl *);
......
......@@ -6,71 +6,62 @@
using namespace scpar;
string FindModule::getModuleName ()
{
string FindModule::getModuleName() {
return _moduleName;
}
FindModule::FindModule (CXXRecordDecl * d, llvm::raw_ostream & os):_decl (d), _os (os),
_isSystemCModule
(false)
{
if (d->hasDefinition () == true)
{
TraverseDecl (d);
FindModule::FindModule (CXXRecordDecl *d, llvm::raw_ostream &os):
_decl(d),
_os (os),
_isSystemCModule(false) {
if (d->hasDefinition () == true) {
TraverseDecl(d);
}
}
bool FindModule::VisitCXXRecordDecl (CXXRecordDecl * d)
{
if (_decl->getNumBases () <= 0)
{
bool FindModule::VisitCXXRecordDecl (CXXRecordDecl *d) {
if (_decl->getNumBases () <= 0) {
return true;
}
for (CXXRecordDecl::base_class_iterator bi = _decl->bases_begin (), be =
_decl->bases_end (); bi != be; ++bi)
{
QualType
q = bi->getType ();
string
baseName = q.getAsString ();
for (CXXRecordDecl::base_class_iterator bi = _decl->bases_begin(),
be = _decl->bases_end(); bi != be; ++bi) {
QualType q = bi->getType();
string baseName = q.getAsString();
if (baseName == "::sc_core::sc_module"
|| baseName == "sc_core::sc_module"
|| baseName == "class sc_core::sc_module")
{
|| baseName == "sc_core::sc_module"
|| baseName == "class sc_core::sc_module") {
_isSystemCModule = true;
IdentifierInfo *
info = _decl->getIdentifier ();
IdentifierInfo *info = _decl->getIdentifier();
if (info != NULL)
{
_moduleName = info->getNameStart ();
if (info != NULL) {
_moduleName = info->getNameStart();
}
}
}
if (_isSystemCModule == false)
{
if (_isSystemCModule == false) {
return true;
}
return false;
}
bool FindModule::isSystemCModule () const{
return
_isSystemCModule;
}
FindModule::~FindModule() {
_decl = nullptr;
}
// Member functions
bool FindModule::isSystemCModule() const{
return _isSystemCModule;
}
void FindModule::printSystemCModuleInformation ()
{
void FindModule::printSystemCModuleInformation() {
_os << "\n ============== FindModule ===============";
_os << "\n:> module name: " << _moduleName << ", CXXRecordDecl*: " <<
_decl << ", isSCModule: " << _isSystemCModule;
......
......@@ -10,18 +10,21 @@ namespace scpar {
using namespace clang;
using namespace std;
class FindModule:public RecursiveASTVisitor < FindModule > {
class FindModule: public RecursiveASTVisitor < FindModule > {
public:
FindModule (CXXRecordDecl *, llvm::raw_ostream &);
virtual bool VisitCXXRecordDecl (CXXRecordDecl * decl);
FindModule(CXXRecordDecl *, llvm::raw_ostream &);
virtual bool VisitCXXRecordDecl(CXXRecordDecl *decl);
void printSystemCModuleInformation ();
string getModuleName ();
virtual ~FindModule();
void printSystemCModuleInformation();
string getModuleName();
bool isSystemCModule () const;
bool isSystemCModule() const;
private:
CXXRecordDecl * _decl;
llvm::raw_ostream & _os;
CXXRecordDecl * _decl;
llvm::raw_ostream & _os;
bool _isSystemCModule;
string _moduleName;
......
......@@ -12,26 +12,22 @@ namespace scpar {
class FindNotify:public RecursiveASTVisitor < FindNotify > {
public:
typedef vector < CallExpr * >notifyCallListType;
typedef vector < CallExpr * > notifyCallListType;
FindNotify (CXXMethodDecl *, raw_ostream &);
~FindNotify ();
virtual bool VisitCallExpr (CallExpr * expr);
FindNotify(CXXMethodDecl *, raw_ostream &);
virtual ~FindNotify();
virtual bool VisitCallExpr (CallExpr *expr);
notifyCallListType getNotifyCallList ();
CXXMethodDecl * getEntryMethod();
void dump (
);
CXXMethodDecl * getEntryMethod();
void dump();
private:
CXXMethodDecl * _entryMethodDecl;
raw_ostream & _os;
CXXMethodDecl * _entryMethodDecl;
raw_ostream & _os;
CallExpr *_notifyCall;
notifyCallListType _notifyCalls;
};
}
#endif
......@@ -18,25 +18,17 @@ namespace scpar {
typedef pair < string, FindTemplateTypes * >kvType;
FindPorts (CXXRecordDecl *, llvm::raw_ostream &
);
~FindPorts (
);
virtual bool VisitFieldDecl (FieldDecl *
);
portType getInputPorts (
);
portType getOutputPorts (
);
portType getInputOutputPorts (
);
void dump (
);
FindPorts(CXXRecordDecl *, llvm::raw_ostream & );
virtual ~FindPorts();
virtual bool VisitFieldDecl (FieldDecl *);
portType getInputPorts();
portType getOutputPorts();
portType getInputOutputPorts();
void dump ();
private:
llvm::raw_ostream & _os;
llvm::raw_ostream & _os;
portType _inPorts;
portType _outPorts;
portType _inoutPorts;
......
......@@ -2,14 +2,17 @@
using namespace scpar;
FindSCMain::FindSCMain (TranslationUnitDecl * tuDecl, llvm::raw_ostream & os):
_os (os), _scmainFunctionDecl (NULL)
{
_os (os),
_scmainFunctionDecl(nullptr) {
assert (!(tuDecl == NULL));
TraverseDecl (tuDecl);
}
bool FindSCMain::VisitFunctionDecl (FunctionDecl * fdecl)
{
FindSCMain::~FindSCMain() {
_scmainFunctionDecl = nullptr;
}
bool FindSCMain::VisitFunctionDecl (FunctionDecl * fdecl) {
//_os << "Print the name: " << fdecl->getNameInfo().getAsString() << "has body: " << fdecl->hasBody() << "\n";
// _os << "Is first declaration: " << fdecl->isFirstDeclaration() << "\n";
......@@ -32,16 +35,12 @@ bool FindSCMain::VisitFunctionDecl (FunctionDecl * fdecl)
return true;
}
FunctionDecl *
FindSCMain::getSCMainFunctionDecl (
)
{
FunctionDecl *FindSCMain::getSCMainFunctionDecl() {
assert (!(_scmainFunctionDecl == NULL));
return _scmainFunctionDecl;
}
bool FindSCMain::isSCMainFound ()
{
bool FindSCMain::isSCMainFound () {
return (_scmainFunctionDecl != NULL);
}
......@@ -10,18 +10,15 @@ namespace scpar {
using namespace clang;
class FindSCMain:public RecursiveASTVisitor < FindSCMain > {
public:
FindSCMain (TranslationUnitDecl *, llvm::raw_ostream &
);
FindSCMain (TranslationUnitDecl *, llvm::raw_ostream &);
virtual bool VisitFunctionDecl (FunctionDecl * decl
);
virtual ~FindSCMain();
virtual bool VisitFunctionDecl (FunctionDecl * decl);
FunctionDecl *getSCMainFunctionDecl (
);
bool isSCMainFound (
);
FunctionDecl *getSCMainFunctionDecl();
bool isSCMainFound ();
private:
llvm::raw_ostream & _os;
llvm::raw_ostream & _os;
FunctionDecl *_scmainFunctionDecl;
};
......
......@@ -2,35 +2,29 @@
#include "FindTemplateTypes.h"
using namespace scpar;
FindSensitivity::FindSensitivity (Stmt * s, llvm::raw_ostream & os):_os (os),
_foundSensitiveNode
(false)
{
FindSensitivity::FindSensitivity (Stmt * s, llvm::raw_ostream & os):
_os (os),
_foundSensitiveNode(false) {
/// Pass 1
/// Find the ASTNode CXXOperatorCallExpr
TraverseStmt (s);
TraverseStmt(s);
}
bool FindSensitivity::VisitCXXOperatorCallExpr (CXXOperatorCallExpr * e)
{
bool FindSensitivity::VisitCXXOperatorCallExpr (CXXOperatorCallExpr *e) {
return true;
}
bool FindSensitivity::VisitMemberExpr (MemberExpr * e)
{
bool FindSensitivity::VisitMemberExpr (MemberExpr *e) {
QualType
q = e->getType ();
QualType q = e->getType ();
if (!_foundSensitiveNode)
{
string
memberName = e->getMemberDecl ()->getNameAsString ();
string memberName = e->getMemberDecl ()->getNameAsString ();
if ((q.getAsString () != "class sc_core::sc_sensitive")
|| (memberName != "sensitive"))
{
|| (memberName != "sensitive")) {