Merge "versioner: start using C++17."

am: c816e9fa03

Change-Id: Ie148482169ab9cfae841a94b95b8266c520a45e6
This commit is contained in:
Josh Gao 2016-12-16 22:25:27 +00:00 committed by android-build-merger
commit 73c9ecd00d
3 changed files with 31 additions and 32 deletions

View file

@ -37,6 +37,7 @@ cc_binary_host {
target: {
host: {
cppflags: [
"-std=gnu++1z",
"-fno-rtti",
],
},

View file

@ -61,11 +61,10 @@ class Visitor : public RecursiveASTVisitor<Visitor> {
return mangled;
}
auto identifier = decl->getIdentifier();
if (!identifier) {
return "<error>";
if (auto identifier = decl->getIdentifier()) {
return identifier->getName();
}
return identifier->getName();
return "<error>";
}
bool VisitDecl(Decl* decl) {
@ -172,18 +171,16 @@ class Visitor : public RecursiveASTVisitor<Visitor> {
&arch_availability[Arch::x86_64].introduced } },
};
auto it = prefix_map.find(fragments[0]);
if (it == prefix_map.end()) {
continue;
}
int value;
if (fragments[1].getAsInteger(10, value)) {
errx(1, "invalid __ANDROID_AVAILABILITY_DUMP__ annotation: '%s'",
annotation.str().c_str());
}
if (auto it = prefix_map.find(fragments[0]); it != prefix_map.end()) {
int value;
if (fragments[1].getAsInteger(10, value)) {
errx(1, "invalid __ANDROID_AVAILABILITY_DUMP__ annotation: '%s'",
annotation.str().c_str());
}
for (int* ptr : it->second) {
*ptr = value;
for (int* ptr : it->second) {
*ptr = value;
}
}
}
}
@ -196,8 +193,16 @@ class Visitor : public RecursiveASTVisitor<Visitor> {
}
// Find or insert an entry for the declaration.
auto declaration_it = symbol_it->second.declarations.find(location);
if (declaration_it == symbol_it->second.declarations.end()) {
if (auto declaration_it = symbol_it->second.declarations.find(location);
declaration_it != symbol_it->second.declarations.end()) {
if (declaration_it->second.is_extern != is_extern ||
declaration_it->second.is_definition != is_definition ||
declaration_it->second.no_guard != no_guard) {
errx(1, "varying declaration of '%s' at %s:%u:%u", declaration_name.c_str(),
location.filename.c_str(), location.start.line, location.start.column);
}
declaration_it->second.availability.insert(std::make_pair(type, availability));
} else {
Declaration declaration;
declaration.name = declaration_name;
declaration.location = location;
@ -206,14 +211,6 @@ class Visitor : public RecursiveASTVisitor<Visitor> {
declaration.no_guard = no_guard;
declaration.availability.insert(std::make_pair(type, availability));
symbol_it->second.declarations.insert(std::make_pair(location, declaration));
} else {
if (declaration_it->second.is_extern != is_extern ||
declaration_it->second.is_definition != is_definition ||
declaration_it->second.no_guard != no_guard) {
errx(1, "varying declaration of '%s' at %s:%u:%u", declaration_name.c_str(),
location.filename.c_str(), location.start.line, location.start.column);
}
declaration_it->second.availability.insert(std::make_pair(type, availability));
}
return true;

View file

@ -382,8 +382,8 @@ static bool checkVersions(const std::set<CompilationType>& types,
const std::string& symbol_name = it.first;
bool symbol_error = false;
auto missing_it = missing_availability.find(symbol_name);
if (missing_it != missing_availability.end()) {
if (auto missing_it = missing_availability.find(symbol_name);
missing_it != missing_availability.end()) {
printf("%s: declaration marked available but symbol missing in [%s]\n", symbol_name.c_str(),
Join(missing_it->second, ", ").c_str());
symbol_error = true;
@ -391,8 +391,8 @@ static bool checkVersions(const std::set<CompilationType>& types,
}
if (strict) {
auto extra_it = extra_availability.find(symbol_name);
if (extra_it != extra_availability.end()) {
if (auto extra_it = extra_availability.find(symbol_name);
extra_it != extra_availability.end()) {
printf("%s: declaration marked unavailable but symbol available in [%s]\n",
symbol_name.c_str(), Join(extra_it->second, ", ").c_str());
symbol_error = true;
@ -401,11 +401,12 @@ static bool checkVersions(const std::set<CompilationType>& types,
}
if (symbol_error) {
auto symbol_it = header_database->symbols.find(symbol_name);
if (symbol_it == header_database->symbols.end()) {
if (auto symbol_it = header_database->symbols.find(symbol_name);
symbol_it != header_database->symbols.end()) {
symbol_it->second.dump(cwd);
} else {
errx(1, "failed to find symbol in header database");
}
symbol_it->second.dump(cwd);
}
}