本文整理汇总了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));
}
示例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
}
示例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;
}