hidl-gen: warnings for bad annotations
hidl-gen never paid attention to annotations, and we can see in-tree
that there are some annotatoins which don't do anything.
Warnings instead of errors, since it doesn't make sense to break
downstream (might enable them after a long time if it became more
important).
Bug: 173732508
Test: build/test with adding errors to cleanup AOSP interfaces
Change-Id: I5b68a25f5e39239b2061c0e5186710f5cbf12c22
diff --git a/Scope.cpp b/Scope.cpp
index 588ba95..026a7ac 100644
--- a/Scope.cpp
+++ b/Scope.cpp
@@ -41,6 +41,13 @@
mTypeIndexByName[type->definedName()] = index;
}
+status_t Scope::validate() const {
+ status_t status = validateAnnotations();
+ if (status != OK) return status;
+
+ return NamedType::validate();
+}
+
status_t Scope::validateUniqueNames() const {
for (const auto* type : mTypes) {
if (mTypes[mTypeIndexByName.at(type->definedName())] != type) {
@@ -52,6 +59,15 @@
return OK;
}
+status_t Scope::validateAnnotations() const {
+ for (const Annotation* annotation : annotations()) {
+ std::cerr << "WARNING: Unrecognized annotation '" << annotation->name() << "' at "
+ << location() << ". No annotations are supported here." << std::endl;
+ // This is a warning to avoid breaking downstream unnecessarily.
+ }
+ return OK;
+}
+
NamedType *Scope::lookupType(const FQName &fqName) const {
CHECK(fqName.package().empty() && fqName.version().empty());
if (!fqName.valueName().empty()) {