本文整理汇总了C++中SgScopeStatement::class_name方法的典型用法代码示例。如果您正苦于以下问题:C++ SgScopeStatement::class_name方法的具体用法?C++ SgScopeStatement::class_name怎么用?C++ SgScopeStatement::class_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgScopeStatement
的用法示例。
在下文中一共展示了SgScopeStatement::class_name方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void visitorTraversal::visit(SgNode* n)
{
// There are three types ir IR nodes that can be queried for scope:
// - SgStatement, and
// - SgInitializedName
SgStatement* statement = isSgStatement(n);
if (statement != NULL)
{
SgScopeStatement* scope = statement->get_scope();
ROSE_ASSERT(scope != NULL);
printf ("SgStatement = %12p = %30s has scope = %12p = %s (total number = %d) \n",
statement,statement->class_name().c_str(),
scope,scope->class_name().c_str(),(int)scope->numberOfNodes());
}
SgInitializedName* initializedName = isSgInitializedName(n);
if (initializedName != NULL)
{
SgScopeStatement* scope = initializedName->get_scope();
ROSE_ASSERT(scope != NULL);
printf ("SgInitializedName = %12p = %30s has scope = %12p = %s (total number = %d)\n",
initializedName,initializedName->get_name().str(),
scope,scope->class_name().c_str(),(int)scope->numberOfNodes());
}
}
示例2: isSgFunctionDefinition
const SgFunctionDefinition*
findRootFunc (const SgScopeStatement* scope)
{
// DQ (12/13/2011): This function is being called recursively (infinite recursion) for test2011_187.C (added support for SgTemplateFunctionDefinition).
// printf ("Inside of findRootFunc(scope = %p) \n",scope);
if (scope != NULL)
{
if (scope->variantT () == V_SgFunctionDefinition)
{
return isSgFunctionDefinition (scope);
}
else
{
if (scope->variantT () == V_SgTemplateFunctionDefinition)
{
return isSgTemplateFunctionDefinition (scope);
}
else
{
// DQ (12/13/2011): Adding test for improperly set scope.
// printf ("In findRootFunc(): scope = %p = %s \n",scope,scope->class_name().c_str());
SgScopeStatement* nextOuterScope = scope->get_scope();
ROSE_ASSERT(nextOuterScope != NULL);
#if 0
printf ("nextOuterScope = %p = %s \n",nextOuterScope,nextOuterScope->class_name().c_str());
#endif
ROSE_ASSERT(nextOuterScope != scope);
return findRootFunc(scope->get_scope());
}
}
}
// Not found.
return NULL;
}
示例3: isSgScopeStatement
void
FixupAstSymbolTables::visit ( SgNode* node )
{
// DQ (6/27/2005): Output the local symbol table from each scope.
// printf ("node = %s \n",node->sage_class_name());
SgScopeStatement* scope = isSgScopeStatement(node);
if (scope != NULL)
{
#if 0
printf ("AST Fixup: Fixup Symbol Table for %p = %s at: \n",scope,scope->class_name().c_str());
#endif
SgSymbolTable* symbolTable = scope->get_symbol_table();
if (symbolTable == NULL)
{
#if 0
printf ("AST Fixup: Fixup Symbol Table for %p = %s at: \n",scope,scope->class_name().c_str());
scope->get_file_info()->display("Symbol Table Location");
#endif
SgSymbolTable* tempSymbolTable = new SgSymbolTable();
ROSE_ASSERT(tempSymbolTable != NULL);
// name this table as compiler generated! The name is a static member used to store
// state for the next_symbol() functions. It is meaningless to set these.
// tempSymbolTable->set_name("compiler-generated symbol table");
scope->set_symbol_table(tempSymbolTable);
// reset the symbolTable using the get_symbol_table() member function
symbolTable = scope->get_symbol_table();
ROSE_ASSERT(symbolTable != NULL);
// DQ (2/16/2006): Set this parent directly (now tested)
symbolTable->set_parent(scope);
ROSE_ASSERT(symbolTable->get_parent() != NULL);
}
ROSE_ASSERT(symbolTable != NULL);
if (symbolTable->get_parent() == NULL)
{
printf ("Warning: Fixing up symbolTable, calling symbolTable->set_parent() (parent not previously set) \n");
symbolTable->set_parent(scope);
}
ROSE_ASSERT(symbolTable->get_parent() != NULL);
// Make sure that the internal hash table used in the symbol table is also present!
if (symbolTable->get_table() == NULL)
{
// DQ (6/27/2005): There are a lot of these built, perhaps more than we really need!
#if 0
printf ("AST Fixup: Building internal Symbol Table hash table (rose_hash_multimap) for %p = %s at: \n",
scope,scope->sage_class_name());
scope->get_file_info()->display("Symbol Table Location");
#endif
rose_hash_multimap* internalHashTable = new rose_hash_multimap();
ROSE_ASSERT(internalHashTable != NULL);
symbolTable->set_table(internalHashTable);
}
ROSE_ASSERT(symbolTable->get_table() != NULL);
SgSymbolTable::BaseHashType* internalTable = symbolTable->get_table();
ROSE_ASSERT(internalTable != NULL);
// DQ (6/23/2011): Note: Declarations that reference types that have not been seen yet may be placed into the
// wronge scope, then later when we see the correct scope we have a symbol in two or more symbol tables. The
// code below detects and fixes this problem.
// DQ (6/16/2011): List of symbols we need to remove from symbol tables where they are multibily represented.
std::vector<SgSymbol*> listOfSymbolsToRemove;
// DQ (6/12/2011): Fixup symbol table by removing symbols that are not associated with a declaration in the current scope.
int idx = 0;
SgSymbolTable::hash_iterator i = internalTable->begin();
while (i != internalTable->end())
{
// DQ: removed SgName casting operator to char*
// cout << "[" << idx << "] " << (*i).first.str();
ROSE_ASSERT ( (*i).first.str() != NULL );
ROSE_ASSERT ( isSgSymbol( (*i).second ) != NULL );
// printf ("Symbol number: %d (pair.first (SgName) = %s) pair.second (SgSymbol) sage_class_name() = %s \n",
// idx,(*i).first.str(),(*i).second->sage_class_name());
SgSymbol* symbol = isSgSymbol((*i).second);
ROSE_ASSERT ( symbol != NULL );
// We have to look at each type of symbol separately! This is because there is no virtual function,
// the reason for this is that each get_declaration() function returns a different type!
// ROSE_ASSERT ( symbol->get_declaration() != NULL );
switch(symbol->variantT())
{
case V_SgClassSymbol:
{
SgClassSymbol* classSymbol = isSgClassSymbol(symbol);
ROSE_ASSERT(classSymbol != NULL);
ROSE_ASSERT(classSymbol->get_declaration() != NULL);
SgDeclarationStatement* declarationToFindInScope = NULL;
//.........这里部分代码省略.........
示例4: isSgScopeStatement
//.........这里部分代码省略.........
}
if (greatestPossibleSimilarity < similarity_threshold)
{
#if DEBUG > 1
printf ("Skipping case of "
"j_index = %d i_index = %d (%s,%s) "
"greatestPossibleSimilarity = %f \n",
j_index,
i_index,
i->c_str(),
j->c_str(),
greatestPossibleSimilarity);
#endif
continue;
}
#if DEBUG > 2
printf ("Evaluating similarityMetric of"
"j_index = %d <= i_index = %d (%s,%s) \n",
j_index,
i_index,
i->c_str(),
j->c_str());
#endif
float similarity =
similarityMetric(
i->c_str(),
j->c_str());
if (similarity > similarity_threshold)
{
string lcs = longestCommonSubstring(i->c_str(), j->c_str());
#if DEBUG > 1
printf("\n\"%s\" and \"%s\" are %3.0f%% similar.\n"
"One of the longest common sequences is \"%s\".\n\n",
i->c_str(),
j->c_str(),
similarity*100,
lcs.c_str());
#endif
results.push_back(
std::pair<NameStructureType, NameStructureType> (*i, *j));
}
}
}// for each synthesized attribute
// Output the resulting matches of any non-empty list of results
if (results.empty() == false)
{
if (SgProject::get_verbose() > 2)
{
printf ("Processing matches of name in "
"scope = %p = %s = %s \n",
scopeStatement,
scopeStatement->class_name().c_str(),
SageInterface::get_name(scopeStatement).c_str());
}
vector< std::pair<NameStructureType, NameStructureType> >::iterator i;
for (i = results.begin(); i != results.end(); ++i)
{
// Output the matching names
SgNode* firstNode = i->first.associatedNode;
ROSE_ASSERT(firstNode != NULL);
SgNode* secondNode = i->second.associatedNode;
ROSE_ASSERT(secondNode != NULL);
float similarity =
similarityMetric(i->first.c_str(), i->second.c_str());
int similarityPercentage = 100 * similarity;
SgLocatedNode* first_node =
isSgLocatedNode(i->first.associatedNode);
SgLocatedNode* second_node =
isSgLocatedNode(i->second.associatedNode);
if (first_node != NULL &&
second_node != NULL &&
first_node != second_node)
{
if (Compass::IsNodeInUserLocation(first_node, source_directory_) &&
Compass::IsNodeInUserLocation(second_node, source_directory_))
{
output_->addOutput(
CompassAnalyses::VariableNameSimilarity::
CreateCheckerOutput(
similarityPercentage,
first_node,
second_node));
}
}
}
}
}
示例5: printf
void
MangledNameMapTraversal::visit ( SgNode* node)
{
ROSE_ASSERT(node != NULL);
#if 0
printf ("MangledNameMapTraversal::visit: node = %s \n",node->class_name().c_str());
#endif
// Keep track of the number of IR nodes visited
numberOfNodes++;
// DQ (7/4/2010): Optimizations:
// 1) Only process each IR node once
// 2) Only process declarations that we want to share (can we be selective?).
// DQ (7/4/2010): To optimize performance, build a set of previously visited IR nodes
// so that we only test IR nodes once to add them into the mangled name map. This
// should be especially important where the AST is sharing nodes since shared nodes
// are visited multiple times (as if they were not shared).
// We need to tet if this actually optimizes the performance.
if (setOfNodesPreviouslyVisited.find(node) == setOfNodesPreviouslyVisited.end())
{
setOfNodesPreviouslyVisited.insert(node);
}
else
{
return;
}
bool sharable = shareableIRnode(node);
#if 0
printf ("MangledNameMapTraversal::visit: node = %p = %s sharable = %s \n",node,node->class_name().c_str(),sharable ? "true" : "false");
#endif
// DQ (7/10/2010): This is a test of the AST merge to investigate robustness.
#if 1
if (sharable == true)
{
// Initially we will only merge things in global scope! Then
// we will operate on namespaces! Then I think we are done!
// Basically we can simplify the problem by skipping merging of things in
// function definitions since if the function definitions are the same they
// will be merged directly.
// Keep track of the number of IR nodes that were considered sharable
numberOfNodesSharable++;
// Here is where we get much more specific about what is sharable!
switch (node->variantT())
{
// Since we abstract out the generation of the key we can simplify this code!
#if 1
// DQ (7/11/2010): This fails for tests/nonsmoke/functional/CompileTests/mergeAST_tests/mergeTest_06.C, I don't know why!
case V_SgFunctionDeclaration:
#endif
#if 1
// DQ (7/20/2010): Testing this case...
case V_SgVariableDeclaration:
case V_SgClassDeclaration:
// DQ (2/10/2007): These need to be shared (but I still see "xxxxx____Lnnnn" based names)
case V_SgTemplateInstantiationDecl:
// DQ (2/10/2007): These should be shared
case V_SgPragmaDeclaration:
case V_SgTemplateInstantiationDirectiveStatement:
case V_SgTypedefDeclaration:
case V_SgEnumDeclaration:
case V_SgTemplateDeclaration:
case V_SgUsingDeclarationStatement:
case V_SgUsingDirectiveStatement:
// DQ (2/3/2007): Added additional declarations that we should share
case V_SgMemberFunctionDeclaration:
case V_SgTemplateInstantiationFunctionDecl:
case V_SgTemplateInstantiationMemberFunctionDecl:
#endif
#if 1
// DQ (2/3/2007): Added support for symbols
case V_SgClassSymbol:
case V_SgEnumFieldSymbol:
case V_SgEnumSymbol:
case V_SgFunctionSymbol:
case V_SgMemberFunctionSymbol:
case V_SgLabelSymbol:
case V_SgNamespaceSymbol:
// DQ (2/10/2007): This case has been a problem previously
case V_SgTemplateSymbol:
case V_SgTypedefSymbol:
case V_SgVariableSymbol:
#endif
#if 0
// DQ (7/20/2010): These nodes are a problem to merge, but also not important to merge
//.........这里部分代码省略.........
示例6: ATgetAnnotation
SgScopeStatement*
AtermSupport::getAtermScopeNodeAttribute (ATerm term, const std::string & annotationName )
{
SgScopeStatement* returnNode = NULL;
ATerm idannot = ATgetAnnotation(term, ATmake(annotationName.c_str()));
if (idannot)
{
#if 1
printf ("In getAtermScopeNodeAttribute(): Found an annotation: annotationName = %s \n",annotationName.c_str());
#endif
char* id = NULL;
// Get the associated annotation string.
if (ATmatch(idannot, "<str>", &id))
{
#if 1
printf ("In getAtermScopeNodeAttribute(): Found an string in the annotation: annotationName = %s id = %s \n",annotationName.c_str(),id);
#endif
if (translationScopeMap.find(id) != translationScopeMap.end())
{
returnNode = translationScopeMap[id];
ROSE_ASSERT(returnNode != NULL);
#if 1
printf ("In getAtermScopeNodeAttribute translationScopeMap: id = %s returnNode = %p = %s \n",id,returnNode,returnNode->class_name().c_str());
#endif
}
else
{
#if 1
printf ("In getAtermScopeNodeAttribute(): Node not found in translationNodeMap: returing NULL pointer \n");
#endif
}
}
else
{
printf ("Error: The nested aterm associated with the annotation must be available on the aterm: annotationName = %s \n",annotationName.c_str());
ROSE_ASSERT(false);
}
}
else
{
printf ("Error: The annotation not found on the aterm: annotationName = %s \n",annotationName.c_str());
ROSE_ASSERT(false);
}
#if 0
printf ("In AtermSupport::getAtermScopeNodeAttribute(): not yet implemented \n");
ROSE_ASSERT(false);
#endif
return returnNode;
}
示例7: isSgVariableDeclaration
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
}
}
示例8: printf
bool
FixupTemplateArguments::contains_private_type (SgTemplateArgument* templateArgument, SgScopeStatement* targetScope)
{
// Note that within EDG and ROSE the template arguments may be shared so that we can support testing for equivalence.
// static std::list<SgTemplateArgument*> templateArgumentList;
// templateArgumentList.push_back(templateArgument);
static std::set<SgTemplateArgument*> templateArgumentSet;
if (templateArgumentSet.find(templateArgument) == templateArgumentSet.end())
{
templateArgumentSet.insert(templateArgument);
}
else
{
#if DEBUGGING_USING_RECURSIVE_DEPTH
printf ("@@@@@@@@@@@@@@@@@ Already been or being processed: templateArgument = %p = %s templateArgumentSet.size() = %zu \n",templateArgument,templateArgument->unparseToString().c_str(),templateArgumentSet.size());
#endif
#if 0
printf ("Leaving contains_private_type(SgTemplateArgument): templateArgument = %p returning FALSE \n",templateArgument);
#endif
// DQ (2/15/2017): Unclear if this is the correct return value, it might be that we want to record
// the associated value from the first time the argument list was processed and use that value.
// Then again, if the value had already been substituted into the template argument then no further
// processing is required.
return false;
}
#if DEBUGGING_USING_RECURSIVE_DEPTH
printf ("--- added templateArgument = %p templateArgumentSet.size() = %zu \n",templateArgument,templateArgumentSet.size());
#endif
#if DEBUGGING_USING_RECURSIVE_DEPTH
// For debugging, keep track of the recursive depth.
static size_t depth = 0;
printf ("In contains_private_type(SgTemplateArgument*): depth = %zu \n",depth);
ROSE_ASSERT(depth < 500);
printf ("In contains_private_type(SgTemplateArgument*): global_depth = %zu \n",global_depth);
if (global_depth >= 50)
{
// output the list of SgTemplateArgument in the list
printf ("Error: too many elements in list: recursuion too deep \n");
size_t counter = 0;
for (std::set<SgTemplateArgument*>::iterator i = templateArgumentSet.begin(); i != templateArgumentSet.end(); i++)
{
printf ("--- templateArgumentSet[counter] = %p = %s \n",*i,templateArgument->unparseToString().c_str());
counter++;
}
}
ROSE_ASSERT(global_depth < 50);
#endif
// Note this is the recursive function.
bool returnValue = false;
#if DEBUG_PRIVATE_TYPE
printf ("In contains_private_type(SgTemplateArgument*): templateArgument = %p = %s = %s \n",templateArgument,templateArgument->class_name().c_str(),templateArgument->unparseToString().c_str());
#endif
switch (templateArgument->get_argumentType())
{
case SgTemplateArgument::type_argument:
{
ROSE_ASSERT (templateArgument->get_type() != NULL);
SgType* templateArgumentType = templateArgument->get_type();
#if DEBUG_PRIVATE_TYPE
printf ("templateArgumentType = %p = %s \n",templateArgumentType,templateArgumentType->class_name().c_str());
if (isSgModifierType(templateArgumentType) != NULL)
{
SgModifierType* modifierType = isSgModifierType(templateArgumentType);
SgType* base_type = modifierType->get_base_type();
printf ("--- base_type = %p = %s \n",base_type,base_type->class_name().c_str());
SgNamedType* namedType = isSgNamedType(base_type);
if (namedType != NULL)
{
printf ("--- base_type: name = %s \n",namedType->get_name().str());
}
}
#endif
#if DEBUGGING_USING_RECURSIVE_DEPTH
depth++;
global_depth++;
#endif
#if 0
printf ("In contains_private_type(SgTemplateArgument*): case SgTemplateArgument::type_argument: Calling contains_private_type(templateArgumentType) \n");
#endif
// DQ (2/14/2017): We might want to generate a list of the private types used so
// that we can check them against the scope of the declaration where they occur.
// Note also that this does not address types that might appear in name qualification.
returnValue = contains_private_type(templateArgumentType,targetScope);
#if DEBUGGING_USING_RECURSIVE_DEPTH
depth--;
global_depth--;
//.........这里部分代码省略.........
示例9: contains_private_type
bool FixupTemplateArguments::contains_private_type (SgType* type, SgScopeStatement* targetScope)
{
// DQ (4/2/2018): Note that this function now addresses requirements of supporting both private and protected types.
#if DEBUGGING_USING_RECURSIVE_DEPTH
// For debugging, keep track of the recursive depth.
static size_t depth = 0;
printf ("In contains_private_type(SgType*): depth = %zu \n",depth);
ROSE_ASSERT(depth < 500);
printf ("In contains_private_type(SgType*): global_depth = %zu \n",global_depth);
ROSE_ASSERT(global_depth < 55);
#endif
// Note this is the recursive function.
bool returnValue = false;
#if DEBUG_PRIVATE_TYPE || 0
// DQ (1/7/2016): It is a problem to do this for some files (failing about 35 files in Cxx_tests).
// The issues appears to be in the unparsing of the template arguments of the qualified names for the types.
// printf ("In contains_private_type(SgType*): type = %p = %s = %s \n",type,type->class_name().c_str(),type->unparseToString().c_str());
printf ("In contains_private_type(SgType*): type = %p = %s \n",type,type->class_name().c_str());
#endif
SgTypedefType* typedefType = isSgTypedefType(type);
if (typedefType != NULL)
{
// Get the associated declaration.
SgTypedefDeclaration* typedefDeclaration = isSgTypedefDeclaration(typedefType->get_declaration());
ROSE_ASSERT(typedefDeclaration != NULL);
#if 0
bool isPrivate = typedefDeclaration->get_declarationModifier().get_accessModifier().isPrivate();
#else
// DQ (4/2/2018): Fix this to address requirements of both private and protected class members (see Cxx11_tests/test2018_71.C).
bool isPrivate = typedefDeclaration->get_declarationModifier().get_accessModifier().isPrivate() ||
typedefDeclaration->get_declarationModifier().get_accessModifier().isProtected();
#endif
#if DEBUG_PRIVATE_TYPE || 0
printf ("typedefDeclaration isPrivate = %s \n",isPrivate ? "true" : "false");
#endif
// First we need to know if this is a visable type.
bool isVisable = false;
#if 0
printf ("targetScope = %p = %s \n",targetScope,targetScope->class_name().c_str());
// printf ("typedefDeclaration = %p = %s \n",typedefDeclaration,typedefDeclaration->class_name().c_str());
printf ("typedefDeclaration->get_scope() = %p = %s \n",typedefDeclaration->get_scope(),typedefDeclaration->get_scope()->class_name().c_str());
#endif
#if 0
printf ("SageInterface::whereAmI(targetScope): \n");
SageInterface::whereAmI(targetScope);
printf ("SageInterface::whereAmI(typedefDeclaration): \n");
SageInterface::whereAmI(typedefDeclaration);
#endif
#if 0
printf ("\ntargetScope symbol table: \n");
targetScope->get_symbol_table()->print("targetScope");
printf ("end of symbol table \n");
printf ("\ntypedefDeclaration->get_scope() symbol table: \n");
typedefDeclaration->get_scope()->get_symbol_table()->print("typedefDeclaration->get_scope()");
printf ("end of symbol table \n\n");
#endif
// Test for the trivial case of matching scope (an even better test (below) is be to make sure that the targetScope is nested in the typedef scope).
if (typedefDeclaration->get_scope() == targetScope)
{
#if 0
printf ("In contains_private_type(SgType*): This is a typedef type from the same scope as the target declaration \n");
#endif
// ROSE_ASSERT(false);
// return false;
isVisable = true;
}
else
{
// SgTypedefSymbol* lookupTypedefSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
SgTypedefSymbol* typedefSymbol = SageInterface::lookupTypedefSymbolInParentScopes (typedefDeclaration->get_name(),targetScope);
if (typedefSymbol != NULL)
{
#if 0
printf ("In contains_private_type(SgType*): This is not in the current scope but can be reached from the current scope \n");
#endif
// ROSE_ASSERT(false);
// return false;
isVisable = true;
}
else
{
#if 0
printf ("Symbol for typedef name = %s not found in parent scopes \n",typedefDeclaration->get_name().str());
#endif
// ROSE_ASSERT(false);
}
}
#if 0
// Testing codes because it seems that "BitSet" shuld be visiable and so we need to debug this first.
if (typedefDeclaration->get_name() == "BitSet")
{
printf ("Exiting as a test! \n");
//.........这里部分代码省略.........
示例10: fixupAstDeclarationScope
void fixupAstDeclarationScope( SgNode* node )
{
// This function was designed to fixup what I thought were inconsistancies in how the
// defining and some non-defining declarations associated with friend declarations had
// their scope set. I now know this this was not a problem, but it is helpful to enforce the
// consistancy. It might also be useful to process declarations with scopes set to
// namespace definitions, so that the namespace definition can be normalized to be
// consistant across all of the different re-entrant namespace definitions. This is
// possible within the new namespace support in ROSE.
TimingPerformance timer ("Fixup declaration scopes:");
// This simplifies how the traversal is called!
FixupAstDeclarationScope astFixupTraversal;
// DQ (1/29/2007): This traversal now uses the memory pool (so that we will visit declaration hidden in types (e.g. SgClassType)
// SgClassType::traverseMemoryPoolNodes(v);
astFixupTraversal.traverseMemoryPool();
// Now process the map of sets of declarations.
std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* > & mapOfSets = astFixupTraversal.mapOfSets;
#if 0
printf ("In fixupAstDeclarationScope(): mapOfSets.size() = %" PRIuPTR " \n",mapOfSets.size());
#endif
std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* >::iterator i = mapOfSets.begin();
while (i != mapOfSets.end())
{
SgDeclarationStatement* firstNondefiningDeclaration = i->first;
// DQ (3/2/2015): Added assertion.
ROSE_ASSERT(firstNondefiningDeclaration != NULL);
// DQ (3/2/2015): Added assertion.
ROSE_ASSERT(firstNondefiningDeclaration->get_firstNondefiningDeclaration() != NULL);
// DQ (3/2/2015): Make this assertion a warning: fails in outlining example seq7a_test2006_78.C.
// ROSE_ASSERT(firstNondefiningDeclaration == firstNondefiningDeclaration->get_firstNondefiningDeclaration());
if (firstNondefiningDeclaration != firstNondefiningDeclaration->get_firstNondefiningDeclaration())
{
printf ("WARNING: In fixupAstDeclarationScope(): firstNondefiningDeclaration != firstNondefiningDeclaration->get_firstNondefiningDeclaration() \n");
printf (" --- firstNondefiningDeclaration = %p = %s \n",
firstNondefiningDeclaration,firstNondefiningDeclaration->class_name().c_str());
printf (" --- firstNondefiningDeclaration->get_firstNondefiningDeclaration() = %p = %s \n",
firstNondefiningDeclaration->get_firstNondefiningDeclaration(),firstNondefiningDeclaration->get_firstNondefiningDeclaration()->class_name().c_str());
}
SgScopeStatement* correctScope = firstNondefiningDeclaration->get_scope();
ROSE_ASSERT(correctScope != NULL);
#if 0
printf ("In FixupAstDeclarationScope::visit(): node = %p = %s firstNondefiningDeclaration = %p correctScope = %p = %s \n",node,node->class_name().c_str(),firstNondefiningDeclaration,correctScope,correctScope->class_name().c_str());
#endif
std::set<SgDeclarationStatement*>* declarationSet = i->second;
ROSE_ASSERT(declarationSet != NULL);
#if 0
printf ("In fixupAstDeclarationScope(): mapOfSets[%p]->size() = %" PRIuPTR " \n",firstNondefiningDeclaration,mapOfSets[firstNondefiningDeclaration]->size());
#endif
std::set<SgDeclarationStatement*>::iterator j = declarationSet->begin();
while (j != declarationSet->end())
{
SgScopeStatement* associatedScope = (*j)->get_scope();
ROSE_ASSERT(associatedScope != NULL);
// DQ (6/11/2013): This is triggered by namespace definition scopes that are different
// due to re-entrant namespace declarations. We should maybe fix this.
// TV (7/22/13): This is also triggered when for global scope accross files.
if (associatedScope != correctScope)
{
// DQ (1/30/2014): Cleaning up some output spew.
if (SgProject::get_verbose() > 0)
{
mprintf ("WARNING: This is the wrong scope (declaration = %p = %s): associatedScope = %p = %s correctScope = %p = %s \n",
*j,(*j)->class_name().c_str(),associatedScope,associatedScope->class_name().c_str(),correctScope,correctScope->class_name().c_str());
}
#if 0
printf ("Make this an error for now! \n");
ROSE_ASSERT(false);
#endif
}
j++;
}
i++;
}
#if 0
printf ("Leaving fixupAstDeclarationScope() node = %p = %s \n",node,node->class_name().c_str());
#endif
}
示例11: isSgDeclarationStatement
string
nodeColor( SgStatement* statement )
{
/* color: colorCode:red:on
color: colorCode:orange:on
color: colorCode:yellow:on
color: colorCode:blue:on
color: colorCode:green:on
color: colorCode:violet:on
color: colorCode:brown:on
color: colorCode:purple:on
color: colorCode:lightblue:on
color: colorCode:lightgreen:on
color: colorCode:lightred:on
color: colorCode:black:on
color: colorCode:darkblue:on
color: colorCode:grey:on
color: colorCode:darkgrey:on
color: colorCode:olivegreen:on
color: colorCode:darkgreen:on
*/
string returnString;
SgDeclarationStatement* declarationStatement = isSgDeclarationStatement(statement);
if (declarationStatement != NULL)
{
switch (declarationStatement->variantT())
{
case V_SgFunctionDeclaration:
case V_SgMemberFunctionDeclaration:
case V_SgTemplateInstantiationFunctionDecl:
case V_SgTemplateInstantiationMemberFunctionDecl:
returnString = "orange";
break;
case V_SgClassDeclaration:
case V_SgTemplateInstantiationDecl:
returnString = "yellow";
break;
case V_SgAsmStmt:
case V_SgCtorInitializerList:
case V_SgEnumDeclaration:
case V_SgFunctionParameterList:
case V_SgNamespaceAliasDeclarationStatement:
case V_SgNamespaceDeclarationStatement:
case V_SgPragmaDeclaration:
case V_SgTemplateDeclaration:
case V_SgTemplateInstantiationDirectiveStatement:
case V_SgTypedefDeclaration:
case V_SgUsingDeclarationStatement:
case V_SgUsingDirectiveStatement:
case V_SgVariableDeclaration:
case V_SgVariableDefinition:
returnString = "lightred";
break;
// DQ (11/11/2012): Added support for newer IR nodes in edg4x work.
case V_SgTemplateMemberFunctionDeclaration:
case V_SgTemplateClassDeclaration:
case V_SgTemplateFunctionDeclaration:
case V_SgTemplateVariableDeclaration:
returnString = "red";
break;
default:
returnString = "ERROR DEFAULT REACHED";
printf ("Default reached in nodeColor() exiting ... (%s) \n",declarationStatement->class_name().c_str());
ROSE_ASSERT(false);
break;
}
}
SgScopeStatement* scopeStatement = isSgScopeStatement(statement);
if (scopeStatement != NULL)
{
switch (scopeStatement->variantT())
{
case V_SgBasicBlock:
returnString = "lightblue";
break;
case V_SgClassDefinition:
returnString = "lightblue";
break;
case V_SgTemplateInstantiationDefn:
case V_SgFunctionDefinition:
returnString = "lightblue";
break;
case V_SgWhileStmt:
case V_SgDoWhileStmt:
case V_SgForStatement:
returnString = "darkblue";
break;
case V_SgGlobal:
case V_SgIfStmt:
case V_SgNamespaceDefinitionStatement:
//.........这里部分代码省略.........