summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Prichard <rprichard@google.com>2024-02-15 17:49:32 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-02-15 17:49:32 +0000
commit42f592ef4f4343b042bdc26cc3c25356649611b2 (patch)
tree501f13e0b719f95b3bffc2413d4fc9411bc2057b
parent2487e59982b3ce524ca43d14d8ba92403e656d47 (diff)
parent1fe2a1571fddfeb49816d899dd8170811491dbb8 (diff)
downloaddevelopment-42f592ef4f4343b042bdc26cc3c25356649611b2.tar.gz
Merge "header-checker: replace llvm::Optional with std::optional" into main
-rw-r--r--vndk/tools/header-checker/src/linker/header_abi_linker.cpp4
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp7
-rw-r--r--vndk/tools/header-checker/src/utils/api_level.cpp2
-rw-r--r--vndk/tools/header-checker/src/utils/api_level.h5
-rw-r--r--vndk/tools/header-checker/src/utils/string_utils.cpp5
-rw-r--r--vndk/tools/header-checker/src/utils/string_utils.h5
6 files changed, 12 insertions, 16 deletions
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 d98673a68..98e6226c2 100644
--- a/vndk/tools/header-checker/src/linker/header_abi_linker.cpp
+++ b/vndk/tools/header-checker/src/linker/header_abi_linker.cpp
@@ -21,7 +21,6 @@
#include "utils/command_line_utils.h"
#include "utils/source_path_utils.h"
-#include <llvm/ADT/Optional.h>
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/raw_ostream.h>
@@ -29,6 +28,7 @@
#include <functional>
#include <iostream>
#include <memory>
+#include <optional>
#include <string>
#include <thread>
#include <vector>
@@ -429,7 +429,7 @@ bool HeaderAbiLinker::ReadExportedSymbols() {
}
bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() {
- llvm::Optional<utils::ApiLevel> api_level = api_level_map_.Parse(api_);
+ std::optional<utils::ApiLevel> api_level = api_level_map_.Parse(api_);
if (!api_level) {
llvm::errs() << "-api must be either \"current\" or an integer (e.g. 21)\n";
return false;
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 8ce450fdc..fe1735587 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,10 +17,9 @@
#include "repr/symbol/exported_symbol_set.h"
#include "utils/string_utils.h"
-#include <llvm/ADT/Optional.h>
-
#include <iostream>
#include <memory>
+#include <optional>
#include <regex>
#include <set>
#include <string>
@@ -102,7 +101,7 @@ VersionScriptParser::ParsedTags VersionScriptParser::ParseSymbolTags(
// Check introduced tags.
if (utils::StartsWith(tag, "introduced=")) {
- llvm::Optional<utils::ApiLevel> intro = api_level_map_.Parse(
+ std::optional<utils::ApiLevel> intro = api_level_map_.Parse(
std::string(tag.substr(sizeof("introduced=") - 1)));
if (!intro) {
ReportError("Bad introduced tag: " + std::string(tag));
@@ -116,7 +115,7 @@ VersionScriptParser::ParsedTags VersionScriptParser::ParseSymbolTags(
}
if (utils::StartsWith(tag, introduced_arch_tag_)) {
- llvm::Optional<utils::ApiLevel> intro = api_level_map_.Parse(
+ std::optional<utils::ApiLevel> intro = api_level_map_.Parse(
std::string(tag.substr(introduced_arch_tag_.size())));
if (!intro) {
ReportError("Bad introduced tag " + std::string(tag));
diff --git a/vndk/tools/header-checker/src/utils/api_level.cpp b/vndk/tools/header-checker/src/utils/api_level.cpp
index 421aad53d..6dcfcd16b 100644
--- a/vndk/tools/header-checker/src/utils/api_level.cpp
+++ b/vndk/tools/header-checker/src/utils/api_level.cpp
@@ -46,7 +46,7 @@ bool ApiLevelMap::Load(std::istream &stream) {
return true;
}
-llvm::Optional<ApiLevel> ApiLevelMap::Parse(const std::string &api) const {
+std::optional<ApiLevel> ApiLevelMap::Parse(const std::string &api) const {
auto it = codename_to_api_level_.find(api);
if (it != codename_to_api_level_.end()) {
return it->second;
diff --git a/vndk/tools/header-checker/src/utils/api_level.h b/vndk/tools/header-checker/src/utils/api_level.h
index 53e9c60c3..23f2c7342 100644
--- a/vndk/tools/header-checker/src/utils/api_level.h
+++ b/vndk/tools/header-checker/src/utils/api_level.h
@@ -15,10 +15,9 @@
#ifndef API_LEVEL_H_
#define API_LEVEL_H_
-#include <llvm/ADT/Optional.h>
-
#include <istream>
#include <map>
+#include <optional>
#include <string>
@@ -37,7 +36,7 @@ class ApiLevelMap {
// Load a json object and return whether the operation succeeds.
bool Load(std::istream &stream);
- llvm::Optional<ApiLevel> Parse(const std::string &api) const;
+ std::optional<ApiLevel> Parse(const std::string &api) const;
private:
std::map<std::string, ApiLevel> codename_to_api_level_;
diff --git a/vndk/tools/header-checker/src/utils/string_utils.cpp b/vndk/tools/header-checker/src/utils/string_utils.cpp
index 8cb205310..f31d4f36b 100644
--- a/vndk/tools/header-checker/src/utils/string_utils.cpp
+++ b/vndk/tools/header-checker/src/utils/string_utils.cpp
@@ -19,11 +19,10 @@
#include <algorithm>
#include <cctype>
#include <cstdlib>
+#include <optional>
#include <string>
#include <utility>
-#include <llvm/ADT/Optional.h>
-
namespace header_checker {
namespace utils {
@@ -76,7 +75,7 @@ std::vector<std::string_view> Split(std::string_view s,
}
-llvm::Optional<int> ParseInt(const std::string &s) {
+std::optional<int> 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 2111377fd..f515f765f 100644
--- a/vndk/tools/header-checker/src/utils/string_utils.h
+++ b/vndk/tools/header-checker/src/utils/string_utils.h
@@ -15,8 +15,7 @@
#ifndef STRING_UTILS_H_
#define STRING_UTILS_H_
-#include <llvm/ADT/Optional.h>
-
+#include <optional>
#include <set>
#include <string>
#include <vector>
@@ -38,7 +37,7 @@ bool EndsWith(std::string_view s, std::string_view suffix);
std::vector<std::string_view> Split(std::string_view s,
std::string_view delim_chars);
-llvm::Optional<int> ParseInt(const std::string &s);
+std::optional<int> ParseInt(const std::string &s);
bool ParseBool(const std::string &s);