本文整理汇总了C++中TranslationUnit::getPreprocessor方法的典型用法代码示例。如果您正苦于以下问题:C++ TranslationUnit::getPreprocessor方法的具体用法?C++ TranslationUnit::getPreprocessor怎么用?C++ TranslationUnit::getPreprocessor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationUnit
的用法示例。
在下文中一共展示了TranslationUnit::getPreprocessor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
llvm::cl::ParseCommandLineOptions(argc, argv, "clang-wpa");
std::vector<ASTUnit*> ASTUnits;
Program Prog;
Indexer Idxer(Prog);
if (InputFilenames.empty())
return 0;
DiagnosticOptions DiagOpts;
llvm::IntrusiveRefCntPtr<Diagnostic> Diags
= CompilerInstance::createDiagnostics(DiagOpts, argc, argv);
for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
const std::string &InFile = InputFilenames[i];
llvm::OwningPtr<ASTUnit> AST(ASTUnit::LoadFromASTFile(InFile, Diags));
if (!AST)
return 1;
ASTUnits.push_back(AST.take());
}
if (ViewCallGraph) {
llvm::OwningPtr<CallGraph> CG;
CG.reset(new CallGraph(Prog));
for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i)
CG->addTU(ASTUnits[i]->getASTContext());
CG->ViewCallGraph();
return 0;
}
if (AnalyzeFunction.empty())
return 0;
// Feed all ASTUnits to the Indexer.
for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i) {
ASTUnitTU *TU = new ASTUnitTU(ASTUnits[i]);
Idxer.IndexAST(TU);
}
Entity Ent = Entity::get(AnalyzeFunction, Prog);
FunctionDecl *FD;
TranslationUnit *TU;
llvm::tie(FD, TU) = Idxer.getDefinitionFor(Ent);
if (!FD)
return 0;
// Create an analysis engine.
Preprocessor &PP = TU->getPreprocessor();
// Hard code options for now.
AnalysisManager AMgr(TU->getASTContext(), PP.getDiagnostics(),
PP.getLangOptions(), /* PathDiagnostic */ 0,
CreateRegionStoreManager,
CreateRangeConstraintManager, &Idxer,
/* MaxNodes */ 300000, /* MaxLoop */ 3,
/* VisualizeEG */ false, /* VisualizeEGUbi */ false,
/* PurgeDead */ true, /* EagerlyAssume */ false,
/* TrimGraph */ false, /* InlineCall */ true,
/* UseUnoptimizedCFG */ false);
GRTransferFuncs* TF = MakeCFRefCountTF(AMgr.getASTContext(), /*GC*/false,
AMgr.getLangOptions());
GRExprEngine Eng(AMgr, TF);
Eng.ExecuteWorkList(AMgr.getStackFrame(FD, TU), AMgr.getMaxNodes());
return 0;
}