本文整理汇总了C++中SgInitializedName::get_parent方法的典型用法代码示例。如果您正苦于以下问题:C++ SgInitializedName::get_parent方法的具体用法?C++ SgInitializedName::get_parent怎么用?C++ SgInitializedName::get_parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgInitializedName
的用法示例。
在下文中一共展示了SgInitializedName::get_parent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
virtual void visit(SgNode* n) {
if (isSgVarRefExp(n)) {
SgVarRefExp* copy_vr = isSgVarRefExp(n);
assert (copy_vr->get_symbol());
SgInitializedName* copy = copy_vr->get_symbol()->get_declaration();
assert (copy);
if (!SageInterface::isReferenceType(copy->get_type()))
return; // Fail if non-reference
SgInitializer* copyinit = copy->get_initializer();
SgNode* copyscope_ =
copy->get_parent()->get_parent();
while (!isSgScopeStatement(copyscope_))
copyscope_ = copyscope_->get_parent();
// cout << "copyscope is a " << copyscope_->sage_class_name() << endl;
// SgScopeStatement* copyscope = isSgScopeStatement(copyscope_);
if (isSgAssignInitializer(copyinit)) {
SgAssignInitializer* init = isSgAssignInitializer(copyinit);
SgExpression* orig_expr = init->get_operand();
// cout << "orig is " << orig_expr->unparseToString() << ", copy is " << copy->get_name().str() << endl;
bool shouldReplace = false;
if (isSgVarRefExp(orig_expr)) {
SgVarRefExp* orig_vr = isSgVarRefExp(orig_expr);
// cout << "Found potential copy from " << orig_vr->get_symbol()->get_name().str() << " to " << copy_vr->get_symbol()->get_name().str() << endl;
SgInitializedName* orig = orig_vr->get_symbol()->get_declaration();
assert (orig);
SgNode* origscope = orig->get_parent()->get_parent();
assert (origscope);
shouldReplace = true;
}
if (shouldReplace) {
assert (orig_expr);
SgExpression* orig_copy =
isSgExpression(orig_expr /*->copy(SgTreeCopy()) */);
assert (orig_copy);
orig_copy->set_parent(copy_vr->get_parent());
isSgExpression(copy_vr->get_parent())->
replace_expression(copy_vr, orig_copy);
}
}
}
}
示例2: isSgArrayType
/**
* class: SgVarRefExp
* term: var_ref_exp_annotation(tpe,name,static,scope)
* arg tpe: type
* arg name: name
* arg static: wether the declaration was static
* arg scope: scope name (either from a namespace, a class or "null")
*/
PrologCompTerm*
RoseToTerm::getVarRefExpSpecific(SgVarRefExp* vr) {
SgInitializedName* n = vr->get_symbol()->get_declaration();
/* type: in general, this can be taken "as is" from the ROSE AST. However,
* ROSE (up to 0.9.4a-8xxx at least) gets a detail wrong: a declaration
* like "int arr[]" as a function parameter declares a *pointer*, not an
* array. Thus we check whether the variable might be of this sort, and if
* yes, we must make a pointer type for it. */
PrologTerm* typeSpecific = NULL;
SgInitializedName* vardecl = vr->get_symbol()->get_declaration();
SgType* t = vr->get_type()->stripType(SgType::STRIP_MODIFIER_TYPE
| SgType::STRIP_REFERENCE_TYPE
| SgType::STRIP_TYPEDEF_TYPE);
if (isSgFunctionParameterList(vardecl->get_parent()) && isSgArrayType(t)) {
SgType* baseType = isSgArrayType(t)->get_base_type();
PrologTerm* baseTypeSpecific = getTypeSpecific(baseType);
typeSpecific = new PrologCompTerm("pointer_type", /*1,*/ baseTypeSpecific);
} else {
typeSpecific = getTypeSpecific(n->get_typeptr());
}
/* static? (relevant for unparsing if scope is a class)*/
PrologTerm *isStatic;
SgDeclarationStatement* vdec = n->get_declaration();
if (vdec != NULL) {
isStatic =
getEnum(vdec->get_declarationModifier().get_storageModifier().isStatic(),
re.static_flags);
} else {
isStatic = getEnum(0, re.static_flags);
}
PrologTerm* scope;
if (vdec != NULL) {
/* named scope or irrelevant?*/
if (SgNamespaceDefinitionStatement* scn =
isSgNamespaceDefinitionStatement(vdec->get_parent())) {
scope = getNamespaceScopeName(scn);
} else if (SgClassDefinition* scn =
isSgClassDefinition(vdec->get_parent())) {
scope = getClassScopeName(scn);
} else {
scope = new PrologAtom("null");
}
} else {
scope = new PrologAtom("null");
}
return new PrologCompTerm
("var_ref_exp_annotation", //5,
typeSpecific,
/* name*/ new PrologAtom(n->get_name().getString()),
isStatic,
scope,
PPI(vr));
}
示例3: DCL02_C
/**
* Use visually distinct identifiers
*
* \note also checks DCL31-C
*/
bool DCL02_C( const SgNode *node ) {
static std::map<const SgScopeStatement *, std::set<std::string> > scopeMap;
static std::map<std::string, const SgInitializedName *> strVarMap;
const SgScopeStatement *scope = isSgScopeStatement(node);
if (!scope)
return false;
bool violation = false;
if (isSgGlobal(scope)) {
std::set<std::string> externNames;
/** populate scopeMap */
FOREACH_SUBNODE(scope, nodes, i, V_SgInitializedName) {
SgInitializedName *var = isSgInitializedName(*i);
assert(var);
if (isCompilerGeneratedNode(var)
|| !isSgDeclarationStatement(var->get_parent())
|| findParentOfType(var, SgCtorInitializerList)
|| findParentOfType(var, SgClassDeclaration) // Might be too strong
|| var->get_name().getString().empty()
|| (var->get_name().getString().substr(0,2) == "__"))
continue;
/** Ignore function prototypes */
const SgFunctionDeclaration * fnDecl = findParentOfType(var, SgFunctionDeclaration);
if (fnDecl && !fnDecl->get_definition())
continue;
if (isExternVar(var)) {
if (externNames.find(var->get_name().getString()) != externNames.end())
continue;
externNames.insert(var->get_name().getString());
}
const SgScopeStatement *varScope = var->get_scope();
std::string str (normalize_string(var->get_name().str(), isExternVar(var)));
if (scopeMap[varScope].find(str) != scopeMap[varScope].end()) {
DCL02_report_error(var);
violation = true;
} else {
scopeMap[varScope].insert(str);
strVarMap[str] = var;
}
}
return false;
}
示例4: printf
void
FixupEnumValues::visit(SgNode* node)
{
#if 0
printf ("##### FixupEnumValues::visit(node = %p = %s) \n",node,node->sage_class_name());
#endif
SgEnumVal* enumVal = isSgEnumVal(node);
ROSE_ASSERT(enumVal != NULL);
if (enumVal->get_declaration() == NULL)
{
ROSE_ASSERT(enumVal->get_startOfConstruct() != NULL);
ROSE_ASSERT(enumVal->get_endOfConstruct() != NULL);
// printf ("Found an enum value with a NULL declaration, fixup the declaration! \n");
// enumVal->get_startOfConstruct()->display("Found an enum value with a NULL declaration");
SgClassDefinition* enclosingClassDefinition = TransformationSupport::getClassDefinition(enumVal);
ROSE_ASSERT(enclosingClassDefinition != NULL);
// Now search for the enumVal name in the symbol table
SgEnumFieldSymbol* enumFieldSymbol = enclosingClassDefinition->lookup_enum_field_symbol(enumVal->get_name());
ROSE_ASSERT(enumFieldSymbol != NULL);
if (enumFieldSymbol != NULL)
{
// We have now found the enum symbol in the scope of the class where the enum value was used.
// It could have been elsewhere and we don't search there, it could be in a namespace that was
// included using a using directive, so this could be very complex if it is not in the enclosing
// class. To handle the case of where we can't find it, we ALLOW the declaration in the enumVal
// to be NULL, but we try to set it where we can easily figure it out.
SgInitializedName* enumFieldName = enumFieldSymbol->get_declaration();
SgNode* parentNode = enumFieldName->get_parent();
ROSE_ASSERT(parentNode != NULL);
SgEnumDeclaration* enumDeclaration = isSgEnumDeclaration(parentNode);
ROSE_ASSERT(enumDeclaration != NULL);
// Set the declaration to the enum declaration found!
// printf ("Fixup the NULL declaration in enumVal = %p = %s with valid enum declaration = %p = %s \n",enumVal,enumVal->get_name().str(),enumDeclaration,enumDeclaration->get_name().str());
enumVal->set_declaration(enumDeclaration);
}
}
}
示例5: build
void SystemDependenceGraph::build()
{
boost::unordered_map<CFGVertex, Vertex> cfgVerticesToSdgVertices;
boost::unordered_map<SgNode*, Vertex> astNodesToSdgVertices;
//map<SgFunctionCallExp*, vector<SDGNode*> > funcCallToArgs;
vector<CallSiteInfo> functionCalls;
map<SgNode*, vector<Vertex> > actualInParameters;
map<SgNode*, vector<Vertex> > actualOutParameters;
map<SgNode*, Vertex> formalInParameters;
map<SgNode*, Vertex> formalOutParameters;
vector<SgFunctionDefinition*> funcDefs =
SageInterface::querySubTree<SgFunctionDefinition>(project_, V_SgFunctionDefinition);
foreach (SgFunctionDefinition* funcDef, funcDefs)
{
SgFunctionDeclaration* funcDecl = funcDef->get_declaration();
CFG* cfg = new CFG(funcDef, cfgNodefilter_);
functionsToCFGs_[funcDecl] = cfg;
// For each function, build an entry node for it.
SDGNode* entry = new SDGNode(SDGNode::Entry);
entry->astNode = funcDef;
//entry->funcDef = funcDef;
Vertex entryVertex = addVertex(entry);
functionsToEntries_[funcDecl] = entryVertex;
// Add all out formal parameters to SDG.
const SgInitializedNamePtrList& formalArgs = funcDecl->get_args();
foreach (SgInitializedName* initName, formalArgs)
{
// If the parameter is passed by reference, create a formal-out node.
if (isParaPassedByRef(initName->get_type()))
{
SDGNode* formalOutNode = new SDGNode(SDGNode::FormalOut);
formalOutNode->astNode = initName;
Vertex formalOutVertex = addVertex(formalOutNode);
formalOutParameters[initName] = formalOutVertex;
// Add a CD edge from call node to this formal-out node.
addTrueCDEdge(entryVertex, formalOutVertex);
}
}
// A vertex representing the returned value.
Vertex returnVertex;
// If the function returns something, build a formal-out node.
if (!isSgTypeVoid(funcDecl->get_type()->get_return_type()))
{
SDGNode* formalOutNode = new SDGNode(SDGNode::FormalOut);
// Assign the function declaration to the AST node of this vertex to make
// it possible to classify this node into the subgraph of this function.
formalOutNode->astNode = funcDecl;
returnVertex = addVertex(formalOutNode);
formalOutParameters[funcDecl] = returnVertex;
// Add a CD edge from call node to this formal-out node.
addTrueCDEdge(entryVertex, returnVertex);
}
// Add all CFG vertices to SDG.
foreach (CFGVertex cfgVertex, boost::vertices(*cfg))
{
if (cfgVertex == cfg->getEntry() || cfgVertex == cfg->getExit())
continue;
SgNode* astNode = (*cfg)[cfgVertex]->getNode();
// If this node is an initialized name and it is a parameter, make it
// as a formal in node.
SgInitializedName* initName = isSgInitializedName(astNode);
if (initName && isSgFunctionParameterList(initName->get_parent()))
{
SDGNode* formalInNode = new SDGNode(SDGNode::FormalIn);
formalInNode->astNode = initName;
Vertex formalInVertex = addVertex(formalInNode);
formalInParameters[initName] = formalInVertex;
cfgVerticesToSdgVertices[cfgVertex] = formalInVertex;
astNodesToSdgVertices[astNode] = formalInVertex;
// Add a CD edge from call node to this formal-in node.
addTrueCDEdge(entryVertex, formalInVertex);
continue;
}
// Add a new node to SDG.
SDGNode* newSdgNode = new SDGNode(SDGNode::ASTNode);
//newSdgNode->cfgNode = (*cfg)[cfgVertex];
newSdgNode->astNode = astNode;
Vertex sdgVertex = addVertex(newSdgNode);
cfgVerticesToSdgVertices[cfgVertex] = sdgVertex;
astNodesToSdgVertices[astNode] = sdgVertex;
//.........这里部分代码省略.........
示例6: InheritedAttribute
InheritedAttribute
visitorTraversal::evaluateInheritedAttribute(SgNode* n, InheritedAttribute inheritedAttribute)
{
Sg_File_Info* s = n->get_startOfConstruct();
Sg_File_Info* e = n->get_endOfConstruct();
Sg_File_Info* f = n->get_file_info();
for(int x=0; x < inheritedAttribute.depth; ++x) {
printf(" ");
}
if(s != NULL && e != NULL && !isSgLabelStatement(n)) {
printf ("%s (%d, %d, %d)->(%d, %d): %s",n->sage_class_name(),s->get_file_id()+1,s->get_raw_line(),s->get_raw_col(),e->get_raw_line(),e->get_raw_col(), verbose ? n->unparseToString().c_str() : "" );
if(isSgAsmDwarfConstruct(n)) {
printf(" [DWARF construct name: %s]", isSgAsmDwarfConstruct(n)->get_name().c_str());
}
SgExprStatement * exprStmt = isSgExprStatement(n);
if(exprStmt != NULL) {
printf(" [expr type: %s]", exprStmt->get_expression()->sage_class_name());
SgFunctionCallExp * fcall = isSgFunctionCallExp(exprStmt->get_expression());
if(fcall != NULL) {
SgExpression * funcExpr = fcall->get_function();
if(funcExpr != NULL) {
printf(" [function expr: %s]", funcExpr->class_name().c_str());
}
SgFunctionDeclaration * fdecl = fcall->getAssociatedFunctionDeclaration();
if(fdecl != NULL) {
printf(" [called function: %s]", fdecl->get_name().str());
}
}
}
if(isSgFunctionDeclaration(n)) {
printf(" [declares function: %s]", isSgFunctionDeclaration(n)->get_name().str());
}
SgStatement * sgStmt = isSgStatement(n);
if(sgStmt != NULL) {
printf(" [scope: %s, %p]", sgStmt->get_scope()->sage_class_name(), sgStmt->get_scope());
}
//SgLabelStatement * lblStmt = isSgLabelStatement(n);
//if(lblStmt != NULL) {
// SgStatement * lblStmt2 = lblStmt->get_statement();
//}
} else if (f != NULL) {
SgInitializedName * iname = isSgInitializedName(n);
if(iname != NULL) {
SgType* inameType = iname->get_type();
printf("%s (%d, %d, %d): %s [type: %s", n->sage_class_name(),f->get_file_id()+1,f->get_raw_line(),f->get_raw_col(),n->unparseToString().c_str(),inameType->class_name().c_str());
SgDeclarationStatement * ds = isSgDeclarationStatement(iname->get_parent());
if(ds != NULL) {
if(ds->get_declarationModifier().get_storageModifier().isStatic()) {
printf(" static");
}
}
SgArrayType * art = isSgArrayType(iname->get_type());
if(art != NULL) {
printf(" %d", art->get_rank());
}
printf("]");
if(isSgAsmDwarfConstruct(n)) {
printf(" [DWARF construct name: %s]", isSgAsmDwarfConstruct(n)->get_name().c_str());
}
} else {
printf("%s (%d, %d, %d): %s", n->sage_class_name(),f->get_file_id()+1,f->get_raw_line(),f->get_raw_col(), verbose ? n->unparseToString().c_str() : "");
}
} else {
printf("%s : %s", n->sage_class_name(), verbose ? n->unparseToString().c_str() : "");
if(isSgAsmDwarfConstruct(n)) {
printf(" [DWARF construct name: %s]", isSgAsmDwarfConstruct(n)->get_name().c_str());
}
}
printf(" succ# %lu", n->get_numberOfTraversalSuccessors());
printf("\n");
return InheritedAttribute(inheritedAttribute.depth+1);
}
示例7: main
int main( int argc, char * argv[] )
{
// Option to linearize the array.
Rose_STL_Container<std::string> localCopy_argv = CommandlineProcessing::generateArgListFromArgcArgv(argc, argv);
int newArgc;
char** newArgv = NULL;
vector<string> argList = localCopy_argv;
if (CommandlineProcessing::isOption(argList,"-f2c:","linearize",true) == true)
{
isLinearlizeArray = true;
}
CommandlineProcessing::generateArgcArgvFromList(argList,newArgc, newArgv);
// Build the AST used by ROSE
SgProject* project = frontend(newArgc,newArgv);
AstTests::runAllTests(project);
if (SgProject::get_verbose() > 2)
generateAstGraph(project,8000,"_orig");
// Traversal with Memory Pool to search for variableDeclaration
variableDeclTraversal translateVariableDeclaration;
traverseMemoryPoolVisitorPattern(translateVariableDeclaration);
for(vector<SgVariableDeclaration*>::iterator dec=variableDeclList.begin(); dec!=variableDeclList.end(); ++dec)
{
/*
For the Fortran AST, a single variableDeclaration can be shared by multiple variables.
This violated the normalization rules for C unparser. Therefore, we have to transform it.
*/
SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(*dec);
ROSE_ASSERT(variableDeclaration);
if((variableDeclaration->get_variables()).size() != 1)
{
updateVariableDeclarationList(variableDeclaration);
statementList.push_back(variableDeclaration);
removeList.push_back(variableDeclaration);
}
}
// reset the vector that collects all variable declaration. We need to walk through memory pool again to find types
variableDeclList.clear();
traverseMemoryPoolVisitorPattern(translateVariableDeclaration);
for(vector<SgVariableDeclaration*>::iterator dec=variableDeclList.begin(); dec!=variableDeclList.end(); ++dec)
{
SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(*dec);
ROSE_ASSERT(variableDeclaration);
SgInitializedNamePtrList initializedNameList = variableDeclaration->get_variables();
for(SgInitializedNamePtrList::iterator i=initializedNameList.begin(); i!=initializedNameList.end();++i)
{
SgInitializedName* initiallizedName = isSgInitializedName(*i);
SgType* baseType = initiallizedName->get_type();
if(baseType->variantT() == V_SgArrayType)
{
SgArrayType* arrayBase = isSgArrayType(baseType);
// At this moment, we are still working on the Fortran-stype AST. Therefore, there is no nested types for multi-dim array.
if(arrayBase->findBaseType()->variantT() == V_SgTypeString)
{
arrayBase->reset_base_type(translateType(arrayBase->findBaseType()));
arrayBase->set_rank(arrayBase->get_rank()+1);
}
}
else
{
initiallizedName->set_type(translateType(baseType));
}
}
}
// replace the AttributeSpecificationStatement
Rose_STL_Container<SgNode*> AttributeSpecificationStatement = NodeQuery::querySubTree (project,V_SgAttributeSpecificationStatement);
for (Rose_STL_Container<SgNode*>::iterator i = AttributeSpecificationStatement.begin(); i != AttributeSpecificationStatement.end(); i++)
{
SgAttributeSpecificationStatement* attributeSpecificationStatement = isSgAttributeSpecificationStatement(*i);
ROSE_ASSERT(attributeSpecificationStatement);
translateAttributeSpecificationStatement(attributeSpecificationStatement);
statementList.push_back(attributeSpecificationStatement);
removeList.push_back(attributeSpecificationStatement);
}
// replace the parameter reference
parameterTraversal translateParameterRef;
traverseMemoryPoolVisitorPattern(translateParameterRef);
for(vector<SgVarRefExp*>::iterator i=parameterRefList.begin(); i!=parameterRefList.end(); ++i)
{
SgVarRefExp* parameterRef = isSgVarRefExp(*i);
if(parameterSymbolList.find(parameterRef->get_symbol()) != parameterSymbolList.end())
{
SgExpression* newExpr = isSgExpression(deepCopy(parameterSymbolList.find(parameterRef->get_symbol())->second));
ROSE_ASSERT(newExpr);
newExpr->set_parent(parameterRef->get_parent());
replaceExpression(parameterRef,
newExpr,
false);
}
}
/*
Parameters will be replaced by #define, all the declarations should be removed
*/
for(map<SgVariableSymbol*,SgExpression*>::iterator i=parameterSymbolList.begin();i!=parameterSymbolList.end();++i)
//.........这里部分代码省略.........
示例8: 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());
if (className == "sigaction")
{
// 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;
std::string macroString = "#undef sa_handler\n";
std::string filenameString = "macro_call_fixupSelfReferentialMacrosInAST";
int line_no = 1;
int col_no = 1;
int nol = 1;
PreprocessingInfo::RelativePositionType relPos = PreprocessingInfo::before;
PreprocessingInfo* macro = new PreprocessingInfo(directiveType,macroString,filenameString,line_no,col_no,nol,relPos);
// printf ("Attaching CPP directive %s to IR node %p as attributes. \n",PreprocessingInfo::directiveTypeName(macro->getTypeOfDirective()).c_str(),associatedStatement);
associatedStatement->addToAttachedPreprocessingInfo(macro);
#if 0
printf ("Exiting as a test! \n");
ROSE_ASSERT(false);
#endif
}
}
}
}
default:
{
// printf ("Not handled in FixupSelfReferentialMacrosInAST::visit(%s) \n",node->class_name().c_str());
}
}
}
示例9: 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",
//.........这里部分代码省略.........