本文整理汇总了C++中ASTReader类的典型用法代码示例。如果您正苦于以下问题:C++ ASTReader类的具体用法?C++ ASTReader怎么用?C++ ASTReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ASTReader类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m_Interpreter
InterpreterCallbacks::InterpreterCallbacks(Interpreter* interp,
bool enableExternalSemaSourceCallbacks/* = false*/,
bool enableDeserializationListenerCallbacks/* = false*/,
bool enablePPCallbacks/* = false*/)
: m_Interpreter(interp), m_IsRuntime(false) {
if (enableExternalSemaSourceCallbacks) {
m_ExternalSemaSource.reset(new InterpreterExternalSemaSource(this));
m_Interpreter->getSema().addExternalSource(m_ExternalSemaSource.get());
}
ASTReader* Reader = m_Interpreter->getCI()->getModuleManager();
if (enableDeserializationListenerCallbacks && Reader) {
// FIXME: need to create a multiplexer if a DeserializationListener is
// alreday present.
m_DeserializationListener.
reset(new InterpreterDeserializationListener(this));
Reader->setDeserializationListener(m_DeserializationListener.get());
}
if (enablePPCallbacks) {
m_PPCallbacks.reset(new InterpreterPPCallbacks(this));
Preprocessor& PP = m_Interpreter->getCI()->getPreprocessor();
PP.addPPCallbacks(m_PPCallbacks.get());
}
}
示例2: dumpModuleFileInputs
static void dumpModuleFileInputs(serialization::ModuleFile &Mod,
ASTReader &Reader,
raw_ostream &OS) {
OS << "---- Module Inputs ----\n";
Reader.visitInputFiles(Mod, /*IncludeSystem=*/true, /*Complain=*/false,
[&](const serialization::InputFile &IF, bool isSystem) {
OS << (isSystem ? "system" : "user") << " | ";
OS << IF.getFile()->getName() << '\n';
});
}
示例3: m_Interpreter
InterpreterCallbacks::InterpreterCallbacks(Interpreter* interp,
bool enableExternalSemaSourceCallbacks/* = false*/,
bool enableDeserializationListenerCallbacks/* = false*/,
bool enablePPCallbacks/* = false*/)
: m_Interpreter(interp), m_ExternalSemaSource(0), m_PPCallbacks(0),
m_IsRuntime(false) {
Sema& SemaRef = interp->getSema();
ASTReader* Reader = m_Interpreter->getCI()->getModuleManager().get();
ExternalSemaSource* externalSemaSrc = SemaRef.getExternalSource();
if (enableExternalSemaSourceCallbacks)
if (!externalSemaSrc || externalSemaSrc == Reader) {
// If the ExternalSemaSource is the PCH reader we still need to insert
// our listener.
m_ExternalSemaSource = new InterpreterExternalSemaSource(this);
m_ExternalSemaSource->InitializeSema(SemaRef);
m_Interpreter->getSema().addExternalSource(m_ExternalSemaSource);
// FIXME: We should add a multiplexer in the ASTContext, too.
llvm::IntrusiveRefCntPtr<ExternalASTSource>
astContextExternalSource(SemaRef.getExternalSource());
clang::ASTContext& Ctx = SemaRef.getASTContext();
// FIXME: This is a gross hack. We must make multiplexer in the
// astcontext or a derived class that extends what we need.
Ctx.ExternalSource.resetWithoutRelease();//FIXME: make sure we delete it.
Ctx.setExternalSource(astContextExternalSource);
}
if (enableDeserializationListenerCallbacks && Reader) {
// FIXME: need to create a multiplexer if a DeserializationListener is
// alreday present.
m_DeserializationListener.
reset(new InterpreterDeserializationListener(this));
Reader->setDeserializationListener(m_DeserializationListener.get());
}
if (enablePPCallbacks) {
Preprocessor& PP = m_Interpreter->getCI()->getPreprocessor();
m_PPCallbacks = new InterpreterPPCallbacks(this);
PP.addPPCallbacks(std::unique_ptr<InterpreterPPCallbacks>(m_PPCallbacks));
}
}
示例4: Reader
std::unique_ptr<ModuleFileExtensionReader>
TestModuleFileExtension::createExtensionReader(
const ModuleFileExtensionMetadata &Metadata,
ASTReader &Reader, serialization::ModuleFile &Mod,
const llvm::BitstreamCursor &Stream)
{
assert(Metadata.BlockName == BlockName && "Wrong block name");
if (std::make_pair(Metadata.MajorVersion, Metadata.MinorVersion) !=
std::make_pair(MajorVersion, MinorVersion)) {
Reader.getDiags().Report(Mod.ImportLoc,
diag::err_test_module_file_extension_version)
<< BlockName << Metadata.MajorVersion << Metadata.MinorVersion
<< MajorVersion << MinorVersion;
return nullptr;
}
return std::unique_ptr<ModuleFileExtensionReader>(
new TestModuleFileExtension::Reader(this, Stream));
}
示例5: assert
void DependencyFileGenerator::AttachToASTReader(ASTReader &R) {
DFGImpl *I = reinterpret_cast<DFGImpl *>(Impl);
assert(I && "missing implementation");
R.addListener(llvm::make_unique<DFGASTReaderListener>(*I));
}
示例6: attachToASTReader
void DependencyCollector::attachToASTReader(ASTReader &R) {
R.addListener(llvm::make_unique<DepCollectorASTListener>(*this));
}
示例7: attachToASTReader
void DependencyCollector::attachToASTReader(ASTReader &R) {
R.addListener(new DepCollectorASTListener(*this));
}
示例8: attachToASTReader
void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
R.addListener(llvm::make_unique<ModuleDependencyListener>(*this));
}
示例9: AST
ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
bool OnlyLocalDecls,
RemappedFile *RemappedFiles,
unsigned NumRemappedFiles,
bool CaptureDiagnostics) {
llvm::OwningPtr<ASTUnit> AST(new ASTUnit(true));
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>
ASTUnitCleanup(AST.get());
llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine,
llvm::CrashRecoveryContextReleaseRefCleanup<DiagnosticsEngine> >
DiagCleanup(Diags.getPtr());
ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics);
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
AST->Diagnostics = Diags;
AST->FileMgr = new FileManager(FileSystemOpts);
AST->SourceMgr = new SourceManager(AST->getDiagnostics(),
AST->getFileManager());
AST->ImportInfo.reset(new ImportSearch(AST->getFileManager()));
for (unsigned I = 0; I != NumRemappedFiles; ++I) {
FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) {
// Create the file entry for the file that we're mapping from.
const FileEntry *FromFile
= AST->getFileManager().getVirtualFile(RemappedFiles[I].first,
memBuf->getBufferSize(),
0);
if (!FromFile) {
AST->getDiagnostics().Report(diag::err_fe_remap_missing_from_file)
<< RemappedFiles[I].first;
delete memBuf;
continue;
}
// Override the contents of the "from" file with the contents of
// the "to" file.
AST->getSourceManager().overrideFileContents(FromFile, memBuf);
} else {
const char *fname = fileOrBuf.get<const char *>();
const FileEntry *ToFile = AST->FileMgr->getFile(fname);
if (!ToFile) {
AST->getDiagnostics().Report(diag::err_fe_remap_missing_to_file)
<< RemappedFiles[I].first << fname;
continue;
}
// Create the file entry for the file that we're mapping from.
const FileEntry *FromFile
= AST->getFileManager().getVirtualFile(RemappedFiles[I].first,
ToFile->getSize(),
0);
if (!FromFile) {
AST->getDiagnostics().Report(diag::err_fe_remap_missing_from_file)
<< RemappedFiles[I].first;
delete memBuf;
continue;
}
// Override the contents of the "from" file with the contents of
// the "to" file.
AST->getSourceManager().overrideFileContents(FromFile, ToFile);
}
}
// Gather Info for preprocessor construction later on.
LangOptions LangInfo;
ImportSearch &HeaderInfo = *AST->ImportInfo.get();
std::string TargetTriple;
std::string Predefines;
unsigned Counter;
llvm::OwningPtr<ASTReader> Reader;
Reader.reset(new ASTReader(AST->getSourceManager(), AST->getFileManager(),
AST->getDiagnostics()));
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar<ASTReader>
ReaderCleanup(Reader.get());
Reader->setListener(new ASTInfoCollector(LangInfo, HeaderInfo, TargetTriple,
Predefines, Counter));
switch (Reader->ReadAST(Filename, ASTReader::MainFile)) {
case ASTReader::Success:
break;
case ASTReader::Failure:
case ASTReader::IgnorePCH:
AST->getDiagnostics().Report(diag::err_fe_unable_to_load_pch);
//.........这里部分代码省略.........