[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-22 Thread Yanzuo Liu via lldb-commits


@@ -74,16 +75,31 @@ class formatv_object_base {
   static std::pair
   splitLiteralAndReplacement(StringRef Fmt);
 
-  formatv_object_base(StringRef Fmt,
+  formatv_object_base(StringRef Fmt, bool ValidateNumArgs,
   ArrayRef Adapters)
-  : Fmt(Fmt), Adapters(Adapters) {}
+  : Fmt(Fmt), ValidateNumArgs(ValidateNumArgs), Adapters(Adapters) {}
 
   formatv_object_base(formatv_object_base const &rhs) = delete;
   formatv_object_base(formatv_object_base &&rhs) = default;
 
 public:
   void format(raw_ostream &S) const {
-for (auto &R : parseFormatString(Fmt)) {
+const auto [Replacements, NumExpectedParams] = parseFormatString(Fmt);
+// Fail formatv() call if the number of replacement parameters provided
+// does not match the expected number after parsing the format string.
+// Assert in debug builds.
+if (ValidateNumArgs && NumExpectedParams != Adapters.size()) {
+  errs() << "Invalid format() in formatv: " << Fmt << "\n";
+  assert(0 &&
+ "Mismatch between replacement parameters expected and provided");
+
+  S << "formatv() error: " << NumExpectedParams
+<< " replacement parameters expected, but " << Adapters.size()
+<< " provided";

zwuis wrote:

Do we need to add a `\n` here?

https://github.com/llvm/llvm-project/pull/105745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [clang][DebugInfo] Expand detection of structured bindings to account for std::get free function (PR #122265)

2025-01-10 Thread Yanzuo Liu via lldb-commits

zwuis wrote:

Do we need a test case about explicit object member function? i.e.
```cpp
template int get(this triple);
template<> int get<0>(this triple t) { return /* ... */; }
```

https://github.com/llvm/llvm-project/pull/122265
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [Clang][AST][NFC] (`RecordDecl` -> `CXXRecordDecl`)`::isInjectedClassName` (PR #148195)

2025-07-12 Thread Yanzuo Liu via lldb-commits

https://github.com/zwuis closed https://github.com/llvm/llvm-project/pull/148195
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [Clang][AST][NFC] (`RecordDecl` -> `CXXRecordDecl`)`::isInjectedClassName` (PR #148195)

2025-07-12 Thread Yanzuo Liu via lldb-commits

zwuis wrote:

Thanks for your review.

https://github.com/llvm/llvm-project/pull/148195
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [Clang][AST][NFC] (`RecordDecl` -> `CXXRecordDecl`)`::isInjectedClassName` (PR #148195)

2025-07-11 Thread Yanzuo Liu via lldb-commits

zwuis wrote:

> > I'm not sure if I should update 
> > `llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc` and 
> > `libcxxabi/test/DemangleTestCases.inc`.
> 
> Why would you need to? There are no changes to mangling/demangling here AFAICT

These files test demangling `RecordDecl::isInjectedClassName`, which will be 
out-of-date (I think) after merging this PR.

https://github.com/llvm/llvm-project/pull/148195
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [Clang][AST][NFC] (`RecordDecl` -> `CXXRecordDecl`)`::isInjectedClassName` (PR #148195)

2025-07-11 Thread Yanzuo Liu via lldb-commits

https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/148195
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [Clang][AST][NFC] (`RecordDecl` -> `CXXRecordDecl`)`::isInjectedClassName` (PR #148195)

2025-07-11 Thread Yanzuo Liu via lldb-commits

https://github.com/zwuis created 
https://github.com/llvm/llvm-project/pull/148195

Co-authored-by: Matheus Izvekov 

>From 306049aa7dd17f6683935d631b3ad222b268a3f2 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Fri, 11 Jul 2025 18:17:05 +0800
Subject: [PATCH] (`RecordDecl` -> `CXXRecordDecl`)`::isInjectedClassName`

---
 clang-tools-extra/clangd/CodeComplete.cpp  |  2 +-
 clang-tools-extra/clangd/Quality.cpp   |  2 +-
 .../clangd/SemanticHighlighting.cpp|  2 +-
 clang/include/clang/AST/Decl.h | 15 ---
 clang/include/clang/AST/DeclCXX.h  | 18 --
 clang/lib/AST/Decl.cpp |  5 -
 clang/lib/AST/DeclCXX.cpp  | 10 ++
 clang/lib/Sema/SemaAccess.cpp  |  3 ++-
 .../Clang/ClangASTImporter.cpp |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp   |  5 -
 10 files changed, 36 insertions(+), 28 deletions(-)

diff --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 14679fea6ac8a..d5907e3143bf6 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -870,7 +870,7 @@ bool contextAllowsIndex(enum CodeCompletionContext::Kind K) 
{
 }
 
 static bool isInjectedClass(const NamedDecl &D) {
-  if (auto *R = dyn_cast_or_null(&D))
+  if (auto *R = dyn_cast_or_null(&D))
 if (R->isInjectedClassName())
   return true;
   return false;
diff --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index c1ab63fb22f61..3f630b05c654b 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -258,7 +258,7 @@ static SymbolRelevanceSignals::AccessibleScope
 computeScope(const NamedDecl *D) {
   // Injected "Foo" within the class "Foo" has file scope, not class scope.
   const DeclContext *DC = D->getDeclContext();
-  if (auto *R = dyn_cast_or_null(D))
+  if (auto *R = dyn_cast_or_null(D))
 if (R->isInjectedClassName())
   DC = DC->getParent();
   // Class constructor should have the same scope as the class.
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index dc574dcd11703..e6d5cf7053694 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -597,7 +597,7 @@ class HighlightingsBuilder {
 std::optional scopeModifier(const NamedDecl *D) {
   const DeclContext *DC = D->getDeclContext();
   // Injected "Foo" within the class "Foo" has file scope, not class scope.
-  if (auto *R = dyn_cast_or_null(D))
+  if (auto *R = dyn_cast_or_null(D))
 if (R->isInjectedClassName())
   DC = DC->getParent();
   // Lambda captures are considered function scope, not class scope.
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index de79a9df29a5b..3d7969cca83fd 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4420,21 +4420,6 @@ class RecordDecl : public TagDecl {
 
   void reorderDecls(const SmallVectorImpl &Decls);
 
-  /// Determines whether this declaration represents the
-  /// injected class name.
-  ///
-  /// The injected class name in C++ is the name of the class that
-  /// appears inside the class itself. For example:
-  ///
-  /// \code
-  /// struct C {
-  ///   // C is implicitly declared here as a synonym for the class name.
-  /// };
-  ///
-  /// C::C c; // same as "C c;"
-  /// \endcode
-  bool isInjectedClassName() const;
-
   /// Determine whether this record is a class describing a lambda
   /// function object.
   bool isLambda() const;
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 05cddd024d7cf..77bc3cad72ed9 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -546,8 +546,7 @@ class CXXRecordDecl : public RecordDecl {
   }
 
   CXXRecordDecl *getMostRecentNonInjectedDecl() {
-CXXRecordDecl *Recent =
-static_cast(this)->getMostRecentDecl();
+CXXRecordDecl *Recent = getMostRecentDecl();
 while (Recent->isInjectedClassName()) {
   // FIXME: Does injected class name need to be in the redeclarations 
chain?
   assert(Recent->getPreviousDecl());
@@ -1889,6 +1888,21 @@ class CXXRecordDecl : public RecordDecl {
 DL.IsGenericLambda = IsGeneric;
   }
 
+  /// Determines whether this declaration represents the
+  /// injected class name.
+  ///
+  /// The injected class name in C++ is the name of the class that
+  /// appears inside the class itself. For example:
+  ///
+  /// \code
+  /// struct C {
+  ///   // C is implicitly declared here as a synonym for the class name.
+  /// };
+  ///
+  /// C::C c; // same as "C c;"
+  /// \endcode
+  bool isInjectedClassName() const;
+
   // Determine whether this type is an Interface Like type for
   // __interface inheritance purposes.
   bo

[Lldb-commits] [clang] [clang-tools-extra] [lldb] [Clang][AST][NFC] (`RecordDecl` -> `CXXRecordDecl`)`::isInjectedClassName` (PR #148195)

2025-07-11 Thread Yanzuo Liu via lldb-commits

zwuis wrote:

I'm not sure if I should update 
`llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc` and 
`libcxxabi/test/DemangleTestCases.inc`.

https://github.com/llvm/llvm-project/pull/148195
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [clang] remove IsDefaulted bit from TemplateArgument (PR #155120)

2025-08-23 Thread Yanzuo Liu via lldb-commits


@@ -95,24 +95,25 @@ TC
 https://github.com/llvm/llvm-project/pull/155120
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits