本文整理汇总了C++中clang::CompilerInstance::getASTContext方法的典型用法代码示例。如果您正苦于以下问题:C++ CompilerInstance::getASTContext方法的具体用法?C++ CompilerInstance::getASTContext怎么用?C++ CompilerInstance::getASTContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clang::CompilerInstance
的用法示例。
在下文中一共展示了CompilerInstance::getASTContext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
bool WebCLValidatorAction::initialize(clang::CompilerInstance &instance)
{
if (!WebCLAction::initialize(instance))
return false;
rewriter_ = new clang::Rewriter(
instance.getSourceManager(), instance.getLangOpts());
if (!rewriter_) {
reporter_->fatal("Internal error. Can't create rewriter.\n");
return false;
}
transformer_ = new WebCLTransformer(instance, *rewriter_);
if (!transformer_) {
reporter_->fatal("Internal error. Can't create AST transformer.\n");
return false;
}
// Consumer must be allocated dynamically. The framework deletes
// it.
consumer_ = new WebCLConsumer(instance, *rewriter_, *transformer_);
if (!consumer_) {
reporter_->fatal("Internal error. Can't create AST consumer.\n");
return false;
}
sema_ = new clang::Sema(
instance.getPreprocessor(), instance.getASTContext(), *consumer_);
if (!sema_) {
reporter_->fatal("Internal error. Can't create semantic actions.\n");
return false;
}
return true;
}
示例2: sizeOfPointer
int TypeUtils::sizeOfPointer(const clang::CompilerInstance &ci, clang::QualType qt)
{
if (!qt.getTypePtrOrNull())
return -1;
// HACK: What's a better way of getting the size of a pointer ?
auto &astContext = ci.getASTContext();
return astContext.getTypeSize(astContext.getPointerType(qt));
}
示例3: MatchFinder
std::unique_ptr<clang::ASTConsumer>
ClangTidyASTConsumerFactory::CreateASTConsumer(
clang::CompilerInstance &Compiler, StringRef File) {
// FIXME: Move this to a separate method, so that CreateASTConsumer doesn't
// modify Compiler.
Context.setSourceManager(&Compiler.getSourceManager());
Context.setCurrentFile(File);
Context.setASTContext(&Compiler.getASTContext());
std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
CheckFactories->createChecks(&Context, Checks);
ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
if (auto *P = Context.getCheckProfileData())
FinderOptions.CheckProfiling.emplace(P->Records);
std::unique_ptr<ast_matchers::MatchFinder> Finder(
new ast_matchers::MatchFinder(std::move(FinderOptions)));
for (auto &Check : Checks) {
Check->registerMatchers(&*Finder);
Check->registerPPCallbacks(Compiler);
}
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
if (!Checks.empty())
Consumers.push_back(Finder->newASTConsumer());
AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
// FIXME: Remove this option once clang's cfg-temporary-dtors option defaults
// to true.
AnalyzerOptions->Config["cfg-temporary-dtors"] =
Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";
GlobList &Filter = Context.getChecksFilter();
AnalyzerOptions->CheckersControlList = getCheckersControlList(Filter);
if (!AnalyzerOptions->CheckersControlList.empty()) {
setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
AnalyzerOptions->AnalyzeNestedBlocks = true;
AnalyzerOptions->eagerlyAssumeBinOpBifurcation = true;
std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer =
ento::CreateAnalysisConsumer(Compiler);
AnalysisConsumer->AddDiagnosticConsumer(
new AnalyzerDiagnosticConsumer(Context));
Consumers.push_back(std::move(AnalysisConsumer));
}
return llvm::make_unique<ClangTidyASTConsumer>(
std::move(Consumers), std::move(Finder), std::move(Checks));
}
示例4: parseAST
bool parseAST(const char* szSourceCodeFilePath, clang::ast_matchers::MatchFinder finder)
{
// create the compiler instance setup for this file as main file
prepareCompilerforFile(szSourceCodeFilePath);
std::unique_ptr<clang::ASTConsumer> pAstConsumer (finder.newASTConsumer());
clang::DiagnosticConsumer& diagConsumer = m_CompilerInstance.getDiagnosticClient();
diagConsumer.BeginSourceFile(m_CompilerInstance.getLangOpts(), &m_CompilerInstance.getPreprocessor());
clang::ParseAST(m_CompilerInstance.getPreprocessor(), pAstConsumer.get(), m_CompilerInstance.getASTContext());
diagConsumer.EndSourceFile();
return diagConsumer.getNumErrors() != 0;
}
示例5: FindNamedClassConsumer
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
clang::CompilerInstance &Compiler, llvm::StringRef InFile)
{
return std::unique_ptr<clang::ASTConsumer>(
new FindNamedClassConsumer(&Compiler.getASTContext()));
}
示例6: CreateASTConsumer
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
clang::CompilerInstance &Compiler, llvm::StringRef InFile)
{
return std::unique_ptr<clang::ASTConsumer>(new fxc::Driver(Compiler.getASTContext(), Compiler.getDiagnostics()));
}
示例7: CreateASTConsumer
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance & compiler, llvm::StringRef inFile )
{
return std::unique_ptr< clang::ASTConsumer >( new MetricsCalculatorASTConsumer( &compiler.getASTContext() ) );
}
示例8: isTooBigForQList
bool QtUtils::isTooBigForQList(clang::QualType qt, const clang::CompilerInstance &ci)
{
return (int)ci.getASTContext().getTypeSize(qt) <= TypeUtils::sizeOfPointer(ci, qt);
}
示例9: GetASTContext
clang::ASTContext& GetASTContext() { return m_CompilerInstance.getASTContext(); }