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) ); } } } } }
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; }