Merge "header-checker: Downgrade to C++ 14"
am: 1f4f441945
Change-Id: I813233bc994ba4b326085f3a887a49467ba54bb1
This commit is contained in:
@@ -32,7 +32,7 @@ cc_defaults {
|
|||||||
cppflags: [
|
cppflags: [
|
||||||
"-fno-exceptions",
|
"-fno-exceptions",
|
||||||
"-fno-rtti",
|
"-fno-rtti",
|
||||||
"-std=c++17",
|
"-std=c++14",
|
||||||
],
|
],
|
||||||
|
|
||||||
target: {
|
target: {
|
||||||
@@ -211,6 +211,7 @@ cc_test_host {
|
|||||||
],
|
],
|
||||||
|
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
|
"libLLVM_host",
|
||||||
"libc++_host",
|
"libc++_host",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -156,8 +156,9 @@ static std::string GetConfigFilePath(const std::string &dump_file_path) {
|
|||||||
static void ReadConfigFile(const std::string &config_file_path) {
|
static void ReadConfigFile(const std::string &config_file_path) {
|
||||||
ConfigFile cfg = ConfigParser::ParseFile(config_file_path);
|
ConfigFile cfg = ConfigParser::ParseFile(config_file_path);
|
||||||
if (cfg.HasSection("global")) {
|
if (cfg.HasSection("global")) {
|
||||||
for (auto &&[key, value] : cfg.GetSection("global")) {
|
for (auto &&p : cfg.GetSection("global")) {
|
||||||
bool value_bool = ParseBool(value);
|
auto &&key = p.first;
|
||||||
|
bool value_bool = ParseBool(p.second);
|
||||||
if (key == "allow_adding_removing_weak_symbols") {
|
if (key == "allow_adding_removing_weak_symbols") {
|
||||||
allow_adding_removing_weak_symbols = value_bool;
|
allow_adding_removing_weak_symbols = value_bool;
|
||||||
} else if (key == "advice_only") {
|
} else if (key == "advice_only") {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "utils/command_line_utils.h"
|
#include "utils/command_line_utils.h"
|
||||||
#include "utils/header_abi_util.h"
|
#include "utils/header_abi_util.h"
|
||||||
|
|
||||||
|
#include <llvm/ADT/Optional.h>
|
||||||
#include <llvm/Support/CommandLine.h>
|
#include <llvm/Support/CommandLine.h>
|
||||||
#include <llvm/Support/raw_ostream.h>
|
#include <llvm/Support/raw_ostream.h>
|
||||||
|
|
||||||
@@ -401,7 +402,7 @@ bool HeaderAbiLinker::ReadExportedSymbols() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() {
|
bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() {
|
||||||
std::optional<utils::ApiLevel> api_level = utils::ParseApiLevel(api_);
|
llvm::Optional<utils::ApiLevel> api_level = utils::ParseApiLevel(api_);
|
||||||
if (!api_level) {
|
if (!api_level) {
|
||||||
llvm::errs() << "-api must be either \"current\" or an integer (e.g. 21)\n";
|
llvm::errs() << "-api must be either \"current\" or an integer (e.g. 21)\n";
|
||||||
return false;
|
return false;
|
||||||
@@ -415,7 +416,7 @@ bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() {
|
|||||||
|
|
||||||
repr::VersionScriptParser parser;
|
repr::VersionScriptParser parser;
|
||||||
parser.SetArch(arch_);
|
parser.SetArch(arch_);
|
||||||
parser.SetApiLevel(api_level.value());
|
parser.SetApiLevel(api_level.getValue());
|
||||||
for (auto &&version : excluded_symbol_versions_) {
|
for (auto &&version : excluded_symbol_versions_) {
|
||||||
parser.AddExcludedSymbolVersion(version);
|
parser.AddExcludedSymbolVersion(version);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include "repr/symbol/exported_symbol_set.h"
|
#include "repr/symbol/exported_symbol_set.h"
|
||||||
#include "utils/string_utils.h"
|
#include "utils/string_utils.h"
|
||||||
|
|
||||||
|
#include <llvm/ADT/Optional.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
@@ -94,28 +96,28 @@ VersionScriptParser::ParsedTags VersionScriptParser::ParseSymbolTags(
|
|||||||
|
|
||||||
// Check introduced tags.
|
// Check introduced tags.
|
||||||
if (utils::StartsWith(tag, "introduced=")) {
|
if (utils::StartsWith(tag, "introduced=")) {
|
||||||
std::optional<utils::ApiLevel> intro = utils::ParseApiLevel(
|
llvm::Optional<utils::ApiLevel> intro = utils::ParseApiLevel(
|
||||||
std::string(tag.substr(sizeof("introduced=") - 1)));
|
std::string(tag.substr(sizeof("introduced=") - 1)));
|
||||||
if (!intro) {
|
if (!intro) {
|
||||||
ReportError("Bad introduced tag: " + std::string(tag));
|
ReportError("Bad introduced tag: " + std::string(tag));
|
||||||
} else {
|
} else {
|
||||||
if (!has_introduced_arch_tags) {
|
if (!has_introduced_arch_tags) {
|
||||||
result.has_introduced_tags_ = true;
|
result.has_introduced_tags_ = true;
|
||||||
result.introduced_ = intro.value();
|
result.introduced_ = intro.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils::StartsWith(tag, introduced_arch_tag_)) {
|
if (utils::StartsWith(tag, introduced_arch_tag_)) {
|
||||||
std::optional<utils::ApiLevel> intro = utils::ParseApiLevel(
|
llvm::Optional<utils::ApiLevel> intro = utils::ParseApiLevel(
|
||||||
std::string(tag.substr(introduced_arch_tag_.size())));
|
std::string(tag.substr(introduced_arch_tag_.size())));
|
||||||
if (!intro) {
|
if (!intro) {
|
||||||
ReportError("Bad introduced tag " + std::string(tag));
|
ReportError("Bad introduced tag " + std::string(tag));
|
||||||
} else {
|
} else {
|
||||||
has_introduced_arch_tags = true;
|
has_introduced_arch_tags = true;
|
||||||
result.has_introduced_tags_ = true;
|
result.has_introduced_tags_ = true;
|
||||||
result.introduced_ = intro.value();
|
result.introduced_ = intro.getValue();
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "utils/string_utils.h"
|
#include "utils/string_utils.h"
|
||||||
|
|
||||||
|
#include <llvm/ADT/Optional.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@ namespace header_checker {
|
|||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
|
|
||||||
std::optional<ApiLevel> ParseApiLevel(const std::string &api_level_str) {
|
llvm::Optional<ApiLevel> ParseApiLevel(const std::string &api_level_str) {
|
||||||
if (api_level_str == "current") {
|
if (api_level_str == "current") {
|
||||||
return FUTURE_API_LEVEL;
|
return FUTURE_API_LEVEL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
#ifndef API_LEVEL_H_
|
#ifndef API_LEVEL_H_
|
||||||
#define API_LEVEL_H_
|
#define API_LEVEL_H_
|
||||||
|
|
||||||
#include <optional>
|
#include <llvm/ADT/Optional.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ using ApiLevel = int;
|
|||||||
constexpr ApiLevel FUTURE_API_LEVEL = 10000;
|
constexpr ApiLevel FUTURE_API_LEVEL = 10000;
|
||||||
|
|
||||||
|
|
||||||
std::optional<ApiLevel> ParseApiLevel(const std::string &api);
|
llvm::Optional<ApiLevel> ParseApiLevel(const std::string &api);
|
||||||
|
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ TEST(ApiLevelTest, ParseApiLevel) {
|
|||||||
EXPECT_FALSE(ParseApiLevel(""));
|
EXPECT_FALSE(ParseApiLevel(""));
|
||||||
EXPECT_FALSE(ParseApiLevel("A"));
|
EXPECT_FALSE(ParseApiLevel("A"));
|
||||||
|
|
||||||
EXPECT_TRUE(ParseApiLevel("current").has_value());
|
EXPECT_TRUE(ParseApiLevel("current").hasValue());
|
||||||
EXPECT_EQ(FUTURE_API_LEVEL, ParseApiLevel("current").value());
|
EXPECT_EQ(FUTURE_API_LEVEL, ParseApiLevel("current").getValue());
|
||||||
|
|
||||||
EXPECT_TRUE(ParseApiLevel("16").has_value());
|
EXPECT_TRUE(ParseApiLevel("16").hasValue());
|
||||||
EXPECT_EQ(16l, ParseApiLevel("16").value());
|
EXPECT_EQ(16l, ParseApiLevel("16").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include "utils/string_utils.h"
|
#include "utils/string_utils.h"
|
||||||
|
|
||||||
|
#include <llvm/ADT/Optional.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -72,7 +74,7 @@ std::vector<std::string_view> Split(std::string_view s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::optional<int> ParseInt(const std::string &s) {
|
llvm::Optional<int> ParseInt(const std::string &s) {
|
||||||
const char *start = s.c_str();
|
const char *start = s.c_str();
|
||||||
if (*start == '\0') {
|
if (*start == '\0') {
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
#ifndef STRING_UTILS_H_
|
#ifndef STRING_UTILS_H_
|
||||||
#define STRING_UTILS_H_
|
#define STRING_UTILS_H_
|
||||||
|
|
||||||
#include <optional>
|
#include <llvm/ADT/Optional.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ bool EndsWith(std::string_view s, std::string_view suffix);
|
|||||||
std::vector<std::string_view> Split(std::string_view s,
|
std::vector<std::string_view> Split(std::string_view s,
|
||||||
std::string_view delim_chars);
|
std::string_view delim_chars);
|
||||||
|
|
||||||
std::optional<int> ParseInt(const std::string &s);
|
llvm::Optional<int> ParseInt(const std::string &s);
|
||||||
|
|
||||||
bool ParseBool(const std::string &s);
|
bool ParseBool(const std::string &s);
|
||||||
|
|
||||||
|
|||||||
@@ -83,14 +83,14 @@ TEST(StringUtilsTest, ParseInt) {
|
|||||||
EXPECT_FALSE(ParseInt("0xa"));
|
EXPECT_FALSE(ParseInt("0xa"));
|
||||||
EXPECT_FALSE(ParseInt("16h"));
|
EXPECT_FALSE(ParseInt("16h"));
|
||||||
|
|
||||||
EXPECT_TRUE(ParseInt("0").has_value());
|
EXPECT_TRUE(ParseInt("0").hasValue());
|
||||||
EXPECT_EQ(0, ParseInt("0").value());
|
EXPECT_EQ(0, ParseInt("0").getValue());
|
||||||
|
|
||||||
EXPECT_TRUE(ParseInt("16").has_value());
|
EXPECT_TRUE(ParseInt("16").hasValue());
|
||||||
EXPECT_EQ(16, ParseInt("16").value());
|
EXPECT_EQ(16, ParseInt("16").getValue());
|
||||||
|
|
||||||
EXPECT_TRUE(ParseInt("-16").has_value());
|
EXPECT_TRUE(ParseInt("-16").hasValue());
|
||||||
EXPECT_EQ(-16, ParseInt("-16").value());
|
EXPECT_EQ(-16, ParseInt("-16").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user