Pull up IsUserDefined()
IsUserDefined() is an AidlNode with AIDL_LOCATION_HERE. These nodes are
skipped from lint/dump.
Bug: 218912230
Test: aidl_integration_test
Change-Id: Ic72fa2d0570b5d4b98f7a7cc05d114d7f294f7df
diff --git a/aidl.cpp b/aidl.cpp
index fd63c6a..6938b53 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -578,18 +578,18 @@
if (options.Version() > 0) {
auto ret = typenames->MakeResolvedType(AIDL_LOCATION_HERE, "int", false);
vector<unique_ptr<AidlArgument>>* args = new vector<unique_ptr<AidlArgument>>();
- auto method = std::make_unique<AidlMethod>(
- AIDL_LOCATION_HERE, false, ret.release(), "getInterfaceVersion", args, Comments{},
- kGetInterfaceVersionId, false /* is_user_defined */);
+ auto method = std::make_unique<AidlMethod>(AIDL_LOCATION_HERE, false, ret.release(),
+ "getInterfaceVersion", args, Comments{},
+ kGetInterfaceVersionId);
interface->AddMethod(std::move(method));
}
// add the meta-method 'string getInterfaceHash()' if hash is specified.
if (!options.Hash().empty()) {
auto ret = typenames->MakeResolvedType(AIDL_LOCATION_HERE, "String", false);
vector<unique_ptr<AidlArgument>>* args = new vector<unique_ptr<AidlArgument>>();
- auto method = std::make_unique<AidlMethod>(
- AIDL_LOCATION_HERE, false, ret.release(), kGetInterfaceHash, args, Comments{},
- kGetInterfaceHashId, false /* is_user_defined */);
+ auto method =
+ std::make_unique<AidlMethod>(AIDL_LOCATION_HERE, false, ret.release(),
+ kGetInterfaceHash, args, Comments{}, kGetInterfaceHashId);
interface->AddMethod(std::move(method));
}
if (!CheckAndAssignMethodIDs(interface->GetMethods())) {
diff --git a/aidl_dumpapi.cpp b/aidl_dumpapi.cpp
index 7d3f19d..30f65dc 100644
--- a/aidl_dumpapi.cpp
+++ b/aidl_dumpapi.cpp
@@ -32,6 +32,9 @@
namespace aidl {
void DumpVisitor::DumpType(const AidlDefinedType& dt, const string& type) {
+ if (!dt.IsUserDefined()) {
+ return;
+ }
DumpComments(dt);
DumpAnnotations(dt);
out << type << " " << dt.GetName();
@@ -47,7 +50,6 @@
void DumpVisitor::DumpMembers(const AidlDefinedType& dt) {
for (const auto& method : dt.GetMethods()) {
- if (!method->IsUserDefined()) continue;
method->DispatchVisit(*this);
}
for (const auto& field : dt.GetFields()) {
@@ -95,16 +97,23 @@
void DumpVisitor::Visit(const AidlInterface& t) {
DumpType(t, "interface");
}
+
void DumpVisitor::Visit(const AidlParcelable& t) {
DumpType(t, "parcelable");
}
+
void DumpVisitor::Visit(const AidlStructuredParcelable& t) {
DumpType(t, "parcelable");
}
+
void DumpVisitor::Visit(const AidlUnionDecl& t) {
DumpType(t, "union");
}
+
void DumpVisitor::Visit(const AidlEnumDeclaration& t) {
+ if (!t.IsUserDefined()) {
+ return;
+ }
DumpComments(t);
DumpAnnotations(t);
out << "enum " << t.GetName() << " {\n";
@@ -119,10 +128,17 @@
}
void DumpVisitor::Visit(const AidlMethod& m) {
+ if (!m.IsUserDefined()) {
+ return;
+ }
DumpComments(m);
out << m.ToString() << ";\n";
}
+
void DumpVisitor::Visit(const AidlVariableDeclaration& v) {
+ if (!v.IsUserDefined()) {
+ return;
+ }
DumpComments(v);
Visit(v.GetType());
if (v.IsDefaultUserSpecified()) {
@@ -133,7 +149,11 @@
out << " " << v.GetName() << ";\n";
}
}
+
void DumpVisitor::Visit(const AidlConstantDeclaration& c) {
+ if (!c.IsUserDefined()) {
+ return;
+ }
DumpComments(c);
out << "const ";
Visit(c.GetType());
diff --git a/aidl_language.cpp b/aidl_language.cpp
index e6b4b32..c835396 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -1068,20 +1068,19 @@
AidlMethod::AidlMethod(const AidlLocation& location, bool oneway, AidlTypeSpecifier* type,
const std::string& name, std::vector<std::unique_ptr<AidlArgument>>* args,
const Comments& comments)
- : AidlMethod(location, oneway, type, name, args, comments, 0, true) {
+ : AidlMethod(location, oneway, type, name, args, comments, 0) {
has_id_ = false;
}
AidlMethod::AidlMethod(const AidlLocation& location, bool oneway, AidlTypeSpecifier* type,
const std::string& name, std::vector<std::unique_ptr<AidlArgument>>* args,
- const Comments& comments, int id, bool is_user_defined)
+ const Comments& comments, int id)
: AidlMember(location, comments),
oneway_(oneway),
type_(type),
name_(name),
arguments_(std::move(*args)),
- id_(id),
- is_user_defined_(is_user_defined) {
+ id_(id) {
has_id_ = true;
delete args;
for (const unique_ptr<AidlArgument>& a : arguments_) {
diff --git a/aidl_language.h b/aidl_language.h
index c73618f..1e52625 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -165,6 +165,7 @@
static void ClearUnvisitedNodes();
static const std::vector<AidlLocation>& GetLocationsOfUnvisitedNodes();
void MarkVisited() const;
+ bool IsUserDefined() const { return !GetLocation().IsInternal(); }
private:
std::string PrintLine() const;
@@ -854,8 +855,7 @@
AidlMethod(const AidlLocation& location, bool oneway, AidlTypeSpecifier* type, const string& name,
vector<unique_ptr<AidlArgument>>* args, const Comments& comments);
AidlMethod(const AidlLocation& location, bool oneway, AidlTypeSpecifier* type, const string& name,
- vector<unique_ptr<AidlArgument>>* args, const Comments& comments, int id,
- bool is_user_defined = true);
+ vector<unique_ptr<AidlArgument>>* args, const Comments& comments, int id);
virtual ~AidlMethod() = default;
// non-copyable, non-movable
@@ -877,8 +877,6 @@
int GetId() const { return id_; }
void SetId(unsigned id) { id_ = id; }
- bool IsUserDefined() const { return is_user_defined_; }
-
const std::vector<std::unique_ptr<AidlArgument>>& GetArguments() const {
return arguments_;
}
@@ -920,7 +918,6 @@
std::vector<const AidlArgument*> out_arguments_;
bool has_id_;
int id_;
- bool is_user_defined_ = true;
};
// AidlDefinedType represents either an interface, parcelable, or enum that is
diff --git a/diagnostics.cpp b/diagnostics.cpp
index 81799c0..0eca8ae 100644
--- a/diagnostics.cpp
+++ b/diagnostics.cpp
@@ -55,6 +55,9 @@
DiagnosticsContext(DiagnosticMapping mapping) : mapping_({std::move(mapping)}) {}
AidlErrorLog Report(const AidlLocation& loc, DiagnosticID id,
DiagnosticSeverity force_severity = DiagnosticSeverity::DISABLED) {
+ if (loc.IsInternal()) {
+ return AidlErrorLog(AidlErrorLog::NO_OP, loc);
+ }
const std::string suffix = " [-W" + to_string(id) + "]";
auto severity = std::max(force_severity, mapping_.top().Severity(id));
switch (severity) {