diff options
author | Dan McGregor <dan.mcgregor@usask.ca> | 2023-06-08 22:37:05 -0600 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2023-06-16 13:28:20 -0700 |
commit | 3d26f0af253e831b1fd24475a0fbbe7c9e19fcfd (patch) | |
tree | 4c2143e3ba78538c24baab282d0c29164588dfc9 /recipes-devtools/clang | |
parent | 190da5cb56f182dcbb35f7fffb11083a06c8e606 (diff) | |
download | meta-clang-3d26f0af253e831b1fd24475a0fbbe7c9e19fcfd.tar.gz |
clang: Apply upstream D152570
This fixes real file names appearing in lambda names that are
used as arguments to function templates.
Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
Diffstat (limited to 'recipes-devtools/clang')
-rw-r--r-- | recipes-devtools/clang/clang/0038-clang-Apply-fmacro-prefix-map-to-anonymous-tags-in-t.patch | 86 | ||||
-rw-r--r-- | recipes-devtools/clang/common.inc | 1 |
2 files changed, 87 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0038-clang-Apply-fmacro-prefix-map-to-anonymous-tags-in-t.patch b/recipes-devtools/clang/clang/0038-clang-Apply-fmacro-prefix-map-to-anonymous-tags-in-t.patch new file mode 100644 index 0000000..08c8822 --- /dev/null +++ b/recipes-devtools/clang/clang/0038-clang-Apply-fmacro-prefix-map-to-anonymous-tags-in-t.patch | |||
@@ -0,0 +1,86 @@ | |||
1 | From 98a5709ff5a34a2906536e110d227f83898f550b Mon Sep 17 00:00:00 2001 | ||
2 | From: Dan McGregor <dan.mcgregor@usask.ca> | ||
3 | Date: Fri, 16 Jun 2023 08:47:00 -0700 | ||
4 | Subject: [PATCH] [clang] Apply -fmacro-prefix-map to anonymous tags in | ||
5 | template arguments | ||
6 | |||
7 | When expanding template arguments for pretty function printing, | ||
8 | such as for __PRETTY_FUNCTION__, make TypePrinter apply | ||
9 | macro-prefix-map remapping to anonymous tags such as lambdas. | ||
10 | |||
11 | Fixes https://github.com/llvm/llvm-project/issues/63219 | ||
12 | |||
13 | Reviewed By: MaskRay, aaron.ballman | ||
14 | |||
15 | Differential Revision: https://reviews.llvm.org/D152570 | ||
16 | |||
17 | Upstream-Status: Backport | ||
18 | --- | ||
19 | clang/docs/ReleaseNotes.rst | 2 ++ | ||
20 | clang/lib/AST/Expr.cpp | 14 ++++++++++++++ | ||
21 | clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp | 14 ++++++++++++++ | ||
22 | 3 files changed, 30 insertions(+) | ||
23 | create mode 100644 clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp | ||
24 | |||
25 | diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst | ||
26 | index 8d67ff904469..bf3ea4a54d01 100644 | ||
27 | --- a/clang/docs/ReleaseNotes.rst | ||
28 | +++ b/clang/docs/ReleaseNotes.rst | ||
29 | @@ -724,6 +724,8 @@ Bug Fixes in This Version | ||
30 | - Fix crash when passing a braced initializer list to a parentehsized aggregate | ||
31 | initialization expression. | ||
32 | (`#63008 <https://github.com/llvm/llvm-project/issues/63008>`_). | ||
33 | +- Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments | ||
34 | + (`#63219 <https://github.com/llvm/llvm-project/issues/63219>`_). | ||
35 | |||
36 | Bug Fixes to Compiler Builtins | ||
37 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
38 | diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp | ||
39 | index e45ae68cd5fe..a65678f5998c 100644 | ||
40 | --- a/clang/lib/AST/Expr.cpp | ||
41 | +++ b/clang/lib/AST/Expr.cpp | ||
42 | @@ -783,7 +783,21 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) { | ||
43 | Out << "static "; | ||
44 | } | ||
45 | |||
46 | + class PrettyCallbacks final : public PrintingCallbacks { | ||
47 | + public: | ||
48 | + PrettyCallbacks(const LangOptions &LO) : LO(LO) {} | ||
49 | + std::string remapPath(StringRef Path) const override { | ||
50 | + SmallString<128> p(Path); | ||
51 | + LO.remapPathPrefix(p); | ||
52 | + return std::string(p); | ||
53 | + } | ||
54 | + | ||
55 | + private: | ||
56 | + const LangOptions &LO; | ||
57 | + }; | ||
58 | PrintingPolicy Policy(Context.getLangOpts()); | ||
59 | + PrettyCallbacks PrettyCB(Context.getLangOpts()); | ||
60 | + Policy.Callbacks = &PrettyCB; | ||
61 | std::string Proto; | ||
62 | llvm::raw_string_ostream POut(Proto); | ||
63 | |||
64 | diff --git a/clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp b/clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp | ||
65 | new file mode 100644 | ||
66 | index 000000000000..e87f0ab484dc | ||
67 | --- /dev/null | ||
68 | +++ b/clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp | ||
69 | @@ -0,0 +1,14 @@ | ||
70 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmacro-prefix-map=%p=./UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s | ||
71 | + | ||
72 | +template<typename f> | ||
73 | +auto lambdatest(f&& cb) { | ||
74 | + const char *s = __PRETTY_FUNCTION__; | ||
75 | + return s; | ||
76 | +} | ||
77 | + | ||
78 | +int main() { | ||
79 | + auto *s = lambdatest([](){}); | ||
80 | +// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at ./UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}.cpp:[[#@LINE-1]]:24)]\00", align 1 | ||
81 | + | ||
82 | + return 0; | ||
83 | +} | ||
84 | -- | ||
85 | 2.40.1 | ||
86 | |||
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index c539bb3..11a7410 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc | |||
@@ -47,6 +47,7 @@ SRC_URI = "\ | |||
47 | file://0035-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch \ | 47 | file://0035-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch \ |
48 | file://0036-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \ | 48 | file://0036-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \ |
49 | file://0037-clang-Call-printName-to-get-name-of-Decl.patch \ | 49 | file://0037-clang-Call-printName-to-get-name-of-Decl.patch \ |
50 | file://0038-clang-Apply-fmacro-prefix-map-to-anonymous-tags-in-t.patch \ | ||
50 | " | 51 | " |
51 | # Fallback to no-PIE if not set | 52 | # Fallback to no-PIE if not set |
52 | GCCPIE ??= "" | 53 | GCCPIE ??= "" |