Rose_STL_Container<SgInitializedName*> buildListOfGlobalVariables ( SgSourceFile* file ) { // This function builds a list of global variables (from a SgFile). assert(file != NULL); Rose_STL_Container<SgInitializedName*> globalVariableList; SgGlobal* globalScope = file->get_globalScope(); assert(globalScope != NULL); Rose_STL_Container<SgDeclarationStatement*>::iterator i = globalScope->get_declarations().begin(); while(i != globalScope->get_declarations().end()) { SgVariableDeclaration *variableDeclaration = isSgVariableDeclaration(*i); if (variableDeclaration != NULL) { Rose_STL_Container<SgInitializedName*> & variableList = variableDeclaration->get_variables(); Rose_STL_Container<SgInitializedName*>::iterator var = variableList.begin(); while(var != variableList.end()) { globalVariableList.push_back(*var); var++; } } i++; } return globalVariableList; }
/* * The function * queryNodePragmaDeclarationFromName() * takes as a first parameter a SgNode*. As a second parameter it takes * a SgNode* who must be of type SgName. The SgName contains a std::string which * should be the same as the left side in the pragma or a part of the left * side of the pragma. If the std::string is empty, * there will be an error message. * * #pragma std::stringInSgNode = information * */ Rose_STL_Container<SgNode*> NodeQuery::queryNodePragmaDeclarationFromName(SgNode* node, SgNode* nameNode){ ROSE_ASSERT( nameNode != NULL ); ROSE_ASSERT( node != NULL ); Rose_STL_Container<SgNode*> returnList; //finds the name which should be matched to SgName* sageName = isSgName(nameNode); ROSE_ASSERT( sageName != NULL ); std::string nameToMatch = sageName->str(); ROSE_ASSERT( nameToMatch.length() > 0 ); if(node->variantT() == V_SgPragmaDeclaration){ SgPragmaDeclaration* sagePragmaDeclaration = isSgPragmaDeclaration(node); ROSE_ASSERT( sagePragmaDeclaration ); ROSE_ASSERT( sagePragmaDeclaration->get_pragma() != NULL ); // ROSE_ASSERT( sagePragmaDeclaration->get_pragma()->get_pragma() ); std::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( nameToMatch ) != pragmaDeclarationString.length() ){ cout << pragmaDeclarationString << endl; returnList.push_back(node); } } return returnList; }
// DQ (7/8/2005): Rose_STL_Container<string> CommandlineProcessing::generateArgListFromString ( string commandline ) { Rose_STL_Container<string> argList; // DQ (12/21/2006): Required to be long to avoid "if (subStringEnd == string::npos)" always evaluating to false. unsigned long int subStringStart = 0; unsigned long int subStringEnd = commandline.find(" "); // printf ("commandline.size() = %ld \n",commandline.size()); while (subStringStart < commandline.size()) { string subString = commandline.substr(subStringStart,subStringEnd-subStringStart); // printf ("subString (%ld,%ld) = %s \n",subStringStart,subStringEnd,subString.c_str()); // DQ (8/1/2005): Fix suggested by Milind (supporting astMerge in compilation of multiple files) // subStringStart = subStringEnd; // subStringEnd = commandline.find(" ",subStringStart+1); subStringStart = subStringEnd + 1; subStringEnd = commandline.find(" ",subStringStart); // printf ("New values subStringStart = %ld subStringEnd = %ld \n",subStringStart,subStringEnd); if (subStringEnd == string::npos) { subStringEnd = commandline.size(); // printf ("Reset subStringEnd = %ld \n",subStringEnd); } argList.push_back(subString); } return argList; }
Rose_STL_Container<string> CommandlineProcessing::generateArgListFromArgcArgv ( int argc, const char* argv[] ) { Rose_STL_Container<string> argList; // printf ("In generateArgListFromArgcArgv(): argc = %d \n",argc); for (int i=0; i < argc; i++) { if (argv[i] != NULL) argList.push_back(argv[i]); } return argList; }
Rose_STL_Container<string> CommandlineProcessing::generateOptionWithNameParameterList ( Rose_STL_Container<string> & argList, string inputPrefix , string newPrefix ) { // This function returns a list of options using the inputPrefix (with the // inputPrefix stripped off and replaced if new Prefix is provided. // It also modified the input argList to remove matched options. Rose_STL_Container<string> optionList; Rose_STL_Container<string> deleteList; int prefixLength = inputPrefix.length(); Rose_STL_Container<string>::iterator it = argList.begin(); while (it != argList.end()) { if ( it->substr(0,prefixLength) == inputPrefix ) { // get the rest of the string as the option optionList.push_back( (newPrefix == "") ? it->substr(prefixLength) : newPrefix + it->substr(prefixLength)); it = argList.erase(it); // That sounds real buggy as to detect if an option has parameters it // assumes inputPrefix-ed options are consecutive. if ( it->substr(0,prefixLength) != inputPrefix ) { optionList.push_back(*it); it = argList.erase(it); } else { printf ("Error: missing parameter in option with parameter \n"); ROSE_ABORT(); } } else { ++it; } } return optionList; }
/* * The function * queryPragmaString() * teakes a SgNode* as a parameter and return a list<string>. It is a NameQuery * which query the AST or a subtree of the AST for the string of all the * SgPragma's. * */ Rose_STL_Container< string > queryFindPragmaString (SgNode * node) { Rose_STL_Container< string > returnList; if (node->variantT () == V_SgPragmaDeclaration) { SgPragmaDeclaration *sagePragmaStatement = isSgPragmaDeclaration (node); ROSE_ASSERT (sagePragmaStatement); ROSE_ASSERT (sagePragmaStatement->get_pragma () != NULL); returnList.push_back (sagePragmaStatement->get_pragma ()-> get_pragma ()); } return returnList; }
Rose_STL_Container<string> CommandlineProcessing::generateOptionList (const Rose_STL_Container<string> & argList, string inputPrefix ) { // This function returns a list of options using the inputPrefix (with the // inputPrefix stripped off). It does NOT modify the argList passed as a reference. Rose_STL_Container<string> optionList; unsigned int prefixLength = inputPrefix.length(); for (Rose_STL_Container<string>::const_iterator i = argList.begin(); i != argList.end(); i++) { if ( (*i).substr(0,prefixLength) == inputPrefix ) { // get the rest of the string as the option string option = (*i).substr(prefixLength); optionList.push_back(option); } } return optionList; }
Rose_STL_Container<string> CommandlineProcessing::generateOptionList ( Rose_STL_Container<string> & argList, string inputPrefix ) { // This function returns a list of options using the inputPrefix (with the // inputPrefix stripped off). It also modified the input argList to remove // those options from the argList returned by reference (modified). // printf ("Input argList = \n%s \n",StringUtility::listToString(argList).c_str()); Rose_STL_Container<string> optionList; // Rose_STL_Container<string> deleteList; unsigned int prefixLength = inputPrefix.length(); for (Rose_STL_Container<string>::iterator i = argList.begin(); i != argList.end(); i++) { if ( (*i).substr(0,prefixLength) == inputPrefix ) { // get the rest of the string as the option optionList.push_back((*i).substr(prefixLength)); // keep track of elements so that they can be deleted later (after exit from loop over the eleents) // deleteList.push_back(*i); } } #if 0 // remove the elements identified in the previous loop for (Rose_STL_Container<string>::iterator i = deleteList.begin(); i != deleteList.end(); i++) { // DQ (9/25/2007): Moved to use of std::vector instead of std::list // argList.remove(*i); argList.erase(i); } #else // DQ (9/25/2007): Moved to use of std::vector instead of std::list // argList.erase(deleteList.begin(),deleteList.end()); // argList.clear(); #endif // printf ("return value: optionList = \n%s \n",StringUtility::listToString(optionList).c_str()); return optionList; }
ProjectNode::ProjectNode(const QString & n) : name(n), sgProject( new SgProject() ), metricsConfig( new MetricsConfig( "", NULL, sgProject ) ), callGraph(NULL), srcFileHeaderNode(NULL), binFileHeaderNode(NULL) { // Create an empty SgProject //sgProject = new SgProject(); sgProject->get_fileList().clear(); // TODO why is that needed? what does "cc" do? // just starting rose with filename argument seems to work too // ->what is the commandline of an SgProject created with frontend() Rose_STL_Container<std::string> commandLine; commandLine.push_back("cc"); commandLine.push_back("-c"); sgProject->set_originalCommandLineArgumentList (commandLine); }
Rose_STL_Container<SgNode*> NodeQuery::queryNodeVariableDeclarationFromName(SgNode* astNode, SgNode* nameNode){ ROSE_ASSERT( nameNode != NULL ); ROSE_ASSERT( astNode != NULL ); Rose_STL_Container<SgNode*> returnList; if(astNode->variantT() == V_SgVariableDeclaration){ SgName* sageName = isSgName(nameNode); ROSE_ASSERT( sageName != NULL ); std::string nameToMatch = sageName->str(); ROSE_ASSERT( nameToMatch.length() > 0 ); SgVariableDeclaration* sageVariableDeclaration = isSgVariableDeclaration(astNode); ROSE_ASSERT(sageVariableDeclaration != NULL); ROSE_ASSERT( sageVariableDeclaration->get_definition() != NULL ); SgInitializedNamePtrList sageInitializedNameList = sageVariableDeclaration->get_variables (); //see if this variable declaration fits the criteria typedef SgInitializedNamePtrList::iterator variableIterator; for (variableIterator k = sageInitializedNameList.begin (); k != sageInitializedNameList.end(); ++k) { SgInitializedName* elmVar = *k; std::string name = elmVar->get_name().str(); if(name == nameToMatch) returnList.push_back(astNode); } } return returnList; }; /* End function: queryNodeVariableDeclarationFromName */
Rose_STL_Container<SgVarRefExp*> buildListOfVariableReferenceExpressionsUsingGlobalVariables ( SgNode* node ) { // This function builds a list of "uses" of variables (SgVarRefExp IR nodes) within the AST. // return variable Rose_STL_Container<SgVarRefExp*> globalVariableUseList; // list of all variables (then select out the global variables by testing the scope) Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree ( node, V_SgVarRefExp ); Rose_STL_Container<SgNode*>::iterator i = nodeList.begin(); while(i != nodeList.end()) { SgVarRefExp *variableReferenceExpression = isSgVarRefExp(*i); assert(variableReferenceExpression != NULL); assert(variableReferenceExpression->get_symbol() != NULL); assert(variableReferenceExpression->get_symbol()->get_declaration() != NULL); assert(variableReferenceExpression->get_symbol()->get_declaration()->get_scope() != NULL); // Note that variableReferenceExpression->get_symbol()->get_declaration() returns the // SgInitializedName (not the SgVariableDeclaration where it was declared)! SgInitializedName* variable = variableReferenceExpression->get_symbol()->get_declaration(); SgScopeStatement* variableScope = variable->get_scope(); // Check if this is a variable declared in global scope, if so, then save it if (isSgGlobal(variableScope) != NULL) { globalVariableUseList.push_back(variableReferenceExpression); } i++; } return globalVariableUseList; }
// DQ (8/27/2006): This functionality already exists elsewhere // It is a shame that it is recreated here as well !!! NameQuerySynthesizedAttributeType NameQuery::queryNameTypeName (SgNode * astNode) { ROSE_ASSERT (astNode != NULL); string typeName = ""; Rose_STL_Container< string > returnList; SgType *type = isSgType (astNode); // printf ("In TransformationSupport::getTypeName(): type->sage_class_name() = %s \n",type->sage_class_name()); if (type != NULL) switch (type->variantT ()) { case V_SgTypeComplex: typeName = "complex"; break; case V_SgTypeImaginary: typeName = "imaginary"; break; case V_SgTypeBool: typeName = "bool"; break; case V_SgEnumType: typeName = "enum"; break; case V_SgTypeChar: typeName = "char"; break; case V_SgTypeVoid: typeName = "void"; break; case V_SgTypeInt: typeName = "int"; break; case V_SgTypeDouble: typeName = "double"; break; case V_SgTypeFloat: typeName = "float"; break; case V_SgTypeLong: typeName = "long"; break; case V_SgTypeLongDouble: typeName = "long double"; break; case V_SgTypeEllipse: typeName = "ellipse"; break; case V_SgTypeGlobalVoid: typeName = "void"; break; case V_SgTypeLongLong: typeName = "long long"; break; case V_SgTypeShort: typeName = "short"; break; case V_SgTypeSignedChar: typeName = "signed char"; break; case V_SgTypeSignedInt: typeName = "signed int"; break; case V_SgTypeSignedLong: typeName = "signed long"; break; case V_SgTypeSignedShort: typeName = "signed short"; break; case V_SgTypeString: typeName = "string"; break; case V_SgTypeUnknown: typeName = "unknown"; break; case V_SgTypeUnsignedChar: typeName = "unsigned char"; break; case V_SgTypeUnsignedInt: typeName = "unsigned int"; break; case V_SgTypeUnsignedLong: typeName = "unsigned long"; break; case V_SgTypeUnsignedShort: typeName = "unsigned short"; break; case V_SgTypeUnsignedLongLong: typeName = "unsigned long long"; break; case V_SgReferenceType: { ROSE_ASSERT (isSgReferenceType (type)->get_base_type () != NULL); Rose_STL_Container< string > subTypeNames = queryNameTypeName (isSgReferenceType (type)->get_base_type ()); typedef Rose_STL_Container< string >::iterator typeIterator; //This iterator will only contain one name for (typeIterator i = subTypeNames.begin (); i != subTypeNames.end (); ++i) { string e = *i; typeName = e; break; } break; } case V_SgPointerType: { ROSE_ASSERT (isSgPointerType (type)->get_base_type () != NULL); Rose_STL_Container< string > subTypeNames = queryNameTypeName (isSgPointerType (type)->get_base_type ()); typedef Rose_STL_Container< string >::iterator typeIterator; //This iterator will only contain one name for (typeIterator i = subTypeNames.begin (); i != subTypeNames.end (); ++i) { string e = *i; typeName = e; break; } break; } case V_SgModifierType: { ROSE_ASSERT (isSgModifierType (type)->get_base_type () != NULL); Rose_STL_Container< string > subTypeNames = queryNameTypeName (isSgModifierType (type)->get_base_type ()); typedef Rose_STL_Container< string >::iterator typeIterator; //This iterator will only contain one name for (typeIterator i = subTypeNames.begin (); i != subTypeNames.end (); ++i) { string e = *i; typeName = e; break; } break; } case V_SgNamedType: { SgNamedType *sageNamedType = isSgNamedType (type); ROSE_ASSERT (sageNamedType != NULL); typeName = sageNamedType->get_name ().str (); break; } case V_SgClassType: { SgClassType *sageClassType = isSgClassType (type); ROSE_ASSERT (sageClassType != NULL); typeName = sageClassType->get_name ().str (); break; } case V_SgTypedefType: { SgTypedefType *sageTypedefType = isSgTypedefType (type); ROSE_ASSERT (sageTypedefType != NULL); typeName = sageTypedefType->get_name ().str (); break; } case V_SgPointerMemberType: { SgPointerMemberType *pointerMemberType = isSgPointerMemberType (type); ROSE_ASSERT (pointerMemberType != NULL); SgClassType *classType = isSgClassType(pointerMemberType->get_class_type()->stripTypedefsAndModifiers()); ROSE_ASSERT (classType != NULL); SgClassDeclaration *classDeclaration = isSgClassDeclaration(classType->get_declaration()); ROSE_ASSERT (classDeclaration != NULL); typeName = classDeclaration->get_name ().str (); break; } case V_SgArrayType: { ROSE_ASSERT (isSgArrayType (type)->get_base_type () != NULL); Rose_STL_Container< string > subTypeNames = queryNameTypeName (isSgArrayType (type)->get_base_type ()); typedef Rose_STL_Container< string >::iterator typeIterator; //This iterator will only contain one name for (typeIterator i = subTypeNames.begin (); i != subTypeNames.end (); ++i) { string e = *i; typeName = e; break; } break; } case V_SgFunctionType: { SgFunctionType *functionType = isSgFunctionType (type); ROSE_ASSERT (functionType != NULL); typeName = functionType->get_mangled_type ().str (); break; } case V_SgMemberFunctionType: { SgMemberFunctionType *memberFunctionType = isSgMemberFunctionType (type); ROSE_ASSERT (memberFunctionType != NULL); SgClassType *classType = isSgClassType(memberFunctionType->get_class_type()->stripTypedefsAndModifiers()); ROSE_ASSERT (classType != NULL); SgClassDeclaration *classDeclaration = isSgClassDeclaration(classType->get_declaration()); ROSE_ASSERT (classDeclaration != NULL); typeName = classDeclaration->get_name ().str (); break; } case V_SgTypeWchar: typeName = "wchar"; break; case V_SgTypeDefault: typeName = "default"; break; default: printf ("default reached in switch within TransformationSupport::getTypeName type->sage_class_name() = %s variant = %d \n", type->sage_class_name (), type->variant ()); ROSE_ABORT (); break; } // Fix for purify problem report // typeName = ROSE::stringDuplicate(typeName); if (typeName.size () > 0) returnList.push_back (typeName); //ROSE_ASSERT(typeName.c_str() != NULL); // return typeName; return returnList; //return ROSE::stringDuplicate(typeName.c_str()); }
Rose_STL_Container<string> CommandlineProcessing::generateSourceFilenames ( Rose_STL_Container<string> argList, bool binaryMode ) { Rose_STL_Container<string> sourceFileList; Rose_STL_Container<string>::iterator i = argList.begin(); // skip the 0th entry since this is just the name of the program (e.g. rose) ROSE_ASSERT(argList.size() > 0); i++; int counter = 0; while ( i != argList.end() ) { // Count up the number of filenames (if it is ZERO then this is likely a // link line called using the compiler (required for template processing // in C++ with most compilers)) if there is at least ONE then this is the // source file. Currently their can be up to maxFileNames = 256 files // specified. // most options appear as -<option> // have to process +w2 (warnings option) on some compilers so include +<option> // DQ (1/5/2008): Ignore things that would be obvious options using a "-" or "+" prefix. // if ( ((*i)[0] != '-') || ((*i)[0] != '+') ) if ( ((*i)[0] != '-') && ((*i)[0] != '+') ) { // printf ("In CommandlineProcessing::generateSourceFilenames(): Look for file names: argv[%d] = %s length = %" PRIuPTR " \n",counter,(*i).c_str(),(*i).size()); // bool foundSourceFile = false; if ( isSourceFilename(*i) == false && isExecutableFilename(*i) == true ) { // printf ("This is an executable file: *i = %s \n",(*i).c_str()); // executableFileList.push_back(*i); sourceFileList.push_back(*i); } // PC (4/27/2006): Support for custom source file suffixes // if ( isSourceFilename(*i) ) if ( isObjectFilename(*i) == false && isSourceFilename(*i) == true ) { // printf ("This is a source file: *i = %s \n",(*i).c_str()); // foundSourceFile = true; sourceFileList.push_back(*i); } #if 0 if ( isObjectFilename(*i) ) { objectFileList.push_back(*i); } #endif } // DQ (12/8/2007): Looking for rose options that take filenames that would accidentally be considered as source files. if (isOptionTakingFileName(*i) == true) { // Jump over the next argument when such options are identified. counter++; i++; } counter++; i++; } return sourceFileList; }
// Static function (interface function) ArrayAssignmentStatementQuerySynthesizedAttributeType ArrayAssignmentStatementTransformation::transformation( const ArrayStatementQueryInheritedAttributeType & X, SgNode* astNode) { #if DEBUG printf (" Top of ArrayAssignmentStatementTransformation::transformation \n"); #endif // This function returns the string representing the array statement transformation ROSE_ASSERT (isSgExprStatement(astNode) != NULL); // Pass in the ArrayStatementQueryInheritedAttributeType object so // that all previously visited scopes can be copied to the new // inherited attribute. ArrayAssignmentStatementQueryInheritedAttributeType arrayAssignmentStatementQueryInheritedData(X, astNode); list<int> & transformationOptions = arrayAssignmentStatementQueryInheritedData.getTransformationOptions(); // Find all the hints specified as enum values constructor parameters for declarations of // variables of type "TransformationAssertion". The current scope and all parent scopes are // searched back to the global scope. (Maybe this should return a value rather than modify a // reference parameter???) TransformationSupport::getTransformationOptions(astNode, transformationOptions, "TransformationAssertion"); #if DEBUG printf(" In ArrayAssignmentStatementTransformation::transformation (Need to handle indexObjectNameStringList) "); #endif // Generate a list of names of variables of type InternalIndex // Kamal (07/21/2011) Check later to see if the list is still needed Rose_STL_Container < string > indexObjectNameStringList = NameQuery::querySubTree(astNode, "InternalIndex", NameQuery::VariableNamesWithTypeName); // Now use STL to build a list of unique names //indexObjectNameStringList.unique(); // If Index objects are used in the array statement then we want to use special indexing based // substript computation and we need to communicate this to all phases of the transformation // (through use of an inherited attribute!). // ROSE_ASSERT (arrayAssignmentStatementQueryInheritedData.getUsingIndexObjectsInSubscriptComputation() == FALSE); if (indexObjectNameStringList.size() > 0) arrayAssignmentStatementQueryInheritedData.setUsingIndexObjectsInSubscriptComputation(true); else arrayAssignmentStatementQueryInheritedData.setUsingIndexObjectsInSubscriptComputation(false); // The dimension of the array statement must be computed on the way down (in the traversal of the AST). // This query gets the list of integer associated with the dimension of each array operand (array // operands using the doubleArray::operator() member function). #if DEBUG cout << " Checking queryNumberOfArgsInParenthesisOperator " << astNode->unparseToString() << astNode->class_name() << " Variant: " << astNode->variantT() << " " << V_SgExprListExp << " " << V_SgFunctionCallExp << endl; #endif vector<SgFunctionCallExp*> functionExpList = querySubTree<SgFunctionCallExp>(astNode, V_SgFunctionCallExp); SgFunctionCallExp* functionCall; Rose_STL_Container<int> operandDimensionList; for (vector<SgFunctionCallExp*>::iterator iter = functionExpList.begin(); iter != functionExpList.end(); iter++) { string operatorName = TransformationSupport::getFunctionName(*iter); #if DEBUG cout << " Arg List Size: " << (*iter)->get_args()->get_expressions().size() << " " << TransformationSupport::getFunctionName ( *iter ) << endl; #endif if (operatorName == "operator()") { operandDimensionList.push_back((*iter)->get_args()->get_expressions().size()); break; } } #if DEBUG printf(" operandDimensionList size : %d \n", operandDimensionList.size()); #endif // If there is no dimension computed for the query then it means that there were no operator() // used in which case we have to assume 6D array operations int dimensionOfArrayStatement = (operandDimensionList.size() == 0) ? 6 : *(operandDimensionList.begin()); #if DEBUG printf("Array statement is %d dimensional \n", dimensionOfArrayStatement); printf("arrayAssignmentStatementQueryInheritedData.arrayStatementDimension = %d \n", arrayAssignmentStatementQueryInheritedData.arrayStatementDimension); #endif // Make sure that it has the default value before we change it (error checking) ROSE_ASSERT (arrayAssignmentStatementQueryInheritedData.arrayStatementDimension == -1); // Modify the inherited attribute using the array statement dimension data arrayAssignmentStatementQueryInheritedData.arrayStatementDimensionDefined = TRUE; arrayAssignmentStatementQueryInheritedData.arrayStatementDimension = dimensionOfArrayStatement; #if DEBUG printf("(after search for array statement dimension = %d) ... \n", dimensionOfArrayStatement); #endif // Build a transformation object so we can setup the accumulatorValue which is not a static data // member. Other transformations which don't use an accumulatorValue attribute don't require this // step. ArrayAssignmentStatementTransformation transformation; // Build a return value for the transformation function ArrayAssignmentStatementQuerySynthesizedAttributeType returnArrayStatementTransformation(astNode); // WARNING: It is a design problem that we have the dimension set in two locations // Set the dimension of the array statement in the array operand database transformation.accumulatorValue.operandDataBase.setDimension(dimensionOfArrayStatement); ROSE_ASSERT (transformation.accumulatorValue.operandDataBase.getDimension() > 0); // Setup the data base with the options specified by the use and extracted from the current scope // of the application code. transformation.accumulatorValue.operandDataBase.setUserOptimizationAssertions( arrayAssignmentStatementQueryInheritedData.transformationOptions); ROSE_ASSERT ( transformation.accumulatorValue.operandDataBase.transformationOption > ArrayTransformationSupport::UnknownIndexingAccess ); // Make sure the data base has been setup properly ROSE_ASSERT ( transformation.accumulatorValue.operandDataBase.transformationOption > ArrayTransformationSupport::UnknownIndexingAccess ); ROSE_ASSERT ( transformation.accumulatorValue.operandDataBase.dimension > -1 ); // Call the tree traversal mechanism (tree walker) returnArrayStatementTransformation = transformation.traverse(astNode, arrayAssignmentStatementQueryInheritedData); #if DEBUG printf ("(after ASSIGNMENT TRANSFORMATION QUERY) ... \n"); #endif return returnArrayStatementTransformation; }
void instantiateTemplates ( SgProject* project ) { // DQ (7/12/2005): Introduce tracking of performance of ROSE. TimingPerformance timer ("AST Object Code Generation (instantiateTemplates): time (sec) = "); // DQ (9/6/2005): I think these operations have been superseded // by the AST post processing mechanism which is more complete. printf ("In instantiateTemplates(): I think this may be dead code! \n"); ROSE_ASSERT(false); // After compilation we can start the process of template instantiation // 1) Compiling to object files (building *.ti files) // a) build *.ti files (call instantiateTemplates() function) // 2) Linking // a) call prelink utility // * builds instantiation information (*.ii files) // * calls compilation step to force instantiation (using info in *.ii files) // * calls prelink utility iteratively // b) call g++ to do final linking with all templates resolved ROSE_ASSERT (project != NULL); // printf ("In instantiateTemplates(project = %p) \n",project); #if 1 // *********************** // Calling prelink utility // *********************** // printf ("Calling prelink utility ... \n"); Rose_STL_Container<string> sourceFilenameList = project->get_sourceFileNameList(); ROSE_ASSERT (sourceFilenameList.size() <= 1); if ( project->get_prelink() == false ) { Rose_STL_Container<string> objectFilenameList = project->get_objectFileNameList(); string prelinkOptions = "-v -d9 -i "; string objectFiles; Rose_STL_Container<string> argList; if ( (sourceFilenameList.size() == 1) && (objectFilenameList.size() == 0) ) { printf ("Handling (debugging) single file case of template instantiation \n"); Rose_STL_Container<string>::iterator fileIndex = sourceFilenameList.begin(); ROSE_ASSERT (sourceFilenameList.size() == 1); string filenameWithPath = *fileIndex; string filename = Rose::utility_stripPathFromFileName(filenameWithPath.c_str()); int filenameLength = filename.length(); printf ("In instantiateTemplates(): filename = %s \n",filename.c_str()); // This would not handle a foo.cpp file name (with ".cpp" as a suffix), I think string nameWithoutSuffix = filename.substr(0,filenameLength-2); #if 0 objectFiles = nameWithoutSuffix + ".o"; #else // Make the prelink phase operate on a rose_<file name>.o file and fix // the object file name generated by the vendor compiler (to generate // the same file name). objectFiles = string("rose_") + nameWithoutSuffix + ".o"; #endif printf ("In instantiateTemplates(): objectFiles = %s \n",objectFiles.c_str()); // DQ (9/25/2007): This is the first element to be put into the list, so we can use push_back() inplace of push_front(). // argList.push_front(objectFiles); argList.push_back(objectFiles); } else { // linking only (this processing is different than that of a single file) // Debug the single file case before addressing multiple files required // for link only processing. printf ("Linking only, template instantiation stil being debugged (similar to single file case) \n"); // ROSE_ASSERT (false); objectFiles = CommandlineProcessing::generateStringFromArgList(project->get_objectFileNameList()); argList = project->get_objectFileNameList(); } // DQ (1/13/2005): // We could check to make sure there are valid *.ti (template instantiation files) associated with the objectFiles // if not then calling "edg_prelink" will cause an error. But it is not required! It is not an error for edg_prelink // to not find a corresponding *.ti file for each object file! // printf ("Check for corresponding template instantiation files: objectFiles = %s \n",objectFiles.c_str()); // Build the command line to execute the edg_prelink utility // (user's path must include location of edg_prelink utility). string prelinkCommandLine = "edg_prelink " + prelinkOptions + objectFiles; #if 0 printf ("\n\n"); printf ("######################################### \n"); printf ("######################################### \n"); printf ("######################################### \n"); printf ("prelinkCommandLine = %s \n",prelinkCommandLine.c_str()); printf ("######################################### \n"); printf ("######################################### \n"); printf ("######################################### \n"); printf ("\n\n"); printf ("Print out rose_test2005_74.C (before prelink) \n"); system("cat /home/dquinlan2/ROSE/LINUX-3.3.2/developersScratchSpace/Dan/rose_test2005_74.C"); #endif int argc = 0; char** argv = NULL; // Add the commandline parameters as separate strings (in reverse order) // argList.push_front(" -i "); // argList.push_front(" -d9 "); // argList.push_front(" -a 0 "); // DQ (9/25/2007): Move from std::list to std::vector. // argList.push_front(" -v "); argList.insert(argList.begin()," -v "); // Separate list out into form traditional argc and argv form parameters CommandlineProcessing::generateArgcArgvFromList (argList,argc,argv); printf ("Calling generateArgcArgvFromList: argc = %d compressed argList = %s \n", argc,CommandlineProcessing::generateStringFromArgList(argList).c_str()); // Declaration of prelink_main() function int prelink_main(int argc, char *argv[]); printf ("############### Before call to prelink_main ... ################ \n"); // Use original interface (from when it was a command line utility! prelink_main(argc,argv); printf ("############### After call to prelink_main ... ################ \n"); // ROSE_ASSERT(false); } else { // printf ("############### Prelink option specified (exited compilation!) ################ \n"); } // printf ("Print out rose_test2004_18.C (after prelink) \n"); // system("cat /home/dquinlan2/ROSE/LINUX-3.3.2/dqDevelopmentDirectory/rose_test2004_18.C"); #else printf ("Skipping calls to iterative prelink utility ... \n"); #endif #if 0 printf ("Exiting after handling newly instantiated code! \n"); ROSE_ASSERT (false); #endif }
result_type operator()(SgNode* node ) const { Rose_STL_Container<SgNode*> returnList; returnList.push_back(node); return returnList; }
void Compass::commandLineProcessing(Rose_STL_Container<std::string> & commandLineArray) { // printf ("Preprocessor (before): argv = \n%s \n",StringUtility::listToString(commandLineArray).c_str()); // Add option to force EDG warnings and errors to be put onto a single line. This helps // Flymake present the message in Emacs when using the connection of Compass to Emacs. // commandLineArray.push_back("--edg:remarks"); // commandLineArray.push_back("--edg:brief_diagnostics"); commandLineArray.push_back("--edg:no_wrap_diagnostics"); commandLineArray.push_back("--edg:display_error_number"); #if 1 // We need these to exclude the C++ header files that don't have ".h" suffix extensions. // Exclude reporting Compass errors from specific paths or header files // These have to be entered as two separate options // For more details on Flymake: /nfs/apps/emacs/22.1/share/emacs/22.1/lisp/progmodes/ commandLineArray.push_back("-rose:excludePath"); commandLineArray.push_back("/include/g++_HEADERS/"); commandLineArray.push_back("-rose:excludePath"); commandLineArray.push_back("/usr/include/"); commandLineArray.push_back("-rose:excludePath"); commandLineArray.push_back("/tests/CompileTest/"); #endif // commandLineArray.push_back("-rose:excludePath"); // commandLineArray.push_back("/home/dquinlan/ROSE/NEW_ROSE/"); // Skip header files (but only works on non-C++ standard header files with ".h" commandLineArray.push_back("-rose:excludeFile"); commandLineArray.push_back(".h"); // Add a test for a custom command line option if ( CommandlineProcessing::isOption(commandLineArray,"--compass:"******"(s|silent)",true) ) { // printf ("Setting Compass silent mode to ON \n"); Compass::verboseSetting = -1; } if ( CommandlineProcessing::isOption(commandLineArray,"--compass:"******"(warnings)",true) ) { // Turn EDG warnings on Compass::compilerWarnings = true; } else { // Turn EDG warnings off Compass::compilerWarnings = false; commandLineArray.push_back("--edg:no_warnings"); } if ( CommandlineProcessing::isOption(commandLineArray,"--compass:"******"(remarks)",true) ) { // Turn EDG remarks on Compass::compilerRemarks = true; commandLineArray.push_back("--edg:remarks"); } else { // Turn EDG remarks off Compass::compilerRemarks = false; } int integerOptionForVerboseMode = 0; if ( CommandlineProcessing::isOptionWithParameter(commandLineArray,"--compass:"******"(v|verbose)",integerOptionForVerboseMode,true) ) { printf ("Setting Compass verbose mode to ON (set to %d) \n",integerOptionForVerboseMode); Compass::verboseSetting = integerOptionForVerboseMode; } // Flymake option if ( CommandlineProcessing::isOption(commandLineArray,"--compass:"******"(flymake)",true) ) { // printf ("Setting Compass flymake mode to ON \n"); Compass::UseFlymake = true; } // This is the ToolGear Option const bool remove = true; // std::vector<std::string> argvList = CommandlineProcessing::generateArgListFromArgcArgv(argc, argv); // if ( CommandlineProcessing::isOptionWithParameter( argvList, std::string("--tgui"), std::string("*"), tguiXML, remove ) ) if ( CommandlineProcessing::isOptionWithParameter( commandLineArray, std::string("--tgui"), std::string("*"), tguiXML, remove ) ) { Compass::UseToolGear = true; } if ( CommandlineProcessing::isOptionWithParameter( commandLineArray, std::string("--outputDb"), std::string("*"), outputDbName, remove ) ) { #ifdef HAVE_SQLITE3 Compass::UseDbOutput = true; con.open(outputDbName.c_str()); #else std::cerr << "Compile ROSE with --with-sqlite3 to enable the --outputDb option " << std::endl; abort(); #endif } // Adding a new command line parameter (for mechanisms in ROSE that take command lines) // printf ("commandLineArray.size() = %zu \n",commandLineArray.size()); // printf ("Preprocessor (after): argv = \n%s \n",StringUtility::listToString(commandLineArray).c_str()); }
Rose_STL_Container<string> CommandlineProcessing::generateOptionWithNameParameterList ( Rose_STL_Container<string> & argList, string inputPrefix , string newPrefix ) { // This function returns a list of options using the inputPrefix (with the // inputPrefix stripped off and replaced if new Prefix is provided. // It also modified the input argList to remove matched options. Rose_STL_Container<string> optionList; Rose_STL_Container<string> deleteList; int prefixLength = inputPrefix.length(); Rose_STL_Container<string>::iterator it = argList.begin(); while (it != argList.end()) { if ( it->substr(0,prefixLength) == inputPrefix ) { // get the rest of the string as the option optionList.push_back( (newPrefix == "") ? it->substr(prefixLength) : newPrefix + it->substr(prefixLength)); it = argList.erase(it); // That sounds real buggy as to detect if an option has parameters it // assumes inputPrefix-ed options are consecutive. if ( it->substr(0,prefixLength) != inputPrefix ) { optionList.push_back(*it); it = argList.erase(it); #if 0 // DQ (1/25/2017): Comment this out as a test of C file command line generation to EDG. // DQ (1/21/2017): Adding support for options taking more than one paramter. if (isOptionTakingThirdParameter(inputPrefix) == true) { if ( it->substr(0,prefixLength) != inputPrefix ) { optionList.push_back(*it); it = argList.erase(it); } else { printf ("Error: missing 2nd parameter in option with two parameters \n"); ROSE_ABORT(); } #if 0 printf ("Need to handle options taking more than one parameter (e.g. --edg_parameter:): inputPrefix = %s \n",inputPrefix.c_str()); ROSE_ASSERT(false); #endif } #endif } else { printf ("Error: missing parameter in option with parameter \n"); ROSE_ABORT(); } } else { ++it; } } return optionList; }