Exemplo n.º 1
0
 virtual void visit(SgNode* n) {
     SgLabelStatement* l = isSgLabelStatement(n);
     if (l) {
         SgName name = l->get_label();
         // The label is in some inner scope, and needs to be moved to the
         // enclosing function definition
         SgSymbolTable* st = l->get_scope()->get_symbol_table();
         ROSE_ASSERT (st);
         ROSE_ASSERT (st->find_label(name));
         st->remove(st->find_label(name));
         name << "__" << ++labelRenameCounter;
         // cout << "Found label " << l->get_label().getString() << " to rename to " << name.getString() << endl;
         l->set_label(name);
         l->set_scope(newScope);
         SgLabelSymbol* lSym = new SgLabelSymbol(l);
         lSym->set_parent(symtab);
         symtab->insert(name, lSym);
     }
 }
TEST(SymbolTableTest, LookUpOfNameInEmptyTableReturnsFalseNullOrZero){
  SgSymbolTable *p = new SgSymbolTable();
  const SgName foo("foo");
  EXPECT_EQ(p->exists(foo), false);
//  EXPECT_EQ(isNull(p->find_any(foo)),true); error: no matching function for call to ‘SgSymbolTable::find_any(const SgName&)’ FIXME WTF
  EXPECT_EQ(isNull(p->find_variable(foo)), true);
  EXPECT_EQ(isNull(p->find_class(foo)), true);
  EXPECT_EQ(isNull(p->find_function(foo)), true);
  EXPECT_EQ(isNull(p->find_function_type(foo)), true);
  EXPECT_EQ(isNull(p->find_typedef(foo)), true);
  EXPECT_EQ(isNull(p->find_enum(foo)), true);
  EXPECT_EQ(isNull(p->find_enum_field(foo)), true);
  EXPECT_EQ(isNull(p->find_label(foo)), true);
  EXPECT_EQ(isNull(p->find_java_label(foo)), true);
  EXPECT_EQ(isNull(p->find_namespace(foo)), true);
//  EXPECT_EQ(isNull(p->find_aliased_symbol(foo)), true);
  EXPECT_EQ(p->count(foo), 0);
  EXPECT_EQ(p->count_aliases(foo), 0);
  EXPECT_EQ(p->get_symbols().size(), 0);
}