Make recursive methods in Type work with cyclic AST
Fixes Type::canCheckEquality, Type::needsResolveReferences,
Type::isJavaCompatible, Type:containsPointer.
Adds set of visited Types to these functions to prevent
infinite recursion.
deep versions of these functions *do not* guarantee the correct
return value, but non-deep versions do:
We need to find al least one path from requested vertex
to "bad" vertex (ie. which is not java compatible).
Fixes a bug with containsPointer (containsPointer returned true
if inner type contained a pointer), so more structures get
__attribute__ aligned and static_assert generated for
struct fields.
This change is required for forward reference, as current
implementations assume that the graph is acyclic.
Potential future work: to reduce theoretical complexity of
described actions (square to linear).
Bug: 31827278
Test: mma
Test: output not changed in
out/soong/.intermediates/hardware/interfaces
Change-Id: I3dbdd1605f9317637241057b12de6031125abf7b
diff --git a/AST.cpp b/AST.cpp
index ed58a37..ac997e2 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -591,18 +591,7 @@
}
bool AST::isJavaCompatible() const {
- if (!AST::isInterface()) {
- for (const auto* type : mRootScope.getSubTypes()) {
- if (!type->isJavaCompatible()) {
- return false;
- }
- }
-
- return true;
- }
-
- const Interface* iface = mRootScope.getInterface();
- return iface->isJavaCompatible();
+ return mRootScope.isJavaCompatible();
}
void AST::appendToExportedTypesVector(