diff --git a/vndk/tools/header-checker/Android.bp b/vndk/tools/header-checker/Android.bp index 65e248497..d22ac551d 100644 --- a/vndk/tools/header-checker/Android.bp +++ b/vndk/tools/header-checker/Android.bp @@ -32,7 +32,7 @@ cc_defaults { cppflags: [ "-fno-exceptions", "-fno-rtti", - "-std=c++17", + "-std=c++14", ], target: { @@ -211,6 +211,7 @@ cc_test_host { ], shared_libs: [ + "libLLVM_host", "libc++_host", ], diff --git a/vndk/tools/header-checker/src/diff/header_abi_diff.cpp b/vndk/tools/header-checker/src/diff/header_abi_diff.cpp index e0ead7423..f482253c1 100644 --- a/vndk/tools/header-checker/src/diff/header_abi_diff.cpp +++ b/vndk/tools/header-checker/src/diff/header_abi_diff.cpp @@ -156,8 +156,9 @@ static std::string GetConfigFilePath(const std::string &dump_file_path) { static void ReadConfigFile(const std::string &config_file_path) { ConfigFile cfg = ConfigParser::ParseFile(config_file_path); if (cfg.HasSection("global")) { - for (auto &&[key, value] : cfg.GetSection("global")) { - bool value_bool = ParseBool(value); + for (auto &&p : cfg.GetSection("global")) { + auto &&key = p.first; + bool value_bool = ParseBool(p.second); if (key == "allow_adding_removing_weak_symbols") { allow_adding_removing_weak_symbols = value_bool; } else if (key == "advice_only") { diff --git a/vndk/tools/header-checker/src/linker/header_abi_linker.cpp b/vndk/tools/header-checker/src/linker/header_abi_linker.cpp index 618c2092b..802241c3f 100644 --- a/vndk/tools/header-checker/src/linker/header_abi_linker.cpp +++ b/vndk/tools/header-checker/src/linker/header_abi_linker.cpp @@ -20,6 +20,7 @@ #include "utils/command_line_utils.h" #include "utils/header_abi_util.h" +#include #include #include @@ -401,7 +402,7 @@ bool HeaderAbiLinker::ReadExportedSymbols() { } bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() { - std::optional api_level = utils::ParseApiLevel(api_); + llvm::Optional api_level = utils::ParseApiLevel(api_); if (!api_level) { llvm::errs() << "-api must be either \"current\" or an integer (e.g. 21)\n"; return false; @@ -415,7 +416,7 @@ bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() { repr::VersionScriptParser parser; parser.SetArch(arch_); - parser.SetApiLevel(api_level.value()); + parser.SetApiLevel(api_level.getValue()); for (auto &&version : excluded_symbol_versions_) { parser.AddExcludedSymbolVersion(version); } diff --git a/vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp b/vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp index eecbfe554..274ecd4e7 100644 --- a/vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp +++ b/vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp @@ -17,6 +17,8 @@ #include "repr/symbol/exported_symbol_set.h" #include "utils/string_utils.h" +#include + #include #include #include @@ -94,28 +96,28 @@ VersionScriptParser::ParsedTags VersionScriptParser::ParseSymbolTags( // Check introduced tags. if (utils::StartsWith(tag, "introduced=")) { - std::optional intro = utils::ParseApiLevel( + llvm::Optional intro = utils::ParseApiLevel( std::string(tag.substr(sizeof("introduced=") - 1))); if (!intro) { ReportError("Bad introduced tag: " + std::string(tag)); } else { if (!has_introduced_arch_tags) { result.has_introduced_tags_ = true; - result.introduced_ = intro.value(); + result.introduced_ = intro.getValue(); } } continue; } if (utils::StartsWith(tag, introduced_arch_tag_)) { - std::optional intro = utils::ParseApiLevel( + llvm::Optional intro = utils::ParseApiLevel( std::string(tag.substr(introduced_arch_tag_.size()))); if (!intro) { ReportError("Bad introduced tag " + std::string(tag)); } else { has_introduced_arch_tags = true; result.has_introduced_tags_ = true; - result.introduced_ = intro.value(); + result.introduced_ = intro.getValue(); } continue; } diff --git a/vndk/tools/header-checker/src/utils/api_level.cpp b/vndk/tools/header-checker/src/utils/api_level.cpp index a04b9b42b..d588e4134 100644 --- a/vndk/tools/header-checker/src/utils/api_level.cpp +++ b/vndk/tools/header-checker/src/utils/api_level.cpp @@ -16,6 +16,8 @@ #include "utils/string_utils.h" +#include + #include #include @@ -24,7 +26,7 @@ namespace header_checker { namespace utils { -std::optional ParseApiLevel(const std::string &api_level_str) { +llvm::Optional ParseApiLevel(const std::string &api_level_str) { if (api_level_str == "current") { return FUTURE_API_LEVEL; } diff --git a/vndk/tools/header-checker/src/utils/api_level.h b/vndk/tools/header-checker/src/utils/api_level.h index 45e86e47c..834dd6d99 100644 --- a/vndk/tools/header-checker/src/utils/api_level.h +++ b/vndk/tools/header-checker/src/utils/api_level.h @@ -15,7 +15,8 @@ #ifndef API_LEVEL_H_ #define API_LEVEL_H_ -#include +#include + #include @@ -29,7 +30,7 @@ using ApiLevel = int; constexpr ApiLevel FUTURE_API_LEVEL = 10000; -std::optional ParseApiLevel(const std::string &api); +llvm::Optional ParseApiLevel(const std::string &api); } // namespace utils diff --git a/vndk/tools/header-checker/src/utils/api_level_test.cpp b/vndk/tools/header-checker/src/utils/api_level_test.cpp index 74f06675b..c1de948aa 100644 --- a/vndk/tools/header-checker/src/utils/api_level_test.cpp +++ b/vndk/tools/header-checker/src/utils/api_level_test.cpp @@ -25,11 +25,11 @@ TEST(ApiLevelTest, ParseApiLevel) { EXPECT_FALSE(ParseApiLevel("")); EXPECT_FALSE(ParseApiLevel("A")); - EXPECT_TRUE(ParseApiLevel("current").has_value()); - EXPECT_EQ(FUTURE_API_LEVEL, ParseApiLevel("current").value()); + EXPECT_TRUE(ParseApiLevel("current").hasValue()); + EXPECT_EQ(FUTURE_API_LEVEL, ParseApiLevel("current").getValue()); - EXPECT_TRUE(ParseApiLevel("16").has_value()); - EXPECT_EQ(16l, ParseApiLevel("16").value()); + EXPECT_TRUE(ParseApiLevel("16").hasValue()); + EXPECT_EQ(16l, ParseApiLevel("16").getValue()); } diff --git a/vndk/tools/header-checker/src/utils/string_utils.cpp b/vndk/tools/header-checker/src/utils/string_utils.cpp index 2dd97aded..4efcfbec4 100644 --- a/vndk/tools/header-checker/src/utils/string_utils.cpp +++ b/vndk/tools/header-checker/src/utils/string_utils.cpp @@ -14,6 +14,8 @@ #include "utils/string_utils.h" +#include + #include #include #include @@ -72,7 +74,7 @@ std::vector Split(std::string_view s, } -std::optional ParseInt(const std::string &s) { +llvm::Optional ParseInt(const std::string &s) { const char *start = s.c_str(); if (*start == '\0') { return {}; diff --git a/vndk/tools/header-checker/src/utils/string_utils.h b/vndk/tools/header-checker/src/utils/string_utils.h index bcb840504..a42c9a546 100644 --- a/vndk/tools/header-checker/src/utils/string_utils.h +++ b/vndk/tools/header-checker/src/utils/string_utils.h @@ -15,7 +15,8 @@ #ifndef STRING_UTILS_H_ #define STRING_UTILS_H_ -#include +#include + #include #include @@ -33,7 +34,7 @@ bool EndsWith(std::string_view s, std::string_view suffix); std::vector Split(std::string_view s, std::string_view delim_chars); -std::optional ParseInt(const std::string &s); +llvm::Optional ParseInt(const std::string &s); bool ParseBool(const std::string &s); diff --git a/vndk/tools/header-checker/src/utils/string_utils_test.cpp b/vndk/tools/header-checker/src/utils/string_utils_test.cpp index 4ad007440..98f25ca4c 100644 --- a/vndk/tools/header-checker/src/utils/string_utils_test.cpp +++ b/vndk/tools/header-checker/src/utils/string_utils_test.cpp @@ -83,14 +83,14 @@ TEST(StringUtilsTest, ParseInt) { EXPECT_FALSE(ParseInt("0xa")); EXPECT_FALSE(ParseInt("16h")); - EXPECT_TRUE(ParseInt("0").has_value()); - EXPECT_EQ(0, ParseInt("0").value()); + EXPECT_TRUE(ParseInt("0").hasValue()); + EXPECT_EQ(0, ParseInt("0").getValue()); - EXPECT_TRUE(ParseInt("16").has_value()); - EXPECT_EQ(16, ParseInt("16").value()); + EXPECT_TRUE(ParseInt("16").hasValue()); + EXPECT_EQ(16, ParseInt("16").getValue()); - EXPECT_TRUE(ParseInt("-16").has_value()); - EXPECT_EQ(-16, ParseInt("-16").value()); + EXPECT_TRUE(ParseInt("-16").hasValue()); + EXPECT_EQ(-16, ParseInt("-16").getValue()); }