本文整理汇总了C++中SourceFile::getScope方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceFile::getScope方法的具体用法?C++ SourceFile::getScope怎么用?C++ SourceFile::getScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceFile
的用法示例。
在下文中一共展示了SourceFile::getScope方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performCompile
//.........这里部分代码省略.........
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 Context.hadError();
}
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::DumpScopeMaps ||
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::DumpScopeMaps) {
ASTScope &scope = SF->getScope();
if (opts.DumpScopeMapLocations.empty()) {
scope.expandAll();
} else if (auto bufferID = SF->getBufferID()) {
SourceManager &sourceMgr = Instance->getSourceMgr();
// Probe each of the locations, and dump what we find.
for (auto lineColumn : opts.DumpScopeMapLocations) {
SourceLoc loc = sourceMgr.getLocForLineCol(*bufferID,
lineColumn.first,
lineColumn.second);
if (loc.isInvalid()) continue;
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() << " ";