[flang] Tweak API per review
authorpeter klausler <pklausler@nvidia.com>
Tue, 5 Mar 2019 21:11:57 +0000 (13:11 -0800)
committerpeter klausler <pklausler@nvidia.com>
Tue, 5 Mar 2019 21:11:57 +0000 (13:11 -0800)
Original-commit: flang-compiler/f18@c0ab787cd1eb82a13fca9a473973b25e737da77a
Reviewed-on: https://github.com/flang-compiler/f18/pull/311

flang/lib/semantics/tools.cc
flang/lib/semantics/tools.h

index 9418c21..4f3334a 100644 (file)
@@ -87,22 +87,25 @@ bool IsUseAssociated(const Symbol &symbol, const Scope &scope) {
       owner != FindProgramUnitContaining(scope);
 }
 
-bool IsAncestor(const Scope *maybeAncestor, const Scope &maybeDescendent) {
-  if (maybeAncestor == nullptr) {
-    return false;
-  }
-  const Scope *scope{&maybeDescendent};
-  while (scope->kind() != Scope::Kind::Global) {
-    scope = &scope->parent();
-    if (scope == maybeAncestor) {
-      return true;
+bool DoesScopeContain(const Scope *maybeAncestor, const Scope &maybeDescendent) {
+  if (maybeAncestor != nullptr) {
+    const Scope *scope{&maybeDescendent};
+    while (scope->kind() != Scope::Kind::Global) {
+      scope = &scope->parent();
+      if (scope == maybeAncestor) {
+        return true;
+      }
     }
   }
   return false;
 }
 
+bool DoesScopeContain(const Scope *maybeAncestor, const Symbol &symbol) {
+  return DoesScopeContain(maybeAncestor, symbol.owner());
+}
+
 bool IsHostAssociated(const Symbol &symbol, const Scope &scope) {
-  return IsAncestor(FindProgramUnitContaining(symbol), scope);
+  return DoesScopeContain(FindProgramUnitContaining(symbol), scope);
 }
 
 bool IsDummy(const Symbol &symbol) {
index 49638bd..d83fe50 100644 (file)
@@ -35,7 +35,8 @@ const Symbol *FindPointerComponent(const DeclTypeSpec &);
 const Symbol *FindPointerComponent(const Symbol &);
 
 bool IsCommonBlockContaining(const Symbol &block, const Symbol &object);
-bool IsAncestor(const Scope *maybeAncestor, const Scope &maybeDescendent);
+bool DoesScopeContain(const Scope *maybeAncestor, const Scope &maybeDescendent);
+bool DoesScopeContain(const Scope *, const Symbol &);
 bool IsUseAssociated(const Symbol *, const Scope &);
 bool IsHostAssociated(const Symbol &, const Scope &);
 bool IsDummy(const Symbol &);