From 810d0b07547c0c5d2795c72cca576edea7ba7000 Mon Sep 17 00:00:00 2001 From: Dan McGregor Date: Tue, 21 Mar 2023 14:19:28 -0600 Subject: clang: fix reproducibily issue Clang gives a name to the constructors of anonymous structures in debug info that's based on the filename of the structure's definition. It didn't respect the debug-prefix-map setting, causimg QA warnings in several recipes, notably libcxx. Signed-off-by: Dan McGregor --- ...-clang-Call-printName-to-get-name-of-Decl.patch | 70 ++++++++++++++++++++++ recipes-devtools/clang/common.inc | 1 + 2 files changed, 71 insertions(+) create mode 100644 recipes-devtools/clang/clang/0037-clang-Call-printName-to-get-name-of-Decl.patch (limited to 'recipes-devtools') diff --git a/recipes-devtools/clang/clang/0037-clang-Call-printName-to-get-name-of-Decl.patch b/recipes-devtools/clang/clang/0037-clang-Call-printName-to-get-name-of-Decl.patch new file mode 100644 index 0000000..8670afe --- /dev/null +++ b/recipes-devtools/clang/clang/0037-clang-Call-printName-to-get-name-of-Decl.patch @@ -0,0 +1,70 @@ +From d33d6a8c4f43907cb53130730a2bc48624a34b74 Mon Sep 17 00:00:00 2001 +From: Dan McGregor +Date: Tue, 21 Mar 2023 13:04:51 -0600 +Subject: [PATCH] [clang] Call printName to get name of Decl + +Rather than sending a name directly to the stream, use printName +to preserve any PrintingPolicy. This ensures that names are properly +affected by path remapping. + +Differential Revision: https://reviews.llvm.org/D149272 + +Upstream-Status: pending +--- + clang/lib/AST/Decl.cpp | 4 ++-- + clang/lib/AST/DeclarationName.cpp | 4 ++-- + clang/test/CodeGen/debug-prefix-map.cpp | 11 +++++++++++ + 3 files changed, 15 insertions(+), 4 deletions(-) + create mode 100644 clang/test/CodeGen/debug-prefix-map.cpp + +diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp +index e60cc28f6e0f..24de6156c0f5 100644 +--- a/clang/lib/AST/Decl.cpp ++++ b/clang/lib/AST/Decl.cpp +@@ -1626,8 +1626,8 @@ Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const { + llvm_unreachable("unknown module kind"); + } + +-void NamedDecl::printName(raw_ostream &OS, const PrintingPolicy&) const { +- OS << Name; ++void NamedDecl::printName(raw_ostream &OS, const PrintingPolicy &Policy) const { ++ Name.print(OS, Policy); + } + + void NamedDecl::printName(raw_ostream &OS) const { +diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp +index c1219041a466..da8b3886c340 100644 +--- a/clang/lib/AST/DeclarationName.cpp ++++ b/clang/lib/AST/DeclarationName.cpp +@@ -117,12 +117,12 @@ static void printCXXConstructorDestructorName(QualType ClassType, + Policy.adjustForCPlusPlus(); + + if (const RecordType *ClassRec = ClassType->getAs()) { +- OS << *ClassRec->getDecl(); ++ ClassRec->getDecl()->printName(OS, Policy); + return; + } + if (Policy.SuppressTemplateArgsInCXXConstructors) { + if (auto *InjTy = ClassType->getAs()) { +- OS << *InjTy->getDecl(); ++ InjTy->getDecl()->printName(OS, Policy); + return; + } + } +diff --git a/clang/test/CodeGen/debug-prefix-map.cpp b/clang/test/CodeGen/debug-prefix-map.cpp +new file mode 100644 +index 000000000000..7ddaee531282 +--- /dev/null ++++ b/clang/test/CodeGen/debug-prefix-map.cpp +@@ -0,0 +1,11 @@ ++// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S %s -emit-llvm -o - | FileCheck %s ++ ++struct alignas(64) an { ++ struct { ++ unsigned char x{0}; ++ } arr[64]; ++}; ++ ++struct an *pan = new an; ++ ++// CHECK: !DISubprogram(name: "(unnamed struct at ./UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}", diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index 6b85edf..c539bb3 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc @@ -46,6 +46,7 @@ SRC_URI = "\ file://0034-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \ file://0035-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch \ file://0036-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \ + file://0037-clang-Call-printName-to-get-name-of-Decl.patch \ " # Fallback to no-PIE if not set GCCPIE ??= "" -- cgit v1.2.3-54-g00ecf