diff options
author | Jooyung Han <jooyung@google.com> | 2021-02-10 14:01:07 +0900 |
---|---|---|
committer | Jooyung Han <jooyung@google.com> | 2021-02-10 16:13:22 +0900 |
commit | 1d78a36f296fbc1a566fd37939df5bf4e19d8ae9 (patch) | |
tree | c404f5f94d0a856f10e671ec241ba822bd1cc86d /diagnostics.cpp | |
parent | a439bf67e4edc60cf9a6760d7d407c6b15b70067 (diff) | |
download | aidl-1d78a36f296fbc1a566fd37939df5bf4e19d8ae9.tar.gz |
Fix -Wmixed-oneway
Synthetic methods should be skipped when checking mixed-oneway.
Bug: none
Test: m aidl_unittests
Change-Id: Ic593e5a0aaa046ac38d93681a31e936ef7e7cad0
Diffstat (limited to 'diagnostics.cpp')
-rw-r--r-- | diagnostics.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/diagnostics.cpp b/diagnostics.cpp index b9138c70..baec2d76 100644 --- a/diagnostics.cpp +++ b/diagnostics.cpp @@ -17,7 +17,6 @@ #include <functional> #include <stack> -#include <unordered_set> #include "aidl_language.h" #include "logging.h" @@ -192,10 +191,17 @@ struct DiagnoseExplicitDefault : DiagnosticsVisitor { struct DiagnoseMixedOneway : DiagnosticsVisitor { DiagnoseMixedOneway(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {} void Visit(const AidlInterface& i) override { - const auto& methods = i.GetMethods(); - if (std::adjacent_find(begin(methods), end(methods), [](const auto& a, const auto& b) { - return a->IsOneway() != b->IsOneway(); - }) != end(methods)) { + bool has_oneway = false; + bool has_twoway = false; + for (const auto& m : i.GetMethods()) { + if (!m->IsUserDefined()) continue; + if (m->IsOneway()) { + has_oneway = true; + } else { + has_twoway = true; + } + } + if (has_oneway && has_twoway) { diag.Report(i.GetLocation(), DiagnosticID::mixed_oneway) << "The interface '" << i.GetName() << "' has both one-way and two-way methods."; } |