versioner: improve error output slightly.
Print [introduced = 9, deprecated = 10, obsoleted = 11] instead of [9,10,11]. Change-Id: Ifb8a66abbcec92aa13086d220af7ee6fa17b0897
This commit is contained in:
parent
658dbd920d
commit
173e7c0753
|
@ -19,6 +19,7 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -72,6 +73,31 @@ struct DeclarationAvailability {
|
|||
int obsoleted = 0;
|
||||
|
||||
void dump(std::ostream& out = std::cout) const {
|
||||
out << describe();
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return !(introduced || deprecated || obsoleted);
|
||||
}
|
||||
|
||||
auto tie() const {
|
||||
return std::tie(introduced, deprecated, obsoleted);
|
||||
}
|
||||
|
||||
bool operator==(const DeclarationAvailability& rhs) const {
|
||||
return this->tie() == rhs.tie();
|
||||
}
|
||||
|
||||
bool operator!=(const DeclarationAvailability& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
std::string describe() const {
|
||||
if (!(introduced || deprecated || obsoleted)) {
|
||||
return "no availability";
|
||||
}
|
||||
|
||||
std::stringstream out;
|
||||
bool need_comma = false;
|
||||
auto comma = [&out, &need_comma]() {
|
||||
if (!need_comma) {
|
||||
|
@ -93,27 +119,8 @@ struct DeclarationAvailability {
|
|||
comma();
|
||||
out << "obsoleted = " << obsoleted;
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return !(introduced || deprecated || obsoleted);
|
||||
}
|
||||
|
||||
auto tie() const {
|
||||
return std::tie(introduced, deprecated, obsoleted);
|
||||
}
|
||||
|
||||
bool operator==(const DeclarationAvailability& rhs) const {
|
||||
return this->tie() == rhs.tie();
|
||||
}
|
||||
|
||||
bool operator!=(const DeclarationAvailability& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
std::string describe() const {
|
||||
return std::string("[") + std::to_string(introduced) + "," + std::to_string(deprecated) + "," +
|
||||
std::to_string(obsoleted) + "]";
|
||||
return out.str();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -137,6 +144,26 @@ struct DeclarationLocation {
|
|||
bool operator==(const DeclarationLocation& other) const {
|
||||
return tie() == other.tie();
|
||||
}
|
||||
|
||||
void dump(const std::string& base_path = "", std::ostream& out = std::cout) const {
|
||||
const char* var_type = declarationTypeName(type);
|
||||
const char* declaration_type = is_definition ? "definition" : "declaration";
|
||||
const char* linkage = is_extern ? "extern" : "static";
|
||||
|
||||
std::string stripped_path;
|
||||
if (llvm::StringRef(filename).startswith(base_path)) {
|
||||
stripped_path = filename.substr(base_path.size());
|
||||
} else {
|
||||
stripped_path = filename;
|
||||
}
|
||||
|
||||
out << " " << linkage << " " << var_type << " " << declaration_type << " @ "
|
||||
<< stripped_path << ":" << line_number << ":" << column;
|
||||
|
||||
out << "\t[";
|
||||
availability.dump(out);
|
||||
out << "]\n";
|
||||
}
|
||||
};
|
||||
|
||||
struct Declaration {
|
||||
|
@ -165,29 +192,7 @@ struct Declaration {
|
|||
void dump(const std::string& base_path = "", std::ostream& out = std::cout) const {
|
||||
out << " " << name << " declared in " << locations.size() << " locations:\n";
|
||||
for (const DeclarationLocation& location : locations) {
|
||||
const char* var_type = declarationTypeName(location.type);
|
||||
const char* declaration_type = location.is_definition ? "definition" : "declaration";
|
||||
const char* linkage = location.is_extern ? "extern" : "static";
|
||||
|
||||
std::string filename;
|
||||
if (llvm::StringRef(location.filename).startswith(base_path)) {
|
||||
filename = location.filename.substr(base_path.size());
|
||||
} else {
|
||||
filename = location.filename;
|
||||
}
|
||||
|
||||
out << " " << linkage << " " << var_type << " " << declaration_type << " @ "
|
||||
<< filename << ":" << location.line_number << ":" << location.column;
|
||||
|
||||
if (!location.availability.empty()) {
|
||||
out << "\t[";
|
||||
location.availability.dump(out);
|
||||
out << "]";
|
||||
} else {
|
||||
out << "\t[no availability]";
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
location.dump(base_path, out);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -318,7 +318,7 @@ static bool sanityCheck(const std::set<CompilationType>& types,
|
|||
// Make sure that availability declarations are consistent across API levels for a given arch.
|
||||
if (last_availability != current_availability) {
|
||||
error = true;
|
||||
printf("%s: availability mismatch between %s and %s: %s before, %s after\n",
|
||||
printf("%s: availability mismatch between %s and %s: [%s] before, [%s] after\n",
|
||||
symbol_name.c_str(), last_type.describe().c_str(), type.describe().c_str(),
|
||||
last_availability.describe().c_str(), current_availability.describe().c_str());
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
foo: availability mismatch between arm-9 and arm-12: [9,0,0] before, [10,0,0] after
|
||||
foo: availability mismatch between arm-9 and arm-12: [introduced = 9] before, [introduced = 10] after
|
||||
versioner: sanity check failed
|
||||
|
|
Loading…
Reference in New Issue