[Lldb-commits] [flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/74061 This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. >From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Fri, 1 Dec 2023 13:35:23 +0300 Subject: [PATCH 1/2] [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed --- clang/test/CXX/drs/dr1xx.cpp | 20 ++-- clang/www/cxx_dr_status.html | 20 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 60e80a4c0e1c4f9..50236eb7c9499d4 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes extern "C" S operator+(S, S) { return S(); } } -namespace dr108 { // dr108: yes +namespace dr108 { // dr108: 2.9 template struct A { struct B { typedef int X; }; B::X x; @@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes } b; // expected-error {{abstract}} } -namespace dr115 { // dr115: yes +namespace dr115 { // dr115: 3.0 template int f(T); // expected-note +{{}} template int g(T); // expected-note +{{}} template int g(T, int); // expected-note +{{}} @@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes void g(int n) { n = 2; } } -namespace dr141 { // dr141: yes +namespace dr141 { // dr141: 3.1 template void f(); template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} struct A : S { @@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes void i() { C().i(); } // ok!! } -namespace dr142 { // dr142: yes +namespace dr142 { // dr142: 2.8 class B { // expected-note +{{here}} public: int mi; // expected-note +{{here}} @@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes // dr149: na -namespace dr151 { // dr151: yes +namespace dr151 { // dr151: 3.1 struct X {}; typedef int X::*p; #if __cplusplus < 201103L @@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5 // dr160: na -namespace dr161 { // dr161: yes +namespace dr161 { // dr161: 3.1 class A { protected: struct B { int n; } b; // expected-note 2{{here}} @@ -724,7 +724,7 @@ namespace dr165 { // dr165: no void N::g() {} } -namespace dr166 { // dr166: yes +namespace dr166 { // dr166: 2.9 namespace A { class X; } template int f(T t) { return t.n; } @@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes // dr174: sup 1012 -namespace dr175 { // dr175: yes +namespace dr175 { // dr175: 2.8 struct A {}; // expected-note {{here}} struct B : private A {}; // expected-note {{constrained by private inheritance}} struct C : B { @@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes }; } -namespace dr176 { // dr176: yes +namespace dr176 { // dr176: 3.1 template class Y; template<> class Y { void f() { @@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} } -namespace dr180 { // dr180: yes +namespace dr180 { // dr180: 2.8 template struct X : T, T::some_base { X() : T::some_type_that_might_be_T(), T::some_base() {} friend class T::some_class; diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 7cf657a47d64093..141b2aa515ad9ad 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -685,7 +685,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/108.html";>108 TC1 Are classes nested in templates dependent? -Yes +Clang 2.9 https://cplusplus.github.io/CWG/issues/109.html";>109 @@ -727,7 +727,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/115.html";>115 CD1 Address of template-id -Yes +Clang 3.0 https://cplusplus.github.io/CWG/issues/116.html";>116 @@ -883,13 +883,13 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/141.html";>141 CD1 Non-member function templates in member access expressions -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/142.html";>142 TC1 Injection-related errors in access example -Yes +Clang 2.8 https://cplusplus.github.io/CWG/issues/143.html";>143 @@ -943,7 +943,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/151.html";>151 TC1 Terminology of zero-initialization -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/152.html";>152 @@ -1003,7 +1003,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/161.html";>161 TC1 Access to protected nested type -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/162.html";>162 @@ -
[Lldb-commits] [flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. --- Patch is 54.76 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74061.diff 1 Files Affected: - (modified) clang/test/CXX/drs/dr1xx.cpp (+436-248) ``diff diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 50236eb7c9499d4..e80999e7a2d0cff 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -1,30 +1,31 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98,cxx98-11,cxx98-14,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,cxx98-11,cxx98-14,cxx98-17,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,cxx98-14,cxx98-17,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors namespace dr100 { // dr100: yes - template struct A {}; // expected-note 0-1{{declared here}} - template struct B {}; // expected-note 0-1{{declared here}} - template struct C {}; // expected-note 0-1{{declared here}} - template struct D {}; // expected-note 0-1{{declared here}} - A<&"foo"> a; // #100a - B<"bar"> b; // #100b - C<"baz"> c; // #100c - D<*"quux"> d; // #100d -#if __cplusplus < 201703L - // expected-error@#100a {{does not refer to any declaration}} - // expected-error@#100b {{does not refer to any declaration}} - // expected-error@#100c {{does not refer to any declaration}} - // expected-error@#100d {{does not refer to any declaration}} -#else - // expected-error@#100a {{pointer to string literal is not allowed in a template argument}} - // expected-error@#100b {{reference to string literal is not allowed in a template argument}} - // expected-error@#100c {{pointer to subobject of string literal is not allowed in a template argument}} - // expected-error@#100d {{reference to subobject of string literal is not allowed in a template argument}} -#endif + template struct A {}; // #dr100-A + template struct B {}; // #dr100-B + template struct C {}; // #dr100-C + template struct D {}; // #dr100-D + A<&"foo"> a; // #dr100-a + // cxx98-14-error@#dr100-a {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-A {{template parameter is declared here}} + // since-cxx17-error@#dr100-a {{pointer to string literal is not allowed in a template argument}} + B<"bar"> b; // #dr100-b + // cxx98-14-error@#dr100-b {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-B {{template parameter is declared here}} + // since-cxx17-error@#dr100-b {{reference to string literal is not allowed in a template argument}} + C<"baz"> c; // #dr100-c + // cxx98-14-error@#dr100-c {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-C {{template parameter is declared here}} + // since-cxx17-error@#dr100-c {{pointer to subobject of string literal is not allowed in a template argument}} + D<*"quux"> d; // #dr100-d + // cxx98-14-error@#dr100-d {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-D {{template parameter is declared here}} + // since-cxx17-error@#dr100-d {{reference to subobject of string literal is not allowed in a template argument}} } namespace dr101 { // dr101: 3.5 @@ -42,13 +43,16 @@ namespace dr101 { // dr101: 3.5 namespace dr102 { // dr102: yes namespace A { -template T
[Lldb-commits] [flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
Endilll wrote: This PR is created to run the patch through CI, so no review requested. https://github.com/llvm/llvm-project/pull/74061 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [libc] [flang] [lldb] [libcxx] [clang] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/74061 >From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Fri, 1 Dec 2023 13:35:23 +0300 Subject: [PATCH 1/3] [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed --- clang/test/CXX/drs/dr1xx.cpp | 20 ++-- clang/www/cxx_dr_status.html | 20 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 60e80a4c0e1c4f9..50236eb7c9499d4 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes extern "C" S operator+(S, S) { return S(); } } -namespace dr108 { // dr108: yes +namespace dr108 { // dr108: 2.9 template struct A { struct B { typedef int X; }; B::X x; @@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes } b; // expected-error {{abstract}} } -namespace dr115 { // dr115: yes +namespace dr115 { // dr115: 3.0 template int f(T); // expected-note +{{}} template int g(T); // expected-note +{{}} template int g(T, int); // expected-note +{{}} @@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes void g(int n) { n = 2; } } -namespace dr141 { // dr141: yes +namespace dr141 { // dr141: 3.1 template void f(); template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} struct A : S { @@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes void i() { C().i(); } // ok!! } -namespace dr142 { // dr142: yes +namespace dr142 { // dr142: 2.8 class B { // expected-note +{{here}} public: int mi; // expected-note +{{here}} @@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes // dr149: na -namespace dr151 { // dr151: yes +namespace dr151 { // dr151: 3.1 struct X {}; typedef int X::*p; #if __cplusplus < 201103L @@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5 // dr160: na -namespace dr161 { // dr161: yes +namespace dr161 { // dr161: 3.1 class A { protected: struct B { int n; } b; // expected-note 2{{here}} @@ -724,7 +724,7 @@ namespace dr165 { // dr165: no void N::g() {} } -namespace dr166 { // dr166: yes +namespace dr166 { // dr166: 2.9 namespace A { class X; } template int f(T t) { return t.n; } @@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes // dr174: sup 1012 -namespace dr175 { // dr175: yes +namespace dr175 { // dr175: 2.8 struct A {}; // expected-note {{here}} struct B : private A {}; // expected-note {{constrained by private inheritance}} struct C : B { @@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes }; } -namespace dr176 { // dr176: yes +namespace dr176 { // dr176: 3.1 template class Y; template<> class Y { void f() { @@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} } -namespace dr180 { // dr180: yes +namespace dr180 { // dr180: 2.8 template struct X : T, T::some_base { X() : T::some_type_that_might_be_T(), T::some_base() {} friend class T::some_class; diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 7cf657a47d64093..141b2aa515ad9ad 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -685,7 +685,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/108.html";>108 TC1 Are classes nested in templates dependent? -Yes +Clang 2.9 https://cplusplus.github.io/CWG/issues/109.html";>109 @@ -727,7 +727,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/115.html";>115 CD1 Address of template-id -Yes +Clang 3.0 https://cplusplus.github.io/CWG/issues/116.html";>116 @@ -883,13 +883,13 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/141.html";>141 CD1 Non-member function templates in member access expressions -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/142.html";>142 TC1 Injection-related errors in access example -Yes +Clang 2.8 https://cplusplus.github.io/CWG/issues/143.html";>143 @@ -943,7 +943,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/151.html";>151 TC1 Terminology of zero-initialization -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/152.html";>152 @@ -1003,7 +1003,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/161.html";>161 TC1 Access to protected nested type -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/162.html";>162 @@ -1033,7 +1033,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/166.html";>166 TC1 Friend dec
[Lldb-commits] [flang] [compiler-rt] [libunwind] [libcxx] [clang] [lld] [clang-tools-extra] [lldb] [libc] [llvm] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { AaronBallman wrote: Should we return false in the case `s == 0`? It would be good to add test coverage for parsing failures. https://github.com/llvm/llvm-project/pull/71771 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [flang] [libunwind] [clang-tools-extra] [libcxx] [clang] [libc] [compiler-rt] [llvm] [lld] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -537,8 +557,12 @@ ArgType PrintfSpecifier::getScalarArgType(ASTContext &Ctx, ArgType(Ctx.getPointerDiffType(), "ptrdiff_t")); case LengthModifier::AsAllocate: case LengthModifier::AsMAllocate: - case LengthModifier::AsWide: return ArgType::Invalid(); + case LengthModifier::AsWide: + case LengthModifier::AsWideFast: +int s = getExplicitlyFixedSize(); +bool fast = LM.getKind() == LengthModifier::AsWideFast ? true : false; +return clang::analyze_format_string::wToArgType(s, fast, Ctx); AaronBallman wrote: ```suggestion int S = getExplicitlyFixedSize(); bool Fast = LM.getKind() == LengthModifier::AsWideFast ? true : false; return clang::analyze_format_string::wToArgType(S, Fast, Ctx); ``` Same below. https://github.com/llvm/llvm-project/pull/71771 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [lld] [lldb] [libunwind] [flang] [llvm] [libcxx] [libc] [clang-tools-extra] [clang] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { +std::set supported_list {8, 16, 32, 64}; +if (supported_list.count(s) == 0) { + return false; +} AaronBallman wrote: ```suggestion if (supported_list.count(s) == 0) return false; ``` https://github.com/llvm/llvm-project/pull/71771 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [libc] [clang-tools-extra] [lld] [libcxx] [llvm] [libunwind] [flang] [compiler-rt] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -460,6 +463,14 @@ class FormatSpecifier { FieldWidth = Amt; } + void setExplicitlyFixedSize(unsigned s) { +ExplicitlyFixedSize = s; AaronBallman wrote: ```suggestion void setExplicitlyFixedSize(unsigned S) { ExplicitlyFixedSize = S; ``` https://github.com/llvm/llvm-project/pull/71771 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [flang] [lld] [clang] [llvm] [libc] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/74061 >From e6b9f54ce066e029b043e72281a7144338a84219 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Fri, 1 Dec 2023 13:35:23 +0300 Subject: [PATCH 1/4] [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed --- clang/test/CXX/drs/dr1xx.cpp | 20 ++-- clang/www/cxx_dr_status.html | 20 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 60e80a4c0e1c4f9..50236eb7c9499d4 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -72,7 +72,7 @@ namespace dr107 { // dr107: yes extern "C" S operator+(S, S) { return S(); } } -namespace dr108 { // dr108: yes +namespace dr108 { // dr108: 2.9 template struct A { struct B { typedef int X; }; B::X x; @@ -143,7 +143,7 @@ namespace dr114 { // dr114: yes } b; // expected-error {{abstract}} } -namespace dr115 { // dr115: yes +namespace dr115 { // dr115: 3.0 template int f(T); // expected-note +{{}} template int g(T); // expected-note +{{}} template int g(T, int); // expected-note +{{}} @@ -480,7 +480,7 @@ namespace dr140 { // dr140: yes void g(int n) { n = 2; } } -namespace dr141 { // dr141: yes +namespace dr141 { // dr141: 3.1 template void f(); template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} struct A : S { @@ -518,7 +518,7 @@ namespace dr141 { // dr141: yes void i() { C().i(); } // ok!! } -namespace dr142 { // dr142: yes +namespace dr142 { // dr142: 2.8 class B { // expected-note +{{here}} public: int mi; // expected-note +{{here}} @@ -602,7 +602,7 @@ namespace dr148 { // dr148: yes // dr149: na -namespace dr151 { // dr151: yes +namespace dr151 { // dr151: 3.1 struct X {}; typedef int X::*p; #if __cplusplus < 201103L @@ -655,7 +655,7 @@ namespace dr159 { // dr159: 3.5 // dr160: na -namespace dr161 { // dr161: yes +namespace dr161 { // dr161: 3.1 class A { protected: struct B { int n; } b; // expected-note 2{{here}} @@ -724,7 +724,7 @@ namespace dr165 { // dr165: no void N::g() {} } -namespace dr166 { // dr166: yes +namespace dr166 { // dr166: 2.9 namespace A { class X; } template int f(T t) { return t.n; } @@ -827,7 +827,7 @@ namespace dr173 { // dr173: yes // dr174: sup 1012 -namespace dr175 { // dr175: yes +namespace dr175 { // dr175: 2.8 struct A {}; // expected-note {{here}} struct B : private A {}; // expected-note {{constrained by private inheritance}} struct C : B { @@ -836,7 +836,7 @@ namespace dr175 { // dr175: yes }; } -namespace dr176 { // dr176: yes +namespace dr176 { // dr176: 3.1 template class Y; template<> class Y { void f() { @@ -904,7 +904,7 @@ namespace dr179 { // dr179: yes int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} } -namespace dr180 { // dr180: yes +namespace dr180 { // dr180: 2.8 template struct X : T, T::some_base { X() : T::some_type_that_might_be_T(), T::some_base() {} friend class T::some_class; diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 7cf657a47d64093..141b2aa515ad9ad 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -685,7 +685,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/108.html";>108 TC1 Are classes nested in templates dependent? -Yes +Clang 2.9 https://cplusplus.github.io/CWG/issues/109.html";>109 @@ -727,7 +727,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/115.html";>115 CD1 Address of template-id -Yes +Clang 3.0 https://cplusplus.github.io/CWG/issues/116.html";>116 @@ -883,13 +883,13 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/141.html";>141 CD1 Non-member function templates in member access expressions -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/142.html";>142 TC1 Injection-related errors in access example -Yes +Clang 2.8 https://cplusplus.github.io/CWG/issues/143.html";>143 @@ -943,7 +943,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/151.html";>151 TC1 Terminology of zero-initialization -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/152.html";>152 @@ -1003,7 +1003,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/161.html";>161 TC1 Access to protected nested type -Yes +Clang 3.1 https://cplusplus.github.io/CWG/issues/162.html";>162 @@ -1033,7 +1033,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/166.html";>166 TC1 Friend dec
[Lldb-commits] [libc] [libcxx] [llvm] [lld] [lldb] [clang] [flang] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/74061 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/test] Add OpenBSD to _get_platform_os (PR #74036)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/74036 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Simplify pipe2(2) handling on FreeBSD (PR #74019)
https://github.com/JDevlieghere approved this pull request. Neat 👍 https://github.com/llvm/llvm-project/pull/74019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make use of LD_LIBRARY_PATH on OpenBSD (PR #74017)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/74017 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unncesary string conversions (PR #74119)
https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/74119 This PR cleans up OptionArgParser in a couple of ways: 1. We remove unnecessary std::string temporaries 2. Through else-after-return elimination, we prove the existence of unreachable code >From 6f502ee61bae59a16f90f30357eb72698ad577d0 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Fri, 1 Dec 2023 09:07:11 -0800 Subject: [PATCH 1/3] [lldb][NFC] Remove unnecessary std::string temporaries The existing code was taking three substrings from a regex match and converting to std::strings prior to using them. This may have been done to address null-termination concerns, but this is not the case: 1. `name` was being used to call `c_str()` and then implicitly converted back to a `StringRef` on the call to `ToAddress`. While the path `const char *` -> `StringRef` requires null-termination, we can simply use the original StringRef. 2. `str_offset` was being converted back to a StringRef in order to call a member method. Member methods can't handle non-null termination. 3. `sign` simply had it's 0-th element accessed. --- lldb/source/Interpreter/OptionArgParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp index ba2d3416e1838a9..9e53261ac885436 100644 --- a/lldb/source/Interpreter/OptionArgParser.cpp +++ b/lldb/source/Interpreter/OptionArgParser.cpp @@ -243,9 +243,9 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, llvm::SmallVector matches; if (g_symbol_plus_offset_regex.Execute(sref, &matches)) { uint64_t offset = 0; - std::string name = matches[1].str(); - std::string sign = matches[2].str(); - std::string str_offset = matches[3].str(); + llvm::StringRef name = matches[1]; + llvm::StringRef sign = matches[2]; + llvm::StringRef str_offset = matches[3]; if (!llvm::StringRef(str_offset).getAsInteger(0, offset)) { Status error; addr = ToAddress(exe_ctx, name.c_str(), LLDB_INVALID_ADDRESS, &error); >From f7b4bece1f40ffbb22cffb1ef25d56fb34bfedb2 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Fri, 1 Dec 2023 09:44:28 -0800 Subject: [PATCH 2/3] [lldb][NFC] Remove else after return in OptionArgParse This will enable us to prove that there is unreachable code in this function in a subsequent commit. --- lldb/source/Interpreter/OptionArgParser.cpp | 21 + 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp index 9e53261ac885436..8698f1de224de20 100644 --- a/lldb/source/Interpreter/OptionArgParser.cpp +++ b/lldb/source/Interpreter/OptionArgParser.cpp @@ -168,7 +168,6 @@ lldb::addr_t OptionArgParser::ToAddress(const ExecutionContext *exe_ctx, std::optional OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, Status *error_ptr) { - bool error_set = false; if (s.empty()) { if (error_ptr) error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"", @@ -212,6 +211,7 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, target->EvaluateExpression(s, exe_ctx->GetFramePtr(), valobj_sp, options); bool success = false; + bool error_set = false; if (expr_result == eExpressionCompleted) { if (valobj_sp) valobj_sp = valobj_sp->GetQualifiedRepresentationIfAvailable( @@ -223,16 +223,14 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, if (error_ptr) error_ptr->Clear(); return addr; -} else { - if (error_ptr) { -error_set = true; -error_ptr->SetErrorStringWithFormat( -"address expression \"%s\" resulted in a value whose type " -"can't be converted to an address: %s", -s.str().c_str(), valobj_sp->GetTypeName().GetCString()); - } } - +if (error_ptr) { + error_set = true; + error_ptr->SetErrorStringWithFormat( + "address expression \"%s\" resulted in a value whose type " + "can't be converted to an address: %s", + s.str().c_str(), valobj_sp->GetTypeName().GetCString()); +} } else { // Since the compiler can't handle things like "main + 12" we should try to // do this for now. The compiler doesn't like adding offsets to function @@ -252,8 +250,7 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, if (addr != LLDB_INVALID_ADDRESS) { if (sign[0] == '+') return addr + offset; - else -return addr - offset; + return addr - offset; } } } >From 25decf3ecd15f3782ffe8e5666423d8a750ff14d Mon Sep 17 00:00:00 2001 From: Felipe de Az
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unncesary string conversions (PR #74119)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Felipe de Azevedo Piovezan (felipepiovezan) Changes This PR cleans up OptionArgParser in a couple of ways: 1. We remove unnecessary std::string temporaries 2. Through else-after-return elimination, we prove the existence of unreachable code --- Full diff: https://github.com/llvm/llvm-project/pull/74119.diff 1 Files Affected: - (modified) lldb/source/Interpreter/OptionArgParser.cpp (+29-42) ``diff diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp index ba2d3416e1838a9..2f2c510462dc79a 100644 --- a/lldb/source/Interpreter/OptionArgParser.cpp +++ b/lldb/source/Interpreter/OptionArgParser.cpp @@ -168,7 +168,6 @@ lldb::addr_t OptionArgParser::ToAddress(const ExecutionContext *exe_ctx, std::optional OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, Status *error_ptr) { - bool error_set = false; if (s.empty()) { if (error_ptr) error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"", @@ -223,52 +222,40 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, if (error_ptr) error_ptr->Clear(); return addr; -} else { - if (error_ptr) { -error_set = true; -error_ptr->SetErrorStringWithFormat( -"address expression \"%s\" resulted in a value whose type " -"can't be converted to an address: %s", -s.str().c_str(), valobj_sp->GetTypeName().GetCString()); - } } +if (error_ptr) + error_ptr->SetErrorStringWithFormat( + "address expression \"%s\" resulted in a value whose type " + "can't be converted to an address: %s", + s.str().c_str(), valobj_sp->GetTypeName().GetCString()); +return {}; + } - } else { -// Since the compiler can't handle things like "main + 12" we should try to -// do this for now. The compiler doesn't like adding offsets to function -// pointer types. -static RegularExpression g_symbol_plus_offset_regex( -"^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$"); - -llvm::SmallVector matches; -if (g_symbol_plus_offset_regex.Execute(sref, &matches)) { - uint64_t offset = 0; - std::string name = matches[1].str(); - std::string sign = matches[2].str(); - std::string str_offset = matches[3].str(); - if (!llvm::StringRef(str_offset).getAsInteger(0, offset)) { -Status error; -addr = ToAddress(exe_ctx, name.c_str(), LLDB_INVALID_ADDRESS, &error); -if (addr != LLDB_INVALID_ADDRESS) { - if (sign[0] == '+') -return addr + offset; - else -return addr - offset; -} + // Since the compiler can't handle things like "main + 12" we should try to + // do this for now. The compiler doesn't like adding offsets to function + // pointer types. + static RegularExpression g_symbol_plus_offset_regex( + "^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$"); + + llvm::SmallVector matches; + if (g_symbol_plus_offset_regex.Execute(sref, &matches)) { +uint64_t offset = 0; +llvm::StringRef name = matches[1]; +llvm::StringRef sign = matches[2]; +llvm::StringRef str_offset = matches[3]; +if (!llvm::StringRef(str_offset).getAsInteger(0, offset)) { + Status error; + addr = ToAddress(exe_ctx, name.c_str(), LLDB_INVALID_ADDRESS, &error); + if (addr != LLDB_INVALID_ADDRESS) { +if (sign[0] == '+') + return addr + offset; +return addr - offset; } } - -if (error_ptr) { - error_set = true; - error_ptr->SetErrorStringWithFormat( - "address expression \"%s\" evaluation failed", s.str().c_str()); -} } - if (error_ptr) { -if (!error_set) - error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"", - s.str().c_str()); - } + if (error_ptr) +error_ptr->SetErrorStringWithFormat( +"address expression \"%s\" evaluation failed", s.str().c_str()); return {}; } `` https://github.com/llvm/llvm-project/pull/74119 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)
https://github.com/felipepiovezan edited https://github.com/llvm/llvm-project/pull/74119 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)
https://github.com/JDevlieghere approved this pull request. Github makes this look extremely complicated but in my editor this all looks pretty obvious. LGTM. https://github.com/llvm/llvm-project/pull/74119 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/test] Add OpenBSD to _get_platform_os (PR #74036)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/74036 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Simplify pipe2(2) handling on FreeBSD (PR #74019)
https://github.com/bulbazord approved this pull request. 🥳 https://github.com/llvm/llvm-project/pull/74019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make use of LD_LIBRARY_PATH on OpenBSD (PR #74017)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/74017 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/74119 >From d4143eea927eed4f4f0efaa9e1657de5f452a257 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Fri, 1 Dec 2023 09:07:11 -0800 Subject: [PATCH 1/3] [lldb][NFC] Remove unnecessary std::string temporaries The existing code was taking three substrings from a regex match and converting to std::strings prior to using them. This may have been done to address null-termination concerns, but this is not the case: 1. `name` was being used to call `c_str()` and then implicitly converted back to a `StringRef` on the call to `ToAddress`. While the path `const char *` -> `StringRef` requires null-termination, we can simply use the original StringRef. 2. `str_offset` was being converted back to a StringRef in order to call a member method. Member methods can't handle non-null termination. 3. `sign` simply had it's 0-th element accessed. --- lldb/source/Interpreter/OptionArgParser.cpp | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp index ba2d3416e1838a9..933bc6514ca2418 100644 --- a/lldb/source/Interpreter/OptionArgParser.cpp +++ b/lldb/source/Interpreter/OptionArgParser.cpp @@ -243,12 +243,12 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, llvm::SmallVector matches; if (g_symbol_plus_offset_regex.Execute(sref, &matches)) { uint64_t offset = 0; - std::string name = matches[1].str(); - std::string sign = matches[2].str(); - std::string str_offset = matches[3].str(); - if (!llvm::StringRef(str_offset).getAsInteger(0, offset)) { + llvm::StringRef name = matches[1]; + llvm::StringRef sign = matches[2]; + llvm::StringRef str_offset = matches[3]; + if (!str_offset.getAsInteger(0, offset)) { Status error; -addr = ToAddress(exe_ctx, name.c_str(), LLDB_INVALID_ADDRESS, &error); +addr = ToAddress(exe_ctx, name, LLDB_INVALID_ADDRESS, &error); if (addr != LLDB_INVALID_ADDRESS) { if (sign[0] == '+') return addr + offset; >From 58283e15fd2ac6ecb29d24a77b99e883b3a9831a Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Fri, 1 Dec 2023 09:44:28 -0800 Subject: [PATCH 2/3] [lldb][NFC] Remove else after return in OptionArgParse This will enable us to prove that there is unreachable code in this function in a subsequent commit. --- lldb/source/Interpreter/OptionArgParser.cpp | 21 + 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp index 933bc6514ca2418..c61072dfafc19f2 100644 --- a/lldb/source/Interpreter/OptionArgParser.cpp +++ b/lldb/source/Interpreter/OptionArgParser.cpp @@ -168,7 +168,6 @@ lldb::addr_t OptionArgParser::ToAddress(const ExecutionContext *exe_ctx, std::optional OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, Status *error_ptr) { - bool error_set = false; if (s.empty()) { if (error_ptr) error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"", @@ -212,6 +211,7 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, target->EvaluateExpression(s, exe_ctx->GetFramePtr(), valobj_sp, options); bool success = false; + bool error_set = false; if (expr_result == eExpressionCompleted) { if (valobj_sp) valobj_sp = valobj_sp->GetQualifiedRepresentationIfAvailable( @@ -223,16 +223,14 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, if (error_ptr) error_ptr->Clear(); return addr; -} else { - if (error_ptr) { -error_set = true; -error_ptr->SetErrorStringWithFormat( -"address expression \"%s\" resulted in a value whose type " -"can't be converted to an address: %s", -s.str().c_str(), valobj_sp->GetTypeName().GetCString()); - } } - +if (error_ptr) { + error_set = true; + error_ptr->SetErrorStringWithFormat( + "address expression \"%s\" resulted in a value whose type " + "can't be converted to an address: %s", + s.str().c_str(), valobj_sp->GetTypeName().GetCString()); +} } else { // Since the compiler can't handle things like "main + 12" we should try to // do this for now. The compiler doesn't like adding offsets to function @@ -252,8 +250,7 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, if (addr != LLDB_INVALID_ADDRESS) { if (sign[0] == '+') return addr + offset; - else -return addr - offset; + return addr - offset; } } } >From d6a4756ca3d65382a532c59ff89ddc6d57fc
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)
felipepiovezan wrote: > Github makes this look extremely complicated but in my editor this all looks > pretty obvious. LGTM. Yeah, that's part of the reason I tried to break the changes into smaller bits, but it still doesn't look as obvious as I wish it did https://github.com/llvm/llvm-project/pull/74119 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)
JDevlieghere wrote: > > Github makes this look extremely complicated but in my editor this all > > looks pretty obvious. LGTM. > > Yeah, that's part of the reason I tried to break the changes into smaller > bits, but it still doesn't look as obvious as I wish it did I noticed that too late, but also it's more Github's fault than anything. I bet Phabricator would've done a better job! ;-) https://github.com/llvm/llvm-project/pull/74119 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)
https://github.com/bulbazord approved this pull request. 🎉 https://github.com/llvm/llvm-project/pull/74119 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/74119 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [clang-tools-extra] [lld] [libunwind] [lldb] [libcxx] [libc] [compiler-rt] [flang] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { ZijunZhaoCCK wrote: > Should we return false in the case s == 0? This is incorrect. I already correct this on my local side but I haven't upload my change because I am still debugging the warning thing. https://github.com/llvm/llvm-project/pull/71771 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
https://github.com/kevinfrei updated https://github.com/llvm/llvm-project/pull/70996 >From fc24f4c0ba2328009796a09ae2c2c925c773af44 Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Wed, 18 Oct 2023 14:37:34 -0700 Subject: [PATCH 1/9] DEBUGINFOD based DWP acquisition for LLDB Summary: I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic downloading of DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set to a space delimited set of web servers, LLDB will try to use them as a last resort when searching for DWP files. If you do *not* have that environment variable set, nothing should be changed. There's also a setting, per Greg Clayton's request, that will override the env variable, or can be used instead of the env var. This setting is the reason for the additional API added to the llvm's Debuginfod library. Test Plan: Suggestions are welcome here. I should probably have some positive and negative tests, but I wanted to get the diff up for people who have a clue what they're doing to rip it to pieces before spending too much time validating my implementation. --- lldb/include/lldb/Target/Target.h | 3 +++ lldb/source/Core/CoreProperties.td| 2 +- lldb/source/Core/Debugger.cpp | 5 .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 1 + lldb/source/Symbol/CMakeLists.txt | 1 + lldb/source/Target/Target.cpp | 19 +- lldb/source/Target/TargetProperties.td| 4 +++ llvm/include/llvm/Debuginfod/Debuginfod.h | 4 +++ llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++- 9 files changed, 57 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index c37682e2a03859f..7f10f0409fb1315 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + Args GetDebugInfoDURLs() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); @@ -270,6 +272,7 @@ class TargetProperties : public Properties { void DisableASLRValueChangedCallback(); void InheritTCCValueChangedCallback(); void DisableSTDIOValueChangedCallback(); + void DebugInfoDURLsChangedCallback(); // Settings checker for target.jit-save-objects-dir: void CheckJITObjectsDir(); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index 92884258347e9be..865030b0133bbb2 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -4,7 +4,7 @@ let Definition = "modulelist" in { def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">, Global, DefaultTrue, -Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">; +Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched. If all other methods fail, and the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol is used to acquire symbols from a compatible Debuginfod service.">; def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">, Global, DefaultFalse, diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 21f71e449ca5ed0..9a3e82f3e6a2adf 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -61,6 +61,8 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Debuginfod/HTTPClient.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" @@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const { void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) { assert(g_debugger_list_ptr == nullptr && "Debugger::Initialize called more than once!"); + // We might be using the Debuginfod service, s
[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)
@@ -63,13 +68,30 @@ class Progress { /// /// @param [in] title The title of this progress activity. /// + /// @param [in] report_type Enum value indicating how the progress is being + /// reported. Progress reports considered "aggregate" are reports done for + /// operations that may happen multiple times during a debug session. + /// + /// For example, when a debug session is first started it needs to parse the + /// symbol tables for all files that were initially included and this + /// operation will deliver progress reports. If new dSYMs are added later + /// during the session then these will also be parsed and deliver more + /// progress reports. This type of operation would use the + /// eAggregateProgressReport enum. Using this enum would allow these progress + /// reports to be grouped together as one, even though their reports are + /// happening individually. + /// /// @param [in] total The total units of work to be done if specified, if /// set to UINT64_MAX then an indeterminate progress indicator should be /// displayed. /// /// @param [in] debugger An optional debugger pointer to specify that this /// progress is to be reported only to specific debuggers. - Progress(std::string title, uint64_t total = UINT64_MAX, + /// + Progress(std::string title, + ProgressReportType report_type = + ProgressReportType::eNonAggregateProgressReport, chelcassanova wrote: I tried this locally and an error will be throw if you try to use an int place of a `ProgressReportType`. https://github.com/llvm/llvm-project/pull/69516 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/test] Add OpenBSD to _get_platform_os (PR #74036)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/74036 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Simplify pipe2(2) handling on FreeBSD (PR #74019)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/74019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c3f0932 - [lldb] Simplify pipe2(2) handling on FreeBSD (#74019)
Author: Brad Smith Date: 2023-12-01T16:05:38-05:00 New Revision: c3f0932c189e4c11f82a3f8d73d2002e0aa6dab6 URL: https://github.com/llvm/llvm-project/commit/c3f0932c189e4c11f82a3f8d73d2002e0aa6dab6 DIFF: https://github.com/llvm/llvm-project/commit/c3f0932c189e4c11f82a3f8d73d2002e0aa6dab6.diff LOG: [lldb] Simplify pipe2(2) handling on FreeBSD (#74019) FreeBSD 10.x and 11.x support has been dropped leaving 12.x as the minimum version. This FreeBSD check can be simplified. https://github.com/llvm/llvm-project/commit/812dad536ed50abe94d6e2b2519f351791c24c59 Added: Modified: lldb/source/Host/posix/PipePosix.cpp Removed: diff --git a/lldb/source/Host/posix/PipePosix.cpp b/lldb/source/Host/posix/PipePosix.cpp index 6fc4646953b4257..afd3fe39059ac17 100644 --- a/lldb/source/Host/posix/PipePosix.cpp +++ b/lldb/source/Host/posix/PipePosix.cpp @@ -31,8 +31,8 @@ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE // pipe2 is supported by a limited set of platforms // TODO: Add more platforms that support pipe2. -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) || \ -defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \ +defined(__OpenBSD__) #define PIPE2_SUPPORTED 1 #else #define PIPE2_SUPPORTED 0 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 25ea0e9 - [lldb] Make use of LD_LIBRARY_PATH on OpenBSD (#74017)
Author: Brad Smith Date: 2023-12-01T16:06:22-05:00 New Revision: 25ea0e9d9a262d228b1c43ac1906017822dcc365 URL: https://github.com/llvm/llvm-project/commit/25ea0e9d9a262d228b1c43ac1906017822dcc365 DIFF: https://github.com/llvm/llvm-project/commit/25ea0e9d9a262d228b1c43ac1906017822dcc365.diff LOG: [lldb] Make use of LD_LIBRARY_PATH on OpenBSD (#74017) Added: Modified: lldb/packages/Python/lldbsuite/test/lldbplatformutil.py lldb/test/API/lit.cfg.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index 37d06f7e88f98ca..bd92d03e0e22129 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -175,7 +175,7 @@ def __init__( def createPlatformContext(): if platformIsDarwin(): return _PlatformContext("DYLD_LIBRARY_PATH", ":", "lib", "dylib") -elif getPlatform() in ("freebsd", "linux", "netbsd"): +elif getPlatform() in ("linux", "freebsd", "netbsd", "openbsd"): return _PlatformContext("LD_LIBRARY_PATH", ":", "lib", "so") else: return _PlatformContext("PATH", ";", "", "dll") diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index 8b35e8b2a217cf7..12675edc0fd3b9e 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -45,7 +45,7 @@ def find_sanitizer_runtime(name): def find_shlibpath_var(): -if platform.system() in ["Linux", "FreeBSD", "NetBSD", "SunOS"]: +if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]: yield "LD_LIBRARY_PATH" elif platform.system() == "Darwin": yield "DYLD_LIBRARY_PATH" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make use of LD_LIBRARY_PATH on OpenBSD (PR #74017)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/74017 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/69516 >From 028d5b9f706fdf06ee0d9a33228d96660d68f5f0 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 18 Oct 2023 13:07:51 -0700 Subject: [PATCH] [lldb][progress] Add discrete boolean flag to progress reports This commit adds a boolean flag `is_discrete` is to progress reports in LLDB. The flag is set to false by default and indicates if a progress event is discrete, i.e. an operation that has no clear start and end and can happen multiple times during the course of a debug session. Operations that happen in this manner will report multiple individual progress events as they happen, so this flag gives the functionality to group multiple progress events so they can be reported in a less haphazard manner. --- lldb/include/lldb/Core/Debugger.h | 8 +++- lldb/include/lldb/Core/DebuggerEvents.h | 11 +- lldb/include/lldb/Core/Progress.h | 37 --- lldb/source/Core/Debugger.cpp | 17 + lldb/source/Core/DebuggerEvents.cpp | 1 + lldb/source/Core/Progress.cpp | 18 + .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 3 +- .../SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 6 ++- .../TestProgressReporting.py | 13 ++- 10 files changed, 88 insertions(+), 28 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index e4ee94809cf1a09..395ac09a965e05b 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -618,10 +618,16 @@ class Debugger : public std::enable_shared_from_this, /// debugger identifier that this progress should be delivered to. If this /// optional parameter does not have a value, the progress will be /// delivered to all debuggers. + /// + /// \param [in] report_type + /// Indicates whether the operation for which this progress reporting is + /// reporting on will happen as an aggregate of multiple individual + /// progress reports or not. static void ReportProgress(uint64_t progress_id, std::string title, std::string details, uint64_t completed, uint64_t total, - std::optional debugger_id); + std::optional debugger_id, + Progress::ProgressReportType report_type); static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index 982b9701f89..dc933c47dcf53f0 100644 --- a/lldb/include/lldb/Core/DebuggerEvents.h +++ b/lldb/include/lldb/Core/DebuggerEvents.h @@ -7,6 +7,7 @@ //===--===// #include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/Progress.h" #include "lldb/Utility/Event.h" #include "lldb/Utility/StructuredData.h" @@ -21,10 +22,11 @@ class Stream; class ProgressEventData : public EventData { public: ProgressEventData(uint64_t progress_id, std::string title, std::string update, -uint64_t completed, uint64_t total, bool debugger_specific) +uint64_t completed, uint64_t total, bool debugger_specific, +Progress::ProgressReportType report_type) : m_title(std::move(title)), m_details(std::move(update)), m_id(progress_id), m_completed(completed), m_total(total), -m_debugger_specific(debugger_specific) {} +m_debugger_specific(debugger_specific), m_report_type(report_type) {} static llvm::StringRef GetFlavorString(); @@ -52,6 +54,10 @@ class ProgressEventData : public EventData { const std::string &GetTitle() const { return m_title; } const std::string &GetDetails() const { return m_details; } bool IsDebuggerSpecific() const { return m_debugger_specific; } + bool IsAggregate() const { +return m_report_type == + Progress::ProgressReportType::eAggregateProgressReport; + } private: /// The title of this progress event. The value is expected to remain stable @@ -68,6 +74,7 @@ class ProgressEventData : public EventData { uint64_t m_completed; const uint64_t m_total; const bool m_debugger_specific; + const Progress::ProgressReportType m_report_type; ProgressEventData(const ProgressEventData &) = delete; const ProgressEventData &operator=(const ProgressEventData &) = delete; }; diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index b2b8781a43b0591..803f984f345ded6 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -55,6 +55,11 @@ namespace lldb_private { class Progress { public: + /// Enum that indicates the type of pro
[Lldb-commits] [flang] [clang-tools-extra] [llvm] [libcxx] [libc] [lld] [lldb] [clang] [compiler-rt] [libunwind] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/71771 Sorry, this diff is unavailable. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [clang-tools-extra] [llvm] [libcxx] [libc] [lld] [lldb] [clang] [compiler-rt] [mlir] [libunwind] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/71771 >From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Thu, 9 Nov 2023 02:21:46 + Subject: [PATCH 1/3] Fix clang to recognize new C23 modifiers %w and %wf when printing --- clang/include/clang/AST/FormatString.h | 16 +++- clang/lib/AST/FormatString.cpp | 52 +- clang/lib/AST/PrintfFormatString.cpp | 19 ++ clang/test/Sema/format-strings-ms.c| 28 ++ 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/AST/FormatString.h b/clang/include/clang/AST/FormatString.h index 5c4ad9baaef608c..6a886854650f1d9 100644 --- a/clang/include/clang/AST/FormatString.h +++ b/clang/include/clang/AST/FormatString.h @@ -81,8 +81,10 @@ class LengthModifier { AsLongDouble, // 'L' AsAllocate, // for '%as', GNU extension to C90 scanf AsMAllocate, // for '%ms', GNU extension to scanf -AsWide, // 'w' (MSVCRT, like l but only for c, C, s, S, or Z -AsWideChar = AsLong // for '%ls', only makes sense for printf +AsWide, // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on windows + // 2. for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) +AsWideFast, // 'wf' (for b, d, i, o, u, x, or X) +AsWideChar = AsLong, // for '%ls', only makes sense for printf }; LengthModifier() @@ -417,6 +419,7 @@ class FormatSpecifier { /// http://www.opengroup.org/onlinepubs/009695399/functions/printf.html bool UsesPositionalArg; unsigned argIndex; + unsigned size; public: FormatSpecifier(bool isPrintf) : CS(isPrintf), VectorNumElts(false), @@ -460,6 +463,15 @@ class FormatSpecifier { FieldWidth = Amt; } + void setSize(unsigned s) { +size = s; + } + + unsigned getSize() const { +return size; + } + + bool usesPositionalArg() const { return UsesPositionalArg; } bool hasValidLengthModifier(const TargetInfo &Target, diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a243..ebc136e780717e4 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { +std::set supported_list {8, 16, 32, 64}; +if (supported_list.count(s) == 0) { + return false; +} +FS.setSize(s); + } + + break; } LengthModifier lm(lmPosition, lmKind); FS.setLengthModifier(lm); @@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const { return "m"; case AsWide: return "w"; + case AsWideFast: +return "wf"; case None: return ""; } @@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target, case ConversionSpecifier::SArg: case ConversionSpecifier::ZArg: return Target.getTriple().isOSMSVCRT(); +case ConversionSpecifier::bArg: +case ConversionSpecifier::dArg: +case ConversionSpecifier::iArg: +case ConversionSpecifier::oArg: +case ConversionSpecifier::uArg: +case ConversionSpecifier::xArg: +case ConversionSpecifier::XArg: + return true; +default: + return false; + } +case LengthModifier::AsWideFast: + switch (CS.getKind()) { +case ConversionSpecifier::bArg: +case ConversionSpecifier::dArg: +case ConversionSpecifier::iArg: +case ConversionSpecifier::oArg: +case ConversionSpecifier::uArg: +case ConversionSpecifier::xArg: +case ConversionSpecifier::XArg: + return true; default: return false; } @@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const { case LengthModifier::AsInt3264: case LengthModifier::AsInt64: case LengthModifier::AsWide: +case LengthModifier::AsWideFast: case LengthModifier::AsShortLong: // ??? return false; } diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp index f0b9d0ecaf23461..4b9111e8bcf509a 100644 --- a/clang/lib/AST/PrintfFormatString.cpp +++ b/clang/l
[Lldb-commits] [flang] [clang-tools-extra] [llvm] [libcxx] [libc] [lld] [lldb] [clang] [compiler-rt] [mlir] [libunwind] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/71771 >From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Thu, 9 Nov 2023 02:21:46 + Subject: [PATCH 1/4] Fix clang to recognize new C23 modifiers %w and %wf when printing --- clang/include/clang/AST/FormatString.h | 16 +++- clang/lib/AST/FormatString.cpp | 52 +- clang/lib/AST/PrintfFormatString.cpp | 19 ++ clang/test/Sema/format-strings-ms.c| 28 ++ 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/AST/FormatString.h b/clang/include/clang/AST/FormatString.h index 5c4ad9baaef608c..6a886854650f1d9 100644 --- a/clang/include/clang/AST/FormatString.h +++ b/clang/include/clang/AST/FormatString.h @@ -81,8 +81,10 @@ class LengthModifier { AsLongDouble, // 'L' AsAllocate, // for '%as', GNU extension to C90 scanf AsMAllocate, // for '%ms', GNU extension to scanf -AsWide, // 'w' (MSVCRT, like l but only for c, C, s, S, or Z -AsWideChar = AsLong // for '%ls', only makes sense for printf +AsWide, // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on windows + // 2. for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) +AsWideFast, // 'wf' (for b, d, i, o, u, x, or X) +AsWideChar = AsLong, // for '%ls', only makes sense for printf }; LengthModifier() @@ -417,6 +419,7 @@ class FormatSpecifier { /// http://www.opengroup.org/onlinepubs/009695399/functions/printf.html bool UsesPositionalArg; unsigned argIndex; + unsigned size; public: FormatSpecifier(bool isPrintf) : CS(isPrintf), VectorNumElts(false), @@ -460,6 +463,15 @@ class FormatSpecifier { FieldWidth = Amt; } + void setSize(unsigned s) { +size = s; + } + + unsigned getSize() const { +return size; + } + + bool usesPositionalArg() const { return UsesPositionalArg; } bool hasValidLengthModifier(const TargetInfo &Target, diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a243..ebc136e780717e4 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { +std::set supported_list {8, 16, 32, 64}; +if (supported_list.count(s) == 0) { + return false; +} +FS.setSize(s); + } + + break; } LengthModifier lm(lmPosition, lmKind); FS.setLengthModifier(lm); @@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const { return "m"; case AsWide: return "w"; + case AsWideFast: +return "wf"; case None: return ""; } @@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target, case ConversionSpecifier::SArg: case ConversionSpecifier::ZArg: return Target.getTriple().isOSMSVCRT(); +case ConversionSpecifier::bArg: +case ConversionSpecifier::dArg: +case ConversionSpecifier::iArg: +case ConversionSpecifier::oArg: +case ConversionSpecifier::uArg: +case ConversionSpecifier::xArg: +case ConversionSpecifier::XArg: + return true; +default: + return false; + } +case LengthModifier::AsWideFast: + switch (CS.getKind()) { +case ConversionSpecifier::bArg: +case ConversionSpecifier::dArg: +case ConversionSpecifier::iArg: +case ConversionSpecifier::oArg: +case ConversionSpecifier::uArg: +case ConversionSpecifier::xArg: +case ConversionSpecifier::XArg: + return true; default: return false; } @@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const { case LengthModifier::AsInt3264: case LengthModifier::AsInt64: case LengthModifier::AsWide: +case LengthModifier::AsWideFast: case LengthModifier::AsShortLong: // ??? return false; } diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp index f0b9d0ecaf23461..4b9111e8bcf509a 100644 --- a/clang/lib/AST/PrintfFormatString.cpp +++ b/clang/l
[Lldb-commits] [flang] [clang-tools-extra] [llvm] [libcxx] [libc] [lld] [lldb] [clang] [compiler-rt] [mlir] [libunwind] Fix clang to recognize new C23 modifiers %w and %wf when printing and scanning (
https://github.com/ZijunZhaoCCK edited https://github.com/llvm/llvm-project/pull/71771 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits