Пример #1
0
void
FixupTemplateArguments::visit ( SgNode* node )
   {
     ROSE_ASSERT(node != NULL);

     SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(node);
     if (variableDeclaration != NULL)
        {
       // Check the type of the variable declaration, and any template arguments if it is a template type with template arguments.
       // SgType* type = variableDeclaration->get_type();
       // ROSE_ASSERT(type != NULL);
          SgInitializedName* initializedName = SageInterface::getFirstInitializedName(variableDeclaration);
          ROSE_ASSERT(initializedName != NULL);
          SgType* type = initializedName->get_type();
          ROSE_ASSERT(type != NULL);
#if 0
          printf ("\n**************************************************************************** \n");
          printf ("FixupTemplateArguments::visit(): variableDeclaration = %p = %s initializedName = %s \n",variableDeclaration,variableDeclaration->class_name().c_str(),initializedName->get_name().str());
          printf ("   --- type = %p = %s \n",type,type->class_name().c_str());
          string filename = initializedName->get_file_info()->get_filename();
          int linenumber  = initializedName->get_file_info()->get_line();
          printf ("   --- filename = %s line = %d \n",filename.c_str(),linenumber);
#endif
          SgScopeStatement* targetScope = variableDeclaration->get_scope();
          ROSE_ASSERT(targetScope != NULL);
#if 0
          printf ("In FixupTemplateArguments::visit(): targetScope for variableDeclaration = %p = %s \n",targetScope,targetScope->class_name().c_str());
#endif

       // DQ (2/16/2017): Don't process code in template instantiations.
          SgTemplateInstantiationDefn*               templateInstantiationDefn              = isSgTemplateInstantiationDefn(targetScope);
          SgFunctionDeclaration*                     functionDeclaration                    = TransformationSupport::getFunctionDeclaration(targetScope);
          SgTemplateInstantiationFunctionDecl*       templateInstantiationFunctionDec       = isSgTemplateInstantiationFunctionDecl(functionDeclaration);
          SgTemplateInstantiationMemberFunctionDecl* templateInstantiationMemberFunctionDec = isSgTemplateInstantiationMemberFunctionDecl(functionDeclaration);
       // if (templateInstantiationDefn == NULL)
          if (templateInstantiationDefn == NULL && templateInstantiationFunctionDec == NULL && templateInstantiationMemberFunctionDec == NULL)
             {
#if 1
            // DQ (2/15/2017): When this is run, we cause transformations that cause ROSE to have an infinte loop.
            // Since this is a second (redundant) invocaion, we likely should just not run this.  But it is not 
            // clear if this truely fixes the problem that I am seeing.
               bool result = contains_private_type(type,targetScope);

            // DQ (3/25/2017): Added a trivial use to eliminate Clang warning about the return value not being used.
            // But it might be that we should not run the function, however this is a complex subject from last month 
            // that I don't wish to revisit at the moment while being focused om eliminating warnings from Clang.
               ROSE_ASSERT(result == true || result == false);
#endif
#if 0
               if (result == true)
                  {
                    printf ("******** contains private type: variableDeclaration = %p = %s initializedName = %s \n",variableDeclaration,variableDeclaration->class_name().c_str(),initializedName->get_name().str());
                  }
#endif
             }
#if 0
          printf ("DONE: FixupTemplateArguments::visit(): variableDeclaration = %p = %s initializedName = %s \n",variableDeclaration,variableDeclaration->class_name().c_str(),initializedName->get_name().str());
#endif
#if 0
          printf ("Exiting as a test! \n");
          ROSE_ASSERT(false);
#endif
        }
   }
void
visitorTraversal::visit (SgNode * n)
{
  ROSE_ASSERT (n != NULL);
  switch (n->variantT())
  { 
    //some of  SgScopeStatement
    case V_SgGlobal:
    case V_SgBasicBlock:
    case V_SgNamespaceDefinitionStatement:
    case V_SgClassDefinition:
    case V_SgFunctionDefinition:
    case V_SgTemplateInstantiationDefn:
      {
        GET_QUALIFIED_NAME(ScopeStatement)
        break;
      }
      //Some of SgDeclarationStatement
    case V_SgFunctionDeclaration:
      {
        GET_QUALIFIED_NAME(FunctionDeclaration)
        break;
      }
    case V_SgClassDeclaration:
      {
        GET_QUALIFIED_NAME(ClassDeclaration)
        break;
      }  
    case V_SgEnumDeclaration:
      {
        GET_QUALIFIED_NAME(EnumDeclaration)
        break;
      }
    case V_SgNamespaceDeclarationStatement:
      {
        GET_QUALIFIED_NAME(NamespaceDeclarationStatement)
        break;
      }
    case V_SgTemplateDeclaration:
      {
        GET_QUALIFIED_NAME(TemplateDeclaration)
        break;
      }
    case V_SgTemplateInstantiationDecl:
      {
        GET_QUALIFIED_NAME(TemplateInstantiationDecl)
        break;
      }
    case V_SgMemberFunctionDeclaration:
      {
        GET_QUALIFIED_NAME(MemberFunctionDeclaration)
        break;
      }
    case V_SgTypedefDeclaration:
      {
        GET_QUALIFIED_NAME(TypedefDeclaration)
        break;
      }
      // special case here 
    case V_SgVariableDeclaration:
      {
        SgVariableDeclaration * target = isSgVariableDeclaration(n);
        SgQualifiedNamePtrList & n_list = target-> get_qualifiedNameList ();
        SgQualifiedNamePtrList::const_iterator iter = n_list.begin();
        for (; iter!=n_list.end(); iter++)
        {
          SgQualifiedName * q_name = *iter;
          ROSE_ASSERT (q_name != NULL);
          cout<< target->class_name()<<endl;
          cout<<"\tunparsed string is "<< target->unparseToString()<<endl;
        }
        break;
      }
      //Others   
    case V_SgInitializedName:
      {
        GET_QUALIFIED_NAME(InitializedName)
        break;
      }
    case V_SgNamedType:
      {
        GET_QUALIFIED_NAME(NamedType)
        break;
      }
    default:
      {
        break;
      }
  } // end switch
}