本文整理汇总了C++中SgLocatedNode::getAttachedPreprocessingInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ SgLocatedNode::getAttachedPreprocessingInfo方法的具体用法?C++ SgLocatedNode::getAttachedPreprocessingInfo怎么用?C++ SgLocatedNode::getAttachedPreprocessingInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgLocatedNode
的用法示例。
在下文中一共展示了SgLocatedNode::getAttachedPreprocessingInfo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void visitorTraversal::visit(SgNode* n)
{
// On each node look for any comments of CPP directives
SgLocatedNode* locatedNode = isSgLocatedNode(n);
if (locatedNode != NULL)
{
AttachedPreprocessingInfoType* comments = locatedNode->getAttachedPreprocessingInfo();
if (comments != NULL)
{
printf ("Found attached comments (to IR node at %p of type: %s): \n",locatedNode,locatedNode->class_name().c_str());
int counter = 0;
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin(); i != comments->end(); i++)
{
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());
}
}
else
{
printf ("No attached comments (at %p of type: %s): \n",locatedNode,locatedNode->sage_class_name());
}
}
}
示例2: visit
void findPreprocInfo::visit(SgNode* n)
{
// Add in the information from the current node
SgLocatedNode* locatedNode = isSgLocatedNode(n);
if (locatedNode != NULL)
{
AttachedPreprocessingInfoType* commentsAndDirectives = locatedNode->getAttachedPreprocessingInfo();
if (commentsAndDirectives != NULL)
{
// printf ("Found attached comments (to IR node at %p of type: %s): \n",locatedNode,locatedNode->class_name().c_str());
// int counter = 0;
// Use a reverse iterator so that we preserve the order when using push_front to add each directive to the accumulatedList
AttachedPreprocessingInfoType::reverse_iterator i;
for (i = commentsAndDirectives->rbegin(); i != commentsAndDirectives->rend(); i++)
{
// The different classifications of comments and directives are in ROSE/src/frontend/SageIII/rose_attributes_list.h
if ((*i)->getTypeOfDirective() == PreprocessingInfo::CMacroCall)
{
wherePreprocIsAttached.push_back(std::pair<SgNode*,PreprocessingInfo*>(n,*i) );
}
}
}
}
}
示例3: visit
void visit ( SgNode* n )
{
SgLocatedNode* locatedNode = isSgLocatedNode(n);
if (locatedNode != NULL)
{
AttachedPreprocessingInfoType* comments = locatedNode->getAttachedPreprocessingInfo();
if (comments != NULL)
{
printf ("Found attached comments (at %p of type: %s): \n",locatedNode,locatedNode->sage_class_name());
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin(); i != comments->end(); i++)
{
ROSE_ASSERT ( (*i) != NULL );
printf (" Attached Comment (relativePosition=%s): %s\n",
((*i)->getRelativePosition() == PreprocessingInfo::before) ? "before" : "after",
(*i)->getString().c_str());
#if 1
// This does not appear to be a valid object when read in from an AST file.
printf ("Comment/Directive getNumberOfLines = %d getColumnNumberOfEndOfString = %d \n",(*i)->getNumberOfLines(),(*i)->getColumnNumberOfEndOfString());
#endif
#if 1
// This does not appear to be a valid object when read in from an AST file.
(*i)->get_file_info()->display("comment/directive location");
#endif
}
}
}
}
示例4: isSgLocatedNode
SynthesizedAttribute
visitorTraversal::evaluateSynthesizedAttribute ( SgNode* n, SynthesizedAttributesList childAttributes )
{
SynthesizedAttribute localResult;
// printf ("In evaluateSynthesizedAttribute(n = %p = %s) \n",n,n->class_name().c_str());
// Build the list from children (in reverse order to preserve the final ordering)
for (SynthesizedAttributesList::reverse_iterator child = childAttributes.rbegin(); child != childAttributes.rend(); child++)
{
localResult.accumulatedList.splice(localResult.accumulatedList.begin(),child->accumulatedList);
}
// Add in the information from the current node
SgLocatedNode* locatedNode = isSgLocatedNode(n);
if (locatedNode != NULL)
{
AttachedPreprocessingInfoType* commentsAndDirectives = locatedNode->getAttachedPreprocessingInfo();
if (commentsAndDirectives != NULL)
{
// printf ("Found attached comments (to IR node at %p of type: %s): \n",locatedNode,locatedNode->class_name().c_str());
// int counter = 0;
// Use a reverse iterator so that we preserve the order when using push_front to add each directive to the accumulatedList
AttachedPreprocessingInfoType::reverse_iterator i;
for (i = commentsAndDirectives->rbegin(); i != commentsAndDirectives->rend(); i++)
{
// The different classifications of comments and directives are in ROSE/src/frontend/SageIII/rose_attributes_list.h
if ((*i)->getTypeOfDirective() == PreprocessingInfo::CpreprocessorDefineDeclaration)
{
#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
// use push_front() to end up with source ordering of final list of directives
localResult.accumulatedList.push_front(*i);
}
}
}
}
// printf ("localResult after adding current node info \n");
// localResult.display();
return localResult;
}
示例5: isSgLocatedNode
static std::string
commentAndCppInformation (SgNode* node)
{
// DQ (8/31/2013): Adding source position information for DOT output.
string ss;
SgLocatedNode* locatedNode = isSgLocatedNode(node);
if (locatedNode != NULL)
{
AttachedPreprocessingInfoType* commentsAndCppDirectives = locatedNode->getAttachedPreprocessingInfo();
size_t numberofCommentsAndCppDirectives = 0;
if (commentsAndCppDirectives != NULL)
{
numberofCommentsAndCppDirectives = commentsAndCppDirectives->size();
if (numberofCommentsAndCppDirectives >= 0)
{
// ss = string("comments = ") + StringUtility::numberToString(numberofCommentsAndCppDirectives) + "\\n";
ss += string("comments/directives (before) = ") + StringUtility::numberToString(numberByRelativePosition(commentsAndCppDirectives,PreprocessingInfo::before)) + "\\n";
ss += string("comments/directives (inside) = ") + StringUtility::numberToString(numberByRelativePosition(commentsAndCppDirectives,PreprocessingInfo::inside)) + "\\n";
ss += string("comments/directives (after) = ") + StringUtility::numberToString(numberByRelativePosition(commentsAndCppDirectives,PreprocessingInfo::after)) + "\\n";
}
}
}
#if 0
else
{
// DQ (9/1/2013): We could handle the source position of some other IR nodes (e.g. output name of the file for SgFile).
SgFile* file = isSgFile(node);
if (file != NULL)
{
// ROSE_ASSERT(file->get_file_info() != NULL);
// ss += generateFileLineColumnString(file->get_file_info());
AttachedPreprocessingInfoType* commentsAndCppDirectives = file->getAttachedPreprocessingInfo();
size_t numberofCommentsAndCppDirectives = 0;
if (commentsAndCppDirectives != NULL)
{
numberofCommentsAndCppDirectives = commentsAndCppDirectives->size();
if (numberofCommentsAndCppDirectives > 0)
{
ss = string("comments = ") + StringUtility::numberToString(numberofCommentsAndCppDirectives) + "\\n";
}
}
}
}
#endif
return ss;
}
示例6: isSgLocatedNode
void
visitorTraversal::visit (SgNode * n)
{
// On each node look for any comments of CPP directives
SgLocatedNode *locatedNode = isSgLocatedNode (n);
if (locatedNode != NULL)
{
AttachedPreprocessingInfoType *comments =
locatedNode->getAttachedPreprocessingInfo ();
if (comments != NULL)
{
printf ("-----------------------------------------------\n");
printf ("Found an IR node with preprocessing Info attached:\n");
printf ("(memory address: %p Sage type: %s) in file \n%s (line %d column %d) \n",
locatedNode,
locatedNode->class_name ().c_str (),
(locatedNode->get_file_info ()->get_filenameString ()).c_str (),
locatedNode->get_file_info ()->get_line(),
locatedNode->get_file_info ()->get_col() );
int counter = 0;
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin (); i != comments->end (); i++)
{
printf("-------------PreprocessingInfo #%d ----------- : \n",counter++);
printf("classification = %s:\n String format = %s\n",
PreprocessingInfo::directiveTypeName((*i)->getTypeOfDirective ()). c_str (),
(*i)->getString ().c_str ());
printf ("relative position is = ");
if ((*i)->getRelativePosition () == PreprocessingInfo::inside)
printf ("inside\n");
else
printf ("%s\n", \
((*i)->getRelativePosition () == PreprocessingInfo::before) ? "before" : "after");
}
}
}
}
示例7: SgName
Rose_STL_Container<
ControlStructureContainer *
>queryFindCommentsInScope (const string stringPrefixToMatch,
const string stringToMatch,
SgScopeStatement * sageScopeStatement)
{
ROSE_ASSERT (stringPrefixToMatch.length () > 0);
ROSE_ASSERT (stringToMatch.length () > 0);
ROSE_ASSERT (sageScopeStatement != NULL);
Rose_STL_Container< ControlStructureContainer * >returnList;
//find all pragmas who match the stringToMatch
//cout << "Before pragma search" << endl;
/*list < SgNode * >pragmaStatements =
NodeQuery::querySubTree (sageScopeStatement,
new SgName (stringToMatch.c_str ()),
NodeQuery::PragmaDeclarationFromName);
*/
//list<SGNode*> pragmaStatements ;
//cout << "After pragma search" << endl;
/* cout << "BEFORE LIST" << endl;
list < SgNode * >pragmaStatements = queryNodePragmaStatementFromName2(sageScopeStatement,
new SgName(stringToMatch.c_str()));
cout << "AFTER LIST" << endl;*/
//return the pragmas in containers
/* for (list < SgNode * >::iterator i = pragmaStatements.begin ();
i != pragmaStatements.end (); ++i)
{
SgPragmaDeclaration *sagePragma = isSgPragmaDeclaration (*i);
ROSE_ASSERT (sagePragma);
ROSE_ASSERT (sagePragma->get_pragma () != NULL);
ROSE_ASSERT (sagePragma->get_pragma ()->get_pragma ());
ControlStructureContainer *container = new ControlStructureContainer ();
container->setPragmaString (sagePragma->get_pragma ()->get_pragma ());
container->setAssociatedStatement (sagePragma);
returnList.push_back (container);
}
*/
//find all statements in the current scope
if (sageScopeStatement->variantT () == V_SgClassDefinition)
{
SgDeclarationStatementPtrList statementsInScope =
sageScopeStatement->getDeclarationList ();
SgDeclarationStatementPtrList::iterator i;
for (i = statementsInScope.begin (); i != statementsInScope.end (); i++)
{
SgLocatedNode *locatedNode = isSgLocatedNode (*i);
ROSE_ASSERT (locatedNode != NULL);
//find all comments attached to current node.
AttachedPreprocessingInfoType *comments =
locatedNode->getAttachedPreprocessingInfo ();
if(locatedNode->variantT() == V_SgPragmaDeclaration){
SgPragmaDeclaration* sagePragmaDeclaration = isSgPragmaDeclaration(locatedNode);
ROSE_ASSERT( sagePragmaDeclaration );
ROSE_ASSERT( sagePragmaDeclaration->get_pragma() != NULL );
string pragmaDeclarationString = sagePragmaDeclaration->get_pragma()->get_pragma();
//extract the part before the leftmost = is pragmaDeclarationString
pragmaDeclarationString = pragmaDeclarationString.substr(0,pragmaDeclarationString.find("="));
//if the name-criteria is met accept node
if(pragmaDeclarationString.find( stringToMatch ) != string::npos ){
cout << pragmaDeclarationString << endl;
ControlStructureContainer *container = new ControlStructureContainer ();
container->setPragmaString (sagePragmaDeclaration->get_pragma ()->get_pragma ());
container->setAssociatedStatement (sagePragmaDeclaration);
returnList.push_back (container);
}
}
if (comments != NULL)
{
//We need to find comments which fits the criteria
printf ("Found attached comments (at %p of type: %s): \n",
locatedNode, locatedNode->sage_class_name ());
AttachedPreprocessingInfoType::iterator j;
for (j = comments->begin (); j != comments->end (); j++)
{
ROSE_ASSERT ((*j) != NULL);
string comment = (*j)->getString ();
//see if comment begins with stringPrefixToMatch
string tempString = comment.substr (0, comment.find (' '));
if (tempString == stringPrefixToMatch)
{ //+stringPrefixToMatch ){
//cout << "Found string" << endl;
comment =
StringUtility::copyEdit (comment, stringPrefixToMatch,
"");
//see if the comment has an element which matches the stringToMatch
if (comment.find (stringToMatch) != string::npos)
{
//.........这里部分代码省略.........