diff options
| author | 2021-08-05 14:15:56 -0700 | |
|---|---|---|
| committer | 2021-08-05 15:37:18 -0700 | |
| commit | ecb965cd7c47fa5636814f92d83a20b90a4f7ee5 (patch) | |
| tree | 448944a871b0c816729e9df7c21ba1c594df423d | |
| parent | aa87e1d092f2b459ab2b1aaf179e4f5920a8dc87 (diff) | |
Fix enum_value_name() for compiler update.
Bug: 195659713
Test: run libinput_test
Change-Id: I82c1d98bd189e60f86a26a02281c49167368e8ad
| -rw-r--r-- | include/input/NamedEnum.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/input/NamedEnum.h b/include/input/NamedEnum.h index 6562348701..8d3f6b7946 100644 --- a/include/input/NamedEnum.h +++ b/include/input/NamedEnum.h @@ -50,6 +50,10 @@ constexpr std::optional<std::string_view> enum_value_name() { // Example (cont'd): V = android::test::TestEnums::ONE view = view.substr(valStart); + // Check invalid enum values with cast, like V = (android::test::TestEnums)8. + if (view.find('(') != std::string::npos) { + return std::nullopt; + } size_t nameStart = view.rfind("::"); if (nameStart == std::string::npos) { return std::nullopt; |