From b55856ae03884fe6d612b315e06fc3903a1cc409 Mon Sep 17 00:00:00 2001 From: Mu-Le Lee Date: Mon, 27 Jun 2022 02:36:28 +0000 Subject: [PATCH] Remove location information of unnamed elements in dumps to avoid automerge conflict. Test: ANDROID_BUILD_TOP=`realpath .` \ PATH=$PATH:`realpath out/soong/dist/bin`:`realpath out/soong/host/linux-x86/bin` \ development/vndk/tools/header-checker/tests/test.py Bug: 236800109 Change-Id: I811d9508166f11f7e69ccbc554bcac8b1f122be6 --- .../header-checker/src/dumper/ast_processing.cpp | 3 +++ .../header-checker/tests/expected/example1.cpp | 8 ++++---- .../tools/header-checker/tests/expected/example1.h | 8 ++++---- .../arm64/libanonymous_enum_odr.so.lsdump | 14 +++++++------- .../arm64/libgolden_anonymous_enum.so.lsdump | 8 ++++---- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/vndk/tools/header-checker/src/dumper/ast_processing.cpp b/vndk/tools/header-checker/src/dumper/ast_processing.cpp index 12dcbb30d..1cf094e6c 100644 --- a/vndk/tools/header-checker/src/dumper/ast_processing.cpp +++ b/vndk/tools/header-checker/src/dumper/ast_processing.cpp @@ -208,6 +208,9 @@ void HeaderASTConsumer::HandleTranslationUnit(clang::ASTContext &ctx) { // names to avoid inconsistency between C and C++ (for C++ files, this is true // by default) policy.SuppressTagKeyword = true; + // Hide the location of the anonymous or unnamed structures entity while + // getting QualType string names to avoid automerge conflict + policy.AnonymousTagLocations = false; PrintNormalizedPath callbacks(options_.root_dirs_); policy.Callbacks = &callbacks; ctx.setPrintingPolicy(policy); diff --git a/vndk/tools/header-checker/tests/expected/example1.cpp b/vndk/tools/header-checker/tests/expected/example1.cpp index 50f89e7df..702153244 100644 --- a/vndk/tools/header-checker/tests/expected/example1.cpp +++ b/vndk/tools/header-checker/tests/expected/example1.cpp @@ -220,7 +220,7 @@ record_types { } record_types { type_info { - name: "Hello::(anonymous struct at development/vndk/tools/header-checker/tests/input/example1.h:19:3)" + name: "Hello::(anonymous)" size: 12 alignment: 4 referenced_type: "_ZTIN5HelloUt1_E" @@ -252,7 +252,7 @@ record_types { } record_types { type_info { - name: "Hello::(anonymous struct at development/vndk/tools/header-checker/tests/input/example1.h:19:3)::(anonymous struct at development/vndk/tools/header-checker/tests/input/example1.h:22:5)" + name: "Hello::(anonymous)::(anonymous)" size: 4 alignment: 4 referenced_type: "_ZTIN5HelloUt1_Ut_E" @@ -448,7 +448,7 @@ enum_types { } enum_types { type_info { - name: "Hello::(unnamed enum at development/vndk/tools/header-checker/tests/input/example1.h:17:3)" + name: "Hello::(unnamed)" size: 4 alignment: 4 referenced_type: "_ZTIN5Hello2$AE" @@ -469,7 +469,7 @@ enum_types { } enum_types { type_info { - name: "Hello::(unnamed enum at development/vndk/tools/header-checker/tests/input/example1.h:18:3)" + name: "Hello::(unnamed)" size: 4 alignment: 4 referenced_type: "_ZTIN5Hello2$CE" diff --git a/vndk/tools/header-checker/tests/expected/example1.h b/vndk/tools/header-checker/tests/expected/example1.h index 963597037..7eb312113 100644 --- a/vndk/tools/header-checker/tests/expected/example1.h +++ b/vndk/tools/header-checker/tests/expected/example1.h @@ -220,7 +220,7 @@ record_types { } record_types { type_info { - name: "Hello::(anonymous struct at development/vndk/tools/header-checker/tests/input/example1.h:19:3)" + name: "Hello::(anonymous)" size: 12 alignment: 4 referenced_type: "_ZTIN5HelloUt1_E" @@ -252,7 +252,7 @@ record_types { } record_types { type_info { - name: "Hello::(anonymous struct at development/vndk/tools/header-checker/tests/input/example1.h:19:3)::(anonymous struct at development/vndk/tools/header-checker/tests/input/example1.h:22:5)" + name: "Hello::(anonymous)::(anonymous)" size: 4 alignment: 4 referenced_type: "_ZTIN5HelloUt1_Ut_E" @@ -448,7 +448,7 @@ enum_types { } enum_types { type_info { - name: "Hello::(unnamed enum at development/vndk/tools/header-checker/tests/input/example1.h:17:3)" + name: "Hello::(unnamed)" size: 4 alignment: 4 referenced_type: "_ZTIN5Hello2$AE" @@ -469,7 +469,7 @@ enum_types { } enum_types { type_info { - name: "Hello::(unnamed enum at development/vndk/tools/header-checker/tests/input/example1.h:18:3)" + name: "Hello::(unnamed)" size: 4 alignment: 4 referenced_type: "_ZTIN5Hello2$CE" diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libanonymous_enum_odr.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libanonymous_enum_odr.so.lsdump index eecb0cb07..4de60844d 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/arm64/libanonymous_enum_odr.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libanonymous_enum_odr.so.lsdump @@ -37,7 +37,7 @@ } ], "linker_set_key" : "_ZTI2$A", - "name" : "(unnamed enum at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:1:1)", + "name" : "(unnamed)", "referenced_type" : "_ZTI2$A", "self_type" : "_ZTI2$A", "size" : 1, @@ -54,7 +54,7 @@ } ], "linker_set_key" : "_ZTI2$B", - "name" : "(unnamed enum at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:5:1)", + "name" : "(unnamed)", "referenced_type" : "_ZTI2$B", "self_type" : "_ZTI2$B", "size" : 1, @@ -71,7 +71,7 @@ } ], "linker_set_key" : "_ZTI21$FIRST_ANONYMOUS_ENUM", - "name" : "(unnamed enum at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/include_golden.h:1:1)", + "name" : "(unnamed)", "referenced_type" : "_ZTI21$FIRST_ANONYMOUS_ENUM", "self_type" : "_ZTI21$FIRST_ANONYMOUS_ENUM", "size" : 4, @@ -92,7 +92,7 @@ } ], "linker_set_key" : "_ZTIN3$_22$BE", - "name" : "(unnamed struct at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:9:1)::(unnamed enum at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:10:3)", + "name" : "(unnamed)::(unnamed)", "referenced_type" : "_ZTIN3$_22$BE", "self_type" : "_ZTIN3$_22$BE", "size" : 4, @@ -113,7 +113,7 @@ } ], "linker_set_key" : "_ZTIN3$_32$BE", - "name" : "(unnamed struct at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:9:1)::(unnamed enum at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:10:3)", + "name" : "(unnamed)::(unnamed)", "referenced_type" : "_ZTIN3$_32$BE", "self_type" : "_ZTIN3$_32$BE", "size" : 4, @@ -140,7 +140,7 @@ ], "is_anonymous" : true, "linker_set_key" : "_ZTI3$_2", - "name" : "(unnamed struct at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:9:1)", + "name" : "(unnamed)", "referenced_type" : "_ZTI3$_2", "self_type" : "_ZTI3$_2", "size" : 4, @@ -157,7 +157,7 @@ ], "is_anonymous" : true, "linker_set_key" : "_ZTI3$_3", - "name" : "(unnamed struct at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:9:1)", + "name" : "(unnamed)", "referenced_type" : "_ZTI3$_3", "self_type" : "_ZTI3$_3", "size" : 4, diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_anonymous_enum.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_anonymous_enum.so.lsdump index 9be3f3471..fd7beff43 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_anonymous_enum.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_anonymous_enum.so.lsdump @@ -37,7 +37,7 @@ } ], "linker_set_key" : "_ZTI2$A", - "name" : "(unnamed enum at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:1:1)", + "name" : "(unnamed)", "referenced_type" : "_ZTI2$A", "self_type" : "_ZTI2$A", "size" : 1, @@ -54,7 +54,7 @@ } ], "linker_set_key" : "_ZTI2$B", - "name" : "(unnamed enum at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:5:1)", + "name" : "(unnamed)", "referenced_type" : "_ZTI2$B", "self_type" : "_ZTI2$B", "size" : 1, @@ -75,7 +75,7 @@ } ], "linker_set_key" : "_ZTIN3$_22$BE", - "name" : "(unnamed struct at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:9:1)::(unnamed enum at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:10:3)", + "name" : "(unnamed)::(unnamed)", "referenced_type" : "_ZTIN3$_22$BE", "self_type" : "_ZTIN3$_22$BE", "size" : 4, @@ -102,7 +102,7 @@ ], "is_anonymous" : true, "linker_set_key" : "_ZTI3$_2", - "name" : "(unnamed struct at development/vndk/tools/header-checker/tests/integration/cpp/anonymous_enum/include/golden.h:9:1)", + "name" : "(unnamed)", "referenced_type" : "_ZTI3$_2", "self_type" : "_ZTI3$_2", "size" : 4,