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


C++ CompilerInstance::getFrontendOpts方法代码示例

本文整理汇总了C++中clang::CompilerInstance::getFrontendOpts方法的典型用法代码示例。如果您正苦于以下问题:C++ CompilerInstance::getFrontendOpts方法的具体用法?C++ CompilerInstance::getFrontendOpts怎么用?C++ CompilerInstance::getFrontendOpts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clang::CompilerInstance的用法示例。


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

示例1: prepareCompilerforFile

	void prepareCompilerforFile(const char* szSourceCodeFilePath)
	{
		// To reuse the source manager we have to create these tables.
		m_CompilerInstance.getSourceManager().clearIDTables();
		//m_CompilerInstance.InitializeSourceManager(clang::FrontendInputFile(szSourceCodeFilePath, clang::InputKind::IK_C));// ger(m_CompilerInstance.getFileManager());

		// supply the file to the source manager and set it as main-file 
		const clang::FileEntry * file = m_CompilerInstance.getFileManager().getFile(szSourceCodeFilePath);
		clang::FileID fileID = m_CompilerInstance.getSourceManager().createFileID(file, clang::SourceLocation(), clang::SrcMgr::CharacteristicKind::C_User);
		m_CompilerInstance.getSourceManager().setMainFileID(fileID);

		// CodeGenAction needs this
		clang::FrontendOptions& feOptions = m_CompilerInstance.getFrontendOpts();
		feOptions.Inputs.clear();
		feOptions.Inputs.push_back(clang::FrontendInputFile(szSourceCodeFilePath, clang::FrontendOptions::getInputKindForExtension(clang::StringRef(szSourceCodeFilePath).rsplit('.').second), false));
	}
开发者ID:KrishnaPG,项目名称:CodingAssistant-Clang,代码行数:16,代码来源:main.cpp

示例2: CreateASTConsumer

TriaAction::CreateAstConsumerResultType TriaAction::CreateASTConsumer (clang::CompilerInstance &ci,
                                                                       llvm::StringRef fileName) {
	ci.getFrontendOpts().SkipFunctionBodies = true;
	ci.getPreprocessor().enableIncrementalProcessing (true);
	ci.getLangOpts().DelayedTemplateParsing = true;
	
	// Enable everything for code compatibility
	ci.getLangOpts().MicrosoftExt = true;
	ci.getLangOpts().DollarIdents = true;
	ci.getLangOpts().CPlusPlus11 = true;
	ci.getLangOpts().GNUMode = true;
	
#if CLANG_VERSION_MINOR < 6
	ci.getLangOpts().CPlusPlus1y = true;
#else
	ci.getLangOpts().CPlusPlus14 = true;
#endif
	
	if (argVerboseTimes) {
		UNIQUE_COMPAT(PreprocessorHooks, hook, new PreprocessorHooks (ci));
		hook->timing ()->name = sourceFileName (this->m_definitions->sourceFiles ());
		this->m_definitions->setTimingNode (hook->timing ());
		ci.getPreprocessor ().addPPCallbacks (MOVE_COMPAT(hook));
	}
	
	// 
	QStringList whichInherit;
	for (const std::string &cur : argInspectBases) {
		whichInherit.append (QString::fromStdString (cur));
	}
	
	// 
	TriaASTConsumer *consumer = new TriaASTConsumer (ci, fileName, whichInherit, argInspectAll,
	                                                 argGlobalClass, this->m_definitions);
	
#if CLANG_VERSION_MINOR < 6
	return consumer;
#else
	return std::unique_ptr< clang::ASTConsumer > (consumer);
#endif
}
开发者ID:NuriaProject,项目名称:Tria,代码行数:41,代码来源:triaaction.cpp

示例3: initialize

bool WebCLAction::initialize(clang::CompilerInstance &instance)
{
    reporter_ = new WebCLReporter(instance);
    if (!reporter_) {
        llvm::errs() << "Internal error. Can't report errors.\n";
        return false;
    }

    preprocessor_ = new WebCLPreprocessor(instance, extensions_, usedExtensions_);
    if (!preprocessor_) {
        reporter_->fatal("Internal error. Can't create preprocessor callbacks.\n");
        return false;
    }
    clang::Preprocessor &preprocessor = instance.getPreprocessor();
    preprocessor.addPPCallbacks(preprocessor_);

    if (output_) {
        // see clang::PrintPreprocessedAction
        instance.getFrontendOpts().OutputFile = output_;
        out_ = instance.createDefaultOutputFile(true, getCurrentFile());
        if (!out_) {
            reporter_->fatal("Internal error. Can't create output stream.");
            return false;
        }
    }

    const clang::FrontendInputFile &file = getCurrentInput();
    if (file.getKind() != clang::IK_OpenCL) {
        static const char *format =
            "Source file '%0' isn't treated as OpenCL code. Make sure that you "
            "give the '-x cl' option or that the file has a '.cl' extension.\n";
        reporter_->fatal(format) << file.getFile();
        return false;
    }

    return true;
}
开发者ID:KhronosGroup,项目名称:webcl-validator,代码行数:37,代码来源:WebCLAction.cpp


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