[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -455,6 +455,64 @@ The SYCL kernel in the previous code sample meets these 
expectations.
   }];
 }
 
+def SYCLKernelEntryPointDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``sycl_kernel_entry_point`` attribute specifies that a function definition
+defines a pattern for an offload kernel entry point function to be emitted when
+the source code is compiled with ``-fsycl`` for a device target. Such functions
+serve as the execution entry point for a SYCL run-time library to invoke a SYCL
+kernel on a device. The function's parameters define the parameters to the
+offload kernel.
+
+The attribute requires a single type argument that specifies a class type that
+meets the requirements for a SYCL kernel name as described in section 5.2,
+"Naming of kernels", of the SYCL 2020 specification. A unique kernel name type
+is required for each function declared with the attribute. The attribute may
+not first appear on a declaration that follows a definition of the function.
+
+The attribute appertains only to non-member functions and static member
+functions that meet the following requirements:
+
+- Has a ``void`` return type.
+- Is not a variadic function.

tahonermann wrote:

Thank you, fixed.

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -0,0 +1,47 @@
+//===--- SYCLKernelInfo.h --- Information about SYCL kernels 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// This file declares types used to describe SYCL kernels.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_AST_SYCLKERNELINFO_H
+#define LLVM_CLANG_AST_SYCLKERNELINFO_H
+
+#include 
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+
+namespace clang {
+
+class SYCLKernelInfo {
+public:
+  SYCLKernelInfo(
+  CanQualType KernelNameType,
+  const FunctionDecl *KernelEntryPointDecl)
+  :
+  KernelNameType(KernelNameType),
+  KernelEntryPointDecl(KernelEntryPointDecl)
+  {}
+
+  CanQualType GetKernelNameType() const {
+return KernelNameType;
+  }
+
+  const FunctionDecl* GetKernelEntryPointDecl() const {

tahonermann wrote:

Thank you, fixed.

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -0,0 +1,47 @@
+//===--- SYCLKernelInfo.h --- Information about SYCL kernels 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// This file declares types used to describe SYCL kernels.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_AST_SYCLKERNELINFO_H
+#define LLVM_CLANG_AST_SYCLKERNELINFO_H
+
+#include 
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+
+namespace clang {
+
+class SYCLKernelInfo {
+public:
+  SYCLKernelInfo(
+  CanQualType KernelNameType,
+  const FunctionDecl *KernelEntryPointDecl)
+  :
+  KernelNameType(KernelNameType),
+  KernelEntryPointDecl(KernelEntryPointDecl)
+  {}
+
+  CanQualType GetKernelNameType() const {

tahonermann wrote:

Thank you, fixed.

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -455,6 +455,64 @@ The SYCL kernel in the previous code sample meets these 
expectations.
   }];
 }
 
+def SYCLKernelEntryPointDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``sycl_kernel_entry_point`` attribute specifies that a function definition

tahonermann wrote:

Yeah. I rewrote a bunch of the doc. Hopefully better now.

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -455,6 +455,64 @@ The SYCL kernel in the previous code sample meets these 
expectations.
   }];
 }
 
+def SYCLKernelEntryPointDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``sycl_kernel_entry_point`` attribute specifies that a function definition
+defines a pattern for an offload kernel entry point function to be emitted when
+the source code is compiled with ``-fsycl`` for a device target. Such functions
+serve as the execution entry point for a SYCL run-time library to invoke a SYCL
+kernel on a device. The function's parameters define the parameters to the
+offload kernel.
+
+The attribute requires a single type argument that specifies a class type that
+meets the requirements for a SYCL kernel name as described in section 5.2,
+"Naming of kernels", of the SYCL 2020 specification. A unique kernel name type
+is required for each function declared with the attribute. The attribute may
+not first appear on a declaration that follows a definition of the function.
+
+The attribute appertains only to non-member functions and static member
+functions that meet the following requirements:
+
+- Has a ``void`` return type.
+- Is not a variadic function.
+- Is not a coroutine.
+- Is not defined as deleted or as defaulted.

tahonermann wrote:

I haven't been able to imagine such a use case. Can you explain further how you 
envision this being useful? I'm inclined toward prohibiting use with defaulted 
functions for now; we can always relax support later if a use case emerges.

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -14296,6 +14296,31 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   }
 }
 
+static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context,
+  CanQualType KernelNameType,
+  const FunctionDecl *FD) {
+  return { KernelNameType, FD };
+}
+
+void ASTContext::registerSYCLEntryPointFunction(FunctionDecl *FD) {
+  assert(!FD->isInvalidDecl());
+  assert(!FD->isDependentContext());
+
+  const auto *SKEPAttr = FD->getAttr();
+  assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
+
+  CanQualType KernelNameType = getCanonicalType(SKEPAttr->getKernelName());
+  auto IT = SYCLKernels.find(KernelNameType);
+  if (IT != SYCLKernels.end()) {
+if (!declaresSameEntity(FD, IT->second.GetKernelEntryPointDecl()))
+  llvm::report_fatal_error("SYCL kernel name conflict");

tahonermann wrote:

Very much agreed. Diagnostics will be available in the next PR. There are still 
a few issues we're working to fix before that PR is submitted though. Our WIP 
is staged 
[here](https://github.com/tahonermann/llvm-project/compare/sycl-upstream-fe-pr1...tahonermann:llvm-project:sycl-upstream-fe-pr2).
 Feel free to take a look and offer any comments here; I'll then address them 
before that PR is submitted.

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -14296,6 +14296,31 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   }
 }
 
+static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context,
+  CanQualType KernelNameType,
+  const FunctionDecl *FD) {
+  return { KernelNameType, FD };
+}
+
+void ASTContext::registerSYCLEntryPointFunction(FunctionDecl *FD) {
+  assert(!FD->isInvalidDecl());
+  assert(!FD->isDependentContext());

tahonermann wrote:

No. At least, I don't think so. The intent is to reject any declaration that is 
somehow templated. A static member function of a class template (as opposed to 
its instantiated declaration in an instantiated specialization) shouldn't be 
registered.

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


[clang] [clang][docs][OpenMP] Move tracing interface to OpenMP 5.0 (PR #112125)

2024-10-12 Thread Luke Marzen via cfe-commits

https://github.com/lmarzen created 
https://github.com/llvm/llvm-project/pull/112125

The OMPT Device Tracing Interface was introduced in the OpenMP 5.0 
specification (see section 4.6.2).

https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf

>From 41e3caa489f5607b3b292f5a75a5b5a4a8cb9357 Mon Sep 17 00:00:00 2001
From: Luke Marzen <98473324+lmar...@users.noreply.github.com>
Date: Sun, 13 Oct 2024 01:09:07 -0500
Subject: [PATCH] [clang][docs][OpenMP] Move tracing interface to OpenMP 5.0

The OMPT Device Tracing Interface was introduced in the OpenMP 5.0 
specification (see section 4.6.2).

https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf
---
 clang/docs/OpenMPSupport.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 6c7afc12b44ebb..3c9720539ab025 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -111,7 +111,9 @@ implementation.
 
+--+--+--+---+
 | OMPD | OMPD interfaces   
   | :good:`done` | https://reviews.llvm.org/D99914   
(Supports only HOST(CPU) and Linux  |
 
+--+--+--+---+
-| OMPT | OMPT interfaces (callback support)
   | :good:`done` | 
  |
+| OMPT | callback interface
   | :good:`done` | 
  |
++--+--+--+---+
+| OMPT | device tracing interface  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
 | thread affinity  | thread affinity   
   | :good:`done` | 
  |
 
+--+--+--+---+
@@ -332,8 +334,6 @@ implementation.
 
+--+--+--+---+
 | OMPT | new 'emi' callbacks for external monitoring 
interfaces   | :good:`done` |   
|
 
+--+--+--+---+
-| OMPT | device tracing interface  
   | :none:`unclaimed`| 
  |
-+--+--+--+---+
 | task | 'strict' modifier for taskloop construct  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
 | task | inoutset in depend clause 
   | :good:`done` | D97085, D118383 
  |

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


[clang] [clang][docs][OpenMP] Move tracing interface to OpenMP 5.0 (PR #112125)

2024-10-12 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/112125
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][docs][OpenMP] Move tracing interface to OpenMP 5.0 (PR #112125)

2024-10-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Luke Marzen (lmarzen)


Changes

The OMPT Device Tracing Interface was introduced in the OpenMP 5.0 
specification (see section 4.6.2).

https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf

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


1 Files Affected:

- (modified) clang/docs/OpenMPSupport.rst (+3-3) 


``diff
diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 6c7afc12b44ebb..3c9720539ab025 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -111,7 +111,9 @@ implementation.
 
+--+--+--+---+
 | OMPD | OMPD interfaces   
   | :good:`done` | https://reviews.llvm.org/D99914   
(Supports only HOST(CPU) and Linux  |
 
+--+--+--+---+
-| OMPT | OMPT interfaces (callback support)
   | :good:`done` | 
  |
+| OMPT | callback interface
   | :good:`done` | 
  |
++--+--+--+---+
+| OMPT | device tracing interface  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
 | thread affinity  | thread affinity   
   | :good:`done` | 
  |
 
+--+--+--+---+
@@ -332,8 +334,6 @@ implementation.
 
+--+--+--+---+
 | OMPT | new 'emi' callbacks for external monitoring 
interfaces   | :good:`done` |   
|
 
+--+--+--+---+
-| OMPT | device tracing interface  
   | :none:`unclaimed`| 
  |
-+--+--+--+---+
 | task | 'strict' modifier for taskloop construct  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
 | task | inoutset in depend clause 
   | :good:`done` | D97085, D118383 
  |

``




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


[clang] [clang][docs][OpenMP] Move tracing interface to OpenMP 5.0 (PR #112125)

2024-10-12 Thread Luke Marzen via cfe-commits

lmarzen wrote:

@jdoerfert, @AndreyChurbanov

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -455,6 +455,64 @@ The SYCL kernel in the previous code sample meets these 
expectations.
   }];
 }
 
+def SYCLKernelEntryPointDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``sycl_kernel_entry_point`` attribute specifies that a function definition
+defines a pattern for an offload kernel entry point function to be emitted when
+the source code is compiled with ``-fsycl`` for a device target. Such functions
+serve as the execution entry point for a SYCL run-time library to invoke a SYCL
+kernel on a device. The function's parameters define the parameters to the
+offload kernel.
+
+The attribute requires a single type argument that specifies a class type that
+meets the requirements for a SYCL kernel name as described in section 5.2,
+"Naming of kernels", of the SYCL 2020 specification. A unique kernel name type
+is required for each function declared with the attribute. The attribute may
+not first appear on a declaration that follows a definition of the function.
+
+The attribute appertains only to non-member functions and static member

tahonermann wrote:

I reworded by moving the restriction on non-static member functions into the 
bullet list. I also added constructors and destructors.

Historically, lambdas would be prohibited by the restrictions against 
non-static member functions. We now have lambda expressions that produce a 
closure type with a static fiunction call operator. I think those should be ok.

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -0,0 +1,137 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only 
-fsycl-is-device -verify %s

tahonermann wrote:

Those tests are included with the diagnostic work that will be in the next PR. 
See 
[here](https://github.com/tahonermann/llvm-project/compare/sycl-upstream-fe-pr1...tahonermann:llvm-project:sycl-upstream-fe-pr2)
 for what has been completed. We still have some SFINAE issues to address (an 
invalid use of the attribute is triggering SFINAE and therefore affecting 
overload resolution) and I'm still working on a diagnostic for forward 
declarability of kernel names (for SYCL portability warnings; Clang won't 
actually require forward declarability since it won't depend on integration 
headers).

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -14296,6 +14296,31 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   }
 }
 
+static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context,
+  CanQualType KernelNameType,
+  const FunctionDecl *FD) {
+  return { KernelNameType, FD };
+}
+
+void ASTContext::registerSYCLEntryPointFunction(FunctionDecl *FD) {
+  assert(!FD->isInvalidDecl());
+  assert(!FD->isDependentContext());
+
+  const auto *SKEPAttr = FD->getAttr();
+  assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
+
+  CanQualType KernelNameType = getCanonicalType(SKEPAttr->getKernelName());
+  auto IT = SYCLKernels.find(KernelNameType);
+  if (IT != SYCLKernels.end()) {
+if (!declaresSameEntity(FD, IT->second.GetKernelEntryPointDecl()))
+  llvm::report_fatal_error("SYCL kernel name conflict");
+  } else {
+SYCLKernels.insert_or_assign(

tahonermann wrote:

Thank you. I think the "or_assign" part was leftover from before some 
refactoring. Fixed.

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


[clang-tools-extra] [clang-tidy] Make `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

2024-10-12 Thread Julian Schmidt via cfe-commits


@@ -352,21 +352,30 @@ void good13(void) {
   int Buffer[BufferSize];
 
   int *P = &Buffer[0];
-  while (P < (Buffer + sizeof(Buffer) / sizeof(int))) {
+  while (P < Buffer + sizeof(Buffer) / sizeof(int)) {
 // NO-WARNING: Calculating the element count of the buffer here, which is
 // safe with this idiom (as long as the types don't change).
 ++P;
   }
 
-  while (P < (Buffer + sizeof(Buffer) / sizeof(Buffer[0]))) {
+  while (P < Buffer + sizeof(Buffer) / sizeof(Buffer[0])) {
 // NO-WARNING: Calculating the element count of the buffer here, which is
 // safe with this idiom.
 ++P;
   }
 
-  while (P < (Buffer + sizeof(Buffer) / sizeof(*P))) {
+  while (P < Buffer + sizeof(Buffer) / sizeof(*P)) {
 // NO-WARNING: Calculating the element count of the buffer here, which is
 // safe with this idiom.
 ++P;
   }
 }
+
+void situational14(int *Buffer, size_t BufferSize) {
+  int *P = &Buffer[0];
+  while (P < Buffer + BufferSize / sizeof(*Buffer)) {
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious usage of 
'sizeof(...)' in pointer arithmetic; this scaled value will be scaled again by 
the '+' operator

5chmidti wrote:

You're right

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


[clang-tools-extra] [clang-tidy] Make `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

2024-10-12 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti approved this pull request.


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


[clang] [Clang] fix range calculation for conditionals with throw expressions (PR #112081)

2024-10-12 Thread Oleksandr T. via cfe-commits

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

>From 67c41612085489a2a17eec49f98dbfa0e5bb97cf Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 12 Oct 2024 08:27:51 +0300
Subject: [PATCH] [Clang] fix range calculation for conditionals with throw
 expressions

---
 clang/docs/ReleaseNotes.rst | 1 +
 clang/lib/Sema/SemaChecking.cpp | 3 +++
 clang/test/SemaCXX/conditional-expr.cpp | 7 +++
 3 files changed, 11 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 337e3fc10bf49d..2ab13640bfa53c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -512,6 +512,7 @@ Bug Fixes to C++ Support
   and undeclared templates. (#GH107047, #GH49093)
 - Clang no longer crashes when a lambda contains an invalid block declaration 
that contains an unexpanded
   parameter pack. (#GH109148)
+- Fixed assertion failure in range calculations for conditional throw 
expressions (#GH111854)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2bcb930acdcb57..b3d88f053872c1 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -9827,6 +9827,9 @@ static IntRange GetExprRange(ASTContext &C, const Expr 
*E, unsigned MaxWidth,
 return IntRange(BitField->getBitWidthValue(C),
 BitField->getType()->isUnsignedIntegerOrEnumerationType());
 
+  if (GetExprType(E)->isVoidType())
+return IntRange{0, true};
+
   return IntRange::forValueOfType(C, GetExprType(E));
 }
 
diff --git a/clang/test/SemaCXX/conditional-expr.cpp 
b/clang/test/SemaCXX/conditional-expr.cpp
index 01effaa189322b..8f17555fd806ff 100644
--- a/clang/test/SemaCXX/conditional-expr.cpp
+++ b/clang/test/SemaCXX/conditional-expr.cpp
@@ -429,3 +429,10 @@ void g() {
   long e = a = b ? throw 0 : throw 1;
 }
 } // namespace PR46484
+
+namespace GH111854 {
+void f() {
+  (true ? throw 0 : 0) <= 0;  // expected-warning {{relational comparison 
result unused}}
+  (false ? 0 : throw 0) <= 0; // expected-warning {{relational comparison 
result unused}}
+}
+}

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


[clang] 3acb0e9 - [HIP] Replace use of `llvm-mc` with `clang` (#112041)

2024-10-12 Thread via cfe-commits

Author: Joseph Huber
Date: 2024-10-12T07:03:28-05:00
New Revision: 3acb0e9e600cbe3668b7db3956238a592ebadc0a

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

LOG: [HIP] Replace use of `llvm-mc` with `clang` (#112041)

Summary:
We currently use `llvm-mc` which is intended for internal testing and
not expected to be present in every installation. This patch changes
that to just use clang instead to get the `.o` from the HIP registration
code.

My preferred solution would be to use the new driver, but I still
haven't gotten the test suite to pass on this one weird OpenMP case.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIPUtility.cpp
clang/test/Driver/hip-link-save-temps.hip
clang/test/Driver/hip-partial-link.hip
clang/test/Driver/hip-save-temps.hip
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/hip-toolchain-rdc-static-lib.hip
clang/test/Driver/hip-toolchain-rdc.hip
clang/test/Driver/hip-unbundle-preproc.hipi
clang/test/Driver/hipspv-toolchain-rdc.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp 
b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index b3adfe65402ff3..a23858e5f90978 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -346,14 +346,14 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
   // Create Temp Object File Generator,
   // Offload Bundled file and Bundled Object file.
   // Keep them if save-temps is enabled.
-  const char *McinFile;
+  const char *ObjinFile;
   const char *BundleFile;
   if (C.getDriver().isSaveTempsEnabled()) {
-McinFile = C.getArgs().MakeArgString(Name + ".mcin");
+ObjinFile = C.getArgs().MakeArgString(Name + ".mcin");
 BundleFile = C.getArgs().MakeArgString(Name + ".hipfb");
   } else {
 auto TmpNameMcin = C.getDriver().GetTemporaryPath(Name, "mcin");
-McinFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameMcin));
+ObjinFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameMcin));
 auto TmpNameFb = C.getDriver().GetTemporaryPath(Name, "hipfb");
 BundleFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameFb));
   }
@@ -454,7 +454,7 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
 
   // Open script file and write the contents.
   std::error_code EC;
-  llvm::raw_fd_ostream Objf(McinFile, EC, llvm::sys::fs::OF_None);
+  llvm::raw_fd_ostream Objf(ObjinFile, EC, llvm::sys::fs::OF_None);
 
   if (EC) {
 C.getDriver().Diag(clang::diag::err_unable_to_make_temp) << EC.message();
@@ -463,10 +463,11 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
 
   Objf << ObjBuffer;
 
-  ArgStringList McArgs{"-triple", Args.MakeArgString(HostTriple.normalize()),
+  ArgStringList McArgs{"-target", Args.MakeArgString(HostTriple.normalize()),
"-o",  Output.getFilename(),
-   McinFile,  "--filetype=obj"};
-  const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc"));
-  C.addCommand(std::make_unique(JA, T, ResponseFileSupport::None(), 
Mc,
- McArgs, Inputs, Output));
+   "-x",  "assembler",
+   ObjinFile, "-c"};
+  const char *Clang = Args.MakeArgString(C.getDriver().ClangExecutable);
+  C.addCommand(std::make_unique(JA, T, ResponseFileSupport::None(),
+ Clang, McArgs, Inputs, Output));
 }

diff  --git a/clang/test/Driver/hip-link-save-temps.hip 
b/clang/test/Driver/hip-link-save-temps.hip
index 5656614626b9cd..e321970274bb4b 100644
--- a/clang/test/Driver/hip-link-save-temps.hip
+++ b/clang/test/Driver/hip-link-save-temps.hip
@@ -39,10 +39,10 @@
 // CHECK-NOT: {{".*/opt"}}
 // CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
-// CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
+// CHECK-SAME: "-o" "[[HIPFB1:.+]]" "obj1-hip-amdgcn-amd-amdhsa-gfx900.o" 
"obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
-// CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx906" 
"obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
-// CHECK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" 
"--filetype=obj"
+// CHECK-SAME: "-o" "[[HIPFB2:.+]]" "obj1-hip-amdgcn-amd-amdhsa-gfx906.o" 
"obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
+// CHECK: "{{.*clang.*}}" "-target" "x86_64-unknown-linux-gnu" "-o" 
"[[OBJBUNDLE:.+.o]]" "-x" "assembler" "{{.*}}.mcin" "-c"
 // OUT: "{{.*ld.*}}" {{.*}} "-o" "executable" {{.*}} "[[OBJBUNDLE]]"
 // NOUT: "{{.*ld.*}}" {{.

[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread Joseph Huber via cfe-commits

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


[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-ppc64le-rhel` 
running on `ppc64le-clang-rhel-test` while building `clang` at step 5 
"build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
1.541 [501/4/1] Building CXX object 
tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
1.579 [500/4/2] Linking CXX executable bin/llvm-config
1.589 [500/3/3] Generating VCSRevision.h
1.622 [497/5/4] Generating VCSVersion.inc
2.746 [496/5/5] Building CXX object 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Version.cpp.o
5.810 [496/4/6] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
FAILED: 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 
ccache /home/docker/llvm-external-buildbots/clang.17.0.6/bin/clang++ 
--gcc-toolchain=/gcc-toolchain/usr -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/lib/Driver
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/lib/Driver
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -MF 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o.d
 -o 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp:343:20:
 error: unused variable 'TC' [-Werror,-Wunused-variable]
  343 |   const ToolChain &TC = T.getToolChain();
  |^~
1 error generated.
6.440 [496/3/7] Building CXX object 
lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
21.581 [496/2/8] Building CXX object 
lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
23.783 [496/1/9] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
ninja: build stopped: subcommand failed.

```



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


[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while 
building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[4150/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/FunctionSummary.cpp.o
[4151/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CheckerContext.cpp.o
[4152/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CheckerHelpers.cpp.o
[4153/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/LoopWidening.cpp.o
[4154/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/MemRegion.cpp.o
[4155/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CheckerManager.cpp.o
[4156/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/ExprEngineCallAndReturn.cpp.o
[4157/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o
[4158/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangedConstraintManager.cpp.o
[4159/5279] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
FAILED: 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build0/bin/clang++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/tools/clang/lib/Driver
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Driver
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/include
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/tools/clang/include
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/include
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -MF 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o.d
 -o 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -c 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp:343:20:
 error: unused variable 'TC' [-Werror,-Wunused-variable]
  343 |   const ToolChain &TC = T.getToolChain();
  |^~
1 error generated.
[4160/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/HTMLDiagnostics.cpp.o
[4161/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CoreEngine.cpp.o
[4162/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/ExplodedGraph.cpp.o
[4163/5279] Building RISCVGenSubtargetInfo.inc...
[4164/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/PlistDiagnostics.cpp.o
[4165/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/ExprEngine.cpp.o
[4166/5279] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles

[clang] 6a6af02 - [Clang] Remove unused TC variable

2024-10-12 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2024-10-12T07:09:03-05:00
New Revision: 6a6af0246bd2d68291582e9aefc0543e5c6102fe

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

LOG: [Clang] Remove unused TC variable

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIPUtility.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp 
b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index a23858e5f90978..d4d324fb339c45 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -340,7 +340,6 @@ void HIP::constructHIPFatbinCommand(Compilation &C, const 
JobAction &JA,
 void HIP::constructGenerateObjFileFromHIPFatBinary(
 Compilation &C, const InputInfo &Output, const InputInfoList &Inputs,
 const ArgList &Args, const JobAction &JA, const Tool &T) {
-  const ToolChain &TC = T.getToolChain();
   std::string Name = std::string(llvm::sys::path::stem(Output.getFilename()));
 
   // Create Temp Object File Generator,



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


[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` 
running on `ppc64le-sanitizer` while building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[3708/4073] Building CXX object 
tools/clang/tools/libclang/CMakeFiles/libclang.dir/Indexing.cpp.o
[3709/4073] Linking CXX executable bin/llvm-diff
[3710/4073] Building CXX object 
tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/core_main.cpp.o
[3711/4073] Building CXX object 
tools/clang/tools/driver/CMakeFiles/clang.dir/driver.cpp.o
[3712/4073] Building CXX object 
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
[3713/4073] Building CXX object 
tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o
[3714/4073] Building CXX object 
tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexCodeCompletion.cpp.o
[3715/4073] Building CXX object 
tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/ClangInstallAPI.cpp.o
[3716/4073] Building CXX object 
tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXExtractAPI.cpp.o
[3717/4073] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
FAILED: 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm_build0/bin/clang++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/lib/Driver
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Driver
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -MF 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o.d
 -o 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp:343:20:
 error: unused variable 'TC' [-Werror,-Wunused-variable]
  343 |   const ToolChain &TC = T.getToolChain();
  |^~
1 error generated.
[3718/4073] Building CXX object 
lib/MC/MCParser/CMakeFiles/LLVMMCParser.dir/AsmParser.cpp.o
ninja: build stopped: subcommand failed.

How to reproduce locally: 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild

@@@STEP_FAILURE@@@
@@@BUILD_STEP test compiler-rt debug@@@
ninja: Entering directory `build_default'
[1/240] Linking CXX static library lib/libLLVMMCParser.a
[2/240] Linking CXX static library lib/libLLVMObject.a
[3/240] Linking CXX static library lib/libLLVMPowerPCAsmParser.a
[4/240] Linking CXX static library lib/libLLVMObjCopy.a
[5/240] Linking CXX static library lib/libLLVMLibDriver.a
[6/240] Linking CXX static library lib/libLLVMObjectYAML.a
[7/240] Linking CXX static library lib/libLLVMDlltoolDriver.a
[8/240] Linking CXX static library lib/libLLVMXRay.a
[9/240] Linking CXX static library lib/libLLVMRuntimeDyld.a
[10/240] Linking CXX static library lib/libLLVMDebugInfoDWARF.a
[11/240] Linking CXX static library lib/libLLVMDebugInfoPDB

[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux` 
running on `sanitizer-buildbot1` while building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[4331/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/SARIFDiagnosticPrinter.cpp.o
[4332/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/SerializedDiagnosticReader.cpp.o
[4333/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/SerializedDiagnosticPrinter.cpp.o
[4334/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/TestModuleFileExtension.cpp.o
[4335/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/TextDiagnosticBuffer.cpp.o
[4336/5308] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGObjC.cpp.o
[4337/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/TextDiagnosticPrinter.cpp.o
[4338/5308] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/BPF.cpp.o
[4339/5308] Building CXX object 
tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/FixItRewriter.cpp.o
[4340/5308] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
FAILED: 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/b/sanitizer-x86_64-linux/build/llvm_build0/bin/clang++ -DGTEST_HAS_RTTI=0 
-D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/b/sanitizer-x86_64-linux/build/build_default/tools/clang/lib/Driver 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/clang/include 
-I/home/b/sanitizer-x86_64-linux/build/build_default/tools/clang/include 
-I/home/b/sanitizer-x86_64-linux/build/build_default/include 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/include -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -MF 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o.d
 -o 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -c 
/home/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp
/home/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp:343:20:
 error: unused variable 'TC' [-Werror,-Wunused-variable]
  343 |   const ToolChain &TC = T.getToolChain();
  |^~
1 error generated.
[4341/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTUnit.cpp.o
[4342/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CreateInvocationFromCommandLine.cpp.o
[4343/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/DependencyFile.cpp.o
[4344/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CompilerInstance.cpp.o
[4345/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/PrintPreprocessedOutput.cpp.o
[4346/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/HeaderIncludeGen.cpp.o
[4347/5308] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/ARM.cpp.o
[4348/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/VerifyDiagnosticConsumer.cpp.o
[4349/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/TextDiagnostic.cpp.o
[4350/5308] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/InitPreprocessor.cpp.o
[4351/5308] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/DirectX.cpp.o
[4352/5308] Building CXX object 
tools/clan

[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-aarch64-linux` 
running on `sanitizer-buildbot7` while building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[4550/5304] Linking CXX executable bin/llvm-symbolizer
[4551/5304] Building CXX object 
tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/ClangInstallAPI.cpp.o
[4552/5304] Generating ../../bin/llvm-addr2line
[4553/5304] Linking CXX executable bin/yaml2obj
[4554/5304] Building X86GenDAGISel.inc...
[4555/5304] Linking CXX executable bin/llvm-xray
[4556/5304] Linking CXX executable bin/sanstats
[4557/5304] Linking CXX executable bin/obj2yaml
[4558/5304] Linking CXX executable bin/verify-uselistorder
[4559/5304] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
FAILED: 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/b/sanitizer-aarch64-linux/build/llvm_build0/bin/clang++ 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/b/sanitizer-aarch64-linux/build/build_default/tools/clang/lib/Driver 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Driver 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/include 
-I/home/b/sanitizer-aarch64-linux/build/build_default/tools/clang/include 
-I/home/b/sanitizer-aarch64-linux/build/build_default/include 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/include -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -MF 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o.d
 -o 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -c 
/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp
/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp:343:20:
 error: unused variable 'TC' [-Werror,-Wunused-variable]
  343 |   const ToolChain &TC = T.getToolChain();
  |^~
1 error generated.
[4560/5304] Building X86GenSubtargetInfo.inc...
[4561/5304] Building RISCVGenInstrInfo.inc...
[4562/5304] Building AMDGPUGenAsmWriter.inc...
[4563/5304] Building RISCVGenGlobalISel.inc...
[4564/5304] Building X86GenInstrInfo.inc...
[4565/5304] Building AMDGPUGenAsmMatcher.inc...
[4566/5304] Building AMDGPUGenGlobalISel.inc...
[4567/5304] Building RISCVGenDAGISel.inc...
[4568/5304] Building AMDGPUGenDAGISel.inc...
[4569/5304] Building AMDGPUGenInstrInfo.inc...
[4570/5304] Building AMDGPUGenRegisterBank.inc...
[4571/5304] Building AMDGPUGenRegisterInfo.inc...
[4572/5304] Building RISCVGenSubtargetInfo.inc...
ninja: build stopped: subcommand failed.

How to reproduce locally: 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild

@@@STEP_FAILURE@@@
@@@BUILD_STEP test compiler-rt symbolizer@@@
ninja: Entering directory `build_default'
[1/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVAsmPrinter.cpp.o
[2/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVCallingConv.cpp.o
[3/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVCodeGenPrepare.cpp.o
[4/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVConstantPoolValue.cpp.o
[5/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVDeadRegisterDefinitions.cpp.o
[6/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVMakeCompressible.cpp.o
[7/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVExpandAtomicPseudoInsts.cpp.o
[8/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVExpandPseudoInsts.cpp.o
[9/491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVFrameLowering.cpp.o
[10/491] Building CXX ob

[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -455,6 +455,64 @@ The SYCL kernel in the previous code sample meets these 
expectations.
   }];
 }
 
+def SYCLKernelEntryPointDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``sycl_kernel_entry_point`` attribute specifies that a function definition
+defines a pattern for an offload kernel entry point function to be emitted when
+the source code is compiled with ``-fsycl`` for a device target. Such functions
+serve as the execution entry point for a SYCL run-time library to invoke a SYCL
+kernel on a device. The function's parameters define the parameters to the
+offload kernel.
+
+The attribute requires a single type argument that specifies a class type that
+meets the requirements for a SYCL kernel name as described in section 5.2,
+"Naming of kernels", of the SYCL 2020 specification. A unique kernel name type
+is required for each function declared with the attribute. The attribute may
+not first appear on a declaration that follows a definition of the function.
+
+The attribute appertains only to non-member functions and static member
+functions that meet the following requirements:
+
+- Has a ``void`` return type.
+- Is not a variadic function.
+- Is not a coroutine.
+- Is not defined as deleted or as defaulted.
+- Is not declared with the ``constexpr`` or ``consteval`` specifiers.

tahonermann wrote:

Hmm, maybe? I guess I'm not opposed, but it seems strange. There is no 
possibility of the offload kernel entry point being invoked in a constant 
evaluation context. The possibility of `constexpr` being implicitly added is a 
good point, but I don't really see this attribute being used with (static) 
lambdas either. I'm inclined to wait and see if use cases arise.

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


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-12 Thread Tom Honermann via cfe-commits


@@ -455,6 +455,64 @@ The SYCL kernel in the previous code sample meets these 
expectations.
   }];
 }
 
+def SYCLKernelEntryPointDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``sycl_kernel_entry_point`` attribute specifies that a function definition
+defines a pattern for an offload kernel entry point function to be emitted when
+the source code is compiled with ``-fsycl`` for a device target. Such functions
+serve as the execution entry point for a SYCL run-time library to invoke a SYCL
+kernel on a device. The function's parameters define the parameters to the
+offload kernel.
+
+The attribute requires a single type argument that specifies a class type that
+meets the requirements for a SYCL kernel name as described in section 5.2,
+"Naming of kernels", of the SYCL 2020 specification. A unique kernel name type
+is required for each function declared with the attribute. The attribute may
+not first appear on a declaration that follows a definition of the function.
+
+The attribute appertains only to non-member functions and static member
+functions that meet the following requirements:
+
+- Has a ``void`` return type.
+- Is not a variadic function.
+- Is not a coroutine.
+- Is not defined as deleted or as defaulted.
+- Is not declared with the ``constexpr`` or ``consteval`` specifiers.
+- Is not declared with the ``[[noreturn]]`` attribute.
+
+This attribute is intended for use in the implementation of SYCL run-time

tahonermann wrote:

I don't think so. That would tend to bias against SYCL library implementations 
that aren't provided with LLVM/Clang or distributed with an OS. I don't know 
that such implementations are likely to appear, but I'm not inclined towards 
adding roadblocks for them.

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


[clang] [lld] [llvm] [WebAssembly] Define a new "Trail1" CPU (PR #112035)

2024-10-12 Thread Dan Gohman via cfe-commits

https://github.com/sunfishcode updated 
https://github.com/llvm/llvm-project/pull/112035

>From b8f33cd68d11759ad774e16b4d25491a1c9fc3e4 Mon Sep 17 00:00:00 2001
From: Dan Gohman 
Date: Fri, 11 Oct 2024 04:30:32 -0700
Subject: [PATCH 1/4] [WebAssembly] Define a new "Trail1" CPU

First, define some new target features. These are subsets of existing features
that reflect implemenetation concerns:

 - "call-indirect-overlong" - implied by "reference-types"; just the overlong
   encoding for the `call_indirect` immediate, and not the actual reference
   types.

 - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and
   `memory.fill`, and not the other instructions in the bulk-memory
proposal.

Next, define a new target CPU, "Trail1", which enables mutable-globals,
bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const,
and call-indirect-overlong. Unlike the default "generic" CPU, "trail1" is meant
to be frozen, and followed up by "trail2" and so on when new features are
desired.
---
 clang/lib/Basic/Targets/WebAssembly.cpp   | 45 +++
 clang/lib/Basic/Targets/WebAssembly.h |  2 +
 lld/test/wasm/compress-relocs.ll  |  2 +-
 lld/test/wasm/import-table-explicit.s |  2 +-
 lld/test/wasm/invalid-mvp-table-use.s |  2 +-
 lld/wasm/InputFiles.cpp   | 11 ++---
 lld/wasm/SyntheticSections.cpp|  2 +-
 .../AsmParser/WebAssemblyAsmParser.cpp| 12 ++---
 llvm/lib/Target/WebAssembly/WebAssembly.td| 14 ++
 .../WebAssembly/WebAssemblyFastISel.cpp   |  2 +-
 .../WebAssembly/WebAssemblyISelLowering.cpp   |  2 +-
 .../WebAssembly/WebAssemblyInstrBulkMemory.td | 15 ---
 .../WebAssembly/WebAssemblyInstrInfo.td   |  8 
 .../WebAssemblySelectionDAGInfo.cpp   |  4 +-
 .../Target/WebAssembly/WebAssemblySubtarget.h |  4 ++
 .../WebAssembly/WebAssemblyUtilities.cpp  |  4 +-
 llvm/test/CodeGen/WebAssembly/bulk-memory.ll  |  6 +--
 .../test/CodeGen/WebAssembly/bulk-memory64.ll |  6 +--
 18 files changed, 110 insertions(+), 33 deletions(-)

diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 5ac9421663adea..aa3a2770727c3a 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   return llvm::StringSwitch(Feature)
   .Case("atomics", HasAtomics)
   .Case("bulk-memory", HasBulkMemory)
+  .Case("bulk-memory-opt", HasBulkMemoryOpt)
   .Case("exception-handling", HasExceptionHandling)
   .Case("extended-const", HasExtendedConst)
   .Case("fp16", HasFP16)
@@ -55,6 +56,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   .Case("mutable-globals", HasMutableGlobals)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("reference-types", HasReferenceTypes)
+  .Case("call-indirect-overlong", HasCallIndirectOverlong)
   .Case("relaxed-simd", SIMDLevel >= RelaxedSIMD)
   .Case("sign-ext", HasSignExt)
   .Case("simd128", SIMDLevel >= SIMD128)
@@ -78,6 +80,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const 
LangOptions &Opts,
 Builder.defineMacro("__wasm_atomics__");
   if (HasBulkMemory)
 Builder.defineMacro("__wasm_bulk_memory__");
+  if (HasBulkMemoryOpt)
+Builder.defineMacro("__wasm_bulk_memory_opt__");
   if (HasExceptionHandling)
 Builder.defineMacro("__wasm_exception_handling__");
   if (HasExtendedConst)
@@ -154,12 +158,23 @@ bool WebAssemblyTargetInfo::initFeatureMap(
 Features["multivalue"] = true;
 Features["mutable-globals"] = true;
 Features["reference-types"] = true;
+Features["call-indirect-overlong"] = true;
 Features["sign-ext"] = true;
   };
+  auto addTrail1Features = [&]() {
+Features["multivalue"] = true;
+Features["mutable-globals"] = true;
+Features["call-indirect-overlong"] = true;
+Features["sign-ext"] = true;
+Features["bulk-memory-opt"] = true;
+Features["nontrapping-fptoint"] = true;
+Features["extended-const"] = true;
+  };
   auto addBleedingEdgeFeatures = [&]() {
 addGenericFeatures();
 Features["atomics"] = true;
 Features["bulk-memory"] = true;
+Features["bulk-memory-opt"] = true;
 Features["exception-handling"] = true;
 Features["extended-const"] = true;
 Features["fp16"] = true;
@@ -170,6 +185,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
   };
   if (CPU == "generic") {
 addGenericFeatures();
+  } else if (CPU == "trail1") {
+addTrail1Features();
   } else if (CPU == "bleeding-edge") {
 addBleedingEdgeFeatures();
   }
@@ -196,6 +213,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
   HasBulkMemory = false;
   continue;
 }
+if (Feature == "+bulk-memory-opt") {
+  HasBulkMemoryOpt = true;
+  continue;
+}
+if (Feature == "-bulk-memory-opt") {
+

[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)

2024-10-12 Thread Owen Pan via cfe-commits

https://github.com/owenca commented:

Please update the release notes.

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


[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)

2024-10-12 Thread Owen Pan via cfe-commits


@@ -972,6 +972,11 @@ struct FormatStyle {
   /// \version 3.7
   bool AllowShortLoopsOnASingleLine;
 
+  /// If ``true``, ``namespace a { class b; }`` can be put on a single a single
+  /// line.

owenca wrote:

You need to rerun `dump_format_style.py`.

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


[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)

2024-10-12 Thread Owen Pan via cfe-commits


@@ -616,6 +627,62 @@ class LineJoiner {
 return 1;
   }
 
+  unsigned tryMergeNamespace(SmallVectorImpl::const_iterator 
I,
+ SmallVectorImpl::const_iterator 
E,
+ unsigned Limit) {
+if (Limit == 0)
+  return 0;
+if (I[1]->InPPDirective != (*I)->InPPDirective ||
+(I[1]->InPPDirective && I[1]->First->HasUnescapedNewline)) {
+  return 0;
+}
+if (I + 2 == E || I[2]->Type == LT_Invalid)
+  return 0;
+
+Limit = limitConsideringMacros(I + 1, E, Limit);
+
+if (!nextTwoLinesFitInto(I, Limit))
+  return 0;
+
+// Check if it's a namespace inside a namespace, and call recursively if 
so.
+// '3' is the sizes of the whitespace and closing brace for " _inner_ }".
+if (I[1]->First->is(tok::kw_namespace)) {
+  if (I[1]->Last->is(tok::comment))
+return 0;
+
+  const unsigned InnerLimit = Limit - I[1]->Last->TotalLength - 3;
+  const unsigned MergedLines = tryMergeNamespace(I + 1, E, InnerLimit);
+  if (!MergedLines)
+return 0;
+  const auto N = MergedLines + 2;
+  // Check if there is even a line after the inner result.
+  if (std::distance(I, E) <= N)
+return 0;
+  // Check that the line after the inner result starts with a closing brace
+  // which we are permitted to merge into one line.
+  if (I[N]->First->is(tok::r_brace) && !I[N]->First->MustBreakBefore &&
+  !I[MergedLines + 1]->Last->is(tok::comment) &&

owenca wrote:

Seems you missed this one:
```suggestion
  I[MergedLines + 1]->Last->isNot(tok::comment) &&
```

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


[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)

2024-10-12 Thread Owen Pan via cfe-commits


@@ -27981,6 +27981,132 @@ TEST_F(FormatTest, BreakBinaryOperations) {
Style);
 }
 
+TEST_F(FormatTest, ShortNamespacesOption) {
+  auto BaseStyle = getLLVMStyle();
+  BaseStyle.AllowShortNamespacesOnASingleLine = true;
+  BaseStyle.FixNamespaceComments = false;
+
+  auto Style = BaseStyle;
+
+  // Basic functionality.
+  verifyFormat("namespace foo { class bar; }", Style);
+  verifyFormat("namespace foo::bar { class baz; }", Style);
+  verifyFormat("namespace { class bar; }", Style);
+  verifyFormat("namespace foo {\n"
+   "class bar;\n"
+   "class baz;\n"
+   "}",
+   Style);
+
+  // Trailing comments prevent merging.
+  verifyFormat("namespace foo {\n"
+   "namespace baz { class qux; } // comment\n"
+   "}",
+   Style);
+
+  // Make sure code doesn't walk too far on unbalanced code.
+  verifyFormat("namespace foo {", Style);
+  verifyFormat("namespace foo {\n"
+   "class baz;",
+   Style);
+  verifyFormat("namespace foo {\n"
+   "namespace bar { class baz; }",
+   Style);
+
+  // Nested namespaces.
+  verifyFormat("namespace foo { namespace bar { class baz; } }", Style);
+  verifyFormat("namespace foo {\n"
+   "namespace bar { class baz; }\n"
+   "namespace qux { class quux; }\n"
+   "}",
+   Style);
+
+  // Varying inner content.
+  verifyFormat("namespace foo {\n"
+   "int f() { return 5; }\n"
+   "}",
+   Style);
+  verifyFormat("namespace foo { template  struct bar; }", Style);
+  verifyFormat("namespace foo { constexpr int num = 42; }", Style);
+
+  // Validate wrapping scenarios around the ColumnLimit.
+  Style.ColumnLimit = 64;
+
+  // Validate just under the ColumnLimit.
+  verifyFormat(
+  "namespace foo { namespace bar { namespace baz { class qux; } } }",
+  Style);
+
+  // Validate just over the ColumnLimit.
+  verifyFormat("namespace foo {\n"
+   "namespace bar { namespace baz { class quux; } }\n"
+   "}",
+   Style);
+
+  verifyFormat("namespace foo {\n"
+   "namespace bar {\n"
+   "namespace baz { namespace qux { class quux; } }\n"
+   "}\n"
+   "}",
+   Style);
+
+  // Validate that the ColumnLimit logic accounts for trailing content as well.
+  verifyFormat("namespace foo {\n"
+   "namespace bar { namespace baz { class qux; } }\n"
+   "} // extra",
+   Style);
+
+  // No ColumnLimit, allows long nested one-liners, but also leaves multi-line
+  // instances alone.
+  Style.ColumnLimit = 0;
+  verifyFormat(
+  "namespace foo { namespace bar { namespace baz { class qux; } } }",
+  Style);
+
+  verifyNoChange("namespace foo {\n"
+ "namespace bar { namespace baz { class qux; } }\n"
+ "}",
+ Style);

owenca wrote:

I'm inclined to think that all the `AllowShort` options should work the same 
way whether `ColumnLimit` is 0. However, a couple of them I checked 
(`AllowShortLoops` and `AllowShortBlocks`) have no effect unless set to 
`false`. I suggest that we mark the test as a FIXME or don't include it here.

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


[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)

2024-10-12 Thread Owen Pan via cfe-commits

owenca wrote:

> > The following are missing:
> > 
> > * Run `dump_format_style.py`.
> > * Add a `ConfigParseTest` for the new option.
> > 
> > How does the new option interact with `CompactNamespaces`? For example:
> > 
> > * `AllowShortNamespacesOnASingleLine: true` and `CompactNamespaces: false`
> > 
> > ```
> > namespace a {
> > namespace b { class c; }
> > } // namespace a
> > ```
> > 
> > * Both `true`
> >   `namespace a { namespace b { class c; } }`
> 
> Aah, I hadn't considered the interaction of this 
> AllowShortNamespacesOnASingleLine and CompactNamespaces, as 
> AllowShortNamespacesOnASingleLine effectively forces CompactNamespaces 
> behavior when the block can all fit on a single line. However, it does appear 
> that they were in conflict where the CompactNamespaces code was running first 
> and then short circuiting out of the AllowShortNamespacesOnASingleLine logic.
> 
> Moved the logic around a bit, as AllowShortNamespacesOnASingleLine is mostly 
> a superset of the CompactNamespaces logic. There are still some ambiguous 
> situations around nested namespaces with a single statement inside that could 
> be merged with both these two rules. I am just letting those get merged with 
> CompactNamespaces first if the full expression can't be pulled onto a single 
> line.

IMO `AllowShortNamespacesOnASingleLine` shouldn't imply `CompactNamespaces` so 
that we can get any of the formats below:

- `AllowShortNamespacesOnASingleLine: false`, `CompactNamespaces: false`
```
namespace a {
namespace b {
class c;
}
}
```

- `AllowShortNamespacesOnASingleLine: false`, `CompactNamespaces: true`
```
namespace a { namespace b {
class c;
}}
```

- `AllowShortNamespacesOnASingleLine: true`, `CompactNamespaces: false`
```
namespace a {
namespace b { class c; }
}
```

- `AllowShortNamespacesOnASingleLine: true`, `CompactNamespaces: true`
```
namespace a { namespace b { class c; } }
```

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


[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)

2024-10-12 Thread Owen Pan via cfe-commits


@@ -616,6 +626,62 @@ class LineJoiner {
 return 1;
   }
 
+  unsigned tryMergeNamespace(SmallVectorImpl::const_iterator 
I,
+ SmallVectorImpl::const_iterator 
E,
+ unsigned Limit) {
+if (Limit == 0)
+  return 0;
+if (I[1]->InPPDirective != (*I)->InPPDirective ||
+(I[1]->InPPDirective && I[1]->First->HasUnescapedNewline)) {
+  return 0;
+}
+if (I + 2 == E || I[2]->Type == LT_Invalid)
+  return 0;
+
+Limit = limitConsideringMacros(I + 1, E, Limit);
+
+if (!nextTwoLinesFitInto(I, Limit))
+  return 0;
+
+// Check if it's a namespace inside a namespace, and call recursively if so
+// '3' is the sizes of the whitespace and closing brace for " _inner_ }".
+if (I[1]->First->is(tok::kw_namespace)) {
+  if (I[1]->Last->is(TT_LineComment))
+return 0;
+
+  const unsigned InnerLimit = Limit - I[1]->Last->TotalLength - 3;
+  const unsigned MergedLines = tryMergeNamespace(I + 1, E, InnerLimit);
+  if (!MergedLines)

owenca wrote:

I would assert it though.
```suggestion
  assert(Limit >= I[1]->Last->TotalLength + 3);
  const unsigned InnerLimit = Limit - I[1]->Last->TotalLength - 3;
  const unsigned MergedLines = tryMergeNamespace(I + 1, E, InnerLimit);
  if (MergedLines == 0)
```

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


[clang] clang-format: Add "AllowShortNamespacesOnASingleLine" option (PR #105597)

2024-10-12 Thread Owen Pan via cfe-commits

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


[clang] [Sema] Avoid repeated hash lookups (NFC) (PR #112071)

2024-10-12 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang-tools-extra] [clang-tidy] Avoid repeated hash lookups (NFC) (PR #112074)

2024-10-12 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] [llvm] [MIPS] LLVM data layout give i128 an alignment of 16 for mips64 (PR #112084)

2024-10-12 Thread via cfe-commits

https://github.com/yingopq created 
https://github.com/llvm/llvm-project/pull/112084

Fix parts of #102783.

>From 03b1e39f7dd416db9e2eb19303a676a9ddcac5c2 Mon Sep 17 00:00:00 2001
From: Ying Huang 
Date: Sat, 12 Oct 2024 03:12:44 -0400
Subject: [PATCH] [MIPS] LLVM data layout give i128 an alignment of 16 for
 mips64

Fix parts of #102783.
---
 clang/lib/Basic/Targets/Mips.h|  4 +-
 clang/test/CodeGen/target-data.c  |  8 +--
 llvm/lib/IR/AutoUpgrade.cpp   |  2 +-
 llvm/lib/Target/Mips/MipsTargetMachine.cpp|  2 +-
 llvm/test/CodeGen/Mips/data-layout.ll | 60 +++
 llvm/test/CodeGen/Mips/implicit-sret.ll   | 18 +++---
 .../Bitcode/DataLayoutUpgradeTest.cpp |  8 +++
 7 files changed, 85 insertions(+), 17 deletions(-)
 create mode 100644 llvm/test/CodeGen/Mips/data-layout.ll

diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 45425db3ac27ad..8acaf56523b218 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -28,9 +28,9 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 if (ABI == "o32")
   Layout = "m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
 else if (ABI == "n32")
-  Layout = "m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
+  Layout = "m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
 else if (ABI == "n64")
-  Layout = "m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128";
+  Layout = "m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
 else
   llvm_unreachable("Invalid ABI");
 
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index 8548aa00cfe877..054825011dd36c 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -54,7 +54,7 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // RUN: %clang_cc1 -triple mipsisa64r6el-linux-gnuabi64 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
-// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EL: target datalayout = 
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
@@ -64,7 +64,7 @@
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // RUN: %clang_cc1 -triple mipsisa64r6el-linux-gnuabin32 -o - -emit-llvm \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
-// MIPS-64EL-N32: target datalayout = 
"e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EL-N32: target datalayout = 
"e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
@@ -74,7 +74,7 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // RUN: %clang_cc1 -triple mipsisa64r6-linux-gnuabi64 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
-// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EB: target datalayout = 
"E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 
\
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
@@ -84,7 +84,7 @@
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // RUN: %clang_cc1 -triple mipsisa64r6-linux-gnuabin32 -o - -emit-llvm %s \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
-// MIPS-64EB-N32: target datalayout = 
"E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EB-N32: target datalayout = 
"E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PS3
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 3753509f9aa718..95e011b5aa1b9a 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5566,7 +5566,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
 return Res;
   }
 
-  if (T.isSPARC()) {
+  if (T.isSPARC() || T.isMIPS64()) {
 // Add "-i128:128"
 std::string I64 = "-i64:64";
 std::string I128 = "-i128:128";
diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp 
b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
index 7802767e31c2f6..0554d275d1e0b3 100644
--- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
@@ -99,7 +99,7 @@ static std::string computeDataLayout(const Triple &TT, 
StringRef CPU,
   // aligned. On N64 64 bit registers are also available and the stack is
   // 128 bit aligned.
   if (ABI.IsN64() || ABI.IsN32())
-Ret += "-n32:64-S128";
+Ret += "-i128:128-n32:64-S128";
   else
 Ret += "-n32-S64";
 
diff --git a/llvm/test/CodeGen/Mips/data-layout.ll 
b/llvm/test/CodeGen/Mips/data-layout.ll
new file mode 100644
index 00..0b2fc213bb0b60

[clang] [llvm] [MIPS] LLVM data layout give i128 an alignment of 16 for mips64 (PR #112084)

2024-10-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (yingopq)


Changes

Fix parts of #102783.

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


7 Files Affected:

- (modified) clang/lib/Basic/Targets/Mips.h (+2-2) 
- (modified) clang/test/CodeGen/target-data.c (+4-4) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+1-1) 
- (modified) llvm/lib/Target/Mips/MipsTargetMachine.cpp (+1-1) 
- (added) llvm/test/CodeGen/Mips/data-layout.ll (+60) 
- (modified) llvm/test/CodeGen/Mips/implicit-sret.ll (+9-9) 
- (modified) llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp (+8) 


``diff
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 45425db3ac27ad..8acaf56523b218 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -28,9 +28,9 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 if (ABI == "o32")
   Layout = "m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
 else if (ABI == "n32")
-  Layout = "m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
+  Layout = "m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
 else if (ABI == "n64")
-  Layout = "m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128";
+  Layout = "m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
 else
   llvm_unreachable("Invalid ABI");
 
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index 8548aa00cfe877..054825011dd36c 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -54,7 +54,7 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // RUN: %clang_cc1 -triple mipsisa64r6el-linux-gnuabi64 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
-// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EL: target datalayout = 
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
@@ -64,7 +64,7 @@
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // RUN: %clang_cc1 -triple mipsisa64r6el-linux-gnuabin32 -o - -emit-llvm \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
-// MIPS-64EL-N32: target datalayout = 
"e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EL-N32: target datalayout = 
"e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
@@ -74,7 +74,7 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // RUN: %clang_cc1 -triple mipsisa64r6-linux-gnuabi64 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
-// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EB: target datalayout = 
"E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 
\
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
@@ -84,7 +84,7 @@
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // RUN: %clang_cc1 -triple mipsisa64r6-linux-gnuabin32 -o - -emit-llvm %s \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
-// MIPS-64EB-N32: target datalayout = 
"E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EB-N32: target datalayout = 
"E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PS3
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 3753509f9aa718..95e011b5aa1b9a 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5566,7 +5566,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
 return Res;
   }
 
-  if (T.isSPARC()) {
+  if (T.isSPARC() || T.isMIPS64()) {
 // Add "-i128:128"
 std::string I64 = "-i64:64";
 std::string I128 = "-i128:128";
diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp 
b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
index 7802767e31c2f6..0554d275d1e0b3 100644
--- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
@@ -99,7 +99,7 @@ static std::string computeDataLayout(const Triple &TT, 
StringRef CPU,
   // aligned. On N64 64 bit registers are also available and the stack is
   // 128 bit aligned.
   if (ABI.IsN64() || ABI.IsN32())
-Ret += "-n32:64-S128";
+Ret += "-i128:128-n32:64-S128";
   else
 Ret += "-n32-S64";
 
diff --git a/llvm/test/CodeGen/Mips/data-layout.ll 
b/llvm/test/CodeGen/Mips/data-layout.ll
new file mode 100644
index 00..0b2fc213bb0b60
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/data-layout.ll
@@ -0,0 +1,60 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
+; RUN: llc -mtriple=mips64-linux-gnuabi64 -mcpu=mips64 < %s | FileCheck 

[clang] [llvm] [LoongArch] Add options for annotate tablejump (PR #102411)

2024-10-12 Thread Lu Weining via cfe-commits


@@ -5340,6 +5340,10 @@ def mno_lasx : Flag<["-"], "mno-lasx">, 
Group,
 def msimd_EQ : Joined<["-"], "msimd=">, Group,
   Flags<[TargetSpecific]>,
   HelpText<"Select the SIMD extension(s) to be enabled in LoongArch either 
'none', 'lsx', 'lasx'.">;
+def mannotate_tablejump : Flag<["-"], "mannotate-tablejump">, 
Group,
+  HelpText<"Enable annotate table jump instruction to correlate it with the 
jump table.">;

SixWeining wrote:

Is it necessary to add the TargetSpecific flag?

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


[clang] [llvm] [LoongArch] Add options for annotate tablejump (PR #102411)

2024-10-12 Thread Lu Weining via cfe-commits

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


[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-a-1` while building `clang` at step 4 
"annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[1329/1331] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests
[1330/1331] Running the Clang regression tests
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using clang: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/clang
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126:
 note: Did not find clang-repl in 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/ld.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/lld-link
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/ld64.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/wasm-ld
-- Testing: 21326 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 
FAIL: Clang :: Driver/hip-link-save-temps.hip (10896 of 21326)
 TEST 'Clang :: Driver/hip-link-save-temps.hip' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: rm -rf 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp
 && mkdir 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp
+ rm -rf 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp
+ mkdir 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp
RUN: at line 3: touch 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp/obj1.o
+ touch 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp/obj1.o
RUN: at line 4: touch 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp/obj2.o
+ touch 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp/obj2.o
RUN: at line 5: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/clang -### 
--target=x86_64-linux-gnu -nogpulib -save-temps--hip-link -o executable 
-fgpu-rdc --cuda-gpu-arch=gfx900--no-offload-new-driver 
--offload-arch=gfx906  
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp/obj1.o
 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp/obj2.o
 2>&1 |
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/FileCheck 
-check-prefixes=CHECK,OUT 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/hip-link-save-temps.hip
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/clang 
-### --target=x86_64-linux-gnu -nogpulib -save-temps --hip-link -o executable 
-fgpu-rdc --cuda-gpu-arch=gfx900 --no-offload-new-driver --offload-arch=gfx906 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp/obj1.o
 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/tools/clang/test/Driver/Output/hip-link-save-temps.hip.tmp/obj2.o
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-cklwaupw/bin/FileCheck 
-check-prefixes=CHECK,OUT 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/hip-link-save-temps.hip
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/hip-link-save-temps.hip:45:11:
 error: CHECK: expected string not found in input
// CHECK: "{{.*clang.*}}" "-target" "x86_64-unknown-linux-gnu" "-o" 
"[[OBJBUNDLE:.+.o]]" "-x" "assembler" "{{.*}}.mcin" "-

[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`ppc64le-lld-multistage-test` running on `ppc64le-lld-multistage-test` while 
building `clang` at step 12 "build-stage2-unified-tree".

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


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

```
Step 12 (build-stage2-unified-tree) failure: build (failure)
...
266.232 [1928/1154/3209] Linking CXX static library lib/libLLVMAVRInfo.a
266.265 [1927/1154/3210] Building CXX object 
lib/ToolDrivers/llvm-lib/CMakeFiles/LLVMLibDriver.dir/LibDriver.cpp.o
266.303 [1926/1154/3211] Building CXX object 
tools/clang/lib/IndexSerialization/CMakeFiles/obj.clangIndexSerialization.dir/SerializablePathCollection.cpp.o
266.323 [1925/1154/3212] Building CXX object 
lib/Target/Lanai/MCTargetDesc/CMakeFiles/LLVMLanaiDesc.dir/LanaiELFObjectWriter.cpp.o
266.352 [1924/1154/3213] Linking CXX static library lib/libLLVMBPFInfo.a
266.394 [1923/1154/3214] Building X86GenDisassemblerTables.inc...
266.431 [1922/1154/3215] Building CXX object 
lib/ExecutionEngine/Orc/CMakeFiles/LLVMOrcJIT.dir/MachO.cpp.o
266.442 [1921/1154/3216] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/XCore.cpp.o
266.482 [1920/1154/3217] Linking CXX static library lib/libLLVMLibDriver.a
266.615 [1919/1154/3218] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
FAILED: 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 
ccache 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/install/stage1/bin/clang++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/lib/Driver
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Driver
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -MF 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o.d
 -o 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
 -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Driver/ToolChains/HIPUtility.cpp:343:20:
 error: unused variable 'TC' [-Werror,-Wunused-variable]
  343 |   const ToolChain &TC = T.getToolChain();
  |^~
1 error generated.
266.634 [1919/1153/3219] Building RISCVGenSearchableTables.inc...
266.695 [1919/1152/3220] Building CXX object 
tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/PPCallbacks.cpp.o
266.735 [1919/1151/3221] Building CXX object 
lib/Target/Mips/MCTargetDesc/CMakeFiles/LLVMMipsDesc.dir/MipsMCAsmInfo.cpp.o
266.785 [1919/1150/3222] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/Types.cpp.o
266.805 [1919/1149/3223] Building CXX object 
lib/Target/Mips/TargetInfo/CMakeFiles/LLVMMipsInfo.dir/MipsTargetInfo.cpp.o
266.835 [1919/1148/3224] Building CXX object 
tools/clang/lib/Analysis/FlowSensitive/CMakeFiles/obj.clangAnalysisFlowSensitive.dir/WatchedLiteralsSolver.cpp.o
266.925 [1919/1147/3225] Building CXX object 
lib/Target/Lanai/MCTargetDesc/CMakeFiles/LLVMLanaiDesc.dir/LanaiMCCodeEmitter.cpp.o
266.945 [1919/1146/3226] Building CXX object 
lib/Target/MSP430/MCTargetDesc/CMakeFi

[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-12 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

@petrhosek Can someone explain why the clang executable in these tests is 
called `llvm` on the Fuchsia bots?

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


[clang] [llvm] [mlir] [polly] [NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (PR #111752)

2024-10-12 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> TBH I am wondering if we should revert this rename. I don't think it's a good 
> idea to reuse getDeclaration with substantially different semantics, and if 
> we're not reusing it, then there's not much point to rename...
> 
> Instead of having getOrInsertDeclaration + getDeclaration with a meaning 
> inversion, we can have getDeclaration and getDeclarationIfExists without the 
> inversion.

I'd like to revert this change, or just add `Intrinsic::getDeclaration` back 
and mark it as deprecated. I have encountered a build error on Alive2.


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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits

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

Very nice improvement, LGTM, thanks!!!

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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits

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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits


@@ -9,8 +9,10 @@
 #include "UseStartsEndsWithCheck.h"
 
 #include "../utils/ASTUtils.h"
-#include "../utils/OptionsUtils.h"
+#include "../utils/Matchers.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/ArrayRef.h"

nicovank wrote:

```suggestion
```
Supernit.

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


[clang-tools-extra] [clang-tidy] insert ``static`` keyword in correct position for misc-use-internal-linkage (PR #108792)

2024-10-12 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/108792

>From 795b3ae677210ff50f7710a0cf73d435889b68ae Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Mon, 16 Sep 2024 13:47:10 +0800
Subject: [PATCH 1/2] [clang-tidy] insert ``static`` keyword in correct
 position for misc-use-internal-linkage

Fixes: #108760
---
 .../misc/UseInternalLinkageCheck.cpp  | 34 +--
 .../clang-tidy/utils/LexerUtils.cpp   |  4 ++-
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 +++
 .../misc/use-internal-linkage-func.cpp| 21 
 .../misc/use-internal-linkage-var.cpp | 12 +++
 5 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
index c086e7721e02bd..a92448c15ef3a9 100644
--- a/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
@@ -8,12 +8,15 @@
 
 #include "UseInternalLinkageCheck.h"
 #include "../utils/FileExtensionsUtils.h"
+#include "../utils/LexerUtils.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/ASTMatchers/ASTMatchersMacros.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Token.h"
 #include "llvm/ADT/STLExtras.h"
 
 using namespace clang::ast_matchers;
@@ -110,10 +113,36 @@ static constexpr StringRef Message =
 "%0 %1 can be made static or moved into an anonymous namespace "
 "to enforce internal linkage";
 
+static SourceLocation getQualifiedTypeStartLoc(SourceLocation L,
+   const SourceManager &SM,
+   const ASTContext &Context) {
+  const SourceLocation StartOfFile = SM.getLocForStartOfFile(SM.getFileID(L));
+  if (L.isInvalid() || L.isMacroID())
+return L;
+  bool HasChanged = true;
+  while (HasChanged) {
+if (L == StartOfFile)
+  return L;
+auto [Tok, Loc] =
+utils::lexer::getPreviousTokenAndStart(L, SM, Context.getLangOpts());
+if (Tok.is(tok::raw_identifier)) {
+  IdentifierInfo &Info = Context.Idents.get(
+  StringRef(SM.getCharacterData(Tok.getLocation()), Tok.getLength()));
+  Tok.setIdentifierInfo(&Info);
+  Tok.setKind(Info.getTokenID());
+}
+HasChanged = Tok.isOneOf(tok::kw_const, tok::kw_volatile);
+if (HasChanged)
+  L = Loc;
+  }
+  return L;
+}
+
 void UseInternalLinkageCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *FD = Result.Nodes.getNodeAs("fn")) {
 DiagnosticBuilder DB = diag(FD->getLocation(), Message) << "function" << 
FD;
-SourceLocation FixLoc = FD->getTypeSpecStartLoc();
+const SourceLocation FixLoc = getQualifiedTypeStartLoc(
+FD->getTypeSpecStartLoc(), *Result.SourceManager, *Result.Context);
 if (FixLoc.isInvalid() || FixLoc.isMacroID())
   return;
 if (FixMode == FixModeKind::UseStatic)
@@ -128,7 +157,8 @@ void UseInternalLinkageCheck::check(const 
MatchFinder::MatchResult &Result) {
   return;
 
 DiagnosticBuilder DB = diag(VD->getLocation(), Message) << "variable" << 
VD;
-SourceLocation FixLoc = VD->getTypeSpecStartLoc();
+const SourceLocation FixLoc = getQualifiedTypeStartLoc(
+VD->getTypeSpecStartLoc(), *Result.SourceManager, *Result.Context);
 if (FixLoc.isInvalid() || FixLoc.isMacroID())
   return;
 if (FixMode == FixModeKind::UseStatic)
diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
index df2b0bef576ca3..92c3e0ed7894e1 100644
--- a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
@@ -24,13 +24,15 @@ getPreviousTokenAndStart(SourceLocation Location, const 
SourceManager &SM,
   if (Location.isInvalid())
 return {Token, Location};
 
-  auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
+  const auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
   while (Location != StartOfFile) {
 Location = Lexer::GetBeginningOfToken(Location, SM, LangOpts);
 if (!Lexer::getRawToken(Location, Token, SM, LangOpts) &&
 (!SkipComments || !Token.is(tok::comment))) {
   break;
 }
+if (Location == StartOfFile)
+  return {Token, Location};
 Location = Location.getLocWithOffset(-1);
   }
   return {Token, Location};
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 8d0c093b312dd5..7cbcc23f28efaf 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -128,6 +128,10 @@ Changes in existing checks
   ` check to avoid
   false positive for C++23 deducing this.
 
+- Improved 

[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-10-12 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/96281

>From c08b0a8d34107dc4563c434485ba5f326ab8df93 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Fri, 21 Jun 2024 14:28:42 +0800
Subject: [PATCH 01/11] Clang: Support minimumnum and maximumnum intrinsics

We just introduce llvm.minimumnum and llvm.maximumnum intrinsics
support to llvm. Let's support them in Clang.

See: #93033
---
 clang/include/clang/Basic/Builtins.td | 28 +++
 clang/lib/CodeGen/CGBuiltin.cpp   | 24 
 .../Tooling/Inclusions/Stdlib/CSymbolMap.inc  |  6 
 .../Inclusions/Stdlib/StdSymbolMap.inc| 18 
 clang/test/CodeGen/builtins.c | 18 
 clang/test/CodeGen/math-libcalls.c| 25 +
 6 files changed, 119 insertions(+)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 7068473a0e12ac..a7e2ee30d9d732 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -215,6 +215,18 @@ def FminF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T, T)";
 }
 
+def FmaximumNumF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fmaximum_num"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+  let Prototype = "T(T, T)";
+}
+
+def FminimumNumF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fminimum_num"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+  let Prototype = "T(T, T)";
+}
+
 def Atan2F128 : Builtin {
   let Spellings = ["__builtin_atan2f128"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow, 
ConstIgnoringErrnoAndExceptions];
@@ -3728,6 +3740,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {
+  let Spellings = ["fmaximum_num"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "T(T, T)";
+  let AddBuiltinPrefixedAlias = 1;
+  let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
+}
+
+def FminimumNum : FPMathTemplate, LibBuiltin<"math.h"> {
+  let Spellings = ["fminimum_num"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "T(T, T)";
+  let AddBuiltinPrefixedAlias = 1;
+  let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
+}
+
 def Hypot : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["hypot"];
   let Attributes = [NoThrow, ConstIgnoringErrnoAndExceptions];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ff678ee04f9c2a..955d6dd2dd1d5e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2869,6 +2869,30 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
Intrinsic::minnum,

Intrinsic::experimental_constrained_minnum));
 
+case Builtin::BIfmaximum_num:
+case Builtin::BIfmaximum_numf:
+case Builtin::BIfmaximum_numl:
+case Builtin::BI__builtin_fmaximum_num:
+case Builtin::BI__builtin_fmaximum_numf:
+case Builtin::BI__builtin_fmaximum_numf16:
+case Builtin::BI__builtin_fmaximum_numl:
+case Builtin::BI__builtin_fmaximum_numf128:
+  return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::maximumnum,
+  Intrinsic::experimental_constrained_maximumnum));
+
+case Builtin::BIfminimum_num:
+case Builtin::BIfminimum_numf:
+case Builtin::BIfminimum_numl:
+case Builtin::BI__builtin_fminimum_num:
+case Builtin::BI__builtin_fminimum_numf:
+case Builtin::BI__builtin_fminimum_numf16:
+case Builtin::BI__builtin_fminimum_numl:
+case Builtin::BI__builtin_fminimum_numf128:
+  return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::minimumnum,
+  Intrinsic::experimental_constrained_minimumnum));
+
 // fmod() is a special-case. It maps to the frem instruction rather than an
 // LLVM intrinsic.
 case Builtin::BIfmod:
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
index 463ce921f0672f..af2dcb632fbb64 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
@@ -475,6 +475,12 @@ SYMBOL(fmaxl, None, )
 SYMBOL(fmin, None, )
 SYMBOL(fminf, None, )
 SYMBOL(fminl, None, )
+SYMBOL(fmaximum_num, None, )
+SYMBOL(fmaximum_numf, None, )
+SYMBOL(fmaximum_numfl, None, )
+SYMBOL(fminimum_num, None, )
+SYMBOL(fminimum_numf, None, )
+SYMBOL(fminimum_numl, None, )
 SYMBOL(fmod, None, )
 SYMBOL(fmodf, None, )
 SYMBOL(fmodl, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index b46bd2e4d7a4b5..442316ce8d4ff6 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/S

[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti created 
https://github.com/llvm/llvm-project/pull/112101

Rewrite the AST matchers for slightly more composability and
performance. Furthermore, check that the `starts_with` and `ends_with`
functions return a `bool`.
There is one behavioral change, in that the methods of a class (and
transitive classes) are searched once for a matching
`starts_with`/`ends_with` function, picking the first it can find.
Previously, the matchers would try to find `starts_with`, then
`startsWith`, and finally, `startswith`. Now, the first of the three that
is encountered will be the matched method.


>From cd6de859501e8c0102aa1c1e57341ecc35266ed1 Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Sat, 12 Oct 2024 18:07:38 +0200
Subject: [PATCH] [clang-tidy] rewrite matchers in
 modernize-use-starts-ends-with

Rewrite the AST matchers for slightly more composability and
performance. Furthermore, check that the `starts_with` and `ends_with`
functions return a `bool`.
There is one behavioral change, in that the methods of a class (and
transitive classes) are searched once for a matching
`starts_with`/`ends_with` function, picking the first it can find.
Previously, the matchers would try to find `starts_with`, then
`startsWith`, and finally, `startswith`. Now, the first of the three that
is encountered will be the matched method.
---
 .../modernize/UseStartsEndsWithCheck.cpp  | 59 ---
 .../modernize/use-starts-ends-with.cpp|  4 +-
 2 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index 5eb3267adb0799..a1376aa8fa5e6e 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -9,8 +9,10 @@
 #include "UseStartsEndsWithCheck.h"
 
 #include "../utils/ASTUtils.h"
-#include "../utils/OptionsUtils.h"
+#include "../utils/Matchers.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/ArrayRef.h"
 
 #include 
 
@@ -82,34 +84,25 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef 
Name,
 void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
   const auto ZeroLiteral = integerLiteral(equals(0));
 
-  const auto HasStartsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("starts_with_fun"));
-  };
-  const auto HasStartsWithMethod =
-  anyOf(HasStartsWithMethodWithName("starts_with"),
-HasStartsWithMethodWithName("startsWith"),
-HasStartsWithMethodWithName("startswith"));
-  const auto OnClassWithStartsWithFunction =
-  on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasStartsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(
-
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)));
-
-  const auto HasEndsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("ends_with_fun"));
-  };
-  const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
-   HasEndsWithMethodWithName("endsWith"),
-   HasEndsWithMethodWithName("endswith"));
+  const auto ClassTypeWithMethod =
+  [](const StringRef MethodBoundName,
+ const llvm::ArrayRef &Methods) {
+const auto Method =
+cxxMethodDecl(isConst(), parameterCountIs(1),
+  returns(booleanType()), hasAnyName(Methods))
+.bind(MethodBoundName);
+return qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+anyOf(hasMethod(Method),
+  hasAnyBase(hasType(hasCanonicalType(
+  hasDeclaration(cxxRecordDecl(hasMethod(Method)));
+  };
+
+  const auto OnClassWithStartsWithFunction = on(hasType(ClassTypeWithMethod(
+  "starts_with_fun", {"starts_with", "startsWith", "startswith"})));
+
   const auto OnClassWithEndsWithFunction =
-  on(expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasEndsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(hasDeclaration(
-cxxRecordDecl(HasEndsWithMethod)))
+  on(expr(hasType(ClassTypeWithMethod(
+  "ends_with_fun", {"ends_with", "endsWith", "endswith"})))
  .bind("haystack"));
 
   // Case 1: X.find(Y) [!=]= 0 -> starts_with.
@@ -145,7 +138,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   // All cases comparing to 0.
   Finder->addMatcher(
   binaryOperator(
-  hasAnyOperatorName("==", "!="),
+  matcher

[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Julian Schmidt (5chmidti)


Changes

Rewrite the AST matchers for slightly more composability and
performance. Furthermore, check that the `starts_with` and `ends_with`
functions return a `bool`.
There is one behavioral change, in that the methods of a class (and
transitive classes) are searched once for a matching
`starts_with`/`ends_with` function, picking the first it can find.
Previously, the matchers would try to find `starts_with`, then
`startsWith`, and finally, `startswith`. Now, the first of the three that
is encountered will be the matched method.


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


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
(+25-34) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-starts-ends-with.cpp 
(+2-2) 


``diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index 5eb3267adb0799..a1376aa8fa5e6e 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -9,8 +9,10 @@
 #include "UseStartsEndsWithCheck.h"
 
 #include "../utils/ASTUtils.h"
-#include "../utils/OptionsUtils.h"
+#include "../utils/Matchers.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/ArrayRef.h"
 
 #include 
 
@@ -82,34 +84,25 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef 
Name,
 void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
   const auto ZeroLiteral = integerLiteral(equals(0));
 
-  const auto HasStartsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("starts_with_fun"));
-  };
-  const auto HasStartsWithMethod =
-  anyOf(HasStartsWithMethodWithName("starts_with"),
-HasStartsWithMethodWithName("startsWith"),
-HasStartsWithMethodWithName("startswith"));
-  const auto OnClassWithStartsWithFunction =
-  on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasStartsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(
-
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)));
-
-  const auto HasEndsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("ends_with_fun"));
-  };
-  const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
-   HasEndsWithMethodWithName("endsWith"),
-   HasEndsWithMethodWithName("endswith"));
+  const auto ClassTypeWithMethod =
+  [](const StringRef MethodBoundName,
+ const llvm::ArrayRef &Methods) {
+const auto Method =
+cxxMethodDecl(isConst(), parameterCountIs(1),
+  returns(booleanType()), hasAnyName(Methods))
+.bind(MethodBoundName);
+return qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+anyOf(hasMethod(Method),
+  hasAnyBase(hasType(hasCanonicalType(
+  hasDeclaration(cxxRecordDecl(hasMethod(Method)));
+  };
+
+  const auto OnClassWithStartsWithFunction = on(hasType(ClassTypeWithMethod(
+  "starts_with_fun", {"starts_with", "startsWith", "startswith"})));
+
   const auto OnClassWithEndsWithFunction =
-  on(expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasEndsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(hasDeclaration(
-cxxRecordDecl(HasEndsWithMethod)))
+  on(expr(hasType(ClassTypeWithMethod(
+  "ends_with_fun", {"ends_with", "endsWith", "endswith"})))
  .bind("haystack"));
 
   // Case 1: X.find(Y) [!=]= 0 -> starts_with.
@@ -145,7 +138,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   // All cases comparing to 0.
   Finder->addMatcher(
   binaryOperator(
-  hasAnyOperatorName("==", "!="),
+  matchers::isEqualityOperator(),
   hasOperands(cxxMemberCallExpr(anyOf(FindExpr, RFindExpr, CompareExpr,
   CompareEndsWithExpr))
   .bind("find_expr"),
@@ -156,7 +149,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   // Case 5: X.rfind(Y) [!=]= LEN(X) - LEN(Y) -> ends_with.
   Finder->addMatcher(
   binaryOperator(
-  hasAnyOperatorName("==", "!="),
+  matchers::isEqualityOperator(),
   hasOperands(
   cxxMemberCallExpr(
   anyOf(
@@ -190,9 +183,8 @@ void UseS

[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread via cfe-commits

llvmbot wrote:




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

Author: Julian Schmidt (5chmidti)


Changes

Rewrite the AST matchers for slightly more composability and
performance. Furthermore, check that the `starts_with` and `ends_with`
functions return a `bool`.
There is one behavioral change, in that the methods of a class (and
transitive classes) are searched once for a matching
`starts_with`/`ends_with` function, picking the first it can find.
Previously, the matchers would try to find `starts_with`, then
`startsWith`, and finally, `startswith`. Now, the first of the three that
is encountered will be the matched method.


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


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
(+25-34) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-starts-ends-with.cpp 
(+2-2) 


``diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index 5eb3267adb0799..a1376aa8fa5e6e 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -9,8 +9,10 @@
 #include "UseStartsEndsWithCheck.h"
 
 #include "../utils/ASTUtils.h"
-#include "../utils/OptionsUtils.h"
+#include "../utils/Matchers.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/ArrayRef.h"
 
 #include 
 
@@ -82,34 +84,25 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef 
Name,
 void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
   const auto ZeroLiteral = integerLiteral(equals(0));
 
-  const auto HasStartsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("starts_with_fun"));
-  };
-  const auto HasStartsWithMethod =
-  anyOf(HasStartsWithMethodWithName("starts_with"),
-HasStartsWithMethodWithName("startsWith"),
-HasStartsWithMethodWithName("startswith"));
-  const auto OnClassWithStartsWithFunction =
-  on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasStartsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(
-
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)));
-
-  const auto HasEndsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("ends_with_fun"));
-  };
-  const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
-   HasEndsWithMethodWithName("endsWith"),
-   HasEndsWithMethodWithName("endswith"));
+  const auto ClassTypeWithMethod =
+  [](const StringRef MethodBoundName,
+ const llvm::ArrayRef &Methods) {
+const auto Method =
+cxxMethodDecl(isConst(), parameterCountIs(1),
+  returns(booleanType()), hasAnyName(Methods))
+.bind(MethodBoundName);
+return qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+anyOf(hasMethod(Method),
+  hasAnyBase(hasType(hasCanonicalType(
+  hasDeclaration(cxxRecordDecl(hasMethod(Method)));
+  };
+
+  const auto OnClassWithStartsWithFunction = on(hasType(ClassTypeWithMethod(
+  "starts_with_fun", {"starts_with", "startsWith", "startswith"})));
+
   const auto OnClassWithEndsWithFunction =
-  on(expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasEndsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(hasDeclaration(
-cxxRecordDecl(HasEndsWithMethod)))
+  on(expr(hasType(ClassTypeWithMethod(
+  "ends_with_fun", {"ends_with", "endsWith", "endswith"})))
  .bind("haystack"));
 
   // Case 1: X.find(Y) [!=]= 0 -> starts_with.
@@ -145,7 +138,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   // All cases comparing to 0.
   Finder->addMatcher(
   binaryOperator(
-  hasAnyOperatorName("==", "!="),
+  matchers::isEqualityOperator(),
   hasOperands(cxxMemberCallExpr(anyOf(FindExpr, RFindExpr, CompareExpr,
   CompareEndsWithExpr))
   .bind("find_expr"),
@@ -156,7 +149,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   // Case 5: X.rfind(Y) [!=]= LEN(X) - LEN(Y) -> ends_with.
   Finder->addMatcher(
   binaryOperator(
-  hasAnyOperatorName("==", "!="),
+  matchers::isEqualityOperator(),
   hasOperands(
   cxxMemberCallExpr(
   anyOf(
@@ -190,9 +183,8 @@ vo

[clang] [lld] [llvm] [WebAssembly] Define a new "Trail1" CPU (PR #112035)

2024-10-12 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 14705a912f6296700cef4d2aa7eb100f71dfbd0a 
24e58550483c0569e48f9b1e11edaee5acb1ac1e --extensions cpp,h -- 
clang/lib/Basic/Targets/WebAssembly.cpp clang/lib/Basic/Targets/WebAssembly.h 
lld/wasm/InputFiles.cpp lld/wasm/SyntheticSections.cpp 
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp 
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp 
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp 
llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp 
llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h 
llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h 
b/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h
index 8e623d694d..f6cc975960 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h
+++ b/llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h
@@ -105,7 +105,9 @@ public:
   bool hasMutableGlobals() const { return HasMutableGlobals; }
   bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
   bool hasReferenceTypes() const { return HasReferenceTypes; }
-  bool hasCallIndirectOverlong() const { return HasCallIndirectOverlong || 
HasReferenceTypes; }
+  bool hasCallIndirectOverlong() const {
+return HasCallIndirectOverlong || HasReferenceTypes;
+  }
   bool hasRelaxedSIMD() const { return SIMDLevel >= RelaxedSIMD; }
   bool hasSignExt() const { return HasSignExt; }
   bool hasSIMD128() const { return SIMDLevel >= SIMD128; }

``




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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

Note that his is not an NFC due to the change in what method may be found 
first, but given that it's quite out there to have 2+ of `{'starts_with',  
'startsWith', 'startswith'}` in one class hierarchy, which is how the non-NFC 
part could be observed. Because of this I think this does not need a release 
note, thoughts?

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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti updated 
https://github.com/llvm/llvm-project/pull/112101

>From cd6de859501e8c0102aa1c1e57341ecc35266ed1 Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Sat, 12 Oct 2024 18:07:38 +0200
Subject: [PATCH 1/2] [clang-tidy] rewrite matchers in
 modernize-use-starts-ends-with

Rewrite the AST matchers for slightly more composability and
performance. Furthermore, check that the `starts_with` and `ends_with`
functions return a `bool`.
There is one behavioral change, in that the methods of a class (and
transitive classes) are searched once for a matching
`starts_with`/`ends_with` function, picking the first it can find.
Previously, the matchers would try to find `starts_with`, then
`startsWith`, and finally, `startswith`. Now, the first of the three that
is encountered will be the matched method.
---
 .../modernize/UseStartsEndsWithCheck.cpp  | 59 ---
 .../modernize/use-starts-ends-with.cpp|  4 +-
 2 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index 5eb3267adb0799..a1376aa8fa5e6e 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -9,8 +9,10 @@
 #include "UseStartsEndsWithCheck.h"
 
 #include "../utils/ASTUtils.h"
-#include "../utils/OptionsUtils.h"
+#include "../utils/Matchers.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/ArrayRef.h"
 
 #include 
 
@@ -82,34 +84,25 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef 
Name,
 void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
   const auto ZeroLiteral = integerLiteral(equals(0));
 
-  const auto HasStartsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("starts_with_fun"));
-  };
-  const auto HasStartsWithMethod =
-  anyOf(HasStartsWithMethodWithName("starts_with"),
-HasStartsWithMethodWithName("startsWith"),
-HasStartsWithMethodWithName("startswith"));
-  const auto OnClassWithStartsWithFunction =
-  on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasStartsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(
-
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)));
-
-  const auto HasEndsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("ends_with_fun"));
-  };
-  const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
-   HasEndsWithMethodWithName("endsWith"),
-   HasEndsWithMethodWithName("endswith"));
+  const auto ClassTypeWithMethod =
+  [](const StringRef MethodBoundName,
+ const llvm::ArrayRef &Methods) {
+const auto Method =
+cxxMethodDecl(isConst(), parameterCountIs(1),
+  returns(booleanType()), hasAnyName(Methods))
+.bind(MethodBoundName);
+return qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+anyOf(hasMethod(Method),
+  hasAnyBase(hasType(hasCanonicalType(
+  hasDeclaration(cxxRecordDecl(hasMethod(Method)));
+  };
+
+  const auto OnClassWithStartsWithFunction = on(hasType(ClassTypeWithMethod(
+  "starts_with_fun", {"starts_with", "startsWith", "startswith"})));
+
   const auto OnClassWithEndsWithFunction =
-  on(expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasEndsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(hasDeclaration(
-cxxRecordDecl(HasEndsWithMethod)))
+  on(expr(hasType(ClassTypeWithMethod(
+  "ends_with_fun", {"ends_with", "endsWith", "endswith"})))
  .bind("haystack"));
 
   // Case 1: X.find(Y) [!=]= 0 -> starts_with.
@@ -145,7 +138,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   // All cases comparing to 0.
   Finder->addMatcher(
   binaryOperator(
-  hasAnyOperatorName("==", "!="),
+  matchers::isEqualityOperator(),
   hasOperands(cxxMemberCallExpr(anyOf(FindExpr, RFindExpr, CompareExpr,
   CompareEndsWithExpr))
   .bind("find_expr"),
@@ -156,7 +149,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   // Case 5: X.rfind(Y) [!=]= LEN(X) - LEN(Y) -> ends_with.
   Finder->addMatcher(
   binaryOperator(
-  hasAnyOperatorName("==", "!="),
+  matchers::isEqualityOperator(),
   hasOperan

[clang] [llvm] [mlir] [polly] [NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (PR #111752)

2024-10-12 Thread Rahul Joshi via cfe-commits

jurahul wrote:

I will add getDeclaration back and mark it deprecated. What’s the timeframe
for deprecation thought? A couple of weeks? Because I do want to add back
the getDeclaration with different semantics. Unless we go with @nikic’s
recommendation of getDeclarationIfExists. I am going to wait for @nikic’s
response before any more changes here.

On Sat, Oct 12, 2024 at 6:53 PM Yingwei Zheng ***@***.***>
wrote:

> TBH I am wondering if we should revert this rename. I don't think it's a
> good idea to reuse getDeclaration with substantially different semantics,
> and if we're not reusing it, then there's not much point to rename...
>
> Instead of having getOrInsertDeclaration + getDeclaration with a meaning
> inversion, we can have getDeclaration and getDeclarationIfExists without
> the inversion.
>
> I'd like to revert this change, or just add Intrinsic::getDeclaration
> back and mark it as deprecated. I have encountered a build error on Alive2.
>
> —
> Reply to this email directly, view it on GitHub
> ,
> or unsubscribe
> 
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>


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


[clang-tools-extra] 571354e - [clang-tidy] Avoid repeated hash lookups (NFC) (#112074)

2024-10-12 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-10-12T08:04:17-07:00
New Revision: 571354e25130b213146c26d05524fcd215fbd061

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

LOG: [clang-tidy] Avoid repeated hash lookups (NFC) (#112074)

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
index 5b1b1cd152fffb..6df565c9a9d691 100644
--- a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
@@ -137,11 +137,11 @@ static bool mayShadow(const NamedDecl *ND0,
 const ConfusableIdentifierCheck::ContextInfo *
 ConfusableIdentifierCheck::getContextInfo(const DeclContext *DC) {
   const DeclContext *PrimaryContext = DC->getPrimaryContext();
-  auto It = ContextInfos.find(PrimaryContext);
-  if (It != ContextInfos.end())
+  auto [It, Inserted] = ContextInfos.try_emplace(PrimaryContext);
+  if (!Inserted)
 return &It->second;
 
-  ContextInfo &Info = ContextInfos[PrimaryContext];
+  ContextInfo &Info = It->second;
   Info.PrimaryContext = PrimaryContext;
   Info.NonTransparentContext = PrimaryContext;
 



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


[clang-tools-extra] [clang-tidy] Avoid repeated hash lookups (NFC) (PR #112074)

2024-10-12 Thread Kazu Hirata via cfe-commits

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


[clang] [llvm] [Driver][SYCL] Add initial SYCL offload compilation support (PR #107493)

2024-10-12 Thread Thorsten Schütt via cfe-commits

tschuett wrote:

> Hello - any additional feedback on this?

The house rule is to ping:
If you have received no comments on your patch for a week, you can request a 
review by ‘ping’ing the GitHub PR with “Ping”. The common courtesy ‘ping’ rate 
is once a week. Please remember that you are asking for valuable time from 
other professional developers.

https://llvm.org/docs/Contributing.html

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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Julian Schmidt via cfe-commits

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


[clang] [clang][GNU] Pass -t through to the linker (PR #112106)

2024-10-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Keith Smiley (keith)


Changes



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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+1-1) 
- (modified) clang/test/Driver/Xlinker-args.c (+2-2) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 09bb2df4391027..769c78ddd57abc 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -671,7 +671,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 }
   }
 
-  Args.AddAllArgs(CmdArgs, options::OPT_T);
+  Args.addAllArgs(CmdArgs, {options::OPT_T, options::OPT_t});
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
diff --git a/clang/test/Driver/Xlinker-args.c b/clang/test/Driver/Xlinker-args.c
index b2a913e7cef620..87f98a0cdbd837 100644
--- a/clang/test/Driver/Xlinker-args.c
+++ b/clang/test/Driver/Xlinker-args.c
@@ -8,7 +8,7 @@
 
 /// -T is reordered to the last to make sure -L takes precedence.
 // RUN: %clang -target x86_64-pc-linux-gnu -### \
-// RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
+// RUN:   -e _start -T a.lds -t -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
 
@@ -23,7 +23,7 @@
 
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
-// LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
+// LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds" "-t"
 // MINGW: "--no-demangle"
 // AIX: "-b" "one" "-b" "two"
 

``




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


[clang] [clang][GNU] Pass -t through to the linker (PR #112106)

2024-10-12 Thread Keith Smiley via cfe-commits

https://github.com/keith created 
https://github.com/llvm/llvm-project/pull/112106

None

>From becf5f4848e1482ef440ce5e04af6a5b715031ed Mon Sep 17 00:00:00 2001
From: Keith Smiley 
Date: Sat, 12 Oct 2024 18:08:33 +
Subject: [PATCH] [clang][GNU] Pass -t through to the linker

---
 clang/lib/Driver/ToolChains/Gnu.cpp | 2 +-
 clang/test/Driver/Xlinker-args.c| 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 09bb2df4391027..769c78ddd57abc 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -671,7 +671,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 }
   }
 
-  Args.AddAllArgs(CmdArgs, options::OPT_T);
+  Args.addAllArgs(CmdArgs, {options::OPT_T, options::OPT_t});
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
diff --git a/clang/test/Driver/Xlinker-args.c b/clang/test/Driver/Xlinker-args.c
index b2a913e7cef620..87f98a0cdbd837 100644
--- a/clang/test/Driver/Xlinker-args.c
+++ b/clang/test/Driver/Xlinker-args.c
@@ -8,7 +8,7 @@
 
 /// -T is reordered to the last to make sure -L takes precedence.
 // RUN: %clang -target x86_64-pc-linux-gnu -### \
-// RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
+// RUN:   -e _start -T a.lds -t -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
 
@@ -23,7 +23,7 @@
 
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
-// LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
+// LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds" "-t"
 // MINGW: "--no-demangle"
 // AIX: "-b" "one" "-b" "two"
 

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-12 Thread Nikita Popov via cfe-commits


@@ -1391,22 +1412,65 @@ static void AddParamAndFnBasicAttributes(const CallBase 
&CB,
 
   AttributeList AL = NewInnerCB->getAttributes();
   for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) {
-// Check if the underlying value for the parameter is an argument.
-const Value *UnderlyingV =
-getUnderlyingObject(InnerCB->getArgOperand(I));
-const Argument *Arg = dyn_cast(UnderlyingV);
-if (!Arg)
+// It's unsound or requires special handling to propagate attributes to
+// byval arguments. For reach even if CalledFunction doesn't e.g. write
+// to the argument (readonly), the call to NewInnerCB may write to its
+// by-value copy.
+if (AL.hasParamAttr(I, Attribute::ByVal))
   continue;
 
-if (AL.hasParamAttr(I, Attribute::ByVal))
-  // It's unsound to propagate memory attributes to byval arguments.
-  // Even if CalledFunction doesn't e.g. write to the argument,
-  // the call to NewInnerCB may write to its by-value copy.
+// Don't both propagating attrs to constants.
+if (match(NewInnerCB->getArgOperand(I),
+  llvm::PatternMatch::m_ImmConstant()))
   continue;
 
-unsigned ArgNo = Arg->getArgNo();
+// Check if the underlying value for the parameter is an argument.
+const Argument *Arg = dyn_cast(InnerCB->getArgOperand(I));
+unsigned ArgNo;
+if (Arg) {
+  ArgNo = Arg->getArgNo();
+  // For dereferenceable, dereferenceable_or_null, align, etc...
+  // we don't want to propagate if the existing param has the same
+  // attribute with "better" constraints. So  remove from the
+  // new AL if the region of the existing param is larger than
+  // what we can propagate.
+  AttrBuilder NewAL(Context);
+  for (auto Attr : ValidExactParamAttrs[ArgNo].attrs())
+NewAL.addAttribute(Attr);
+  if (AL.getParamDereferenceableBytes(I) >
+  NewAL.getDereferenceableBytes())
+NewAL.removeAttribute(Attribute::Dereferenceable);
+  if (AL.getParamDereferenceableOrNullBytes(I) >
+  NewAL.getDereferenceableOrNullBytes())
+NewAL.removeAttribute(Attribute::Dereferenceable);

nikic wrote:

```suggestion
NewAL.removeAttribute(Attribute::DereferenceableOrNull);
```

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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits


@@ -82,34 +84,25 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef 
Name,
 void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
   const auto ZeroLiteral = integerLiteral(equals(0));
 
-  const auto HasStartsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("starts_with_fun"));
-  };
-  const auto HasStartsWithMethod =
-  anyOf(HasStartsWithMethodWithName("starts_with"),
-HasStartsWithMethodWithName("startsWith"),
-HasStartsWithMethodWithName("startswith"));
-  const auto OnClassWithStartsWithFunction =
-  on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasStartsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(
-
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)));
-
-  const auto HasEndsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("ends_with_fun"));
-  };
-  const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
-   HasEndsWithMethodWithName("endsWith"),
-   HasEndsWithMethodWithName("endswith"));
+  const auto ClassTypeWithMethod =
+  [](const StringRef MethodBoundName,
+ const llvm::ArrayRef &Methods) {
+const auto Method =
+cxxMethodDecl(isConst(), parameterCountIs(1),
+  returns(booleanType()), hasAnyName(Methods))
+.bind(MethodBoundName);
+return qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+anyOf(hasMethod(Method),
+  hasAnyBase(hasType(hasCanonicalType(
+  hasDeclaration(cxxRecordDecl(hasMethod(Method)));

nicovank wrote:

I don't think we care much about the case where a class inheriting a 
starts-with-class prefers a different overload, so maybe we can simplify to 
this:
```
return cxxRecordDecl(hasMethod(Method));
  };

  const auto OnClassWithStartsWithFunction =
  callee(cxxMethodDecl(ofClass(ClassTypeWithMethod(
  "starts_with_fun", {"starts_with", "startsWith", "startswith"};

  const auto OnClassWithEndsWithFunction = cxxMemberCallExpr(
  callee(cxxMethodDecl(ofClass(ClassTypeWithMethod(
  "ends_with_fun", {"ends_with", "endsWith", "endswith"},
  on(expr().bind("haystack")));
```

This will require deleting the `prefer_underscore_version_inherit` test case 
that was testing this behavior, I think that's fine.

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-12 Thread Nikita Popov via cfe-commits


@@ -1358,18 +1360,37 @@ static void AddParamAndFnBasicAttributes(const CallBase 
&CB,
   auto &Context = CalledFunction->getContext();
 
   // Collect valid attributes for all params.
-  SmallVector ValidParamAttrs;
+  SmallVector ValidObjParamAttrs, ValidExactParamAttrs;
   bool HasAttrToPropagate = false;
 
+  // Attributes we can only propagate if the exact parameter is forwarded.
+  // We can propagate both poison generating and UB generating attributes
+  // without any extra checks. The only attribute that is tricky to propagate
+  // is `noundef` (skipped for now) as that can create new UB where previous
+  // behavior was just using a poison value.
+  static const Attribute::AttrKind ExactAttrsToPropagate[] = {
+  Attribute::Dereferenceable, Attribute::DereferenceableOrNull,
+  Attribute::NonNull, Attribute::Alignment, Attribute::Range};
+
   for (unsigned I = 0, E = CB.arg_size(); I < E; ++I) {
-ValidParamAttrs.emplace_back(AttrBuilder{CB.getContext()});
+ValidObjParamAttrs.emplace_back(AttrBuilder{CB.getContext()});
+ValidExactParamAttrs.emplace_back(AttrBuilder{CB.getContext()});
 // Access attributes can be propagated to any param with the same 
underlying
 // object as the argument.
 if (CB.paramHasAttr(I, Attribute::ReadNone))
-  ValidParamAttrs.back().addAttribute(Attribute::ReadNone);
+  ValidObjParamAttrs.back().addAttribute(Attribute::ReadNone);
 if (CB.paramHasAttr(I, Attribute::ReadOnly))
-  ValidParamAttrs.back().addAttribute(Attribute::ReadOnly);
-HasAttrToPropagate |= ValidParamAttrs.back().hasAttributes();
+  ValidObjParamAttrs.back().addAttribute(Attribute::ReadOnly);
+HasAttrToPropagate |= ValidObjParamAttrs.back().hasAttributes();
+
+for (Attribute::AttrKind AK : ExactAttrsToPropagate) {
+  Attribute Attr = CB.getParamAttr(I, AK);
+  if (Attr.isValid())
+ValidExactParamAttrs.back().addAttribute(Attr);
+}
+
+HasAttrToPropagate |= ValidObjParamAttrs.back().hasAttributes();

nikic wrote:

This is already done above, drop one of them.

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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits


@@ -82,34 +84,25 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef 
Name,
 void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
   const auto ZeroLiteral = integerLiteral(equals(0));
 
-  const auto HasStartsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("starts_with_fun"));
-  };
-  const auto HasStartsWithMethod =
-  anyOf(HasStartsWithMethodWithName("starts_with"),
-HasStartsWithMethodWithName("startsWith"),
-HasStartsWithMethodWithName("startswith"));
-  const auto OnClassWithStartsWithFunction =
-  on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
-  anyOf(HasStartsWithMethod,
-hasAnyBase(hasType(hasCanonicalType(
-
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)));
-
-  const auto HasEndsWithMethodWithName = [](const std::string &Name) {
-return hasMethod(
-cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
-.bind("ends_with_fun"));
-  };
-  const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
-   HasEndsWithMethodWithName("endsWith"),
-   HasEndsWithMethodWithName("endswith"));
+  const auto ClassTypeWithMethod =
+  [](const StringRef MethodBoundName,
+ const llvm::ArrayRef &Methods) {
+const auto Method =
+cxxMethodDecl(isConst(), parameterCountIs(1),
+  returns(booleanType()), hasAnyName(Methods))
+.bind(MethodBoundName);
+return qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+anyOf(hasMethod(Method),
+  hasAnyBase(hasType(hasCanonicalType(
+  hasDeclaration(cxxRecordDecl(hasMethod(Method)));
+  };
+
+  const auto OnClassWithStartsWithFunction = on(hasType(ClassTypeWithMethod(
+  "starts_with_fun", {"starts_with", "startsWith", "startswith"})));

nicovank wrote:

Side note: we can also add `StartsWith`/`EndsWith`, found out Apache Arrow uses 
that:
https://github.com/apache/arrow/blob/5638169313ba09fff26f7dc11bce0f6ce3eefed4/cpp/src/arrow/util/string.h#L56

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


[clang-tools-extra] [clang-tidy] rewrite matchers in modernize-use-starts-ends-with (PR #112101)

2024-10-12 Thread Nicolas van Kempen via cfe-commits


@@ -150,8 +150,8 @@ void test(std::string s, std::string_view sv, sub_string 
ss, sub_sub_string sss,
   // CHECK-FIXES: puv.starts_with("a");
 
   puvf.find("a") == 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with
-  // CHECK-FIXES: puvf.starts_with("a");
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use startsWith
+  // CHECK-FIXES: puvf.startsWith("a");

nicovank wrote:

I kinda liked the idea of preferring `starts_with` over others.
e.g. `llvm::StringRef` used to have the `startswith` overload until 
4ec9a662d388db8a2bb862dbaa7fc3fd809d1240, `folly::StringPiece` still uses 
`startsWith`: 
[folly/Range.h](https://github.com/facebook/folly/blob/0aa6ed46b941d384214b9a0cdf9b339bf68913c6/folly/Range.h#L973-L989)

I feel like most projects are likely to move towards `starts_with` to match 
standard if multiple overloads are present, so might as well recommend it with 
higher priority. What do you think?

Suggestion to keep ordering, merged with other suggestion above to remove and 
simplify out the desugar/subclass logic:
```
const auto ClassTypeWithMethod = [](const StringRef MethodBoundName,
  auto... MethodName) {
return cxxRecordDecl(anyOf(
hasMethod(cxxMethodDecl(isConst(), parameterCountIs(1),
returns(booleanType()), hasName(MethodName))
  .bind(MethodBoundName))...));
  };
```

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-12 Thread Nikita Popov via cfe-commits


@@ -787,6 +787,11 @@ class AttributeList {
   [[nodiscard]] AttributeList addRangeRetAttr(LLVMContext &C,
   const ConstantRange &CR) const;
 
+  /// Add the range attribute to the attribute set at the given arg index.
+  /// Returns a new list because attribute lists are immutable.
+  [[nodiscard]] AttributeList addRangeParamAttr(LLVMContext &C, unsigned Index,

nikic wrote:

```suggestion
  [[nodiscard]] AttributeList addRangeParamAttr(LLVMContext &C, unsigned ArgNo,
```

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-12 Thread Nikita Popov via cfe-commits


@@ -373,6 +373,13 @@ FPClassTest CallBase::getParamNoFPClass(unsigned i) const {
   return Mask;
 }
 
+std::optional CallBase::getParamRange(unsigned ArgNo) const {

nikic wrote:

I don't think this API is used?

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-12 Thread Nikita Popov via cfe-commits


@@ -1391,22 +1412,65 @@ static void AddParamAndFnBasicAttributes(const CallBase 
&CB,
 
   AttributeList AL = NewInnerCB->getAttributes();
   for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) {
-// Check if the underlying value for the parameter is an argument.
-const Value *UnderlyingV =
-getUnderlyingObject(InnerCB->getArgOperand(I));
-const Argument *Arg = dyn_cast(UnderlyingV);
-if (!Arg)
+// It's unsound or requires special handling to propagate attributes to
+// byval arguments. For reach even if CalledFunction doesn't e.g. write
+// to the argument (readonly), the call to NewInnerCB may write to its
+// by-value copy.
+if (AL.hasParamAttr(I, Attribute::ByVal))
   continue;
 
-if (AL.hasParamAttr(I, Attribute::ByVal))
-  // It's unsound to propagate memory attributes to byval arguments.
-  // Even if CalledFunction doesn't e.g. write to the argument,
-  // the call to NewInnerCB may write to its by-value copy.
+// Don't both propagating attrs to constants.
+if (match(NewInnerCB->getArgOperand(I),
+  llvm::PatternMatch::m_ImmConstant()))
   continue;
 
-unsigned ArgNo = Arg->getArgNo();
+// Check if the underlying value for the parameter is an argument.
+const Argument *Arg = dyn_cast(InnerCB->getArgOperand(I));
+unsigned ArgNo;
+if (Arg) {
+  ArgNo = Arg->getArgNo();
+  // For dereferenceable, dereferenceable_or_null, align, etc...
+  // we don't want to propagate if the existing param has the same
+  // attribute with "better" constraints. So  remove from the
+  // new AL if the region of the existing param is larger than
+  // what we can propagate.
+  AttrBuilder NewAL(Context);
+  for (auto Attr : ValidExactParamAttrs[ArgNo].attrs())
+NewAL.addAttribute(Attr);
+  if (AL.getParamDereferenceableBytes(I) >
+  NewAL.getDereferenceableBytes())
+NewAL.removeAttribute(Attribute::Dereferenceable);
+  if (AL.getParamDereferenceableOrNullBytes(I) >
+  NewAL.getDereferenceableOrNullBytes())
+NewAL.removeAttribute(Attribute::Dereferenceable);
+  if (AL.getParamAlignment(I).valueOrOne() >
+  NewAL.getAlignment().valueOrOne())
+NewAL.removeAttribute(Attribute::Alignment);
+
+  auto ExistingRange = AL.getParamRange(I);

nikic wrote:

Move ExistingRange below to the code using it. Though I think it would be 
cleaner if instead you just added the intersected attribute to the NewAL 
AttrBuilder instead of handling range separately. Then you also don't need the 
addRangeParamAttr API.

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-12 Thread Nikita Popov via cfe-commits


@@ -1391,22 +1412,65 @@ static void AddParamAndFnBasicAttributes(const CallBase 
&CB,
 
   AttributeList AL = NewInnerCB->getAttributes();
   for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) {
-// Check if the underlying value for the parameter is an argument.
-const Value *UnderlyingV =
-getUnderlyingObject(InnerCB->getArgOperand(I));
-const Argument *Arg = dyn_cast(UnderlyingV);
-if (!Arg)
+// It's unsound or requires special handling to propagate attributes to
+// byval arguments. For reach even if CalledFunction doesn't e.g. write
+// to the argument (readonly), the call to NewInnerCB may write to its
+// by-value copy.
+if (AL.hasParamAttr(I, Attribute::ByVal))
   continue;
 
-if (AL.hasParamAttr(I, Attribute::ByVal))
-  // It's unsound to propagate memory attributes to byval arguments.
-  // Even if CalledFunction doesn't e.g. write to the argument,
-  // the call to NewInnerCB may write to its by-value copy.
+// Don't both propagating attrs to constants.

nikic wrote:

```suggestion
// Don't bother propagating attrs to constants.
```

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-12 Thread Nikita Popov via cfe-commits


@@ -1391,22 +1412,65 @@ static void AddParamAndFnBasicAttributes(const CallBase 
&CB,
 
   AttributeList AL = NewInnerCB->getAttributes();
   for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) {
-// Check if the underlying value for the parameter is an argument.
-const Value *UnderlyingV =
-getUnderlyingObject(InnerCB->getArgOperand(I));
-const Argument *Arg = dyn_cast(UnderlyingV);
-if (!Arg)
+// It's unsound or requires special handling to propagate attributes to
+// byval arguments. For reach even if CalledFunction doesn't e.g. write

nikic wrote:

For reach?

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-12 Thread Nikita Popov via cfe-commits


@@ -1391,22 +1412,65 @@ static void AddParamAndFnBasicAttributes(const CallBase 
&CB,
 
   AttributeList AL = NewInnerCB->getAttributes();
   for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) {
-// Check if the underlying value for the parameter is an argument.
-const Value *UnderlyingV =
-getUnderlyingObject(InnerCB->getArgOperand(I));
-const Argument *Arg = dyn_cast(UnderlyingV);
-if (!Arg)
+// It's unsound or requires special handling to propagate attributes to
+// byval arguments. For reach even if CalledFunction doesn't e.g. write
+// to the argument (readonly), the call to NewInnerCB may write to its
+// by-value copy.
+if (AL.hasParamAttr(I, Attribute::ByVal))
   continue;
 
-if (AL.hasParamAttr(I, Attribute::ByVal))
-  // It's unsound to propagate memory attributes to byval arguments.
-  // Even if CalledFunction doesn't e.g. write to the argument,
-  // the call to NewInnerCB may write to its by-value copy.
+// Don't both propagating attrs to constants.
+if (match(NewInnerCB->getArgOperand(I),
+  llvm::PatternMatch::m_ImmConstant()))
   continue;
 
-unsigned ArgNo = Arg->getArgNo();
+// Check if the underlying value for the parameter is an argument.
+const Argument *Arg = dyn_cast(InnerCB->getArgOperand(I));
+unsigned ArgNo;
+if (Arg) {
+  ArgNo = Arg->getArgNo();
+  // For dereferenceable, dereferenceable_or_null, align, etc...
+  // we don't want to propagate if the existing param has the same
+  // attribute with "better" constraints. So  remove from the
+  // new AL if the region of the existing param is larger than
+  // what we can propagate.
+  AttrBuilder NewAL(Context);

nikic wrote:

I'd AL -> AS here. We're constructing an AttributeSet for a single parameter.

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


[clang] 9c2fc17 - [Sema] Avoid repeated hash lookups (NFC) (#112071)

2024-10-12 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-10-12T08:00:31-07:00
New Revision: 9c2fc17ee79eea7e18964d3d1b910dd8c1d7e733

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

LOG: [Sema] Avoid repeated hash lookups (NFC) (#112071)

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeduction.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index aa62cfa7dcbd17..7cfb8d687c796a 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4057,11 +4057,10 @@ TemplateDeductionResult 
Sema::FinishTemplateArgumentDeduction(
   // keep track of these diagnostics. They'll be emitted if this specialization
   // is actually used.
   if (Info.diag_begin() != Info.diag_end()) {
-SuppressedDiagnosticsMap::iterator
-  Pos = SuppressedDiagnostics.find(Specialization->getCanonicalDecl());
-if (Pos == SuppressedDiagnostics.end())
-SuppressedDiagnostics[Specialization->getCanonicalDecl()]
-  .append(Info.diag_begin(), Info.diag_end());
+auto [Pos, Inserted] =
+SuppressedDiagnostics.try_emplace(Specialization->getCanonicalDecl());
+if (Inserted)
+  Pos->second.append(Info.diag_begin(), Info.diag_end());
   }
 
   return TemplateDeductionResult::Success;



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


[clang] [Sema] Avoid repeated hash lookups (NFC) (PR #112071)

2024-10-12 Thread Kazu Hirata via cfe-commits

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


[clang] [lld] [llvm] [WebAssembly] Define a new "Trail1" CPU (PR #112035)

2024-10-12 Thread Dan Gohman via cfe-commits

https://github.com/sunfishcode updated 
https://github.com/llvm/llvm-project/pull/112035

>From b8f33cd68d11759ad774e16b4d25491a1c9fc3e4 Mon Sep 17 00:00:00 2001
From: Dan Gohman 
Date: Fri, 11 Oct 2024 04:30:32 -0700
Subject: [PATCH 1/3] [WebAssembly] Define a new "Trail1" CPU

First, define some new target features. These are subsets of existing features
that reflect implemenetation concerns:

 - "call-indirect-overlong" - implied by "reference-types"; just the overlong
   encoding for the `call_indirect` immediate, and not the actual reference
   types.

 - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and
   `memory.fill`, and not the other instructions in the bulk-memory
proposal.

Next, define a new target CPU, "Trail1", which enables mutable-globals,
bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const,
and call-indirect-overlong. Unlike the default "generic" CPU, "trail1" is meant
to be frozen, and followed up by "trail2" and so on when new features are
desired.
---
 clang/lib/Basic/Targets/WebAssembly.cpp   | 45 +++
 clang/lib/Basic/Targets/WebAssembly.h |  2 +
 lld/test/wasm/compress-relocs.ll  |  2 +-
 lld/test/wasm/import-table-explicit.s |  2 +-
 lld/test/wasm/invalid-mvp-table-use.s |  2 +-
 lld/wasm/InputFiles.cpp   | 11 ++---
 lld/wasm/SyntheticSections.cpp|  2 +-
 .../AsmParser/WebAssemblyAsmParser.cpp| 12 ++---
 llvm/lib/Target/WebAssembly/WebAssembly.td| 14 ++
 .../WebAssembly/WebAssemblyFastISel.cpp   |  2 +-
 .../WebAssembly/WebAssemblyISelLowering.cpp   |  2 +-
 .../WebAssembly/WebAssemblyInstrBulkMemory.td | 15 ---
 .../WebAssembly/WebAssemblyInstrInfo.td   |  8 
 .../WebAssemblySelectionDAGInfo.cpp   |  4 +-
 .../Target/WebAssembly/WebAssemblySubtarget.h |  4 ++
 .../WebAssembly/WebAssemblyUtilities.cpp  |  4 +-
 llvm/test/CodeGen/WebAssembly/bulk-memory.ll  |  6 +--
 .../test/CodeGen/WebAssembly/bulk-memory64.ll |  6 +--
 18 files changed, 110 insertions(+), 33 deletions(-)

diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 5ac9421663adea..aa3a2770727c3a 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   return llvm::StringSwitch(Feature)
   .Case("atomics", HasAtomics)
   .Case("bulk-memory", HasBulkMemory)
+  .Case("bulk-memory-opt", HasBulkMemoryOpt)
   .Case("exception-handling", HasExceptionHandling)
   .Case("extended-const", HasExtendedConst)
   .Case("fp16", HasFP16)
@@ -55,6 +56,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   .Case("mutable-globals", HasMutableGlobals)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("reference-types", HasReferenceTypes)
+  .Case("call-indirect-overlong", HasCallIndirectOverlong)
   .Case("relaxed-simd", SIMDLevel >= RelaxedSIMD)
   .Case("sign-ext", HasSignExt)
   .Case("simd128", SIMDLevel >= SIMD128)
@@ -78,6 +80,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const 
LangOptions &Opts,
 Builder.defineMacro("__wasm_atomics__");
   if (HasBulkMemory)
 Builder.defineMacro("__wasm_bulk_memory__");
+  if (HasBulkMemoryOpt)
+Builder.defineMacro("__wasm_bulk_memory_opt__");
   if (HasExceptionHandling)
 Builder.defineMacro("__wasm_exception_handling__");
   if (HasExtendedConst)
@@ -154,12 +158,23 @@ bool WebAssemblyTargetInfo::initFeatureMap(
 Features["multivalue"] = true;
 Features["mutable-globals"] = true;
 Features["reference-types"] = true;
+Features["call-indirect-overlong"] = true;
 Features["sign-ext"] = true;
   };
+  auto addTrail1Features = [&]() {
+Features["multivalue"] = true;
+Features["mutable-globals"] = true;
+Features["call-indirect-overlong"] = true;
+Features["sign-ext"] = true;
+Features["bulk-memory-opt"] = true;
+Features["nontrapping-fptoint"] = true;
+Features["extended-const"] = true;
+  };
   auto addBleedingEdgeFeatures = [&]() {
 addGenericFeatures();
 Features["atomics"] = true;
 Features["bulk-memory"] = true;
+Features["bulk-memory-opt"] = true;
 Features["exception-handling"] = true;
 Features["extended-const"] = true;
 Features["fp16"] = true;
@@ -170,6 +185,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
   };
   if (CPU == "generic") {
 addGenericFeatures();
+  } else if (CPU == "trail1") {
+addTrail1Features();
   } else if (CPU == "bleeding-edge") {
 addBleedingEdgeFeatures();
   }
@@ -196,6 +213,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
   HasBulkMemory = false;
   continue;
 }
+if (Feature == "+bulk-memory-opt") {
+  HasBulkMemoryOpt = true;
+  continue;
+}
+if (Feature == "-bulk-memory-opt") {
+

[clang] [clang] Check null TypeSourceInfo in CreateUnaryExprOrTypeTraitExpr (PR #112111)

2024-10-12 Thread Andrew Sukach via cfe-commits

https://github.com/sookach created 
https://github.com/llvm/llvm-project/pull/112111

Fixes #111594. The crash is caused by the following call
https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ComputeDependence.cpp#L81-L82

We already check for a null TypeInfo when creating a UnaryExprOrTypeTraitExpr 
here
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExpr.cpp#L4616-L4617

but the following lines can, and in the case of the code in the issue, nullify 
the TypeInfo
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExpr.cpp#L4616-L4617

Thus, adding the additional check for nullptr prevents the erroneous memory 
access.

@shafik Thoughts? Thanks


>From 215a126137ef43bbb24abbd5c0847744d2a4d083 Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Sat, 12 Oct 2024 19:47:30 -0400
Subject: [PATCH] [clang] Check for null TypeSourceInfo in
 Sema::CreateUnaryExprOrTypeTraitExpr

---
 clang/lib/Sema/SemaExpr.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4e37385710af5e..b0bd216c5dc101 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4629,6 +4629,9 @@ ExprResult 
Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
   TInfo->getType()->isVariablyModifiedType())
 TInfo = TransformToPotentiallyEvaluated(TInfo);
 
+  if (!TInfo)
+return ExprError();
+
   // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
   return new (Context) UnaryExprOrTypeTraitExpr(
   ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());

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


[clang] [clang] Check null TypeSourceInfo in CreateUnaryExprOrTypeTraitExpr (PR #112111)

2024-10-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Andrew Sukach (sookach)


Changes

Fixes #111594. The crash is caused by the following call
https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ComputeDependence.cpp#L81-L82

We already check for a null TypeInfo when creating a UnaryExprOrTypeTraitExpr 
here
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExpr.cpp#L4616-L4617

but the following lines can, and in the case of the code in the issue, nullify 
the TypeInfo
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExpr.cpp#L4616-L4617

Thus, adding the additional check for nullptr prevents the erroneous memory 
access.

@shafik Thoughts? Thanks


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


1 Files Affected:

- (modified) clang/lib/Sema/SemaExpr.cpp (+3) 


``diff
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4e37385710af5e..b0bd216c5dc101 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4629,6 +4629,9 @@ ExprResult 
Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
   TInfo->getType()->isVariablyModifiedType())
 TInfo = TransformToPotentiallyEvaluated(TInfo);
 
+  if (!TInfo)
+return ExprError();
+
   // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
   return new (Context) UnaryExprOrTypeTraitExpr(
   ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());

``




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


[clang-tools-extra] [clang-tidy][readability-identifier-naming] Support namespace aliases (PR #112112)

2024-10-12 Thread via cfe-commits

llvmbot wrote:




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

Author: Keith Smiley (keith)


Changes

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


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


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
(+3) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp 
(+4) 


``diff
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 828f13805a6980..3f63eec2c51a8c 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -1135,6 +1135,9 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   if (isa(D) && NamingStyles[SK_TypeAlias])
 return SK_TypeAlias;
 
+  if (isa(D) && NamingStyles[SK_Namespace])
+return SK_Namespace;
+
   if (const auto *Decl = dyn_cast(D)) {
 if (Decl->isAnonymousNamespace())
   return SK_Invalid;
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
index 99149fe86aceec..be5ba54513c672 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
@@ -101,6 +101,10 @@ inline namespace InlineNamespace {
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for inline 
namespace 'InlineNamespace'
 // CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}}
 
+namespace FOO_ALIAS = FOO_NS;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for namespace 
'FOO_ALIAS' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}namespace foo_alias = FOO_NS;{{$}}
+
 SYSTEM_NS::structure g_s1;
 // NO warnings or fixes expected as SYSTEM_NS and structure are declared in a 
header file
 

``




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


[clang-tools-extra] [clang-tidy][readability-identifier-naming] Support namespace aliases (PR #112112)

2024-10-12 Thread Keith Smiley via cfe-commits

https://github.com/keith created 
https://github.com/llvm/llvm-project/pull/112112

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


>From b74b4fec46c871c5981422a7779fdf39c215487c Mon Sep 17 00:00:00 2001
From: Keith Smiley 
Date: Sat, 12 Oct 2024 13:38:36 -0700
Subject: [PATCH] [clang-tidy][readability-identifier-naming] Support namespace
 aliases

Fixes: https://github.com/llvm/llvm-project/issues/109385
---
 .../clang-tidy/readability/IdentifierNamingCheck.cpp  | 3 +++
 .../clang-tidy/checkers/readability/identifier-naming.cpp | 4 
 2 files changed, 7 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 828f13805a6980..3f63eec2c51a8c 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -1135,6 +1135,9 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   if (isa(D) && NamingStyles[SK_TypeAlias])
 return SK_TypeAlias;
 
+  if (isa(D) && NamingStyles[SK_Namespace])
+return SK_Namespace;
+
   if (const auto *Decl = dyn_cast(D)) {
 if (Decl->isAnonymousNamespace())
   return SK_Invalid;
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
index 99149fe86aceec..be5ba54513c672 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
@@ -101,6 +101,10 @@ inline namespace InlineNamespace {
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for inline 
namespace 'InlineNamespace'
 // CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}}
 
+namespace FOO_ALIAS = FOO_NS;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for namespace 
'FOO_ALIAS' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}namespace foo_alias = FOO_NS;{{$}}
+
 SYSTEM_NS::structure g_s1;
 // NO warnings or fixes expected as SYSTEM_NS and structure are declared in a 
header file
 

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


[clang-tools-extra] [clang-tidy][readability-identifier-naming] Support namespace aliases (PR #112112)

2024-10-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Keith Smiley (keith)


Changes

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


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


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
(+3) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp 
(+4) 


``diff
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 828f13805a6980..3f63eec2c51a8c 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -1135,6 +1135,9 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   if (isa(D) && NamingStyles[SK_TypeAlias])
 return SK_TypeAlias;
 
+  if (isa(D) && NamingStyles[SK_Namespace])
+return SK_Namespace;
+
   if (const auto *Decl = dyn_cast(D)) {
 if (Decl->isAnonymousNamespace())
   return SK_Invalid;
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
index 99149fe86aceec..be5ba54513c672 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
@@ -101,6 +101,10 @@ inline namespace InlineNamespace {
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for inline 
namespace 'InlineNamespace'
 // CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}}
 
+namespace FOO_ALIAS = FOO_NS;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for namespace 
'FOO_ALIAS' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}namespace foo_alias = FOO_NS;{{$}}
+
 SYSTEM_NS::structure g_s1;
 // NO warnings or fixes expected as SYSTEM_NS and structure are declared in a 
header file
 

``




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


[clang] [llvm] [LoongArch] Add options for annotate tablejump (PR #102411)

2024-10-12 Thread Lu Weining via cfe-commits


@@ -1888,6 +1888,14 @@ void Clang::AddLoongArchTargetArgs(const ArgList &Args,
 CmdArgs.push_back("-tune-cpu");
 CmdArgs.push_back(Args.MakeArgString(TuneCPU));
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_mannotate_tablejump,
+   options::OPT_mno_annotate_tablejump)) {
+if (A->getOption().matches(options::OPT_mannotate_tablejump)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-loongarch-annotate-tablejump");
+}

SixWeining wrote:

else: -loongarch-annotate-tablejump=false

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


[clang] [llvm] [LoongArch] Add options for annotate tablejump (PR #102411)

2024-10-12 Thread Lu Weining via cfe-commits

https://github.com/SixWeining commented:

Better to add gcc's links to commit message to let people know the background.

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


[clang] [llvm] [LoongArch] Add options for annotate tablejump (PR #102411)

2024-10-12 Thread Lu Weining via cfe-commits


@@ -5340,6 +5340,10 @@ def mno_lasx : Flag<["-"], "mno-lasx">, 
Group,
 def msimd_EQ : Joined<["-"], "msimd=">, Group,
   Flags<[TargetSpecific]>,
   HelpText<"Select the SIMD extension(s) to be enabled in LoongArch either 
'none', 'lsx', 'lasx'.">;
+def mannotate_tablejump : Flag<["-"], "mannotate-tablejump">, 
Group,
+  HelpText<"Enable annotate table jump instruction to correlate it with the 
jump table.">;
+def mno_annotate_tablejump : Flag<["-"], "mno-annotate-tablejump">, 
Group,

SixWeining wrote:

The negative option is useless?

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


[clang] Add isTrivial() and isTriviallyCopyable() AST matchers (PR #90634)

2024-10-12 Thread Nikolas Klauser via cfe-commits

philnik777 wrote:

While the libc++ checks are in the same tree as clang-tidy itself we (libc++) 
don't actually consider them in-tree, since they are compiled as a plugin 
against a clang-tidy that's already installed on the system.

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


[clang] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions (PR #110435)

2024-10-12 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` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-unit :: Utility/./UtilityTests/7/8 (2027 of 2036)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/1/3 (2028 of 2036)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/2/3 (2029 of 2036)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/0/2 (2030 of 2036)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/1/2 (2031 of 2036)
PASS: lldb-unit :: Host/./HostTests/11/12 (2032 of 2036)
PASS: lldb-unit :: Target/./TargetTests/11/14 (2033 of 2036)
PASS: lldb-unit :: Host/./HostTests/3/12 (2034 of 2036)
PASS: lldb-unit :: Process/gdb-remote/./ProcessGdbRemoteTests/8/9 (2035 of 2036)
UNRESOLVED: lldb-api :: tools/lldb-server/TestLldbGdbServer.py (2036 of 2036)
 TEST 'lldb-api :: tools/lldb-server/TestLldbGdbServer.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 ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --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/make --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/tools/lldb-server
 -p TestLldbGdbServer.py
--
Exit Code: 1

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

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_another_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_minus_one_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_zero_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_writes_all_gpr_registers_debugserver 
(TestLldbGdbServer.LldbGdbServe

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-12 Thread via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang] [llvm] [MIPS] LLVM data layout give i128 an alignment of 16 for mips64 (PR #112084)

2024-10-12 Thread Brad Smith via cfe-commits


@@ -75,6 +75,14 @@ TEST(DataLayoutUpgradeTest, ValidDataLayoutUpgrade) {
   EXPECT_EQ(UpgradeDataLayoutString("E-m:e-i64:64-n32:64-S128", "sparcv9"),
 "E-m:e-i64:64-i128:128-n32:64-S128");
 
+  // Check that SPARC targets add -i128:128.

brad0 wrote:

Should say MIPS.

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


[clang] [llvm] [MIPS] LLVM data layout give i128 an alignment of 16 for mips64 (PR #112084)

2024-10-12 Thread via cfe-commits

https://github.com/yingopq updated 
https://github.com/llvm/llvm-project/pull/112084

>From 956c8622fc120db71cc2ed7ab4e2269cbadf9d95 Mon Sep 17 00:00:00 2001
From: Ying Huang 
Date: Sat, 12 Oct 2024 03:12:44 -0400
Subject: [PATCH] [MIPS] LLVM data layout give i128 an alignment of 16 for
 mips64

Fix parts of #102783.
---
 clang/lib/Basic/Targets/Mips.h|  4 +-
 clang/test/CodeGen/target-data.c  |  8 +--
 llvm/lib/IR/AutoUpgrade.cpp   |  2 +-
 llvm/lib/Target/Mips/MipsTargetMachine.cpp|  2 +-
 llvm/test/CodeGen/Mips/data-layout.ll | 60 +++
 llvm/test/CodeGen/Mips/implicit-sret.ll   | 18 +++---
 .../Bitcode/DataLayoutUpgradeTest.cpp |  8 +++
 7 files changed, 85 insertions(+), 17 deletions(-)
 create mode 100644 llvm/test/CodeGen/Mips/data-layout.ll

diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 45425db3ac27ad..8acaf56523b218 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -28,9 +28,9 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 if (ABI == "o32")
   Layout = "m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
 else if (ABI == "n32")
-  Layout = "m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
+  Layout = "m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
 else if (ABI == "n64")
-  Layout = "m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128";
+  Layout = "m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
 else
   llvm_unreachable("Invalid ABI");
 
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index 8548aa00cfe877..054825011dd36c 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -54,7 +54,7 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // RUN: %clang_cc1 -triple mipsisa64r6el-linux-gnuabi64 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
-// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EL: target datalayout = 
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
@@ -64,7 +64,7 @@
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // RUN: %clang_cc1 -triple mipsisa64r6el-linux-gnuabin32 -o - -emit-llvm \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
-// MIPS-64EL-N32: target datalayout = 
"e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EL-N32: target datalayout = 
"e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
@@ -74,7 +74,7 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // RUN: %clang_cc1 -triple mipsisa64r6-linux-gnuabi64 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
-// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EB: target datalayout = 
"E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 
\
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
@@ -84,7 +84,7 @@
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // RUN: %clang_cc1 -triple mipsisa64r6-linux-gnuabin32 -o - -emit-llvm %s \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
-// MIPS-64EB-N32: target datalayout = 
"E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+// MIPS-64EB-N32: target datalayout = 
"E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PS3
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 3753509f9aa718..95e011b5aa1b9a 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5566,7 +5566,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
 return Res;
   }
 
-  if (T.isSPARC()) {
+  if (T.isSPARC() || T.isMIPS64()) {
 // Add "-i128:128"
 std::string I64 = "-i64:64";
 std::string I128 = "-i128:128";
diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp 
b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
index 7802767e31c2f6..0554d275d1e0b3 100644
--- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
@@ -99,7 +99,7 @@ static std::string computeDataLayout(const Triple &TT, 
StringRef CPU,
   // aligned. On N64 64 bit registers are also available and the stack is
   // 128 bit aligned.
   if (ABI.IsN64() || ABI.IsN32())
-Ret += "-n32:64-S128";
+Ret += "-i128:128-n32:64-S128";
   else
 Ret += "-n32-S64";
 
diff --git a/llvm/test/CodeGen/Mips/data-layout.ll 
b/llvm/test/CodeGen/Mips/data-layout.ll
new file mode 100644
index 00..0b2fc213bb0b60
--- /dev/null
+++ b/ll

[clang] [llvm] [MIPS] LLVM data layout give i128 an alignment of 16 for mips64 (PR #112084)

2024-10-12 Thread via cfe-commits


@@ -75,6 +75,14 @@ TEST(DataLayoutUpgradeTest, ValidDataLayoutUpgrade) {
   EXPECT_EQ(UpgradeDataLayoutString("E-m:e-i64:64-n32:64-S128", "sparcv9"),
 "E-m:e-i64:64-i128:128-n32:64-S128");
 
+  // Check that SPARC targets add -i128:128.

yingopq wrote:

Sorry for my mistake, updated.

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


[clang-tools-extra] [clang-tidy] Make `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

2024-10-12 Thread via cfe-commits


@@ -352,21 +352,30 @@ void good13(void) {
   int Buffer[BufferSize];
 
   int *P = &Buffer[0];
-  while (P < (Buffer + sizeof(Buffer) / sizeof(int))) {
+  while (P < Buffer + sizeof(Buffer) / sizeof(int)) {
 // NO-WARNING: Calculating the element count of the buffer here, which is
 // safe with this idiom (as long as the types don't change).
 ++P;
   }
 
-  while (P < (Buffer + sizeof(Buffer) / sizeof(Buffer[0]))) {
+  while (P < Buffer + sizeof(Buffer) / sizeof(Buffer[0])) {
 // NO-WARNING: Calculating the element count of the buffer here, which is
 // safe with this idiom.
 ++P;
   }
 
-  while (P < (Buffer + sizeof(Buffer) / sizeof(*P))) {
+  while (P < Buffer + sizeof(Buffer) / sizeof(*P)) {
 // NO-WARNING: Calculating the element count of the buffer here, which is
 // safe with this idiom.
 ++P;
   }
 }
+
+void situational14(int *Buffer, size_t BufferSize) {
+  int *P = &Buffer[0];
+  while (P < Buffer + BufferSize / sizeof(*Buffer)) {
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious usage of 
'sizeof(...)' in pointer arithmetic; this scaled value will be scaled again by 
the '+' operator

whisperity wrote:

I am not saying "_with_ the", I am saying "**by** the", which highlights the 
difference. Pointer arithmetic operator `+` does an internal scaling, cathing 
the misuse of this is the goal of the improvement that was done in the previous 
patch.

> scaled value will be used again with the other operand

This does not explain why it is an issue, only reiterates what is visible 
otherwise from the code.

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


  1   2   >