本文整理汇总了C++中SgStatement::get_startOfConstruct方法的典型用法代码示例。如果您正苦于以下问题:C++ SgStatement::get_startOfConstruct方法的具体用法?C++ SgStatement::get_startOfConstruct怎么用?C++ SgStatement::get_startOfConstruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgStatement
的用法示例。
在下文中一共展示了SgStatement::get_startOfConstruct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: switch
void
FixupSelfReferentialMacrosInAST::visit ( SgNode* node )
{
// DQ (3/11/2006): Set NULL pointers where we would like to have none.
// printf ("In FixupSelfReferentialMacrosInAST::visit(): node = %s \n",node->class_name().c_str());
ROSE_ASSERT(node != NULL);
switch (node->variantT())
{
case V_SgInitializedName:
{
SgInitializedName* initializedName = isSgInitializedName(node);
ROSE_ASSERT(initializedName != NULL);
SgType* type = initializedName->get_type()->stripType();
SgClassType* classType = isSgClassType(type);
if (classType != NULL)
{
SgClassDeclaration* targetClassDeclaration = isSgClassDeclaration(classType->get_declaration());
SgName className = targetClassDeclaration->get_name();
// printf ("In FixupSelfReferentialMacrosInAST::visit(): Found a class declaration name = %s \n",className.str());
// For sudo_exec_pty.c also look for siginfo
if (className == "sigaction" || className == "siginfo")
{
// printf ("In FixupSelfReferentialMacrosInAST::visit(): Found a sigaction type \n");
// Note we could also check that the declaration came from a known header file.
SgStatement* associatedStatement = isSgStatement(initializedName->get_parent());
if (associatedStatement != NULL)
{
// Add a macro to undefine the "#define sa_handler __sigaction_handler.sa_handler" macro.
// printf ("In FixupSelfReferentialMacrosInAST::visit(): Add a macro to undefine the macro #define sa_handler __sigaction_handler.sa_handler \n");
// PreprocessingInfo* macro = new PreprocessingInfo(DirectiveType, const std::string & inputString,const std::string & filenameString, int line_no , int col_no,int nol, RelativePositionType relPos );
PreprocessingInfo::DirectiveType directiveType = PreprocessingInfo::CpreprocessorUndefDeclaration;
// We are puting out all macros anytime we see either type. This might be too much...
// From the sigaction.h file (included by signal.h):
addMacro(associatedStatement,"#undef sa_handler\n",directiveType);
addMacro(associatedStatement,"#undef sa_sigaction\n",directiveType);
// From the siginfo.h file (included by signal.h):
addMacro(associatedStatement,"#undef si_pid\n", directiveType);
addMacro(associatedStatement,"#undef si_uid\n", directiveType);
addMacro(associatedStatement,"#undef si_timerid\n",directiveType);
addMacro(associatedStatement,"#undef si_overrun\n",directiveType);
addMacro(associatedStatement,"#undef si_status\n", directiveType);
addMacro(associatedStatement,"#undef si_utime\n", directiveType);
addMacro(associatedStatement,"#undef si_stime\n", directiveType);
addMacro(associatedStatement,"#undef si_value\n", directiveType);
addMacro(associatedStatement,"#undef si_int\n", directiveType);
addMacro(associatedStatement,"#undef si_ptr\n", directiveType);
addMacro(associatedStatement,"#undef si_addr\n", directiveType);
addMacro(associatedStatement,"#undef si_band\n", directiveType);
addMacro(associatedStatement,"#undef si_fd\n", directiveType);
}
}
}
}
default:
{
// printf ("Not handled in FixupSelfReferentialMacrosInAST::visit(%s) \n",node->class_name().c_str());
}
}
#if 0
// DQ (12/30/2013): Comments and CPP directives have not yet been attached to the AST, so we can't process them here.
// SgLocatedNode* locatedNode = isSgLocatedNode(node);
// if (locatedNode != NULL)
SgStatement* stmt = isSgStatement(node);
if (stmt != NULL)
{
// Find all #define statements and look for self referencing macros
int numberOfComments = -1;
if (stmt->getAttachedPreprocessingInfo() != NULL)
numberOfComments = stmt->getAttachedPreprocessingInfo()->size();
std::string s = std::string(" --- startOfConstruct: file = " ) + stmt->get_startOfConstruct()->get_filenameString()
+ " raw filename = " + stmt->get_startOfConstruct()->get_raw_filename()
+ " raw line = " + StringUtility::numberToString(stmt->get_startOfConstruct()->get_raw_line())
+ " raw column = " + StringUtility::numberToString(stmt->get_startOfConstruct()->get_raw_col())
+ " #comments = " + StringUtility::numberToString(numberOfComments)
+ " \n ";
AttachedPreprocessingInfoType* comments = stmt->getAttachedPreprocessingInfo();
if (comments != NULL)
{
printf ("Found attached comments (at %p of type: %s): \n",stmt,stmt->class_name().c_str());
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin(); i != comments->end(); i++)
{
ROSE_ASSERT ( (*i) != NULL );
printf (" Attached Comment (relativePosition=%s): %s\n",
//.........这里部分代码省略.........