12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- From d33d6a8c4f43907cb53130730a2bc48624a34b74 Mon Sep 17 00:00:00 2001
- From: Dan McGregor <dan.mcgregor@usask.ca>
- 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<RecordType>()) {
- - OS << *ClassRec->getDecl();
- + ClassRec->getDecl()->printName(OS, Policy);
- return;
- }
- if (Policy.SuppressTemplateArgsInCXXConstructors) {
- if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
- - 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{{/|\\\\}}{{.*}}",
|