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


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

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


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

示例1: Files

	ClangParser()
	{
		// Usually all examples try to build the CompilerInstance Object from CompilerInvocation object.
		// However, CompilterInstance already has an in-built CompilerInvocation object. So we use it.
		// Only problem is: target options are not set correctly for the in-built object. We do it manually.
		// This below line is just to assert that the object exist.
		clang::CompilerInvocation& invocation = m_CompilerInstance.getInvocation();

		// Diagnostics is needed - set it up
		m_CompilerInstance.createDiagnostics();

		// set the include directories path
		clang::HeaderSearchOptions & headerSearchOptions = m_CompilerInstance.getHeaderSearchOpts();
		headerSearchOptions.AddPath("C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\include", clang::frontend::IncludeDirGroup::Angled, false, false);
		// headerSearchOptions.Verbose = true;

		// set few options
		clang::LangOptions& langOptions = m_CompilerInstance.getLangOpts();
		langOptions.CPlusPlus = 1;
		langOptions.Bool = 1;
		langOptions.RTTI = 0;
#if defined(_MSC_VER)
		langOptions.MicrosoftExt = 1;
		langOptions.MSVCCompat = 1;
		langOptions.MSBitfields = 1;
		langOptions.DelayedTemplateParsing = 1; // MSVC parses templates at the time of actual use
		m_CompilerInstance.getDiagnosticOpts().setFormat(clang::TextDiagnosticFormat::Msvc);
		//clInstance.getTargetOpts().ABI = "microsoft";
#endif

		// Need to set the source manager before AST
		m_CompilerInstance.createFileManager();
		m_CompilerInstance.createSourceManager(m_CompilerInstance.getFileManager());

		// Need to set the target before AST. Adjust the default target options and create a target
		m_CompilerInstance.getTargetOpts().Triple = llvm::sys::getProcessTriple();
		m_CompilerInstance.setTarget(clang::TargetInfo::CreateTargetInfo(m_CompilerInstance.getDiagnostics(), &m_CompilerInstance.getTargetOpts()));

		// Create pre-processor and AST Context
		m_CompilerInstance.createPreprocessor(clang::TranslationUnitKind::TU_Module);
		m_CompilerInstance.createASTContext();
		if (m_CompilerInstance.hasPreprocessor())
		{
			clang::Preprocessor & preprocessor = m_CompilerInstance.getPreprocessor();
			preprocessor.getBuiltinInfo().InitializeBuiltins(preprocessor.getIdentifierTable(), preprocessor.getLangOpts());
		}
	}
开发者ID:KrishnaPG,项目名称:CodingAssistant-Clang,代码行数:47,代码来源:main.cpp


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