示例#1
0
        virtual void visit(SgNode *n)
        {
            SgDeclarationStatement *st = isSgDeclarationStatement(n);
            if (!st)
            {
                return;
            }
            if (!isRecognizedDeclaration(st))
            {
                return;
            }

            string proto = getProtoName(st);
            SgDeclarationStatement *dxSt = getDoxygenAttachedDeclaration(st);

            if ((*symTab)[proto].count(dxSt) == 0)
            {
                DoxygenCommentListAttribute *attr = new DoxygenCommentListAttribute();
                // King84 (2010.08.03) : This seems to be called with the same node multiple times.
                // From what I can tell, this is because a single function has been documented multiple times.
                // At the moment this function is AssemblerX86::AssemblerX86() from src/frontend/Disassemblers/AssemblerX86.h
                // For now, we will print out a warning and use the new documentation (instead of addNewAttribute we use setAttribute).
                if (dxSt->attributeExists("DoxygenCommentList"))
                {
                    std::cerr << "Warning: Multiple Doxygen comments found for function " << dxSt->get_mangled_name().getString() << " at file " << dxSt->get_file_info()->get_filenameString() << ":" << dxSt->get_file_info()->get_line() << "," << dxSt->get_file_info()->get_col() << ".  Picking the last." << std::endl;
                }
                dxSt->setAttribute("DoxygenCommentList", attr);
//                      dxSt->addNewAttribute("DoxygenCommentList", attr);
                (*symTab)[proto][dxSt] = &(attr->commentList);
            }
            list<DoxygenComment *> *commentList = (*symTab)[proto][dxSt];

            AttachedPreprocessingInfoType *info = st->getAttachedPreprocessingInfo();
            if (info)
            {
                for (AttachedPreprocessingInfoType::iterator i = info->begin(); i != info->end(); ++i)
                {
                    PreprocessingInfo *pi = *i;
                    if (pi->getRelativePosition() == PreprocessingInfo::before && DoxygenComment::isDoxygenComment(pi))
                    {
                        commentList->push_back(new DoxygenComment(st, pi));
                    }
                }
            }
        }
// void FixupTemplateArguments::visit ( SgNode* node )
void
FixupTemplateArguments::processTemplateArgument ( SgTemplateArgument* templateArgument, SgScopeStatement* targetScope )
   {
  // ROSE_ASSERT(node != NULL);
     ROSE_ASSERT(templateArgument != NULL);

#if DEBUGGING_USING_RECURSIVE_DEPTH
  // For debugging, keep track of the recursive depth.
     printf ("In FixupTemplateArguments::visit: global_depth = %zu \n",global_depth);
     ROSE_ASSERT(global_depth < 50);
#endif

  // DQ (2/11/2017): Change this traversal to not use memory pools.
  // SgTemplateArgument* templateArgument = isSgTemplateArgument(node);
     ROSE_ASSERT(templateArgument != NULL);

#if DEBUGGING_USING_RECURSIVE_DEPTH
     global_depth++;
#endif

     bool result = contains_private_type(templateArgument,targetScope);

#if DEBUGGING_USING_RECURSIVE_DEPTH
     global_depth--;
#endif

     if (result == true)
        {
       // This type will be a problem to unparse, because it contains parts that are private (or protected).
#if DEBUG_VISIT_PRIVATE_TYPE
          printf ("\n\nWARNING: This template parameter can NOT be unparsed (contains references to private types): templateArgument = %p = %s \n",templateArgument,templateArgument->unparseToString().c_str());
          SgNode* parent = templateArgument->get_parent();
          SgDeclarationStatement* parentDeclaration = isSgDeclarationStatement(parent);
          if (parentDeclaration != NULL)
             {
               if (parentDeclaration->get_file_info() != NULL)
                  {
#if 0
                    parentDeclaration->get_file_info()->display("location of parent non-defining declaration using templateArgument: debug");
                    SgDeclarationStatement* parentDefiningDeclaration = isSgDeclarationStatement(parentDeclaration->get_definingDeclaration());
                    if (parentDefiningDeclaration != NULL)
                       {
                         parentDefiningDeclaration->get_file_info()->display("location of parent defining declaration using templateArgument: debug");
                       }
#endif
                  }
             }
            else
             {
               if (parent->get_file_info() != NULL)
                  {
#if 0
                    parent->get_file_info()->display("location of parent node using templateArgument: debug");
#endif
                  }
             }
#endif
        }
       else
        {
       // This type is fine to unparse
#if DEBUG_PRIVATE_TYPE
          printf ("Template parameter CAN be unparsed (no private types) \n\n");
#endif
        }
   }