本文整理汇总了C++中SourceFile::dumpInterfaceHash方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceFile::dumpInterfaceHash方法的具体用法?C++ SourceFile::dumpInterfaceHash怎么用?C++ SourceFile::dumpInterfaceHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceFile
的用法示例。
在下文中一共展示了SourceFile::dumpInterfaceHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performCompile
/// Performs the compile requested by the user.
/// \returns true on error
static bool performCompile(CompilerInstance &Instance,
CompilerInvocation &Invocation,
ArrayRef<const char *> Args,
int &ReturnValue) {
FrontendOptions opts = Invocation.getFrontendOptions();
FrontendOptions::ActionType Action = opts.RequestedAction;
IRGenOptions &IRGenOpts = Invocation.getIRGenOptions();
bool inputIsLLVMIr = Invocation.getInputKind() == InputFileKind::IFK_LLVM_IR;
if (inputIsLLVMIr) {
auto &LLVMContext = llvm::getGlobalContext();
// Load in bitcode file.
assert(Invocation.getInputFilenames().size() == 1 &&
"We expect a single input for bitcode input!");
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
llvm::MemoryBuffer::getFileOrSTDIN(Invocation.getInputFilenames()[0]);
if (!FileBufOrErr) {
Instance.getASTContext().Diags.diagnose(SourceLoc(),
diag::error_open_input_file,
Invocation.getInputFilenames()[0],
FileBufOrErr.getError().message());
return true;
}
llvm::MemoryBuffer *MainFile = FileBufOrErr.get().get();
llvm::SMDiagnostic Err;
std::unique_ptr<llvm::Module> Module = llvm::parseIR(
MainFile->getMemBufferRef(),
Err, LLVMContext);
if (!Module) {
// TODO: Translate from the diagnostic info to the SourceManager location
// if available.
Instance.getASTContext().Diags.diagnose(SourceLoc(),
diag::error_parse_input_file,
Invocation.getInputFilenames()[0],
Err.getMessage());
return true;
}
// TODO: remove once the frontend understands what action it should perform
IRGenOpts.OutputKind = getOutputKind(Action);
return performLLVM(IRGenOpts, Instance.getASTContext(), Module.get());
}
ReferencedNameTracker nameTracker;
bool shouldTrackReferences = !opts.ReferenceDependenciesFilePath.empty();
if (shouldTrackReferences)
Instance.setReferencedNameTracker(&nameTracker);
if (Action == FrontendOptions::DumpParse ||
Action == FrontendOptions::DumpInterfaceHash)
Instance.performParseOnly();
else
Instance.performSema();
FrontendOptions::DebugCrashMode CrashMode = opts.CrashMode;
if (CrashMode == FrontendOptions::DebugCrashMode::AssertAfterParse)
debugFailWithAssertion();
else if (CrashMode == FrontendOptions::DebugCrashMode::CrashAfterParse)
debugFailWithCrash();
ASTContext &Context = Instance.getASTContext();
if (Action == FrontendOptions::REPL) {
runREPL(Instance, ProcessCmdLine(Args.begin(), Args.end()),
Invocation.getParseStdlib());
return false;
}
SourceFile *PrimarySourceFile = Instance.getPrimarySourceFile();
// We've been told to dump the AST (either after parsing or type-checking,
// which is already differentiated in CompilerInstance::performSema()),
// so dump or print the main source file and return.
if (Action == FrontendOptions::DumpParse ||
Action == FrontendOptions::DumpAST ||
Action == FrontendOptions::PrintAST ||
Action == FrontendOptions::DumpTypeRefinementContexts ||
Action == FrontendOptions::DumpInterfaceHash) {
SourceFile *SF = PrimarySourceFile;
if (!SF) {
SourceFileKind Kind = Invocation.getSourceFileKind();
SF = &Instance.getMainModule()->getMainSourceFile(Kind);
}
if (Action == FrontendOptions::PrintAST)
SF->print(llvm::outs(), PrintOptions::printEverything());
else if (Action == FrontendOptions::DumpTypeRefinementContexts)
SF->getTypeRefinementContext()->dump(llvm::errs(), Context.SourceMgr);
else if (Action == FrontendOptions::DumpInterfaceHash)
SF->dumpInterfaceHash(llvm::errs());
else
SF->dump();
return false;
}
//.........这里部分代码省略.........
示例2: performCompile
//.........这里部分代码省略.........
llvm::errs() << "***Scope at " << lineColumn.first << ":"
<< lineColumn.second << "***\n";
auto locScope = scope.findInnermostEnclosingScope(loc);
locScope->print(llvm::errs(), 0, false, false);
// Dump the AST context, too.
if (auto dc = locScope->getDeclContext()) {
dc->printContext(llvm::errs());
}
// Grab the local bindings introduced by this scope.
auto localBindings = locScope->getLocalBindings();
if (!localBindings.empty()) {
llvm::errs() << "Local bindings: ";
interleave(localBindings.begin(), localBindings.end(),
[&](ValueDecl *value) {
llvm::errs() << value->getFullName();
},
[&]() {
llvm::errs() << " ";
});
llvm::errs() << "\n";
}
}
llvm::errs() << "***Complete scope map***\n";
}
// Print the resulting map.
scope.print(llvm::errs());
} else if (Action == FrontendOptions::DumpTypeRefinementContexts)
SF->getTypeRefinementContext()->dump(llvm::errs(), Context.SourceMgr);
else if (Action == FrontendOptions::DumpInterfaceHash)
SF->dumpInterfaceHash(llvm::errs());
else
SF->dump();
return Context.hadError();
}
// If we were asked to print Clang stats, do so.
if (opts.PrintClangStats && Context.getClangModuleLoader())
Context.getClangModuleLoader()->printStatistics();
if (!opts.DependenciesFilePath.empty())
(void)emitMakeDependencies(Context.Diags, *Instance->getDependencyTracker(),
opts);
if (shouldTrackReferences)
emitReferenceDependencies(Context.Diags, Instance->getPrimarySourceFile(),
*Instance->getDependencyTracker(), opts);
if (Context.hadError())
return true;
// FIXME: This is still a lousy approximation of whether the module file will
// be externally consumed.
bool moduleIsPublic =
!Instance->getMainModule()->hasEntryPoint() &&
opts.ImplicitObjCHeaderPath.empty() &&
!Context.LangOpts.EnableAppExtensionRestrictions;
// We've just been told to perform a typecheck, so we can return now.
if (Action == FrontendOptions::Typecheck) {
if (!opts.ObjCHeaderOutputPath.empty())
return printAsObjC(opts.ObjCHeaderOutputPath, Instance->getMainModule(),
opts.ImplicitObjCHeaderPath, moduleIsPublic);