本文整理汇总了C++中SgInitializedName::get_file_info方法的典型用法代码示例。如果您正苦于以下问题:C++ SgInitializedName::get_file_info方法的具体用法?C++ SgInitializedName::get_file_info怎么用?C++ SgInitializedName::get_file_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgInitializedName
的用法示例。
在下文中一共展示了SgInitializedName::get_file_info方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
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";
}
}
}
}
示例2: if
// Count the load and store bytes for the
// I think we can only return expressions to calculate the value, not the actual values,
// since sizeof(type) is machine dependent
// Consider both scalar and array accesses by default. Consider both floating point and integer types by default.
// return a pair of expressions:
// load_byte_exp, and
// store_byte_exp
// Algorithm:
// 1. Call side effect analysis to find read/write variables, some reference may trigger both read and write accesses
// Accesses to the same array/scalar variable are grouped into one read (or write) access
// e.g. array[i][j], array[i][j+1], array[i][j-1], etc are counted a single access
// 2. Group accesses based on the types (same type? increment the same counter to shorten expression length)
// 4. Iterate on the results to generate expression like 2*sizeof(float) + 5* sizeof(double)
// As an approximate, we use simple analysis here assuming no function calls.
std::pair <SgExpression*, SgExpression*> CountLoadStoreBytes (SgLocatedNode* input, bool includeScalars /* = true */, bool includeIntType /* = true */)
{
std::pair <SgExpression*, SgExpression*> result;
assert (input != NULL);
// the input is essentially the loop body, a scope statement
SgScopeStatement* scope = isSgScopeStatement(input);
// We need to record the associated loop info.
//SgStatement* loop= NULL;
SgForStatement* forloop = isSgForStatement(scope->get_scope());
SgFortranDo* doloop = isSgFortranDo(scope->get_scope());
if (forloop)
{
//loop = forloop;
}
else if (doloop)
{
//loop = doloop;
}
else
{
cerr<<"Error in CountLoadStoreBytes (): input is not loop body type:"<< input->class_name()<<endl;
assert(false);
}
//Plan A: use and extend Qing's side effect analysis
std::set<SgInitializedName*> readVars;
std::set<SgInitializedName*> writeVars;
bool success = SageInterface::collectReadWriteVariables (isSgStatement(input), readVars, writeVars);
if (success!= true)
{
cout<<"Warning: CountLoadStoreBytes(): failed to collect load/store, mostly due to existence of function calls inside of loop body @ "<<input->get_file_info()->get_line()<<endl;
}
std::set<SgInitializedName*>::iterator it;
if (debug)
cout<<"debug: found read variables (SgInitializedName) count = "<<readVars.size()<<endl;
for (it=readVars.begin(); it!=readVars.end(); it++)
{
SgInitializedName* iname = (*it);
if (debug)
cout<<scalar_or_array (iname->get_type()) <<" "<<iname->get_name()<<"@"<<iname->get_file_info()->get_line()<<endl;
}
if (!includeScalars )
readVars = filterVariables (readVars);
if (debug)
cout<<"debug: found write variables (SgInitializedName) count = "<<writeVars.size()<<endl;
for (it=writeVars.begin(); it!=writeVars.end(); it++)
{
SgInitializedName* iname = (*it);
if (debug)
cout<<scalar_or_array(iname->get_type()) <<" "<<iname->get_name()<<"@"<<iname->get_file_info()->get_line()<<endl;
}
if (!includeScalars )
writeVars = filterVariables (writeVars);
result.first = calculateBytes (readVars, scope, true);
result.second = calculateBytes (writeVars, scope, false);
return result;
}
示例3: isSgVariableDeclaration
void
FixupTemplateArguments::visit ( SgNode* node )
{
ROSE_ASSERT(node != NULL);
SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(node);
if (variableDeclaration != NULL)
{
// Check the type of the variable declaration, and any template arguments if it is a template type with template arguments.
// SgType* type = variableDeclaration->get_type();
// ROSE_ASSERT(type != NULL);
SgInitializedName* initializedName = SageInterface::getFirstInitializedName(variableDeclaration);
ROSE_ASSERT(initializedName != NULL);
SgType* type = initializedName->get_type();
ROSE_ASSERT(type != NULL);
#if 0
printf ("\n**************************************************************************** \n");
printf ("FixupTemplateArguments::visit(): variableDeclaration = %p = %s initializedName = %s \n",variableDeclaration,variableDeclaration->class_name().c_str(),initializedName->get_name().str());
printf (" --- type = %p = %s \n",type,type->class_name().c_str());
string filename = initializedName->get_file_info()->get_filename();
int linenumber = initializedName->get_file_info()->get_line();
printf (" --- filename = %s line = %d \n",filename.c_str(),linenumber);
#endif
SgScopeStatement* targetScope = variableDeclaration->get_scope();
ROSE_ASSERT(targetScope != NULL);
#if 0
printf ("In FixupTemplateArguments::visit(): targetScope for variableDeclaration = %p = %s \n",targetScope,targetScope->class_name().c_str());
#endif
// DQ (2/16/2017): Don't process code in template instantiations.
SgTemplateInstantiationDefn* templateInstantiationDefn = isSgTemplateInstantiationDefn(targetScope);
SgFunctionDeclaration* functionDeclaration = TransformationSupport::getFunctionDeclaration(targetScope);
SgTemplateInstantiationFunctionDecl* templateInstantiationFunctionDec = isSgTemplateInstantiationFunctionDecl(functionDeclaration);
SgTemplateInstantiationMemberFunctionDecl* templateInstantiationMemberFunctionDec = isSgTemplateInstantiationMemberFunctionDecl(functionDeclaration);
// if (templateInstantiationDefn == NULL)
if (templateInstantiationDefn == NULL && templateInstantiationFunctionDec == NULL && templateInstantiationMemberFunctionDec == NULL)
{
#if 1
// DQ (2/15/2017): When this is run, we cause transformations that cause ROSE to have an infinte loop.
// Since this is a second (redundant) invocaion, we likely should just not run this. But it is not
// clear if this truely fixes the problem that I am seeing.
bool result = contains_private_type(type,targetScope);
// DQ (3/25/2017): Added a trivial use to eliminate Clang warning about the return value not being used.
// But it might be that we should not run the function, however this is a complex subject from last month
// that I don't wish to revisit at the moment while being focused om eliminating warnings from Clang.
ROSE_ASSERT(result == true || result == false);
#endif
#if 0
if (result == true)
{
printf ("******** contains private type: variableDeclaration = %p = %s initializedName = %s \n",variableDeclaration,variableDeclaration->class_name().c_str(),initializedName->get_name().str());
}
#endif
}
#if 0
printf ("DONE: FixupTemplateArguments::visit(): variableDeclaration = %p = %s initializedName = %s \n",variableDeclaration,variableDeclaration->class_name().c_str(),initializedName->get_name().str());
#endif
#if 0
printf ("Exiting as a test! \n");
ROSE_ASSERT(false);
#endif
}
}
示例4: isSgFile
void
visitorTraversal::visit(SgNode* n)
{
SgFile* file = isSgFile(n);
if (file != NULL)
{
filename = file->get_sourceFileNameWithPath();
}
// On each statement node and output it's position.
SgStatement* statement = isSgStatement(n);
bool outputStatement = (statement != NULL) ? true : false;
// Check for the statement to exist in the input source file
outputStatement = outputStatement && (statement->get_file_info()->get_filenameString() == filename);
// Skip SgGlobal IR nodes
outputStatement = outputStatement && (isSgGlobal(statement) == NULL);
if (outputStatement == true)
{
AttachedPreprocessingInfoType* comments = statement->getAttachedPreprocessingInfo();
if (comments != NULL)
{
// printf ("Found attached comments (to IR node at %p of type: %s): \n",statement,statement->class_name().c_str());
// int counter = 0;
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin(); i != comments->end(); i++)
{
#if 0
printf (" Attached Comment #%d in file %s (relativePosition=%s): classification %s :\n%s\n",
counter++,(*i)->get_file_info()->get_filenameString().c_str(),
((*i)->getRelativePosition() == PreprocessingInfo::before) ? "before" : "after",
PreprocessingInfo::directiveTypeName((*i)->getTypeOfDirective()).c_str(),
(*i)->getString().c_str());
#endif
// Mark comments and CPP directives a few different colors.
int startingLineNumber = (*i)->get_file_info()->get_line();
int startingColumnNumber = (*i)->get_file_info()->get_col();
// Subtract 1 from number of lines to avoid over counting the current line.
int endingLineNumber = startingLineNumber + ((*i)->getNumberOfLines() - 1);
int endingColumnNumber = (*i)->getColumnNumberOfEndOfString();
string color = directiveTypeColor((*i)->getTypeOfDirective());
#if 0
printf ("%d,%d,%s,%d,%d\n",startingLineNumber,startingColumnNumber,color.c_str(),endingLineNumber,endingColumnNumber);
#endif
dataFile << startingLineNumber << "," << startingColumnNumber << "," << color << "," << endingLineNumber << "," << endingColumnNumber << endl;
}
}
else
{
// printf ("No attached comments (at %p of type: %s): \n",statement,statement->sage_class_name());
}
ROSE_ASSERT(statement->get_startOfConstruct() != NULL);
int startingLineNumber = statement->get_startOfConstruct()->get_line();
int startingColumnNumber = statement->get_startOfConstruct()->get_col();
if (statement->get_endOfConstruct() == NULL)
{
printf ("Error: statement->get_endOfConstruct() == NULL (statement = %p = %s) \n",statement,statement->class_name().c_str());
}
ROSE_ASSERT(statement->get_endOfConstruct() != NULL);
int endingLineNumber = statement->get_endOfConstruct()->get_line();
int endingColumnNumber = statement->get_endOfConstruct()->get_col();
// Catch errors (likely compiler generate IR node or NULL file)
if (endingLineNumber == 0)
{
endingLineNumber = startingLineNumber;
endingColumnNumber = startingColumnNumber;
}
#if 0
// Mark all statements blue
string color = "blue";
if (isSgScopeStatement(statement) != NULL)
color = "red";
#else
string color = nodeColor(statement);
#endif
#if 0
printf ("%d,%d,%s,%d,%d %s = %p \n",startingLineNumber,startingColumnNumber,color.c_str(),endingLineNumber,endingColumnNumber,statement->class_name().c_str(),statement);
#endif
dataFile << startingLineNumber << "," << startingColumnNumber << "," << color << "," << endingLineNumber << "," << endingColumnNumber << endl;
}
// On each statement node and output it's position.
SgExpression* expression = isSgExpression(n);
bool outputExpression = (expression != NULL) ? true : false;
// Check for the statement to exist in the input source file
outputExpression = outputExpression && (expression->get_file_info()->get_filenameString() == filename);
//.........这里部分代码省略.........
示例5: Detection_InheritedAttribute
Detection_InheritedAttribute
DetectionTraversal::evaluateInheritedAttribute (SgNode* astNode, Detection_InheritedAttribute inheritedAttribute )
{
#if 0
printf ("In DetectionTraversal::evaluateInheritedAttribute(): astNode = %p = %s \n",astNode,astNode->class_name().c_str());
#endif
// DQ (2/3/2016): Recognize IR nodes that are representative of target DSL abstractions.
bool foundTargetDslAbstraction = DSL_Support::isDslAbstraction(astNode);
#if 1
printf ("In DetectionTraversal::evaluateInheritedAttribute(): astNode = %p = %s: foundTargetDslAbstraction = %s \n",astNode,astNode->class_name().c_str(),foundTargetDslAbstraction ? "true" : "false");
#endif
#if 0
// OLD CODE (represented by DSL_Support::isDslAbstraction() function).
// Detection of stencil declaration and stencil operator.
// Where the stencil specification is using std::vectors as parameters to the constructor, we have to first
// find the stencil declaration and read the associated SgVarRefExp to get the variable names used.
// Then a finite state machine can be constructed for each of the input variables so that we can
// interpret the state when the stencil operator is constructed.
SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(astNode);
if (variableDeclaration != NULL)
{
// Get the SgInitializedName from the SgVariableDeclaration.
SgInitializedName* initializedName = SageInterface::getFirstInitializedName(variableDeclaration);
SgType* base_type = initializedName->get_type()->findBaseType();
ROSE_ASSERT(base_type != NULL);
// SgClassType* classType = isSgClassType(initializedName->get_type());
SgClassType* classType = isSgClassType(base_type);
if (classType != NULL)
{
#if 1
printf ("In DetectionTraversal::evaluateInheritedAttribute(): case SgClassType: class name = %s \n",classType->get_name().str());
#endif
// Check if this is associated with a template instantiation.
SgTemplateInstantiationDecl* templateInstantiationDecl = isSgTemplateInstantiationDecl(classType->get_declaration());
if (templateInstantiationDecl != NULL)
{
#if 1
printf ("case SgTemplateInstaiationDecl: class name = %s \n",classType->get_name().str());
printf ("case SgTemplateInstaiationDecl: templateInstantiationDecl->get_templateName() = %s \n",templateInstantiationDecl->get_templateName().str());
#endif
// inheritedAttribute.set_StencilDeclaration(templateInstantiationDecl->get_templateName() == "Stencil");
// inheritedAttribute.set_StencilOperatorDeclaration(templateInstantiationDecl->get_templateName() == "StencilOperator");
if (templateInstantiationDecl->get_templateName() == "Stencil")
{
// DQ (2/8/2015): Ignore compiler generated IR nodes (from template instantiations, etc.).
// Note that simpleCNS.cpp generates one of these from it's use of the tuple template and associated template instantations.
// DQ: Test the DSL support.
ROSE_ASSERT(isMatchingClassType(classType,"Stencil",true) == true);
checkAndResetToMakeConsistantCompilerGenerated(initializedName);
if (initializedName->isCompilerGenerated() == false)
{
// Save the SgInitializedName associated with the stencil.
// stencilInitializedNameList.push_back(initializedName);
// inheritedAttribute.set_StencilDeclaration(true);
// foundStencilVariable = true;
#if 1
printf ("Detected Stencil<> typed variable: initializedName = %p name = %s \n",initializedName,initializedName->get_name().str());
// printf (" --- stencilInitializedNameList.size() = %zu \n",stencilInitializedNameList.size());
#endif
#if 1
initializedName->get_file_info()->display("In DetectionTraversal::evaluateInheritedAttribute(): initializedName : debug");
#endif
#if 0
Stencil_Attribute* dslAttribute = new Stencil_Attribute();
#if 1
printf ("Adding (Stencil) dslAttribute = %p \n",dslAttribute);
#endif
ROSE_ASSERT(dslAttribute != NULL);
// virtual void addNewAttribute (std::string s, AstAttribute *a);
initializedName->addNewAttribute(StencilVariable,dslAttribute);
#endif
}
}
}
SgClassDeclaration* classDeclaration = isSgClassDeclaration(classType->get_declaration());
if (classDeclaration != NULL)
{
if (classDeclaration->get_name() == "Point")
{
// Save the SgInitializedName associated with the Point type.
#if 0
printf ("Detected Point<> typed variable: initializedName = %p name = %s \n",initializedName,initializedName->get_name().str());
#endif
checkAndResetToMakeConsistantCompilerGenerated(initializedName);
if (initializedName->isCompilerGenerated() == false)
{
//.........这里部分代码省略.........