Merge changes I94b119a0,Id6522955,Ie9b95842,I687e4a31,Ibc355441
* changes: header-checker: Remove _FORTIFY_SOURCE workaround header-checker: Remove OpenMP workaround header-checker: Extract SoFileParser header-checker: Extract VersionScriptParser header-checker: Code cleanup
This commit is contained in:
@@ -59,8 +59,6 @@ cc_binary_host {
|
||||
"header-abi-dumper/src/frontend_action.cpp",
|
||||
"header-abi-dumper/src/frontend_action_factory.cpp",
|
||||
"header-abi-dumper/src/header_checker.cpp",
|
||||
"header-abi-dumper/src/workaround_fortify.cpp",
|
||||
"header-abi-dumper/src/workaround_openmp.cpp",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "abi_diff.h"
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include "header_abi_util.h"
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
@@ -140,14 +140,14 @@ bool HeaderAbiDiff::CollectUserDefinedTypes(
|
||||
auto old_enums_and_records_extracted = ExtractUserDefinedTypes(old_tu);
|
||||
auto new_enums_and_records_extracted = ExtractUserDefinedTypes(new_tu);
|
||||
|
||||
return CollectUserDefinedTypesInternal(
|
||||
return (CollectUserDefinedTypesInternal(
|
||||
old_enums_and_records_extracted.second,
|
||||
new_enums_and_records_extracted.second, old_types_map,
|
||||
new_types_map, ir_diff_dumper) &&
|
||||
CollectUserDefinedTypesInternal(old_enums_and_records_extracted.first,
|
||||
CollectUserDefinedTypesInternal(
|
||||
old_enums_and_records_extracted.first,
|
||||
new_enums_and_records_extracted.first,
|
||||
old_types_map, new_types_map,
|
||||
ir_diff_dumper);
|
||||
old_types_map, new_types_map, ir_diff_dumper));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -158,11 +158,11 @@ bool HeaderAbiDiff::CollectUserDefinedTypesInternal(
|
||||
const AbiElementMap<const abi_util::TypeIR *> &new_types_map,
|
||||
abi_util::IRDiffDumper *ir_diff_dumper) {
|
||||
|
||||
return Collect(old_ud_types_map, new_ud_types_map, nullptr, nullptr,
|
||||
return (Collect(old_ud_types_map, new_ud_types_map, nullptr, nullptr,
|
||||
ir_diff_dumper, old_types_map, new_types_map) &&
|
||||
PopulateCommonElements(old_ud_types_map, new_ud_types_map, old_types_map,
|
||||
new_types_map, ir_diff_dumper,
|
||||
abi_util::DiffMessageIR::Unreferenced);
|
||||
PopulateCommonElements(old_ud_types_map, new_ud_types_map,
|
||||
old_types_map, new_types_map, ir_diff_dumper,
|
||||
abi_util::DiffMessageIR::Unreferenced));
|
||||
}
|
||||
|
||||
template <typename T, typename ElfSymbolType>
|
||||
@@ -210,12 +210,12 @@ bool HeaderAbiDiff::CollectDynsymExportables(
|
||||
return true;
|
||||
}
|
||||
|
||||
// Collect added and removed Elements. The elf set is needed since some symbols
|
||||
// might not have meta-data about them collected through the AST. For eg: if a
|
||||
// function Foo is defined in an assembly file on target A, but in a c/c++ file
|
||||
// on target B, foo does not have meta-data surrounding it when building target
|
||||
// A, this does not mean it is not in the ABI + API of the library.
|
||||
|
||||
// Collect the added and removed elements. The ELF maps are needed because the
|
||||
// metadata for some symbols might be absent from AST. For example, if a
|
||||
// function Foo() is defined in an assembly file on target A, but in a C/C++
|
||||
// file on target B. Even though Foo() does not have metadata surrounding it
|
||||
// when building target A, it doesn't mean that Foo() is not a part of the ABI
|
||||
// of the library.
|
||||
template <typename T>
|
||||
bool HeaderAbiDiff::Collect(
|
||||
const AbiElementMap<const T*> &old_elements_map,
|
||||
@@ -228,10 +228,9 @@ bool HeaderAbiDiff::Collect(
|
||||
if (!PopulateRemovedElements(
|
||||
old_elements_map, new_elements_map, new_elf_map, ir_diff_dumper,
|
||||
abi_util::DiffMessageIR::Removed, old_types_map) ||
|
||||
!PopulateRemovedElements(new_elements_map, old_elements_map, old_elf_map,
|
||||
ir_diff_dumper,
|
||||
abi_util::IRDiffDumper::DiffKind::Added,
|
||||
new_types_map)) {
|
||||
!PopulateRemovedElements(
|
||||
new_elements_map, old_elements_map, old_elf_map, ir_diff_dumper,
|
||||
abi_util::IRDiffDumper::DiffKind::Added, new_types_map)) {
|
||||
llvm::errs() << "Populating functions in report failed\n";
|
||||
return false;
|
||||
}
|
||||
@@ -248,10 +247,10 @@ bool HeaderAbiDiff::CollectElfSymbols(
|
||||
std::vector<const abi_util::ElfSymbolIR *> added_elements =
|
||||
abi_util::FindRemovedElements(new_symbols, old_symbols);
|
||||
|
||||
return PopulateElfElements(removed_elements, ir_diff_dumper,
|
||||
return (PopulateElfElements(removed_elements, ir_diff_dumper,
|
||||
abi_util::IRDiffDumper::DiffKind::Removed) &&
|
||||
PopulateElfElements(added_elements, ir_diff_dumper,
|
||||
abi_util::IRDiffDumper::DiffKind::Added);
|
||||
abi_util::IRDiffDumper::DiffKind::Added));
|
||||
}
|
||||
|
||||
bool HeaderAbiDiff::PopulateElfElements(
|
||||
@@ -358,11 +357,10 @@ bool HeaderAbiDiff::DumpDiffElements(
|
||||
[](const T *e) {return e->GetLinkerSetKey();})) {
|
||||
continue;
|
||||
}
|
||||
abi_diff_wrappers::DiffWrapper<T> diff_wrapper(old_element, new_element,
|
||||
ir_diff_dumper, old_types,
|
||||
new_types,
|
||||
diff_policy_options_,
|
||||
&type_cache_);
|
||||
|
||||
abi_diff_wrappers::DiffWrapper<T> diff_wrapper(
|
||||
old_element, new_element, ir_diff_dumper, old_types, new_types,
|
||||
diff_policy_options_, &type_cache_);
|
||||
if (!diff_wrapper.DumpDiff(diff_kind)) {
|
||||
llvm::errs() << "Failed to diff elements\n";
|
||||
return false;
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "abi_diff_wrappers.h"
|
||||
#ifndef ABI_DIFF_H_
|
||||
#define ABI_DIFF_H_
|
||||
|
||||
#include <ir_representation.h>
|
||||
#include "abi_diff_wrappers.h"
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -38,7 +40,7 @@ class HeaderAbiDiff {
|
||||
diff_policy_options_(diff_policy_options),
|
||||
check_all_apis_(check_all_apis),
|
||||
text_format_old_(text_format_old), text_format_new_(text_format_new),
|
||||
text_format_diff_(text_format_diff) { }
|
||||
text_format_diff_(text_format_diff) {}
|
||||
|
||||
abi_util::CompatibilityStatusIR GenerateCompatibilityReport();
|
||||
|
||||
@@ -145,3 +147,5 @@ class HeaderAbiDiff {
|
||||
abi_util::TextFormatIR text_format_new_;
|
||||
abi_util::TextFormatIR text_format_diff_;
|
||||
};
|
||||
|
||||
#endif // ABI_DIFF_H_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "abi_diff_wrappers.h"
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include "header_abi_util.h"
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
@@ -85,13 +85,13 @@ bool DiffWrapper<abi_util::FunctionIR>::DumpDiff(
|
||||
abi_util::DiffMessageIR::DiffKind diff_kind) {
|
||||
std::deque<std::string> type_queue;
|
||||
type_queue.push_back(oldp_->GetName());
|
||||
DiffStatus param_diffs = CompareFunctionParameters(oldp_->GetParameters(),
|
||||
newp_->GetParameters(),
|
||||
&type_queue, diff_kind);
|
||||
DiffStatus return_type_diff =
|
||||
CompareAndDumpTypeDiff(oldp_->GetReturnType(),
|
||||
newp_->GetReturnType(),
|
||||
&type_queue, diff_kind);
|
||||
|
||||
DiffStatus param_diffs = CompareFunctionParameters(
|
||||
oldp_->GetParameters(), newp_->GetParameters(), &type_queue, diff_kind);
|
||||
|
||||
DiffStatus return_type_diff = CompareAndDumpTypeDiff(
|
||||
oldp_->GetReturnType(), newp_->GetReturnType(), &type_queue, diff_kind);
|
||||
|
||||
CompareTemplateInfo(oldp_->GetTemplateElements(),
|
||||
newp_->GetTemplateElements(),
|
||||
&type_queue, diff_kind);
|
||||
@@ -111,4 +111,4 @@ bool DiffWrapper<abi_util::FunctionIR>::DumpDiff(
|
||||
return true;
|
||||
}
|
||||
|
||||
} // abi_diff_wrappers
|
||||
} // namespace abi_diff_wrappers
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ABI_DIFF_WRAPPERS_H
|
||||
#define ABI_DIFF_WRAPPERS_H
|
||||
#ifndef ABI_DIFF_WRAPPERS_H_
|
||||
#define ABI_DIFF_WRAPPERS_H_
|
||||
|
||||
#include <abi_diff_helpers.h>
|
||||
#include <ir_representation.h>
|
||||
#include "abi_diff_helpers.h"
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <deque>
|
||||
|
||||
@@ -30,13 +30,11 @@ template <typename T, typename F>
|
||||
static bool IgnoreSymbol(const T *element,
|
||||
const std::set<std::string> &ignored_symbols,
|
||||
F func) {
|
||||
return ignored_symbols.find(func(element)) !=
|
||||
ignored_symbols.end();
|
||||
return ignored_symbols.find(func(element)) != ignored_symbols.end();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class DiffWrapper : public AbiDiffHelper {
|
||||
|
||||
public:
|
||||
DiffWrapper(const T *oldp, const T *newp,
|
||||
abi_util::IRDiffDumper *ir_diff_dumper,
|
||||
@@ -45,7 +43,8 @@ class DiffWrapper : public AbiDiffHelper {
|
||||
const abi_util::DiffPolicyOptions &diff_policy_options,
|
||||
std::set<std::string> *type_cache)
|
||||
: AbiDiffHelper(old_types, new_types, diff_policy_options, type_cache,
|
||||
ir_diff_dumper), oldp_(oldp), newp_(newp) { }
|
||||
ir_diff_dumper),
|
||||
oldp_(oldp), newp_(newp) {}
|
||||
|
||||
bool DumpDiff(abi_util::IRDiffDumper::DiffKind diff_kind);
|
||||
|
||||
@@ -54,6 +53,6 @@ class DiffWrapper : public AbiDiffHelper {
|
||||
const T *newp_;
|
||||
};
|
||||
|
||||
} // abi_diff_wrappers
|
||||
} // namespace abi_diff_wrappers
|
||||
|
||||
#endif // ABI_DIFF_WRAPPERS_H
|
||||
#endif // ABI_DIFF_WRAPPERS_H_
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
|
||||
#include "abi_diff.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <llvm/Support/CommandLine.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
static llvm::cl::OptionCategory header_checker_category(
|
||||
"header-abi-diff options");
|
||||
|
||||
@@ -132,13 +132,13 @@ static const char kWarn[] = "\033[36;1mwarning: \033[0m";
|
||||
static const char kError[] = "\033[31;1merror: \033[0m";
|
||||
|
||||
bool ShouldEmitWarningMessage(abi_util::CompatibilityStatusIR status) {
|
||||
return (!allow_extensions &&
|
||||
return ((!allow_extensions &&
|
||||
(status & abi_util::CompatibilityStatusIR::Extension)) ||
|
||||
(!allow_unreferenced_changes &&
|
||||
(status & abi_util::CompatibilityStatusIR::UnreferencedChanges)) ||
|
||||
(!allow_unreferenced_elf_symbol_changes &&
|
||||
(status & abi_util::CompatibilityStatusIR::ElfIncompatible)) ||
|
||||
(status & abi_util::CompatibilityStatusIR::Incompatible);
|
||||
(status & abi_util::CompatibilityStatusIR::Incompatible));
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
@@ -196,7 +196,7 @@ int main(int argc, const char **argv) {
|
||||
<< "'s ABI has "
|
||||
<< status_str
|
||||
<< unreferenced_change_str
|
||||
<< " Please check compatiblity report at : "
|
||||
<< " Please check compatiblity report at: "
|
||||
<< compatibility_report << "\n"
|
||||
<< "******************************************************\n";
|
||||
}
|
||||
|
||||
@@ -14,15 +14,17 @@
|
||||
|
||||
#include "abi_wrappers.h"
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include "header_abi_util.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <clang/AST/QualTypeNames.h>
|
||||
#include <clang/Index/CodegenNameGenerator.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace abi_wrapper;
|
||||
|
||||
ABIWrapper::ABIWrapper(
|
||||
@@ -35,7 +37,7 @@ ABIWrapper::ABIWrapper(
|
||||
mangle_contextp_(mangle_contextp),
|
||||
ast_contextp_(ast_contextp),
|
||||
ir_dumper_(ir_dumper),
|
||||
ast_caches_(ast_caches) { }
|
||||
ast_caches_(ast_caches) {}
|
||||
|
||||
std::string ABIWrapper::GetCachedDeclSourceFile(
|
||||
const clang::Decl *decl, const clang::CompilerInstance *cip) {
|
||||
@@ -67,7 +69,8 @@ static const clang::RecordDecl *GetAnonymousRecord(clang::QualType type) {
|
||||
const clang::RecordDecl *record_decl =
|
||||
llvm::dyn_cast<clang::RecordDecl>(tag_decl);
|
||||
|
||||
if (record_decl != nullptr && (!record_decl->hasNameForLinkage() ||
|
||||
if (record_decl != nullptr &&
|
||||
(!record_decl->hasNameForLinkage() ||
|
||||
record_decl->isAnonymousStructOrUnion())) {
|
||||
return record_decl;
|
||||
}
|
||||
@@ -95,8 +98,7 @@ static bool IsReferencingType(clang::QualType qual_type) {
|
||||
bool is_ptr = base_type->isPointerType();
|
||||
bool is_reference = base_type->isReferenceType();
|
||||
bool is_array = base_type->isArrayType();
|
||||
return is_array || is_ptr || is_reference ||
|
||||
qual_type.hasLocalQualifiers();
|
||||
return is_array || is_ptr || is_reference || qual_type.hasLocalQualifiers();
|
||||
}
|
||||
|
||||
static clang::QualType GetReferencedType(const clang::QualType qual_type);
|
||||
@@ -194,18 +196,17 @@ static clang::QualType GetReferencedType(const clang::QualType qual_type) {
|
||||
return qual_type.getNonReferenceType();
|
||||
}
|
||||
|
||||
bool ABIWrapper::CreateExtendedType(
|
||||
clang::QualType qual_type,
|
||||
bool ABIWrapper::CreateExtendedType(clang::QualType qual_type,
|
||||
abi_util::TypeIR *typep) {
|
||||
const clang::QualType canonical_type = qual_type.getCanonicalType();
|
||||
// The source file is going to be set later anyway.
|
||||
return CreateBasicNamedAndTypedDecl(canonical_type, typep, "");
|
||||
}
|
||||
|
||||
//This overload takes in a qualtype and adds its information to the abi-dump on
|
||||
//its own.
|
||||
bool ABIWrapper::CreateBasicNamedAndTypedDecl(
|
||||
clang::QualType qual_type, const std::string &source_file) {
|
||||
// This overload takes in a qualtype and adds its information to the abi-dump on
|
||||
// its own.
|
||||
bool ABIWrapper::CreateBasicNamedAndTypedDecl(clang::QualType qual_type,
|
||||
const std::string &source_file) {
|
||||
const std::string &type_key = GetKeyForTypeId(qual_type);
|
||||
const clang::QualType canonical_type = qual_type.getCanonicalType();
|
||||
const clang::Type *base_type = canonical_type.getTypePtr();
|
||||
@@ -228,9 +229,12 @@ bool ABIWrapper::CreateBasicNamedAndTypedDecl(
|
||||
llvm::errs() << "nullptr with valid type while creating basic type\n";
|
||||
return false;
|
||||
}
|
||||
return type_and_status.should_create_type_ ?
|
||||
CreateBasicNamedAndTypedDecl(canonical_type, typep.get(), source_file) &&
|
||||
ir_dumper_->AddLinkableMessageIR(typep.get()) : true;
|
||||
if (!type_and_status.should_create_type_) {
|
||||
return true;
|
||||
}
|
||||
return (CreateBasicNamedAndTypedDecl(
|
||||
canonical_type, typep.get(), source_file) &&
|
||||
ir_dumper_->AddLinkableMessageIR(typep.get()));
|
||||
}
|
||||
|
||||
std::string RecordDeclWrapper::GetMangledRTTI(
|
||||
@@ -258,19 +262,18 @@ std::string ABIWrapper::GetTypeUniqueId(const clang::TagDecl *tag_decl) {
|
||||
return QualTypeToString(qual_type);
|
||||
}
|
||||
|
||||
// CreateBasicNamedAndTypedDecl creates a BasicNamedAndTypedDecl : that'll
|
||||
// include all the generic information a basic type will have:
|
||||
// abi_dump::BasicNamedAndTypedDecl. Other methods fill in more specific
|
||||
// information, eg: RecordDecl, EnumDecl.
|
||||
// CreateBasicNamedAndTypedDecl creates a BasicNamedAndTypedDecl which will
|
||||
// include all the generic information of a basic type. Other methods will
|
||||
// create more specific information, e.g. RecordDecl, EnumDecl.
|
||||
bool ABIWrapper::CreateBasicNamedAndTypedDecl(
|
||||
clang::QualType canonical_type,
|
||||
abi_util::TypeIR *typep, const std::string &source_file) {
|
||||
clang::QualType canonical_type, abi_util::TypeIR *typep,
|
||||
const std::string &source_file) {
|
||||
// Cannot determine the size and alignment for template parameter dependent
|
||||
// types as well as incomplete types.
|
||||
const clang::Type *base_type = canonical_type.getTypePtr();
|
||||
assert(base_type != nullptr);
|
||||
clang::Type::TypeClass type_class = base_type->getTypeClass();
|
||||
// Temporary Hack for auto type sizes. Not determinable.
|
||||
// Temporary hack for auto type sizes. Not determinable.
|
||||
if ((type_class != clang::Type::Auto) && !base_type->isIncompleteType() &&
|
||||
!(base_type->isDependentType())) {
|
||||
std::pair<clang::CharUnits, clang::CharUnits> size_and_alignment =
|
||||
@@ -284,8 +287,8 @@ bool ABIWrapper::CreateBasicNamedAndTypedDecl(
|
||||
TypeNameWithFinalDestination(canonical_type);
|
||||
typep->SetName(type_name_with_destination);
|
||||
typep->SetLinkerSetKey(type_name_with_destination);
|
||||
// default values are false, we don't set them since explicitly doing that
|
||||
// makes the abi dumps more verbose.
|
||||
// Default values are false, we don't set them since explicitly doing that
|
||||
// makes the ABI dumps more verbose.
|
||||
// This type has a reference type if its a pointer / reference OR it has CVR
|
||||
// qualifiers.
|
||||
clang::QualType referenced_type = GetReferencedType(canonical_type);
|
||||
@@ -382,22 +385,20 @@ std::string ABIWrapper::GetMangledNameDecl(
|
||||
return mangled_name;
|
||||
}
|
||||
|
||||
std::string ABIWrapper::GetTagDeclQualifiedName(
|
||||
const clang::TagDecl *decl) {
|
||||
std::string ABIWrapper::GetTagDeclQualifiedName(const clang::TagDecl *decl) {
|
||||
if (decl->getTypedefNameForAnonDecl()) {
|
||||
return decl->getTypedefNameForAnonDecl()->getQualifiedNameAsString();
|
||||
}
|
||||
return decl->getQualifiedNameAsString();
|
||||
}
|
||||
|
||||
bool ABIWrapper::SetupTemplateArguments(
|
||||
const clang::TemplateArgumentList *tl,
|
||||
bool ABIWrapper::SetupTemplateArguments(const clang::TemplateArgumentList *tl,
|
||||
abi_util::TemplatedArtifactIR *ta,
|
||||
const std::string &source_file) {
|
||||
abi_util::TemplateInfoIR template_info;
|
||||
for (int i = 0; i < tl->size(); i++) {
|
||||
const clang::TemplateArgument &arg = (*tl)[i];
|
||||
//TODO: More comprehensive checking needed.
|
||||
// TODO: More comprehensive checking needed.
|
||||
if (arg.getKind() != clang::TemplateArgument::Type) {
|
||||
continue;
|
||||
}
|
||||
@@ -414,8 +415,7 @@ bool ABIWrapper::SetupTemplateArguments(
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ABIWrapper::QualTypeToString(
|
||||
const clang::QualType &sweet_qt) {
|
||||
std::string ABIWrapper::QualTypeToString(const clang::QualType &sweet_qt) {
|
||||
const clang::QualType salty_qt = sweet_qt.getCanonicalType();
|
||||
// clang::TypeName::getFullyQualifiedName removes the part of the type related
|
||||
// to it being a template parameter. Don't use it for dependent types.
|
||||
@@ -432,8 +432,9 @@ FunctionTypeWrapper::FunctionTypeWrapper(
|
||||
const clang::FunctionType *function_type, abi_util::IRDumper *ir_dumper,
|
||||
ast_util::ASTCaches *ast_caches, const std::string &source_file)
|
||||
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
|
||||
ast_caches), function_type_(function_type),
|
||||
source_file_(source_file) { }
|
||||
ast_caches),
|
||||
function_type_(function_type),
|
||||
source_file_(source_file) {}
|
||||
|
||||
bool FunctionTypeWrapper::SetupFunctionType(
|
||||
abi_util::FunctionTypeIR *function_type_ir) {
|
||||
@@ -476,7 +477,7 @@ FunctionDeclWrapper::FunctionDeclWrapper(
|
||||
ast_util::ASTCaches *ast_caches)
|
||||
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
|
||||
ast_caches),
|
||||
function_decl_(decl) { }
|
||||
function_decl_(decl) {}
|
||||
|
||||
bool FunctionDeclWrapper::SetupThisParameter(abi_util::FunctionIR *functionp,
|
||||
const std::string &source_file) {
|
||||
@@ -544,8 +545,7 @@ bool FunctionDeclWrapper::SetupFunction(abi_util::FunctionIR *functionp,
|
||||
SetupTemplateInfo(functionp, source_file);
|
||||
}
|
||||
|
||||
bool FunctionDeclWrapper::SetupTemplateInfo(
|
||||
abi_util::FunctionIR *functionp,
|
||||
bool FunctionDeclWrapper::SetupTemplateInfo(abi_util::FunctionIR *functionp,
|
||||
const std::string &source_file) {
|
||||
switch (function_decl_->getTemplatedKind()) {
|
||||
case clang::FunctionDecl::TK_FunctionTemplateSpecialization: {
|
||||
@@ -581,7 +581,7 @@ RecordDeclWrapper::RecordDeclWrapper(
|
||||
ast_util::ASTCaches *ast_caches)
|
||||
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
|
||||
ast_caches),
|
||||
record_decl_(decl) { }
|
||||
record_decl_(decl) {}
|
||||
|
||||
bool RecordDeclWrapper::SetupRecordFields(abi_util::RecordTypeIR *recordp,
|
||||
const std::string &source_file) {
|
||||
@@ -613,8 +613,7 @@ bool RecordDeclWrapper::SetupRecordFields(abi_util::RecordTypeIR *recordp,
|
||||
}
|
||||
|
||||
bool RecordDeclWrapper::SetupCXXBases(
|
||||
abi_util::RecordTypeIR *cxxp,
|
||||
const clang::CXXRecordDecl *cxx_record_decl) {
|
||||
abi_util::RecordTypeIR *cxxp, const clang::CXXRecordDecl *cxx_record_decl) {
|
||||
if (!cxx_record_decl || !cxxp) {
|
||||
return false;
|
||||
}
|
||||
@@ -823,8 +822,8 @@ bool RecordDeclWrapper::SetupRecordInfo(abi_util::RecordTypeIR *record_declp,
|
||||
SetupCXXRecordInfo(record_declp, source_file);
|
||||
}
|
||||
|
||||
bool RecordDeclWrapper::SetupCXXRecordInfo(
|
||||
abi_util::RecordTypeIR *record_declp, const std::string &source_file) {
|
||||
bool RecordDeclWrapper::SetupCXXRecordInfo(abi_util::RecordTypeIR *record_declp,
|
||||
const std::string &source_file) {
|
||||
const clang::CXXRecordDecl *cxx_record_decl =
|
||||
clang::dyn_cast<clang::CXXRecordDecl>(record_decl_);
|
||||
if (!cxx_record_decl) {
|
||||
@@ -835,7 +834,7 @@ bool RecordDeclWrapper::SetupCXXRecordInfo(
|
||||
SetupRecordVTable(record_declp, cxx_record_decl);
|
||||
}
|
||||
|
||||
// TODO: Can we use clang's ODR hash to do faster ODR checking ?
|
||||
// TODO: Can we use clang's ODR hash to do faster ODR checking?
|
||||
bool RecordDeclWrapper::GetRecordDecl() {
|
||||
auto abi_decl = std::make_unique<abi_util::RecordTypeIR>();
|
||||
std::string source_file = GetCachedDeclSourceFile(record_decl_, cip_);
|
||||
@@ -860,7 +859,7 @@ EnumDeclWrapper::EnumDeclWrapper(
|
||||
ast_util::ASTCaches *ast_caches)
|
||||
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
|
||||
ast_caches),
|
||||
enum_decl_(decl) { }
|
||||
enum_decl_(decl) {}
|
||||
|
||||
bool EnumDeclWrapper::SetupEnumFields(abi_util::EnumTypeIR *enump) {
|
||||
if (!enump) {
|
||||
@@ -912,12 +911,11 @@ GlobalVarDeclWrapper::GlobalVarDeclWrapper(
|
||||
ast_util::ASTCaches *ast_caches)
|
||||
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
|
||||
ast_caches),
|
||||
global_var_decl_(decl) { }
|
||||
global_var_decl_(decl) {}
|
||||
|
||||
bool GlobalVarDeclWrapper::SetupGlobalVar(
|
||||
abi_util::GlobalVarIR *global_varp,
|
||||
bool GlobalVarDeclWrapper::SetupGlobalVar(abi_util::GlobalVarIR *global_varp,
|
||||
const std::string &source_file) {
|
||||
// Temporary fix : clang segfaults on trying to mangle global variable which
|
||||
// Temporary fix: clang segfaults on trying to mangle global variable which
|
||||
// is a dependent sized array type.
|
||||
std::string mangled_name =
|
||||
GetMangledNameDecl(global_var_decl_, mangle_contextp_);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#define ABI_WRAPPERS_H_
|
||||
|
||||
#include "ast_util.h"
|
||||
#include <ir_representation.h>
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <clang/AST/AST.h>
|
||||
#include <clang/AST/ASTConsumer.h>
|
||||
@@ -31,7 +31,7 @@ struct TypeAndCreationStatus {
|
||||
bool should_create_type_; // Whether the type is to be created.
|
||||
TypeAndCreationStatus(std::unique_ptr<abi_util::TypeIR> &&typep,
|
||||
bool should_create_type = true)
|
||||
: typep_(std::move(typep)), should_create_type_(should_create_type) { }
|
||||
: typep_(std::move(typep)), should_create_type_(should_create_type) {}
|
||||
};
|
||||
|
||||
class ABIWrapper {
|
||||
@@ -162,7 +162,6 @@ class FunctionDeclWrapper : public ABIWrapper {
|
||||
|
||||
bool SetupThisParameter(abi_util::FunctionIR *functionp,
|
||||
const std::string &source_file);
|
||||
|
||||
};
|
||||
|
||||
class FunctionTypeWrapper : public ABIWrapper {
|
||||
@@ -215,11 +214,12 @@ class GlobalVarDeclWrapper : public ABIWrapper {
|
||||
|
||||
private:
|
||||
const clang::VarDecl *global_var_decl_;
|
||||
|
||||
private:
|
||||
bool SetupGlobalVar(abi_util::GlobalVarIR *global_varp,
|
||||
const std::string &source_file);
|
||||
};
|
||||
|
||||
} //end namespace abi_wrapper
|
||||
} // namespace abi_wrapper
|
||||
|
||||
#endif // ABI_WRAPPERS_H_
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "ast_processing.h"
|
||||
|
||||
#include "abi_wrappers.h"
|
||||
|
||||
#include <clang/Lex/Token.h>
|
||||
@@ -43,7 +44,7 @@ HeaderASTVisitor::HeaderASTVisitor(
|
||||
exported_headers_(exported_headers),
|
||||
tu_decl_(tu_decl),
|
||||
ir_dumper_(ir_dumper),
|
||||
ast_caches_(ast_caches) { }
|
||||
ast_caches_(ast_caches) {}
|
||||
|
||||
bool HeaderASTVisitor::VisitRecordDecl(const clang::RecordDecl *decl) {
|
||||
// Skip forward declarations, dependent records. Also skip anonymous records
|
||||
@@ -69,7 +70,7 @@ bool HeaderASTVisitor::VisitEnumDecl(const clang::EnumDecl *decl) {
|
||||
EnumDeclWrapper enum_decl_wrapper(
|
||||
mangle_contextp_, ast_contextp_, cip_, decl, ir_dumper_, ast_caches_);
|
||||
return enum_decl_wrapper.GetEnumDecl();
|
||||
}
|
||||
}
|
||||
|
||||
static bool MutateFunctionWithLinkageName(const abi_util::FunctionIR *function,
|
||||
abi_util::IRDumper *ir_dumper,
|
||||
@@ -120,9 +121,8 @@ bool HeaderASTVisitor::VisitFunctionDecl(const clang::FunctionDecl *decl) {
|
||||
if (ShouldSkipFunctionDecl(decl)) {
|
||||
return true;
|
||||
}
|
||||
FunctionDeclWrapper function_decl_wrapper(mangle_contextp_, ast_contextp_,
|
||||
cip_, decl, ir_dumper_,
|
||||
ast_caches_);
|
||||
FunctionDeclWrapper function_decl_wrapper(
|
||||
mangle_contextp_, ast_contextp_, cip_, decl, ir_dumper_, ast_caches_);
|
||||
auto function_wrapper = function_decl_wrapper.GetFunctionDecl();
|
||||
// Destructors and Constructors can have more than 1 symbol generated from the
|
||||
// same Decl.
|
||||
@@ -138,14 +138,13 @@ bool HeaderASTVisitor::VisitFunctionDecl(const clang::FunctionDecl *decl) {
|
||||
}
|
||||
|
||||
bool HeaderASTVisitor::VisitVarDecl(const clang::VarDecl *decl) {
|
||||
if(!decl->hasGlobalStorage()||
|
||||
if (!decl->hasGlobalStorage() ||
|
||||
decl->getType().getTypePtr()->isDependentType()) {
|
||||
// Non global / static variable declarations don't need to be dumped.
|
||||
return true;
|
||||
}
|
||||
GlobalVarDeclWrapper global_var_decl_wrapper(mangle_contextp_, ast_contextp_,
|
||||
cip_, decl, ir_dumper_,
|
||||
ast_caches_);
|
||||
GlobalVarDeclWrapper global_var_decl_wrapper(
|
||||
mangle_contextp_, ast_contextp_, cip_, decl, ir_dumper_, ast_caches_);
|
||||
return global_var_decl_wrapper.GetGlobalVarDecl();
|
||||
}
|
||||
|
||||
@@ -184,7 +183,7 @@ HeaderASTConsumer::HeaderASTConsumer(
|
||||
: cip_(compiler_instancep),
|
||||
out_dump_name_(out_dump_name),
|
||||
exported_headers_(exported_headers),
|
||||
text_format_(text_format){ }
|
||||
text_format_(text_format) {}
|
||||
|
||||
void HeaderASTConsumer::HandleTranslationUnit(clang::ASTContext &ctx) {
|
||||
clang::PrintingPolicy policy(ctx.getPrintingPolicy());
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#define AST_PROCESSING_H_
|
||||
|
||||
#include "ast_util.h"
|
||||
#include <ir_representation.h>
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <clang/AST/AST.h>
|
||||
#include <clang/AST/ASTConsumer.h>
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef AST_UTIL
|
||||
#define AST_UTIL
|
||||
|
||||
#ifndef AST_UTIL_H_
|
||||
#define AST_UTIL_H_
|
||||
|
||||
#include <clang/AST/AST.h>
|
||||
|
||||
@@ -24,9 +25,8 @@ namespace ast_util {
|
||||
constexpr static char type_id_prefix[] = "type-";
|
||||
|
||||
struct ASTCaches {
|
||||
|
||||
ASTCaches(const std::string &translation_unit_source)
|
||||
: translation_unit_source_(translation_unit_source) { };
|
||||
: translation_unit_source_(translation_unit_source) {}
|
||||
|
||||
std::string GetTypeId(const std::string &qual_type) {
|
||||
auto type_id_it = qual_type_to_type_id_cache_.find(qual_type);
|
||||
@@ -45,5 +45,6 @@ struct ASTCaches {
|
||||
uint64_t max_type_id_ = 0;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
} // namespace ast_util
|
||||
|
||||
#endif // AST_UTIL_H_
|
||||
|
||||
@@ -12,24 +12,23 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "frontend_action.h"
|
||||
|
||||
#include "ast_processing.h"
|
||||
#include "frontend_action.h"
|
||||
#include <header_abi_util.h>
|
||||
#include <ir_representation.h>
|
||||
#include "header_abi_util.h"
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <clang/AST/ASTConsumer.h>
|
||||
#include <clang/Frontend/CompilerInstance.h>
|
||||
#include <clang/Lex/Preprocessor.h>
|
||||
|
||||
#include <llvm/ADT/STLExtras.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
#include <llvm/Support/Path.h>
|
||||
|
||||
HeaderCheckerFrontendAction::HeaderCheckerFrontendAction(
|
||||
const std::string &dump_name, std::set<std::string> &exported_headers,
|
||||
abi_util::TextFormatIR text_format)
|
||||
: dump_name_(dump_name), exported_headers_(exported_headers),
|
||||
text_format_(text_format) { }
|
||||
text_format_(text_format) {}
|
||||
|
||||
std::unique_ptr<clang::ASTConsumer>
|
||||
HeaderCheckerFrontendAction::CreateASTConsumer(clang::CompilerInstance &ci,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef FRONTEND_ACTION_H_
|
||||
#define FRONTEND_ACTION_H_
|
||||
|
||||
#include <ir_representation.h>
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <clang/Frontend/FrontendAction.h>
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
|
||||
@@ -23,7 +23,7 @@ HeaderCheckerFrontendActionFactory::HeaderCheckerFrontendActionFactory(
|
||||
std::set<std::string> &exported_headers,
|
||||
abi_util::TextFormatIR text_format)
|
||||
: dump_name_(dump_name), exported_headers_(exported_headers),
|
||||
text_format_(text_format) { }
|
||||
text_format_(text_format) {}
|
||||
|
||||
clang::FrontendAction *HeaderCheckerFrontendActionFactory::create() {
|
||||
return new HeaderCheckerFrontendAction(dump_name_, exported_headers_,
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
#ifndef FRONTEND_ACTION_FACTORY_H_
|
||||
#define FRONTEND_ACTION_FACTORY_H_
|
||||
|
||||
#include <ir_representation.h>
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <clang/Tooling/Tooling.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
|
||||
#include "fixed_argv.h"
|
||||
#include "frontend_action_factory.h"
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include "header_abi_util.h"
|
||||
|
||||
#include <clang/Frontend/FrontendActions.h>
|
||||
#include <clang/Tooling/CommonOptionsParser.h>
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
#ifndef OMP_HEADER_DATA_H_
|
||||
#define OMP_HEADER_DATA_H_
|
||||
|
||||
const char OMP_HEADER_DATA[] = R"__SOURCE__(
|
||||
/*
|
||||
* include/50/omp.h.var
|
||||
*/
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.txt for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef __OMP_H
|
||||
# define __OMP_H
|
||||
|
||||
# define KMP_VERSION_MAJOR 5
|
||||
# define KMP_VERSION_MINOR 0
|
||||
# define KMP_VERSION_BUILD 20140926
|
||||
# define KMP_BUILD_DATE "No_Timestamp"
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# if defined(_WIN32)
|
||||
# define __KAI_KMPC_CONVENTION __cdecl
|
||||
# else
|
||||
# define __KAI_KMPC_CONVENTION
|
||||
# endif
|
||||
|
||||
/* schedule kind constants */
|
||||
typedef enum omp_sched_t {
|
||||
omp_sched_static = 1,
|
||||
omp_sched_dynamic = 2,
|
||||
omp_sched_guided = 3,
|
||||
omp_sched_auto = 4
|
||||
} omp_sched_t;
|
||||
|
||||
/* set API functions */
|
||||
extern void __KAI_KMPC_CONVENTION omp_set_num_threads (int);
|
||||
extern void __KAI_KMPC_CONVENTION omp_set_dynamic (int);
|
||||
extern void __KAI_KMPC_CONVENTION omp_set_nested (int);
|
||||
extern void __KAI_KMPC_CONVENTION omp_set_max_active_levels (int);
|
||||
extern void __KAI_KMPC_CONVENTION omp_set_schedule (omp_sched_t, int);
|
||||
|
||||
/* query API functions */
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_num_threads (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_dynamic (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_nested (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_max_threads (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_thread_num (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_num_procs (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_in_parallel (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_in_final (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_active_level (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_level (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_ancestor_thread_num (int);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_team_size (int);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_thread_limit (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_max_active_levels (void);
|
||||
extern void __KAI_KMPC_CONVENTION omp_get_schedule (omp_sched_t *, int *);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_max_task_priority (void);
|
||||
|
||||
/* lock API functions */
|
||||
typedef struct omp_lock_t {
|
||||
void * _lk;
|
||||
} omp_lock_t;
|
||||
|
||||
extern void __KAI_KMPC_CONVENTION omp_init_lock (omp_lock_t *);
|
||||
extern void __KAI_KMPC_CONVENTION omp_set_lock (omp_lock_t *);
|
||||
extern void __KAI_KMPC_CONVENTION omp_unset_lock (omp_lock_t *);
|
||||
extern void __KAI_KMPC_CONVENTION omp_destroy_lock (omp_lock_t *);
|
||||
extern int __KAI_KMPC_CONVENTION omp_test_lock (omp_lock_t *);
|
||||
|
||||
/* nested lock API functions */
|
||||
typedef struct omp_nest_lock_t {
|
||||
void * _lk;
|
||||
} omp_nest_lock_t;
|
||||
|
||||
extern void __KAI_KMPC_CONVENTION omp_init_nest_lock (omp_nest_lock_t *);
|
||||
extern void __KAI_KMPC_CONVENTION omp_set_nest_lock (omp_nest_lock_t *);
|
||||
extern void __KAI_KMPC_CONVENTION omp_unset_nest_lock (omp_nest_lock_t *);
|
||||
extern void __KAI_KMPC_CONVENTION omp_destroy_nest_lock (omp_nest_lock_t *);
|
||||
extern int __KAI_KMPC_CONVENTION omp_test_nest_lock (omp_nest_lock_t *);
|
||||
|
||||
/* lock hint type for dynamic user lock */
|
||||
typedef enum omp_lock_hint_t {
|
||||
omp_lock_hint_none = 0,
|
||||
omp_lock_hint_uncontended = 1,
|
||||
omp_lock_hint_contended = (1<<1 ),
|
||||
omp_lock_hint_nonspeculative = (1<<2 ),
|
||||
omp_lock_hint_speculative = (1<<3 ),
|
||||
kmp_lock_hint_hle = (1<<16),
|
||||
kmp_lock_hint_rtm = (1<<17),
|
||||
kmp_lock_hint_adaptive = (1<<18)
|
||||
} omp_lock_hint_t;
|
||||
|
||||
/* hinted lock initializers */
|
||||
extern void __KAI_KMPC_CONVENTION omp_init_lock_with_hint(omp_lock_t *, omp_lock_hint_t);
|
||||
extern void __KAI_KMPC_CONVENTION omp_init_nest_lock_with_hint(omp_nest_lock_t *, omp_lock_hint_t);
|
||||
|
||||
/* time API functions */
|
||||
extern double __KAI_KMPC_CONVENTION omp_get_wtime (void);
|
||||
extern double __KAI_KMPC_CONVENTION omp_get_wtick (void);
|
||||
|
||||
/* OpenMP 4.0 */
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_default_device (void);
|
||||
extern void __KAI_KMPC_CONVENTION omp_set_default_device (int);
|
||||
extern int __KAI_KMPC_CONVENTION omp_is_initial_device (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_num_devices (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_num_teams (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_team_num (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_cancellation (void);
|
||||
|
||||
# include <stdlib.h>
|
||||
/* OpenMP 4.5 */
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_initial_device (void);
|
||||
extern void* __KAI_KMPC_CONVENTION omp_target_alloc(size_t, int);
|
||||
extern void __KAI_KMPC_CONVENTION omp_target_free(void *, int);
|
||||
extern int __KAI_KMPC_CONVENTION omp_target_is_present(void *, int);
|
||||
extern int __KAI_KMPC_CONVENTION omp_target_memcpy(void *, void *, size_t, size_t, size_t, int, int);
|
||||
extern int __KAI_KMPC_CONVENTION omp_target_memcpy_rect(void *, void *, size_t, int, const size_t *,
|
||||
const size_t *, const size_t *, const size_t *, const size_t *, int, int);
|
||||
extern int __KAI_KMPC_CONVENTION omp_target_associate_ptr(void *, void *, size_t, size_t, int);
|
||||
extern int __KAI_KMPC_CONVENTION omp_target_disassociate_ptr(void *, int);
|
||||
|
||||
/* kmp API functions */
|
||||
extern int __KAI_KMPC_CONVENTION kmp_get_stacksize (void);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_stacksize (int);
|
||||
extern size_t __KAI_KMPC_CONVENTION kmp_get_stacksize_s (void);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_stacksize_s (size_t);
|
||||
extern int __KAI_KMPC_CONVENTION kmp_get_blocktime (void);
|
||||
extern int __KAI_KMPC_CONVENTION kmp_get_library (void);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_blocktime (int);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_library (int);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_library_serial (void);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_library_turnaround (void);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_library_throughput (void);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_defaults (char const *);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_disp_num_buffers (int);
|
||||
|
||||
/* Intel affinity API */
|
||||
typedef void * kmp_affinity_mask_t;
|
||||
|
||||
extern int __KAI_KMPC_CONVENTION kmp_set_affinity (kmp_affinity_mask_t *);
|
||||
extern int __KAI_KMPC_CONVENTION kmp_get_affinity (kmp_affinity_mask_t *);
|
||||
extern int __KAI_KMPC_CONVENTION kmp_get_affinity_max_proc (void);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_create_affinity_mask (kmp_affinity_mask_t *);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_destroy_affinity_mask (kmp_affinity_mask_t *);
|
||||
extern int __KAI_KMPC_CONVENTION kmp_set_affinity_mask_proc (int, kmp_affinity_mask_t *);
|
||||
extern int __KAI_KMPC_CONVENTION kmp_unset_affinity_mask_proc (int, kmp_affinity_mask_t *);
|
||||
extern int __KAI_KMPC_CONVENTION kmp_get_affinity_mask_proc (int, kmp_affinity_mask_t *);
|
||||
|
||||
/* OpenMP 4.0 affinity API */
|
||||
typedef enum omp_proc_bind_t {
|
||||
omp_proc_bind_false = 0,
|
||||
omp_proc_bind_true = 1,
|
||||
omp_proc_bind_master = 2,
|
||||
omp_proc_bind_close = 3,
|
||||
omp_proc_bind_spread = 4
|
||||
} omp_proc_bind_t;
|
||||
|
||||
extern omp_proc_bind_t __KAI_KMPC_CONVENTION omp_get_proc_bind (void);
|
||||
|
||||
/* OpenMP 4.5 affinity API */
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_num_places (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_place_num_procs (int);
|
||||
extern void __KAI_KMPC_CONVENTION omp_get_place_proc_ids (int, int *);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_place_num (void);
|
||||
extern int __KAI_KMPC_CONVENTION omp_get_partition_num_places (void);
|
||||
extern void __KAI_KMPC_CONVENTION omp_get_partition_place_nums (int *);
|
||||
|
||||
extern void * __KAI_KMPC_CONVENTION kmp_malloc (size_t);
|
||||
extern void * __KAI_KMPC_CONVENTION kmp_aligned_malloc (size_t, size_t);
|
||||
extern void * __KAI_KMPC_CONVENTION kmp_calloc (size_t, size_t);
|
||||
extern void * __KAI_KMPC_CONVENTION kmp_realloc (void *, size_t);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_free (void *);
|
||||
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_warnings_on(void);
|
||||
extern void __KAI_KMPC_CONVENTION kmp_set_warnings_off(void);
|
||||
|
||||
/* OpenMP 5.0 Tool Control */
|
||||
typedef enum omp_control_tool_result_t {
|
||||
omp_control_tool_notool = -2,
|
||||
omp_control_tool_nocallback = -1,
|
||||
omp_control_tool_success = 0,
|
||||
omp_control_tool_ignored = 1
|
||||
} omp_control_tool_result_t;
|
||||
|
||||
typedef enum omp_control_tool_t {
|
||||
omp_control_tool_start = 1,
|
||||
omp_control_tool_pause = 2,
|
||||
omp_control_tool_flush = 3,
|
||||
omp_control_tool_end = 4
|
||||
} omp_control_tool_t;
|
||||
|
||||
extern int __KAI_KMPC_CONVENTION omp_control_tool(int, int, void*);
|
||||
|
||||
# undef __KAI_KMPC_CONVENTION
|
||||
|
||||
/* Warning:
|
||||
The following typedefs are not standard, deprecated and will be removed in a future release.
|
||||
*/
|
||||
typedef int omp_int_t;
|
||||
typedef double omp_wtime_t;
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* __OMP_H */
|
||||
)__SOURCE__";
|
||||
|
||||
#endif // OMP_HEADER_DATA_H_
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "fixed_argv.h"
|
||||
|
||||
static void DisableFortifySource(FixedArgv &fixed_argv) {
|
||||
// FIXME: Clang FORTIFY requires a version of clang at least as new as
|
||||
// clang-3688880 (r285906). Since external/clang is currently r275480, we need
|
||||
// to disable FORTIFY for this tool to function correctly.
|
||||
fixed_argv.PushForwardArgs("-U_FORTIFY_SOURCE");
|
||||
}
|
||||
|
||||
static FixedArgvRegistry X(DisableFortifySource);
|
||||
@@ -1,90 +0,0 @@
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "fixed_argv.h"
|
||||
#include "omp_header_data.h"
|
||||
|
||||
#include <llvm/ADT/SmallString.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
#include <llvm/Support/Path.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static std::string openmp_include_dir;
|
||||
|
||||
static void RemoveOpenMPIncludeDir() {
|
||||
if (openmp_include_dir.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the <omp.h> header file.
|
||||
llvm::SmallString<64> path;
|
||||
llvm::sys::path::append(path, openmp_include_dir, "omp.h");
|
||||
llvm::sys::fs::remove(llvm::Twine(path));
|
||||
|
||||
// Remove the directory.
|
||||
llvm::sys::fs::remove(llvm::Twine(openmp_include_dir));
|
||||
}
|
||||
|
||||
static std::error_code WriteFile(const char *path, const char *data,
|
||||
size_t size) {
|
||||
std::fstream output(path, std::ios_base::out | std::ios_base::trunc);
|
||||
if (!output) {
|
||||
return std::make_error_code(std::io_errc::stream);
|
||||
}
|
||||
|
||||
output.write(data, size);
|
||||
if (!output) {
|
||||
return std::make_error_code(std::io_errc::stream);
|
||||
}
|
||||
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
static std::error_code CreateOpenMPIncludeDir() {
|
||||
llvm::SmallString<64> path;
|
||||
|
||||
// Create a temporary directory for include fixes.
|
||||
std::error_code error_code =
|
||||
llvm::sys::fs::createUniqueDirectory("header-abi-dump-include", path);
|
||||
if (error_code) {
|
||||
return error_code;
|
||||
}
|
||||
|
||||
openmp_include_dir = path.str();
|
||||
|
||||
// Register a directory cleanup callback.
|
||||
::atexit(RemoveOpenMPIncludeDir);
|
||||
|
||||
// Create <omp.h> and write the content.
|
||||
llvm::sys::path::append(path, "omp.h");
|
||||
return WriteFile(path.c_str(), OMP_HEADER_DATA, sizeof(OMP_HEADER_DATA) - 1);
|
||||
}
|
||||
|
||||
static void SetupOpenMPIncludeDir(FixedArgv &fixed_argv) {
|
||||
// FIXME: clang-3289846 does not have <omp.h>. This workaround copies omp.h
|
||||
// from LLVM 5.0+ and adds `-isystem` to header search paths.
|
||||
if (fixed_argv.IsLastArgEqualFirstOption("-fopenmp", "-fno-openmp")) {
|
||||
std::error_code ec = CreateOpenMPIncludeDir();
|
||||
if (!ec) {
|
||||
fixed_argv.PushForwardArgs("-isystem", openmp_include_dir.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static FixedArgvRegistry X(SetupOpenMPIncludeDir);
|
||||
@@ -12,17 +12,19 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include <ir_representation.h>
|
||||
#include "header_abi_util.h"
|
||||
#include "ir_representation.h"
|
||||
#include "so_file_parser.h"
|
||||
#include "version_script_parser.h"
|
||||
|
||||
#include <llvm/Support/CommandLine.h>
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
@@ -94,7 +96,7 @@ class HeaderAbiLinker {
|
||||
const std::string &api)
|
||||
: dump_files_(dump_files), exported_header_dirs_(exported_header_dirs),
|
||||
version_script_(version_script), so_file_(so_file),
|
||||
out_dump_name_(linked_dump), arch_(arch), api_(api) {};
|
||||
out_dump_name_(linked_dump), arch_(arch), api_(api) {}
|
||||
|
||||
bool LinkAndDump();
|
||||
|
||||
@@ -278,8 +280,7 @@ static std::regex CreateRegexMatchExprFromSet(
|
||||
|
||||
template <typename T>
|
||||
bool HeaderAbiLinker::LinkDecl(
|
||||
abi_util::IRDumper *dst,
|
||||
const abi_util::AbiElementMap<T> &src,
|
||||
abi_util::IRDumper *dst, const abi_util::AbiElementMap<T> &src,
|
||||
const std::function<bool(const std::string &)> &symbol_filter) {
|
||||
assert(dst != nullptr);
|
||||
for (auto &&element : src) {
|
||||
@@ -345,8 +346,8 @@ bool HeaderAbiLinker::LinkGlobalVars(
|
||||
}
|
||||
|
||||
bool HeaderAbiLinker::ParseVersionScriptFiles() {
|
||||
abi_util::VersionScriptParser version_script_parser(version_script_, arch_,
|
||||
api_);
|
||||
abi_util::VersionScriptParser version_script_parser(
|
||||
version_script_, arch_, api_);
|
||||
if (!version_script_parser.Parse()) {
|
||||
llvm::errs() << "Failed to parse version script\n";
|
||||
return false;
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
#ifndef ABI_DIFF_HELPERS
|
||||
#define ABI_DIFF_HELPERS
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <ir_representation.h>
|
||||
#ifndef ABI_DIFF_HELPERS_H_
|
||||
#define ABI_DIFF_HELPERS_H_
|
||||
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <deque>
|
||||
|
||||
@@ -23,13 +37,13 @@ enum DiffStatus {
|
||||
opaque_diff = 3,
|
||||
};
|
||||
|
||||
static inline DiffStatus operator| (DiffStatus f,DiffStatus s) {
|
||||
static inline DiffStatus operator|(DiffStatus f,DiffStatus s) {
|
||||
return static_cast<DiffStatus>(
|
||||
static_cast<std::underlying_type<DiffStatus>::type>(f) |
|
||||
static_cast<std::underlying_type<DiffStatus>::type>(s));
|
||||
}
|
||||
|
||||
static inline DiffStatus operator& (DiffStatus f, DiffStatus s) {
|
||||
static inline DiffStatus operator&(DiffStatus f, DiffStatus s) {
|
||||
return static_cast<DiffStatus>(
|
||||
static_cast<std::underlying_type<DiffStatus>::type>(f) &
|
||||
static_cast<std::underlying_type<DiffStatus>::type>(s));
|
||||
@@ -49,9 +63,10 @@ struct GenericFieldDiffInfo {
|
||||
std::string Unwind(const std::deque<std::string> *type_queue);
|
||||
|
||||
struct DiffPolicyOptions {
|
||||
DiffPolicyOptions(bool consider_opaque_types_different) :
|
||||
consider_opaque_types_different_(consider_opaque_types_different) { }
|
||||
bool consider_opaque_types_different_ = false;
|
||||
DiffPolicyOptions(bool consider_opaque_types_different)
|
||||
: consider_opaque_types_different_(consider_opaque_types_different) {}
|
||||
|
||||
bool consider_opaque_types_different_;
|
||||
};
|
||||
|
||||
class AbiDiffHelper {
|
||||
@@ -66,7 +81,7 @@ class AbiDiffHelper {
|
||||
: old_types_(old_types), new_types_(new_types),
|
||||
diff_policy_options_(diff_policy_options), type_cache_(type_cache),
|
||||
ir_diff_dumper_(ir_diff_dumper),
|
||||
local_to_global_type_id_map_(local_to_global_type_id_map) { }
|
||||
local_to_global_type_id_map_(local_to_global_type_id_map) {}
|
||||
|
||||
DiffStatus CompareAndDumpTypeDiff(
|
||||
const std::string &old_type_str, const std::string &new_type_str,
|
||||
@@ -110,6 +125,7 @@ class AbiDiffHelper {
|
||||
|
||||
DiffStatus CompareBuiltinTypes(const abi_util::BuiltinTypeIR *old_type,
|
||||
const abi_util::BuiltinTypeIR *new_type);
|
||||
|
||||
static void CompareEnumFields(
|
||||
const std::vector<abi_util::EnumFieldIR> &old_fields,
|
||||
const std::vector<abi_util::EnumFieldIR> &new_fields,
|
||||
@@ -182,17 +198,19 @@ class AbiDiffHelper {
|
||||
bool AddToDiff(DiffType *mutable_diff, const DiffElement *oldp,
|
||||
const DiffElement *newp,
|
||||
std::deque<std::string> *type_queue = nullptr);
|
||||
|
||||
protected:
|
||||
const AbiElementMap<const abi_util::TypeIR *> &old_types_;
|
||||
const AbiElementMap<const abi_util::TypeIR *> &new_types_;
|
||||
const DiffPolicyOptions &diff_policy_options_;
|
||||
std::set<std::string> *type_cache_ = nullptr;
|
||||
abi_util::IRDiffDumper *ir_diff_dumper_ = nullptr;
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map_ = nullptr;
|
||||
std::set<std::string> *type_cache_;
|
||||
abi_util::IRDiffDumper *ir_diff_dumper_;
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map_;
|
||||
};
|
||||
|
||||
void ReplaceTypeIdsWithTypeNames(
|
||||
const AbiElementMap<const TypeIR *> &type_graph, LinkableMessageIR *lm);
|
||||
|
||||
} // namespace abi_util
|
||||
#endif
|
||||
|
||||
#endif // ABI_DIFF_HELPERS_H_
|
||||
|
||||
@@ -12,13 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <ir_representation.h>
|
||||
#ifndef HEADER_ABI_UTIL_H_
|
||||
#define HEADER_ABI_UTIL_H_
|
||||
|
||||
#include <llvm/Object/ELFObjectFile.h>
|
||||
#include <llvm/Object/ELFTypes.h>
|
||||
#include <llvm/Object/SymbolSize.h>
|
||||
#include <llvm/Support/Endian.h>
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <map>
|
||||
#include <regex>
|
||||
@@ -26,11 +23,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using llvm::object::ObjectFile;
|
||||
using llvm::object::ELFObjectFile;
|
||||
using llvm::object::ELFFile;
|
||||
using llvm::object::ELFType;
|
||||
|
||||
namespace abi_util {
|
||||
|
||||
std::string RealPath(const std::string &path);
|
||||
@@ -38,58 +30,6 @@ std::string RealPath(const std::string &path);
|
||||
std::set<std::string> CollectAllExportedHeaders(
|
||||
const std::vector<std::string> &exported_header_dirs);
|
||||
|
||||
class VersionScriptParser {
|
||||
public:
|
||||
|
||||
enum LineScope {
|
||||
global,
|
||||
local,
|
||||
};
|
||||
|
||||
VersionScriptParser(const std::string &version_script,
|
||||
const std::string &arch,
|
||||
const std::string &api);
|
||||
bool Parse();
|
||||
|
||||
const std::map<std::string, ElfFunctionIR> &GetFunctions();
|
||||
|
||||
const std::map<std::string, ElfObjectIR> &GetGlobVars();
|
||||
|
||||
const std::set<std::string> &GetFunctionRegexs();
|
||||
|
||||
const std::set<std::string> &GetGlobVarRegexs();
|
||||
|
||||
private:
|
||||
|
||||
bool ParseInnerBlock(std::ifstream &symbol_ifstream);
|
||||
|
||||
LineScope GetLineScope(std::string &line, LineScope scope);
|
||||
|
||||
bool ParseSymbolLine(const std::string &line);
|
||||
|
||||
bool SymbolInArchAndApiVersion(const std::string &line,
|
||||
const std::string &arch, int api);
|
||||
|
||||
bool SymbolExported(const std::string &line, const std::string &arch,
|
||||
int api);
|
||||
|
||||
int ApiStrToInt(const std::string &api);
|
||||
|
||||
void AddToVars(std::string &symbol);
|
||||
|
||||
void AddToFunctions(std::string &symbol);
|
||||
|
||||
private:
|
||||
const std::string &version_script_;
|
||||
const std::string &arch_;
|
||||
std::map<std::string, ElfFunctionIR> functions_;
|
||||
std::map<std::string, ElfObjectIR> globvars_;
|
||||
// Added to speed up version script parsing and linking.
|
||||
std::set<std::string> function_regexs_;
|
||||
std::set<std::string> globvar_regexs_;
|
||||
int api_;
|
||||
};
|
||||
|
||||
inline std::string FindAndReplace(const std::string &candidate_str,
|
||||
const std::string &find_str,
|
||||
const std::string &replace_str) {
|
||||
@@ -99,39 +39,6 @@ inline std::string FindAndReplace(const std::string &candidate_str,
|
||||
return std::regex_replace(candidate_str, match_expr, replace_str);
|
||||
}
|
||||
|
||||
|
||||
class SoFileParser {
|
||||
public:
|
||||
static std::unique_ptr<SoFileParser> Create(const ObjectFile *obj);
|
||||
virtual const std::map<std::string, ElfFunctionIR> &GetFunctions() const = 0;
|
||||
virtual const std::map<std::string, ElfObjectIR> &GetGlobVars() const = 0;
|
||||
virtual ~SoFileParser() {};
|
||||
virtual void GetSymbols() = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ELFSoFileParser : public SoFileParser {
|
||||
public:
|
||||
const std::map<std::string, ElfFunctionIR> &GetFunctions() const override;
|
||||
|
||||
const std::map<std::string, ElfObjectIR> &GetGlobVars() const override;
|
||||
|
||||
LLVM_ELF_IMPORT_TYPES_ELFT(T)
|
||||
typedef ELFFile<T> ELFO;
|
||||
typedef typename ELFO::Elf_Sym Elf_Sym;
|
||||
|
||||
ELFSoFileParser(const ELFObjectFile<T> *obj) : obj_(obj) {}
|
||||
virtual ~ELFSoFileParser() override {};
|
||||
void GetSymbols() override;
|
||||
private:
|
||||
const ELFObjectFile<T> *obj_;
|
||||
std::map<std::string, abi_util::ElfFunctionIR> functions_;
|
||||
std::map<std::string, abi_util::ElfObjectIR> globvars_;
|
||||
|
||||
private:
|
||||
bool IsSymbolExported(const Elf_Sym *elf_sym) const;
|
||||
};
|
||||
|
||||
template <typename T, typename K>
|
||||
std::vector<T> FindRemovedElements(
|
||||
const std::map<K, T> &old_elements_map,
|
||||
@@ -191,3 +98,5 @@ std::vector<std::pair<T, T>> FindCommonElements(
|
||||
}
|
||||
|
||||
} // namespace abi_util
|
||||
|
||||
#endif // HEADER_ABI_UTIL_H_
|
||||
|
||||
@@ -11,17 +11,18 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef IR_
|
||||
#define IR_
|
||||
|
||||
#ifndef IR_REPRESENTATION_H_
|
||||
#define IR_REPRESENTATION_H_
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
// Classes which act as middle-men between clang AST parsing routines and
|
||||
@@ -57,8 +58,8 @@ static inline CompatibilityStatusIR operator|(CompatibilityStatusIR f,
|
||||
static_cast<std::underlying_type<CompatibilityStatusIR>::type>(s));
|
||||
}
|
||||
|
||||
static inline CompatibilityStatusIR operator&(
|
||||
CompatibilityStatusIR f, CompatibilityStatusIR s) {
|
||||
static inline CompatibilityStatusIR operator&(CompatibilityStatusIR f,
|
||||
CompatibilityStatusIR s) {
|
||||
return static_cast<CompatibilityStatusIR>(
|
||||
static_cast<std::underlying_type<CompatibilityStatusIR>::type>(f) &
|
||||
static_cast<std::underlying_type<CompatibilityStatusIR>::type>(s));
|
||||
@@ -95,6 +96,8 @@ std::map<V, K> CreateInverseMap(const std::map<K, V> &m) {
|
||||
|
||||
class LinkableMessageIR {
|
||||
public:
|
||||
virtual ~LinkableMessageIR() {}
|
||||
|
||||
const std::string &GetLinkerSetKey() const {
|
||||
return linker_set_key_;
|
||||
}
|
||||
@@ -112,7 +115,7 @@ class LinkableMessageIR {
|
||||
}
|
||||
|
||||
virtual LinkableMessageKind GetKind() const = 0;
|
||||
virtual ~LinkableMessageIR() { };
|
||||
|
||||
protected:
|
||||
// The source file where this message comes from. This will be an empty string
|
||||
// for built-in types.
|
||||
@@ -122,6 +125,14 @@ class LinkableMessageIR {
|
||||
|
||||
class ReferencesOtherType {
|
||||
public:
|
||||
ReferencesOtherType(const std::string &referenced_type)
|
||||
: referenced_type_(referenced_type) {}
|
||||
|
||||
ReferencesOtherType(std::string &&referenced_type)
|
||||
: referenced_type_(std::move(referenced_type)) {}
|
||||
|
||||
ReferencesOtherType() {}
|
||||
|
||||
void SetReferencedType(const std::string &referenced_type) {
|
||||
referenced_type_ = referenced_type;
|
||||
}
|
||||
@@ -130,21 +141,14 @@ class ReferencesOtherType {
|
||||
return referenced_type_;
|
||||
}
|
||||
|
||||
ReferencesOtherType(const std::string &referenced_type)
|
||||
: referenced_type_(referenced_type) { }
|
||||
|
||||
ReferencesOtherType(std::string &&referenced_type)
|
||||
: referenced_type_(std::move(referenced_type)) { }
|
||||
|
||||
ReferencesOtherType() { }
|
||||
|
||||
protected:
|
||||
std::string referenced_type_;
|
||||
};
|
||||
|
||||
// TODO: Break this up into types with sizes and those without types ?
|
||||
class TypeIR : public LinkableMessageIR , public ReferencesOtherType {
|
||||
// TODO: Break this up into types with sizes and those without types?
|
||||
class TypeIR : public LinkableMessageIR, public ReferencesOtherType {
|
||||
public:
|
||||
virtual ~TypeIR() {}
|
||||
|
||||
void SetSelfType(const std::string &self_type) {
|
||||
self_type_ = self_type;
|
||||
@@ -165,18 +169,19 @@ class TypeIR : public LinkableMessageIR , public ReferencesOtherType {
|
||||
void SetSize(uint64_t size) {
|
||||
size_ = size;
|
||||
}
|
||||
|
||||
uint64_t GetSize() const {
|
||||
return size_;
|
||||
}
|
||||
|
||||
void SetAlignment(uint32_t alignment) {
|
||||
alignment_ = alignment;
|
||||
}
|
||||
|
||||
uint32_t GetAlignment() const {
|
||||
return alignment_;
|
||||
}
|
||||
|
||||
virtual ~TypeIR() { }
|
||||
|
||||
protected:
|
||||
std::string name_;
|
||||
std::string self_type_;
|
||||
@@ -213,9 +218,9 @@ class VTableComponentIR {
|
||||
|
||||
VTableComponentIR(const std::string &name, Kind kind, int64_t value,
|
||||
bool is_pure)
|
||||
: component_name_(name), kind_(kind), value_(value), is_pure_(is_pure) { }
|
||||
: component_name_(name), kind_(kind), value_(value), is_pure_(is_pure) {}
|
||||
|
||||
VTableComponentIR() { }
|
||||
VTableComponentIR() {}
|
||||
|
||||
Kind GetKind() const {
|
||||
return kind_;
|
||||
@@ -261,10 +266,10 @@ class VTableLayoutIR {
|
||||
class CXXBaseSpecifierIR : public ReferencesOtherType {
|
||||
public:
|
||||
CXXBaseSpecifierIR(const std::string &type, bool is_virtual,
|
||||
AccessSpecifierIR access) :
|
||||
ReferencesOtherType(type), is_virtual_(is_virtual), access_(access) { }
|
||||
AccessSpecifierIR access)
|
||||
: ReferencesOtherType(type), is_virtual_(is_virtual), access_(access) {}
|
||||
|
||||
CXXBaseSpecifierIR() { }
|
||||
CXXBaseSpecifierIR() {}
|
||||
|
||||
bool IsVirtual() const {
|
||||
return is_virtual_;
|
||||
@@ -282,12 +287,12 @@ class CXXBaseSpecifierIR : public ReferencesOtherType {
|
||||
class TemplateElementIR : public ReferencesOtherType {
|
||||
public:
|
||||
TemplateElementIR(std::string &&type)
|
||||
: ReferencesOtherType(std::move(type)) { }
|
||||
: ReferencesOtherType(std::move(type)) {}
|
||||
|
||||
TemplateElementIR(const std::string &type)
|
||||
: ReferencesOtherType(type) { }
|
||||
: ReferencesOtherType(type) {}
|
||||
|
||||
TemplateElementIR() { }
|
||||
TemplateElementIR() {}
|
||||
};
|
||||
|
||||
class TemplateInfoIR {
|
||||
@@ -331,9 +336,9 @@ class RecordFieldIR : public ReferencesOtherType {
|
||||
RecordFieldIR(const std::string &name, const std::string &type,
|
||||
uint64_t offset, AccessSpecifierIR access)
|
||||
: ReferencesOtherType(type), name_(name), offset_(offset),
|
||||
access_(access) { }
|
||||
access_(access) {}
|
||||
|
||||
RecordFieldIR() { }
|
||||
RecordFieldIR() {}
|
||||
|
||||
const std::string &GetName() const {
|
||||
return name_;
|
||||
@@ -353,7 +358,7 @@ class RecordFieldIR : public ReferencesOtherType {
|
||||
AccessSpecifierIR access_ = AccessSpecifierIR::PublicAccess;
|
||||
};
|
||||
|
||||
class RecordTypeIR: public TypeIR, public TemplatedArtifactIR,
|
||||
class RecordTypeIR : public TypeIR, public TemplatedArtifactIR,
|
||||
public TagTypeIR {
|
||||
public:
|
||||
enum RecordKind {
|
||||
@@ -444,7 +449,8 @@ class RecordTypeIR: public TypeIR, public TemplatedArtifactIR,
|
||||
class EnumFieldIR {
|
||||
public:
|
||||
EnumFieldIR(const std::string &name, int value)
|
||||
: name_(name), value_(value) { }
|
||||
: name_(name), value_(value) {}
|
||||
|
||||
const std::string &GetName() const {
|
||||
return name_;
|
||||
}
|
||||
@@ -594,7 +600,7 @@ class QualifiedTypeIR : public TypeIR {
|
||||
bool is_volatile_;
|
||||
};
|
||||
|
||||
class GlobalVarIR: public LinkableMessageIR , public ReferencesOtherType {
|
||||
class GlobalVarIR : public LinkableMessageIR , public ReferencesOtherType {
|
||||
public:
|
||||
// Add Methods to get information from the IR.
|
||||
void SetName(std::string &&name) {
|
||||
@@ -628,8 +634,8 @@ class GlobalVarIR: public LinkableMessageIR , public ReferencesOtherType {
|
||||
|
||||
class ParamIR : public ReferencesOtherType {
|
||||
public:
|
||||
ParamIR(const std::string &type, bool is_default, bool is_this_ptr) :
|
||||
ReferencesOtherType(type) , is_default_(is_default),
|
||||
ParamIR(const std::string &type, bool is_default, bool is_this_ptr)
|
||||
: ReferencesOtherType(type) , is_default_(is_default),
|
||||
is_this_ptr_(is_this_ptr) {}
|
||||
|
||||
bool GetIsDefault() const {
|
||||
@@ -666,6 +672,7 @@ class CFunctionLikeIR {
|
||||
std::vector<ParamIR> &GetParameters() {
|
||||
return parameters_;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string return_type_; // return type reference
|
||||
std::vector<ParamIR> parameters_;
|
||||
@@ -724,6 +731,12 @@ class ElfSymbolIR {
|
||||
Protected,
|
||||
};
|
||||
|
||||
public:
|
||||
ElfSymbolIR(const std::string &name, ElfSymbolBinding binding)
|
||||
: name_(name), binding_(binding) {}
|
||||
|
||||
virtual ~ElfSymbolIR() {}
|
||||
|
||||
const std::string GetName() const {
|
||||
return name_;
|
||||
}
|
||||
@@ -732,14 +745,8 @@ class ElfSymbolIR {
|
||||
return binding_;
|
||||
}
|
||||
|
||||
|
||||
ElfSymbolIR(const std::string &name, ElfSymbolBinding binding)
|
||||
: name_(name), binding_(binding) { }
|
||||
|
||||
virtual ElfSymbolKind GetKind() const = 0;
|
||||
|
||||
virtual ~ElfSymbolIR() { }
|
||||
|
||||
protected:
|
||||
std::string name_;
|
||||
ElfSymbolBinding binding_;
|
||||
@@ -747,27 +754,29 @@ class ElfSymbolIR {
|
||||
|
||||
class ElfFunctionIR : public ElfSymbolIR {
|
||||
public:
|
||||
ElfFunctionIR(const std::string &name, ElfSymbolBinding binding)
|
||||
: ElfSymbolIR(name, binding) {}
|
||||
|
||||
ElfSymbolKind GetKind() const override {
|
||||
return ElfFunctionKind;
|
||||
}
|
||||
|
||||
ElfFunctionIR(const std::string &name, ElfSymbolBinding binding)
|
||||
: ElfSymbolIR(name, binding) { }
|
||||
};
|
||||
|
||||
class ElfObjectIR : public ElfSymbolIR {
|
||||
public:
|
||||
ElfObjectIR(const std::string &name, ElfSymbolBinding binding)
|
||||
: ElfSymbolIR(name, binding) {}
|
||||
|
||||
ElfSymbolKind GetKind() const override {
|
||||
return ElfObjectKind;
|
||||
}
|
||||
|
||||
ElfObjectIR(const std::string &name, ElfSymbolBinding binding)
|
||||
: ElfSymbolIR(name, binding) { }
|
||||
};
|
||||
|
||||
class IRDumper {
|
||||
public:
|
||||
IRDumper(const std::string &dump_path) : dump_path_(dump_path) { }
|
||||
IRDumper(const std::string &dump_path) : dump_path_(dump_path) {}
|
||||
|
||||
virtual ~IRDumper() {}
|
||||
|
||||
static std::unique_ptr<IRDumper> CreateIRDumper(
|
||||
TextFormatIR text_format, const std::string &dump_path);
|
||||
@@ -778,21 +787,17 @@ class IRDumper {
|
||||
|
||||
virtual bool Dump() = 0;
|
||||
|
||||
virtual ~IRDumper() {}
|
||||
|
||||
protected:
|
||||
const std::string &dump_path_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline std::string GetReferencedTypeMapKey(
|
||||
T &element) {
|
||||
inline std::string GetReferencedTypeMapKey(T &element) {
|
||||
return element.GetReferencedType();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::string GetReferencedTypeMapKey<ArrayTypeIR>(
|
||||
ArrayTypeIR &element) {
|
||||
inline std::string GetReferencedTypeMapKey<ArrayTypeIR>(ArrayTypeIR &element) {
|
||||
return element.GetReferencedType() + ":" + std::to_string(element.GetSize());
|
||||
}
|
||||
|
||||
@@ -842,8 +847,12 @@ typename AbiElementMap<T>::iterator AddToMapAndTypeGraph(
|
||||
|
||||
class TextFormatToIRReader {
|
||||
public:
|
||||
|
||||
struct MergeStatus {
|
||||
MergeStatus(bool was_newly_added, const std::string &type_id)
|
||||
: was_newly_added_(was_newly_added), type_id_(type_id) {}
|
||||
|
||||
MergeStatus() {}
|
||||
|
||||
// type_id_ always has the global_type_id corresponding to the type this
|
||||
// MergeStatus corresponds to. For
|
||||
// generic reference types (pointers, qual types, l(r)value references etc),
|
||||
@@ -851,14 +860,15 @@ class TextFormatToIRReader {
|
||||
// parent type_graph if the we decide to add the referencing type to the
|
||||
// parent post ODR checking.
|
||||
bool was_newly_added_ = false;
|
||||
|
||||
std::string type_id_;
|
||||
MergeStatus(bool was_newly_added, const std::string &type_id)
|
||||
: was_newly_added_(was_newly_added), type_id_(type_id) { }
|
||||
MergeStatus() { }
|
||||
};
|
||||
|
||||
public:
|
||||
TextFormatToIRReader(const std::set<std::string> *exported_headers)
|
||||
: exported_headers_(exported_headers) { }
|
||||
: exported_headers_(exported_headers) {}
|
||||
|
||||
virtual ~TextFormatToIRReader() {}
|
||||
|
||||
const AbiElementMap<FunctionIR> &GetFunctions() const {
|
||||
return functions_;
|
||||
@@ -880,13 +890,11 @@ class TextFormatToIRReader {
|
||||
return enum_types_;
|
||||
}
|
||||
|
||||
const AbiElementMap<LvalueReferenceTypeIR> &
|
||||
GetLvalueReferenceTypes() const {
|
||||
const AbiElementMap<LvalueReferenceTypeIR> &GetLvalueReferenceTypes() const {
|
||||
return lvalue_reference_types_;
|
||||
}
|
||||
|
||||
const AbiElementMap<RvalueReferenceTypeIR> &
|
||||
GetRvalueReferenceTypes() const {
|
||||
const AbiElementMap<RvalueReferenceTypeIR> &GetRvalueReferenceTypes() const {
|
||||
return rvalue_reference_types_;
|
||||
}
|
||||
|
||||
@@ -928,7 +936,7 @@ class TextFormatToIRReader {
|
||||
template <typename Iterator>
|
||||
bool ReadDumps(Iterator begin, Iterator end) {
|
||||
Iterator it = begin;
|
||||
while(it != end) {
|
||||
while (it != end) {
|
||||
if (!ReadDump(*it)) {
|
||||
return false;
|
||||
}
|
||||
@@ -937,8 +945,6 @@ class TextFormatToIRReader {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual ~TextFormatToIRReader() { }
|
||||
|
||||
void Merge(TextFormatToIRReader &&addend) {
|
||||
MergeElements(&functions_, std::move(addend.functions_));
|
||||
MergeElements(&global_variables_, std::move(addend.global_variables_));
|
||||
@@ -1057,8 +1063,8 @@ class TextFormatToIRReader {
|
||||
const TypeIR *addend_node, const TextFormatToIRReader &addend,
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map);
|
||||
|
||||
MergeStatus MergeType(const TypeIR *addend_type,
|
||||
const TextFormatToIRReader &addend,
|
||||
MergeStatus MergeType(
|
||||
const TypeIR *addend_type, const TextFormatToIRReader &addend,
|
||||
AbiElementMap<MergeStatus> *merged_types_cache);
|
||||
|
||||
std::string AllocateNewTypeId();
|
||||
@@ -1068,7 +1074,6 @@ class TextFormatToIRReader {
|
||||
const std::set<std::string> *exported_headers = nullptr);
|
||||
|
||||
protected:
|
||||
|
||||
template <typename Augend, typename Addend>
|
||||
inline void MergeElements(Augend *augend, Addend &&addend) {
|
||||
augend->insert(std::make_move_iterator(addend.begin()),
|
||||
@@ -1107,7 +1112,6 @@ class TextFormatToIRReader {
|
||||
|
||||
class DiffMessageIR {
|
||||
public:
|
||||
|
||||
enum DiffKind {
|
||||
Extension, // Applicable for enums.
|
||||
Added,
|
||||
@@ -1116,7 +1120,11 @@ class DiffMessageIR {
|
||||
Unreferenced
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~DiffMessageIR() {}
|
||||
|
||||
virtual LinkableMessageKind Kind() const = 0;
|
||||
|
||||
void SetName(const std::string &name) {
|
||||
name_ = name;
|
||||
}
|
||||
@@ -1125,8 +1133,6 @@ class DiffMessageIR {
|
||||
return name_;
|
||||
}
|
||||
|
||||
virtual ~DiffMessageIR() { }
|
||||
|
||||
protected:
|
||||
std::string name_;
|
||||
};
|
||||
@@ -1135,7 +1141,7 @@ class AccessSpecifierDiffIR {
|
||||
public:
|
||||
AccessSpecifierDiffIR(AccessSpecifierIR old_access,
|
||||
AccessSpecifierIR new_access)
|
||||
: old_access_(old_access), new_access_(new_access) { }
|
||||
: old_access_(old_access), new_access_(new_access) {}
|
||||
|
||||
protected:
|
||||
AccessSpecifierIR old_access_;
|
||||
@@ -1146,7 +1152,7 @@ class TypeDiffIR {
|
||||
public:
|
||||
TypeDiffIR(std::pair<uint64_t, uint64_t> &&sizes,
|
||||
std::pair<uint32_t, uint32_t> &&alignment)
|
||||
: sizes_(std::move(sizes)), alignments_(std::move(alignment)) { }
|
||||
: sizes_(std::move(sizes)), alignments_(std::move(alignment)) {}
|
||||
|
||||
const std::pair<uint64_t, uint64_t> &GetSizes() const {
|
||||
return sizes_;
|
||||
@@ -1165,7 +1171,7 @@ class VTableLayoutDiffIR {
|
||||
public:
|
||||
VTableLayoutDiffIR(const VTableLayoutIR &old_layout,
|
||||
const VTableLayoutIR &new_layout)
|
||||
: old_layout_(old_layout), new_layout_(new_layout) { }
|
||||
: old_layout_(old_layout), new_layout_(new_layout) {}
|
||||
|
||||
const VTableLayoutIR &GetOldVTable() const {
|
||||
return old_layout_;
|
||||
@@ -1184,7 +1190,8 @@ class RecordFieldDiffIR {
|
||||
public:
|
||||
RecordFieldDiffIR(const RecordFieldIR *old_field,
|
||||
const RecordFieldIR *new_field)
|
||||
: old_field_(old_field), new_field_(new_field) { }
|
||||
: old_field_(old_field), new_field_(new_field) {}
|
||||
|
||||
const RecordFieldIR *GetOldField() const {
|
||||
return old_field_;
|
||||
}
|
||||
@@ -1203,7 +1210,8 @@ class CXXBaseSpecifierDiffIR {
|
||||
const std::vector<CXXBaseSpecifierIR> &old_base_specifiers,
|
||||
const std::vector<CXXBaseSpecifierIR> &new_base_specifiers)
|
||||
: old_base_specifiers_(old_base_specifiers),
|
||||
new_base_specifiers_(new_base_specifiers) { }
|
||||
new_base_specifiers_(new_base_specifiers) {}
|
||||
|
||||
const std::vector<CXXBaseSpecifierIR> &GetOldBases() const {
|
||||
return old_base_specifiers_;
|
||||
}
|
||||
@@ -1298,7 +1306,7 @@ class RecordTypeDiffIR : public DiffMessageIR {
|
||||
class EnumFieldDiffIR {
|
||||
public:
|
||||
EnumFieldDiffIR(const EnumFieldIR *old_field, const EnumFieldIR *new_field)
|
||||
: old_field_(old_field), new_field_(new_field) { }
|
||||
: old_field_(old_field), new_field_(new_field) {}
|
||||
|
||||
const EnumFieldIR *GetOldField() const {
|
||||
return old_field_;
|
||||
@@ -1353,7 +1361,6 @@ class EnumTypeDiffIR : public DiffMessageIR {
|
||||
fields_added_.size() != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1361,7 +1368,6 @@ class EnumTypeDiffIR : public DiffMessageIR {
|
||||
if (fields_removed_.size() != 0 || fields_diff_.size() != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1388,7 +1394,7 @@ class GlobalVarDiffIR : public DiffMessageIR {
|
||||
|
||||
GlobalVarDiffIR(const GlobalVarIR *old_global_var,
|
||||
const GlobalVarIR *new_global_var)
|
||||
: old_global_var_(old_global_var), new_global_var_(new_global_var) { }
|
||||
: old_global_var_(old_global_var), new_global_var_(new_global_var) {}
|
||||
|
||||
const GlobalVarIR *GetOldGlobalVar() const {
|
||||
return old_global_var_;
|
||||
@@ -1405,14 +1411,14 @@ class GlobalVarDiffIR : public DiffMessageIR {
|
||||
|
||||
class FunctionDiffIR : public DiffMessageIR {
|
||||
public:
|
||||
FunctionDiffIR(const FunctionIR *old_function,
|
||||
const FunctionIR *new_function)
|
||||
: old_function_(old_function), new_function_(new_function) {}
|
||||
|
||||
LinkableMessageKind Kind() const override {
|
||||
return LinkableMessageKind::FunctionKind;
|
||||
}
|
||||
|
||||
FunctionDiffIR(const FunctionIR *old_function,
|
||||
const FunctionIR *new_function)
|
||||
: old_function_(old_function), new_function_(new_function) { }
|
||||
|
||||
const FunctionIR *GetOldFunction() const {
|
||||
return old_function_;
|
||||
}
|
||||
@@ -1430,7 +1436,10 @@ class IRDiffDumper {
|
||||
public:
|
||||
typedef DiffMessageIR::DiffKind DiffKind;
|
||||
|
||||
IRDiffDumper(const std::string &dump_path) : dump_path_(dump_path) { }
|
||||
public:
|
||||
IRDiffDumper(const std::string &dump_path) : dump_path_(dump_path) {}
|
||||
|
||||
virtual ~IRDiffDumper() {}
|
||||
|
||||
virtual bool AddDiffMessageIR(const DiffMessageIR *,
|
||||
const std::string &type_stack,
|
||||
@@ -1452,13 +1461,13 @@ class IRDiffDumper {
|
||||
|
||||
virtual CompatibilityStatusIR GetCompatibilityStatusIR() = 0;
|
||||
|
||||
virtual ~IRDiffDumper() {}
|
||||
static std::unique_ptr<IRDiffDumper> CreateIRDiffDumper(
|
||||
TextFormatIR, const std::string &dump_path);
|
||||
|
||||
protected:
|
||||
const std::string &dump_path_;
|
||||
};
|
||||
|
||||
} // namespace abi_util
|
||||
|
||||
#endif // IR_
|
||||
#endif // IR_REPRESENTATION_H_
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef IR_JSON_
|
||||
#define IR_JSON_
|
||||
|
||||
#include <ir_representation.h>
|
||||
#ifndef IR_REPRESENTATION_JSON_H_
|
||||
#define IR_REPRESENTATION_JSON_H_
|
||||
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <json/value.h>
|
||||
|
||||
@@ -118,14 +119,14 @@ class JsonIRDumper : public IRDumper, public IRToJsonConverter {
|
||||
public:
|
||||
JsonIRDumper(const std::string &dump_path);
|
||||
|
||||
~JsonIRDumper() override {}
|
||||
|
||||
bool AddLinkableMessageIR(const LinkableMessageIR *) override;
|
||||
|
||||
bool AddElfSymbolMessageIR(const ElfSymbolIR *) override;
|
||||
|
||||
bool Dump() override;
|
||||
|
||||
~JsonIRDumper() override {}
|
||||
|
||||
private:
|
||||
JsonObject translation_unit_;
|
||||
};
|
||||
@@ -281,6 +282,7 @@ class JsonToIRReader : public TextFormatToIRReader {
|
||||
|
||||
static EnumTypeIR EnumTypeJsonToIR(const JsonObjectRef &enum_type);
|
||||
};
|
||||
|
||||
} // namespace abi_util
|
||||
|
||||
#endif // IR_JSON_
|
||||
#endif // IR_REPRESENTATION_JSON_H_
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef IR_PROTOBUF_
|
||||
#define IR_PROTOBUF_
|
||||
|
||||
#include <ir_representation.h>
|
||||
#ifndef IR_REPRESENTATION_PROTOBUF_H_
|
||||
#define IR_REPRESENTATION_PROTOBUF_H_
|
||||
|
||||
#include "ir_representation.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
@@ -33,7 +34,7 @@ namespace abi_util {
|
||||
|
||||
inline abi_diff::CompatibilityStatus CompatibilityStatusIRToProtobuf(
|
||||
CompatibilityStatusIR status) {
|
||||
switch(status) {
|
||||
switch (status) {
|
||||
case CompatibilityStatusIR::Incompatible:
|
||||
return abi_diff::CompatibilityStatus::INCOMPATIBLE;
|
||||
case CompatibilityStatusIR::Extension:
|
||||
@@ -46,7 +47,7 @@ inline abi_diff::CompatibilityStatus CompatibilityStatusIRToProtobuf(
|
||||
|
||||
inline abi_dump::ElfSymbolBinding ElfSymbolBindingIRToProtobuf(
|
||||
ElfSymbolIR::ElfSymbolBinding binding) {
|
||||
switch(binding) {
|
||||
switch (binding) {
|
||||
case ElfSymbolIR::ElfSymbolBinding::Global:
|
||||
return abi_dump::ElfSymbolBinding::Global;
|
||||
case ElfSymbolIR::ElfSymbolBinding::Weak:
|
||||
@@ -59,7 +60,7 @@ inline abi_dump::ElfSymbolBinding ElfSymbolBindingIRToProtobuf(
|
||||
|
||||
inline ElfSymbolIR::ElfSymbolBinding ElfSymbolBindingProtobufToIR(
|
||||
abi_dump::ElfSymbolBinding binding) {
|
||||
switch(binding) {
|
||||
switch (binding) {
|
||||
case abi_dump::ElfSymbolBinding::Global:
|
||||
return ElfSymbolIR::ElfSymbolBinding::Global;
|
||||
case abi_dump::ElfSymbolBinding::Weak:
|
||||
@@ -216,6 +217,7 @@ class IRToProtobufConverter {
|
||||
|
||||
static bool AddEnumFields(abi_dump::EnumType *enum_protobuf,
|
||||
const EnumTypeIR *enum_ir);
|
||||
|
||||
public:
|
||||
static abi_dump::EnumType ConvertEnumTypeIR(const EnumTypeIR *enump);
|
||||
|
||||
@@ -265,7 +267,8 @@ class IRToProtobufConverter {
|
||||
|
||||
class IRDiffToProtobufConverter {
|
||||
private:
|
||||
static bool AddTypeInfoDiff(abi_diff::TypeInfoDiff *type_info_diff_protobuf,
|
||||
static bool AddTypeInfoDiff(
|
||||
abi_diff::TypeInfoDiff *type_info_diff_protobuf,
|
||||
const TypeDiffIR *type_diff_ir);
|
||||
|
||||
static bool AddVTableLayoutDiff(
|
||||
@@ -335,7 +338,9 @@ class ProtobufIRDumper : public IRDumper, public IRToProtobufConverter {
|
||||
|
||||
public:
|
||||
ProtobufIRDumper(const std::string &dump_path)
|
||||
: IRDumper(dump_path), tu_ptr_(new abi_dump::TranslationUnit()) { }
|
||||
: IRDumper(dump_path), tu_ptr_(new abi_dump::TranslationUnit()) {}
|
||||
|
||||
~ProtobufIRDumper() override {}
|
||||
|
||||
bool AddLinkableMessageIR(const LinkableMessageIR *) override;
|
||||
|
||||
@@ -343,18 +348,19 @@ class ProtobufIRDumper : public IRDumper, public IRToProtobufConverter {
|
||||
|
||||
bool Dump() override;
|
||||
|
||||
~ProtobufIRDumper() override { }
|
||||
|
||||
private:
|
||||
std::unique_ptr<abi_dump::TranslationUnit> tu_ptr_;
|
||||
};
|
||||
|
||||
|
||||
class ProtobufTextFormatToIRReader : public TextFormatToIRReader {
|
||||
public:
|
||||
private:
|
||||
template <typename T>
|
||||
using RepeatedPtrField = google::protobuf::RepeatedPtrField<T>;
|
||||
|
||||
public:
|
||||
ProtobufTextFormatToIRReader(const std::set<std::string> *exported_headers)
|
||||
: TextFormatToIRReader(exported_headers) { }
|
||||
: TextFormatToIRReader(exported_headers) {}
|
||||
|
||||
bool ReadDump(const std::string &dump_file) override;
|
||||
|
||||
@@ -381,9 +387,9 @@ class ProtobufTextFormatToIRReader : public TextFormatToIRReader {
|
||||
|
||||
void ReadRvalueReferenceTypes(const abi_dump::TranslationUnit &tu);
|
||||
|
||||
void ReadElfFunctions (const abi_dump::TranslationUnit &tu);
|
||||
void ReadElfFunctions(const abi_dump::TranslationUnit &tu);
|
||||
|
||||
void ReadElfObjects (const abi_dump::TranslationUnit &tu);
|
||||
void ReadElfObjects(const abi_dump::TranslationUnit &tu);
|
||||
|
||||
void ReadTypeInfo(const abi_dump::BasicNamedAndTypedDecl &type_info,
|
||||
TypeIR *typep);
|
||||
@@ -397,13 +403,13 @@ class ProtobufTextFormatToIRReader : public TextFormatToIRReader {
|
||||
const abi_dump::RecordType &record_type_protobuf);
|
||||
|
||||
std::vector<RecordFieldIR> RecordFieldsProtobufToIR(
|
||||
const google::protobuf::RepeatedPtrField<abi_dump::RecordFieldDecl> &rfp);
|
||||
const RepeatedPtrField<abi_dump::RecordFieldDecl> &rfp);
|
||||
|
||||
std::vector<CXXBaseSpecifierIR> RecordCXXBaseSpecifiersProtobufToIR(
|
||||
const google::protobuf::RepeatedPtrField<abi_dump::CXXBaseSpecifier> &rbs);
|
||||
const RepeatedPtrField<abi_dump::CXXBaseSpecifier> &rbs);
|
||||
|
||||
std::vector<EnumFieldIR> EnumFieldsProtobufToIR(
|
||||
const google::protobuf::RepeatedPtrField<abi_dump::EnumFieldDecl> &efp);
|
||||
const RepeatedPtrField<abi_dump::EnumFieldDecl> &efp);
|
||||
|
||||
EnumTypeIR EnumTypeProtobufToIR(
|
||||
const abi_dump::EnumType &enum_type_protobuf);
|
||||
@@ -419,7 +425,9 @@ class ProtobufIRDiffDumper : public IRDiffDumper {
|
||||
public:
|
||||
ProtobufIRDiffDumper(const std::string &dump_path)
|
||||
: IRDiffDumper(dump_path),
|
||||
diff_tu_(new abi_diff::TranslationUnitDiff()) { }
|
||||
diff_tu_(new abi_diff::TranslationUnitDiff()) {}
|
||||
|
||||
~ProtobufIRDiffDumper() override {}
|
||||
|
||||
bool AddDiffMessageIR(const DiffMessageIR *, const std::string &type_stack,
|
||||
DiffKind diff_kind) override;
|
||||
@@ -439,8 +447,6 @@ class ProtobufIRDiffDumper : public IRDiffDumper {
|
||||
|
||||
CompatibilityStatusIR GetCompatibilityStatusIR() override;
|
||||
|
||||
~ProtobufIRDiffDumper() override { }
|
||||
|
||||
private:
|
||||
// User defined types.
|
||||
bool AddRecordTypeDiffIR(const RecordTypeDiffIR *,
|
||||
@@ -474,6 +480,6 @@ class ProtobufIRDiffDumper : public IRDiffDumper {
|
||||
std::unique_ptr<abi_diff::TranslationUnitDiff> diff_tu_;
|
||||
};
|
||||
|
||||
} // abi_util
|
||||
} // namespace abi_util
|
||||
|
||||
#endif // IR_PROTOBUF_
|
||||
#endif // IR_REPRESENTATION_PROTOBUF_H_
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SO_FILE_PARSER_H_
|
||||
#define SO_FILE_PARSER_H_
|
||||
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <llvm/Object/ELFObjectFile.h>
|
||||
#include <llvm/Object/ELFTypes.h>
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace abi_util {
|
||||
|
||||
class SoFileParser {
|
||||
public:
|
||||
virtual ~SoFileParser() {}
|
||||
|
||||
static std::unique_ptr<SoFileParser> Create(
|
||||
const llvm::object::ObjectFile *obj);
|
||||
|
||||
virtual const std::map<std::string, ElfFunctionIR> &GetFunctions() const = 0;
|
||||
virtual const std::map<std::string, ElfObjectIR> &GetGlobVars() const = 0;
|
||||
virtual void GetSymbols() = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ELFSoFileParser : public SoFileParser {
|
||||
private:
|
||||
LLVM_ELF_IMPORT_TYPES_ELFT(T)
|
||||
typedef llvm::object::ELFFile<T> ELFO;
|
||||
typedef typename ELFO::Elf_Sym Elf_Sym;
|
||||
|
||||
public:
|
||||
ELFSoFileParser(const llvm::object::ELFObjectFile<T> *obj) : obj_(obj) {}
|
||||
~ELFSoFileParser() override {}
|
||||
|
||||
const std::map<std::string, ElfFunctionIR> &GetFunctions() const override;
|
||||
const std::map<std::string, ElfObjectIR> &GetGlobVars() const override;
|
||||
void GetSymbols() override;
|
||||
|
||||
private:
|
||||
const llvm::object::ELFObjectFile<T> *obj_;
|
||||
std::map<std::string, abi_util::ElfFunctionIR> functions_;
|
||||
std::map<std::string, abi_util::ElfObjectIR> globvars_;
|
||||
|
||||
private:
|
||||
bool IsSymbolExported(const Elf_Sym *elf_sym) const;
|
||||
};
|
||||
|
||||
} // namespace abi_util
|
||||
|
||||
#endif // SO_FILE_PARSER_H_
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef VERSION_SCRIPT_PARSER_H_
|
||||
#define VERSION_SCRIPT_PARSER_H_
|
||||
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace abi_util {
|
||||
|
||||
class VersionScriptParser {
|
||||
public:
|
||||
enum LineScope {
|
||||
global,
|
||||
local,
|
||||
};
|
||||
|
||||
VersionScriptParser(const std::string &version_script,
|
||||
const std::string &arch,
|
||||
const std::string &api);
|
||||
bool Parse();
|
||||
|
||||
const std::map<std::string, ElfFunctionIR> &GetFunctions();
|
||||
|
||||
const std::map<std::string, ElfObjectIR> &GetGlobVars();
|
||||
|
||||
const std::set<std::string> &GetFunctionRegexs();
|
||||
|
||||
const std::set<std::string> &GetGlobVarRegexs();
|
||||
|
||||
private:
|
||||
bool ParseInnerBlock(std::ifstream &symbol_ifstream);
|
||||
|
||||
LineScope GetLineScope(std::string &line, LineScope scope);
|
||||
|
||||
bool ParseSymbolLine(const std::string &line);
|
||||
|
||||
bool SymbolInArchAndApiVersion(const std::string &line,
|
||||
const std::string &arch, int api);
|
||||
|
||||
bool SymbolExported(const std::string &line, const std::string &arch,
|
||||
int api);
|
||||
|
||||
int ApiStrToInt(const std::string &api);
|
||||
|
||||
void AddToVars(std::string &symbol);
|
||||
|
||||
void AddToFunctions(std::string &symbol);
|
||||
|
||||
private:
|
||||
const std::string &version_script_;
|
||||
const std::string &arch_;
|
||||
std::map<std::string, ElfFunctionIR> functions_;
|
||||
std::map<std::string, ElfObjectIR> globvars_;
|
||||
// Added to speed up version script parsing and linking.
|
||||
std::set<std::string> function_regexs_;
|
||||
std::set<std::string> globvar_regexs_;
|
||||
int api_;
|
||||
};
|
||||
|
||||
} // namespace abi_util
|
||||
|
||||
#endif // VERSION_SCRIPT_PARSER_H_
|
||||
@@ -1,5 +1,19 @@
|
||||
#include <abi_diff_helpers.h>
|
||||
#include <header_abi_util.h>
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "abi_diff_helpers.h"
|
||||
#include "header_abi_util.h"
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
@@ -72,8 +86,7 @@ static void ReplaceReferencesOtherTypeIdWithName(
|
||||
}
|
||||
|
||||
static void ReplaceEnumTypeIRTypeIdsWithTypeNames(
|
||||
const AbiElementMap<const TypeIR *> &type_graph,
|
||||
EnumTypeIR *enum_type_ir) {
|
||||
const AbiElementMap<const TypeIR *> &type_graph, EnumTypeIR *enum_type_ir) {
|
||||
// Replace underlying type.
|
||||
enum_type_ir->SetUnderlyingType(
|
||||
ConvertTypeIdToString(type_graph, enum_type_ir->GetUnderlyingType()));
|
||||
@@ -119,21 +132,20 @@ void ReplaceTypeIdsWithTypeNames(
|
||||
LinkableMessageIR *lm) {
|
||||
switch (lm->GetKind()) {
|
||||
case FunctionKind:
|
||||
ReplaceFunctionTypeIdsWithTypeNames(type_graph,
|
||||
static_cast<FunctionIR *>(lm));
|
||||
ReplaceFunctionTypeIdsWithTypeNames(
|
||||
type_graph, static_cast<FunctionIR *>(lm));
|
||||
break;
|
||||
case GlobalVarKind:
|
||||
ReplaceGlobalVarTypeIdsWithTypeNames(type_graph,
|
||||
static_cast<GlobalVarIR *>(lm));
|
||||
ReplaceGlobalVarTypeIdsWithTypeNames(
|
||||
type_graph, static_cast<GlobalVarIR *>(lm));
|
||||
break;
|
||||
case RecordTypeKind:
|
||||
ReplaceRecordTypeIRTypeIdsWithTypeNames(type_graph,
|
||||
static_cast<RecordTypeIR *>(lm));
|
||||
|
||||
ReplaceRecordTypeIRTypeIdsWithTypeNames(
|
||||
type_graph, static_cast<RecordTypeIR *>(lm));
|
||||
break;
|
||||
case EnumTypeKind:
|
||||
ReplaceEnumTypeIRTypeIdsWithTypeNames(type_graph,
|
||||
static_cast<EnumTypeIR *>(lm));
|
||||
ReplaceEnumTypeIRTypeIdsWithTypeNames(
|
||||
type_graph, static_cast<EnumTypeIR *>(lm));
|
||||
break;
|
||||
default:
|
||||
// This method should not be called on any other LinkableMessage
|
||||
@@ -165,8 +177,8 @@ void AbiDiffHelper::CompareEnumFields(
|
||||
|
||||
enum_type_diff_ir->SetFieldsRemoved(std::move(removed_fields));
|
||||
|
||||
std::vector<std::pair<
|
||||
const abi_util::EnumFieldIR *, const abi_util::EnumFieldIR *>> cf =
|
||||
std::vector<std::pair<const abi_util::EnumFieldIR *,
|
||||
const abi_util::EnumFieldIR *>> cf =
|
||||
abi_util::FindCommonElements(old_fields_map, new_fields_map);
|
||||
std::vector<abi_util::EnumFieldDiffIR> enum_field_diffs;
|
||||
for (auto &&common_fields : cf) {
|
||||
@@ -372,9 +384,8 @@ AbiDiffHelper::CompareRecordFields(
|
||||
abi_util::FindCommonElements(old_fields_map, new_fields_map);
|
||||
bool common_field_diff_exists = false;
|
||||
for (auto &&common_fields : cf) {
|
||||
auto diffed_field_ptr = CompareCommonRecordFields(common_fields.first,
|
||||
common_fields.second,
|
||||
type_queue, diff_kind);
|
||||
auto diffed_field_ptr = CompareCommonRecordFields(
|
||||
common_fields.first, common_fields.second, type_queue, diff_kind);
|
||||
if (!common_field_diff_exists &&
|
||||
(diffed_field_ptr.first &
|
||||
(DiffStatus::direct_diff | DiffStatus::indirect_diff))) {
|
||||
@@ -563,10 +574,9 @@ DiffStatus AbiDiffHelper::CompareRecordTypes(
|
||||
}
|
||||
auto &old_fields_dup = old_type->GetFields();
|
||||
auto &new_fields_dup = new_type->GetFields();
|
||||
auto field_status_and_diffs =
|
||||
CompareRecordFields(old_fields_dup, new_fields_dup,
|
||||
type_queue, diff_kind);
|
||||
// TODO: combine this with base class diffs as well.
|
||||
auto field_status_and_diffs = CompareRecordFields(
|
||||
old_fields_dup, new_fields_dup, type_queue, diff_kind);
|
||||
// TODO: Combine this with base class diffs as well.
|
||||
final_diff_status = final_diff_status | field_status_and_diffs.diff_status_;
|
||||
|
||||
std::vector<abi_util::CXXBaseSpecifierIR> old_bases = old_type->GetBases();
|
||||
@@ -611,17 +621,17 @@ DiffStatus AbiDiffHelper::CompareRecordTypes(
|
||||
llvm::errs() << "AddDiffMessage on record type failed\n";
|
||||
::exit(1);
|
||||
}
|
||||
} // Records cannot be 'extended' compatibly, without a certain amount of
|
||||
// risk.
|
||||
}
|
||||
|
||||
final_diff_status = final_diff_status |
|
||||
CompareTemplateInfo(old_type->GetTemplateElements(),
|
||||
new_type->GetTemplateElements(),
|
||||
type_queue, diff_kind);
|
||||
|
||||
return
|
||||
(final_diff_status &
|
||||
// Records cannot be 'extended' compatibly, without a certain amount of risk.
|
||||
return ((final_diff_status &
|
||||
(DiffStatus::direct_diff | DiffStatus::indirect_diff)) ?
|
||||
DiffStatus::indirect_diff : DiffStatus::no_diff;
|
||||
DiffStatus::indirect_diff : DiffStatus::no_diff);
|
||||
}
|
||||
|
||||
DiffStatus AbiDiffHelper::CompareLvalueReferenceTypes(
|
||||
@@ -681,11 +691,8 @@ DiffStatus AbiDiffHelper::CompareBuiltinTypes(
|
||||
const abi_util::BuiltinTypeIR *new_type) {
|
||||
// If the size, alignment and is_unsigned are the same, return no_diff
|
||||
// else return direct_diff.
|
||||
uint64_t old_signedness = old_type->IsUnsigned();
|
||||
uint64_t new_signedness = new_type->IsUnsigned();
|
||||
|
||||
if (!CompareSizeAndAlignment(old_type, new_type) ||
|
||||
old_signedness != new_signedness ||
|
||||
old_type->IsUnsigned() != new_type->IsUnsigned() ||
|
||||
old_type->IsIntegralType() != new_type->IsIntegralType()) {
|
||||
return DiffStatus::direct_diff;
|
||||
}
|
||||
@@ -739,7 +746,6 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
|
||||
static_cast<const abi_util::EnumTypeIR *>(old_type),
|
||||
static_cast<const abi_util::EnumTypeIR *>(new_type),
|
||||
type_queue, diff_kind);
|
||||
|
||||
}
|
||||
|
||||
if (kind == abi_util::LinkableMessageKind::LvalueReferenceTypeKind) {
|
||||
@@ -747,7 +753,6 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
|
||||
static_cast<const abi_util::LvalueReferenceTypeIR *>(old_type),
|
||||
static_cast<const abi_util::LvalueReferenceTypeIR *>(new_type),
|
||||
type_queue, diff_kind);
|
||||
|
||||
}
|
||||
|
||||
if (kind == abi_util::LinkableMessageKind::RvalueReferenceTypeKind) {
|
||||
@@ -792,15 +797,15 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
|
||||
const std::string &old_type_id, const std::string &new_type_id,
|
||||
std::deque<std::string> *type_queue,
|
||||
abi_util::DiffMessageIR::DiffKind diff_kind) {
|
||||
|
||||
// Check the map for type ids which have already been compared
|
||||
// These types have already been diffed, return without further comparison.
|
||||
if (!type_cache_->insert(old_type_id + new_type_id).second) {
|
||||
return DiffStatus::no_diff;
|
||||
} else {
|
||||
TypeQueueCheckAndPushBack(type_queue,
|
||||
ConvertTypeIdToString(old_types_,old_type_id));
|
||||
}
|
||||
|
||||
TypeQueueCheckAndPushBack(
|
||||
type_queue, ConvertTypeIdToString(old_types_,old_type_id));
|
||||
|
||||
AbiElementMap<const abi_util::TypeIR *>::const_iterator old_it =
|
||||
old_types_.find(old_type_id);
|
||||
AbiElementMap<const abi_util::TypeIR *>::const_iterator new_it =
|
||||
@@ -813,10 +818,9 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
|
||||
}
|
||||
return DiffStatus::no_diff;
|
||||
}
|
||||
abi_util::LinkableMessageKind old_kind =
|
||||
old_it->second->GetKind();
|
||||
abi_util::LinkableMessageKind new_kind =
|
||||
new_it->second->GetKind();
|
||||
|
||||
abi_util::LinkableMessageKind old_kind = old_it->second->GetKind();
|
||||
abi_util::LinkableMessageKind new_kind = new_it->second->GetKind();
|
||||
DiffStatus diff_status = DiffStatus::no_diff;
|
||||
if (old_kind != new_kind) {
|
||||
diff_status = CompareDistinctKindMessages(old_it->second, new_it->second);
|
||||
@@ -824,6 +828,7 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
|
||||
diff_status = CompareAndDumpTypeDiff(old_it->second , new_it->second ,
|
||||
old_kind, type_queue, diff_kind);
|
||||
}
|
||||
|
||||
TypeQueueCheckAndPop(type_queue);
|
||||
if (diff_policy_options_.consider_opaque_types_different_ &&
|
||||
diff_status == DiffStatus::opaque_diff &&
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include "header_abi_util.h"
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
#include <llvm/Support/Path.h>
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
@@ -25,16 +25,13 @@
|
||||
namespace abi_util {
|
||||
|
||||
static bool ShouldSkipFile(llvm::StringRef &file_name) {
|
||||
// Ignore swap files and hidden files / dirs. Do not recurse into them too.
|
||||
// We should also not look at source files. Many projects include source
|
||||
// files in their exports.
|
||||
if (file_name.empty() || file_name.startswith(".") ||
|
||||
// Ignore swap files, hidden files, and hidden directories. Do not recurse
|
||||
// into hidden directories either. We should also not look at source files.
|
||||
// Many projects include source files in their exports.
|
||||
return (file_name.empty() || file_name.startswith(".") ||
|
||||
file_name.endswith(".swp") || file_name.endswith(".swo") ||
|
||||
file_name.endswith("#") || file_name.endswith(".cpp") ||
|
||||
file_name.endswith(".cc") || file_name.endswith(".c")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
file_name.endswith(".cc") || file_name.endswith(".c"));
|
||||
}
|
||||
|
||||
std::string RealPath(const std::string &path) {
|
||||
@@ -67,6 +64,7 @@ bool CollectExportedHeaderSet(const std::string &dir_name,
|
||||
walker.no_push();
|
||||
continue;
|
||||
}
|
||||
|
||||
llvm::ErrorOr<llvm::sys::fs::basic_file_status> status = walker->status();
|
||||
if (!status) {
|
||||
llvm::errs() << "Failed to stat file : " << file_path << "\n";
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <abi_diff_helpers.h>
|
||||
#include <ir_representation.h>
|
||||
#include <ir_representation_json.h>
|
||||
#include <ir_representation_protobuf.h>
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include "abi_diff_helpers.h"
|
||||
#include "ir_representation_json.h"
|
||||
#include "ir_representation_protobuf.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
@@ -31,7 +32,6 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace abi_util {
|
||||
|
||||
using MergeStatus = TextFormatToIRReader::MergeStatus;
|
||||
@@ -75,8 +75,7 @@ TextFormatToIRReader::CreateTextFormatToIRReader(
|
||||
}
|
||||
}
|
||||
|
||||
void TextFormatToIRReader::AddToODRListMap(
|
||||
const std::string &key,
|
||||
void TextFormatToIRReader::AddToODRListMap(const std::string &key,
|
||||
const TypeIR *value) {
|
||||
auto map_it = odr_list_map_.find(key);
|
||||
if (map_it == odr_list_map_.end()) {
|
||||
@@ -113,9 +112,9 @@ MergeStatus TextFormatToIRReader::DoesUDTypeODRViolationExist(
|
||||
const TypeIR *ud_type, const TextFormatToIRReader &addend,
|
||||
const std::string ud_type_unique_id_and_source,
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map_) {
|
||||
// Per entry in the map :
|
||||
// Per entry in the map:
|
||||
// /-----------------------------------------------------------------------\
|
||||
// | UDType->UniqueTagId + UdType->source File => list(const UDTypeIR *)|
|
||||
// | UDType->UniqueTagId + UdType->source File => list(const UDTypeIR *) |
|
||||
// \-----------------------------------------------------------------------/
|
||||
auto it = odr_list_map_.find(ud_type_unique_id_and_source);
|
||||
if (it == odr_list_map_.end()) {
|
||||
@@ -132,17 +131,16 @@ MergeStatus TextFormatToIRReader::DoesUDTypeODRViolationExist(
|
||||
nullptr, local_to_global_type_id_map_);
|
||||
for (auto &contender_ud : it->second) {
|
||||
if (diff_helper.CompareAndDumpTypeDiff(contender_ud->GetSelfType(),
|
||||
ud_type->GetSelfType())
|
||||
== DiffStatus::no_diff) {
|
||||
local_to_global_type_id_map_->emplace(ud_type->GetSelfType(),
|
||||
MergeStatus(
|
||||
false,
|
||||
contender_ud->GetSelfType()));
|
||||
ud_type->GetSelfType()) ==
|
||||
DiffStatus::no_diff) {
|
||||
local_to_global_type_id_map_->emplace(
|
||||
ud_type->GetSelfType(),
|
||||
MergeStatus(false, contender_ud->GetSelfType()));
|
||||
return MergeStatus(false, contender_ud->GetSelfType());
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
llvm::errs() << "ODR violation detected for :" << ud_type->GetName() << "\n";
|
||||
llvm::errs() << "ODR violation detected for: " << ud_type->GetName() << "\n";
|
||||
#endif
|
||||
return MergeStatus(true, (*(it->second.begin()))->GetSelfType());
|
||||
}
|
||||
@@ -151,7 +149,7 @@ MergeStatus TextFormatToIRReader::IsTypeNodePresent(
|
||||
const TypeIR *addend_node, const TextFormatToIRReader &addend,
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map) {
|
||||
std::string unique_type_id;
|
||||
switch(addend_node->GetKind()) {
|
||||
switch (addend_node->GetKind()) {
|
||||
case RecordTypeKind:
|
||||
unique_type_id =
|
||||
GetODRListMapKey(static_cast<const RecordTypeIR *>(addend_node));
|
||||
@@ -193,6 +191,7 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternal(
|
||||
references_type->SetReferencedType(local_to_global_it->second.type_id_);
|
||||
return local_to_global_it->second;
|
||||
}
|
||||
|
||||
// If that did not go through, look at the addend's type_map_ and get the
|
||||
// TypeIR* and call MergeType on it.
|
||||
auto local_type_it = addend.type_graph_.find(referenced_type_id);
|
||||
@@ -200,12 +199,12 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternal(
|
||||
// We don't care about merge_status.was_newly_added since we wouldn't have
|
||||
// gotten this far if we weren't adding this.
|
||||
MergeStatus merge_status =
|
||||
MergeType(local_type_it->second, addend,
|
||||
local_to_global_type_id_map);
|
||||
MergeType(local_type_it->second, addend, local_to_global_type_id_map);
|
||||
const std::string &global_type_id = merge_status.type_id_;
|
||||
references_type->SetReferencedType(global_type_id);
|
||||
return merge_status;
|
||||
}
|
||||
|
||||
// The referenced type was hidden, so just set it to type-hidden.
|
||||
const std::string &hidden_type_id = AllocateNewTypeId();
|
||||
references_type->SetReferencedType(hidden_type_id);
|
||||
@@ -215,7 +214,7 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternal(
|
||||
void TextFormatToIRReader::MergeRecordFields(
|
||||
const TextFormatToIRReader &addend, RecordTypeIR *added_node,
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map) {
|
||||
for(auto &field : added_node->GetFields()) {
|
||||
for (auto &field : added_node->GetFields()) {
|
||||
MergeReferencingTypeInternal(addend, &field, local_to_global_type_id_map);
|
||||
}
|
||||
}
|
||||
@@ -223,7 +222,7 @@ void TextFormatToIRReader::MergeRecordFields(
|
||||
void TextFormatToIRReader::MergeRecordCXXBases(
|
||||
const TextFormatToIRReader &addend, RecordTypeIR *added_node,
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map) {
|
||||
for(auto &base : added_node->GetBases()) {
|
||||
for (auto &base : added_node->GetBases()) {
|
||||
MergeReferencingTypeInternal(addend, &base, local_to_global_type_id_map);
|
||||
}
|
||||
}
|
||||
@@ -231,9 +230,9 @@ void TextFormatToIRReader::MergeRecordCXXBases(
|
||||
void TextFormatToIRReader::MergeRecordTemplateElements(
|
||||
const TextFormatToIRReader &addend, RecordTypeIR *added_node,
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map) {
|
||||
for(auto &template_element : added_node->GetTemplateElements()) {
|
||||
MergeReferencingTypeInternal(addend, &template_element,
|
||||
local_to_global_type_id_map);
|
||||
for (auto &template_element : added_node->GetTemplateElements()) {
|
||||
MergeReferencingTypeInternal(
|
||||
addend, &template_element, local_to_global_type_id_map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,18 +334,17 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternalAndUpdateParent(
|
||||
MergeStatus merge_status;
|
||||
uint64_t old_max_type_id = max_type_id_;
|
||||
// Create copy of addend_node
|
||||
T added_node =
|
||||
*(addend_node);
|
||||
T added_node = *(addend_node);
|
||||
added_node.SetSelfType(updated_self_type_id);
|
||||
// The merge status returned is the merge status of the referenced type.
|
||||
merge_status = MergeReferencingTypeInternal(addend, &added_node,
|
||||
local_to_global_type_id_map);
|
||||
if (merge_status.was_newly_added_) {
|
||||
// Emplace to map (type-referenced -> Referencing type)
|
||||
AddToMapAndTypeGraph(std::move(added_node), parent_map,
|
||||
&type_graph_);
|
||||
AddToMapAndTypeGraph(std::move(added_node), parent_map, &type_graph_);
|
||||
return MergeStatus(true, updated_self_type_id);
|
||||
}
|
||||
|
||||
// The type that the added_node references was not newly added to the parent
|
||||
// graph. However, we still might need to add the added_node to the parent
|
||||
// graph, since for the particular 'Kind' of the added_node, it may not be
|
||||
@@ -359,6 +357,7 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternalAndUpdateParent(
|
||||
// already have it's self_type and referenced_type fields fixed up.
|
||||
// We maintain a rollback id to have contiguous type ids.
|
||||
max_type_id_ = old_max_type_id;
|
||||
|
||||
// Try finding the referenced_type is referred to by any referencing type
|
||||
// of the same kind in the parent graph. It is safe to call this on the
|
||||
// added_node, since the referenced_type in the added_node would have been
|
||||
@@ -374,6 +373,7 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternalAndUpdateParent(
|
||||
merge_status = MergeStatus(true, updated_self_type_id);
|
||||
return merge_status;
|
||||
}
|
||||
|
||||
// Update local_to_global_type_id map's MergeStatus.was_newly_added value for
|
||||
// this key with false since this was node was not newly added.
|
||||
// We never remove anything from the local_to_global_type_id_map, what's
|
||||
@@ -382,8 +382,8 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternalAndUpdateParent(
|
||||
// in the parent map which refers to the added_node's modified
|
||||
// referenced_type.
|
||||
merge_status = MergeStatus(false, it->second.GetSelfType());
|
||||
(*local_to_global_type_id_map)[addend_node->GetSelfType()] =
|
||||
merge_status;
|
||||
(*local_to_global_type_id_map)[addend_node->GetSelfType()] = merge_status;
|
||||
|
||||
return merge_status;
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ MergeStatus TextFormatToIRReader::MergeGenericReferringType(
|
||||
MergeStatus TextFormatToIRReader::MergeTypeInternal(
|
||||
const TypeIR *addend_node, const TextFormatToIRReader &addend,
|
||||
AbiElementMap<MergeStatus> *local_to_global_type_id_map) {
|
||||
switch(addend_node->GetKind()) {
|
||||
switch (addend_node->GetKind()) {
|
||||
case BuiltinTypeKind:
|
||||
return IsBuiltinTypeNodePresent(
|
||||
static_cast<const BuiltinTypeIR *>(addend_node), addend,
|
||||
@@ -469,19 +469,18 @@ MergeStatus TextFormatToIRReader::MergeType(
|
||||
// Check if the addend type is already in the parent graph. Since we're
|
||||
// going to traverse all the dependencies add whichever ones are not in the
|
||||
// parent graph. This does not add the node itself though.
|
||||
auto type_it =
|
||||
local_to_global_type_id_map->find(addend_node->GetSelfType());
|
||||
auto type_it = local_to_global_type_id_map->find(addend_node->GetSelfType());
|
||||
if (type_it != local_to_global_type_id_map->end()) {
|
||||
return type_it->second;
|
||||
}
|
||||
|
||||
MergeStatus merge_status = IsTypeNodePresent(addend_node, addend,
|
||||
local_to_global_type_id_map);
|
||||
MergeStatus merge_status = IsTypeNodePresent(
|
||||
addend_node, addend, local_to_global_type_id_map);
|
||||
if (!merge_status.was_newly_added_) {
|
||||
return merge_status;
|
||||
}
|
||||
merge_status = MergeTypeInternal(addend_node, addend,
|
||||
local_to_global_type_id_map);
|
||||
merge_status = MergeTypeInternal(
|
||||
addend_node, addend, local_to_global_type_id_map);
|
||||
return merge_status;
|
||||
}
|
||||
|
||||
@@ -585,5 +584,5 @@ bool TextFormatToIRReader::IsLinkableMessageInExportedHeaders(
|
||||
return exported_headers_->find(linkable_message->GetSourceFile()) !=
|
||||
exported_headers_->end();
|
||||
}
|
||||
} // namespace abi_util
|
||||
|
||||
} // namespace abi_util
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <ir_representation_json.h>
|
||||
#include "ir_representation_json.h"
|
||||
|
||||
#include <json/reader.h>
|
||||
#include <json/writer.h>
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
#include <cstdlib>
|
||||
@@ -934,4 +935,5 @@ void JsonToIRReader::ReadElfObjects(const JsonObjectRef &tu) {
|
||||
elf_objects_.insert({elf_object_ir.GetName(), std::move(elf_object_ir)});
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace abi_util
|
||||
|
||||
@@ -12,20 +12,19 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <ir_representation_protobuf.h>
|
||||
#include "ir_representation_protobuf.h"
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace abi_util {
|
||||
|
||||
void ProtobufTextFormatToIRReader::ReadTypeInfo(
|
||||
const abi_dump::BasicNamedAndTypedDecl &type_info,
|
||||
TypeIR *typep) {
|
||||
const abi_dump::BasicNamedAndTypedDecl &type_info, TypeIR *typep) {
|
||||
typep->SetLinkerSetKey(type_info.linker_set_key());
|
||||
typep->SetName(type_info.name());
|
||||
typep->SetSourceFile(type_info.source_file());
|
||||
@@ -72,7 +71,7 @@ TemplateInfoIR ProtobufTextFormatToIRReader::TemplateInfoProtobufToIR(
|
||||
return template_info_ir;
|
||||
}
|
||||
|
||||
template< typename T>
|
||||
template <typename T>
|
||||
static void SetupCFunctionLikeIR(const T &cfunction_like_protobuf,
|
||||
CFunctionLikeIR *cfunction_like_ir) {
|
||||
cfunction_like_ir->SetReturnType(cfunction_like_protobuf.return_type());
|
||||
@@ -387,8 +386,7 @@ bool IRToProtobufConverter::AddTemplateInformation(
|
||||
}
|
||||
|
||||
bool IRToProtobufConverter::AddTypeInfo(
|
||||
abi_dump::BasicNamedAndTypedDecl *type_info,
|
||||
const TypeIR *typep) {
|
||||
abi_dump::BasicNamedAndTypedDecl *type_info, const TypeIR *typep) {
|
||||
if (!type_info || !typep) {
|
||||
llvm::errs() << "Typeinfo not valid\n";
|
||||
return false;
|
||||
@@ -856,7 +854,7 @@ abi_diff::RecordTypeDiff IRDiffToProtobufConverter::ConvertRecordTypeDiffIR(
|
||||
// If base specifiers differ.
|
||||
const CXXBaseSpecifierDiffIR *base_specifier_diff_ir =
|
||||
record_type_diff_ir->GetBaseSpecifiers();
|
||||
if ( base_specifier_diff_ir != nullptr) {
|
||||
if (base_specifier_diff_ir != nullptr) {
|
||||
abi_diff::CXXBaseSpecifierDiff *base_specifier_diff_protobuf =
|
||||
record_type_diff_protobuf.mutable_bases_diff();
|
||||
if (!AddBaseSpecifierDiffs(base_specifier_diff_protobuf,
|
||||
@@ -970,11 +968,9 @@ abi_diff::FunctionDeclDiff IRDiffToProtobufConverter::ConvertFunctionDiffIR(
|
||||
llvm::errs() << "Function diff could not be added\n";
|
||||
::exit(1);
|
||||
}
|
||||
*old_function =
|
||||
IRToProtobufConverter::ConvertFunctionIR(
|
||||
*old_function = IRToProtobufConverter::ConvertFunctionIR(
|
||||
function_diff_ir->GetOldFunction());
|
||||
*new_function =
|
||||
IRToProtobufConverter::ConvertFunctionIR(
|
||||
*new_function = IRToProtobufConverter::ConvertFunctionIR(
|
||||
function_diff_ir->GetNewFunction());
|
||||
return function_diff;
|
||||
}
|
||||
@@ -1195,7 +1191,7 @@ CompatibilityStatusIR ProtobufIRDiffDumper::GetCompatibilityStatusIR() {
|
||||
combined_status | CompatibilityStatusIR::UnreferencedChanges;
|
||||
}
|
||||
|
||||
if(diff_tu_->removed_elf_functions().size() != 0 ||
|
||||
if (diff_tu_->removed_elf_functions().size() != 0 ||
|
||||
diff_tu_->removed_elf_objects().size() != 0) {
|
||||
combined_status = combined_status | CompatibilityStatusIR::ElfIncompatible;
|
||||
}
|
||||
@@ -1208,38 +1204,33 @@ void ProtobufIRDiffDumper::AddCompatibilityStatusIR(
|
||||
diff_tu_->set_compatibility_status(CompatibilityStatusIRToProtobuf(status));
|
||||
}
|
||||
|
||||
bool ProtobufIRDiffDumper::AddDiffMessageIR(
|
||||
const DiffMessageIR *message,
|
||||
bool ProtobufIRDiffDumper::AddDiffMessageIR(const DiffMessageIR *message,
|
||||
const std::string &type_stack,
|
||||
DiffKind diff_kind) {
|
||||
switch (message->Kind()) {
|
||||
case RecordTypeKind:
|
||||
return AddRecordTypeDiffIR(
|
||||
static_cast<const RecordTypeDiffIR *>(message),
|
||||
type_stack, diff_kind);
|
||||
static_cast<const RecordTypeDiffIR *>(message), type_stack,
|
||||
diff_kind);
|
||||
case EnumTypeKind:
|
||||
return AddEnumTypeDiffIR(
|
||||
static_cast<const EnumTypeDiffIR *>(message),
|
||||
type_stack, diff_kind);
|
||||
static_cast<const EnumTypeDiffIR *>(message), type_stack, diff_kind);
|
||||
case GlobalVarKind:
|
||||
return AddGlobalVarDiffIR(
|
||||
static_cast<const GlobalVarDiffIR*>(message),
|
||||
type_stack, diff_kind);
|
||||
static_cast<const GlobalVarDiffIR*>(message), type_stack, diff_kind);
|
||||
case FunctionKind:
|
||||
return AddFunctionDiffIR(
|
||||
static_cast<const FunctionDiffIR*>(message),
|
||||
type_stack, diff_kind);
|
||||
static_cast<const FunctionDiffIR*>(message), type_stack, diff_kind);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
llvm::errs() << "Dump Diff attempted on something not a user defined type" <<
|
||||
"/ function / global variable\n";
|
||||
llvm::errs() << "Dump Diff attempted on something not a user defined type / "
|
||||
<< "function / global variable\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProtobufIRDiffDumper::AddLinkableMessageIR(
|
||||
const LinkableMessageIR *message,
|
||||
DiffKind diff_kind) {
|
||||
const LinkableMessageIR *message, DiffKind diff_kind) {
|
||||
switch (message->GetKind()) {
|
||||
case RecordTypeKind:
|
||||
return AddLoneRecordTypeDiffIR(
|
||||
@@ -1256,12 +1247,12 @@ bool ProtobufIRDiffDumper::AddLinkableMessageIR(
|
||||
default:
|
||||
break;
|
||||
}
|
||||
llvm::errs() << "Dump Diff attempted on something not a user defined type" <<
|
||||
"/ function / global variable\n";
|
||||
llvm::errs() << "Dump Diff attempted on something not a user defined type / "
|
||||
<< "function / global variable\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProtobufIRDiffDumper::AddElfSymbolMessageIR (const ElfSymbolIR *elf_symbol,
|
||||
bool ProtobufIRDiffDumper::AddElfSymbolMessageIR(const ElfSymbolIR *elf_symbol,
|
||||
DiffKind diff_kind) {
|
||||
switch (elf_symbol->GetKind()) {
|
||||
case ElfSymbolIR::ElfFunctionKind:
|
||||
@@ -1280,7 +1271,7 @@ bool ProtobufIRDiffDumper::AddElfSymbolMessageIR (const ElfSymbolIR *elf_symbol,
|
||||
bool ProtobufIRDiffDumper::AddElfFunctionIR(
|
||||
const ElfFunctionIR *elf_function_ir, DiffKind diff_kind) {
|
||||
abi_dump::ElfFunction *added_elf_function = nullptr;
|
||||
switch(diff_kind) {
|
||||
switch (diff_kind) {
|
||||
case DiffKind::Removed:
|
||||
added_elf_function = diff_tu_->add_removed_elf_functions();
|
||||
break;
|
||||
@@ -1302,7 +1293,7 @@ bool ProtobufIRDiffDumper::AddElfFunctionIR(
|
||||
bool ProtobufIRDiffDumper::AddElfObjectIR(
|
||||
const ElfObjectIR *elf_object_ir, DiffKind diff_kind) {
|
||||
abi_dump::ElfObject *added_elf_object = nullptr;
|
||||
switch(diff_kind) {
|
||||
switch (diff_kind) {
|
||||
case DiffKind::Removed:
|
||||
added_elf_object = diff_tu_->add_removed_elf_objects();
|
||||
break;
|
||||
@@ -1322,8 +1313,7 @@ bool ProtobufIRDiffDumper::AddElfObjectIR(
|
||||
}
|
||||
|
||||
bool ProtobufIRDiffDumper::AddLoneRecordTypeDiffIR(
|
||||
const RecordTypeIR *record_type_ir,
|
||||
DiffKind diff_kind) {
|
||||
const RecordTypeIR *record_type_ir, DiffKind diff_kind) {
|
||||
abi_dump::RecordType *added_record_type = nullptr;
|
||||
switch (diff_kind) {
|
||||
case DiffKind::Removed:
|
||||
@@ -1348,8 +1338,7 @@ bool ProtobufIRDiffDumper::AddLoneRecordTypeDiffIR(
|
||||
}
|
||||
|
||||
bool ProtobufIRDiffDumper::AddLoneFunctionDiffIR(
|
||||
const FunctionIR *function_ir,
|
||||
DiffKind diff_kind) {
|
||||
const FunctionIR *function_ir, DiffKind diff_kind) {
|
||||
abi_dump::FunctionDecl *added_function = nullptr;
|
||||
switch (diff_kind) {
|
||||
case DiffKind::Removed:
|
||||
@@ -1409,8 +1398,7 @@ bool ProtobufIRDiffDumper::AddLoneGlobalVarDiffIR(
|
||||
}
|
||||
|
||||
bool ProtobufIRDiffDumper::AddRecordTypeDiffIR(
|
||||
const RecordTypeDiffIR *record_diff_ir,
|
||||
const std::string &type_stack,
|
||||
const RecordTypeDiffIR *record_diff_ir, const std::string &type_stack,
|
||||
DiffKind diff_kind) {
|
||||
abi_diff::RecordTypeDiff *added_record_type_diff = nullptr;
|
||||
switch (diff_kind) {
|
||||
@@ -1482,8 +1470,7 @@ bool ProtobufIRDiffDumper::AddEnumTypeDiffIR(const EnumTypeDiffIR *enum_diff_ir,
|
||||
}
|
||||
|
||||
bool ProtobufIRDiffDumper::AddGlobalVarDiffIR(
|
||||
const GlobalVarDiffIR *global_var_diff_ir,
|
||||
const std::string &type_stack,
|
||||
const GlobalVarDiffIR *global_var_diff_ir, const std::string &type_stack,
|
||||
DiffKind diff_kind) {
|
||||
abi_diff::GlobalVarDeclDiff *added_global_var_diff =
|
||||
diff_tu_->add_global_var_diffs();
|
||||
|
||||
@@ -12,31 +12,31 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include <ir_representation.h>
|
||||
#include "so_file_parser.h"
|
||||
|
||||
#include "ir_representation.h"
|
||||
|
||||
#include <llvm/Object/ELFObjectFile.h>
|
||||
#include <llvm/Object/Binary.h>
|
||||
#include <llvm/Object/ELFObjectFile.h>
|
||||
#include <llvm/Object/ELFTypes.h>
|
||||
#include <llvm/Object/SymbolSize.h>
|
||||
|
||||
using llvm::object::ELF32LEObjectFile;
|
||||
using llvm::object::ELF32BEObjectFile;
|
||||
using llvm::object::ELF64LEObjectFile;
|
||||
using llvm::object::ELF64BEObjectFile;
|
||||
using llvm::dyn_cast;
|
||||
using llvm::ELF::STB_GLOBAL;
|
||||
using llvm::ELF::STB_WEAK;
|
||||
using llvm::ELF::STV_DEFAULT;
|
||||
using llvm::ELF::STV_PROTECTED;
|
||||
using llvm::ELF::STB_WEAK;
|
||||
using llvm::ELF::STB_GLOBAL;
|
||||
using llvm::dyn_cast;
|
||||
using llvm::object::ELF32BEObjectFile;
|
||||
using llvm::object::ELF32LEObjectFile;
|
||||
using llvm::object::ELF64BEObjectFile;
|
||||
using llvm::object::ELF64LEObjectFile;
|
||||
|
||||
namespace abi_util {
|
||||
|
||||
template <typename T>
|
||||
static inline T UnWrap(llvm::Expected<T> ValueOrError) {
|
||||
if (!ValueOrError) {
|
||||
llvm::errs() << "\nError: "
|
||||
<< llvm::toString(ValueOrError.takeError())
|
||||
llvm::errs() << "\nError: " << llvm::toString(ValueOrError.takeError())
|
||||
<< ".\n";
|
||||
llvm::errs().flush();
|
||||
exit(1);
|
||||
@@ -79,8 +79,7 @@ template<typename T>
|
||||
void ELFSoFileParser<T>::GetSymbols() {
|
||||
assert(obj_ != nullptr);
|
||||
for (auto symbol_it : obj_->getDynamicSymbolIterators()) {
|
||||
const Elf_Sym *elf_sym =
|
||||
obj_->getSymbol(symbol_it.getRawDataRefImpl());
|
||||
const Elf_Sym *elf_sym = obj_->getSymbol(symbol_it.getRawDataRefImpl());
|
||||
assert (elf_sym != nullptr);
|
||||
if (!IsSymbolExported(elf_sym) || elf_sym->isUndefined()) {
|
||||
continue;
|
||||
@@ -129,4 +128,3 @@ std::unique_ptr<SoFileParser> SoFileParser::Create(
|
||||
}
|
||||
|
||||
} // namespace abi_util
|
||||
|
||||
|
||||
@@ -12,27 +12,27 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include "version_script_parser.h"
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
#include <llvm/Support/Path.h>
|
||||
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace abi_util {
|
||||
|
||||
#define FUTURE_API 10000
|
||||
|
||||
std::unordered_set<std::string> AllArches({"arm", "arm64", "x86", "x86_64",
|
||||
"mips", "mips64"});
|
||||
std::unordered_set<std::string> AllArches({
|
||||
"arm", "arm64", "x86", "x86_64", "mips", "mips64"});
|
||||
|
||||
static bool StringContains(const std::string &line,
|
||||
const std::string &substring) {
|
||||
@@ -53,8 +53,8 @@ static bool LineSatisfiesArch(const std::string &line,
|
||||
|
||||
VersionScriptParser::VersionScriptParser(const std::string &version_script,
|
||||
const std::string &arch,
|
||||
const std::string &api) :
|
||||
version_script_(version_script), arch_(arch), api_(ApiStrToInt(api)) { }
|
||||
const std::string &api)
|
||||
: version_script_(version_script), arch_(arch), api_(ApiStrToInt(api)) {}
|
||||
|
||||
int VersionScriptParser::ApiStrToInt(const std::string &api) {
|
||||
// Follow what build/soong/cc/gen_stub_libs.py does.
|
||||
@@ -90,7 +90,7 @@ bool VersionScriptParser::SymbolInArchAndApiVersion(const std::string &line,
|
||||
}
|
||||
// If the arch specific tag / version specific tag was found and the api level
|
||||
// required was greater than the api level offered.
|
||||
return (matched_api <=0 || api >= matched_api);
|
||||
return (matched_api <= 0 || api >= matched_api);
|
||||
}
|
||||
|
||||
bool VersionScriptParser::SymbolExported(const std::string &line,
|
||||
@@ -121,7 +121,7 @@ void VersionScriptParser::AddToFunctions(std::string &symbol) {
|
||||
}
|
||||
|
||||
bool VersionScriptParser::ParseSymbolLine(const std::string &line) {
|
||||
//The symbol lies before the ; and the tags are after ;
|
||||
// The symbol lies before the ';' and the tags are after ';'
|
||||
std::string::size_type pos = line.find(";");
|
||||
if (pos == std::string::npos) {
|
||||
llvm::errs() << "Couldn't find end of symbol" << line <<"\n";
|
||||
@@ -194,21 +194,21 @@ bool VersionScriptParser::Parse() {
|
||||
llvm::errs() << "Failed to open version script file\n";
|
||||
return false;
|
||||
}
|
||||
std::string line = "";
|
||||
|
||||
std::string line;
|
||||
while (std::getline(symbol_ifstream, line)) {
|
||||
// Skip comment lines.
|
||||
if (line.c_str()[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
if (StringContains(line, "{")) {
|
||||
|
||||
if ((StringContains(line, "PRIVATE"))) {
|
||||
continue;
|
||||
}
|
||||
ParseInnerBlock(symbol_ifstream);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "header_abi_util.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#pragma clang diagnostic ignored "-Wnested-anon-types"
|
||||
@@ -19,17 +21,15 @@
|
||||
#include "abi_diff.pb.h"
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#include <header_abi_util.h>
|
||||
#include <google/protobuf/text_format.h>
|
||||
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
||||
|
||||
#include <llvm/Support/CommandLine.h>
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
#include <google/protobuf/text_format.h>
|
||||
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
||||
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ struct CPPHello : private HelloAgain, public ByeAgain<float_type> {
|
||||
const int cpp_foo;
|
||||
cfloat_type cpp_bar;
|
||||
virtual int again() { return 0; }
|
||||
CPPHello() : cpp_foo(20), cpp_bar(1.234) { }
|
||||
CPPHello() : cpp_foo(20), cpp_bar(1.234) {}
|
||||
enum Bla{BLA = 1};
|
||||
int test_enum() {return CPPHello::BLA;}
|
||||
};
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
public:
|
||||
StackNode(T t, StackNode* next = nullptr)
|
||||
: value_(static_cast<T&&>(t)),
|
||||
next_(next) { }
|
||||
next_(next) {}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
StackNode<T>* head_;
|
||||
|
||||
public:
|
||||
Stack() : head_(nullptr) { }
|
||||
Stack() : head_(nullptr) {}
|
||||
|
||||
void push(T t) {
|
||||
head_ = new StackNode<T>(static_cast<T&&>(t), head_);
|
||||
|
||||
@@ -6,4 +6,4 @@ class HiddenBase {
|
||||
float seek;
|
||||
};
|
||||
|
||||
#endif //EXAMPLE3_H
|
||||
#endif // EXAMPLE3_H_
|
||||
|
||||
@@ -12,7 +12,7 @@ struct UnusedStruct {
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo(int *a, int *b) : a_(a), b_(b) { }
|
||||
Foo(int *a, int *b) : a_(a), b_(b) {}
|
||||
private:
|
||||
int *a_;
|
||||
int *b_;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include<c_include.h>
|
||||
#include <c_include.h>
|
||||
|
||||
void CFunction(struct Cstruct **cstruct) {
|
||||
if (cstruct) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include<abstract_class.h>
|
||||
#include<additional_odr.h>
|
||||
#include <abstract_class.h>
|
||||
#include <additional_odr.h>
|
||||
|
||||
SuperSpeaker *SuperSpeaker::CreateSuperSpeaker(int id) {
|
||||
// :)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <high_volume_speaker.h>
|
||||
|
||||
void HighVolumeSpeaker::Speak() { }
|
||||
void HighVolumeSpeaker::Speak() {}
|
||||
|
||||
HighVolumeSpeaker *HighVolumeSpeaker::BadPractice(BP_PARAMETER_TYPE id) {
|
||||
return nullptr;
|
||||
|
||||
@@ -51,9 +51,8 @@ class SuperSpeaker {
|
||||
public:
|
||||
VIRTUAL_FUNCTIONS
|
||||
Volume SpeakLoud();
|
||||
void SpeakLoudest() { };
|
||||
|
||||
virtual ~SuperSpeaker() { }
|
||||
void SpeakLoudest() {}
|
||||
virtual ~SuperSpeaker() {}
|
||||
private:
|
||||
#if GOLDEN_CHANGE_MEMBER_NAME_SAME_OFFSET
|
||||
int mSpeakderId_;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <low_volume_speaker.h>
|
||||
|
||||
void LowVolumeSpeaker::Speak() { }
|
||||
void LowVolumeSpeaker::Speak() {}
|
||||
|
||||
LISTEN_RETURN_TYPE LowVolumeSpeaker::Listen() { LISTEN_RETURN_STATEMENT }
|
||||
|
||||
#ifdef ADD_UNEXPORTED_ELF_SYMBOL
|
||||
|
||||
@@ -13,16 +13,19 @@ from utils import run_header_abi_linker
|
||||
from utils import TARGET_ARCHS
|
||||
from utils import SOURCE_ABI_DUMP_EXT
|
||||
|
||||
|
||||
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
INPUT_DIR = os.path.join(SCRIPT_DIR, 'input')
|
||||
EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected')
|
||||
REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps')
|
||||
ARCH_TARGET_CFLAGS = {'arm': ['-target', 'arm-linux-androideabi'],
|
||||
ARCH_TARGET_CFLAGS = {
|
||||
'arm': ['-target', 'arm-linux-androideabi'],
|
||||
'arm64': ['-target', 'aarch64-linux-android'],
|
||||
'x86' : ['-target', 'i386-linux-androideabi'],
|
||||
'x86_64' : ['-target', 'x86_64-linux-android'],
|
||||
'mips' : ['-target', 'mips-linux-androideabi'],
|
||||
'mips64' : ['-target', 'mips64-linux-android'],}
|
||||
'x86': ['-target', 'i386-linux-androideabi'],
|
||||
'x86_64': ['-target', 'x86_64-linux-android'],
|
||||
'mips': ['-target', 'mips-linux-androideabi'],
|
||||
'mips64': ['-target', 'mips64-linux-android'],
|
||||
}
|
||||
|
||||
def relative_to_abs_path(relative_path):
|
||||
return os.path.join(SCRIPT_DIR, relative_path)
|
||||
@@ -127,384 +130,412 @@ class Module(object):
|
||||
|
||||
TEST_MODULES = [
|
||||
Module(
|
||||
name = 'libc_and_cpp',
|
||||
srcs = ['integration/c_and_cpp/source1.cpp',
|
||||
name='libc_and_cpp',
|
||||
srcs=[
|
||||
'integration/c_and_cpp/source1.cpp',
|
||||
'integration/c_and_cpp/source2.c',
|
||||
],
|
||||
version_script = 'integration/c_and_cpp/map.txt',
|
||||
export_include_dirs = ['integration/c_and_cpp/include'],
|
||||
cflags = [],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/c_and_cpp/map.txt',
|
||||
export_include_dirs=['integration/c_and_cpp/include'],
|
||||
cflags=[],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libc_and_cpp_with_opaque_ptr_a',
|
||||
srcs = ['integration/c_and_cpp/source1.cpp',
|
||||
name='libc_and_cpp_with_opaque_ptr_a',
|
||||
srcs=[
|
||||
'integration/c_and_cpp/source1.cpp',
|
||||
'integration/c_and_cpp/source2.c',
|
||||
],
|
||||
version_script = 'integration/c_and_cpp/map.txt',
|
||||
export_include_dirs = ['integration/c_and_cpp/include'],
|
||||
cflags = ['-DOPAQUE_STRUCT_A=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/c_and_cpp/map.txt',
|
||||
export_include_dirs=['integration/c_and_cpp/include'],
|
||||
cflags=['-DOPAQUE_STRUCT_A=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libc_and_cpp_with_opaque_ptr_b',
|
||||
srcs = ['integration/c_and_cpp/source1.cpp',
|
||||
name='libc_and_cpp_with_opaque_ptr_b',
|
||||
srcs=[
|
||||
'integration/c_and_cpp/source1.cpp',
|
||||
'integration/c_and_cpp/source2.c',
|
||||
],
|
||||
version_script = 'integration/c_and_cpp/map.txt',
|
||||
export_include_dirs = ['integration/c_and_cpp/include'],
|
||||
cflags = ['-DOPAQUE_STRUCT_B=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/c_and_cpp/map.txt',
|
||||
export_include_dirs=['integration/c_and_cpp/include'],
|
||||
cflags=['-DOPAQUE_STRUCT_B=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libc_and_cpp_with_unused_struct',
|
||||
srcs = ['integration/c_and_cpp/source1.cpp',
|
||||
name='libc_and_cpp_with_unused_struct',
|
||||
srcs=[
|
||||
'integration/c_and_cpp/source1.cpp',
|
||||
'integration/c_and_cpp/source2.c',
|
||||
],
|
||||
version_script = 'integration/c_and_cpp/map.txt',
|
||||
export_include_dirs = ['integration/c_and_cpp/include'],
|
||||
cflags = ['-DINCLUDE_UNUSED_STRUCTS=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/c_and_cpp/map.txt',
|
||||
export_include_dirs=['integration/c_and_cpp/include'],
|
||||
cflags=['-DINCLUDE_UNUSED_STRUCTS=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libc_and_cpp_with_unused_cstruct',
|
||||
srcs = ['integration/c_and_cpp/source1.cpp',
|
||||
name='libc_and_cpp_with_unused_cstruct',
|
||||
srcs=[
|
||||
'integration/c_and_cpp/source1.cpp',
|
||||
'integration/c_and_cpp/source2.c',
|
||||
],
|
||||
version_script = 'integration/c_and_cpp/map.txt',
|
||||
export_include_dirs = ['integration/c_and_cpp/include'],
|
||||
cflags = ['-DINCLUDE_UNUSED_STRUCTS=1', '-DMAKE_UNUSED_STRUCT_C=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/c_and_cpp/map.txt',
|
||||
export_include_dirs=['integration/c_and_cpp/include'],
|
||||
cflags=['-DINCLUDE_UNUSED_STRUCTS=1', '-DMAKE_UNUSED_STRUCT_C=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = [],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=[],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_odr',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_odr',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DTEST_ODR'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DTEST_ODR'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_add_function',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_add_function',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map_add_function.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_ADD_FUNCTION=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map_add_function.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_ADD_FUNCTION=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_add_function_and_unexported_elf',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_add_function_and_unexported_elf',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = \
|
||||
'integration/cpp/gold/map_add_function_elf_symbol.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_ADD_FUNCTION=1', '-DADD_UNEXPORTED_ELF_SYMBOL'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map_add_function_elf_symbol.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_ADD_FUNCTION=1', '-DADD_UNEXPORTED_ELF_SYMBOL'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_change_function_access',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_change_function_access',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_CHANGE_FUNCTION_ACCESS=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_CHANGE_FUNCTION_ACCESS=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_add_global_variable',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_add_global_variable',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map_added_globvar.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_ADD_GLOBVAR=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map_added_globvar.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_ADD_GLOBVAR=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_add_global_variable_private',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_add_global_variable_private',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map_added_globvar.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_ADD_GLOBVAR=1', '-DGOLDEN_ADD_GLOBVAR_PRIVATE'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map_added_globvar.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_ADD_GLOBVAR=1', '-DGOLDEN_ADD_GLOBVAR_PRIVATE'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_return_type_diff',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_return_type_diff',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_RETURN_TYPE_DIFF=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_RETURN_TYPE_DIFF=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_parameter_type_diff',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_parameter_type_diff',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map_parameter_type_diff.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_PARAMETER_TYPE_DIFF=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map_parameter_type_diff.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_PARAMETER_TYPE_DIFF=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_vtable_diff',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_vtable_diff',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_VTABLE_DIFF=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_VTABLE_DIFF=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_member_diff',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_member_diff',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_MEMBER_DIFF=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_MEMBER_DIFF=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_member_fake_diff',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_member_fake_diff',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_MEMBER_FAKE_DIFF=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_MEMBER_FAKE_DIFF=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_member_cv_diff',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_member_cv_diff',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_MEMBER_CV_DIFF=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_MEMBER_CV_DIFF=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_change_member_access',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_change_member_access',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_CHANGE_MEMBER_ACCESS=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_CHANGE_MEMBER_ACCESS=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_member_integral_type_diff',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_member_integral_type_diff',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_MEMBER_INTEGRAL_TYPE_DIFF=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_MEMBER_INTEGRAL_TYPE_DIFF=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_enum_diff',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_enum_diff',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_ENUM_DIFF=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_ENUM_DIFF=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_enum_extended',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_enum_extended',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_ENUM_EXTENSION=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_ENUM_EXTENSION=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_unreferenced_elf_symbol_removed',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_unreferenced_elf_symbol_removed',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map_elf_symbol_removed.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = [],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map_elf_symbol_removed.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=[],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libreproducability',
|
||||
srcs = ['integration/c_and_cpp/reproducability.c',
|
||||
],
|
||||
version_script = 'integration/c_and_cpp/repro_map.txt',
|
||||
export_include_dirs = ['integration/c_and_cpp/include'],
|
||||
cflags = [],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
name='libreproducability',
|
||||
srcs=['integration/c_and_cpp/reproducability.c'],
|
||||
version_script='integration/c_and_cpp/repro_map.txt',
|
||||
export_include_dirs=['integration/c_and_cpp/include'],
|
||||
cflags=[],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_member_name_changed',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_member_name_changed',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_CHANGE_MEMBER_NAME_SAME_OFFSET=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_CHANGE_MEMBER_NAME_SAME_OFFSET=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_function_pointer',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_function_pointer',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_FUNCTION_POINTER=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_FUNCTION_POINTER=1'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_function_pointer_parameter_added',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_function_pointer_parameter_added',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_FUNCTION_POINTER_ADD_PARAM=1',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_FUNCTION_POINTER_ADD_PARAM=1',
|
||||
'-DGOLDEN_FUNCTION_POINTER=1'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_internal_public_struct',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_internal_public_struct',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_WITH_INTERNAL_STRUCT',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_WITH_INTERNAL_STRUCT',
|
||||
'-DGOLDEN_WITH_PUBLIC_INTERNAL_STRUCT'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_internal_private_struct',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_internal_private_struct',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_WITH_INTERNAL_STRUCT'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_WITH_INTERNAL_STRUCT'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_inheritance_type_changed',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_inheritance_type_changed',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = ['-DGOLDEN_CHANGE_INHERITANCE_TYPE'],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=['-DGOLDEN_CHANGE_INHERITANCE_TYPE'],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libpure_virtual_function',
|
||||
srcs = ['integration/cpp/pure_virtual/pure_virtual_function.cpp'],
|
||||
export_include_dirs = ['integration/cpp/pure_virtual/include'],
|
||||
version_script = '',
|
||||
cflags = [],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
name='libpure_virtual_function',
|
||||
srcs=['integration/cpp/pure_virtual/pure_virtual_function.cpp'],
|
||||
export_include_dirs=['integration/cpp/pure_virtual/include'],
|
||||
version_script='',
|
||||
cflags=[],
|
||||
arch='',
|
||||
api='current',
|
||||
),
|
||||
Module(
|
||||
name = 'libgolden_cpp_json',
|
||||
srcs = ['integration/cpp/gold/golden_1.cpp',
|
||||
name='libgolden_cpp_json',
|
||||
srcs=[
|
||||
'integration/cpp/gold/golden_1.cpp',
|
||||
'integration/cpp/gold/high_volume_speaker.cpp',
|
||||
'integration/cpp/gold/low_volume_speaker.cpp',
|
||||
],
|
||||
version_script = 'integration/cpp/gold/map.txt',
|
||||
export_include_dirs = ['integration/cpp/gold/include'],
|
||||
cflags = [],
|
||||
arch = '',
|
||||
api = 'current',
|
||||
dumper_flags = ['-output-format', 'Json'],
|
||||
linker_flags = ['-input-format', 'Json', '-output-format', 'Json']
|
||||
version_script='integration/cpp/gold/map.txt',
|
||||
export_include_dirs=['integration/cpp/gold/include'],
|
||||
cflags=[],
|
||||
arch='',
|
||||
api='current',
|
||||
dumper_flags=['-output-format', 'Json'],
|
||||
linker_flags=['-input-format', 'Json', '-output-format', 'Json']
|
||||
),
|
||||
]
|
||||
|
||||
TEST_MODULES = { m.name: m for m in TEST_MODULES }
|
||||
TEST_MODULES = {m.name: m for m in TEST_MODULES}
|
||||
|
||||
@@ -15,11 +15,13 @@ from utils import (
|
||||
from module import Module
|
||||
from gen_all import make_and_copy_reference_dumps
|
||||
|
||||
|
||||
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
INPUT_DIR = os.path.join(SCRIPT_DIR, 'input')
|
||||
EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected')
|
||||
REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps')
|
||||
|
||||
|
||||
class MyTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -50,7 +52,7 @@ class MyTest(unittest.TestCase):
|
||||
self.run_and_compare_name_cpp(name, cflags)
|
||||
|
||||
def run_and_compare_abi_diff(self, old_dump, new_dump, lib, arch,
|
||||
expected_return_code, flags=[]) :
|
||||
expected_return_code, flags=[]):
|
||||
actual_output = run_abi_diff(old_dump, new_dump, arch, lib, flags)
|
||||
self.assertEqual(actual_output, expected_return_code)
|
||||
|
||||
@@ -63,8 +65,7 @@ class MyTest(unittest.TestCase):
|
||||
def create_ref_dump(self, name, dir_name, target_arch):
|
||||
module_bare = Module.get_test_module_by_name(name)
|
||||
module = Module.mutate_module_for_arch(module_bare, target_arch)
|
||||
return make_and_copy_reference_dumps(module, [],
|
||||
dir_name)
|
||||
return make_and_copy_reference_dumps(module, [], dir_name)
|
||||
|
||||
def get_or_create_ref_dump(self, name, target_arch, dir_name, create):
|
||||
if create == True:
|
||||
@@ -76,26 +77,22 @@ class MyTest(unittest.TestCase):
|
||||
create_old=False, create_new=True):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for target_arch in TARGET_ARCHS:
|
||||
old_ref_dump_path = self.get_or_create_ref_dump(old_lib,
|
||||
target_arch,
|
||||
tmp, create_old)
|
||||
new_ref_dump_path = self.get_or_create_ref_dump(new_lib,
|
||||
target_arch,
|
||||
tmp, create_new)
|
||||
self.prepare_and_run_abi_diff(old_ref_dump_path,
|
||||
new_ref_dump_path, target_arch,
|
||||
old_ref_dump_path = self.get_or_create_ref_dump(
|
||||
old_lib, target_arch, tmp, create_old)
|
||||
new_ref_dump_path = self.get_or_create_ref_dump(
|
||||
new_lib, target_arch, tmp, create_new)
|
||||
self.prepare_and_run_abi_diff(
|
||||
old_ref_dump_path, new_ref_dump_path, target_arch,
|
||||
expected_return_code, flags)
|
||||
|
||||
def prepare_and_absolute_diff_all_archs(self, old_lib, new_lib,
|
||||
flags=[], create=True):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for target_arch in TARGET_ARCHS:
|
||||
old_ref_dump_path = self.get_or_create_ref_dump(old_lib,
|
||||
target_arch,
|
||||
tmp, False)
|
||||
new_ref_dump_path = self.get_or_create_ref_dump(new_lib,
|
||||
target_arch,
|
||||
tmp, create)
|
||||
old_ref_dump_path = self.get_or_create_ref_dump(
|
||||
old_lib, target_arch, tmp, False)
|
||||
new_ref_dump_path = self.get_or_create_ref_dump(
|
||||
new_lib, target_arch, tmp, create)
|
||||
self.assertEqual(
|
||||
read_output_content(old_ref_dump_path, AOSP_DIR),
|
||||
read_output_content(new_ref_dump_path, AOSP_DIR))
|
||||
@@ -117,8 +114,8 @@ class MyTest(unittest.TestCase):
|
||||
self.run_and_compare_name_cpp('example2.h')
|
||||
|
||||
def test_libc_and_cpp(self):
|
||||
self.prepare_and_run_abi_diff_all_archs("libc_and_cpp", "libc_and_cpp",
|
||||
0)
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libc_and_cpp", "libc_and_cpp", 0)
|
||||
|
||||
def test_libc_and_cpp_and_libc_and_cpp_with_unused_struct(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
@@ -134,7 +131,8 @@ class MyTest(unittest.TestCase):
|
||||
"libc_and_cpp", "libc_and_cpp_with_unused_struct", 1,
|
||||
['-check-all-apis'])
|
||||
|
||||
def test_libc_and_cpp_with_unused_struct_and_libc_and_cpp_with_unused_cstruct(self):
|
||||
def test_libc_and_cpp_with_unused_struct_and_libc_and_cpp_with_unused_cstruct(
|
||||
self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libc_and_cpp_with_unused_struct",
|
||||
"libc_and_cpp_with_unused_cstruct", 0,
|
||||
@@ -150,8 +148,7 @@ class MyTest(unittest.TestCase):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libc_and_cpp_with_opaque_ptr_a",
|
||||
"libc_and_cpp_with_opaque_ptr_b", 8,
|
||||
['-consider-opaque-types-different'], True,
|
||||
True)
|
||||
['-consider-opaque-types-different'], True, True)
|
||||
|
||||
def test_libgolden_cpp_return_type_diff(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
@@ -173,8 +170,7 @@ class MyTest(unittest.TestCase):
|
||||
|
||||
def test_libgolden_cpp_add_function_and_elf_symbol(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf",
|
||||
4)
|
||||
"libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf", 4)
|
||||
|
||||
def test_libgolden_cpp_change_function_access(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
@@ -194,29 +190,28 @@ class MyTest(unittest.TestCase):
|
||||
"libgolden_cpp", "libgolden_cpp_parameter_type_diff", 8)
|
||||
|
||||
def test_libgolden_cpp_with_vtable_diff(self):
|
||||
self.prepare_and_run_abi_diff_all_archs("libgolden_cpp",
|
||||
"libgolden_cpp_vtable_diff", 8)
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp", "libgolden_cpp_vtable_diff", 8)
|
||||
|
||||
def test_libgolden_cpp_member_diff_advice_only(self):
|
||||
self.prepare_and_run_abi_diff_all_archs("libgolden_cpp",
|
||||
"libgolden_cpp_member_diff",
|
||||
0, ['-advice-only'])
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp", "libgolden_cpp_member_diff", 0, ['-advice-only'])
|
||||
|
||||
def test_libgolden_cpp_member_diff(self):
|
||||
self.prepare_and_run_abi_diff_all_archs("libgolden_cpp",
|
||||
"libgolden_cpp_member_diff", 8)
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp", "libgolden_cpp_member_diff", 8)
|
||||
|
||||
def test_libgolden_cpp_change_member_access(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp", "libgolden_cpp_change_member_access", 8)
|
||||
|
||||
def test_libgolden_cpp_enum_extended(self):
|
||||
self.prepare_and_run_abi_diff_all_archs("libgolden_cpp",
|
||||
"libgolden_cpp_enum_extended",
|
||||
4)
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp", "libgolden_cpp_enum_extended", 4)
|
||||
|
||||
def test_libgolden_cpp_enum_diff(self):
|
||||
self.prepare_and_run_abi_diff_all_archs("libgolden_cpp",
|
||||
"libgolden_cpp_enum_diff", 8)
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp", "libgolden_cpp_enum_diff", 8)
|
||||
|
||||
def test_libgolden_cpp_fabricated_function_ast_removed_diff(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
@@ -237,35 +232,31 @@ class MyTest(unittest.TestCase):
|
||||
|
||||
def test_libgolden_cpp_unreferenced_elf_symbol_removed(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp",
|
||||
"libgolden_cpp_unreferenced_elf_symbol_removed", 16)
|
||||
"libgolden_cpp", "libgolden_cpp_unreferenced_elf_symbol_removed",
|
||||
16)
|
||||
|
||||
def test_libreproducability(self):
|
||||
self.prepare_and_absolute_diff_all_archs("libreproducability",
|
||||
"libreproducability")
|
||||
self.prepare_and_absolute_diff_all_archs(
|
||||
"libreproducability", "libreproducability")
|
||||
|
||||
def test_libgolden_cpp_member_name_changed(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp",
|
||||
"libgolden_cpp_member_name_changed", 0)
|
||||
"libgolden_cpp", "libgolden_cpp_member_name_changed", 0)
|
||||
|
||||
def test_libgolden_cpp_member_function_pointer_changed(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp_function_pointer",
|
||||
"libgolden_cpp_function_pointer_parameter_added", 8, [], True,
|
||||
True)
|
||||
"libgolden_cpp_function_pointer_parameter_added", 8, [], True, True)
|
||||
|
||||
def test_libgolden_cpp_internal_struct_access_upgraded(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp_internal_private_struct",
|
||||
"libgolden_cpp_internal_public_struct", 0, [], True,
|
||||
True)
|
||||
"libgolden_cpp_internal_public_struct", 0, [], True, True)
|
||||
|
||||
def test_libgolden_cpp_internal_struct_access_downgraded(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
"libgolden_cpp_internal_public_struct",
|
||||
"libgolden_cpp_internal_private_struct", 8, [], True,
|
||||
True)
|
||||
"libgolden_cpp_internal_private_struct", 8, [], True, True)
|
||||
|
||||
def test_libgolden_cpp_inheritance_type_changed(self):
|
||||
self.prepare_and_run_abi_diff_all_archs(
|
||||
@@ -274,9 +265,7 @@ class MyTest(unittest.TestCase):
|
||||
|
||||
def test_libpure_virtual_function(self):
|
||||
self.prepare_and_absolute_diff_all_archs(
|
||||
"libpure_virtual_function",
|
||||
"libpure_virtual_function",
|
||||
)
|
||||
"libpure_virtual_function", "libpure_virtual_function")
|
||||
|
||||
def test_libc_and_cpp_in_json(self):
|
||||
self.prepare_and_absolute_diff_all_archs(
|
||||
|
||||
@@ -73,7 +73,7 @@ def copy_reference_dump(lib_path, reference_dump_dir, compress):
|
||||
else:
|
||||
with open(reference_dump_path, 'wb') as f:
|
||||
f.write(bytes(output_content, 'utf-8'))
|
||||
print('Created abi dump at ', reference_dump_path)
|
||||
print('Created abi dump at', reference_dump_path)
|
||||
return reference_dump_path
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ def copy_reference_dump_content(lib_name, output_content,
|
||||
with open(reference_dump_path, 'w') as f:
|
||||
f.write(output_content)
|
||||
|
||||
print('Created abi dump at ', reference_dump_path)
|
||||
print('Created abi dump at', reference_dump_path)
|
||||
return reference_dump_path
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ def run_header_abi_dumper_on_file(input_path, output_path,
|
||||
|
||||
for dir in BUILTIN_HEADERS_DIR:
|
||||
cmd += ['-isystem', dir]
|
||||
# export includes imply local includes
|
||||
# The export include dirs imply local include dirs.
|
||||
for dir in export_include_dirs:
|
||||
cmd += ['-I', dir]
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
Reference in New Issue
Block a user