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
This commit is contained in:
Mu-Le Lee
2022-06-27 02:36:28 +00:00
parent 1da99cc99e
commit b55856ae03
5 changed files with 22 additions and 19 deletions

View File

@@ -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);

View File

@@ -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"

View File

@@ -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"

View File

@@ -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,

View File

@@ -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,