Scope defineScope()

in glean/lang/clang/ast.cpp [505:525]


  Scope defineScope(const clang::DeclContext *ctx) {
    while (ctx) {
      if (clang::isa<clang::TranslationUnitDecl>(ctx)) {
        return GlobalScope{};
      } else if (auto x = clang::dyn_cast<clang::NamespaceDecl>(ctx)) {
        if (auto r = namespaces(x)) {
          return NamespaceScope{x, r->qname};
        }
      } else if (auto x = clang::dyn_cast<clang::CXXRecordDecl>(ctx)) {
        if (auto r = classDecls(x)) {
          return ClassScope{x, r->qname};
        }
      } else if (auto x = clang::dyn_cast<clang::FunctionDecl>(ctx)) {
        if (auto r = funDecls(x)) {
          return LocalScope{x, r->qname};
        }
      }
      ctx = ctx->getParent();
    }
    return GlobalScope{};
  }