Add acyclic check pass to hidl-gen

Adds recursive tree pass that checks that directed graph of
definitions and references is acyclic.
It prints nice error message, which shows the whole found cycle.

To be really tested, it requires lookups to be moved outside of parsing.

Test: hidl_test
Bug: 31827278

Change-Id: I9e96fa8206cfb84a56298991c526f71befae1478
diff --git a/Interface.cpp b/Interface.cpp
index 10fb89d..8eb5907 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -484,6 +484,21 @@
     return ret;
 }
 
+std::vector<Reference<Type>> Interface::getStrongReferences() const {
+    // Interface is a special case as a reference:
+    // its definiton must be completed for extension but
+    // not necessary for other references.
+    // As interface declaration appears only in global scope and
+    // method declaration appears only in interface, we may assume
+    // that all references in method definitions are acyclic.
+
+    std::vector<Reference<Type>> ret;
+    if (superType() != nullptr) {
+        ret.push_back(mSuperType);
+    }
+    return ret;
+}
+
 status_t Interface::resolveInheritance() {
     size_t serial = FIRST_CALL_TRANSACTION;
     for (const auto* ancestor : superTypeChain()) {