[clang] [libcxxabi] [llvm] [WIP][Clang] Mangling of pack indexing type and expression for itanium (PR #123513)

2025-01-19 Thread via cfe-commits

https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/123513

None

>From 1b016f8b86eb004568e2779d19cc030e8c487762 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Sun, 19 Jan 2025 15:08:52 +0100
Subject: [PATCH] [WIP][Clang] Mangling of pack indexing type and expression
 for itanium

---
 clang/lib/AST/ItaniumMangle.cpp  | 47 +--
 libcxxabi/src/demangle/ItaniumDemangle.h | 44 ++
 libcxxabi/src/demangle/ItaniumNodes.def  |  2 +-
 libcxxabi/test/test_demangle.pass.cpp|  5 ++
 llvm/include/llvm/Demangle/ItaniumDemangle.h | 49 
 llvm/include/llvm/Demangle/ItaniumNodes.def  |  1 +
 6 files changed, 134 insertions(+), 14 deletions(-)

diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 1dd936cf4fb518..e8709425394e5c 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -603,6 +603,7 @@ class CXXNameMangler {
   void mangleInitListElements(const InitListExpr *InitList);
   void mangleRequirement(SourceLocation RequiresExprLoc,
  const concepts::Requirement *Req);
+  void mangleReferenceToPack(const NamedDecl* ND);
   void mangleExpression(const Expr *E, unsigned Arity = UnknownArity,
 bool AsTemplateArg = false);
   void mangleCXXCtorType(CXXCtorType T, const CXXRecordDecl *InheritedFrom);
@@ -4348,8 +4349,12 @@ void CXXNameMangler::mangleType(const PackExpansionType 
*T) {
 }
 
 void CXXNameMangler::mangleType(const PackIndexingType *T) {
-  if (!T->hasSelectedType())
+  //   ::= Dy# pack indexing type (C++23)
+  if (!T->hasSelectedType()) {
+Out << "Dy";
 mangleType(T->getPattern());
+mangleExpression(T->getIndexExpr());
+  }
   else
 mangleType(T->getSelectedType());
 }
@@ -4785,6 +4790,19 @@ void CXXNameMangler::mangleRequirement(SourceLocation 
RequiresExprLoc,
   }
 }
 
+void CXXNameMangler::mangleReferenceToPack(const NamedDecl* Pack) {
+if (const TemplateTypeParmDecl *TTP = dyn_cast(Pack))
+mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
+else if (const NonTypeTemplateParmDecl *NTTP
+  = dyn_cast(Pack))
+mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
+else if (const TemplateTemplateParmDecl *TempTP
+  = dyn_cast(Pack))
+mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
+else
+mangleFunctionParam(cast(Pack));
+}
+
 void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity,
   bool AsTemplateArg) {
   //  ::=  
@@ -4803,6 +4821,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, 
unsigned Arity,
   //  ::= fpT# 'this' expression (part 
of )
   //  ::= sr # 
dependent name
   //  ::= sr  # 
dependent template-id
+  //  ::= sy # pack 
indexing expression
   //  ::= ds # 
expr.*expr
   //  ::= sZ # size of 
a parameter pack
   //  ::= sZ # size of a function parameter 
pack
@@ -4886,7 +4905,6 @@ void CXXNameMangler::mangleExpression(const Expr *E, 
unsigned Arity,
   case Expr::OMPIteratorExprClass:
   case Expr::CXXInheritedCtorInitExprClass:
   case Expr::CXXParenListInitExprClass:
-  case Expr::PackIndexingExprClass:
 llvm_unreachable("unexpected statement kind");
 
   case Expr::ConstantExprClass:
@@ -5788,17 +5806,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, 
unsigned Arity,
 }
 
 Out << "sZ";
-const NamedDecl *Pack = SPE->getPack();
-if (const TemplateTypeParmDecl *TTP = dyn_cast(Pack))
-  mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
-else if (const NonTypeTemplateParmDecl *NTTP
-= dyn_cast(Pack))
-  mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
-else if (const TemplateTemplateParmDecl *TempTP
-= dyn_cast(Pack))
-  mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
-else
-  mangleFunctionParam(cast(Pack));
+mangleReferenceToPack(SPE->getPack());
 break;
   }
 
@@ -5828,6 +5836,19 @@ void CXXNameMangler::mangleExpression(const Expr *E, 
unsigned Arity,
 break;
   }
 
+  case Expr::PackIndexingExprClass: {
+  auto *PE = cast(E);
+  if(PE->isFullySubstituted()) {
+  E = PE->getSelectedExpr();
+  goto recurse;
+  }
+  NotPrimaryExpr();
+  Out << "sy";
+  mangleReferenceToPack(PE->getPackDecl());
+  mangleExpression(PE->getIndexExpr());
+  break;
+  }
+
   case Expr::CXXThisExprClass:
 NotPrimaryExpr();
 Out << "fpT";
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h 
b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3df41b5f4d7d07..a65de9fee4a208 100644
--- a/li

[clang] [libcxxabi] [llvm] [WIP][Clang] Mangling of pack indexing type and expression for itanium (PR #123513)

2025-01-19 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 7dd34baf5505d689161c3a8678322a394d7a2929 
1b016f8b86eb004568e2779d19cc030e8c487762 --extensions cpp,h -- 
clang/lib/AST/ItaniumMangle.cpp libcxxabi/src/demangle/ItaniumDemangle.h 
libcxxabi/test/test_demangle.pass.cpp 
llvm/include/llvm/Demangle/ItaniumDemangle.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index e870942539..ddf401f993 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -603,7 +603,7 @@ private:
   void mangleInitListElements(const InitListExpr *InitList);
   void mangleRequirement(SourceLocation RequiresExprLoc,
  const concepts::Requirement *Req);
-  void mangleReferenceToPack(const NamedDecl* ND);
+  void mangleReferenceToPack(const NamedDecl *ND);
   void mangleExpression(const Expr *E, unsigned Arity = UnknownArity,
 bool AsTemplateArg = false);
   void mangleCXXCtorType(CXXCtorType T, const CXXRecordDecl *InheritedFrom);
@@ -4354,8 +4354,7 @@ void CXXNameMangler::mangleType(const PackIndexingType 
*T) {
 Out << "Dy";
 mangleType(T->getPattern());
 mangleExpression(T->getIndexExpr());
-  }
-  else
+  } else
 mangleType(T->getSelectedType());
 }
 
@@ -4790,49 +4789,65 @@ void CXXNameMangler::mangleRequirement(SourceLocation 
RequiresExprLoc,
   }
 }
 
-void CXXNameMangler::mangleReferenceToPack(const NamedDecl* Pack) {
-if (const TemplateTypeParmDecl *TTP = dyn_cast(Pack))
-mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
-else if (const NonTypeTemplateParmDecl *NTTP
-  = dyn_cast(Pack))
-mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
-else if (const TemplateTemplateParmDecl *TempTP
-  = dyn_cast(Pack))
-mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
-else
-mangleFunctionParam(cast(Pack));
+void CXXNameMangler::mangleReferenceToPack(const NamedDecl *Pack) {
+  if (const TemplateTypeParmDecl *TTP = dyn_cast(Pack))
+mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
+  else if (const NonTypeTemplateParmDecl *NTTP =
+   dyn_cast(Pack))
+mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
+  else if (const TemplateTemplateParmDecl *TempTP =
+   dyn_cast(Pack))
+mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
+  else
+mangleFunctionParam(cast(Pack));
 }
 
 void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity,
   bool AsTemplateArg) {
   //  ::=  
   //  ::=   
-  //  ::=

-  //  ::= cv  expression   # conversion with one 
argument
-  //  ::= cv  _ * E # conversion with a 
different number of arguments
-  //  ::= dc   # dynamic_cast 
(expression)
-  //  ::= sc   # static_cast 
(expression)
-  //  ::= cc   # const_cast 
(expression)
-  //  ::= rc   # reinterpret_cast 
(expression)
+  //  ::=   
+  //  
+  //  ::= cv  expression   # conversion with one
+  //  argument
+  //  ::= cv  _ * E # conversion with a different
+  //  number of arguments
+  //  ::= dc   # dynamic_cast
+  //  (expression)
+  //  ::= sc   # static_cast
+  //  (expression)
+  //  ::= cc   # const_cast
+  //  (expression)
+  //  ::= rc   # reinterpret_cast
+  //  (expression)
   //  ::= st   # sizeof (a type)
   //  ::= at   # alignof (a type)
   //  ::= 
   //  ::= 
-  //  ::= fpT# 'this' expression (part 
of )
-  //  ::= sr # 
dependent name
-  //  ::= sr  # 
dependent template-id
-  //  ::= sy # pack 
indexing expression
-  //  ::= ds # 
expr.*expr
-  //  ::= sZ # size of 
a parameter pack
+  //  ::= fpT# 'this' expression (part
+  //  of )
+  //  ::= sr # 
dependent
+  //  name
+  //  ::= sr  # 
dependent
+  //  template-id
+  //  ::= sy # pack
+  //  indexing expression
+  //  ::= ds #
+  //  expr.*expr
+  //  ::= sZ 

[clang] [Clang] Add GCC's __builtin_stack_address() to Clang. (PR #121332)

2025-01-19 Thread via cfe-commits

aalhwc wrote:

@philnik777 does this new version of the patch address your comment?

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


[clang] 0ab1f57 - [clang][bytecode] Register decomposition holding vars (#123515)

2025-01-19 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-01-19T16:29:56+01:00
New Revision: 0ab1f5772cbe6855d55bade566d885b7504c32ee

URL: 
https://github.com/llvm/llvm-project/commit/0ab1f5772cbe6855d55bade566d885b7504c32ee
DIFF: 
https://github.com/llvm/llvm-project/commit/0ab1f5772cbe6855d55bade566d885b7504c32ee.diff

LOG: [clang][bytecode] Register decomposition holding vars (#123515)

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/cxx17.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7afae97f308ad5..414323eaa12654 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4984,6 +4984,15 @@ bool Compiler::visitDeclStmt(const DeclStmt 
*DS) {
   return false;
 if (!this->visitVarDecl(VD))
   return false;
+
+// Register decomposition decl holding vars.
+if (const auto *DD = dyn_cast(VD)) {
+  for (auto *BD : DD->bindings())
+if (auto *KD = BD->getHoldingVar()) {
+  if (!this->visitVarDecl(KD))
+return false;
+}
+}
   }
 
   return true;

diff  --git a/clang/test/AST/ByteCode/cxx17.cpp 
b/clang/test/AST/ByteCode/cxx17.cpp
index e8559d8b9812ac..ecb8a395520a05 100644
--- a/clang/test/AST/ByteCode/cxx17.cpp
+++ b/clang/test/AST/ByteCode/cxx17.cpp
@@ -105,3 +105,23 @@ constexpr S s = getS(); // both-error {{must be 
initialized by a constant expres
 // both-note {{declared here}}
 static_assert(s.a == 12, ""); // both-error {{not an integral constant 
expression}} \
   // both-note {{initializer of 's' is not a 
constant expression}}
+
+using size_t = decltype(sizeof(0));
+namespace std { template struct tuple_size; }
+namespace std { template struct tuple_element; }
+
+namespace constant {
+  struct Q {};
+  template constexpr int get(Q &&) { return N * N; }
+}
+template<> struct std::tuple_size { static const int value = 3; };
+template struct std::tuple_element { typedef int type; 
};
+
+namespace constant {
+  Q q;
+  constexpr bool f() {
+auto [a, b, c] = q;
+return a == 0 && b == 1 && c == 4;
+  }
+  static_assert(f());
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Register decomposition holding vars (PR #123515)

2025-01-19 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr closed 
https://github.com/llvm/llvm-project/pull/123515
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM.
Do you need us to merge that for you?

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


[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread Manuel Sainz de Baranda y Goñi via cfe-commits

redcode wrote:

> This seems related to #85995. Do you plan to fix that issue together?

I wasn't planning on fixing Clang's ``, I thought it would be better 
handled by the maintainers of the standard library, but I can do it if you want.

Do you want me to do it?

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


[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

> > This seems related to #85995. Do you plan to fix that issue together?
> 
> I wasn't planning on fixing Clang's ``, I thought it would be 
> better handled by the maintainers of the standard library, but I can do it if 
> you want.
> 
> Do you want me to do it?

Oh, I didn't mean that. It might be better to do that in a separated PR.

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


[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread Manuel Sainz de Baranda y Goñi via cfe-commits

redcode wrote:

> > > This seems related to #85995. Do you plan to fix that issue together?
> > 
> > 
> > I wasn't planning on fixing Clang's ``, I thought it would be 
> > better handled by the maintainers of the standard library, but I can do it 
> > if you want.
> > Do you want me to do it?
> 
> Oh, I didn't mean that. It might be better to do that in a separated PR.

OK, then I'll fix it in a separate PR.


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


[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)

2025-01-19 Thread Jeremy Rifkin via cfe-commits

jeremy-rifkin wrote:

There are implications with #123166, which might also be clang 21 material

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


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

DeNiCoN wrote:

@cor3ntin Yes. Thank you. Should I squash the commits or this can be done on 
your side?

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


[clang] 293dbea - Fix some typos (#123506)

2025-01-19 Thread via cfe-commits

Author: DeNiCoN
Date: 2025-01-19T16:53:39+01:00
New Revision: 293dbea8b0169525d93a4ee4b7d6c53aa9d4bee0

URL: 
https://github.com/llvm/llvm-project/commit/293dbea8b0169525d93a4ee4b7d6c53aa9d4bee0
DIFF: 
https://github.com/llvm/llvm-project/commit/293dbea8b0169525d93a4ee4b7d6c53aa9d4bee0.diff

LOG: Fix some typos (#123506)

Fixes some typos in the documentation

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/Contributing.rst
clang/docs/ClangTransformerTutorial.rst
llvm/docs/DeveloperPolicy.rst
llvm/docs/GitHub.rst
llvm/docs/MyFirstTypoFix.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index ff8b05ff263c14..4f1df8d114 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -331,7 +331,7 @@ a starting point for your test cases.  A rough outline of 
the process looks like
 - Issue the necessary diagnostics and fix-its in the ``check`` method.
 - Add the necessary ``CHECK-MESSAGES`` and ``CHECK-FIXES`` annotations to your
   test case to validate the diagnostics and fix-its.
-- Build the target ``check-clang-tool`` to confirm the test passes.
+- Build the target ``check-clang-tools`` to confirm the test passes.
 - Repeat the process until all aspects of your check are covered by tests.
 
 The quickest way to prototype your matcher is to use :program:`clang-query` to
@@ -519,8 +519,8 @@ the check implements and what the current values are (e.g. 
for the
   public:
 MyCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-SomeOption(Options.get("SomeOption1", -1U)),
-SomeOption(Options.get("SomeOption2", "some default")) {}
+SomeOption1(Options.get("SomeOption1", -1U)),
+SomeOption2(Options.get("SomeOption2", "some default")) {}
 
 void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
   Options.store(Opts, "SomeOption1", SomeOption1);

diff  --git a/clang/docs/ClangTransformerTutorial.rst 
b/clang/docs/ClangTransformerTutorial.rst
index b07b83f80f17d1..e9b701203300a2 100644
--- a/clang/docs/ClangTransformerTutorial.rst
+++ b/clang/docs/ClangTransformerTutorial.rst
@@ -70,7 +70,7 @@ can express this a Transformer rewrite rule:
 
 .. code-block:: c++
 
-   makeRule(functionDecl(hasName("MkX").bind("fun"),
+   makeRule(functionDecl(hasName("MkX")).bind("fun"),
noopEdit(node("fun")),
cat("The name ``MkX`` is not allowed for functions; please 
rename"));
 

diff  --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 6614d036a014e9..18b05d2e58e6e5 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -136,7 +136,7 @@ awareness of. For such changes, the following should be 
done:
 
 .. warning::
 
-  Phabricator is deprecated is available in read-only mode,
+  Phabricator is deprecated and is available in read-only mode,
   for new code contributions use :ref:`GitHub Pull Requests `.
   This section contains old information that needs to be updated.
 

diff  --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 85766bfe94afd2..892b8abcc2d4e2 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add the `skip-precommit-approval 
`_
label to the PR.
 
 GitHub Tools

diff  --git a/llvm/docs/MyFirstTypoFix.rst b/llvm/docs/MyFirstTypoFix.rst
index 733b3eac141f27..5856615bee8bfa 100644
--- a/llvm/docs/MyFirstTypoFix.rst
+++ b/llvm/docs/MyFirstTypoFix.rst
@@ -378,7 +378,7 @@ your branch with more commits and push to your GitHub fork 
of ``llvm-project``.
 It is best if you answer comments from the reviewer directly instead of 
expecting
 them to read through all the changes again.
 
-For example you might comment "I have done this." or "I was able to this part
+For example you might comment "I have done this." or "I was able to do this 
part
 but have a question about...".
 
 Review expectations



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

https://github.com/cor3ntin closed 
https://github.com/llvm/llvm-project/pull/123506
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Register decomposition holding vars (PR #123515)

2025-01-19 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-libc-amdgpu-runtime` running on `omp-vega20-1` while building 
`clang` at step 7 "Add check check-offload".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/73/builds/11979


Here is the relevant piece of the build log for the reference

```
Step 7 (Add check check-offload) failure: test (failure)
 TEST 'libomptarget :: amdgcn-amd-amdhsa :: 
offloading/pgo1.c' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib
  -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 -Xoffload-linker -lc -Xoffload-linker -lm 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fprofile-instr-generate  -Xclang "-fprofile-instrument=clang"
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp -I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib
 -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 -Xoffload-linker -lc -Xoffload-linker -lm 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fprofile-instr-generate -Xclang -fprofile-instrument=clang
# RUN: at line 3
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 2>&1 | 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
  --check-prefix="CLANG-PGO"
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 --check-prefix=CLANG-PGO
# .---command stderr
# | 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c:32:20:
 error: CLANG-PGO-NEXT: expected string not found in input
# | // CLANG-PGO-NEXT: [ 0 11 20 ]
# |^
# | :3:28: note: scanning from here
# |  Counters =
# |^
# | :4:1: note: possible intended match here
# | [ 0 13 20 ]
# | ^
# | 
# | Input file: 
# | Check file: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<
# |1: === GPU Profile === 
# |2: Target: amdgcn-amd-amdhsa 
# |3:  Counters = 
# | ne

[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

github-actions[bot] wrote:



@DeNiCoN Congratulations on having your first Pull Request (PR) merged into the 
LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building 
`clang-tools-extra,clang,llvm` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/59/builds/11328


Here is the relevant piece of the build log for the reference

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: commands/log/invalid-args/TestInvalidArgsLog.py (167 of 2071)
PASS: lldb-api :: commands/frame/recognizer/TestFrameRecognizer.py (168 of 2071)
PASS: lldb-api :: commands/platform/basic/TestPlatformCommand.py (169 of 2071)
PASS: lldb-api :: commands/memory/write/TestMemoryWrite.py (170 of 2071)
PASS: lldb-api :: commands/platform/basic/TestPlatformPython.py (171 of 2071)
PASS: lldb-api :: commands/platform/file/close/TestPlatformFileClose.py (172 of 
2071)
PASS: lldb-api :: commands/platform/file/read/TestPlatformFileRead.py (173 of 
2071)
PASS: lldb-api :: commands/memory/read/TestMemoryRead.py (174 of 2071)
PASS: lldb-api :: commands/platform/connect/TestPlatformConnect.py (175 of 2071)
UNRESOLVED: lldb-api :: commands/gui/spawn-threads/TestGuiSpawnThreads.py (176 
of 2071)
 TEST 'lldb-api :: 
commands/gui/spawn-threads/TestGuiSpawnThreads.py' FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/commands/gui/spawn-threads
 -p TestGuiSpawnThreads.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 20.0.0git (https://github.com/llvm/llvm-project.git revision 
293dbea8b0169525d93a4ee4b7d6c53aa9d4bee0)
  clang revision 293dbea8b0169525d93a4ee4b7d6c53aa9d4bee0
  llvm revision 293dbea8b0169525d93a4ee4b7d6c53aa9d4bee0
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_gui (TestGuiSpawnThreads.TestGuiSpawnThreadsTest)
==
ERROR: test_gui (TestGuiSpawnThreads.TestGuiSpawnThreadsTest)
--
Traceback (most recent call last):
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 148, in wrapper
return func(*args, **kwargs)
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py",
 line 44, in test_gui
self.child.expect_exact(f"thread #{i + 2}: tid =")
  File "/usr/local/lib/python3.10/dist-packages/pexpect/spawnbase.py", line 
432, in expect_exact
return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.10/dist-packages/pexpect/expect.py", line 179, 
in expect_loop
return self.eof(e)
  File "/usr/local/lib/python3.10/dist-packages/pexpect/expect.py", line 122, 
in eof
raise exc
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.

command: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb
args: ['/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb', 
'--no-lldbinit', '--no-use-colors', '-O', 'settings clear -all', '-O', 
'settings set symbols.enable-external-lookup false', '-O', 'settings set 
target.inherit-tcc true', '-O', 'settings set target.disable-aslr false', '-O', 
'settings set target.detach-on-error false', '-O', 'settings set 
target.auto-apply-fixits false', '-O', 'settings set 
plugin.process.gdb-remote.packet-timeout 60', '-O', 'settings set 
symbols.clang-modules-cache-path 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api"',
 '-O', 

[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #123499)

2025-01-19 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/123499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Fix discarding DerivedToBase casts (PR #123523)

2025-01-19 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/123523

None

>From f5544cfbc4a3223d76f1a388bd4c20d78f14da12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 19 Jan 2025 19:48:31 +0100
Subject: [PATCH] [clang][bytecode] Fix discarding DerivedToBase casts

---
 clang/lib/AST/ByteCode/Compiler.cpp |  6 ++
 clang/test/AST/ByteCode/records.cpp | 15 +++
 2 files changed, 21 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7afae97f308ad5..750516efa1a3e1 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -253,6 +253,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
 
   case CK_UncheckedDerivedToBase:
   case CK_DerivedToBase: {
+if (DiscardResult)
+  return this->discard(SubExpr);
+
 if (!this->delegate(SubExpr))
   return false;
 
@@ -282,6 +285,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   }
 
   case CK_BaseToDerived: {
+if (DiscardResult)
+  return this->discard(SubExpr);
+
 if (!this->delegate(SubExpr))
   return false;
 
diff --git a/clang/test/AST/ByteCode/records.cpp 
b/clang/test/AST/ByteCode/records.cpp
index d329219264d893..b558ee9abec780 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -1684,3 +1684,18 @@ namespace ExplicitThisInTemporary {
   constexpr bool g(B b) { return &b == b.p; }
   static_assert(g({}), "");
 }
+
+namespace IgnoredMemberExpr {
+  class A {
+  public:
+int a;
+  };
+  class B : public A {
+  public:
+constexpr int foo() {
+  a;
+  return 0;
+}
+  };
+  static_assert(B{}.foo() == 0, "");
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Fix discarding DerivedToBase casts (PR #123523)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/123523.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+6) 
- (modified) clang/test/AST/ByteCode/records.cpp (+15) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7afae97f308ad5..750516efa1a3e1 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -253,6 +253,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
 
   case CK_UncheckedDerivedToBase:
   case CK_DerivedToBase: {
+if (DiscardResult)
+  return this->discard(SubExpr);
+
 if (!this->delegate(SubExpr))
   return false;
 
@@ -282,6 +285,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   }
 
   case CK_BaseToDerived: {
+if (DiscardResult)
+  return this->discard(SubExpr);
+
 if (!this->delegate(SubExpr))
   return false;
 
diff --git a/clang/test/AST/ByteCode/records.cpp 
b/clang/test/AST/ByteCode/records.cpp
index d329219264d893..b558ee9abec780 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -1684,3 +1684,18 @@ namespace ExplicitThisInTemporary {
   constexpr bool g(B b) { return &b == b.p; }
   static_assert(g({}), "");
 }
+
+namespace IgnoredMemberExpr {
+  class A {
+  public:
+int a;
+  };
+  class B : public A {
+  public:
+constexpr int foo() {
+  a;
+  return 0;
+}
+  };
+  static_assert(B{}.foo() == 0, "");
+}

``




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


[clang] f13850a - [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#123499)

2025-01-19 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-01-19T10:56:57-08:00
New Revision: f13850a92c13d41ee377b8ebb2c226895fddbb57

URL: 
https://github.com/llvm/llvm-project/commit/f13850a92c13d41ee377b8ebb2c226895fddbb57
DIFF: 
https://github.com/llvm/llvm-project/commit/f13850a92c13d41ee377b8ebb2c226895fddbb57.diff

LOG: [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#123499)

Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //isa, cast and the llvm::dyn_cast

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect Init to be nonnull.  Note that hasInit returns true
only if Init is nonnull among other conditions.

Added: 


Modified: 
clang/lib/AST/Decl.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 30341b046f95e3..f641a72ed26448 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2399,7 +2399,7 @@ Expr *VarDecl::getInit() {
   if (!hasInit())
 return nullptr;
 
-  if (auto *S = Init.dyn_cast())
+  if (auto *S = dyn_cast(Init))
 return cast(S);
 
   auto *Eval = getEvaluatedStmt();



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Register decomposition holding vars (PR #123515)

2025-01-19 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/123515

None

>From 69df4b6dc60426aee3ff61e556c44f81427a0e1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 19 Jan 2025 15:49:30 +0100
Subject: [PATCH] [clang][bytecode] Register decomposition holding vars

---
 clang/lib/AST/ByteCode/Compiler.cpp |  9 +
 clang/test/AST/ByteCode/cxx17.cpp   | 20 
 2 files changed, 29 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7afae97f308ad5..414323eaa12654 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4984,6 +4984,15 @@ bool Compiler::visitDeclStmt(const DeclStmt 
*DS) {
   return false;
 if (!this->visitVarDecl(VD))
   return false;
+
+// Register decomposition decl holding vars.
+if (const auto *DD = dyn_cast(VD)) {
+  for (auto *BD : DD->bindings())
+if (auto *KD = BD->getHoldingVar()) {
+  if (!this->visitVarDecl(KD))
+return false;
+}
+}
   }
 
   return true;
diff --git a/clang/test/AST/ByteCode/cxx17.cpp 
b/clang/test/AST/ByteCode/cxx17.cpp
index e8559d8b9812ac..ecb8a395520a05 100644
--- a/clang/test/AST/ByteCode/cxx17.cpp
+++ b/clang/test/AST/ByteCode/cxx17.cpp
@@ -105,3 +105,23 @@ constexpr S s = getS(); // both-error {{must be 
initialized by a constant expres
 // both-note {{declared here}}
 static_assert(s.a == 12, ""); // both-error {{not an integral constant 
expression}} \
   // both-note {{initializer of 's' is not a 
constant expression}}
+
+using size_t = decltype(sizeof(0));
+namespace std { template struct tuple_size; }
+namespace std { template struct tuple_element; }
+
+namespace constant {
+  struct Q {};
+  template constexpr int get(Q &&) { return N * N; }
+}
+template<> struct std::tuple_size { static const int value = 3; };
+template struct std::tuple_element { typedef int type; 
};
+
+namespace constant {
+  Q q;
+  constexpr bool f() {
+auto [a, b, c] = q;
+return a == 0 && b == 1 && c == 4;
+  }
+  static_assert(f());
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Register decomposition holding vars (PR #123515)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/123515.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+9) 
- (modified) clang/test/AST/ByteCode/cxx17.cpp (+20) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7afae97f308ad5..414323eaa12654 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4984,6 +4984,15 @@ bool Compiler::visitDeclStmt(const DeclStmt 
*DS) {
   return false;
 if (!this->visitVarDecl(VD))
   return false;
+
+// Register decomposition decl holding vars.
+if (const auto *DD = dyn_cast(VD)) {
+  for (auto *BD : DD->bindings())
+if (auto *KD = BD->getHoldingVar()) {
+  if (!this->visitVarDecl(KD))
+return false;
+}
+}
   }
 
   return true;
diff --git a/clang/test/AST/ByteCode/cxx17.cpp 
b/clang/test/AST/ByteCode/cxx17.cpp
index e8559d8b9812ac..ecb8a395520a05 100644
--- a/clang/test/AST/ByteCode/cxx17.cpp
+++ b/clang/test/AST/ByteCode/cxx17.cpp
@@ -105,3 +105,23 @@ constexpr S s = getS(); // both-error {{must be 
initialized by a constant expres
 // both-note {{declared here}}
 static_assert(s.a == 12, ""); // both-error {{not an integral constant 
expression}} \
   // both-note {{initializer of 's' is not a 
constant expression}}
+
+using size_t = decltype(sizeof(0));
+namespace std { template struct tuple_size; }
+namespace std { template struct tuple_element; }
+
+namespace constant {
+  struct Q {};
+  template constexpr int get(Q &&) { return N * N; }
+}
+template<> struct std::tuple_size { static const int value = 3; };
+template struct std::tuple_element { typedef int type; 
};
+
+namespace constant {
+  Q q;
+  constexpr bool f() {
+auto [a, b, c] = q;
+return a == 0 && b == 1 && c == 4;
+  }
+  static_assert(f());
+}

``




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


[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread Manuel Sainz de Baranda y Goñi via cfe-commits

https://github.com/redcode created 
https://github.com/llvm/llvm-project/pull/123514

This small PR makes Clang predefine the following macros:

```
__INT8_C(c)
__INT16_C(c)
__INT32_C(c)
__INT64_C(c)
__INTMAX_C(c)
__UINT8_C(c)
__UINT16_C(c)
__UINT32_C(c)
__UINT64_C(c)
__UINTMAX_C(c)
```

Which improves compatibility with GCC and makes it trivial to implement section 
7.18.4 of ISO/IEC 9899:1999.

Clang defines `__INT_C_SUFFIX__`, `__UINT_C_SUFFIX__`, 
`__INTAX_C_SUFFIX__` and `__UINTMAX_C_SUFFIX__`, but these macros are useless 
for this purpose.

Let's say, for example, that `__INT64_C_SUFFIX__` expands to `L` or `LL`. If 
the user defines them as a macros, the compiler will produce errors if 
`INT64_C` is implemented in `` using `__INT64_C_SUFFIX__`:

**minimal-test.c:**
```cpp
#if defined(__clang__) & !defined(__INT64_C)
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wreserved-identifier"
#   define __PSTDC_INT_C_(literal, suffix) literal##suffix
#   define __PSTDC_INT_C(literal, suffix) __PSTDC_INT_C_(literal, suffix)
#   define INT64_C(literal) __PSTDC_INT_C(literal, __INT64_C_SUFFIX__)
#   pragma clang diagnostic pop
#elif defined(__GNUC__)
#   define INT64_C __INT64_C
#endif

typedef __INT64_TYPE__ int64_t;

#define L  "Make Clang produce an error"
#define LL "Make Clang produce an error"

int main(int argc, char **argv)
{
(void)argc; (void)argv;
int64_t v = INT64_C(9223372036854775807);
(void)v;
return 0;
}

```

https://github.com/user-attachments/assets/6df97af6-7cfd-4cf9-85b7-d7c854509325";
 />

**test.c:**
```cpp
#if defined(__clang__) && !defined(__INT8_C)
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wreserved-identifier"

#   define __PSTDC_INT_C_(literal, suffix) literal##suffix
#   define __PSTDC_INT_C(literal, suffix) __PSTDC_INT_C_(literal, suffix)

#   define INT8_C(literal)__PSTDC_INT_C(literal, __INT8_C_SUFFIX__)
#   define INT16_C(literal)   __PSTDC_INT_C(literal, __INT16_C_SUFFIX__)
#   define INT32_C(literal)   __PSTDC_INT_C(literal, __INT32_C_SUFFIX__)
#   define INT64_C(literal)   __PSTDC_INT_C(literal, __INT64_C_SUFFIX__)
#   define INTMAX_C(literal)  __PSTDC_INT_C(literal, __INTMAX_C_SUFFIX__)
#   define UINT8_C(literal)   __PSTDC_INT_C(literal, __UINT8_C_SUFFIX__)
#   define UINT16_C(literal)  __PSTDC_INT_C(literal, __UINT16_C_SUFFIX__)
#   define UINT32_C(literal)  __PSTDC_INT_C(literal, __UINT32_C_SUFFIX__)
#   define UINT64_C(literal)  __PSTDC_INT_C(literal, __UINT64_C_SUFFIX__)
#   define UINTMAX_C(literal) __PSTDC_INT_C(literal, __UINTMAX_C_SUFFIX__)

#   pragma clang diagnostic pop

#else
#   define INT8_C__INT8_C
#   define INT16_C   __INT16_C
#   define INT32_C   __INT32_C
#   define INT64_C   __INT64_C
#   define INTMAX_C  __INTMAX_C
#   define UINT8_C   __UINT8_C
#   define UINT16_C  __UINT16_C
#   define UINT32_C  __UINT32_C
#   define UINT64_C  __UINT64_C
#   define UINTMAX_C __UINTMAX_C
#endif

typedef __INT8_TYPE__int8_t;
typedef __INT16_TYPE__   int16_t;
typedef __INT32_TYPE__   int32_t;
typedef __INT64_TYPE__   int64_t;
typedef __INTMAX_TYPE__  intmax_t;
typedef __UINT8_TYPE__   uint8_t;
typedef __UINT16_TYPE__  uint16_t;
typedef __UINT32_TYPE__  uint32_t;
typedef __UINT64_TYPE__  uint64_t;
typedef __UINTMAX_TYPE__ uintmax_t;

#define L   "Make Clang produce an error"
#define LL  "Make Clang produce an error"
#define U   "Make Clang produce an error"
#define UL  "Make Clang produce an error"
#define ULL "Make Clang produce an error"

int main(int argc, char **argv)
{
(void)argc; (void)argv;

int8_ta = INT8_C   (127);
int16_t   b = INT16_C  (32767);
int32_t   c = INT32_C  (2147483647);
int64_t   d = INT64_C  (9223372036854775807);
intmax_t  e = INTMAX_C (9223372036854775807);
uint8_t   f = UINT8_C  (255);
uint16_t  g = UINT16_C (65535);
uint32_t  h = UINT32_C (4294967295);
uint64_t  i = UINT64_C (18446744073709551615);
uintmax_t j = UINTMAX_C(18446744073709551615);

(void)a; (void)b; (void)c; (void)d; (void)e;
(void)f; (void)g; (void)h; (void)i; (void)j;
return 0;
}
```



From 507b9804cc748a2441db8d1eb36a01be34bc21ce Mon Sep 17 00:00:00 2001
From: redcode 
Date: Sun, 19 Jan 2025 15:29:01 +0100
Subject: [PATCH] [Clang] Add predefined macros `__INT_C`, `__UINT_C`,
 `__INTMAX_C` and `__UINTMAX_C`

---
 clang/lib/Frontend/InitPreprocessor.cpp | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 29723b573e771a..17f624e9645395 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -253,6 +253,8 @@ static void DefineExactWidthIntType(const L

[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Manuel Sainz de Baranda y Goñi (redcode)


Changes

This small PR makes Clang predefine the following macros:

```
__INT8_C(c)
__INT16_C(c)
__INT32_C(c)
__INT64_C(c)
__INTMAX_C(c)
__UINT8_C(c)
__UINT16_C(c)
__UINT32_C(c)
__UINT64_C(c)
__UINTMAX_C(c)
```

Which improves compatibility with GCC and makes it trivial to implement section 
7.18.4 of ISO/IEC 9899:1999.

Clang defines `__INT_C_SUFFIX__`, `__UINT_C_SUFFIX__`, 
`__INTAX_C_SUFFIX__` and `__UINTMAX_C_SUFFIX__`, but these macros are useless 
for this purpose.

Let's say, for example, that `__INT64_C_SUFFIX__` expands to `L` or `LL`. If 
the user defines them as a macros, the compiler will produce errors if 
`INT64_C` is implemented in `` using `__INT64_C_SUFFIX__`:

**minimal-test.c:**
```cpp
#if defined(__clang__) & !defined(__INT64_C)
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wreserved-identifier"
#   define __PSTDC_INT_C_(literal, suffix) literal##suffix
#   define __PSTDC_INT_C(literal, suffix) __PSTDC_INT_C_(literal, suffix)
#   define INT64_C(literal) __PSTDC_INT_C(literal, __INT64_C_SUFFIX__)
#   pragma clang diagnostic pop
#elif defined(__GNUC__)
#   define INT64_C __INT64_C
#endif

typedef __INT64_TYPE__ int64_t;

#define L  "Make Clang produce an error"
#define LL "Make Clang produce an error"

int main(int argc, char **argv)
{
(void)argc; (void)argv;
int64_t v = INT64_C(9223372036854775807);
(void)v;
return 0;
}

```

imagen

**test.c:**
```cpp
#if defined(__clang__) && !defined(__INT8_C)
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wreserved-identifier"

#   define __PSTDC_INT_C_(literal, suffix) literal##suffix
#   define __PSTDC_INT_C(literal, suffix) __PSTDC_INT_C_(literal, suffix)

#   define INT8_C(literal)__PSTDC_INT_C(literal, __INT8_C_SUFFIX__)
#   define INT16_C(literal)   __PSTDC_INT_C(literal, __INT16_C_SUFFIX__)
#   define INT32_C(literal)   __PSTDC_INT_C(literal, __INT32_C_SUFFIX__)
#   define INT64_C(literal)   __PSTDC_INT_C(literal, __INT64_C_SUFFIX__)
#   define INTMAX_C(literal)  __PSTDC_INT_C(literal, __INTMAX_C_SUFFIX__)
#   define UINT8_C(literal)   __PSTDC_INT_C(literal, __UINT8_C_SUFFIX__)
#   define UINT16_C(literal)  __PSTDC_INT_C(literal, __UINT16_C_SUFFIX__)
#   define UINT32_C(literal)  __PSTDC_INT_C(literal, __UINT32_C_SUFFIX__)
#   define UINT64_C(literal)  __PSTDC_INT_C(literal, __UINT64_C_SUFFIX__)
#   define UINTMAX_C(literal) __PSTDC_INT_C(literal, __UINTMAX_C_SUFFIX__)

#   pragma clang diagnostic pop

#else
#   define INT8_C__INT8_C
#   define INT16_C   __INT16_C
#   define INT32_C   __INT32_C
#   define INT64_C   __INT64_C
#   define INTMAX_C  __INTMAX_C
#   define UINT8_C   __UINT8_C
#   define UINT16_C  __UINT16_C
#   define UINT32_C  __UINT32_C
#   define UINT64_C  __UINT64_C
#   define UINTMAX_C __UINTMAX_C
#endif

typedef __INT8_TYPE__int8_t;
typedef __INT16_TYPE__   int16_t;
typedef __INT32_TYPE__   int32_t;
typedef __INT64_TYPE__   int64_t;
typedef __INTMAX_TYPE__  intmax_t;
typedef __UINT8_TYPE__   uint8_t;
typedef __UINT16_TYPE__  uint16_t;
typedef __UINT32_TYPE__  uint32_t;
typedef __UINT64_TYPE__  uint64_t;
typedef __UINTMAX_TYPE__ uintmax_t;

#define L   "Make Clang produce an error"
#define LL  "Make Clang produce an error"
#define U   "Make Clang produce an error"
#define UL  "Make Clang produce an error"
#define ULL "Make Clang produce an error"

int main(int argc, char **argv)
{
(void)argc; (void)argv;

int8_ta = INT8_C   (127);
int16_t   b = INT16_C  (32767);
int32_t   c = INT32_C  (2147483647);
int64_t   d = INT64_C  (9223372036854775807);
intmax_t  e = INTMAX_C (9223372036854775807);
uint8_t   f = UINT8_C  (255);
uint16_t  g = UINT16_C (65535);
uint32_t  h = UINT32_C (4294967295);
uint64_t  i = UINT64_C (18446744073709551615);
uintmax_t j = UINTMAX_C(18446744073709551615);

(void)a; (void)b; (void)c; (void)d; (void)e;
(void)f; (void)g; (void)h; (void)i; (void)j;
return 0;
}
```



---
Full diff: https://github.com/llvm/llvm-project/pull/123514.diff


1 Files Affected:

- (modified) clang/lib/Frontend/InitPreprocessor.cpp (+10-4) 


``diff
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 29723b573e771a..17f624e9645395 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -253,6 +253,8 @@ static void DefineExactWidthIntType(const LangOptions 
&LangOpts,
 
   StringRef ConstSuffix(TI.getTypeConstantSuffix(Ty));
   Builder.defineMac

[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [libcxxabi] [llvm] [WIP][Clang] Mangling of pack indexing type and expression for itanium (PR #123513)

2025-01-19 Thread Timm Baeder via cfe-commits


@@ -4785,6 +4790,19 @@ void CXXNameMangler::mangleRequirement(SourceLocation 
RequiresExprLoc,
   }
 }
 
+void CXXNameMangler::mangleReferenceToPack(const NamedDecl* Pack) {
+if (const TemplateTypeParmDecl *TTP = dyn_cast(Pack))
+mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
+else if (const NonTypeTemplateParmDecl *NTTP
+  = dyn_cast(Pack))
+mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
+else if (const TemplateTemplateParmDecl *TempTP
+  = dyn_cast(Pack))

tbaederr wrote:

```suggestion
if (const auto *TTP = dyn_cast(Pack))
mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
else if (const auto *NTTP
  = dyn_cast(Pack))
mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
else if (const auto *TempTP
  = dyn_cast(Pack))
```

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


[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-19 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

This seems related to #85995. Do you plan to fix that issue together?

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


[clang] [llvm] [NFC][AMDGPU] Clean-up feature parsing for AMDGCNSPIRV. (PR #123519)

2025-01-19 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx edited 
https://github.com/llvm/llvm-project/pull/123519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC][AMDGPU] Clean-up feature parsing for AMDGCNSPIRV. (PR #123519)

2025-01-19 Thread Alex Voicu via cfe-commits


@@ -323,43 +323,59 @@ void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const 
Triple &T,
   StringMap &Features) {
   // XXX - What does the member GPU mean if device name string passed here?
   if (T.isSPIRV() && T.getOS() == Triple::OSType::AMDHSA) {
-// AMDGCN SPIRV must support the union of all AMDGCN features.
+// AMDGCN SPIRV must support the union of all AMDGCN features. This list

AlexVlx wrote:

Possibly, although tablegen is already a bit of a monster IMHO.

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


[clang] [cindex] Add API to query the class methods of a type (PR #123539)

2025-01-19 Thread Trevor Laughlin via cfe-commits

https://github.com/trelau created 
https://github.com/llvm/llvm-project/pull/123539

Inspired by https://github.com/llvm/llvm-project/pull/120300, add a new API 
`clang_visitCXXMethods` to libclang (and the Python bindings) which allows 
iterating over the class methods of a type.

>From bb0542e8f2ad50892ee9d2c1f76ec1def85c3e56 Mon Sep 17 00:00:00 2001
From: Trevor Laughlin 
Date: Sun, 19 Jan 2025 19:21:10 -0500
Subject: [PATCH] [cindex] Add API to query the class methods of a type

---
 clang/bindings/python/clang/cindex.py | 16 +++
 .../bindings/python/tests/cindex/test_type.py | 18 +
 clang/docs/ReleaseNotes.rst   |  4 +++
 clang/include/clang-c/Index.h | 23 
 clang/tools/libclang/CIndexCXX.cpp| 27 +++
 clang/tools/libclang/libclang.map |  1 +
 6 files changed, 89 insertions(+)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 806e1b40f3c9e1..9e65ea2942d163 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -2710,6 +2710,21 @@ def visitor(base, children):
 conf.lib.clang_visitCXXBaseClasses(self, 
fields_visit_callback(visitor), bases)
 return iter(bases)
 
+def get_methods(self):
+"""Return an iterator for accessing the methods of this type."""
+
+def visitor(method, children):
+assert method != conf.lib.clang_getNullCursor()
+
+# Create reference to TU so it isn't GC'd before Cursor.
+method._tu = self._tu
+methods.append(method)
+return 1  # continue
+
+methods: list[Cursor] = []
+conf.lib.clang_visitCXXMethods(self, fields_visit_callback(visitor), 
methods)
+return iter(methods)
+
 def get_exception_specification_kind(self):
 """
 Return the kind of the exception specification; a value from
@@ -4017,6 +4032,7 @@ def set_property(self, property, value):
 ),
 ("clang_visitChildren", [Cursor, cursor_visit_callback, py_object], 
c_uint),
 ("clang_visitCXXBaseClasses", [Type, fields_visit_callback, py_object], 
c_uint),
+("clang_visitCXXMethods", [Type, fields_visit_callback, py_object], 
c_uint),
 ("clang_Cursor_getNumArguments", [Cursor], c_int),
 ("clang_Cursor_getArgument", [Cursor, c_uint], Cursor),
 ("clang_Cursor_getNumTemplateArguments", [Cursor], c_int),
diff --git a/clang/bindings/python/tests/cindex/test_type.py 
b/clang/bindings/python/tests/cindex/test_type.py
index 9bac33f3041f40..bc893d509524e0 100644
--- a/clang/bindings/python/tests/cindex/test_type.py
+++ b/clang/bindings/python/tests/cindex/test_type.py
@@ -559,3 +559,21 @@ class Template : public A, public B, virtual C {
 self.assertEqual(bases[1].get_base_offsetof(cursor_type_decl), 96)
 self.assertTrue(bases[2].is_virtual_base())
 self.assertEqual(bases[2].get_base_offsetof(cursor_type_decl), 128)
+
+def test_class_methods(self):
+source = """
+template 
+class Template { void Foo(); };
+typedef Template instance;
+instance bar;
+"""
+tu = get_tu(source, lang="cpp", flags=["--target=x86_64-linux-gnu"])
+cursor = get_cursor(tu, "instance")
+cursor_type = cursor.underlying_typedef_type
+self.assertEqual(cursor.kind, CursorKind.TYPEDEF_DECL)
+methods = list(cursor_type.get_methods())
+self.assertEqual(len(methods), 4)
+self.assertEqual(methods[0].kind, CursorKind.CXX_METHOD)
+self.assertEqual(methods[1].kind, CursorKind.CONSTRUCTOR)
+self.assertEqual(methods[2].kind, CursorKind.CONSTRUCTOR)
+self.assertEqual(methods[3].kind, CursorKind.CONSTRUCTOR)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b02ac467cd3a22..dd9f722a6a08cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1241,6 +1241,8 @@ libclang
   of a class.
 - Added ``clang_getOffsetOfBase``, which allows computing the offset of a base
   class in a class's layout.
+- Added ``clang_visitCXXMethods``, which allows visiting the methods
+  of a class.
 
 Static Analyzer
 ---
@@ -1394,6 +1396,8 @@ Python Binding Changes
   allows visiting the base classes of a class.
 - Added ``Cursor.get_base_offsetof``, a binding for ``clang_getOffsetOfBase``,
   which allows computing the offset of a base class in a class's layout.
+- Added ``Type.get_methods``, a binding for ``clang_visitCXXMethods``, which
+  allows visiting the methods of a class.
 
 OpenMP Support
 --
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index aac5d1fa8aa2e0..5d961ca0cdd7fc 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -6680,6 +6680,29 @@ CINDEX_LINKAGE unsigned clang_visitCXXBaseClasses(CXType 
T,
  

[clang] [cindex] Add API to query the class methods of a type (PR #123539)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Trevor Laughlin (trelau)


Changes

Inspired by https://github.com/llvm/llvm-project/pull/120300, add a new API 
`clang_visitCXXMethods` to libclang (and the Python bindings) which allows 
iterating over the class methods of a type.

---
Full diff: https://github.com/llvm/llvm-project/pull/123539.diff


6 Files Affected:

- (modified) clang/bindings/python/clang/cindex.py (+16) 
- (modified) clang/bindings/python/tests/cindex/test_type.py (+18) 
- (modified) clang/docs/ReleaseNotes.rst (+4) 
- (modified) clang/include/clang-c/Index.h (+23) 
- (modified) clang/tools/libclang/CIndexCXX.cpp (+27) 
- (modified) clang/tools/libclang/libclang.map (+1) 


``diff
diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 806e1b40f3c9e1..9e65ea2942d163 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -2710,6 +2710,21 @@ def visitor(base, children):
 conf.lib.clang_visitCXXBaseClasses(self, 
fields_visit_callback(visitor), bases)
 return iter(bases)
 
+def get_methods(self):
+"""Return an iterator for accessing the methods of this type."""
+
+def visitor(method, children):
+assert method != conf.lib.clang_getNullCursor()
+
+# Create reference to TU so it isn't GC'd before Cursor.
+method._tu = self._tu
+methods.append(method)
+return 1  # continue
+
+methods: list[Cursor] = []
+conf.lib.clang_visitCXXMethods(self, fields_visit_callback(visitor), 
methods)
+return iter(methods)
+
 def get_exception_specification_kind(self):
 """
 Return the kind of the exception specification; a value from
@@ -4017,6 +4032,7 @@ def set_property(self, property, value):
 ),
 ("clang_visitChildren", [Cursor, cursor_visit_callback, py_object], 
c_uint),
 ("clang_visitCXXBaseClasses", [Type, fields_visit_callback, py_object], 
c_uint),
+("clang_visitCXXMethods", [Type, fields_visit_callback, py_object], 
c_uint),
 ("clang_Cursor_getNumArguments", [Cursor], c_int),
 ("clang_Cursor_getArgument", [Cursor, c_uint], Cursor),
 ("clang_Cursor_getNumTemplateArguments", [Cursor], c_int),
diff --git a/clang/bindings/python/tests/cindex/test_type.py 
b/clang/bindings/python/tests/cindex/test_type.py
index 9bac33f3041f40..bc893d509524e0 100644
--- a/clang/bindings/python/tests/cindex/test_type.py
+++ b/clang/bindings/python/tests/cindex/test_type.py
@@ -559,3 +559,21 @@ class Template : public A, public B, virtual C {
 self.assertEqual(bases[1].get_base_offsetof(cursor_type_decl), 96)
 self.assertTrue(bases[2].is_virtual_base())
 self.assertEqual(bases[2].get_base_offsetof(cursor_type_decl), 128)
+
+def test_class_methods(self):
+source = """
+template 
+class Template { void Foo(); };
+typedef Template instance;
+instance bar;
+"""
+tu = get_tu(source, lang="cpp", flags=["--target=x86_64-linux-gnu"])
+cursor = get_cursor(tu, "instance")
+cursor_type = cursor.underlying_typedef_type
+self.assertEqual(cursor.kind, CursorKind.TYPEDEF_DECL)
+methods = list(cursor_type.get_methods())
+self.assertEqual(len(methods), 4)
+self.assertEqual(methods[0].kind, CursorKind.CXX_METHOD)
+self.assertEqual(methods[1].kind, CursorKind.CONSTRUCTOR)
+self.assertEqual(methods[2].kind, CursorKind.CONSTRUCTOR)
+self.assertEqual(methods[3].kind, CursorKind.CONSTRUCTOR)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b02ac467cd3a22..dd9f722a6a08cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1241,6 +1241,8 @@ libclang
   of a class.
 - Added ``clang_getOffsetOfBase``, which allows computing the offset of a base
   class in a class's layout.
+- Added ``clang_visitCXXMethods``, which allows visiting the methods
+  of a class.
 
 Static Analyzer
 ---
@@ -1394,6 +1396,8 @@ Python Binding Changes
   allows visiting the base classes of a class.
 - Added ``Cursor.get_base_offsetof``, a binding for ``clang_getOffsetOfBase``,
   which allows computing the offset of a base class in a class's layout.
+- Added ``Type.get_methods``, a binding for ``clang_visitCXXMethods``, which
+  allows visiting the methods of a class.
 
 OpenMP Support
 --
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index aac5d1fa8aa2e0..5d961ca0cdd7fc 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -6680,6 +6680,29 @@ CINDEX_LINKAGE unsigned clang_visitCXXBaseClasses(CXType 
T,
   CXFieldVisitor visitor,
   CXClientData client_data);
 
+/**
+ * Visit the class methods of a type.
+ *
+ * This function visits 

[clang] [cindex] Add API to query the class methods of a type (PR #123539)

2025-01-19 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [clang][bytecode][NFC] Use FixedPoint opaque int API (PR #123522)

2025-01-19 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/123522

Now that we have it, use it.

>From 9495bf522c349f8223f890c2581817814f7ba2f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 19 Jan 2025 19:39:04 +0100
Subject: [PATCH] [clang][bytecode][NFC] Use FixedPoint opaque int API

Now that we have it, use it.
---
 clang/lib/AST/ByteCode/Compiler.cpp | 51 +
 clang/lib/AST/ByteCode/Interp.h | 11 +++
 2 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7afae97f308ad5..78f936ec9f8958 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -689,20 +689,18 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
 if (!this->visit(SubExpr))
   return false;
 
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastIntegralFixedPoint(classifyPrim(SubExpr->getType()), 
I,
-CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastIntegralFixedPoint(classifyPrim(SubExpr->getType()),
+Sem, CE);
   }
   case CK_FloatingToFixedPoint: {
 if (!this->visit(SubExpr))
   return false;
 
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastFloatingFixedPoint(I, CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastFloatingFixedPoint(Sem, CE);
   }
   case CK_FixedPointToFloating: {
 if (!this->visit(SubExpr))
@@ -718,10 +716,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   case CK_FixedPointCast: {
 if (!this->visit(SubExpr))
   return false;
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastFixedPoint(I, CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastFixedPoint(Sem, CE);
   }
 
   case CK_ToVoid:
@@ -1522,28 +1519,29 @@ template 
 bool Compiler::VisitFixedPointBinOp(const BinaryOperator *E) {
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
+  const ASTContext &ASTCtx = Ctx.getASTContext();
 
   assert(LHS->getType()->isFixedPointType() ||
  RHS->getType()->isFixedPointType());
 
-  auto LHSSema = Ctx.getASTContext().getFixedPointSemantics(LHS->getType());
-  auto RHSSema = Ctx.getASTContext().getFixedPointSemantics(RHS->getType());
+  auto LHSSema = ASTCtx.getFixedPointSemantics(LHS->getType());
+  auto LHSSemaInt = LHSSema.toOpaqueInt();
+  auto RHSSema = ASTCtx.getFixedPointSemantics(RHS->getType());
+  auto RHSSemaInt = RHSSema.toOpaqueInt();
 
   if (!this->visit(LHS))
 return false;
   if (!LHS->getType()->isFixedPointType()) {
-uint32_t I;
-std::memcpy(&I, &LHSSema, sizeof(llvm::FixedPointSemantics));
-if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()), I, E))
+if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()),
+  LHSSemaInt, E))
   return false;
   }
 
   if (!this->visit(RHS))
 return false;
   if (!RHS->getType()->isFixedPointType()) {
-uint32_t I;
-std::memcpy(&I, &RHSSema, sizeof(llvm::FixedPointSemantics));
-if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()), I, E))
+if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()),
+  RHSSemaInt, E))
   return false;
   }
 
@@ -1551,13 +1549,10 @@ bool Compiler::VisitFixedPointBinOp(const 
BinaryOperator *E) {
   auto ConvertResult = [&](bool R) -> bool {
 if (!R)
   return false;
-auto ResultSema = Ctx.getASTContext().getFixedPointSemantics(E->getType());
-auto CommonSema = LHSSema.getCommonSemantics(RHSSema);
-if (ResultSema != CommonSema) {
-  uint32_t I;
-  std::memcpy(&I, &ResultSema, sizeof(ResultSema));
-  return this->emitCastFixedPoint(I, E);
-}
+auto ResultSema = 
ASTCtx.getFixedPointSemantics(E->getType()).toOpaqueInt();
+auto CommonSema = LHSSema.getCommonSemantics(RHSSema).toOpaqueInt();
+if (ResultSema != CommonSema)
+  return this->emitCastFixedPoint(ResultSema, E);
 return true;
   };
 
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 93a91976a31bf1..58c0256c7d7df8 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2141,9 +2141,8 @@ inline bool CastFP(InterpState &S, CodePtr OpPC, const 
llvm::fltSemantics *Sem,
 }
 
 inline bool CastFixedP

[clang] [clang][bytecode][NFC] Use FixedPoint opaque int API (PR #123522)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Now that we have it, use it.

---
Full diff: https://github.com/llvm/llvm-project/pull/123522.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+23-28) 
- (modified) clang/lib/AST/ByteCode/Interp.h (+4-7) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7afae97f308ad5..78f936ec9f8958 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -689,20 +689,18 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
 if (!this->visit(SubExpr))
   return false;
 
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastIntegralFixedPoint(classifyPrim(SubExpr->getType()), 
I,
-CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastIntegralFixedPoint(classifyPrim(SubExpr->getType()),
+Sem, CE);
   }
   case CK_FloatingToFixedPoint: {
 if (!this->visit(SubExpr))
   return false;
 
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastFloatingFixedPoint(I, CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastFloatingFixedPoint(Sem, CE);
   }
   case CK_FixedPointToFloating: {
 if (!this->visit(SubExpr))
@@ -718,10 +716,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   case CK_FixedPointCast: {
 if (!this->visit(SubExpr))
   return false;
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastFixedPoint(I, CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastFixedPoint(Sem, CE);
   }
 
   case CK_ToVoid:
@@ -1522,28 +1519,29 @@ template 
 bool Compiler::VisitFixedPointBinOp(const BinaryOperator *E) {
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
+  const ASTContext &ASTCtx = Ctx.getASTContext();
 
   assert(LHS->getType()->isFixedPointType() ||
  RHS->getType()->isFixedPointType());
 
-  auto LHSSema = Ctx.getASTContext().getFixedPointSemantics(LHS->getType());
-  auto RHSSema = Ctx.getASTContext().getFixedPointSemantics(RHS->getType());
+  auto LHSSema = ASTCtx.getFixedPointSemantics(LHS->getType());
+  auto LHSSemaInt = LHSSema.toOpaqueInt();
+  auto RHSSema = ASTCtx.getFixedPointSemantics(RHS->getType());
+  auto RHSSemaInt = RHSSema.toOpaqueInt();
 
   if (!this->visit(LHS))
 return false;
   if (!LHS->getType()->isFixedPointType()) {
-uint32_t I;
-std::memcpy(&I, &LHSSema, sizeof(llvm::FixedPointSemantics));
-if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()), I, E))
+if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()),
+  LHSSemaInt, E))
   return false;
   }
 
   if (!this->visit(RHS))
 return false;
   if (!RHS->getType()->isFixedPointType()) {
-uint32_t I;
-std::memcpy(&I, &RHSSema, sizeof(llvm::FixedPointSemantics));
-if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()), I, E))
+if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()),
+  RHSSemaInt, E))
   return false;
   }
 
@@ -1551,13 +1549,10 @@ bool Compiler::VisitFixedPointBinOp(const 
BinaryOperator *E) {
   auto ConvertResult = [&](bool R) -> bool {
 if (!R)
   return false;
-auto ResultSema = Ctx.getASTContext().getFixedPointSemantics(E->getType());
-auto CommonSema = LHSSema.getCommonSemantics(RHSSema);
-if (ResultSema != CommonSema) {
-  uint32_t I;
-  std::memcpy(&I, &ResultSema, sizeof(ResultSema));
-  return this->emitCastFixedPoint(I, E);
-}
+auto ResultSema = 
ASTCtx.getFixedPointSemantics(E->getType()).toOpaqueInt();
+auto CommonSema = LHSSema.getCommonSemantics(RHSSema).toOpaqueInt();
+if (ResultSema != CommonSema)
+  return this->emitCastFixedPoint(ResultSema, E);
 return true;
   };
 
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 93a91976a31bf1..58c0256c7d7df8 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2141,9 +2141,8 @@ inline bool CastFP(InterpState &S, CodePtr OpPC, const 
llvm::fltSemantics *Sem,
 }
 
 inline bool CastFixedPoint(InterpState &S, CodePtr OpPC, uint32_t FPS) {
-  FixedPointSemantics TargetSemantics(0, 0, false, false, false);
-  std::memcpy(&TargetSemantics, &FPS, sizeof(TargetSemantics));
-
+  FixedPointSemanti

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits

https://github.com/BaLiKfromUA edited 
https://github.com/llvm/llvm-project/pull/123533
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Valentyn Yukhymenko (BaLiKfromUA)


Changes

Fixes llvm#123423

**How did I test it?**

Modified existing test and checked an example from the issue manually.


---
Full diff: https://github.com/llvm/llvm-project/pull/123533.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+8) 
- (modified) clang/test/SemaCXX/alias-template.cpp (+3-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index aa1c02d04f7caa..29e40b4ecab412 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -956,6 +956,7 @@ Bug Fixes to C++ Support
 - Fixed a crash caused by the incorrect construction of template arguments for 
CTAD alias guides when type
   constraints are applied. (#GH122134)
 - Fixed canonicalization of pack indexing types - Clang did not always 
recognized identical pack indexing. (#GH123033)
+- Clang now rejects declaring an alias template with the same name as its 
template parameter. (#GH123423)
 
 
 Bug Fixes to AST Handling
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a867ed73bd4033..4e43a8397cec4e 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, 
AccessSpecifier AS,
 }
 TemplateParameterList *TemplateParams = TemplateParamLists[0];
 
+// Check shadowing of a template parameter name
+for (NamedDecl *TP : TemplateParams->asArray()) {
+  if (NameInfo.getName() == TP->getDeclName()) {
+DiagnoseTemplateParameterShadow(Name.StartLocation, TP);
+return nullptr;
+  }
+}
+
 // Check that we can declare a template here.
 if (CheckTemplateDeclScope(S, TemplateParams))
   return nullptr;
diff --git a/clang/test/SemaCXX/alias-template.cpp 
b/clang/test/SemaCXX/alias-template.cpp
index 5189405e23db56..97134d2f3a96ad 100644
--- a/clang/test/SemaCXX/alias-template.cpp
+++ b/clang/test/SemaCXX/alias-template.cpp
@@ -65,7 +65,8 @@ namespace InFunctions {
   template struct S3 { // expected-note {{template parameter is 
declared here}}
 template using T = int; // expected-error {{declaration of 'T' 
shadows template parameter}}
   };
-  template using Z = Z;
+  template // expected-note {{template parameter is declared here}}
+  using Z = Z; // expected-error {{declaration of 'Z' shadows template 
parameter}}
 }
 
 namespace ClassNameRedecl {
@@ -191,4 +192,4 @@ int g = sfinae_me(); // expected-error{{no matching 
function for call to 's
 
 namespace NullExceptionDecl {
 template auto get = []() { try { } catch(...) {}; return I; }; // 
expected-error{{initializer contains unexpanded parameter pack 'I'}}
-}
+}
\ No newline at end of file

``




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


[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits

https://github.com/BaLiKfromUA converted_to_draft 
https://github.com/llvm/llvm-project/pull/123533
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

2025-01-19 Thread via cfe-commits

https://github.com/Sirraide edited 
https://github.com/llvm/llvm-project/pull/123495
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

2025-01-19 Thread via cfe-commits


@@ -2509,6 +2509,20 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec 
&SS, LookupResult &R,
 DC = DC->getLookupParent();
   }
 
+  // Check whether a similar function-like macro exists and suggest it

Sirraide wrote:

Instead of doing this here before typo correction, the note that this pr adds 
should probably just be emitted right after the error we emit at the very end 
of this function (or after the one right before that we emit if the SS isn’t 
empty).

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


[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

2025-01-19 Thread via cfe-commits


@@ -5936,6 +5936,9 @@ def err_fold_expression_limit_exceeded: Error<
   "instantiating fold expression with %0 arguments exceeded expression nesting 
"
   "limit of %1">, DefaultFatal, NoSFINAE;
 
+def note_function_like_macro_requires_parens
+: Note<"'%0' exists, but as a function-like macro; perhaps, did you forget 
"
+   "the parentheses?">;

Sirraide wrote:

```suggestion
: Note<"'%0' is defined here as a function-like macro; did you mean to 
write '%0(...)'">;
```
Maybe something like that would be bit clearer?

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


[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

2025-01-19 Thread via cfe-commits

https://github.com/Sirraide commented:

This still needs tests and a release note.

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


[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

2025-01-19 Thread via cfe-commits


@@ -134,6 +134,7 @@ void test_NE() {
 // CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:32-110:32}:")"
 
 #define INIT(var, init) Foo var = init; // expected-note 3{{defined here}}
+// expected-note@-1 2{{'INIT' exists, but as a function-like macro; perhaps, 
did you forget the parentheses?}}

Sirraide wrote:

Er, this note being emitted here is ... not great because we *are* using it (or 
at least trying to use it) as a function-like macro below—to be fair though, 
putting an init list in a function-like macro currently already leads to a 
flood of errors because we can’t recover from it too well, so if this is the 
only case that causes a false positive then it’s not *that* much of an issue 
imo.

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


[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits

https://github.com/BaLiKfromUA updated 
https://github.com/llvm/llvm-project/pull/123533

>From e451a8869420d9240f9006eb2adb599a3e6fd9f8 Mon Sep 17 00:00:00 2001
From: Valentyn Yukhymenko 
Date: Sun, 19 Jan 2025 23:13:46 +
Subject: [PATCH] [Clang] Reject declaring an alias template with the same name
 as its template parameter.

Fixes llvm#123423
---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/lib/Sema/SemaDeclCXX.cpp| 8 
 .../CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp | 4 ++--
 clang/test/SemaCXX/alias-template.cpp | 5 +++--
 4 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index aa1c02d04f7caa..29e40b4ecab412 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -956,6 +956,7 @@ Bug Fixes to C++ Support
 - Fixed a crash caused by the incorrect construction of template arguments for 
CTAD alias guides when type
   constraints are applied. (#GH122134)
 - Fixed canonicalization of pack indexing types - Clang did not always 
recognized identical pack indexing. (#GH123033)
+- Clang now rejects declaring an alias template with the same name as its 
template parameter. (#GH123423)
 
 
 Bug Fixes to AST Handling
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a867ed73bd4033..4e43a8397cec4e 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, 
AccessSpecifier AS,
 }
 TemplateParameterList *TemplateParams = TemplateParamLists[0];
 
+// Check shadowing of a template parameter name
+for (NamedDecl *TP : TemplateParams->asArray()) {
+  if (NameInfo.getName() == TP->getDeclName()) {
+DiagnoseTemplateParameterShadow(Name.StartLocation, TP);
+return nullptr;
+  }
+}
+
 // Check that we can declare a template here.
 if (CheckTemplateDeclScope(S, TemplateParams))
   return nullptr;
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp 
b/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
index a990c82564aa40..ab4c663d24c7d5 100644
--- a/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
@@ -121,8 +121,8 @@ namespace PartialSpecialization {
 
 namespace FixedAliasTemplate {
   template struct S {};
-  template using U = S; // expected-note 
2{{template parameter is declared here}}
-  template U &f(U, Ts...); // expected-error 
2{{pack expansion used as argument for non-pack parameter of alias template}}
+  template using Z = S; // expected-note 
2{{template parameter is declared here}}
+  template Z &f(Z, Ts...); // expected-error 
2{{pack expansion used as argument for non-pack parameter of alias template}}
   S &s1 = f({}, 0, 0.0); // expected-error {{no matching 
function}}
 }
 
diff --git a/clang/test/SemaCXX/alias-template.cpp 
b/clang/test/SemaCXX/alias-template.cpp
index 5189405e23db56..97134d2f3a96ad 100644
--- a/clang/test/SemaCXX/alias-template.cpp
+++ b/clang/test/SemaCXX/alias-template.cpp
@@ -65,7 +65,8 @@ namespace InFunctions {
   template struct S3 { // expected-note {{template parameter is 
declared here}}
 template using T = int; // expected-error {{declaration of 'T' 
shadows template parameter}}
   };
-  template using Z = Z;
+  template // expected-note {{template parameter is declared here}}
+  using Z = Z; // expected-error {{declaration of 'Z' shadows template 
parameter}}
 }
 
 namespace ClassNameRedecl {
@@ -191,4 +192,4 @@ int g = sfinae_me(); // expected-error{{no matching 
function for call to 's
 
 namespace NullExceptionDecl {
 template auto get = []() { try { } catch(...) {}; return I; }; // 
expected-error{{initializer contains unexpanded parameter pack 'I'}}
-}
+}
\ No newline at end of file

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits

https://github.com/BaLiKfromUA edited 
https://github.com/llvm/llvm-project/pull/123533
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits

https://github.com/BaLiKfromUA ready_for_review 
https://github.com/llvm/llvm-project/pull/123533
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #123499)

2025-01-19 Thread Nikita Popov via cfe-commits

https://github.com/nikic approved this pull request.


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


[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)

2025-01-19 Thread via cfe-commits

cor3ntin wrote:

Thanks for working on that
Did you do a stage 2 build?
I think this is probably Clang 21 material (unless we become sufficiently 
confident before RC3)

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


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: None (DeNiCoN)


Changes

Fixes some typos I've found while reading the documentation

---
Full diff: https://github.com/llvm/llvm-project/pull/123506.diff


6 Files Affected:

- (modified) clang-tools-extra/docs/clang-tidy/Contributing.rst (+3-3) 
- (modified) clang/docs/ClangTransformerTutorial.rst (+1-1) 
- (modified) clang/include/clang/Basic/Diagnostic.h (+1-1) 
- (modified) llvm/docs/DeveloperPolicy.rst (+1-1) 
- (modified) llvm/docs/GitHub.rst (+1-1) 
- (modified) llvm/docs/MyFirstTypoFix.rst (+1-1) 


``diff
diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index ff8b05ff263c14..4f1df8d114 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -331,7 +331,7 @@ a starting point for your test cases.  A rough outline of 
the process looks like
 - Issue the necessary diagnostics and fix-its in the ``check`` method.
 - Add the necessary ``CHECK-MESSAGES`` and ``CHECK-FIXES`` annotations to your
   test case to validate the diagnostics and fix-its.
-- Build the target ``check-clang-tool`` to confirm the test passes.
+- Build the target ``check-clang-tools`` to confirm the test passes.
 - Repeat the process until all aspects of your check are covered by tests.
 
 The quickest way to prototype your matcher is to use :program:`clang-query` to
@@ -519,8 +519,8 @@ the check implements and what the current values are (e.g. 
for the
   public:
 MyCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-SomeOption(Options.get("SomeOption1", -1U)),
-SomeOption(Options.get("SomeOption2", "some default")) {}
+SomeOption1(Options.get("SomeOption1", -1U)),
+SomeOption2(Options.get("SomeOption2", "some default")) {}
 
 void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
   Options.store(Opts, "SomeOption1", SomeOption1);
diff --git a/clang/docs/ClangTransformerTutorial.rst 
b/clang/docs/ClangTransformerTutorial.rst
index b07b83f80f17d1..e9b701203300a2 100644
--- a/clang/docs/ClangTransformerTutorial.rst
+++ b/clang/docs/ClangTransformerTutorial.rst
@@ -70,7 +70,7 @@ can express this a Transformer rewrite rule:
 
 .. code-block:: c++
 
-   makeRule(functionDecl(hasName("MkX").bind("fun"),
+   makeRule(functionDecl(hasName("MkX")).bind("fun"),
noopEdit(node("fun")),
cat("The name ``MkX`` is not allowed for functions; please 
rename"));
 
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 510b782e35d065..8708bd10dc4014 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -224,7 +224,7 @@ class DiagStorageAllocator {
 
 /// Concrete class used by the front-end to report problems and issues.
 ///
-/// This massages the diagnostics (e.g. handling things like "report warnings
+/// This messages the diagnostics (e.g. handling things like "report warnings
 /// as errors" and passes them off to the DiagnosticConsumer for reporting to
 /// the user. DiagnosticsEngine is tied to one translation unit and one
 /// SourceManager.
diff --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 6614d036a014e9..18b05d2e58e6e5 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -136,7 +136,7 @@ awareness of. For such changes, the following should be 
done:
 
 .. warning::
 
-  Phabricator is deprecated is available in read-only mode,
+  Phabricator is deprecated and is available in read-only mode,
   for new code contributions use :ref:`GitHub Pull Requests `.
   This section contains old information that needs to be updated.
 
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 85766bfe94afd2..df0b4841a7bb58 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add a `skip-precommit-approval 
`_
label to the PR.
 
 GitHub Tools
diff --git a/llvm/docs/MyFirstTypoFix.rst b/llvm/docs/MyFirstTypoFix.rst
index 733b3eac141f27..5856615bee8bfa 100644
--- a/llvm/docs/MyFirstTypoFix.rst
+++ b/llvm/docs/MyFirstTypoFix.rst
@@ -378,7 +378,7 @@ your branch with more commits and push to your GitHub fork 
of ``llvm-project``.
 It is best if you answer comments from the reviewer directly instead of 
expecting
 them to read through all the changes again.
 
-For example you might comment "I have done this." or "I was able to this part
+For example you mi

[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (DeNiCoN)


Changes

Fixes some typos I've found while reading the documentation

---
Full diff: https://github.com/llvm/llvm-project/pull/123506.diff


6 Files Affected:

- (modified) clang-tools-extra/docs/clang-tidy/Contributing.rst (+3-3) 
- (modified) clang/docs/ClangTransformerTutorial.rst (+1-1) 
- (modified) clang/include/clang/Basic/Diagnostic.h (+1-1) 
- (modified) llvm/docs/DeveloperPolicy.rst (+1-1) 
- (modified) llvm/docs/GitHub.rst (+1-1) 
- (modified) llvm/docs/MyFirstTypoFix.rst (+1-1) 


``diff
diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index ff8b05ff263c14..4f1df8d114 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -331,7 +331,7 @@ a starting point for your test cases.  A rough outline of 
the process looks like
 - Issue the necessary diagnostics and fix-its in the ``check`` method.
 - Add the necessary ``CHECK-MESSAGES`` and ``CHECK-FIXES`` annotations to your
   test case to validate the diagnostics and fix-its.
-- Build the target ``check-clang-tool`` to confirm the test passes.
+- Build the target ``check-clang-tools`` to confirm the test passes.
 - Repeat the process until all aspects of your check are covered by tests.
 
 The quickest way to prototype your matcher is to use :program:`clang-query` to
@@ -519,8 +519,8 @@ the check implements and what the current values are (e.g. 
for the
   public:
 MyCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-SomeOption(Options.get("SomeOption1", -1U)),
-SomeOption(Options.get("SomeOption2", "some default")) {}
+SomeOption1(Options.get("SomeOption1", -1U)),
+SomeOption2(Options.get("SomeOption2", "some default")) {}
 
 void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
   Options.store(Opts, "SomeOption1", SomeOption1);
diff --git a/clang/docs/ClangTransformerTutorial.rst 
b/clang/docs/ClangTransformerTutorial.rst
index b07b83f80f17d1..e9b701203300a2 100644
--- a/clang/docs/ClangTransformerTutorial.rst
+++ b/clang/docs/ClangTransformerTutorial.rst
@@ -70,7 +70,7 @@ can express this a Transformer rewrite rule:
 
 .. code-block:: c++
 
-   makeRule(functionDecl(hasName("MkX").bind("fun"),
+   makeRule(functionDecl(hasName("MkX")).bind("fun"),
noopEdit(node("fun")),
cat("The name ``MkX`` is not allowed for functions; please 
rename"));
 
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 510b782e35d065..8708bd10dc4014 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -224,7 +224,7 @@ class DiagStorageAllocator {
 
 /// Concrete class used by the front-end to report problems and issues.
 ///
-/// This massages the diagnostics (e.g. handling things like "report warnings
+/// This messages the diagnostics (e.g. handling things like "report warnings
 /// as errors" and passes them off to the DiagnosticConsumer for reporting to
 /// the user. DiagnosticsEngine is tied to one translation unit and one
 /// SourceManager.
diff --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 6614d036a014e9..18b05d2e58e6e5 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -136,7 +136,7 @@ awareness of. For such changes, the following should be 
done:
 
 .. warning::
 
-  Phabricator is deprecated is available in read-only mode,
+  Phabricator is deprecated and is available in read-only mode,
   for new code contributions use :ref:`GitHub Pull Requests `.
   This section contains old information that needs to be updated.
 
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 85766bfe94afd2..df0b4841a7bb58 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add a `skip-precommit-approval 
`_
label to the PR.
 
 GitHub Tools
diff --git a/llvm/docs/MyFirstTypoFix.rst b/llvm/docs/MyFirstTypoFix.rst
index 733b3eac141f27..5856615bee8bfa 100644
--- a/llvm/docs/MyFirstTypoFix.rst
+++ b/llvm/docs/MyFirstTypoFix.rst
@@ -378,7 +378,7 @@ your branch with more commits and push to your GitHub fork 
of ``llvm-project``.
 It is best if you answer comments from the reviewer directly instead of 
expecting
 them to read through all the changes again.
 
-For example you might comment "I have done this." or "I was able to this part
+For example you might comment 

[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: None (DeNiCoN)


Changes

Fixes some typos I've found while reading the documentation

---
Full diff: https://github.com/llvm/llvm-project/pull/123506.diff


6 Files Affected:

- (modified) clang-tools-extra/docs/clang-tidy/Contributing.rst (+3-3) 
- (modified) clang/docs/ClangTransformerTutorial.rst (+1-1) 
- (modified) clang/include/clang/Basic/Diagnostic.h (+1-1) 
- (modified) llvm/docs/DeveloperPolicy.rst (+1-1) 
- (modified) llvm/docs/GitHub.rst (+1-1) 
- (modified) llvm/docs/MyFirstTypoFix.rst (+1-1) 


``diff
diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index ff8b05ff263c14..4f1df8d114 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -331,7 +331,7 @@ a starting point for your test cases.  A rough outline of 
the process looks like
 - Issue the necessary diagnostics and fix-its in the ``check`` method.
 - Add the necessary ``CHECK-MESSAGES`` and ``CHECK-FIXES`` annotations to your
   test case to validate the diagnostics and fix-its.
-- Build the target ``check-clang-tool`` to confirm the test passes.
+- Build the target ``check-clang-tools`` to confirm the test passes.
 - Repeat the process until all aspects of your check are covered by tests.
 
 The quickest way to prototype your matcher is to use :program:`clang-query` to
@@ -519,8 +519,8 @@ the check implements and what the current values are (e.g. 
for the
   public:
 MyCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-SomeOption(Options.get("SomeOption1", -1U)),
-SomeOption(Options.get("SomeOption2", "some default")) {}
+SomeOption1(Options.get("SomeOption1", -1U)),
+SomeOption2(Options.get("SomeOption2", "some default")) {}
 
 void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
   Options.store(Opts, "SomeOption1", SomeOption1);
diff --git a/clang/docs/ClangTransformerTutorial.rst 
b/clang/docs/ClangTransformerTutorial.rst
index b07b83f80f17d1..e9b701203300a2 100644
--- a/clang/docs/ClangTransformerTutorial.rst
+++ b/clang/docs/ClangTransformerTutorial.rst
@@ -70,7 +70,7 @@ can express this a Transformer rewrite rule:
 
 .. code-block:: c++
 
-   makeRule(functionDecl(hasName("MkX").bind("fun"),
+   makeRule(functionDecl(hasName("MkX")).bind("fun"),
noopEdit(node("fun")),
cat("The name ``MkX`` is not allowed for functions; please 
rename"));
 
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 510b782e35d065..8708bd10dc4014 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -224,7 +224,7 @@ class DiagStorageAllocator {
 
 /// Concrete class used by the front-end to report problems and issues.
 ///
-/// This massages the diagnostics (e.g. handling things like "report warnings
+/// This messages the diagnostics (e.g. handling things like "report warnings
 /// as errors" and passes them off to the DiagnosticConsumer for reporting to
 /// the user. DiagnosticsEngine is tied to one translation unit and one
 /// SourceManager.
diff --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 6614d036a014e9..18b05d2e58e6e5 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -136,7 +136,7 @@ awareness of. For such changes, the following should be 
done:
 
 .. warning::
 
-  Phabricator is deprecated is available in read-only mode,
+  Phabricator is deprecated and is available in read-only mode,
   for new code contributions use :ref:`GitHub Pull Requests `.
   This section contains old information that needs to be updated.
 
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 85766bfe94afd2..df0b4841a7bb58 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add a `skip-precommit-approval 
`_
label to the PR.
 
 GitHub Tools
diff --git a/llvm/docs/MyFirstTypoFix.rst b/llvm/docs/MyFirstTypoFix.rst
index 733b3eac141f27..5856615bee8bfa 100644
--- a/llvm/docs/MyFirstTypoFix.rst
+++ b/llvm/docs/MyFirstTypoFix.rst
@@ -378,7 +378,7 @@ your branch with more commits and push to your GitHub fork 
of ``llvm-project``.
 It is best if you answer comments from the reviewer directly instead of 
expecting
 them to read through all the changes again.
 
-For example you might comment "I have done this." or "I was able to this part
+For example you might com

[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

https://github.com/DeNiCoN created 
https://github.com/llvm/llvm-project/pull/123506

Fixes some typos I've found while reading the documentation

>From f1691c219527e96832316a853d60985fc72115ef Mon Sep 17 00:00:00 2001
From: DeNiCoN 
Date: Tue, 14 Jan 2025 07:30:08 +0100
Subject: [PATCH] Fix some typos

---
 clang-tools-extra/docs/clang-tidy/Contributing.rst | 6 +++---
 clang/docs/ClangTransformerTutorial.rst| 2 +-
 clang/include/clang/Basic/Diagnostic.h | 2 +-
 llvm/docs/DeveloperPolicy.rst  | 2 +-
 llvm/docs/GitHub.rst   | 2 +-
 llvm/docs/MyFirstTypoFix.rst   | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index ff8b05ff263c14..4f1df8d114 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -331,7 +331,7 @@ a starting point for your test cases.  A rough outline of 
the process looks like
 - Issue the necessary diagnostics and fix-its in the ``check`` method.
 - Add the necessary ``CHECK-MESSAGES`` and ``CHECK-FIXES`` annotations to your
   test case to validate the diagnostics and fix-its.
-- Build the target ``check-clang-tool`` to confirm the test passes.
+- Build the target ``check-clang-tools`` to confirm the test passes.
 - Repeat the process until all aspects of your check are covered by tests.
 
 The quickest way to prototype your matcher is to use :program:`clang-query` to
@@ -519,8 +519,8 @@ the check implements and what the current values are (e.g. 
for the
   public:
 MyCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-SomeOption(Options.get("SomeOption1", -1U)),
-SomeOption(Options.get("SomeOption2", "some default")) {}
+SomeOption1(Options.get("SomeOption1", -1U)),
+SomeOption2(Options.get("SomeOption2", "some default")) {}
 
 void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
   Options.store(Opts, "SomeOption1", SomeOption1);
diff --git a/clang/docs/ClangTransformerTutorial.rst 
b/clang/docs/ClangTransformerTutorial.rst
index b07b83f80f17d1..e9b701203300a2 100644
--- a/clang/docs/ClangTransformerTutorial.rst
+++ b/clang/docs/ClangTransformerTutorial.rst
@@ -70,7 +70,7 @@ can express this a Transformer rewrite rule:
 
 .. code-block:: c++
 
-   makeRule(functionDecl(hasName("MkX").bind("fun"),
+   makeRule(functionDecl(hasName("MkX")).bind("fun"),
noopEdit(node("fun")),
cat("The name ``MkX`` is not allowed for functions; please 
rename"));
 
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 510b782e35d065..8708bd10dc4014 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -224,7 +224,7 @@ class DiagStorageAllocator {
 
 /// Concrete class used by the front-end to report problems and issues.
 ///
-/// This massages the diagnostics (e.g. handling things like "report warnings
+/// This messages the diagnostics (e.g. handling things like "report warnings
 /// as errors" and passes them off to the DiagnosticConsumer for reporting to
 /// the user. DiagnosticsEngine is tied to one translation unit and one
 /// SourceManager.
diff --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 6614d036a014e9..18b05d2e58e6e5 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -136,7 +136,7 @@ awareness of. For such changes, the following should be 
done:
 
 .. warning::
 
-  Phabricator is deprecated is available in read-only mode,
+  Phabricator is deprecated and is available in read-only mode,
   for new code contributions use :ref:`GitHub Pull Requests `.
   This section contains old information that needs to be updated.
 
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 85766bfe94afd2..df0b4841a7bb58 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add a `skip-precommit-approval 
`_
label to the PR.
 
 GitHub Tools
diff --git a/llvm/docs/MyFirstTypoFix.rst b/llvm/docs/MyFirstTypoFix.rst
index 733b3eac141f27..5856615bee8bfa 100644
--- a/llvm/docs/MyFirstTypoFix.rst
+++ b/llvm/docs/MyFirstTypoFix.rst
@@ -378,7 +378,7 @@ your branch with more commits and push to your GitHub fork 
of ``llvm-project``.
 It is best if you answer comments from the reviewer directly instead of 
expecting
 them to read through al

[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] Reapply "[Clang][Sema] Use the correct lookup context when building overloaded 'operator->' in the current instantiation (#104458)" (PR #109422)

2025-01-19 Thread via cfe-commits

cor3ntin wrote:

@sdkrystian ping

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


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 approved this pull request.

lgtm for clangtidy part.

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


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits


@@ -224,7 +224,7 @@ class DiagStorageAllocator {
 
 /// Concrete class used by the front-end to report problems and issues.
 ///
-/// This massages the diagnostics (e.g. handling things like "report warnings
+/// This messages the diagnostics (e.g. handling things like "report warnings

cor3ntin wrote:

I think `massages` is correct here (as in adapts/cleans up)

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


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits


@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add a `skip-precommit-approval 
`_

cor3ntin wrote:

```suggestion
   add the `skip-precommit-approval 
`_
```

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


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

https://github.com/DeNiCoN updated 
https://github.com/llvm/llvm-project/pull/123506

>From f1691c219527e96832316a853d60985fc72115ef Mon Sep 17 00:00:00 2001
From: DeNiCoN 
Date: Tue, 14 Jan 2025 07:30:08 +0100
Subject: [PATCH 1/2] Fix some typos

---
 clang-tools-extra/docs/clang-tidy/Contributing.rst | 6 +++---
 clang/docs/ClangTransformerTutorial.rst| 2 +-
 clang/include/clang/Basic/Diagnostic.h | 2 +-
 llvm/docs/DeveloperPolicy.rst  | 2 +-
 llvm/docs/GitHub.rst   | 2 +-
 llvm/docs/MyFirstTypoFix.rst   | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index ff8b05ff263c14..4f1df8d114 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -331,7 +331,7 @@ a starting point for your test cases.  A rough outline of 
the process looks like
 - Issue the necessary diagnostics and fix-its in the ``check`` method.
 - Add the necessary ``CHECK-MESSAGES`` and ``CHECK-FIXES`` annotations to your
   test case to validate the diagnostics and fix-its.
-- Build the target ``check-clang-tool`` to confirm the test passes.
+- Build the target ``check-clang-tools`` to confirm the test passes.
 - Repeat the process until all aspects of your check are covered by tests.
 
 The quickest way to prototype your matcher is to use :program:`clang-query` to
@@ -519,8 +519,8 @@ the check implements and what the current values are (e.g. 
for the
   public:
 MyCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-SomeOption(Options.get("SomeOption1", -1U)),
-SomeOption(Options.get("SomeOption2", "some default")) {}
+SomeOption1(Options.get("SomeOption1", -1U)),
+SomeOption2(Options.get("SomeOption2", "some default")) {}
 
 void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
   Options.store(Opts, "SomeOption1", SomeOption1);
diff --git a/clang/docs/ClangTransformerTutorial.rst 
b/clang/docs/ClangTransformerTutorial.rst
index b07b83f80f17d1..e9b701203300a2 100644
--- a/clang/docs/ClangTransformerTutorial.rst
+++ b/clang/docs/ClangTransformerTutorial.rst
@@ -70,7 +70,7 @@ can express this a Transformer rewrite rule:
 
 .. code-block:: c++
 
-   makeRule(functionDecl(hasName("MkX").bind("fun"),
+   makeRule(functionDecl(hasName("MkX")).bind("fun"),
noopEdit(node("fun")),
cat("The name ``MkX`` is not allowed for functions; please 
rename"));
 
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 510b782e35d065..8708bd10dc4014 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -224,7 +224,7 @@ class DiagStorageAllocator {
 
 /// Concrete class used by the front-end to report problems and issues.
 ///
-/// This massages the diagnostics (e.g. handling things like "report warnings
+/// This messages the diagnostics (e.g. handling things like "report warnings
 /// as errors" and passes them off to the DiagnosticConsumer for reporting to
 /// the user. DiagnosticsEngine is tied to one translation unit and one
 /// SourceManager.
diff --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 6614d036a014e9..18b05d2e58e6e5 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -136,7 +136,7 @@ awareness of. For such changes, the following should be 
done:
 
 .. warning::
 
-  Phabricator is deprecated is available in read-only mode,
+  Phabricator is deprecated and is available in read-only mode,
   for new code contributions use :ref:`GitHub Pull Requests `.
   This section contains old information that needs to be updated.
 
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 85766bfe94afd2..df0b4841a7bb58 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add a `skip-precommit-approval 
`_
label to the PR.
 
 GitHub Tools
diff --git a/llvm/docs/MyFirstTypoFix.rst b/llvm/docs/MyFirstTypoFix.rst
index 733b3eac141f27..5856615bee8bfa 100644
--- a/llvm/docs/MyFirstTypoFix.rst
+++ b/llvm/docs/MyFirstTypoFix.rst
@@ -378,7 +378,7 @@ your branch with more commits and push to your GitHub fork 
of ``llvm-project``.
 It is best if you answer comments from the reviewer directly instead of 
expecting
 them to read through all the changes again.
 
-For example you might comment "I 

[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits

https://github.com/DeNiCoN updated 
https://github.com/llvm/llvm-project/pull/123506

>From f1691c219527e96832316a853d60985fc72115ef Mon Sep 17 00:00:00 2001
From: DeNiCoN 
Date: Tue, 14 Jan 2025 07:30:08 +0100
Subject: [PATCH 1/3] Fix some typos

---
 clang-tools-extra/docs/clang-tidy/Contributing.rst | 6 +++---
 clang/docs/ClangTransformerTutorial.rst| 2 +-
 clang/include/clang/Basic/Diagnostic.h | 2 +-
 llvm/docs/DeveloperPolicy.rst  | 2 +-
 llvm/docs/GitHub.rst   | 2 +-
 llvm/docs/MyFirstTypoFix.rst   | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index ff8b05ff263c14..4f1df8d114 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -331,7 +331,7 @@ a starting point for your test cases.  A rough outline of 
the process looks like
 - Issue the necessary diagnostics and fix-its in the ``check`` method.
 - Add the necessary ``CHECK-MESSAGES`` and ``CHECK-FIXES`` annotations to your
   test case to validate the diagnostics and fix-its.
-- Build the target ``check-clang-tool`` to confirm the test passes.
+- Build the target ``check-clang-tools`` to confirm the test passes.
 - Repeat the process until all aspects of your check are covered by tests.
 
 The quickest way to prototype your matcher is to use :program:`clang-query` to
@@ -519,8 +519,8 @@ the check implements and what the current values are (e.g. 
for the
   public:
 MyCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
-SomeOption(Options.get("SomeOption1", -1U)),
-SomeOption(Options.get("SomeOption2", "some default")) {}
+SomeOption1(Options.get("SomeOption1", -1U)),
+SomeOption2(Options.get("SomeOption2", "some default")) {}
 
 void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
   Options.store(Opts, "SomeOption1", SomeOption1);
diff --git a/clang/docs/ClangTransformerTutorial.rst 
b/clang/docs/ClangTransformerTutorial.rst
index b07b83f80f17d1..e9b701203300a2 100644
--- a/clang/docs/ClangTransformerTutorial.rst
+++ b/clang/docs/ClangTransformerTutorial.rst
@@ -70,7 +70,7 @@ can express this a Transformer rewrite rule:
 
 .. code-block:: c++
 
-   makeRule(functionDecl(hasName("MkX").bind("fun"),
+   makeRule(functionDecl(hasName("MkX")).bind("fun"),
noopEdit(node("fun")),
cat("The name ``MkX`` is not allowed for functions; please 
rename"));
 
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 510b782e35d065..8708bd10dc4014 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -224,7 +224,7 @@ class DiagStorageAllocator {
 
 /// Concrete class used by the front-end to report problems and issues.
 ///
-/// This massages the diagnostics (e.g. handling things like "report warnings
+/// This messages the diagnostics (e.g. handling things like "report warnings
 /// as errors" and passes them off to the DiagnosticConsumer for reporting to
 /// the user. DiagnosticsEngine is tied to one translation unit and one
 /// SourceManager.
diff --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 6614d036a014e9..18b05d2e58e6e5 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -136,7 +136,7 @@ awareness of. For such changes, the following should be 
done:
 
 .. warning::
 
-  Phabricator is deprecated is available in read-only mode,
+  Phabricator is deprecated and is available in read-only mode,
   for new code contributions use :ref:`GitHub Pull Requests `.
   This section contains old information that needs to be updated.
 
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 85766bfe94afd2..df0b4841a7bb58 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add a `skip-precommit-approval 
`_
label to the PR.
 
 GitHub Tools
diff --git a/llvm/docs/MyFirstTypoFix.rst b/llvm/docs/MyFirstTypoFix.rst
index 733b3eac141f27..5856615bee8bfa 100644
--- a/llvm/docs/MyFirstTypoFix.rst
+++ b/llvm/docs/MyFirstTypoFix.rst
@@ -378,7 +378,7 @@ your branch with more commits and push to your GitHub fork 
of ``llvm-project``.
 It is best if you answer comments from the reviewer directly instead of 
expecting
 them to read through all the changes again.
 
-For example you might comment "I 

[clang] 0cb2fe5 - [Clang] Deprecate __is_referenceable (#123185)

2025-01-19 Thread via cfe-commits

Author: Nikolas Klauser
Date: 2025-01-19T10:28:38+01:00
New Revision: 0cb2fe5183c9b25bb96140c27d12b1ad4a80aa92

URL: 
https://github.com/llvm/llvm-project/commit/0cb2fe5183c9b25bb96140c27d12b1ad4a80aa92
DIFF: 
https://github.com/llvm/llvm-project/commit/0cb2fe5183c9b25bb96140c27d12b1ad4a80aa92.diff

LOG: [Clang] Deprecate __is_referenceable (#123185)

`__is_referenceable` is almost unused in the wild, and the few cases I
was able to find had checks around them. Since The places in the
standard library where `__is_referenceable` is used have bespoke
builtins, it doesn't make a ton of sense to keep this builtin around.

See #123078

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 2eb0777dbdc6c8..3aabb4f87fe9b8 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1697,7 +1697,7 @@ The following type trait primitives are supported by 
Clang. Those traits marked
 * ``__is_referenceable`` (C++, GNU, Microsoft, Embarcadero):
   Returns true if a type is referenceable, and false otherwise. A referenceable
   type is a type that's either an object type, a reference type, or an 
unqualified
-  function type.
+  function type. This trait is deprecated and will be removed in Clang 21.
 * ``__is_rvalue_reference`` (C++, Embarcadero)
 * ``__is_same`` (C++, Embarcadero)
 * ``__is_same_as`` (GCC): Synonym for ``__is_same``.

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 14a3b5db05ff3b..b02ac467cd3a22 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -93,6 +93,11 @@ C++ Specific Potentially Breaking Changes
   few users and can be written as ``__is_same(__remove_cv(T), 
decltype(nullptr))``,
   which GCC supports as well.
 
+- The type trait builtin ``__is_referenceable`` has been deprecated, since it 
has
+  very few users and all the type traits that could benefit from it in the
+  standard library already have their own bespoke builtins. It will be removed 
in
+  Clang 21.
+
 - Clang will now correctly diagnose as ill-formed a constant expression where 
an
   enum without a fixed underlying type is set to a value outside the range of
   the enumeration's values.
@@ -310,7 +315,7 @@ C++23 Feature Support
 
 - Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now 
fully
   supports `P2718R0 Lifetime extension in range-based for loops 
`_.
-  
+
 - ``__cpp_explicit_this_parameter`` is now defined. (#GH82780)
 
 C++20 Feature Support
@@ -717,7 +722,7 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses dangling references for C++20's parenthesized aggregate 
initialization (#101957).
 
-- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings 
when an unrelated class 
+- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings 
when an unrelated class
   defined a defaulted comparison operator (#GH116270).
 
   .. code-block:: c++
@@ -937,7 +942,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure caused by invalid default argument substitutions 
in non-defining
   friend declarations. (#GH113324)
 - Fix a crash caused by incorrect argument position in merging deduced 
template arguments. (#GH113659)
-- Fixed a parser crash when using pack indexing as a nested name specifier. 
(#GH119072) 
+- Fixed a parser crash when using pack indexing as a nested name specifier. 
(#GH119072)
 - Fixed a null pointer dereference issue when heuristically computing 
``sizeof...(pack)`` expressions. (#GH81436)
 - Fixed an assertion failure caused by mangled names with invalid identifiers. 
(#GH112205)
 - Fixed an incorrect lambda scope of generic lambdas that caused Clang to 
crash when computing potential lambda



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits


@@ -50,7 +50,7 @@ documentation refer to `GitHub's documentation 
`_
+   add a `skip-precommit-approval 
`_

DeNiCoN wrote:

fixed

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


[clang] [Clang] Deprecate __is_referenceable (PR #123185)

2025-01-19 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 closed 
https://github.com/llvm/llvm-project/pull/123185
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] Fix some typos (PR #123506)

2025-01-19 Thread via cfe-commits


@@ -224,7 +224,7 @@ class DiagStorageAllocator {
 
 /// Concrete class used by the front-end to report problems and issues.
 ///
-/// This massages the diagnostics (e.g. handling things like "report warnings
+/// This messages the diagnostics (e.g. handling things like "report warnings

DeNiCoN wrote:

I'm not sure. This is an old comment so I think its better to left it as is. 
Reverted the change

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


[clang] [Clang] handle [[warn_unused]] attribute for unused private fields (PR #120734)

2025-01-19 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/120734

>From 55fb96c1673911f30721c2a53bea32e7e4b5dc6e Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Fri, 20 Dec 2024 15:32:55 +0200
Subject: [PATCH 1/3] [Clang] handle [[warn_unused]] attribute for unused
 private fields

---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp| 43 +++
 .../SemaCXX/warn-unused-private-field.cpp | 13 ++
 3 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a85ef60b7b58ba..c1d3596140721e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -707,6 +707,7 @@ Improvements to Clang's diagnostics
 }
 
 - Fix -Wdangling false positives on conditional operators (#120206).
+- Clang now diagnoses unused private fields with the ``[[warn_unused]]`` 
attribute (#GH62472).
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c5a72cf812ebc9..760ed06fc1b858 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -3307,6 +3307,29 @@ void Sema::CheckShadowInheritedFields(const 
SourceLocation &Loc,
   }
 }
 
+template 
+inline static bool HasAttribute(const QualType &T) {
+  if (const TagDecl *TD = T->getAsTagDecl())
+return TD->hasAttr();
+  if (const TypedefType *TDT = T->getAs())
+return TDT->getDecl()->hasAttr();
+  return false;
+}
+
+inline static bool IsUnusedPrivateField(FieldDecl *FD) {
+  if (FD->getAccess() == AS_private && FD->getDeclName()) {
+QualType FieldType = FD->getType();
+if (HasAttribute(FieldType))
+  return true;
+
+return !FD->isImplicit() && !FD->hasAttr() &&
+   !FD->getParent()->isDependentContext() &&
+   !HasAttribute(FieldType) &&
+   !InitializationHasSideEffects(*FD);
+  }
+  return false;
+}
+
 NamedDecl *
 Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
MultiTemplateParamsArg TemplateParameterLists,
@@ -3589,25 +3612,11 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, 
AccessSpecifier AS, Declarator &D,
 FieldDecl *FD = cast(Member);
 FieldCollector->Add(FD);
 
-if (!Diags.isIgnored(diag::warn_unused_private_field, FD->getLocation())) {
+if (!Diags.isIgnored(diag::warn_unused_private_field, FD->getLocation()) &&
+IsUnusedPrivateField(FD)) {
   // Remember all explicit private FieldDecls that have a name, no side
   // effects and are not part of a dependent type declaration.
-
-  auto DeclHasUnusedAttr = [](const QualType &T) {
-if (const TagDecl *TD = T->getAsTagDecl())
-  return TD->hasAttr();
-if (const TypedefType *TDT = T->getAs())
-  return TDT->getDecl()->hasAttr();
-return false;
-  };
-
-  if (!FD->isImplicit() && FD->getDeclName() &&
-  FD->getAccess() == AS_private &&
-  !FD->hasAttr() &&
-  !FD->getParent()->isDependentContext() &&
-  !DeclHasUnusedAttr(FD->getType()) &&
-  !InitializationHasSideEffects(*FD))
-UnusedPrivateFields.insert(FD);
+  UnusedPrivateFields.insert(FD);
 }
   }
 
diff --git a/clang/test/SemaCXX/warn-unused-private-field.cpp 
b/clang/test/SemaCXX/warn-unused-private-field.cpp
index 0cc6f687f1b35f..93a285b159f740 100644
--- a/clang/test/SemaCXX/warn-unused-private-field.cpp
+++ b/clang/test/SemaCXX/warn-unused-private-field.cpp
@@ -329,3 +329,16 @@ class C {
   MaybeUnusedTypedef t; // no-warning
 };
 }
+
+namespace GH62472 {
+class [[gnu::warn_unused]] S {
+public:
+  S();
+};
+
+class C {
+private:
+  const int i = 0; // expected-warning {{private field 'i' is not used}}
+  const S s;   // expected-warning {{private field 's' is not used}}
+};
+}

>From ff26d33c97f9eaf7c1d2c21cf341cb771d831be5 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 18 Jan 2025 01:46:03 +0200
Subject: [PATCH 2/3] add additional test cases

---
 .../SemaCXX/warn-unused-private-field.cpp | 26 ++-
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/clang/test/SemaCXX/warn-unused-private-field.cpp 
b/clang/test/SemaCXX/warn-unused-private-field.cpp
index 93a285b159f740..0bcca6b82227f9 100644
--- a/clang/test/SemaCXX/warn-unused-private-field.cpp
+++ b/clang/test/SemaCXX/warn-unused-private-field.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-private-field 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++11 %s
-// RUN: %clang_cc1 -fsyntax-only -Wunused-private-field 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++17 %s
-// RUN: %clang_cc1 -fsyntax-only -Wunused-private-field 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++20 %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused 
-Wno-uninitialized -verify -std=c++

[clang] [Clang] handle [[warn_unused]] attribute for unused private fields (PR #120734)

2025-01-19 Thread Oleksandr T. via cfe-commits


@@ -3307,6 +3307,29 @@ void Sema::CheckShadowInheritedFields(const 
SourceLocation &Loc,
   }
 }
 
+template 
+inline static bool HasAttribute(const QualType &T) {
+  if (const TagDecl *TD = T->getAsTagDecl())
+return TD->hasAttr();
+  if (const TypedefType *TDT = T->getAs())
+return TDT->getDecl()->hasAttr();
+  return false;
+}
+
+inline static bool IsUnusedPrivateField(FieldDecl *FD) {

a-tarasyuk wrote:

Thanks for the feedback. I've added changes.

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


[clang] [clang][bytecode] Fix discarding DerivedToBase casts (PR #123523)

2025-01-19 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/123523

>From db874d225e0994587ca15384679d070651e0cc99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 19 Jan 2025 19:48:31 +0100
Subject: [PATCH] [clang][bytecode] Fix discarding DerivedToBase casts

---
 clang/lib/AST/ByteCode/Compiler.cpp |  6 ++
 clang/test/AST/ByteCode/records.cpp | 15 +++
 2 files changed, 21 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7afae97f308ad5..750516efa1a3e1 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -253,6 +253,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
 
   case CK_UncheckedDerivedToBase:
   case CK_DerivedToBase: {
+if (DiscardResult)
+  return this->discard(SubExpr);
+
 if (!this->delegate(SubExpr))
   return false;
 
@@ -282,6 +285,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   }
 
   case CK_BaseToDerived: {
+if (DiscardResult)
+  return this->discard(SubExpr);
+
 if (!this->delegate(SubExpr))
   return false;
 
diff --git a/clang/test/AST/ByteCode/records.cpp 
b/clang/test/AST/ByteCode/records.cpp
index d329219264d893..9470e7d8e3dcbf 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -1684,3 +1684,18 @@ namespace ExplicitThisInTemporary {
   constexpr bool g(B b) { return &b == b.p; }
   static_assert(g({}), "");
 }
+
+namespace IgnoredMemberExpr {
+  class A {
+  public:
+int a;
+  };
+  class B : public A {
+  public:
+constexpr int foo() {
+  a; // both-warning {{expression result unused}}
+  return 0;
+}
+  };
+  static_assert(B{}.foo() == 0, "");
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)

2025-01-19 Thread via cfe-commits

Sirraide wrote:

> Did you do a stage 2 build?

Not yet; that’s probably a good idea.

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


[clang] [lldb] [llvm] Patch series to reapply #118734 and substantially improve it (PR #120534)

2025-01-19 Thread via cfe-commits

dyung wrote:

> @dyung - OK, I think the current just-pushed version of this PR is worth 
> another test.
> 
> I've taught the TableGen string table emission to go back to working around 
> the MSVC issues using a different table form that we used to use in LLVM when 
> MSVC had a reliable error on it. It appears that now it only sometimes gets 
> miscompiled, and so this workaround got accidentally removed without really 
> being in a reliable place.
> 
> But that still requires that all of the large string tables go through 
> TableGen to get emitted in this form. So I've sent two PRs (separately, they 
> seem independently good) to move NVPTX and Hexagon to TableGen, and this PR 
> contains patches to move more of the ARM builtins to TableGen.
> 
> I _think_ this gets all of the ones that produced too-large string tables, 
> but testing should show. Let me know. If this works and there isn't a really 
> short path to upgrade, I'll start pulling some of the pre-requisite PRs out 
> for independent review, and then update this PR once I'm down to the minimal 
> chain of PRs that do the full conversion of builtins to string tables.
> 
> Thanks, -Chandler

Some good news, everything seems to pass after your latest changes in this PR! 
I didn't believe it at first and did a clean rebuild and test to verify. In the 
end everything passed again.

That being said, I am working on deploying an updated version of VS2019 to our 
internal builders. I have gotten agreement with the plan, the only possible 
hold-up is that we would need to rebuild our internal builders which likely may 
not get done for a few weeks. I can apply quick work-arounds to the machines, 
but they ultimately will need to be rebuilt.

Would you prefer to move forward with the solution currently implemented in 
this PR or for us to update our internal builders?

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


[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits

https://github.com/BaLiKfromUA created 
https://github.com/llvm/llvm-project/pull/123533

Fixes llvm#123423

**How did I test it?**

Modified existing test and checked an example from the issue manually.


>From 0852c8ca587e772d5f851ac0983f43bdeec2ebd5 Mon Sep 17 00:00:00 2001
From: Valentyn Yukhymenko 
Date: Sun, 19 Jan 2025 23:13:46 +
Subject: [PATCH] [Clang] Reject declaring an alias template with the same name
 as its template parameter.

Fixes llvm#123423
---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/lib/Sema/SemaDeclCXX.cpp| 8 
 clang/test/SemaCXX/alias-template.cpp | 5 +++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index aa1c02d04f7caa..29e40b4ecab412 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -956,6 +956,7 @@ Bug Fixes to C++ Support
 - Fixed a crash caused by the incorrect construction of template arguments for 
CTAD alias guides when type
   constraints are applied. (#GH122134)
 - Fixed canonicalization of pack indexing types - Clang did not always 
recognized identical pack indexing. (#GH123033)
+- Clang now rejects declaring an alias template with the same name as its 
template parameter. (#GH123423)
 
 
 Bug Fixes to AST Handling
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a867ed73bd4033..4e43a8397cec4e 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, 
AccessSpecifier AS,
 }
 TemplateParameterList *TemplateParams = TemplateParamLists[0];
 
+// Check shadowing of a template parameter name
+for (NamedDecl *TP : TemplateParams->asArray()) {
+  if (NameInfo.getName() == TP->getDeclName()) {
+DiagnoseTemplateParameterShadow(Name.StartLocation, TP);
+return nullptr;
+  }
+}
+
 // Check that we can declare a template here.
 if (CheckTemplateDeclScope(S, TemplateParams))
   return nullptr;
diff --git a/clang/test/SemaCXX/alias-template.cpp 
b/clang/test/SemaCXX/alias-template.cpp
index 5189405e23db56..97134d2f3a96ad 100644
--- a/clang/test/SemaCXX/alias-template.cpp
+++ b/clang/test/SemaCXX/alias-template.cpp
@@ -65,7 +65,8 @@ namespace InFunctions {
   template struct S3 { // expected-note {{template parameter is 
declared here}}
 template using T = int; // expected-error {{declaration of 'T' 
shadows template parameter}}
   };
-  template using Z = Z;
+  template // expected-note {{template parameter is declared here}}
+  using Z = Z; // expected-error {{declaration of 'Z' shadows template 
parameter}}
 }
 
 namespace ClassNameRedecl {
@@ -191,4 +192,4 @@ int g = sfinae_me(); // expected-error{{no matching 
function for call to 's
 
 namespace NullExceptionDecl {
 template auto get = []() { try { } catch(...) {}; return I; }; // 
expected-error{{initializer contains unexpanded parameter pack 'I'}}
-}
+}
\ No newline at end of file

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [llvm] [Clang] Match MSVC handling of duplicate header search paths in Microsoft compatibility modes. (PR #105738)

2025-01-19 Thread Tom Honermann via cfe-commits

https://github.com/tahonermann updated 
https://github.com/llvm/llvm-project/pull/105738

>From c5d4a8b94d0f5b294dda30b455c492e0a860906a Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Thu, 22 Aug 2024 09:44:56 -0700
Subject: [PATCH] [Clang] Support for MSVC compatible header search path
 ordering.

Clang has historically matched GCC's behavior for header search path order
and pruning of duplicate paths. That traditional behavior is to order user
search paths before system search paths, to ignore user search paths that
duplicate a (later) system search path, and to ignore search paths that
duplicate an earlier search path of the same user/system kind. This differs
from MSVC and can result in inconsistent header file resolution for `#include`
directives.

MSVC orders header search paths as follows:
1) Paths specified by the `/I` and `/external:I` options are processed in
   the order that they appear. Paths specified by `/I` that duplicate a path
   specified by `/external:I` are ignored regardless of the order of the
   options. Paths specified by `/I` that duplicate a path from a prior `/I`
   option are ignored. Paths specified by `/external:I` that duplicate a
   path from a later `/external:I` option are ignored.
2) Paths specified by `/external:env` are processed in the order that they
   appear. Paths that duplicate a path from a `/I` or `/external:I` option
   are ignored regardless of the order of the options. Paths that duplicate a
   path from a prior `/external:env` option or an earlier path from the same
   `/external:env` option are ignored.
3) Paths specified by the `INCLUDE` environment variable are processed in
   the order they appear. Paths that duplicate a path from a `/I`,
   `/external:I`, or `/external:env` option are ignored. Paths that
   duplicate an earlier path in the `INCLUDE` environment variable are
   ignored.
4) Paths specified by the `EXTERNAL_INCLUDE` environment variable are
   processed in the order they appear. Paths that duplicate a path from a
   `/I`, `/external:I`, or `/external:env` option are ignored. Paths that
   duplicate a path from the `INCLUDE` environment variable are ignored.
   Paths that duplicate an earlier path in the `EXTERNAL_INCLUDE
   environment variable are ignored.

Prior to this change, Clang handled the MSVC `/external:I` and `/external:env`
options and the paths present in the `INCLUDE` and `EXTERNAL_INCLUDE`
environment variables as though they were specified with the `-isystem` option.
The GCC behavior described above then lead to a command line such as
`/external:I dir1 /Idir2` having a header search order of `dir2` followed by
`dir1`; contrary to MSVC behavior.

Paths specified by the MSVC `/external:I` or `/external:env` options or by the
`EXTERNAL_INCLUDE` environment variable are not just used to nominate a header
search path. MSVC also uses these paths as external directory prefixes to mark
paths that are to be treated as system directories. When a header file is
resolved to a path for which one of these paths is a prefix match, that header
file is treated as a system header regardless of whether the header file was
resolved against a `/I` specified path. Note that it is not necessary for the
final path component of the external path to match a directory in the filesystem
in order to be used as an external directory prefix, though trailing path
separators are significant. For example:

   Include directive Command line System header
     --   -
   #include   /I. /external:Ifoo   Yes
   #include   /I. /external:Ifoo\  No

This change adds support for the MSVC external path concept through the addition
of new driver options with the following option syntax.
   clang clang-cl
     ---
   -iexternal   /external:I 
   -iexternal-env=  /external:env:

Paths specified by these options are treated as system paths. That is, whether
warnings are issued in header files found via these paths remains subject to
use of the `-Wsystem-headers` and `-Wno-system-headers` options. Note that the
MSVC `/external:W` options are mapped to these options.

The MSVC behavior described above implies that (system) paths present in the
`INCLUDE` and `EXTERNAL_INCLUDE` environment variables do not suppress matching
user paths specified via `/I`. This contrasts with GCC's behavior, and Clang's
historical behavior, of suppressing user paths that match a system path
regardless of how each is specified. In order to support both behaviors, the
following driver option has been added. The option arguments shown reflect the
default behavior for each driver.

   clang clang-cl
     -
   -fheader-search=gcc   -fheader-search=microsoft

Use of the MSVC compatible header search path order by default for `clang-cl`
is a change in behavior with potential to cause p

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits


@@ -65,7 +65,8 @@ namespace InFunctions {
   template struct S3 { // expected-note {{template parameter is 
declared here}}
 template using T = int; // expected-error {{declaration of 'T' 
shadows template parameter}}
   };
-  template using Z = Z;
+  template // expected-note {{template parameter is declared here}}
+  using Z = Z; // expected-error {{declaration of 'Z' shadows template 
parameter}}

BaLiKfromUA wrote:

I am not sure that `InFunctions` is the correct namespace for this test but it 
was here before and I adapted this use case to the new behavior.

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


[clang-tools-extra] [clang-tidy] Added support for 3-argument std::string ctor in bugprone-string-constructor check (PR #123413)

2025-01-19 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor updated 
https://github.com/llvm/llvm-project/pull/123413

>From f5f0ba142a2eb71ce781faf4e15fcd225bec9ca8 Mon Sep 17 00:00:00 2001
From: Victor Baranov 
Date: Sat, 18 Jan 2025 00:49:29 +0300
Subject: [PATCH 1/2] [clang-tidy] Added support for 3-argument string ctor

---
 .../bugprone/StringConstructorCheck.cpp   | 50 +--
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../checkers/bugprone/string-constructor.cpp  | 30 +++
 3 files changed, 80 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
index 8ae4351ac2830a..d1902b658061b1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
@@ -82,7 +82,7 @@ void StringConstructorCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(
   cxxConstructExpr(
   hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
-  hasArgument(0, hasType(qualType(isInteger(,
+  argumentCountIs(2), hasArgument(0, hasType(qualType(isInteger(,
   hasArgument(1, hasType(qualType(isInteger(,
   anyOf(
   // Detect the expression: string('x', 40);
@@ -102,7 +102,7 @@ void StringConstructorCheck::registerMatchers(MatchFinder 
*Finder) {
   cxxConstructExpr(
   hasDeclaration(cxxConstructorDecl(ofClass(
   cxxRecordDecl(hasAnyName(removeNamespaces(StringNames)),
-  hasArgument(0, hasType(CharPtrType)),
+  argumentCountIs(2), hasArgument(0, hasType(CharPtrType)),
   hasArgument(1, hasType(isInteger())),
   anyOf(
   // Detect the expression: string("...", 0);
@@ -114,7 +114,34 @@ void StringConstructorCheck::registerMatchers(MatchFinder 
*Finder) {
   // Detect the expression: string("lit", 5)
   allOf(hasArgument(0, 
ConstStrLiteral.bind("literal-with-length")),
 hasArgument(1, ignoringParenImpCasts(
-   integerLiteral().bind("int"))
+   integerLiteral().bind("length"))
+  .bind("constructor"),
+  this);
+
+  // Check the literal string constructor with char pointer, start position and
+  // length parameters. [i.e. string (const char* s, size_t pos, size_t 
count);]
+  Finder->addMatcher(
+  cxxConstructExpr(
+  hasDeclaration(cxxConstructorDecl(ofClass(
+  cxxRecordDecl(hasAnyName(removeNamespaces(StringNames)),
+  argumentCountIs(3), hasArgument(0, hasType(CharPtrType)),
+  hasArgument(1, hasType(qualType(isInteger(,
+  hasArgument(2, hasType(qualType(isInteger(,
+  anyOf(
+  // Detect the expression: string("...", 1, 0);
+  hasArgument(2, ZeroExpr.bind("empty-string")),
+  // Detect the expression: string("...", -4, 1);
+  hasArgument(1, NegativeExpr.bind("negative-pos")),
+  // Detect the expression: string("...", 0, -4);
+  hasArgument(2, NegativeExpr.bind("negative-length")),
+  // Detect the expression: string("lit", 0, 0x1234567);
+  hasArgument(2, LargeLengthExpr.bind("large-length")),
+  // Detect the expression: string("lit", 1, 5)
+  allOf(hasArgument(0, 
ConstStrLiteral.bind("literal-with-length")),
+hasArgument(
+1, 
ignoringParenImpCasts(integerLiteral().bind("pos"))),
+hasArgument(2, ignoringParenImpCasts(
+   integerLiteral().bind("length"))
   .bind("constructor"),
   this);
 
@@ -155,14 +182,27 @@ void StringConstructorCheck::check(const 
MatchFinder::MatchResult &Result) {
 diag(Loc, "constructor creating an empty string");
   } else if (Result.Nodes.getNodeAs("negative-length")) {
 diag(Loc, "negative value used as length parameter");
+  } else if (Result.Nodes.getNodeAs("negative-pos")) {
+diag(Loc, "negative value used as position of the "
+  "first character parameter");
   } else if (Result.Nodes.getNodeAs("large-length")) {
 if (WarnOnLargeLength)
   diag(Loc, "suspicious large length parameter");
   } else if (Result.Nodes.getNodeAs("literal-with-length")) {
 const auto *Str = Result.Nodes.getNodeAs("str");
-const auto *Lit = Result.Nodes.getNodeAs("int");
-if (Lit->getValue().ugt(Str->getLength())) {
+const auto *Length = Result.Nodes.getNodeAs("length");
+if (Length->getValue().ugt(Str->getLength())) {
   diag(Loc, "length is bigger than string literal size");
+  return;
+}
+if (const auto *Pos = Result.Nodes.getNodeAs("pos")) {
+  if (Pos->getValue().uge(Str->getLength())) {
+diag(Loc, "position of the first charact

[clang-tools-extra] [clang-tidy] Added support for 3-argument std::string ctor in bugprone-string-constructor check (PR #123413)

2025-01-19 Thread Baranov Victor via cfe-commits

vbvictor wrote:

> please update documents in 
> clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst also

Added new error description for "invalid character position argument" and 
provided more examples to existing cases.

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


[clang] [llvm] [NFC][AMDGPU] Clean-up feature parsing for AMDGCNSPIRV. (PR #123519)

2025-01-19 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx created 
https://github.com/llvm/llvm-project/pull/123519

When we did the initial AMDGCNSPIRV commits we left the initialisation of the 
feature map in a relatively disorderly state. This change corrects that 
oversight:

- We make sure that AMDGCNSPIRV actually advertises the union of all AMDGCN 
features, as some were not included;
- We keep feature initialisation in sorted order to make it easy to pick an 
insertion point when features are added in the future.


>From 38b172f721f05b4d589862f647d66e77139b4ffb Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Sun, 19 Jan 2025 17:01:45 +
Subject: [PATCH] Clean up `fillAMDGPUFeatureMap` for AMDGCNSPIRV.

---
 .../CodeGenCXX/dynamic-cast-address-space.cpp |  4 +--
 llvm/lib/TargetParser/TargetParser.cpp| 36 +--
 2 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp 
b/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
index 271d9ede79d0c4..0460352cf7ffcb 100644
--- a/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
+++ b/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
@@ -112,9 +112,9 @@ const B& f(A *a) {
 // CHECK: attributes #[[ATTR3]] = { nounwind }
 // CHECK: attributes #[[ATTR4]] = { noreturn }
 //.
-// WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR0]] = { mustprogress noinline 
optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+fp8-conversion-insts,+fp8-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize32,+wavefrontsize64"
 }
+// WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR0]] = { mustprogress noinline 
optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+16-bit-insts,+ashr-pk-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-buffer-pk-add-bf16-inst,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+bf8-cvt-scale-insts,+bitop3-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot12-insts,+dot13-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+f16bf16-to-fp6bf6-cvt-scale-insts,+f32-to-f16bf16-cvt-sr-insts,+fp4-cvt-scale-insts,+fp6bf6-cvt-scale-insts,+fp8-conversion-insts,+fp8-cvt-scale-insts,+fp8-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gfx950-insts,+gws,+image-insts,+mai-insts,+permlane16-swap,+permlane32-swap,+prng-inst,+s-memrealtime,+s-memtime-inst,+wavefrontsize32,+wavefrontsize64"
 }
 // WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR1:[0-9]+]] = { nounwind 
willreturn memory(read) }
-// WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR2:[0-9]+]] = { 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+fp8-conversion-insts,+fp8-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize32,+wavefrontsize64"
 }
+// WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR2:[0-9]+]] = { 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+16-bit-insts,+ashr-pk-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-buffer-pk-add-bf16-inst,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+bf8-cvt-scale-insts,+bitop3-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot12-insts,+dot13-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+f16bf16-to-fp6bf6-cvt-scale-insts,+f32-to-f16bf16-cvt-sr-insts,+fp4-cvt-scale-insts,+fp6bf6-cvt-scale-insts,+fp8-conversion-insts,+fp8-cvt-scale-insts,+fp8-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gfx950-insts,+gws,+image-insts,+mai-insts,+permlane16-swap,+permlane32-swap,+prng-inst,+s-memrealtime,+s-memtime-inst,+wavefrontsize32,+wavefrontsize64"
 }
 // WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR3]] = { nounwind }
 // WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR4]] = { noreturn }
 //.
diff --git a/llvm/lib/TargetParse

[clang] [llvm] [NFC][AMDGPU] Clean-up feature parsing for AMDGCNSPIRV. (PR #123519)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alex Voicu (AlexVlx)


Changes

When we did the initial AMDGCNSPIRV commits we left the initialisation of the 
feature map in a relatively disorderly state. This change corrects that 
oversight:

- We make sure that AMDGCNSPIRV actually advertises the union of all AMDGCN 
features, as some were not included;
- We keep feature initialisation in sorted order to make it easy to pick an 
insertion point when features are added in the future.


---
Full diff: https://github.com/llvm/llvm-project/pull/123519.diff


2 Files Affected:

- (modified) clang/test/CodeGenCXX/dynamic-cast-address-space.cpp (+2-2) 
- (modified) llvm/lib/TargetParser/TargetParser.cpp (+26-10) 


``diff
diff --git a/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp 
b/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
index 271d9ede79d0c4..0460352cf7ffcb 100644
--- a/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
+++ b/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
@@ -112,9 +112,9 @@ const B& f(A *a) {
 // CHECK: attributes #[[ATTR3]] = { nounwind }
 // CHECK: attributes #[[ATTR4]] = { noreturn }
 //.
-// WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR0]] = { mustprogress noinline 
optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+fp8-conversion-insts,+fp8-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize32,+wavefrontsize64"
 }
+// WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR0]] = { mustprogress noinline 
optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+16-bit-insts,+ashr-pk-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-buffer-pk-add-bf16-inst,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+bf8-cvt-scale-insts,+bitop3-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot12-insts,+dot13-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+f16bf16-to-fp6bf6-cvt-scale-insts,+f32-to-f16bf16-cvt-sr-insts,+fp4-cvt-scale-insts,+fp6bf6-cvt-scale-insts,+fp8-conversion-insts,+fp8-cvt-scale-insts,+fp8-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gfx950-insts,+gws,+image-insts,+mai-insts,+permlane16-swap,+permlane32-swap,+prng-inst,+s-memrealtime,+s-memtime-inst,+wavefrontsize32,+wavefrontsize64"
 }
 // WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR1:[0-9]+]] = { nounwind 
willreturn memory(read) }
-// WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR2:[0-9]+]] = { 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+fp8-conversion-insts,+fp8-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize32,+wavefrontsize64"
 }
+// WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR2:[0-9]+]] = { 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+16-bit-insts,+ashr-pk-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-buffer-pk-add-bf16-inst,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+bf8-cvt-scale-insts,+bitop3-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot12-insts,+dot13-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+f16bf16-to-fp6bf6-cvt-scale-insts,+f32-to-f16bf16-cvt-sr-insts,+fp4-cvt-scale-insts,+fp6bf6-cvt-scale-insts,+fp8-conversion-insts,+fp8-cvt-scale-insts,+fp8-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gfx950-insts,+gws,+image-insts,+mai-insts,+permlane16-swap,+permlane32-swap,+prng-inst,+s-memrealtime,+s-memtime-inst,+wavefrontsize32,+wavefrontsize64"
 }
 // WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR3]] = { nounwind }
 // WITH-NONZERO-DEFAULT-AS: attributes #[[ATTR4]] = { noreturn }
 //.
diff --git a/llvm/lib/TargetParser/TargetParser.cpp 
b/llvm/lib/TargetParser/TargetParser.cpp
index 02295fdb0ecd0d..0a605dfd017cbc 100644
--- a/llvm/lib/TargetParser/Tar

[clang] [llvm] [NFC][AMDGPU] Clean-up feature parsing for AMDGCNSPIRV. (PR #123519)

2025-01-19 Thread Shilei Tian via cfe-commits


@@ -323,43 +323,59 @@ void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const 
Triple &T,
   StringMap &Features) {
   // XXX - What does the member GPU mean if device name string passed here?
   if (T.isSPIRV() && T.getOS() == Triple::OSType::AMDHSA) {
-// AMDGCN SPIRV must support the union of all AMDGCN features.
+// AMDGCN SPIRV must support the union of all AMDGCN features. This list

shiltian wrote:

I wonder in the long term whether we want to table gen this.

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


[clang] [llvm] [NFC][AMDGPU] Clean-up feature parsing for AMDGCNSPIRV. (PR #123519)

2025-01-19 Thread Shilei Tian via cfe-commits

https://github.com/shiltian approved this pull request.


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


[clang] [llvm] [NVPTX] Add support for PTX 8.6 and CUDA 12.6 (12.8) (PR #123398)

2025-01-19 Thread Durgadoss R via cfe-commits


@@ -682,6 +688,9 @@ void NVPTX::getNVPTXTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   case CudaVersion::CUDA_##CUDA_VER:   
\
 PtxFeature = "+ptx" #PTX_VER;  
\
 break;
+CASE_CUDA_VERSION(129, 86);
+CASE_CUDA_VERSION(128, 86);
+CASE_CUDA_VERSION(127, 85);

durga4github wrote:

On rechecking this, we have 12.7 mapping to PTX 86 (and 12.8 to PTX 87).
Could you please check this once?

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


[clang] [llvm] [NFC][AMDGPU] Clean-up feature parsing for AMDGCNSPIRV. (PR #123519)

2025-01-19 Thread Shilei Tian via cfe-commits


@@ -323,43 +323,59 @@ void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const 
Triple &T,
   StringMap &Features) {
   // XXX - What does the member GPU mean if device name string passed here?
   if (T.isSPIRV() && T.getOS() == Triple::OSType::AMDHSA) {
-// AMDGCN SPIRV must support the union of all AMDGCN features.
+// AMDGCN SPIRV must support the union of all AMDGCN features. This list

shiltian wrote:

Technically we added those features via `.td` files so it could potentially 
generate a file for this one to include.

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


[clang] [Clang] Deprecate __is_referenceable (PR #123185)

2025-01-19 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 edited 
https://github.com/llvm/llvm-project/pull/123185
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] handle [[warn_unused]] attribute for unused private fields (PR #120734)

2025-01-19 Thread Timm Baeder via cfe-commits


@@ -3307,6 +3307,29 @@ void Sema::CheckShadowInheritedFields(const 
SourceLocation &Loc,
   }
 }
 
+template 
+inline static bool HasAttribute(const QualType &T) {
+  if (const TagDecl *TD = T->getAsTagDecl())
+return TD->hasAttr();
+  if (const TypedefType *TDT = T->getAs())
+return TDT->getDecl()->hasAttr();
+  return false;
+}
+
+inline static bool IsUnusedPrivateField(FieldDecl *FD) {

tbaederr wrote:

The `inline` in the static functions should go I think, and I hope the 
`FieldDecl` here can be `const`.

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


[clang] First PR to llvm, adding feature for issue (PR #123543)

2025-01-19 Thread via cfe-commits

github-actions[bot] wrote:

⚠️ We detected that you are using a GitHub private e-mail address to contribute 
to the repo. Please turn off [Keep my email addresses 
private](https://github.com/settings/emails) setting in your account. See 
[LLVM 
Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
 for more information.

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


[clang] [Clang][MIPS] Create correct linker arguments for Windows toolchains (PR #121041)

2025-01-19 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` 
running on `doug-worker-5` while building `clang` at step 6 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/190/builds/13136


Here is the relevant piece of the build log for the reference

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM :: 
ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli 
-jit-kind=orc-lazy -compile-threads=2 -thread-entry hello 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
 | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy 
-compile-threads=2 -thread-entry hello 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
 #0 0x000105159284 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100e99284)
 #1 0x000105157308 llvm::sys::RunSignalHandlers() 
(/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100e97308)
 #2 0x000105159940 SignalHandler(int) 
(/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100e99940)
 #3 0x000191c1a584 (/usr/lib/system/libsystem_platform.dylib+0x18047a584)
 #4 0x000191be921c (/usr/lib/system/libsystem_pthread.dylib+0x18044921c)
 #5 0x000191b0fad0 (/usr/lib/libc++.1.dylib+0x18036fad0)
 #6 0x000104d09bf8 void llvm::detail::UniqueFunctionBase, llvm::detail::DenseMapPair>>>::CallImpl, 
llvm::detail::DenseMapPair> 
const&)::$_45>(void*, llvm::Expected, llvm::detail::DenseMapPair>>&) 
(/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100a49bf8)
 #7 0x000104d05968 
llvm::orc::AsynchronousSymbolQuery::handleComplete(llvm::orc::ExecutionSession&)::RunQueryCompleteTask::run()
 (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100a45968)
 #8 0x000104dc1cc4 void* 
std::__1::__thread_proxy[abi:un170006]>, 
llvm::orc::DynamicThreadPoolTaskDispatcher::dispatch(std::__1::unique_ptr>)::$_0>>(void*) 
(/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100b01cc4)
 #9 0x000191be9f94 (/usr/lib/system/libsystem_pthread.dylib+0x180449f94)
#10 0x000191be4d34 (/usr/lib/system/libsystem_pthread.dylib+0x180444d34)
FileCheck error: '' is empty.
FileCheck command line:  
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll

--




```



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


[clang] 046b064 - [clang][bytecode][NFC] Use FixedPoint opaque int API (#123522)

2025-01-19 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-01-20T08:44:59+01:00
New Revision: 046b064df0ac9d4530e79f11077a768383b1ca16

URL: 
https://github.com/llvm/llvm-project/commit/046b064df0ac9d4530e79f11077a768383b1ca16
DIFF: 
https://github.com/llvm/llvm-project/commit/046b064df0ac9d4530e79f11077a768383b1ca16.diff

LOG: [clang][bytecode][NFC] Use FixedPoint opaque int API (#123522)

Now that we have it, use it.

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/lib/AST/ByteCode/Interp.h

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 414323eaa12654..1a0e5ff45587f3 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -689,20 +689,18 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
 if (!this->visit(SubExpr))
   return false;
 
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastIntegralFixedPoint(classifyPrim(SubExpr->getType()), 
I,
-CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastIntegralFixedPoint(classifyPrim(SubExpr->getType()),
+Sem, CE);
   }
   case CK_FloatingToFixedPoint: {
 if (!this->visit(SubExpr))
   return false;
 
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastFloatingFixedPoint(I, CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastFloatingFixedPoint(Sem, CE);
   }
   case CK_FixedPointToFloating: {
 if (!this->visit(SubExpr))
@@ -718,10 +716,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   case CK_FixedPointCast: {
 if (!this->visit(SubExpr))
   return false;
-auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
-uint32_t I;
-std::memcpy(&I, &Sem, sizeof(Sem));
-return this->emitCastFixedPoint(I, CE);
+auto Sem =
+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
+return this->emitCastFixedPoint(Sem, CE);
   }
 
   case CK_ToVoid:
@@ -1522,28 +1519,29 @@ template 
 bool Compiler::VisitFixedPointBinOp(const BinaryOperator *E) {
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
+  const ASTContext &ASTCtx = Ctx.getASTContext();
 
   assert(LHS->getType()->isFixedPointType() ||
  RHS->getType()->isFixedPointType());
 
-  auto LHSSema = Ctx.getASTContext().getFixedPointSemantics(LHS->getType());
-  auto RHSSema = Ctx.getASTContext().getFixedPointSemantics(RHS->getType());
+  auto LHSSema = ASTCtx.getFixedPointSemantics(LHS->getType());
+  auto LHSSemaInt = LHSSema.toOpaqueInt();
+  auto RHSSema = ASTCtx.getFixedPointSemantics(RHS->getType());
+  auto RHSSemaInt = RHSSema.toOpaqueInt();
 
   if (!this->visit(LHS))
 return false;
   if (!LHS->getType()->isFixedPointType()) {
-uint32_t I;
-std::memcpy(&I, &LHSSema, sizeof(llvm::FixedPointSemantics));
-if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()), I, E))
+if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()),
+  LHSSemaInt, E))
   return false;
   }
 
   if (!this->visit(RHS))
 return false;
   if (!RHS->getType()->isFixedPointType()) {
-uint32_t I;
-std::memcpy(&I, &RHSSema, sizeof(llvm::FixedPointSemantics));
-if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()), I, E))
+if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()),
+  RHSSemaInt, E))
   return false;
   }
 
@@ -1551,13 +1549,10 @@ bool Compiler::VisitFixedPointBinOp(const 
BinaryOperator *E) {
   auto ConvertResult = [&](bool R) -> bool {
 if (!R)
   return false;
-auto ResultSema = Ctx.getASTContext().getFixedPointSemantics(E->getType());
-auto CommonSema = LHSSema.getCommonSemantics(RHSSema);
-if (ResultSema != CommonSema) {
-  uint32_t I;
-  std::memcpy(&I, &ResultSema, sizeof(ResultSema));
-  return this->emitCastFixedPoint(I, E);
-}
+auto ResultSema = 
ASTCtx.getFixedPointSemantics(E->getType()).toOpaqueInt();
+auto CommonSema = LHSSema.getCommonSemantics(RHSSema).toOpaqueInt();
+if (ResultSema != CommonSema)
+  return this->emitCastFixedPoint(ResultSema, E);
 return true;
   };
 

diff  --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 93a91976a31bf1..58c0256c7d7df8 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2141,9 +2141,8 @@ inline bool CastFP(InterpState &S, CodePtr OpPC, cons

[clang] [clang][bytecode][NFC] Use FixedPoint opaque int API (PR #123522)

2025-01-19 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr closed 
https://github.com/llvm/llvm-project/pull/123522
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Fix discarding DerivedToBase casts (PR #123523)

2025-01-19 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr closed 
https://github.com/llvm/llvm-project/pull/123523
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6972788 - [clang][bytecode] Fix discarding DerivedToBase casts (#123523)

2025-01-19 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-01-20T08:55:54+01:00
New Revision: 6972788bf3d330b7a6136e2ddd840782882b8dd0

URL: 
https://github.com/llvm/llvm-project/commit/6972788bf3d330b7a6136e2ddd840782882b8dd0
DIFF: 
https://github.com/llvm/llvm-project/commit/6972788bf3d330b7a6136e2ddd840782882b8dd0.diff

LOG: [clang][bytecode] Fix discarding DerivedToBase casts (#123523)

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/records.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 1a0e5ff45587f3..66ab27bdd13da5 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -253,6 +253,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
 
   case CK_UncheckedDerivedToBase:
   case CK_DerivedToBase: {
+if (DiscardResult)
+  return this->discard(SubExpr);
+
 if (!this->delegate(SubExpr))
   return false;
 
@@ -282,6 +285,9 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   }
 
   case CK_BaseToDerived: {
+if (DiscardResult)
+  return this->discard(SubExpr);
+
 if (!this->delegate(SubExpr))
   return false;
 

diff  --git a/clang/test/AST/ByteCode/records.cpp 
b/clang/test/AST/ByteCode/records.cpp
index d329219264d893..9470e7d8e3dcbf 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -1684,3 +1684,18 @@ namespace ExplicitThisInTemporary {
   constexpr bool g(B b) { return &b == b.p; }
   static_assert(g({}), "");
 }
+
+namespace IgnoredMemberExpr {
+  class A {
+  public:
+int a;
+  };
+  class B : public A {
+  public:
+constexpr int foo() {
+  a; // both-warning {{expression result unused}}
+  return 0;
+}
+  };
+  static_assert(B{}.foo() == 0, "");
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NVPTX] Add support for PTX 8.6 and CUDA 12.6 (12.8) (PR #123398)

2025-01-19 Thread Sergey Kozub via cfe-commits

https://github.com/sergey-kozub updated 
https://github.com/llvm/llvm-project/pull/123398

>From 04313ede76d272ec391361b9828e55d8a27b4bda Mon Sep 17 00:00:00 2001
From: Sergey Kozub 
Date: Fri, 17 Jan 2025 21:00:49 +
Subject: [PATCH] Add support for PTX 8.6 and CUDA 12.6 (12.8)

---
 clang/include/clang/Basic/BuiltinsNVPTX.def | 5 -
 clang/include/clang/Basic/Cuda.h| 6 +-
 clang/lib/Basic/Cuda.cpp| 8 ++--
 clang/lib/Basic/Targets/NVPTX.cpp   | 3 +++
 clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp| 1 +
 clang/lib/Driver/ToolChains/Cuda.cpp| 9 +
 llvm/lib/Target/NVPTX/NVPTX.td  | 2 ++
 7 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsNVPTX.def 
b/clang/include/clang/Basic/BuiltinsNVPTX.def
index 969dd9e41ebfa3..37b4e6ff77fda6 100644
--- a/clang/include/clang/Basic/BuiltinsNVPTX.def
+++ b/clang/include/clang/Basic/BuiltinsNVPTX.def
@@ -28,7 +28,9 @@
 #pragma push_macro("SM_90")
 #pragma push_macro("SM_90a")
 #pragma push_macro("SM_100")
-#define SM_100 "sm_100"
+#pragma push_macro("SM_100a")
+#define SM_100a "sm_100a"
+#define SM_100 "sm_100|" SM_100a
 #define SM_90a "sm_90a"
 #define SM_90 "sm_90|" SM_90a "|" SM_100
 #define SM_89 "sm_89|" SM_90
@@ -1091,6 +1093,7 @@ TARGET_BUILTIN(__nvvm_getctarank_shared_cluster, "iv*3", 
"", AND(SM_90,PTX78))
 #pragma pop_macro("SM_90")
 #pragma pop_macro("SM_90a")
 #pragma pop_macro("SM_100")
+#pragma pop_macro("SM_100a")
 #pragma pop_macro("PTX42")
 #pragma pop_macro("PTX60")
 #pragma pop_macro("PTX61")
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index c2a4addf488df1..1cdfc8178db843 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -44,9 +44,12 @@ enum class CudaVersion {
   CUDA_124,
   CUDA_125,
   CUDA_126,
+  CUDA_127,
+  CUDA_128,
+  CUDA_129,
   FULLY_SUPPORTED = CUDA_123,
   PARTIALLY_SUPPORTED =
-  CUDA_126, // Partially supported. Proceed with a warning.
+  CUDA_129, // Partially supported. Proceed with a warning.
   NEW = 1,  // Too new. Issue a warning, but allow using it.
 };
 const char *CudaVersionToString(CudaVersion V);
@@ -80,6 +83,7 @@ enum class OffloadArch {
   SM_90,
   SM_90a,
   SM_100,
+  SM_100a,
   GFX600,
   GFX601,
   GFX602,
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index d56609a2a8f24a..692ab7c319d8bd 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -44,6 +44,9 @@ static const CudaVersionMapEntry CudaNameVersionMap[] = {
 CUDA_ENTRY(12, 4),
 CUDA_ENTRY(12, 5),
 CUDA_ENTRY(12, 6),
+CUDA_ENTRY(12, 7),
+CUDA_ENTRY(12, 8),
+CUDA_ENTRY(12, 9),
 {"", CudaVersion::NEW, 
llvm::VersionTuple(std::numeric_limits::max())},
 {"unknown", CudaVersion::UNKNOWN, {}} // End of list tombstone.
 };
@@ -98,6 +101,7 @@ static const OffloadArchToStringMap arch_names[] = {
 SM(90),  // Hopper
 SM(90a), // Hopper
 SM(100), // Blackwell
+SM(100a),// Blackwell
 GFX(600),  // gfx600
 GFX(601),  // gfx601
 GFX(602),  // gfx602
@@ -227,8 +231,8 @@ CudaVersion MinVersionForOffloadArch(OffloadArch A) {
   case OffloadArch::SM_90a:
 return CudaVersion::CUDA_120;
   case OffloadArch::SM_100:
-return CudaVersion::NEW; // TODO: use specific CUDA version once it's
- // public.
+  case OffloadArch::SM_100a:
+return CudaVersion::CUDA_128;
   default:
 llvm_unreachable("invalid enum");
   }
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index dbc3fec3657610..56efad90cb7c84 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -285,6 +285,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case OffloadArch::SM_90a:
 return "900";
   case OffloadArch::SM_100:
+  case OffloadArch::SM_100a:
 return "1000";
   }
   llvm_unreachable("unhandled OffloadArch");
@@ -292,6 +293,8 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
 if (GPU == OffloadArch::SM_90a)
   Builder.defineMacro("__CUDA_ARCH_FEAT_SM90_ALL", "1");
+if (GPU == OffloadArch::SM_100a)
+  Builder.defineMacro("__CUDA_ARCH_FEAT_SM100_ALL", "1");
   }
 }
 
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 87c3635ed3f70e..c13928f61a7481 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2277,6 +2277,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const 
OMPRequiresDecl *D) {
   case OffloadArch::SM_90:
   case OffloadArch::SM_90a:
   case OffloadArch::SM_100:
+  case OffloadArch::SM_100a:
   case OffloadArch::GFX600:
  

[clang] [llvm] [NVPTX] Add support for PTX 8.6 and CUDA 12.6 (12.8) (PR #123398)

2025-01-19 Thread Sergey Kozub via cfe-commits


@@ -682,6 +688,9 @@ void NVPTX::getNVPTXTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   case CudaVersion::CUDA_##CUDA_VER:   
\
 PtxFeature = "+ptx" #PTX_VER;  
\
 break;
+CASE_CUDA_VERSION(129, 86);
+CASE_CUDA_VERSION(128, 86);
+CASE_CUDA_VERSION(127, 85);

sergey-kozub wrote:

Updated, thank you.
Also, changed line 235 in "clang/lib/Basic/Cuda.cpp", as PTX8.6 supports sm100a.

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


[clang] First PR to llvm, adding feature for issue (PR #123543)

2025-01-19 Thread via cfe-commits

https://github.com/Shakil582 created 
https://github.com/llvm/llvm-project/pull/123543

resolves #43831 

I'll test it a bit more tomorrow. I think I saw something weird with the 
--offset functionality when testing, but my additions  worked for the test 
cases I gave it.


>From 4dc0383b366b3105aa879732332062eb2902b213 Mon Sep 17 00:00:00 2001
From: Shakil Usman 
Date: Sun, 19 Jan 2025 21:41:50 -0500
Subject: [PATCH 1/2] 43831 added off on feature to clang

---
 clang/tools/clang-format/ClangFormat.cpp | 155 +++
 1 file changed, 155 insertions(+)

diff --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index 28610052b9b74a..e5c70979483e24 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -26,6 +26,12 @@
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Process.h"
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 using namespace llvm;
 using clang::tooling::Replacements;
@@ -214,6 +220,9 @@ static cl::opt ListIgnored("list-ignored",
  cl::desc("List ignored files."),
  cl::cat(ClangFormatCategory), cl::Hidden);
 
+static SmallVector OnWords;
+static SmallVector OffWords;
+
 namespace clang {
 namespace format {
 
@@ -277,6 +286,8 @@ static bool fillRanges(MemoryBuffer *Code,
 return false;
   }
 
+  
+
   if (Offsets.empty())
 Offsets.push_back(0);
   if (Offsets.size() != Lengths.size() &&
@@ -307,6 +318,139 @@ static bool fillRanges(MemoryBuffer *Code,
 unsigned Length = Sources.getFileOffset(End) - Offset;
 Ranges.push_back(tooling::Range(Offset, Length));
   }
+
+  std::cout << "Printing ranges " << "\n";
+  for (const auto& i : Ranges)
+  {
+std::cout << i.getOffset() << " " << i.getOffset() + i.getLength() << "\n";
+  }
+
+  if (!OnWords.empty() && !OffWords.empty())
+  {
+StringRef CodeRef = Code->getBuffer();
+std::set OnSet;
+if (Ranges.empty()) 
+{
+OnSet.insert(0);
+} else {
+OnSet.insert(Ranges[0].getOffset());
+}
+std::set OffSet;
+std::cout << "OFF" << "\n";
+if (Ranges.size() == 1 && Ranges[0].getOffset() == 0 && 
Ranges[0].getLength() == CodeRef.size())
+{
+  Ranges.pop_back();
+}
+for (const auto& Word : OffWords)
+{
+  std::cout << Word << "\n";
+  size_t TempOffset = CodeRef.find(Word);
+  while (TempOffset != StringRef::npos)
+  {
+std::cout << "found offword at " << TempOffset << "\n";
+if (TempOffset > *OnSet.begin())
+{
+OffSet.insert(TempOffset);
+}
+TempOffset = CodeRef.find(Word, TempOffset + 1);
+  }
+}
+
+std::cout << "ON" << "\n";
+for (const auto& Word : OnWords)
+{
+  std::cout << Word << "\n";
+  size_t TempOffset = CodeRef.find(Word);
+  while (TempOffset != StringRef::npos)
+  {
+std::cout << "found onword at " << TempOffset << "\n";
+OnSet.insert(TempOffset);
+TempOffset = CodeRef.find(Word, TempOffset + 1);
+  }
+}
+
+std::cout << "Printing ranges " << "\n";
+for (const auto& i : Ranges)
+{
+std::cout << i.getOffset() << " " << i.getOffset() + i.getLength() << 
"\n";
+}
+
+std::cout << "Entering while" << "\n";
+while (!OnSet.empty())
+{
+  size_t Offset = OnSet.extract(OnSet.begin()).value();
+  size_t Length;
+  if (!OffSet.empty())
+  { 
+Length = OffSet.extract(OffSet.begin()).value() - Offset;
+  } 
+  else
+  {
+Length = CodeRef.size() - Offset;
+  }
+
+  std::cout << Offset << " " << Offset + Length << std::endl;
+  // Could result in loss of data
+  tooling::Range NewRange = {static_cast(Offset), 
static_cast(Length)};
+  
+  /*bool inserted = false;
+  for (auto i = Ranges.begin(); i != Ranges.end(); ++i)
+  {
+if (i->overlapsWith(NewRange))
+{
+  std::cout << "Overlap erasure" << std::endl;
+  tooling::Range Temp(std::min(NewRange.getOffset(), i->getOffset()), 
std::max(NewRange.getLength(), i->getLength()));
+  std::cout << "Old range" << "\n";
+  std::cout << i->getOffset() << " " << i->getOffset() + 
i->getLength() << "\n";
+  std::cout << "New range before insert " << "\n";
+  std::cout << NewRange.getOffset() << " " << NewRange.getOffset() + 
NewRange.getLength() << "\n";
+  Ranges.erase(i);
+  Ranges.insert(i, Temp);
+  inserted = true;
+  std::cout << "After" << "\n";
+  std::cout << Temp.getOffset() << " " << Temp.getOffset() + 
Temp.getLength() << "\n"; 
+}
+  }
+  if (!inserted)
+  {*/
+  Ranges.push_back(NewRange);
+  //}
+}
+  }
+
+  std::sort(Ranges.begin(), Ranges.end(), [](const tooling::Range& a, const 
tooling::Range& b) {
+return a.getOffset() + a.getLengt

[clang] First PR to llvm, adding feature for issue (PR #123543)

2025-01-19 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] First PR to llvm, adding feature for issue (PR #123543)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: None (Shakil582)


Changes

resolves #43831 

I'll test it a bit more tomorrow. I think I saw something weird with the 
--offset functionality when testing, but my additions  worked for the test 
cases I gave it.


---
Full diff: https://github.com/llvm/llvm-project/pull/123543.diff


1 Files Affected:

- (modified) clang/tools/clang-format/ClangFormat.cpp (+84) 


``diff
diff --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index 28610052b9b74a..64af04ef4c007c 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -26,6 +26,12 @@
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Process.h"
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 using namespace llvm;
 using clang::tooling::Replacements;
@@ -214,6 +220,9 @@ static cl::opt ListIgnored("list-ignored",
  cl::desc("List ignored files."),
  cl::cat(ClangFormatCategory), cl::Hidden);
 
+static SmallVector OnWords;
+static SmallVector OffWords;
+
 namespace clang {
 namespace format {
 
@@ -307,6 +316,72 @@ static bool fillRanges(MemoryBuffer *Code,
 unsigned Length = Sources.getFileOffset(End) - Offset;
 Ranges.push_back(tooling::Range(Offset, Length));
   }
+
+  if (!OnWords.empty() && !OffWords.empty()) {
+StringRef CodeRef = Code->getBuffer();
+std::set OnSet;
+if (Ranges.empty())
+  OnSet.insert(0);
+else
+  OnSet.insert(Ranges[0].getOffset());
+std::set OffSet;
+if (Ranges.size() == 1 && Ranges[0].getOffset() == 0 &&
+Ranges[0].getLength() == CodeRef.size()) {
+  Ranges.pop_back();
+}
+
+for (const auto &Word : OffWords) {
+  size_t TempOffset = CodeRef.find(Word);
+  while (TempOffset != StringRef::npos) {
+if (TempOffset > *OnSet.begin())
+  OffSet.insert(TempOffset);
+TempOffset = CodeRef.find(Word, TempOffset + 1);
+  }
+}
+
+for (const auto &Word : OnWords) {
+  size_t TempOffset = CodeRef.find(Word);
+  while (TempOffset != StringRef::npos) {
+OnSet.insert(TempOffset);
+TempOffset = CodeRef.find(Word, TempOffset + 1);
+  }
+}
+
+while (!OnSet.empty()) {
+  size_t Offset = OnSet.extract(OnSet.begin()).value();
+  size_t Length;
+  if (!OffSet.empty())
+Length = OffSet.extract(OffSet.begin()).value() - Offset;
+  else
+Length = CodeRef.size() - Offset;
+
+  // Could result in loss of data
+  tooling::Range NewRange = {static_cast(Offset),
+ static_cast(Length)};
+
+  Ranges.push_back(NewRange);
+}
+  }
+
+  std::sort(Ranges.begin(), Ranges.end(),
+[](const tooling::Range &a, const tooling::Range &b) {
+  return a.getOffset() + a.getLength() <
+ b.getOffset() + b.getLength();
+});
+
+  auto start = Ranges.begin();
+  for (auto i = Ranges.begin() + 1; i != Ranges.end(); ++i) {
+if (start->getOffset() + start->getLength() >= i->getOffset()) {
+  tooling::Range Temp(std::min(start->getOffset(), i->getOffset()),
+  std::max(start->getLength(), i->getLength()));
+  Ranges.erase(start, i + 1);
+  start = Ranges.insert(start, Temp);
+  i = start;
+} else {
+  ++start;
+}
+  }
+
   return false;
 }
 
@@ -646,6 +721,15 @@ static bool isIgnored(StringRef FilePath) {
 
   const auto Pathname{convert_to_slash(AbsPath)};
   for (const auto &Pat : Patterns) {
+
+if (Pat.slice(0, 3).equals_insensitive("on:")) {
+  OnWords.push_back(Pat.slice(3, Pat.size()).trim().str());
+  continue;
+}
+if (Pat.slice(0, 4).equals_insensitive("off:")) {
+  OffWords.push_back(Pat.slice(4, Pat.size()).trim().str());
+  continue;
+}
 const bool IsNegated = Pat[0] == '!';
 StringRef Pattern{Pat};
 if (IsNegated)

``




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


[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)

2025-01-19 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 created 
https://github.com/llvm/llvm-project/pull/123551

Fixes https://github.com/llvm/llvm-project/issues/123549

>From cd87f05f19f245e24f5c29b97af0b69266608d7a Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Mon, 20 Jan 2025 01:52:24 -0500
Subject: [PATCH 1/2] Upgrade HeuristicResolver to use QualType rather than
 Type*

---
 clang-tools-extra/clangd/FindTarget.cpp  |  3 +-
 clang-tools-extra/clangd/XRefs.cpp   |  7 +-
 clang/include/clang/Sema/HeuristicResolver.h |  4 +-
 clang/lib/Sema/HeuristicResolver.cpp | 77 ++--
 4 files changed, 47 insertions(+), 44 deletions(-)

diff --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 04fd6d437b7bdd..bb4c91b8313540 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -496,8 +496,7 @@ struct TargetFinder {
   return;
 case NestedNameSpecifier::Identifier:
   if (Resolver) {
-add(QualType(Resolver->resolveNestedNameSpecifierToType(NNS), 0),
-Flags);
+add(Resolver->resolveNestedNameSpecifierToType(NNS), Flags);
   }
   return;
 case NestedNameSpecifier::TypeSpec:
diff --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 0a093108b752c3..1a23f6cca77561 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -2034,9 +2034,10 @@ static void unwrapFindType(
 
   // For smart pointer types, add the underlying type
   if (H)
-if (const auto* PointeeType = 
H->getPointeeType(T.getNonReferenceType().getTypePtr())) {
-unwrapFindType(QualType(PointeeType, 0), H, Out);
-return Out.push_back(T);
+if (auto PointeeType = H->getPointeeType(T.getNonReferenceType());
+!PointeeType.isNull()) {
+  unwrapFindType(PointeeType, H, Out);
+  return Out.push_back(T);
 }
 
   return Out.push_back(T);
diff --git a/clang/include/clang/Sema/HeuristicResolver.h 
b/clang/include/clang/Sema/HeuristicResolver.h
index 947de7a4e83ce0..3760003aab89f1 100644
--- a/clang/include/clang/Sema/HeuristicResolver.h
+++ b/clang/include/clang/Sema/HeuristicResolver.h
@@ -66,13 +66,13 @@ class HeuristicResolver {
   // Try to heuristically resolve a dependent nested name specifier
   // to the type it likely denotes. Note that *dependent* name specifiers 
always
   // denote types, not namespaces.
-  const Type *
+  QualType
   resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS) const;
 
   // Given the type T of a dependent expression that appears of the LHS of a
   // "->", heuristically find a corresponding pointee type in whose scope we
   // could look up the name appearing on the RHS.
-  const Type *getPointeeType(const Type *T) const;
+  const QualType getPointeeType(QualType T) const;
 
 private:
   ASTContext &Ctx;
diff --git a/clang/lib/Sema/HeuristicResolver.cpp 
b/clang/lib/Sema/HeuristicResolver.cpp
index 7c1b8450b96330..f883b85a80c60f 100644
--- a/clang/lib/Sema/HeuristicResolver.cpp
+++ b/clang/lib/Sema/HeuristicResolver.cpp
@@ -42,8 +42,8 @@ class HeuristicResolverImpl {
   resolveDependentNameType(const DependentNameType *DNT);
   std::vector resolveTemplateSpecializationType(
   const DependentTemplateSpecializationType *DTST);
-  const Type *resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
-  const Type *getPointeeType(const Type *T);
+  QualType resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
+  QualType getPointeeType(QualType T);
 
 private:
   ASTContext &Ctx;
@@ -61,12 +61,12 @@ class HeuristicResolverImpl {
   // This heuristic will give the desired answer in many cases, e.g.
   // for a call to vector::size().
   std::vector
-  resolveDependentMember(const Type *T, DeclarationName Name,
+  resolveDependentMember(QualType T, DeclarationName Name,
  llvm::function_ref Filter);
 
   // Try to heuristically resolve the type of a possibly-dependent expression
   // `E`.
-  const Type *resolveExprToType(const Expr *E);
+  QualType resolveExprToType(const Expr *E);
   std::vector resolveExprToDecls(const Expr *E);
 
   // Helper function for HeuristicResolver::resolveDependentMember()
@@ -104,17 +104,17 @@ const auto TemplateFilter = [](const NamedDecl *D) {
   return isa(D);
 };
 
-const Type *resolveDeclsToType(const std::vector &Decls,
-   ASTContext &Ctx) {
+QualType resolveDeclsToType(const std::vector &Decls,
+ASTContext &Ctx) {
   if (Decls.size() != 1) // Names an overload set -- just bail.
-return nullptr;
+return QualType();
   if (const auto *TD = dyn_cast(Decls[0])) {
-return Ctx.getTypeDeclType(TD).getTypePtr();
+return Ctx.getTypeDeclType(TD);
   }
   if (const auto *VD = dyn_cast(Decls[0])) {
-return VD->getType().getTypePtrOrNull();
+return VD->getType();
   }
-  return nullptr;
+  return QualTy

[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nathan Ridge (HighCommander4)


Changes

Fixes https://github.com/llvm/llvm-project/issues/123549

---
Full diff: https://github.com/llvm/llvm-project/pull/123551.diff


5 Files Affected:

- (modified) clang-tools-extra/clangd/FindTarget.cpp (+1-2) 
- (modified) clang-tools-extra/clangd/XRefs.cpp (+4-3) 
- (modified) clang/include/clang/Sema/HeuristicResolver.h (+2-2) 
- (modified) clang/lib/Sema/HeuristicResolver.cpp (+49-38) 
- (modified) clang/unittests/Sema/HeuristicResolverTest.cpp (+20) 


``diff
diff --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 04fd6d437b7bdd..bb4c91b8313540 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -496,8 +496,7 @@ struct TargetFinder {
   return;
 case NestedNameSpecifier::Identifier:
   if (Resolver) {
-add(QualType(Resolver->resolveNestedNameSpecifierToType(NNS), 0),
-Flags);
+add(Resolver->resolveNestedNameSpecifierToType(NNS), Flags);
   }
   return;
 case NestedNameSpecifier::TypeSpec:
diff --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 0a093108b752c3..1a23f6cca77561 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -2034,9 +2034,10 @@ static void unwrapFindType(
 
   // For smart pointer types, add the underlying type
   if (H)
-if (const auto* PointeeType = 
H->getPointeeType(T.getNonReferenceType().getTypePtr())) {
-unwrapFindType(QualType(PointeeType, 0), H, Out);
-return Out.push_back(T);
+if (auto PointeeType = H->getPointeeType(T.getNonReferenceType());
+!PointeeType.isNull()) {
+  unwrapFindType(PointeeType, H, Out);
+  return Out.push_back(T);
 }
 
   return Out.push_back(T);
diff --git a/clang/include/clang/Sema/HeuristicResolver.h 
b/clang/include/clang/Sema/HeuristicResolver.h
index 947de7a4e83ce0..3760003aab89f1 100644
--- a/clang/include/clang/Sema/HeuristicResolver.h
+++ b/clang/include/clang/Sema/HeuristicResolver.h
@@ -66,13 +66,13 @@ class HeuristicResolver {
   // Try to heuristically resolve a dependent nested name specifier
   // to the type it likely denotes. Note that *dependent* name specifiers 
always
   // denote types, not namespaces.
-  const Type *
+  QualType
   resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS) const;
 
   // Given the type T of a dependent expression that appears of the LHS of a
   // "->", heuristically find a corresponding pointee type in whose scope we
   // could look up the name appearing on the RHS.
-  const Type *getPointeeType(const Type *T) const;
+  const QualType getPointeeType(QualType T) const;
 
 private:
   ASTContext &Ctx;
diff --git a/clang/lib/Sema/HeuristicResolver.cpp 
b/clang/lib/Sema/HeuristicResolver.cpp
index 7c1b8450b96330..fbce1a026be61c 100644
--- a/clang/lib/Sema/HeuristicResolver.cpp
+++ b/clang/lib/Sema/HeuristicResolver.cpp
@@ -42,8 +42,8 @@ class HeuristicResolverImpl {
   resolveDependentNameType(const DependentNameType *DNT);
   std::vector resolveTemplateSpecializationType(
   const DependentTemplateSpecializationType *DTST);
-  const Type *resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
-  const Type *getPointeeType(const Type *T);
+  QualType resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
+  QualType getPointeeType(QualType T);
 
 private:
   ASTContext &Ctx;
@@ -61,12 +61,12 @@ class HeuristicResolverImpl {
   // This heuristic will give the desired answer in many cases, e.g.
   // for a call to vector::size().
   std::vector
-  resolveDependentMember(const Type *T, DeclarationName Name,
+  resolveDependentMember(QualType T, DeclarationName Name,
  llvm::function_ref Filter);
 
   // Try to heuristically resolve the type of a possibly-dependent expression
   // `E`.
-  const Type *resolveExprToType(const Expr *E);
+  QualType resolveExprToType(const Expr *E);
   std::vector resolveExprToDecls(const Expr *E);
 
   // Helper function for HeuristicResolver::resolveDependentMember()
@@ -104,17 +104,17 @@ const auto TemplateFilter = [](const NamedDecl *D) {
   return isa(D);
 };
 
-const Type *resolveDeclsToType(const std::vector &Decls,
-   ASTContext &Ctx) {
+QualType resolveDeclsToType(const std::vector &Decls,
+ASTContext &Ctx) {
   if (Decls.size() != 1) // Names an overload set -- just bail.
-return nullptr;
+return QualType();
   if (const auto *TD = dyn_cast(Decls[0])) {
-return Ctx.getTypeDeclType(TD).getTypePtr();
+return Ctx.getTypeDeclType(TD);
   }
   if (const auto *VD = dyn_cast(Decls[0])) {
-return VD->getType().getTypePtrOrNull();
+return VD->getType();
   }
-  return nullptr;
+  return QualType();
 }
 
 TemplateName getReferencedTemplateName(const Type *T) {
@@ -137,7 +137,8

[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Nathan Ridge (HighCommander4)


Changes

Fixes https://github.com/llvm/llvm-project/issues/123549

---
Full diff: https://github.com/llvm/llvm-project/pull/123551.diff


5 Files Affected:

- (modified) clang-tools-extra/clangd/FindTarget.cpp (+1-2) 
- (modified) clang-tools-extra/clangd/XRefs.cpp (+4-3) 
- (modified) clang/include/clang/Sema/HeuristicResolver.h (+2-2) 
- (modified) clang/lib/Sema/HeuristicResolver.cpp (+49-38) 
- (modified) clang/unittests/Sema/HeuristicResolverTest.cpp (+20) 


``diff
diff --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 04fd6d437b7bdd..bb4c91b8313540 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -496,8 +496,7 @@ struct TargetFinder {
   return;
 case NestedNameSpecifier::Identifier:
   if (Resolver) {
-add(QualType(Resolver->resolveNestedNameSpecifierToType(NNS), 0),
-Flags);
+add(Resolver->resolveNestedNameSpecifierToType(NNS), Flags);
   }
   return;
 case NestedNameSpecifier::TypeSpec:
diff --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 0a093108b752c3..1a23f6cca77561 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -2034,9 +2034,10 @@ static void unwrapFindType(
 
   // For smart pointer types, add the underlying type
   if (H)
-if (const auto* PointeeType = 
H->getPointeeType(T.getNonReferenceType().getTypePtr())) {
-unwrapFindType(QualType(PointeeType, 0), H, Out);
-return Out.push_back(T);
+if (auto PointeeType = H->getPointeeType(T.getNonReferenceType());
+!PointeeType.isNull()) {
+  unwrapFindType(PointeeType, H, Out);
+  return Out.push_back(T);
 }
 
   return Out.push_back(T);
diff --git a/clang/include/clang/Sema/HeuristicResolver.h 
b/clang/include/clang/Sema/HeuristicResolver.h
index 947de7a4e83ce0..3760003aab89f1 100644
--- a/clang/include/clang/Sema/HeuristicResolver.h
+++ b/clang/include/clang/Sema/HeuristicResolver.h
@@ -66,13 +66,13 @@ class HeuristicResolver {
   // Try to heuristically resolve a dependent nested name specifier
   // to the type it likely denotes. Note that *dependent* name specifiers 
always
   // denote types, not namespaces.
-  const Type *
+  QualType
   resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS) const;
 
   // Given the type T of a dependent expression that appears of the LHS of a
   // "->", heuristically find a corresponding pointee type in whose scope we
   // could look up the name appearing on the RHS.
-  const Type *getPointeeType(const Type *T) const;
+  const QualType getPointeeType(QualType T) const;
 
 private:
   ASTContext &Ctx;
diff --git a/clang/lib/Sema/HeuristicResolver.cpp 
b/clang/lib/Sema/HeuristicResolver.cpp
index 7c1b8450b96330..fbce1a026be61c 100644
--- a/clang/lib/Sema/HeuristicResolver.cpp
+++ b/clang/lib/Sema/HeuristicResolver.cpp
@@ -42,8 +42,8 @@ class HeuristicResolverImpl {
   resolveDependentNameType(const DependentNameType *DNT);
   std::vector resolveTemplateSpecializationType(
   const DependentTemplateSpecializationType *DTST);
-  const Type *resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
-  const Type *getPointeeType(const Type *T);
+  QualType resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
+  QualType getPointeeType(QualType T);
 
 private:
   ASTContext &Ctx;
@@ -61,12 +61,12 @@ class HeuristicResolverImpl {
   // This heuristic will give the desired answer in many cases, e.g.
   // for a call to vector::size().
   std::vector
-  resolveDependentMember(const Type *T, DeclarationName Name,
+  resolveDependentMember(QualType T, DeclarationName Name,
  llvm::function_ref Filter);
 
   // Try to heuristically resolve the type of a possibly-dependent expression
   // `E`.
-  const Type *resolveExprToType(const Expr *E);
+  QualType resolveExprToType(const Expr *E);
   std::vector resolveExprToDecls(const Expr *E);
 
   // Helper function for HeuristicResolver::resolveDependentMember()
@@ -104,17 +104,17 @@ const auto TemplateFilter = [](const NamedDecl *D) {
   return isa(D);
 };
 
-const Type *resolveDeclsToType(const std::vector &Decls,
-   ASTContext &Ctx) {
+QualType resolveDeclsToType(const std::vector &Decls,
+ASTContext &Ctx) {
   if (Decls.size() != 1) // Names an overload set -- just bail.
-return nullptr;
+return QualType();
   if (const auto *TD = dyn_cast(Decls[0])) {
-return Ctx.getTypeDeclType(TD).getTypePtr();
+return Ctx.getTypeDeclType(TD);
   }
   if (const auto *VD = dyn_cast(Decls[0])) {
-return VD->getType().getTypePtrOrNull();
+return VD->getType();
   }
-  return nullptr;
+  return QualType();
 }
 
 TemplateName getReferencedTemplateName(const Type *T) {
@@ -

[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)

2025-01-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: Nathan Ridge (HighCommander4)


Changes

Fixes https://github.com/llvm/llvm-project/issues/123549

---
Full diff: https://github.com/llvm/llvm-project/pull/123551.diff


5 Files Affected:

- (modified) clang-tools-extra/clangd/FindTarget.cpp (+1-2) 
- (modified) clang-tools-extra/clangd/XRefs.cpp (+4-3) 
- (modified) clang/include/clang/Sema/HeuristicResolver.h (+2-2) 
- (modified) clang/lib/Sema/HeuristicResolver.cpp (+49-38) 
- (modified) clang/unittests/Sema/HeuristicResolverTest.cpp (+20) 


``diff
diff --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 04fd6d437b7bdd..bb4c91b8313540 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -496,8 +496,7 @@ struct TargetFinder {
   return;
 case NestedNameSpecifier::Identifier:
   if (Resolver) {
-add(QualType(Resolver->resolveNestedNameSpecifierToType(NNS), 0),
-Flags);
+add(Resolver->resolveNestedNameSpecifierToType(NNS), Flags);
   }
   return;
 case NestedNameSpecifier::TypeSpec:
diff --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 0a093108b752c3..1a23f6cca77561 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -2034,9 +2034,10 @@ static void unwrapFindType(
 
   // For smart pointer types, add the underlying type
   if (H)
-if (const auto* PointeeType = 
H->getPointeeType(T.getNonReferenceType().getTypePtr())) {
-unwrapFindType(QualType(PointeeType, 0), H, Out);
-return Out.push_back(T);
+if (auto PointeeType = H->getPointeeType(T.getNonReferenceType());
+!PointeeType.isNull()) {
+  unwrapFindType(PointeeType, H, Out);
+  return Out.push_back(T);
 }
 
   return Out.push_back(T);
diff --git a/clang/include/clang/Sema/HeuristicResolver.h 
b/clang/include/clang/Sema/HeuristicResolver.h
index 947de7a4e83ce0..3760003aab89f1 100644
--- a/clang/include/clang/Sema/HeuristicResolver.h
+++ b/clang/include/clang/Sema/HeuristicResolver.h
@@ -66,13 +66,13 @@ class HeuristicResolver {
   // Try to heuristically resolve a dependent nested name specifier
   // to the type it likely denotes. Note that *dependent* name specifiers 
always
   // denote types, not namespaces.
-  const Type *
+  QualType
   resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS) const;
 
   // Given the type T of a dependent expression that appears of the LHS of a
   // "->", heuristically find a corresponding pointee type in whose scope we
   // could look up the name appearing on the RHS.
-  const Type *getPointeeType(const Type *T) const;
+  const QualType getPointeeType(QualType T) const;
 
 private:
   ASTContext &Ctx;
diff --git a/clang/lib/Sema/HeuristicResolver.cpp 
b/clang/lib/Sema/HeuristicResolver.cpp
index 7c1b8450b96330..fbce1a026be61c 100644
--- a/clang/lib/Sema/HeuristicResolver.cpp
+++ b/clang/lib/Sema/HeuristicResolver.cpp
@@ -42,8 +42,8 @@ class HeuristicResolverImpl {
   resolveDependentNameType(const DependentNameType *DNT);
   std::vector resolveTemplateSpecializationType(
   const DependentTemplateSpecializationType *DTST);
-  const Type *resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
-  const Type *getPointeeType(const Type *T);
+  QualType resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
+  QualType getPointeeType(QualType T);
 
 private:
   ASTContext &Ctx;
@@ -61,12 +61,12 @@ class HeuristicResolverImpl {
   // This heuristic will give the desired answer in many cases, e.g.
   // for a call to vector::size().
   std::vector
-  resolveDependentMember(const Type *T, DeclarationName Name,
+  resolveDependentMember(QualType T, DeclarationName Name,
  llvm::function_ref Filter);
 
   // Try to heuristically resolve the type of a possibly-dependent expression
   // `E`.
-  const Type *resolveExprToType(const Expr *E);
+  QualType resolveExprToType(const Expr *E);
   std::vector resolveExprToDecls(const Expr *E);
 
   // Helper function for HeuristicResolver::resolveDependentMember()
@@ -104,17 +104,17 @@ const auto TemplateFilter = [](const NamedDecl *D) {
   return isa(D);
 };
 
-const Type *resolveDeclsToType(const std::vector &Decls,
-   ASTContext &Ctx) {
+QualType resolveDeclsToType(const std::vector &Decls,
+ASTContext &Ctx) {
   if (Decls.size() != 1) // Names an overload set -- just bail.
-return nullptr;
+return QualType();
   if (const auto *TD = dyn_cast(Decls[0])) {
-return Ctx.getTypeDeclType(TD).getTypePtr();
+return Ctx.getTypeDeclType(TD);
   }
   if (const auto *VD = dyn_cast(Decls[0])) {
-return VD->getType().getTypePtrOrNull();
+return VD->getType();
   }
-  return nullptr;
+  return QualType();
 }
 
 TemplateName getReferencedTemplateName(const Type *T) {
@@ -137,7 +137,

[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)

2025-01-19 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

For ease of review, I split the PR into two patches (which I plan to squash):
 * The first patch is mechanical changes to use and propagate `QualType` rather 
than `Type *` in HeuristicResolver interfaces (both public and internal), where 
it makes sense.
 * The second patch uses the newly propagated qualifier information to fix the 
bug, and adds a testcase.

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


[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)

2025-01-19 Thread via cfe-commits

leijurv wrote:

Thank you for the review owenca, those are very reasonable changes, 
particularly on the conditions where the BreakBeforeClosingAngle gets set/used!

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


[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)

2025-01-19 Thread via cfe-commits

https://github.com/leijurv updated 
https://github.com/llvm/llvm-project/pull/118046

>From 1caf823165b16f6701993d586df51d5cdbf0885e Mon Sep 17 00:00:00 2001
From: Leijurv 
Date: Fri, 29 Nov 2024 21:54:36 -0600
Subject: [PATCH 01/12] [clang-format] Add BreakBeforeTemplateClose option

---
 clang/docs/ClangFormatStyleOptions.rst |  21 
 clang/docs/ReleaseNotes.rst|   1 +
 clang/include/clang/Format/Format.h|  20 
 clang/lib/Format/ContinuationIndenter.cpp  |  11 ++
 clang/lib/Format/ContinuationIndenter.h|  26 ++--
 clang/lib/Format/Format.cpp|   2 +
 clang/lib/Format/TokenAnnotator.cpp|   2 +-
 clang/unittests/Format/ConfigParseTest.cpp |   1 +
 clang/unittests/Format/FormatTest.cpp  | 131 +
 9 files changed, 206 insertions(+), 9 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4be448171699ca..84ab1b0a2eff61 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3416,6 +3416,27 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+.. _BreakBeforeTemplateClose:
+
+**BreakBeforeTemplateClose** (``Boolean``) :versionbadge:`clang-format 20` 
:ref:`¶ `
+  If ``true``, a line break will be placed before the ``>`` in a multiline
+  template declaration.
+
+  .. code-block:: c++
+
+ true:
+ template <
+ typename Foo,
+ typename Bar,
+ typename Baz
+ >
+
+ false:
+ template <
+ typename Foo,
+ typename Bar,
+ typename Baz>
+
 .. _BreakBeforeTernaryOperators:
 
 **BreakBeforeTernaryOperators** (``Boolean``) :versionbadge:`clang-format 3.7` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e44aefa90ab386..867d4b5d8c3f18 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -976,6 +976,7 @@ clang-format
   ``Never``, and ``true`` to ``Always``.
 - Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
 - Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
+- Adds ``BreakBeforeTemplateClose`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6383934afa2c40..bffd964f6aa8aa 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2248,6 +2248,25 @@ struct FormatStyle {
   /// \version 16
   BreakBeforeInlineASMColonStyle BreakBeforeInlineASMColon;
 
+  /// If ``true``, a line break will be placed before the ``>`` in a multiline
+  /// template declaration.
+  /// \code
+  ///true:
+  ///template <
+  ///typename Foo,
+  ///typename Bar,
+  ///typename Baz
+  ///>
+  ///
+  ///false:
+  ///template <
+  ///typename Foo,
+  ///typename Bar,
+  ///typename Baz>
+  /// \endcode
+  /// \version 20
+  bool BreakBeforeTemplateClose;
+
   /// If ``true``, ternary operators will be placed after line breaks.
   /// \code
   ///true:
@@ -5184,6 +5203,7 @@ struct FormatStyle {
BreakBeforeBraces == R.BreakBeforeBraces &&
BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations 
&&
BreakBeforeInlineASMColon == R.BreakBeforeInlineASMColon &&
+   BreakBeforeTemplateClose == R.BreakBeforeTemplateClose &&
BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
BreakBinaryOperations == R.BreakBinaryOperations &&
BreakConstructorInitializers == R.BreakConstructorInitializers &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index aed86c1fb99551..4c783623afc535 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -406,6 +406,10 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   }
   if (CurrentState.BreakBeforeClosingParen && Current.is(tok::r_paren))
 return true;
+  if (CurrentState.BreakBeforeClosingAngle &&
+  Current.ClosesTemplateDeclaration && Style.BreakBeforeTemplateClose) {
+return true;
+  }
   if (Style.Language == FormatStyle::LK_ObjC &&
   Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&
@@ -1234,6 +1238,9 @@ unsigned 
ContinuationIndenter::addTokenOnNewLine(LineState &State,
 Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
   }
 
+  if (PreviousNonComment && PreviousNonComment->is(tok::less))
+CurrentState.BreakBeforeClosingAngle = true;
+
   if (CurrentState.AvoidBinPacking) {
 // If we are breaking after '(', '{', '<', or this is the break after a ':'
 // to start a member initializer list in a constructor, this should not
@@ -1370,6 +1377,10 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   State.Stack.size() > 1) {
 return State.Stack[State.Stack.size() - 2].La

[clang] [Clang][MIPS] Create correct linker arguments for Windows toolchains (PR #121041)

2025-01-19 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/121041
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >