当前位置: 首页>>代码示例>>C++>>正文


C++ CFG类代码示例

本文整理汇总了C++中CFG的典型用法代码示例。如果您正苦于以下问题:C++ CFG类的具体用法?C++ CFG怎么用?C++ CFG使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CFG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: add_thread

 void add_thread (ThreadId t, CFG cfg, 
                  VarNameIt sh_begin, VarNameIt sh_end)
     
 {
   auto it = m_cfg_map.find (t);
   if (it != m_cfg_map.end ())
     return;
   
   std::set<varname_t> shared_vs;
   shared_vs.insert (sh_begin, sh_end);
   
   std::set<varname_t> local_vs;
   for (auto &b: boost::make_iterator_range (cfg.begin (), cfg.end ()))
   {
     for (auto &s: b)
     {
       auto ls = s.getLive ();
       if (ls.defs_begin () != ls.defs_end ())
         local_vs.insert (ls.defs_begin (), ls.defs_end ());
       if (ls.uses_begin () != ls.uses_end ())
         local_vs.insert (ls.uses_begin (), ls.uses_end ());
     }
   }
   set_difference (local_vs, shared_vs);
   
   m_cfg_map.insert (std::make_pair (t, cfg));
   m_gv_map.insert (std::make_pair (t, shared_vs));
   m_lv_map.insert (std::make_pair (t, local_vs));
 }
开发者ID:HUST-PLT,项目名称:crab,代码行数:29,代码来源:ConcSys.hpp

示例2: tr

void MainWindow::on_actionLoad_XML_triggered()
{
    scene->clear();
    graph.clear();

    QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", "Files (*.xml)", NULL);
    CFG cfg = parser.getCFG(fileName);

    // add all blocks
    for(Block block : cfg.getBlocks()) {
        Node* node = new Node(block.getName(), 50, 50);
        node->setX(qrand() % ((500 + 1) - (-500)) + (-500));
        node->setY(qrand() % ((500 + 1) - (-500)) + (-500));
        scene->addItem(node);
        graph.addNode(node);
    }

    // add all edges
    for(Block block : cfg.getBlocks()) {
        AbstractNode* from = graph.getNode(block.getName());
        for(QString succName : block.getSuccessors()) {
            AbstractNode* to = graph.getNode(succName);
            EdgeItem* edge = new EdgeItem(from,to,true);
            edge->adjust();
            scene->addItem(edge);
            graph.addEdge(from,to,edge);
        }
    }

    graph.setStart(graph.getNode(cfg.getStart().getName()));
}
开发者ID:Oyuret,项目名称:layers,代码行数:31,代码来源:mainwindow.cpp

示例3: getModeForDecl

void AnalysisConsumer::HandleCode(Decl *D, AnalysisMode Mode,
                                  SetOfConstDecls *VisitedCallees) {
  if (!D->hasBody())
    return;
  Mode = getModeForDecl(D, Mode);
  if (Mode == AM_None)
    return;
//  DisplayFunction(D, Mode, IMode);
  CFG *DeclCFG = Mgr->getCFG(D);
  if (DeclCFG) {
    unsigned CFGSize = DeclCFG->size();
    MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize;
  }

  // Clear the AnalysisManager of old AnalysisDeclContexts.
  Mgr->ClearContexts();
  myLiveVariables* L = /*Mgr->getAnalysis<LiveVariables>(D)*/myLiveVariables::create(*(Mgr->getAnalysisDeclContext(D)), Mgr->getASTContext().getSourceManager());
  L->dumpBlockLiveness(Mgr->getASTContext().getSourceManager());
//  BugReporter BR(*Mgr);

//  if (Mode & AM_Syntax)
//    checkerMgr->runCheckersOnASTBody(D, *Mgr, BR);
//  if ((Mode & AM_Path) && checkerMgr->hasPathSensitiveCheckers()) {
//    RunPathSensitiveChecks(D, IMode, VisitedCallees);
//    if (IMode != ExprEngine::Inline_Minimal)
//      NumFunctionsAnalyzed++;
//  }
}
开发者ID:EvilMcJerkface,项目名称:quro,代码行数:28,代码来源:AnalysisConsumer.cpp

示例4: TEST_F

TEST_F(TestCFG, RecursionElimination) {
    cfg << "<S> ::= <S>a|b";
    CFG expected;
    expected << "<S> ::= b<S'>";
    expected << "<S'> ::= a<S'>|";
    EXPECT_EQ(expected, cfg.withoutRecursion());

    cfg.clear();
    cfg << "<S> ::= <S><S>a|b<A>";
    cfg << "<A> ::= b<B>c|<A>e|";
    cfg << "<B> ::= <B>a|<B>b|c|d|";
    expected.clear();
    expected << "<S> ::= b<A><S'>";
    expected << "<S'> ::= <S>a<S'>|";
    expected << "<A> ::= b<B>c<A'>|<A'>";
    expected << "<A'> ::= e<A'>|";
    expected << "<B> ::= c<B'>|d<B'>|<B'>";
    expected << "<B'> ::= a<B'>|b<B'>|";
    EXPECT_EQ(expected, cfg.withoutRecursion());

    // cfg.clear();
    // cfg << "<S> ::= <A>a|a";
    // cfg << "<A> ::= <B>b|b";
    // cfg << "<B> ::= <S>c|c";
    // expected.clear();
    // expected << "<S> ::= <A>a|a";
    // expected << "<A> ::= <B>b|b";
    // expected << "<B> ::= bac<B'>|ac<B'>|c<B'>";
    // expected << "<B'> ::= bac<B'>|";
    // EXPECT_EQ(expected, cfg.withoutRecursion());
}
开发者ID:Ghabriel,项目名称:FormalLanguageUtils,代码行数:31,代码来源:CFG_test.cpp

示例5: getCFG

CFG CFGGenerator::getCFG(FunctionDefinition& f) {
    CFG result;
    result.fStart = result.newBlock();
    result.fCurrent = result.fStart;
    this->addStatement(result, &f.fBody);
    result.newBlock();
    result.fExit = result.fCurrent;
    return result;
}
开发者ID:MIPS,项目名称:external-skia,代码行数:9,代码来源:SkSLCFGGenerator.cpp

示例6: vals

void lfort::runUninitializedVariablesAnalysis(
    const DeclContext &dc,
    const CFG &cfg,
    AnalysisDeclContext &ac,
    UninitVariablesHandler &handler,
    UninitVariablesAnalysisStats &stats) {
  CFGBlockValues vals(cfg);
  vals.computeSetOfDeclarations(dc);
  if (vals.hasNoDeclarations())
    return;

  stats.NumVariablesAnalyzed = vals.getNumEntries();

  // Precompute which expressions are uses and which are initializations.
  ClassifyRefs classification(ac);
  cfg.VisitBlockStmts(classification);

  // Mark all variables uninitialized at the entry.
  const CFGBlock &entry = cfg.getEntry();
  ValueVector &vec = vals.getValueVector(&entry);
  const unsigned n = vals.getNumEntries();
  for (unsigned j = 0; j < n ; ++j) {
    vec[j] = Uninitialized;
  }

  // Proceed with the workist.
  DataflowWorklist worklist(cfg, *ac.getAnalysis<PostOrderCFGView>());
  llvm::BitVector previouslyVisited(cfg.getNumBlockIDs());
  worklist.enqueueSuccessors(&cfg.getEntry());
  llvm::BitVector wasAnalyzed(cfg.getNumBlockIDs(), false);
  wasAnalyzed[cfg.getEntry().getBlockID()] = true;
  PruneBlocksHandler PBH(cfg.getNumBlockIDs());

  while (const CFGBlock *block = worklist.dequeue()) {
    PBH.currentBlock = block->getBlockID();

    // Did the block change?
    bool changed = runOnBlock(block, cfg, ac, vals,
                              classification, wasAnalyzed, PBH);
    ++stats.NumBlockVisits;
    if (changed || !previouslyVisited[block->getBlockID()])
      worklist.enqueueSuccessors(block);    
    previouslyVisited[block->getBlockID()] = true;
  }

  if (!PBH.hadAnyUse)
    return;

  // Run through the blocks one more time, and report uninitialized variabes.
  for (CFG::const_iterator BI = cfg.begin(), BE = cfg.end(); BI != BE; ++BI) {
    const CFGBlock *block = *BI;
    if (PBH.hadUse[block->getBlockID()]) {
      runOnBlock(block, cfg, ac, vals, classification, wasAnalyzed, handler);
      ++stats.NumBlockVisits;
    }
  }
}
开发者ID:gwelymernans,项目名称:lfort,代码行数:57,代码来源:UninitializedValues.cpp

示例7: print

void GRState::print(llvm::raw_ostream& Out, CFG &C, const char* nl,
                    const char* sep) const {
  // Print the store.
  GRStateManager &Mgr = getStateManager();
  Mgr.getStoreManager().print(getStore(), Out, nl, sep);

  // Print Subexpression bindings.
  bool isFirst = true;

  for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
    if (C.isBlkExpr(I.getKey()))
      continue;

    if (isFirst) {
      Out << nl << nl << "Sub-Expressions:" << nl;
      isFirst = false;
    }
    else { Out << nl; }

    Out << " (" << (void*) I.getKey() << ") ";
    LangOptions LO; // FIXME.
    I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
    Out << " : " << I.getData();
  }

  // Print block-expression bindings.
  isFirst = true;

  for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
    if (!C.isBlkExpr(I.getKey()))
      continue;

    if (isFirst) {
      Out << nl << nl << "Block-level Expressions:" << nl;
      isFirst = false;
    }
    else { Out << nl; }

    Out << " (" << (void*) I.getKey() << ") ";
    LangOptions LO; // FIXME.
    I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
    Out << " : " << I.getData();
  }

  Mgr.getConstraintManager().print(this, Out, nl, sep);

  // Print checker-specific data.
  for (std::vector<Printer*>::iterator I = Mgr.Printers.begin(),
                                       E = Mgr.Printers.end(); I != E; ++I) {
    (*I)->Print(Out, this, nl, sep);
  }
}
开发者ID:lgerbarg,项目名称:clang,代码行数:52,代码来源:GRState.cpp

示例8: assert

int FunctionMetadata::calculateNumUserVisibleVRegs() {
    SourceInfo* source_info = source.get();

    CFG* cfg = source_info->cfg;
    assert(cfg && "We don't calculate the CFG inside this function because it can raise an exception and its "
                  "therefore not safe to call at every point");

    if (!cfg->hasVregsAssigned()) {
        ScopeInfo* scope_info = source->getScopeInfo();
        cfg->assignVRegs(param_names, scope_info);
    }
    return cfg->sym_vreg_map_user_visible.size();
}
开发者ID:ChinaQuants,项目名称:pyston,代码行数:13,代码来源:codegen.cpp

示例9:

bool operator == (const CFG& cfg1, const CFG& cfg2) {
  if (cfg1.getTerminals() != cfg2.getTerminals()) return false;
  if (cfg1.getRules() != cfg2.getRules()) return false;
  if (cfg1.getVariables() != cfg2.getVariables()) return false;
  if (cfg1.getStartSymbol() != cfg2.getStartSymbol()) return false;
  return true;
}
开发者ID:arminnh,项目名称:universal-turing-machine-simulator,代码行数:7,代码来源:CFG.cpp

示例10: KernelStatistics

KernelStatistics *KernelStatistics::computeKernelStatistics(AnalysisDeclContext
    &AC, StringRef name, CompilerKnownClasses &compilerClasses) {
  // No CFG?  Bail out.
  CFG *cfg = AC.getCFG();
  if (!cfg) return 0;

  #ifdef DEBUG_ANALYSIS
  cfg->viewCFG(AC.getASTContext().getLangOpts());
  #endif

  KernelStatsImpl *KS = new KernelStatsImpl(AC, name, compilerClasses);
  KS->runOnAllBlocks();

  return new KernelStatistics(KS);
}
开发者ID:weiweichen,项目名称:hipacc,代码行数:15,代码来源:KernelStatistics.cpp

示例11: main

int main(int argc, char **argv) {

	Manager manager;
	PropList props;
//	LOADER(props) = &Loader::LOADER_Gliss_PowerPC;
	try {
		WorkSpace *fw = manager.load(argv[1], props);
		
		// Find main CFG
		cout << "Looking for the main CFG\n";
		CFG *cfg = fw->getCFGInfo()->findCFG("main");
		if(cfg == 0) {
			cerr << "ERROR: cannot find main !\n";
			return 1;
		}
		else
			cout << "main found at 0x" << cfg->address() << '\n';
		
		// Build dominance
		Dominance dom;
		dom.processCFG(fw, cfg);
		
		// Display dominance information
		for(CFG::BBIterator bb1(cfg); bb1; bb1++) {
			bool first = true;
			cout << bb1->number() << " dominates {";
			for(CFG::BBIterator bb2(cfg); bb2; bb2++)
				if(Dominance::dominates(bb1, bb2)) {
					if(first)
						first = false;
					else
						cout << ", ";
					cout << bb2->number();
				}
			cout << "}\n";
		}
		
		// Display the result
		cout << "SUCCESS\n";
	}
	catch(LoadException e) {
		cerr << "ERROR: " << e.message() << '\n';
		exit(1);
	}
	return 0;
}
开发者ID:alexjordan,项目名称:otawa,代码行数:46,代码来源:test_dom.cpp

示例12: varcnt

std::string CFG::varcnt(void) {
	int cnt = 0;
	char cntvar[64] = {0};
	CFG *root = this;

	while (NULL != root->prev()) {
		root = root->prev();
	}

	cnt = root->_varcnt_();
	if (0 != cnt) {
		snprintf(cntvar, sizeof(cntvar), "0x%X", cnt * PARAM_SIZE);
	}

	_D(LOG_DEBUG, "variable count on %s - %d", root->label().c_str(), cnt);
	return cntvar;
}
开发者ID:cmj0121,项目名称:Zerg,代码行数:17,代码来源:cfg.cpp

示例13: printState

 inline void printState(const LR0State& state, const CFG& cfg) {
     ECHO("Kernel:");
     for (auto& item : state.kernel) {
         ECHO(cfg.toReadableForm(cfg[item.productionNumber]));
         // TRACE(item.position);
         // TRACE(item.targetState);
     }
     ECHO("Items:");
     for (auto& item : state.items) {
         ECHO(cfg.toReadableForm(cfg[item.productionNumber]));
         TRACE(item.position);
         TRACE(item.targetState);
         TRACE(static_cast<int>(item.action));
     }
     // TRACE(state.kernel.size());
     // TRACE(state.items.size());
     ECHO("");
 }
开发者ID:Ghabriel,项目名称:FormalLanguageUtils,代码行数:18,代码来源:Parser.hpp

示例14: main

int main(int argc, char *argv[]) {
    //regex_test();
    /*
    CFG<Parse_data> *cfg = read_grammar(ss.str());
    if (cfg)
        cout << endl << cfg->str() << endl << endl;
        */
    SymbolTable *symtab = new SymbolTable();
    Lexer<int> *lexer = read_lexer(file_to_string(argv[1]), symtab);
    CFG<int> *cfg = read_grammar(file_to_string(argv[2]), symtab);
    //cout << cfg->dfa->str() << endl << endl;
    cfg->parse(lexer->lex(file_to_string(argv[3]), true, true), true);

    // for (int i = 0; i < lexer->rules.size()-2; ++i) {
    //     cout << lexer->rules[i].regex.dfa->str() << endl;
    // }
    
    return 0;
}
开发者ID:bmild,项目名称:grammarian,代码行数:19,代码来源:parser.cpp

示例15: expandState

    inline void expandState(LR0State& state, const CFG& cfg) {
        for (auto& item : state.items) {
            // TRACE(item.productionNumber);
            const Production& prod = cfg[item.productionNumber];
            if (item.position >= prod.size()) {
                continue;
            }

            auto symbol = prod[item.position];
            if (cfg.isNonTerminal(symbol)) {
                for (std::size_t i = 0; i < cfg.size(); i++) {
                    const Production& production = cfg[i];
                    if (production.getName() == symbol) {
                        state.items.emplace_back(LR0Item{i, 0});
                    }
                }
            }
        }
    }
开发者ID:Ghabriel,项目名称:FormalLanguageUtils,代码行数:19,代码来源:Parser.hpp


注:本文中的CFG类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。