Esempio n. 1
0
 void virtual visit (SgNode* n)
 {
   if (isSgProject(n)|| isSgSourceFile(n)||isSgInitializedName(n)||isSgLocatedNode(n))
   {
    setId (n);
   }
 }
Esempio n. 2
0
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) );
        }
      }
    }
  }


}
Esempio n. 3
0
 virtual void addOutput(Compass::OutputViolationBase* theOutput)
    {
      ROSE_ASSERT( isSgLocatedNode(theOutput->getNode()) != NULL 
          || isSgFile(theOutput->getNode()) != NULL );
      outputList.push_back(theOutput);
      printf ("In QRoseOutputObject::addOutput(): getString() = %s \n",theOutput->getString().c_str());
    }
Esempio n. 4
0
// This function is not requied since the base class function is available and is preferred (for conformity).
std::string
CompassAnalyses::FunctionDefinitionPrototype::CheckerOutput::getString() const
{
     ROSE_ASSERT(getNodeArray().size() <= 1);

  // Default implementation for getString
     SgLocatedNode* locatedNode = isSgLocatedNode(getNode());
     std::string sourceCodeLocation;
     if (locatedNode != NULL)
        {
          Sg_File_Info* start = locatedNode->get_startOfConstruct();
          Sg_File_Info* end   = locatedNode->get_endOfConstruct();
          sourceCodeLocation = (end ? Compass::formatStandardSourcePosition(start, end) 
                                    : Compass::formatStandardSourcePosition(start));
       }
      else
       {
      // Else this could be a SgInitializedName or SgTemplateArgument (not yet moved to be a SgLocatedNode)
         Sg_File_Info* start = getNode()->get_file_info();
         ROSE_ASSERT(start != NULL);
         sourceCodeLocation = Compass::formatStandardSourcePosition(start);
       }

     std::string nodeName = getNode()->class_name();

  // The short description used here needs to be put into a separate function (can this be part of what is filled in by the script?)
  // return loc + ": " + nodeName + ": variable requiring static constructor initialization";

     return m_checkerName + ": " + sourceCodeLocation + ": " + nodeName + ": " + m_shortDescription + ".\n\"" + what + "\" does not have a prototype";
} //CompassAnalyses::FunctionDefinitionPrototype::CheckerOutput::getString()
 bool IsNodeNotInUserLocation(const SgNode* node)
 {
   const SgLocatedNode* located_node = isSgLocatedNode(node);
   if (located_node != NULL)
   {
     return !Compass::IsNodeInUserLocation(
         located_node, FunctionWithMultipleReturns::source_directory);
   } else {
     return true;
   }
 };
Esempio n. 6
0
 bool IsNodeNotInUserLocation(const SgNode* node)
 {
     const SgLocatedNode* located_node = isSgLocatedNode(node);
     if (located_node != NULL)
     {
         return ! Compass::IsNodeInUserLocation(
                     located_node,
                     DoNotDeleteThis::source_directory);
     }
     else
     {
         return true;
     }
 };
bool IsNodeNotInUserLocation(const SgNode* node)
{
  const SgLocatedNode* located_node = isSgLocatedNode(node);
  if (located_node != NULL)
  {
    return ! Compass::IsNodeInUserLocation(
        located_node,
        AllocateAndFreeInTheSameModule::source_directory);
  }
  else
  {
    return true;
  }
};
 bool IsNodeNotInUserLocation(const SgNode* node)
 {
     const SgLocatedNode* located_node = isSgLocatedNode(node);
     if (located_node != NULL)
     {
         return ! Compass::IsNodeInUserLocation(
                     located_node,
                     ByteByByteStructureComparison::source_directory);
     }
     else
     {
         return true;
     }
 };
 bool IsNodeNotInUserLocation(const SgNode* node)
 {
   const SgLocatedNode* located_node = isSgLocatedNode(node);
   if (located_node != NULL)
   {
     return ! Compass::IsNodeInUserLocation(
         located_node,
         FloatingPointExactComparison::source_directory);
   }
   else
   {
     return true;
   }
 };
Esempio n. 10
0
FindSmallestStatementsInh
FindSmallestStatements::evaluateInheritedAttribute(SgNode* n, FindSmallestStatementsInh inheritedAttribute)
{



  //If the node should be consired as a topmost node
  if(inheritedAttribute.inSubtreeOfStatement == false && isSgLocatedNode(n))
  {

    Sg_File_Info*  thisNodePos = n->get_file_info();
#if 0

    std::string pos;
    thisNodePos->display(pos);

    std::cerr  << "************************\n";
    std::cerr << "NodePosDisp " << n->class_name() << pos <<  std::endl;
    std::cerr  << "************************\n";

#endif
    //If positions are the same add to list of statements
    switch(n->variantT())
    {
      case V_SgExprStatement:
        std::cout << "Skipping this node" << std::endl;
        break;
      default:
        {
          if( macroCallInfo->get_file_id() == thisNodePos->get_file_id() &&
              macroCallInfo->get_line()    == thisNodePos->get_line()    &&
              macroCallInfo->get_col()     == thisNodePos->get_col()
            )
          {
            if( find_all == false )
              inheritedAttribute.inSubtreeOfStatement = true;
            matchingCalls.push_back(n);
          }
          break;
        }


    }


  }

  return inheritedAttribute;
}
Esempio n. 11
0
NextPreprocessorToInsert * PreprocessorInserter::evaluateInheritedAttribute(SgNode * astNode, NextPreprocessorToInsert * inheritedValue) {
    SgLocatedNode * loc_node = isSgLocatedNode(astNode);
    if (loc_node == NULL) return inheritedValue;

    Sg_File_Info * current_pos = loc_node->get_startOfConstruct();

    bool passed_cursor = *current_pos > *(inheritedValue->cursor);

    if (passed_cursor) {
        // TODO insert on inheritedValue->candidat
        return inheritedValue->next();
    }

    
}
Esempio n. 12
0
 source_position roseNode::getEndPos() const
 {
   source_position pos; 
   ROSE_ASSERT(mNode!=NULL);
   SgLocatedNode* lnode = isSgLocatedNode(mNode);
   if (lnode != NULL)
   {  
     pos.line = lnode->get_endOfConstruct()->get_line();
     pos.column= lnode->get_endOfConstruct()->get_col(); 
   }else
   {
     pos.line=0;
     pos.column=0;
   }
   return pos;
 }
 // Start marking nodes as frontend-specific once we enter an AST that's frontend-specific.
 void preOrderVisit(SgNode *node) {
     SgLocatedNode *located = isSgLocatedNode(node);
     if (located) {
         bool in_fes_ast = fes_ast!=NULL ||
                           is_frontend_specific(located->get_file_info()) ||
                           is_frontend_specific(located->generateMatchingFileInfo()) ||
                           is_frontend_specific(located->get_startOfConstruct()) ||
                           is_frontend_specific(located->get_endOfConstruct());
         if (in_fes_ast) {
             if (!fes_ast)
                 fes_ast = node;
             fix(located, located->get_file_info());
             fix(located, located->generateMatchingFileInfo());
             fix(located, located->get_startOfConstruct());
             fix(located, located->get_endOfConstruct());
         }
     }
 }
Esempio n. 14
0
void ClangToSageTranslator::setCompilerGeneratedFileInfo(SgNode * node, bool to_be_unparse) {
    Sg_File_Info * start_fi = Sg_File_Info::generateDefaultFileInfoForCompilerGeneratedNode();
    Sg_File_Info * end_fi   = Sg_File_Info::generateDefaultFileInfoForCompilerGeneratedNode();

    start_fi->setCompilerGenerated();
    end_fi->setCompilerGenerated();

    if (to_be_unparse) {
        start_fi->setOutputInCodeGeneration();
        end_fi->setOutputInCodeGeneration();
    }

    ROSE_ASSERT(start_fi != NULL && end_fi != NULL);

#if DEBUG_SOURCE_LOCATION
    std::cerr << "Set File_Info for " << node << " of type " << node->class_name() << std::endl;
#endif

    SgLocatedNode * located_node = isSgLocatedNode(node);
    SgInitializedName * init_name = isSgInitializedName(node);

    if (located_node == NULL && init_name == NULL) {
        std::cerr << "Consistency error: try to set a Sage node which is not a SgLocatedNode or a SgInitializedName as compiler generated" << std::endl;
        exit(-1);
    }
    else if (located_node != NULL) {
        Sg_File_Info * fi = located_node->get_startOfConstruct();
        if (fi != NULL) delete fi;
        fi = located_node->get_endOfConstruct();
        if (fi != NULL) delete fi;

        located_node->set_startOfConstruct(start_fi);
        located_node->set_endOfConstruct(end_fi);
    }
    else if (init_name != NULL) {
        Sg_File_Info * fi = init_name->get_startOfConstruct();
        if (fi != NULL) delete fi;
        fi = init_name->get_endOfConstruct();
        if (fi != NULL) delete fi;

        init_name->set_startOfConstruct(start_fi);
        init_name->set_endOfConstruct(end_fi);
    }
}
Esempio n. 15
0
  string roseNode::getFileName() const
  {
    string result;
    ROSE_ASSERT(mNode!=NULL);
    // no uniform way to get file name in ROSE
    SgLocatedNode* lnode = isSgLocatedNode(mNode);
    SgSourceFile* sfile = isSgSourceFile(mNode);
    if (lnode)
      result = lnode->getFilenameString();
    else if (sfile)
      result = sfile->getFileName();
    else
    {
      cerr<<"error: unrecognized sage node to get a file name:"
        <<mNode->class_name()<<endl;
      ROSE_ASSERT(false);
    }

    return result;
  }
Esempio n. 16
0
File: unparser.C Progetto: 8l/rose
string globalUnparseToString ( SgNode* astNode, SgUnparse_Info* inputUnparseInfoPointer )
{
  // This global function permits any SgNode (including it's subtree) to be turned into a string

  // DQ (3/2/2006): Let's make sure we have a valid IR node!
     ROSE_ASSERT(astNode != NULL);

     string returnString;

  // all options are now defined to be false. When these options can be passed in
  // from the prompt, these options will be set accordingly.
     bool _auto                         = false;
     bool linefile                      = false;
     bool useOverloadedOperators        = false;
     bool num                           = false;

  // It is an error to have this always turned off (e.g. pointer = this; will not unparse correctly)
     bool _this                         = true;

     bool caststring                    = false;
     bool _debug                        = false;
     bool _class                        = false;
     bool _forced_transformation_format = false;
     bool _unparse_includes             = false;

  // printf ("In globalUnparseToString(): astNode->sage_class_name() = %s \n",astNode->sage_class_name());

     Unparser_Opt roseOptions( _auto,
                               linefile,
                               useOverloadedOperators,
                               num,
                               _this,
                               caststring,
                               _debug,
                               _class,
                               _forced_transformation_format,
                               _unparse_includes );

     int lineNumber = 0;  // Zero indicates that ALL lines should be unparsed

     // Initialize the Unparser using a special string stream inplace of the usual file stream 
     ostringstream outputString;

     SgLocatedNode* locatedNode = isSgLocatedNode(astNode);
     string fileNameOfStatementsToUnparse;
     if (locatedNode == NULL)
        {
       // printf ("WARNING: applying AST -> string for non expression/statement AST objects \n");
          fileNameOfStatementsToUnparse = "defaultFileNameInGlobalUnparseToString";
        }
       else
        {
          ROSE_ASSERT (locatedNode != NULL);

       // DQ (5/31/2005): Get the filename from a traversal back through the parents to the SgFile
       // fileNameOfStatementsToUnparse = locatedNode->getFileName();
       // fileNameOfStatementsToUnparse = rose::getFileNameByTraversalBackToFileNode(locatedNode);
          if (locatedNode->get_parent() == NULL)
             {
            // DQ (7/29/2005):
            // Allow this function to be called with disconnected AST fragments not connected to 
            // a previously generated AST.  This happens in Qing's interface where AST fragements 
            // are built and meant to be unparsed.  Only the parent of the root of the AST 
            // fragement is expected to be NULL.
               fileNameOfStatementsToUnparse = locatedNode->getFileName();
             }
            else
             {
               fileNameOfStatementsToUnparse = rose::getFileNameByTraversalBackToFileNode(locatedNode);
             }
          
        }
     ROSE_ASSERT (fileNameOfStatementsToUnparse.size() > 0);

     Unparser roseUnparser ( &outputString, fileNameOfStatementsToUnparse, roseOptions, lineNumber );

  // Information that is passed down through the tree (inherited attribute)
  // Use the input SgUnparse_Info object if it is available.
     SgUnparse_Info* inheritedAttributeInfoPointer = NULL;
     if (inputUnparseInfoPointer != NULL)
        {
       // printf ("Using the input inputUnparseInfoPointer object \n");

       // Use the user provided SgUnparse_Info object
          inheritedAttributeInfoPointer = inputUnparseInfoPointer;
        }
       else
        {
       // DEFINE DEFAULT BEHAVIOUR FOR THE CASE WHEN NO inputUnparseInfoPointer (== NULL) IS 
       // PASSED AS ARGUMENT TO THE FUNCTION
       // printf ("Building a new Unparse_Info object \n");

       // If no input parameter has been specified then allocate one
       // inheritedAttributeInfoPointer = new SgUnparse_Info (NO_UNPARSE_INFO);
          inheritedAttributeInfoPointer = new SgUnparse_Info();
          ROSE_ASSERT (inheritedAttributeInfoPointer != NULL);

       // MS: 09/30/2003: comments de-activated in unparsing
          ROSE_ASSERT (inheritedAttributeInfoPointer->SkipComments() == false);

       // Skip all comments in unparsing
          inheritedAttributeInfoPointer->set_SkipComments();
          ROSE_ASSERT (inheritedAttributeInfoPointer->SkipComments() == true);
       // Skip all whitespace in unparsing (removed in generated string)
          inheritedAttributeInfoPointer->set_SkipWhitespaces();
          ROSE_ASSERT (inheritedAttributeInfoPointer->SkipWhitespaces() == true);

       // Skip all directives (macros are already substituted by the front-end, so this has no effect on those)
          inheritedAttributeInfoPointer->set_SkipCPPDirectives();
          ROSE_ASSERT (inheritedAttributeInfoPointer->SkipCPPDirectives() == true);
        }

     ROSE_ASSERT (inheritedAttributeInfoPointer != NULL);
     SgUnparse_Info & inheritedAttributeInfo = *inheritedAttributeInfoPointer;

  // Turn ON the error checking which triggers an error if the default SgUnparse_Info constructor is called
  // SgUnparse_Info::forceDefaultConstructorToTriggerError = true;

#if 1
  // DQ (10/19/2004): Cleaned up this code, remove this dead code after we are sure that this worked properly
  // Actually, this code is required to be this way, since after this branch the current function returns and
  // some data must be cleaned up differently!  So put this back and leave it this way, and remove the
  // "Implementation Note".

  // Both SgProject and SgFile are handled via recursive calls
     if ( (isSgProject(astNode) != NULL) || (isSgFile(astNode) != NULL) )
        {
       // printf ("Implementation Note: Put these cases (unparsing the SgProject and SgFile into the cases for nodes derived from SgSupport below! \n");

       // Handle recursive call for SgProject
          if (isSgProject(astNode) != NULL)
             {
               SgProject* project = isSgProject(astNode);
               ROSE_ASSERT(project != NULL);
               for (int i = 0; i < project->numberOfFiles(); i++)
                  {
                    SgFile* file = &(project->get_file(i));
                    ROSE_ASSERT(file != NULL);
                    string unparsedFileString = globalUnparseToString(file,inputUnparseInfoPointer);
                    string prefixString       = string("/* TOP:")      + string(rose::getFileName(file)) + string(" */ \n");
                    string suffixString       = string("\n/* BOTTOM:") + string(rose::getFileName(file)) + string(" */ \n\n");
                    returnString += prefixString + unparsedFileString + suffixString;
                  }
             }

       // Handle recursive call for SgFile
          if (isSgFile(astNode) != NULL)
             {
               SgFile* file = isSgFile(astNode);
               ROSE_ASSERT(file != NULL);
               SgGlobal* globalScope = file->get_root();
               ROSE_ASSERT(globalScope != NULL);
               returnString = globalUnparseToString(globalScope,inputUnparseInfoPointer);
             }
        }
       else
#endif
        {
       // DQ (1/12/2003): Only now try to trap use of SgUnparse_Info default constructor
       // Turn ON the error checking which triggers an error if the default SgUnparse_Info constructor is called
          SgUnparse_Info::set_forceDefaultConstructorToTriggerError(true);

          if (isSgStatement(astNode) != NULL)
             {
               SgStatement* stmt = isSgStatement(astNode);
               roseUnparser.unparseStatement ( stmt, inheritedAttributeInfo );
             }

          if (isSgExpression(astNode) != NULL)
             {
               SgExpression* expr = isSgExpression(astNode);
               roseUnparser.unparseExpression ( expr, inheritedAttributeInfo );
             }

          if (isSgType(astNode) != NULL)
             {
               SgType* type = isSgType(astNode);
               roseUnparser.unparseType ( type, inheritedAttributeInfo );
             }

          if (isSgSymbol(astNode) != NULL)
             {
               SgSymbol* symbol = isSgSymbol(astNode);
               roseUnparser.unparseSymbol ( symbol, inheritedAttributeInfo );
             }

          if (isSgSupport(astNode) != NULL)
             {
            // Handle different specific cases derived from SgSupport 
            // (e.g. template parameters and template arguments).
               switch (astNode->variantT())
                  {
#if 0
                    case V_SgProject:
                       {
                         SgProject* project = isSgProject(astNode);
                         ROSE_ASSERT(project != NULL);
                         for (int i = 0; i < project->numberOfFiles(); i++)
                            {
                              SgFile* file = &(project->get_file(i));
                              ROSE_ASSERT(file != NULL);
                              string unparsedFileString = globalUnparseToString(file,inputUnparseInfoPointer);
                              string prefixString       = string("/* TOP:")      + string(rose::getFileName(file)) + string(" */ \n");
                              string suffixString       = string("\n/* BOTTOM:") + string(rose::getFileName(file)) + string(" */ \n\n");
                              returnString += prefixString + unparsedFileString + suffixString;
                            }
                         break;
                       }
                    case V_SgFile:
                       {
                         SgFile* file = isSgFile(astNode);
                         ROSE_ASSERT(file != NULL);
                         SgGlobal* globalScope = file->get_root();
                         ROSE_ASSERT(globalScope != NULL);
                         returnString = globalUnparseToString(globalScope,inputUnparseInfoPointer);
                         break;
                       }
#endif
                    case V_SgTemplateParameter:
                       {
                         SgTemplateParameter* templateParameter = isSgTemplateParameter(astNode);
                         roseUnparser.unparseTemplateParameter(templateParameter,inheritedAttributeInfo);
                         break;
                       }
                    case V_SgTemplateArgument:
                       {
                         SgTemplateArgument* templateArgument = isSgTemplateArgument(astNode);
                         roseUnparser.unparseTemplateArgument(templateArgument,inheritedAttributeInfo);
                         break;
                       }
                    case V_SgInitializedName:
                       {
                      // QY: not sure how to implement this
                      // DQ (7/23/2004): This should unparse as a declaration 
                      // (type and name with initializer).
                         break;
                       }

                    case V_Sg_File_Info:
                       {
                      // DQ (5/11/2006): Not sure how or if we shoul implement this
                         break;
                       }

                 // Perhaps the support for SgFile and SgProject shoud be moved to this location?
                    default:
                         printf ("Error: default reached in node derived from SgSupport astNode = %s \n",astNode->sage_class_name());
                         ROSE_ABORT();
                }
             }

       // Turn OFF the error checking which triggers an if the default SgUnparse_Info constructor is called
          SgUnparse_Info::set_forceDefaultConstructorToTriggerError(false);

       // MS: following is the rewritten code of the above outcommented 
       //     code to support ostringstream instead of ostrstream.
          returnString = outputString.str();

       // Call function to tighten up the code to make it more dense
          if (inheritedAttributeInfo.SkipWhitespaces() == true)
             {
               returnString = roseUnparser.removeUnwantedWhiteSpace ( returnString );
             }

       // delete the allocated SgUnparse_Info object
          if (inputUnparseInfoPointer == NULL)
               delete inheritedAttributeInfoPointer;
        }

     return returnString;
   }
Esempio n. 17
0
void ClangToSageTranslator::applySourceRange(SgNode * node, clang::SourceRange source_range) {
    SgLocatedNode * located_node = isSgLocatedNode(node);
    SgInitializedName * init_name = isSgInitializedName(node);

#if DEBUG_SOURCE_LOCATION
    std::cerr << "Set File_Info for " << node << " of type " << node->class_name() << std::endl;
#endif

    if (located_node == NULL && init_name == NULL) {
        std::cerr << "Consistency error: try to apply a source range to a Sage node which is not a SgLocatedNode or a SgInitializedName." << std::endl;
        exit(-1);
    }
    else if (located_node != NULL) {
        Sg_File_Info * fi = located_node->get_startOfConstruct();
        if (fi != NULL) delete fi;
        fi = located_node->get_endOfConstruct();
        if (fi != NULL) delete fi;
    }
    else if (init_name != NULL) {
        Sg_File_Info * fi = init_name->get_startOfConstruct();
        if (fi != NULL) delete fi;
        fi = init_name->get_endOfConstruct();
        if (fi != NULL) delete fi;
    }

    Sg_File_Info * start_fi = NULL;
    Sg_File_Info * end_fi = NULL;

    if (source_range.isValid()) {
        clang::SourceLocation begin  = source_range.getBegin();
        clang::SourceLocation end    = source_range.getEnd();

        if (begin.isValid() && end.isValid()) {
            if (begin.isMacroID()) {
#if DEBUG_SOURCE_LOCATION
                std::cerr << "\tDump SourceLocation begin as it is a MacroID: ";
                begin.dump(p_compiler_instance->getSourceManager());
                std::cerr << std::endl;
#endif
                begin = p_compiler_instance->getSourceManager().getExpansionLoc(begin);
                ROSE_ASSERT(begin.isValid());
            }

            if (end.isMacroID()) {
#if DEBUG_SOURCE_LOCATION
                std::cerr << "\tDump SourceLocation end as it is a MacroID: ";
                end.dump(p_compiler_instance->getSourceManager());
                std::cerr << std::endl;
#endif
                end = p_compiler_instance->getSourceManager().getExpansionLoc(end);
                ROSE_ASSERT(end.isValid());
            }

            clang::FileID file_begin = p_compiler_instance->getSourceManager().getFileID(begin);
            clang::FileID file_end   = p_compiler_instance->getSourceManager().getFileID(end);

            bool inv_begin_line;
            bool inv_begin_col;
            bool inv_end_line;
            bool inv_end_col;

            unsigned ls = p_compiler_instance->getSourceManager().getSpellingLineNumber(begin, &inv_begin_line);
            unsigned cs = p_compiler_instance->getSourceManager().getSpellingColumnNumber(begin, &inv_begin_col);
            unsigned le = p_compiler_instance->getSourceManager().getSpellingLineNumber(end, &inv_end_line);
            unsigned ce = p_compiler_instance->getSourceManager().getSpellingColumnNumber(end, &inv_end_col);

            if (file_begin.isInvalid() || file_end.isInvalid() || inv_begin_line || inv_begin_col || inv_end_line || inv_end_col) {
                ROSE_ASSERT(!"Should not happen as everything have been check before...");
            }

            if (p_compiler_instance->getSourceManager().getFileEntryForID(file_begin) != NULL) {
                std::string file = p_compiler_instance->getSourceManager().getFileEntryForID(file_begin)->getName();

                start_fi = new Sg_File_Info(file, ls, cs);
                end_fi   = new Sg_File_Info(file, le, ce);
#if DEBUG_SOURCE_LOCATION
                std::cerr << "\tCreate FI for node in " << file << ":" << ls << ":" << cs << std::endl;
#endif
            }
#if DEBUG_SOURCE_LOCATION
            else {
                std::cerr << "\tDump SourceLocation for \"Invalid FileID\": " << std::endl << "\t";
                begin.dump(p_compiler_instance->getSourceManager());
                std::cerr << std::endl << "\t";
                end.dump(p_compiler_instance->getSourceManager());
                std::cerr << std::endl;
            }
#endif
        }
    }

    if (start_fi == NULL && end_fi == NULL) {
        start_fi = Sg_File_Info::generateDefaultFileInfoForCompilerGeneratedNode();
        end_fi   = Sg_File_Info::generateDefaultFileInfoForCompilerGeneratedNode();

        start_fi->setCompilerGenerated();
        end_fi->setCompilerGenerated();
#if DEBUG_SOURCE_LOCATION
        std::cerr << "Create FI for compiler generated node" << std::endl;
#endif
    }
    else if (start_fi == NULL || end_fi == NULL) {
        ROSE_ASSERT(!"start_fi == NULL xor end_fi == NULL");
    }

    if (located_node != NULL) {
        located_node->set_startOfConstruct(start_fi);
        located_node->set_endOfConstruct(end_fi);
    }
    else if (init_name != NULL) {
        init_name->set_startOfConstruct(start_fi);
        init_name->set_endOfConstruct(end_fi);
    }

}