本文整理汇总了C++中Sg_File_Info类的典型用法代码示例。如果您正苦于以下问题:C++ Sg_File_Info类的具体用法?C++ Sg_File_Info怎么用?C++ Sg_File_Info使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sg_File_Info类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isSgLocatedNode
AST_Graph::nodePartOfGraph::result_type
AST_Graph::nodePartOfGraph::operator()(pair<SgNode*,std::string>& x)
{
result_type functionalReturn;
functionalReturn.addToGraph = true;
functionalReturn.DOTOptions = "";
functionalReturn.DOTLabel = "";
SgLocatedNode* locatedNode = isSgLocatedNode(x.first);
if(locatedNode!=NULL)
{
Sg_File_Info* fileInfo = locatedNode->get_file_info();
std::string filename(Rose::utility_stripPathFromFileName(fileInfo->get_filename()));
if (filename.find("rose_edg_required_macros_and_functions.h") != std::string::npos)
{
functionalReturn.addToGraph = false;
}
if (fileInfo->isCompilerGenerated()==true)
{
// std::cout << "Is compiler generated\n";
functionalReturn.addToGraph = false;
}
}
return functionalReturn;
}
示例2: isSgInitializedName
void StaticConstructorTraversal::visit(SgNode *n) {
// Get declared variables
SgInitializedName *vName = isSgInitializedName(n);
if (vName && !isAcreIgnore(vName->get_declaration())) {
Sg_File_Info *fInfo = vName->get_file_info();
SgScopeStatement *scope = vName->get_scope();
// Find global variables (variables in namespaces count, e.g. std)
if (!fInfo->isCompilerGenerated() && (isSgGlobal(scope) || isSgNamespaceDefinitionStatement(scope))) {
// Walk typedefs until reach pointer to base type
SgTypedefType *tdType = isSgTypedefType(vName->get_type());
while (tdType && isSgTypedefType(tdType->get_base_type()))
tdType = isSgTypedefType(tdType->get_base_type());
// Determine if type is a class (i.e. type with a constructor)
SgClassType *cType = isSgClassType(vName->get_type());
if (tdType)
cType = isSgClassType(tdType->get_base_type());
// Output location of globals with a static constructor
if (cType) {
*out << "Static Constructor Violation: " << fInfo->get_filename() << " @ " << fInfo->get_line() << "\n";
}
}
}
}
示例3: emit_node_mesg
/** Show an error message about a node. */
static void
emit_node_mesg(SgNode *node, const std::string &mesg="")
{
Sg_File_Info *loc = isSgLocatedNode(node) ? isSgLocatedNode(node)->get_startOfConstruct() : NULL;
std::string filename = loc ? loc->get_filenameString() : "__UNKNOWN_FILE__";
int lno = loc ? loc->get_line() : 0;
int cno = loc ? loc->get_col() : 0;
std::cerr <<filename <<":" <<lno <<"." <<cno <<": " <<(mesg.empty() ? "error" : mesg) <<"\n";
}
示例4:
DOTInheritedAttribute
AstDOTGeneration::evaluateInheritedAttribute(SgNode* node, DOTInheritedAttribute ia)
{
// I think this may no longer be required, but I will leave it in place for now
visitedNodes.insert(node);
// printf ("AstDOTGeneration::evaluateInheritedAttribute(): node = %s \n",node->class_name().c_str());
// We might not want to increment the trace position information for
// the IR nodes from rose_edg_required_macros_and_functions.h
// ia.tdbuTracePos = tdbuTrace++;
// ia.tdTracePos = tdTrace++;
// DQ (5/3/2006)
// We put macros and functions required for GNU compatability in the file:
// rose_edg_required_macros_and_functions.h
// and we want to avoid generating nodes for these within visualizations of the AST.
// Once EDG supports these functions (we have collected the onese missed by EDG here)
// this file will not be required. We could filter on declaration first to avoid
// lots of string comparision. Or use a static pointer to save the first fileInfo
// from "rose_edg_required_macros_and_functions.h" and then use the
// Sg_File_Info::sameFile() function (this reduces to an integer comparision internally).
Sg_File_Info* fileInfo = node->get_file_info();
if (fileInfo != NULL)
{
// Build factored versions of the rather numerous tests (we are now not
// able to rely on short-circuit evaluation which makes the code easier
// to debug using valgrind).
bool isCompilerGeneratedOrPartOfTransformation = fileInfo->isCompilerGenerated();
// DQ (5/3/2006): All constructs from the rose_edg_required_macros_and_functions.h
// file are marked as compiler generated. These are declarations required for GNU
// compatability and we would like to have them be ignored because they should be
// considered builtin and not explicitly represented. In a sense this file is special.
// Not that if we traverse the AST without constraint then we traverse these IR nodes.
if (isCompilerGeneratedOrPartOfTransformation == true)
{
std::string targetFileName = "rose_edg_required_macros_and_functions.h";
std::string rawFileName = node->get_file_info()->get_raw_filename();
std::string filenameWithoutPath = StringUtility::stripPathFromFileName(rawFileName);
if (filenameWithoutPath == targetFileName)
ia.skipSubTree = true;
}
}
// We might not want to increment the trace position information for
// the IR nodes from rose_edg_required_macros_and_functions.h
if (ia.skipSubTree == false)
{
ia.tdbuTracePos = tdbuTrace++;
ia.tdTracePos = tdTrace++;
}
return ia;
}
示例5:
std::ostream &operator<<(std::ostream &os, SgNode *node)
{
os << node->class_name();
if (SgLocatedNode *ln = isSgLocatedNode(node))
{
Sg_File_Info *fi = ln->get_file_info();
os << "(" << fi->get_filename() << ":" << fi->get_line() << ":" << fi->get_col() << ") ";
}
os << node->unparseToCompleteString();
return os;
}
示例6: printPosition
// debugging function of a node location
string printPosition(SgNode *node) {
ostringstream out;
out << "(";
Sg_File_Info *startinf = node->get_startOfConstruct();
Sg_File_Info *endinf = node->get_endOfConstruct();
if(startinf) out << startinf->get_filename() << ":" << startinf->get_line();
if( endinf) {
out << "- " << startinf->get_filename() << ":" << startinf->get_line();
}
out << ") ";
return out.str();
}
示例7: returnFirstOrLastStatementFromCurrentFile
SgStatement*
returnFirstOrLastStatementFromCurrentFile (
SgStatement* target,
const SgStatementPtrList & statementList,
bool findFirstStatement )
{
// printf ("Inside of returnFirstOrLastStatement \n");
// Find the first statement from the current file being processed
SgStatement* statement = NULL;
if (findFirstStatement)
{
SgStatementPtrList::const_iterator statementIterator = statementList.begin();
while (statementIterator != statementList.end())
{
statement = *statementIterator;
ROSE_ASSERT (statement != NULL);
Sg_File_Info* fileInfo = statement->get_file_info();
ROSE_ASSERT (fileInfo != NULL);
string filename = fileInfo->get_filename();
if (filename == ROSE::getFileNameByTraversalBackToFileNode(target))
{
// printf ("Found the first statement in this file = %s \n",filename.c_str());
// printf ("First statement = %s \n",statement->unparseToCompleteString().c_str());
break;
}
statementIterator++;
}
}
else
{
SgStatementPtrList::const_reverse_iterator statementIterator = statementList.rbegin();
while (statementIterator != statementList.rend())
{
statement = *statementIterator;
ROSE_ASSERT (statement != NULL);
Sg_File_Info* fileInfo = statement->get_file_info();
ROSE_ASSERT (fileInfo != NULL);
string filename = fileInfo->get_filename();
if (filename == ROSE::getFileNameByTraversalBackToFileNode(target))
{
// printf ("Found the last statement in this file = %s \n",filename.c_str());
// printf ("First statement = %s \n",statement->unparseToCompleteString().c_str());
break;
}
statementIterator++;
}
}
ROSE_ASSERT (statement != NULL);
return statement;
}
示例8: main
int main(int argc, char * argv[]) {
SgProject* project = frontend(argc,argv);
std::ofstream report_file;
report_file.open(((*project)[0]->getFileName() + ".report").c_str());
if (report_file.is_open()) {
PolyhedralModelisation poly_model;
poly_model.traverse(project);
std::set<PolyhedralElement *> collection;
poly_model.collectPolyhedralElement(collection, true, false, true, true, false); // default arguments...
std::set<PolyhedralElement *>::iterator it;
for (it = collection.begin(); it != collection.end(); it++) {
const PolyhedralControl * control = dynamic_cast<const PolyhedralControl *>(*it);
if (control == NULL) continue;
SgFunctionDefinition * func_def = isSgFunctionDefinition(control->associated_node);
if (func_def == NULL) continue;
SgFunctionDeclaration * func_decl = isSgFunctionDeclaration(func_def->get_declaration());
if (func_decl == NULL) continue;
if (!func_decl->get_functionModifier().isCudaKernel()) continue;
Sg_File_Info * fi = func_def->get_startOfConstruct();
report_file << "Found: " << func_decl->get_name() << " at " << fi->get_filenameString() << ":" << fi->get_line() << std::endl;
report_file << "\tStructure:" << std::endl;
(*it)->print(report_file, "\t\t");
report_file << std::endl;
report_file << "\tAccesses:" << std::endl;
std::set<Access *> accesses;
(*it)->collectAccess(accesses);
std::set<Access *>::iterator it_access;
for (it_access = accesses.begin(); it_access != accesses.end(); it_access++) {
(*it_access)->print(report_file, "\t\t");
}
report_file << std::endl;
report_file << std::endl;
}
}
else
std::cerr << "Cannot open " << (*project)[0]->getFileName() << ".report to save the analysis report..." << std::endl;
return 0;
}
示例9: isSgLocatedNode
//The argument to the function is
filterOnNodes::result_type
filterOnNodes::operator()(filterOnNodes::argument_type x) const
{
AST_Graph::FunctionalReturnType returnValue;
//Determine if the node is to be added to the graph. true=yes
returnValue.addToGraph = true;
//set colors etc. for the graph Node
returnValue.DOTOptions = "shape=polygon,regular=0,URL=\"\\N\",tooltip=\"more info at\\N\",sides=4,peripheries=1,color=\"Blue\",fillcolor=green,fontname=\"7x13bold\",fontcolor=black,style=filled";
if( isSgProject(x.first) != NULL )
returnValue.DOTOptions = "shape=ellipse,regular=0,URL=\"\\N\",tooltip=\"more info at\\N\",sides=4,peripheries=1,color=\"Blue\",fillcolor=yellow,fontname=\"7x13bold\",fontcolor=black,style=filled";
//Filter out SgSymbols from the graph
if ( isSgSymbol(x.first) != NULL )
returnValue.addToGraph = false;
if ( isSgType(x.first) != NULL )
returnValue.addToGraph = false;
//Filter out compiler generated nodes
SgLocatedNode* locatedNode = isSgLocatedNode(x.first);
if ( locatedNode != NULL )
{
Sg_File_Info* fileInfo = locatedNode->get_file_info();
std::string filename(Rose::utility_stripPathFromFileName(fileInfo->get_filename()));
if (filename.find("rose_edg_macros_and_functions_required_for_gnu.h") != std::string::npos)
{
returnValue.addToGraph = false;
}
if (fileInfo->isCompilerGenerated()==true)
{
// std::cout << "Is compiler generated\n";
returnValue.addToGraph = false;
}
}
return returnValue;
}
示例10: clear
void RoseFileComboBox::setProject(SgProject * proj)
{
clear(); //delete all combobox entries
project=proj;
if(project==NULL)
return;
//Add Entries to the combobox
for(int i=0; i < project->numberOfFiles(); i++)
{
Sg_File_Info * fi = (*project)[i]->get_file_info();
QFileInfo qFi;
QVariant fileId (fi->get_file_id());
qFi.setFile(fi->get_filenameString().c_str());
if(dispOnlyFilename)
addItem(qFi.fileName(),-1);
else
addItem(qFi.filePath(),-1);
std::map< int, std::string > map = fi->get_fileidtoname_map();
typedef std::map<int,std::string>::iterator MapIter;
for( MapIter iter = map.begin(); iter != map.end(); ++iter )
{
qFi.setFile( iter->second.c_str());
QString dispString;
if(dispOnlyFilename)
dispString=qFi.fileName();
else
dispString=qFi.filePath();
addItem(QString(" ")+dispString,iter->first);
}
}
}
示例11:
void
createMap::printNodeToTokenMap()
{
#ifndef USE_ROSE
#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
// If we are using ROSE to compile ROSE source code then the Wave support is not present.
std::cout << "BEGIN printing node to token map" << std::endl;
std::cout << "SIZE: " << nodeToTokenMap.size() << std::endl;
for(map<SgNode*,std::pair<int,int> >::iterator map_it = nodeToTokenMap.begin();
map_it != nodeToTokenMap.end(); ++map_it ){
Sg_File_Info* fileInfo = map_it->first->get_file_info();
token_type currentBeginToken = tokenStream[map_it->second.first];
token_type currentEndToken = tokenStream[map_it->second.second];
string nodeFilename = fileInfo->get_filenameString();
int nodeLine = fileInfo->get_line();
int nodeColumn = fileInfo->get_col();
std::cout << "Position of node is filename " << nodeFilename << " line "
<< nodeLine << " column " << nodeColumn << std::endl;
string beginTokenFilename = currentBeginToken.get_position().get_file().c_str();
int beginTokenLine = currentBeginToken.get_position().get_line();
int beginTokenColumn = currentBeginToken.get_position().get_column();
std::cout << "Begin position of token is filename " << beginTokenFilename << " line "
<< beginTokenLine << " column " << beginTokenColumn << std::endl;
string endTokenFilename = currentEndToken.get_position().get_file().c_str();
int endTokenLine = currentEndToken.get_position().get_line();
int endTokenColumn = currentEndToken.get_position().get_column();
std::cout << "End position of token is filename " << endTokenFilename << " line "
<< endTokenLine << " column " << endTokenColumn << std::endl;
std::cout << std::endl;
};
std::cout << "END printing node to token map" << std::endl;
#endif
#endif
}
示例12: visit
void loopTraversal::visit(SgNode *node) {
Sg_File_Info *info = NULL;
SgNode *parent = NULL;
info = node->get_file_info();
/* Find code fragment for bottlenecks type 'loop' in C */
if ((isSgForStatement(node)) &&
(info->get_line() == globals.linenumber)) {
/* Found a C loop on the exact line number */
printf("found a loop on (%s:%d) looking for the parent loop\n",
info->get_filename(), info->get_line());
parent = node->get_parent();
info = parent->get_file_info();
/* It is a basic block. Who is this basic block's parent? */
if (NULL != isSgBasicBlock(parent)) {
parent = parent->get_parent();
}
/* Is it a for/do/while? */
if (isSgForStatement(parent)) {
/* The parent is a loop */
printf("parent loop found on (%s:%d)\n", info->get_filename(),
info->get_line());
/* Do the interchange */
rc = loopInterchange(isSgForStatement(parent), 2, 1);
}
}
}
示例13: switch
FindSmallestStatementsInh
FindSmallestStatements::evaluateInheritedAttribute(SgNode* n, FindSmallestStatementsInh inheritedAttribute)
{
//If the node should be consired as a topmost node
if(inheritedAttribute.inSubtreeOfStatement == false && isSgLocatedNode(n))
{
Sg_File_Info* thisNodePos = n->get_file_info();
#if 0
std::string pos;
thisNodePos->display(pos);
std::cerr << "************************\n";
std::cerr << "NodePosDisp " << n->class_name() << pos << std::endl;
std::cerr << "************************\n";
#endif
//If positions are the same add to list of statements
switch(n->variantT())
{
case V_SgExprStatement:
std::cout << "Skipping this node" << std::endl;
break;
default:
{
if( macroCallInfo->get_file_id() == thisNodePos->get_file_id() &&
macroCallInfo->get_line() == thisNodePos->get_line() &&
macroCallInfo->get_col() == thisNodePos->get_col()
)
{
if( find_all == false )
inheritedAttribute.inSubtreeOfStatement = true;
matchingCalls.push_back(n);
}
break;
}
}
}
return inheritedAttribute;
}
示例14: RegisterItem
static void RegisterItem(SgFunctionDeclaration *funcDecl, SgBasicBlock *funcBody,
SgStatement *stmt, const char *registerFuncName,
SgType *varType, SgVariableDeclaration *var,
bool beforeStmt)
{
Sg_File_Info *fileInfo ;
if (!isSgForStatement(stmt))
{
fileInfo = stmt->get_file_info() ;
}
else
{
fileInfo = (beforeStmt ?
stmt->get_startOfConstruct() : stmt->get_endOfConstruct()) ;
}
SgFunctionCallExp *registerCall = buildFunctionCallExp(
SgName(registerFuncName),
varType,
buildExprListExp(
buildStringVal(fileInfo->get_filenameString()),
buildStringVal(funcDecl->get_name().str()),
buildIntVal(fileInfo->get_line())
),
funcBody
) ;
SgExprStatement *varAssign =
buildExprStatement(buildAssignOp(buildVarRefExp(var), registerCall)) ;
SgExpression *varEqualZero =
buildEqualityOp(buildVarRefExp(var), buildIntVal(0)) ;
SgIfStmt *statement = buildIfStmt( varEqualZero, varAssign, NULL ) ;
stmt->get_scope()->insert_statement(stmt, statement, beforeStmt) ;
return ;
}
示例15:
string
AstPDFGeneration_private::get_bookmark_name(SgNode* node)
{
string nodefilename="--not initialized--";
string bookmarktext;
{
ostringstream ss;
ss << node->sage_class_name() << " ";
SgLocatedNode* sgLocNode = dynamic_cast<SgLocatedNode*> (node);
if(sgLocNode)
{
Sg_File_Info* fi = sgLocNode->get_file_info();
if(fi)
{
// ss << "(" << fi->get_line() << "," << fi->get_col() << ") in \"" << fi->get_filename() << "\"";
// nodefilename=string(fi->get_filename());
#if 1
// if (fi->isCompilerGenerated())
// ss << " compilerGenerated ";
if (fi->isTransformation())
ss << " transformation " ;
if (fi->isOutputInCodeGeneration())
ss<< " unparsable ";
ss << "(" << fi->get_line() << "," << fi->get_col() << ") in \"" << fi->get_filename() << "\"";
#endif
nodefilename=string(fi->get_filename());
}
else
{
ss << "(BUG)";
}
}
else
{
ss << ""; // provide no explicit info about the lack of file_info
}
bookmarktext=ss.str();
}
return bookmarktext;
}