From 82a9f51a146f9efe65b83e63802f48ea1fce5e65 Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Mon, 18 Dec 2017 01:55:40 -0800 Subject: [PATCH] Use mangled name as unique id for C structs as well. Some structs could be included without extern "C" guards. If the same struct is included in a C++ source file and a C source file, it's unique type name will be mangled in one and its name in the other. To work around this inconsistency, mangle their names regardless of context. Bug: 69568963 Test: tests/test.py Change-Id: Ie285c4691dbaa58389a041fee5116ccbfc7985ce --- .../header-abi-dumper/src/abi_wrappers.cpp | 12 ++++-------- .../tools/header-checker/tests/expected/example1.cpp | 6 +++--- vndk/tools/header-checker/tests/expected/example1.h | 6 +++--- .../tests/reference_dumps/arm/libc_and_cpp.so.lsdump | 4 ++-- .../arm/libc_and_cpp_with_unused_struct.so.lsdump | 4 ++-- .../reference_dumps/arm64/libc_and_cpp.so.lsdump | 4 ++-- .../arm64/libc_and_cpp_with_unused_struct.so.lsdump | 4 ++-- .../reference_dumps/mips/libc_and_cpp.so.lsdump | 4 ++-- .../mips/libc_and_cpp_with_unused_struct.so.lsdump | 4 ++-- .../reference_dumps/mips64/libc_and_cpp.so.lsdump | 4 ++-- .../mips64/libc_and_cpp_with_unused_struct.so.lsdump | 4 ++-- .../tests/reference_dumps/x86/libc_and_cpp.so.lsdump | 4 ++-- .../x86/libc_and_cpp_with_unused_struct.so.lsdump | 4 ++-- .../reference_dumps/x86_64/libc_and_cpp.so.lsdump | 4 ++-- .../x86_64/libc_and_cpp_with_unused_struct.so.lsdump | 4 ++-- 15 files changed, 34 insertions(+), 38 deletions(-) diff --git a/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.cpp b/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.cpp index dd654cc38..435d0a858 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.cpp +++ b/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.cpp @@ -156,14 +156,10 @@ std::string RecordDeclWrapper::GetMangledRTTI( std::string ABIWrapper::GetTypeUniqueId(const clang::TagDecl *tag_decl) { clang::QualType qual_type = tag_decl->getTypeForDecl()->getCanonicalTypeInternal(); - // We need to mangle type names for C++ contexts. - if (!tag_decl->isExternCContext() && ast_contextp_->getLangOpts().CPlusPlus) { - llvm::SmallString<256> uid; - llvm::raw_svector_ostream out(uid); - mangle_contextp_->mangleCXXRTTIName(qual_type, out); - return uid.str(); - } - return ABIWrapper::QualTypeToString(qual_type); + llvm::SmallString<256> uid; + llvm::raw_svector_ostream out(uid); + mangle_contextp_->mangleCXXRTTIName(qual_type, out); + return uid.str(); } // CreateBasicNamedAndTypedDecl creates a BasicNamedAndTypedDecl : that'll diff --git a/vndk/tools/header-checker/tests/expected/example1.cpp b/vndk/tools/header-checker/tests/expected/example1.cpp index d1f79a497..0a72db531 100644 --- a/vndk/tools/header-checker/tests/expected/example1.cpp +++ b/vndk/tools/header-checker/tests/expected/example1.cpp @@ -204,7 +204,7 @@ record_types { is_anonymous: true record_kind: struct_kind tag_info { - unique_id: "Hello::(anonymous)::(anonymous)" + unique_id: "_ZTSN5HelloUt1_Ut_E" } } record_types { @@ -238,7 +238,7 @@ record_types { is_anonymous: true record_kind: struct_kind tag_info { - unique_id: "Hello::(anonymous)" + unique_id: "_ZTSN5HelloUt1_E" } } record_types { @@ -289,7 +289,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Hello" + unique_id: "_ZTS5Hello" } } record_types { diff --git a/vndk/tools/header-checker/tests/expected/example1.h b/vndk/tools/header-checker/tests/expected/example1.h index d1f79a497..0a72db531 100644 --- a/vndk/tools/header-checker/tests/expected/example1.h +++ b/vndk/tools/header-checker/tests/expected/example1.h @@ -204,7 +204,7 @@ record_types { is_anonymous: true record_kind: struct_kind tag_info { - unique_id: "Hello::(anonymous)::(anonymous)" + unique_id: "_ZTSN5HelloUt1_Ut_E" } } record_types { @@ -238,7 +238,7 @@ record_types { is_anonymous: true record_kind: struct_kind tag_info { - unique_id: "Hello::(anonymous)" + unique_id: "_ZTSN5HelloUt1_E" } } record_types { @@ -289,7 +289,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Hello" + unique_id: "_ZTS5Hello" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm/libc_and_cpp.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm/libc_and_cpp.so.lsdump index e11393cf2..be5232193 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/arm/libc_and_cpp.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/arm/libc_and_cpp.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm/libc_and_cpp_with_unused_struct.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm/libc_and_cpp_with_unused_struct.so.lsdump index 66e8cf32d..76367c4be 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/arm/libc_and_cpp_with_unused_struct.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/arm/libc_and_cpp_with_unused_struct.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libc_and_cpp.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libc_and_cpp.so.lsdump index 81f71f8de..358c99667 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/arm64/libc_and_cpp.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libc_and_cpp.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libc_and_cpp_with_unused_struct.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libc_and_cpp_with_unused_struct.so.lsdump index e276c0d75..012c760fa 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/arm64/libc_and_cpp_with_unused_struct.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libc_and_cpp_with_unused_struct.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips/libc_and_cpp.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips/libc_and_cpp.so.lsdump index e11393cf2..be5232193 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/mips/libc_and_cpp.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/mips/libc_and_cpp.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips/libc_and_cpp_with_unused_struct.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips/libc_and_cpp_with_unused_struct.so.lsdump index 66e8cf32d..76367c4be 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/mips/libc_and_cpp_with_unused_struct.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/mips/libc_and_cpp_with_unused_struct.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips64/libc_and_cpp.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips64/libc_and_cpp.so.lsdump index 81f71f8de..358c99667 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/mips64/libc_and_cpp.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/mips64/libc_and_cpp.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips64/libc_and_cpp_with_unused_struct.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips64/libc_and_cpp_with_unused_struct.so.lsdump index e276c0d75..012c760fa 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/mips64/libc_and_cpp_with_unused_struct.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/mips64/libc_and_cpp_with_unused_struct.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86/libc_and_cpp.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86/libc_and_cpp.so.lsdump index e11393cf2..be5232193 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/x86/libc_and_cpp.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/x86/libc_and_cpp.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86/libc_and_cpp_with_unused_struct.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86/libc_and_cpp_with_unused_struct.so.lsdump index 66e8cf32d..76367c4be 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/x86/libc_and_cpp_with_unused_struct.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/x86/libc_and_cpp_with_unused_struct.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libc_and_cpp.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libc_and_cpp.so.lsdump index 81f71f8de..358c99667 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libc_and_cpp.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libc_and_cpp.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types { diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libc_and_cpp_with_unused_struct.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libc_and_cpp_with_unused_struct.so.lsdump index e276c0d75..012c760fa 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libc_and_cpp_with_unused_struct.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libc_and_cpp_with_unused_struct.so.lsdump @@ -16,7 +16,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cinner" + unique_id: "_ZTS6Cinner" } } record_types { @@ -43,7 +43,7 @@ record_types { access: public_access record_kind: struct_kind tag_info { - unique_id: "Cstruct" + unique_id: "_ZTS7Cstruct" } } record_types {