[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-24 Thread Will Hawkins via cfe-commits


@@ -0,0 +1,54 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17

hawkinsw wrote:

I'm not 100% sure, but it seems like this `UNSUPPORTED` will have to be updated 
to reflect that `concat` is a 26 feature?

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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqciac (Load-Store Adress calculation) extension (PR #121037)

2024-12-24 Thread via cfe-commits

https://github.com/hchandel created 
https://github.com/llvm/llvm-project/pull/121037

This extension adds 3 instructions that perform load-store address calculation.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

>From 304147a932684d7ccc1a8343655bb64a0c7e238f Mon Sep 17 00:00:00 2001
From: Harsh Chandel 
Date: Tue, 24 Dec 2024 13:00:04 +0530
Subject: [PATCH] [RISCV] Add Qualcomm uC Xqciac (Load-Store Adress
 calculation) extension This extension adds 3 instructions that perform
 load-store address calculation.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

Change-Id: I0b444c049d919b7bf350af438694c538f669a32d
---
 .../Driver/print-supported-extensions-riscv.c |  1 +
 llvm/docs/RISCVUsage.rst  |  3 ++
 llvm/docs/ReleaseNotes.md |  2 +
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp | 12 +
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |  6 +++
 .../Target/RISCV/MCTargetDesc/RISCVBaseInfo.h |  1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|  8 +++
 llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td   | 38 ++
 llvm/lib/TargetParser/RISCVISAInfo.cpp|  2 +-
 llvm/test/CodeGen/RISCV/attributes.ll |  2 +
 llvm/test/MC/RISCV/xqciac-invalid.s   | 43 
 llvm/test/MC/RISCV/xqciac-valid.s | 49 +++
 .../TargetParser/RISCVISAInfoTest.cpp |  5 +-
 13 files changed, 169 insertions(+), 3 deletions(-)
 create mode 100644 llvm/test/MC/RISCV/xqciac-invalid.s
 create mode 100644 llvm/test/MC/RISCV/xqciac-valid.s

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 8344c1aa399737..8e46690cce5a63 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -189,6 +189,7 @@
 // CHECK-NEXT: ssctr1.0   'Ssctr' (Control Transfer 
Records Supervisor Level)
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqcia0.2   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
+// CHECK-NEXT: xqciac   0.2   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
 // CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
 // CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index f6a0dd4bf2383c..22600f5720553e 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -429,6 +429,9 @@ The current vendor extensions supported are:
 ``experimental-Xqcia``
   LLVM implements `version 0.2 of the Qualcomm uC Arithmetic extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
+``experimental-Xqciac``
+  LLVM implements `version 0.2 of the Qualcomm uC Load-Store Address 
Calculation extension specification 
`__ by Qualcomm.  All 
instructions are prefixed with `qc.` as described in the specification. These 
instructions are only available for riscv32.
+
 ``experimental-Xqcics``
   LLVM implements `version 0.2 of the Qualcomm uC Conditional Select extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 2835ace34bff83..9cb8c53f6bba19 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -222,6 +222,8 @@ Changes to the RISC-V Backend
   extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcia` (Arithmetic)
   extension.
+* Adds experimental assembler support for the Qualcomm uC 'Xqciac` (Load-Store 
Address Calculation)
+  extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcics` (Conditonal 
Select)
   extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcilsm` (Load 
Store Multiple)
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 9dcf2e973e6c58..4c1fd5aa41e2b7 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -734,6 +734,16 @@ struct RISCVOperand final : public MCParsedAsmOperand {

[clang] [llvm] [RISCV] Add Qualcomm uC Xqciac (Load-Store Adress calculation) extension (PR #121037)

2024-12-24 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-mc

@llvm/pr-subscribers-backend-risc-v

Author: quic_hchandel (hchandel)


Changes

This extension adds 3 instructions that perform load-store address calculation.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

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


13 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) llvm/docs/RISCVUsage.rst (+3) 
- (modified) llvm/docs/ReleaseNotes.md (+2) 
- (modified) llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (+12) 
- (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+6) 
- (modified) llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+8) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td (+38) 
- (modified) llvm/lib/TargetParser/RISCVISAInfo.cpp (+1-1) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+2) 
- (added) llvm/test/MC/RISCV/xqciac-invalid.s (+43) 
- (added) llvm/test/MC/RISCV/xqciac-valid.s (+49) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+3-2) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 8344c1aa399737..8e46690cce5a63 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -189,6 +189,7 @@
 // CHECK-NEXT: ssctr1.0   'Ssctr' (Control Transfer 
Records Supervisor Level)
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqcia0.2   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
+// CHECK-NEXT: xqciac   0.2   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
 // CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
 // CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index f6a0dd4bf2383c..22600f5720553e 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -429,6 +429,9 @@ The current vendor extensions supported are:
 ``experimental-Xqcia``
   LLVM implements `version 0.2 of the Qualcomm uC Arithmetic extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
+``experimental-Xqciac``
+  LLVM implements `version 0.2 of the Qualcomm uC Load-Store Address 
Calculation extension specification 
`__ by Qualcomm.  All 
instructions are prefixed with `qc.` as described in the specification. These 
instructions are only available for riscv32.
+
 ``experimental-Xqcics``
   LLVM implements `version 0.2 of the Qualcomm uC Conditional Select extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 2835ace34bff83..9cb8c53f6bba19 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -222,6 +222,8 @@ Changes to the RISC-V Backend
   extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcia` (Arithmetic)
   extension.
+* Adds experimental assembler support for the Qualcomm uC 'Xqciac` (Load-Store 
Address Calculation)
+  extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcics` (Conditonal 
Select)
   extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcilsm` (Load 
Store Multiple)
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 9dcf2e973e6c58..4c1fd5aa41e2b7 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -734,6 +734,16 @@ struct RISCVOperand final : public MCParsedAsmOperand {
VK == RISCVMCExpr::VK_RISCV_None;
   }
 
+  bool isUImm5GT3() const {
+if (!isImm())
+  return false;
+RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None;
+int64_t Imm;
+bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
+return IsConstantImm && isUInt<5>(Imm) && (Imm > 3) &&
+   VK == RISCVMCExpr::VK_RISCV_None;
+  }
+
   bool isUImm8GE32() const {
 int64_t Imm;
 RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_No

[clang] [analyzer] Simplify CallEvent castArgToParamTypeIfNeeded (PR #120981)

2024-12-24 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.


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


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

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

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

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


@@ -1696,6 +1697,7 @@ set(files
   __cxx03/__ranges/as_rvalue_view.h
   __cxx03/__ranges/chunk_by_view.h
   __cxx03/__ranges/common_view.h
+  __cxx03/__ranges/concat_view.h

philnik777 wrote:

This shouldn't be added.

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


[clang] [Clang] Added nullptr check to getFriendDecl access (PR #121056)

2024-12-24 Thread via cfe-commits

https://github.com/GrumpyPigSkin created 
https://github.com/llvm/llvm-project/pull/121056

fixes: #120857 where a `nullptr` access was causing a crash.

@shafik please can you review. 

>From a6c7f0dfd1da4b17118f25023cf2f5da70ee3dab Mon Sep 17 00:00:00 2001
From: GrumpyPigSkin 
Date: Tue, 24 Dec 2024 15:18:29 +
Subject: [PATCH] Added nullptr check to getFriendDecl access

---
 clang/lib/Sema/SemaDeclCXX.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c5a72cf812ebc9..64b1fb28e2e184 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -8871,8 +8871,9 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  if (NamedDecl* Ffd = F->getFriendDecl())
+return FD->getCanonicalDecl() == Ffd->getCanonicalDecl();
+  return false;
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;

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


[clang-tools-extra] 2ff614a - [clang-tidy] support parameters file in command line (#120547)

2024-12-24 Thread via cfe-commits

Author: Congcong Cai
Date: 2024-12-24T23:24:14+08:00
New Revision: 2ff614aaa6eb94bc5d02c8f0fb70a1132acb4423

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

LOG: [clang-tidy] support parameters file in command line (#120547)

Fixes: #103499

Added: 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/param/parameters.txt

clang-tools-extra/test/clang-tidy/infrastructure/read-parameters-from-file-error.cpp

clang-tools-extra/test/clang-tidy/infrastructure/read-parameters-from-file.cpp

Modified: 
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/index.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index b8d843cba71330..3451e1f6242576 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -20,12 +20,14 @@
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/WithColor.h"
+#include "llvm/TargetParser/Host.h"
 #include 
 
 using namespace clang::tooling;
@@ -36,6 +38,11 @@ static cl::desc desc(StringRef description) { return 
{description.ltrim()}; }
 static cl::OptionCategory ClangTidyCategory("clang-tidy options");
 
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
+static cl::extrahelp ClangTidyParameterFileHelp(R"(
+Parameters files:
+  A large number of options or source files can be passed as parameter files
+  by use '@parameter-file' in the command line.
+)");
 static cl::extrahelp ClangTidyHelp(R"(
 Configuration files:
   clang-tidy attempts to read configuration for each source file from a
@@ -571,6 +578,21 @@ static llvm::IntrusiveRefCntPtr 
createBaseFS() {
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
+  SmallVector Args{argv, argv + argc};
+
+  // expand parameters file to argc and argv.
+  llvm::BumpPtrAllocator Alloc;
+  llvm::cl::TokenizerCallback Tokenizer =
+  llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows()
+  ? llvm::cl::TokenizeWindowsCommandLine
+  : llvm::cl::TokenizeGNUCommandLine;
+  llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
+  if (llvm::Error Err = ECtx.expandResponseFiles(Args)) {
+llvm::WithColor::error() << llvm::toString(std::move(Err)) << "\n";
+return 1;
+  }
+  argc = static_cast(Args.size());
+  argv = Args.data();
 
   // Enable help for -load option, if plugins are enabled.
   if (cl::Option *LoadOpt = cl::getRegisteredOptions().lookup("load"))

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index fa3a8e577a33ad..fabd0cc78ac645 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -115,6 +115,8 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Improved :program:`clang-tidy` by accepting parameters file in command line.
+
 - Removed :program:`clang-tidy`'s global options for most of checks. All 
options
   are changed to local options except `IncludeStyle`, `StrictMode` and
   `IgnoreMacros`.

diff  --git a/clang-tools-extra/docs/clang-tidy/index.rst 
b/clang-tools-extra/docs/clang-tidy/index.rst
index f053e57e8d4c84..8c79b4dc19393d 100644
--- a/clang-tools-extra/docs/clang-tidy/index.rst
+++ b/clang-tools-extra/docs/clang-tidy/index.rst
@@ -33,6 +33,14 @@ compilation options on the command line after ``--``:
 
   $ clang-tidy test.cpp -- -Imy_project/include -DMY_DEFINES ...
 
+If there are too many options or source files to specify on the command line,
+you can store them in a parameter file, and use :program:`clang-tidy` with that
+parameters file:
+
+.. code-block:: console
+
+  $ clang-tidy @parameters_file
+
 :program:`clang-tidy` has its own checks and can also run Clang Static Analyzer
 checks. Each check has a name and the checks to run can be chosen using the
 ``-checks=`` option, which specifies a comma-separated list of positive and
@@ -264,6 +272,9 @@ An overview of all the command-line options:
 automatically removed, but the rest of a relative path must be a
 suffix of a path in the compile command database.
 
+  Parameters files:
+A large number of options or source files can be passed as parameter files
+by use '@parameter-file' in the com

[clang] [Clang] Added nullptr check to getFriendDecl access (PR #121056)

2024-12-24 Thread via cfe-commits

https://github.com/GrumpyPigSkin updated 
https://github.com/llvm/llvm-project/pull/121056

>From a6c7f0dfd1da4b17118f25023cf2f5da70ee3dab Mon Sep 17 00:00:00 2001
From: GrumpyPigSkin 
Date: Tue, 24 Dec 2024 15:18:29 +
Subject: [PATCH 1/2] Added nullptr check to getFriendDecl access

---
 clang/lib/Sema/SemaDeclCXX.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c5a72cf812ebc9..64b1fb28e2e184 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -8871,8 +8871,9 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  if (NamedDecl* Ffd = F->getFriendDecl())
+return FD->getCanonicalDecl() == Ffd->getCanonicalDecl();
+  return false;
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;

>From 884100d515904ebba05172a3a6a535b34d8a91dd Mon Sep 17 00:00:00 2001
From: GrumpyPigSkin 
Date: Tue, 24 Dec 2024 15:24:08 +
Subject: [PATCH 2/2] Applied formatting

---
 clang/lib/Sema/SemaDeclCXX.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 64b1fb28e2e184..973318c7060a6a 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -8871,7 +8871,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  if (NamedDecl* Ffd = F->getFriendDecl())
+  if (NamedDecl *Ffd = F->getFriendDecl())
 return FD->getCanonicalDecl() == Ffd->getCanonicalDecl();
   return false;
 })) {

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


[clang-tools-extra] [clang-tidy] support parameters file in command line (PR #120547)

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

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


[clang] [Clang] Added nullptr check to getFriendDecl access (PR #121056)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (GrumpyPigSkin)


Changes

fixes: #120857 where a `nullptr` access was causing a crash.

@shafik please can you review. 

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


1 Files Affected:

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


``diff
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c5a72cf812ebc9..64b1fb28e2e184 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -8871,8 +8871,9 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  if (NamedDecl* Ffd = F->getFriendDecl())
+return FD->getCanonicalDecl() == Ffd->getCanonicalDecl();
+  return false;
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;

``




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


[clang-tools-extra] [clang-tidy] support parameters file in command line (PR #120547)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-ppc64le-linux-multistage` running on `ppc64le-clang-multistage-test` 
while building `clang-tools-extra` at step 4 "build stage 1".

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


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

```
Step 4 (build stage 1) failure: 'ninja' (failure)
...
[470/493] Creating library symlink lib/libclangTidyCppCoreGuidelinesModule.so
[471/493] Linking CXX shared library lib/libclangTidyBugproneModule.so.20.0git
[472/493] Creating library symlink lib/libclangTidyBugproneModule.so
[473/493] Linking CXX shared library lib/libclangTidyHICPPModule.so.20.0git
[474/493] Creating library symlink lib/libclangTidyHICPPModule.so
[475/493] Linking CXX shared library lib/libclangTidyCERTModule.so.20.0git
[476/493] Creating library symlink lib/libclangTidyCERTModule.so
[477/493] Linking CXX shared library lib/libclangTidyPlugin.so.20.0git
[478/493] Creating library symlink lib/libclangTidyPlugin.so
[479/493] Linking CXX shared library lib/libclangTidyMain.so.20.0git
FAILED: lib/libclangTidyMain.so.20.0git 
: && /usr/lib64/ccache/c++ -fPIC -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation 
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
-Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,defs 
-Wl,-z,nodelete   
-Wl,-rpath-link,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/./lib
  -Wl,--gc-sections -shared -Wl,-soname,libclangTidyMain.so.20.0git -o 
lib/libclangTidyMain.so.20.0git 
tools/clang/tools/extra/clang-tidy/tool/CMakeFiles/obj.clangTidyMain.dir/ClangTidyMain.cpp.o
  
-Wl,-rpath,"\$ORIGIN/../lib:/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/lib:"
  lib/libclangTidyAndroidModule.so.20.0git  
lib/libclangTidyAbseilModule.so.20.0git  
lib/libclangTidyAlteraModule.so.20.0git  lib/libclangTidyBoostModule.so.20.0git 
 lib/libclangTidyCERTModule.so.20.0git  
lib/libclangTidyConcurrencyModule.so.20.0git  
lib/libclangTidyDarwinModule.so.20.0git  
lib/libclangTidyFuchsiaModule.so.20.0git  
lib/libclangTidyHICPPModule.so.20.0git  
lib/libclangTidyLinuxKernelModule.so.20.0git  
lib/libclangTidyLLVMModule.so.20.0git  
lib/libclangTidyLLVMLibcModule.so.20.0git  
lib/libclangTidyObjCModule.so.20.0git  lib/libclangTidyOpenMPModule.so.20.0git  
lib/libclangTidyPortabilityModule.so.20.0git  
lib/libclangTidyZirconModule.so.20.0git  lib/libclangTidyMPIModule.so.20.0git  
lib/libLLVMAArch64AsmParser.so.20.0git  lib/libLLVMAMDGPUAsmParser.so.20.0git  
lib/libLLVMARMAsmParser.so.20.0git  lib/libLLVMAVRAsmParser.so.20.0git  
lib/libLLVMBPFAsmParser.so.20.0git  lib/libLLVMHexagonAsmParser.so.20.0git  
lib/libLLVMLanaiAsmParser.so.20.0git  lib/libLLVMLoongArchAsmParser.so.20.0git  
lib/libLLVMMipsAsmParser.so.20.0git  lib/libLLVMMSP430AsmParser.so.20.0git  
lib/libLLVMPowerPCAsmParser.so.20.0git  lib/libLLVMRISCVAsmParser.so.20.0git  
lib/libLLVMSparcAsmParser.so.20.0git  lib/libLLVMSystemZAsmParser.so.20.0git  
lib/libLLVMVEAsmParser.so.20.0git  lib/libLLVMWebAssemblyAsmParser.so.20.0git  
lib/libLLVMX86AsmParser.so.20.0git  lib/libLLVMAArch64Desc.so.20.0git  
lib/libLLVMAMDGPUDesc.so.20.0git  lib/libLLVMARMDesc.so.20.0git  
lib/libLLVMAVRDesc.so.20.0git  lib/libLLVMBPFDesc.so.20.0git  
lib/libLLVMHexagonDesc.so.20.0git  lib/libLLVMLanaiDesc.so.20.0git  
lib/libLLVMLoongArchDesc.so.20.0git  lib/libLLVMMipsDesc.so.20.0git  
lib/libLLVMMSP430Desc.so.20.0git  lib/libLLVMNVPTXDesc.so.20.0git  
lib/libLLVMPowerPCDesc.so.20.0git  lib/libLLVMRISCVDesc.so.20.0git  
lib/libLLVMSparcDesc.so.20.0git  lib/libLLVMSystemZDesc.so.20.0git  
lib/libLLVMVEDesc.so.20.0git  lib/libLLVMWebAssemblyDesc.so.20.0git  
lib/libLLVMX86Desc.so.20.0git  lib/libLLVMXCoreDesc.so.20.0git  
lib/libLLVMAArch64Info.so.20.0git  lib/libLLVMAMDGPUInfo.so.20.0git  
lib/libLLVMARMInfo.so.20.0git  lib/libLLVMAVRInfo.so.20.0git  
lib/libLLVMBPFInfo.so.20.0git  lib/libLLVMHexagonInfo.so.20.0git  
lib/libLLVMLanaiInfo.so.20.0git  lib/libLLVMLoongArchInfo.so.20.0git  
lib/libLLVMMipsInfo.so.20.0git  lib/libLLVMMSP430Info.so.20.0git  
lib/libLLVMNVPTXInfo.so.20.0git  lib/libLLVMPowerPCInfo.so.20.0git  
lib/libLLVMRISCVInfo.so.20.0git  lib/libLLVMSparcInfo.so.20.0git  
lib/libLLVMSystemZInfo.so.20.0git  lib/libLLVMVEInfo.so.20.0git  
lib/libLLVMWebAssemblyInfo.so.20.0git  lib/libLLVMX86Info.so.20.0git  
lib/libLLVMXCoreInfo.so.20.0git  lib/libclangTidyBugproneModule.so.20.0git  
lib/libclangTidyCppCoreGuidelinesModule.so.20.0git  
lib/l

[clang-tools-extra] [clang-tidy] swap cppcoreguidelines-narrowing-conversions and bugprone-narrowing-conversions (PR #120245)

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

HerrCai0907 wrote:

ping

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


[clang-tools-extra] [clang-tidy] add depercation warning for non-whitelisted global options (PR #121057)

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

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/121057

We plan to depercate `StrictMode` and `IgnoreMacros` global options after 2 
major versions and support local options only for them.
This patch introduces the depercation warning.


>From 5d1269d61450ee64183877108d4fdeaa611c66e8 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Tue, 24 Dec 2024 23:32:02 +0800
Subject: [PATCH] [clang-tidy] add depercation warning for non-whitelisted
 global options

---
 .../clang-tidy/ClangTidyCheck.cpp | 28 +++
 .../checkers/modernize/use-std-format-fmt.cpp |  2 +-
 .../deprecation-global-option.cpp |  3 ++
 3 files changed, 21 insertions(+), 12 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/infrastructure/deprecation-global-option.cpp

diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 6028bb2258136b..6e190101b220cf 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -7,11 +7,11 @@
 
//===--===//
 
 #include "ClangTidyCheck.h"
-#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Error.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/YAMLParser.h"
 #include 
+#include 
 
 namespace clang::tidy {
 
@@ -62,16 +62,25 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const 
{
   return std::nullopt;
 }
 
+static const llvm::StringSet<> AllowedGlobalOption{"IncludeStyle"};
+
 static ClangTidyOptions::OptionMap::const_iterator
 findPriorityOption(const ClangTidyOptions::OptionMap &Options,
StringRef NamePrefix, StringRef LocalName,
-   llvm::StringSet<> *Collector) {
+   ClangTidyContext *Context) {
+  llvm::StringSet<> *Collector = Context->getOptionsCollector();
   if (Collector) {
 Collector->insert((NamePrefix + LocalName).str());
 Collector->insert(LocalName);
   }
   auto IterLocal = Options.find((NamePrefix + LocalName).str());
   auto IterGlobal = Options.find(LocalName);
+  // FIXME: temporary solution for deprecation warnings, should be removed
+  // after 22.x.
+  if (IterGlobal != Options.end() && !AllowedGlobalOption.contains(LocalName))
+Context->configurationDiag(
+"deprecation global option '%0', please use '%1%0'.")
+<< LocalName << NamePrefix;
   if (IterLocal == Options.end())
 return IterGlobal;
   if (IterGlobal == Options.end())
@@ -83,8 +92,7 @@ findPriorityOption(const ClangTidyOptions::OptionMap &Options,
 
 std::optional
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
-  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName,
- Context->getOptionsCollector());
+  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
   if (Iter != CheckOptions.end())
 return StringRef(Iter->getValue().Value);
   return std::nullopt;
@@ -117,8 +125,7 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) 
const {
 template <>
 std::optional
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const 
{
-  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName,
- Context->getOptionsCollector());
+  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
   if (Iter != CheckOptions.end()) {
 if (auto Result = getAsBool(Iter->getValue().Value, Iter->getKey()))
   return Result;
@@ -157,10 +164,9 @@ std::optional 
ClangTidyCheck::OptionsView::getEnumInt(
 bool IgnoreCase) const {
   if (!CheckGlobal && Context->getOptionsCollector())
 Context->getOptionsCollector()->insert((NamePrefix + LocalName).str());
-  auto Iter = CheckGlobal
-  ? findPriorityOption(CheckOptions, NamePrefix, LocalName,
-   Context->getOptionsCollector())
-  : CheckOptions.find((NamePrefix + LocalName).str());
+  auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix,
+   LocalName, Context)
+  : CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter == CheckOptions.end())
 return std::nullopt;
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
index 1eaf18ac119966..71c8af190467cf 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-use-std-format %t -- \
 // RUN:   -config="{CheckOptions: { \
-// RUN:  StrictMode: true, \
+// RUN:  modernize-use-st

[clang-tools-extra] [clang-tidy] add depercation warning for non-whitelisted global options (PR #121057)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




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

Author: Congcong Cai (HerrCai0907)


Changes

We plan to depercate `StrictMode` and `IgnoreMacros` global options after 2 
major versions and support local options only for them.
This patch introduces the depercation warning.


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


3 Files Affected:

- (modified) clang-tools-extra/clang-tidy/ClangTidyCheck.cpp (+17-11) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp 
(+1-1) 
- (added) 
clang-tools-extra/test/clang-tidy/infrastructure/deprecation-global-option.cpp 
(+3) 


``diff
diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 6028bb2258136b..6e190101b220cf 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -7,11 +7,11 @@
 
//===--===//
 
 #include "ClangTidyCheck.h"
-#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Error.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/YAMLParser.h"
 #include 
+#include 
 
 namespace clang::tidy {
 
@@ -62,16 +62,25 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const 
{
   return std::nullopt;
 }
 
+static const llvm::StringSet<> AllowedGlobalOption{"IncludeStyle"};
+
 static ClangTidyOptions::OptionMap::const_iterator
 findPriorityOption(const ClangTidyOptions::OptionMap &Options,
StringRef NamePrefix, StringRef LocalName,
-   llvm::StringSet<> *Collector) {
+   ClangTidyContext *Context) {
+  llvm::StringSet<> *Collector = Context->getOptionsCollector();
   if (Collector) {
 Collector->insert((NamePrefix + LocalName).str());
 Collector->insert(LocalName);
   }
   auto IterLocal = Options.find((NamePrefix + LocalName).str());
   auto IterGlobal = Options.find(LocalName);
+  // FIXME: temporary solution for deprecation warnings, should be removed
+  // after 22.x.
+  if (IterGlobal != Options.end() && !AllowedGlobalOption.contains(LocalName))
+Context->configurationDiag(
+"deprecation global option '%0', please use '%1%0'.")
+<< LocalName << NamePrefix;
   if (IterLocal == Options.end())
 return IterGlobal;
   if (IterGlobal == Options.end())
@@ -83,8 +92,7 @@ findPriorityOption(const ClangTidyOptions::OptionMap &Options,
 
 std::optional
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
-  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName,
- Context->getOptionsCollector());
+  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
   if (Iter != CheckOptions.end())
 return StringRef(Iter->getValue().Value);
   return std::nullopt;
@@ -117,8 +125,7 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) 
const {
 template <>
 std::optional
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const 
{
-  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName,
- Context->getOptionsCollector());
+  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
   if (Iter != CheckOptions.end()) {
 if (auto Result = getAsBool(Iter->getValue().Value, Iter->getKey()))
   return Result;
@@ -157,10 +164,9 @@ std::optional 
ClangTidyCheck::OptionsView::getEnumInt(
 bool IgnoreCase) const {
   if (!CheckGlobal && Context->getOptionsCollector())
 Context->getOptionsCollector()->insert((NamePrefix + LocalName).str());
-  auto Iter = CheckGlobal
-  ? findPriorityOption(CheckOptions, NamePrefix, LocalName,
-   Context->getOptionsCollector())
-  : CheckOptions.find((NamePrefix + LocalName).str());
+  auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix,
+   LocalName, Context)
+  : CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter == CheckOptions.end())
 return std::nullopt;
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
index 1eaf18ac119966..71c8af190467cf 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-use-std-format %t -- \
 // RUN:   -config="{CheckOptions: { \
-// RUN:  StrictMode: true, \
+// RUN:  modernize-use-std-format.StrictMode: true, \
 // RUN:  modernize-use-std-format.StrFormatLikeFunctions: 
'fmt::sprintf', \
 // RUN:  modernize-use-std-format.Repla

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Stephen Senran Zhang via cfe-commits

https://github.com/zsrkmyn updated 
https://github.com/llvm/llvm-project/pull/120352

>From 80ee70143f6754f53fc11d5d013bf571856c090c Mon Sep 17 00:00:00 2001
From: Senran Zhang 
Date: Tue, 17 Dec 2024 16:15:25 +0800
Subject: [PATCH] [ConstantRange] Estimate tighter lower (upper) bounds for
 masked binary and (or)

Co-author: Yingwei Zheng (@dtcxzyw)
---
 clang/test/CodeGen/AArch64/fpm-helpers.c  | 18 ++--
 llvm/lib/IR/ConstantRange.cpp | 76 ++--
 .../SCCP/range-and-or-bit-masked.ll   | 88 +++
 llvm/unittests/IR/ConstantRangeTest.cpp   | 16 
 4 files changed, 183 insertions(+), 15 deletions(-)
 create mode 100644 llvm/test/Transforms/SCCP/range-and-or-bit-masked.ll

diff --git a/clang/test/CodeGen/AArch64/fpm-helpers.c 
b/clang/test/CodeGen/AArch64/fpm-helpers.c
index 4bced01d5c71fa..6264b5caeb4f50 100644
--- a/clang/test/CodeGen/AArch64/fpm-helpers.c
+++ b/clang/test/CodeGen/AArch64/fpm-helpers.c
@@ -35,7 +35,7 @@ extern "C" {
 //
 fpm_t test_init() { return __arm_fpm_init(); }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_src1_1(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -6) i64 @test_src1_1(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 -8
@@ -44,7 +44,7 @@ fpm_t test_src1_1() {
   return __arm_set_fpm_src1_format(INIT_ONES, __ARM_FPM_E5M2);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_src1_2(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -6) i64 @test_src1_2(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 1
@@ -53,7 +53,7 @@ fpm_t test_src1_2() {
   return __arm_set_fpm_src1_format(INIT_ZERO, __ARM_FPM_E4M3);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_src2_1(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -48) i64 @test_src2_1(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 -57
@@ -62,7 +62,7 @@ fpm_t test_src2_1() {
   return __arm_set_fpm_src2_format(INIT_ONES, __ARM_FPM_E5M2);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_src2_2(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -48) i64 @test_src2_2(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 8
@@ -71,7 +71,7 @@ fpm_t test_src2_2() {
   return __arm_set_fpm_src2_format(INIT_ZERO, __ARM_FPM_E4M3);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_dst1_1(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -384) i64 @test_dst1_1(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 -449
@@ -80,7 +80,7 @@ fpm_t test_dst1_1() {
   return __arm_set_fpm_dst_format(INIT_ONES, __ARM_FPM_E5M2);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_dst2_2(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -384) i64 @test_dst2_2(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 64
@@ -139,21 +139,21 @@ fpm_t test_lscale() { return 
__arm_set_fpm_lscale(INIT_ZERO, 127); }
 //
 fpm_t test_lscale2() { return __arm_set_fpm_lscale2(INIT_ZERO, 63); }
 
-// CHECK-LABEL: define dso_local noundef range(i64 0, 4294967296) i64 
@test_nscale_1(
+// CHECK-LABEL: define dso_local noundef range(i64 0, 4278190081) i64 
@test_nscale_1(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 2147483648
 //
 fpm_t test_nscale_1() { return __arm_set_fpm_nscale(INIT_ZERO, -128); }
 
-// CHECK-LABEL: define dso_local noundef range(i64 0, 4294967296) i64 
@test_nscale_2(
+// CHECK-LABEL: define dso_local noundef range(i64 0, 4278190081) i64 
@test_nscale_2(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 2130706432
 //
 fpm_t test_nscale_2() { return __arm_set_fpm_nscale(INIT_ZERO, 127); }
 
-// CHECK-LABEL: define dso_local noundef range(i64 0, 4294967296) i64 
@test_nscale_3(
+// CHECK-LABEL: define dso_local noundef range(i64 0, 4278190081) i64 
@test_nscale_3(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 4278190080
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index d81a292916fdea..8b36d72b7105b7 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'00101'1,  ; LLo
+///  10'1'0]  ; LHi
+///   RHS = [10'1'0,  ; RLo
+///  10'1'1]  ; RHi
+///
+/// we know that the higher 2 bits of the

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Stephen Senran Zhang via cfe-commits

zsrkmyn wrote:

Test updated.

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


[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

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


@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'00101'1,  ; LLo
+///  10'1'0]  ; LHi
+///   RHS = [10'1'0,  ; RLo
+///  10'1'1]  ; RHi
+///
+/// we know that the higher 2 bits of the result is always 10; and we also
+/// notice that RHS[1:6] are always 1, so the result[1:6] can no be less than
+/// LHS[1:6] (i.e., 00101). Thus, the lower bound is 10'00101'0.
+///
+/// The algorithm is as follows,
+/// 1. we first calculate a mask to find the higher common bits by
+///   Mask = ~((LLo ^ LHi) | (LLo ^ LHi) | (LLo ^ RLo));
+///   Mask = clear all non-leading-ones bits in Mask;
+///in the example, the Mask is set to 11'0'0;
+/// 2. calculate a new mask by setting all common leading bits to 1 in RHS, and
+///keeping the longest leading ones (i.e., 11'1'0 in the example).
+/// 3. return (LLo & new mask) as the lower bound;
+/// 4. repeat the step 2 and 3 with LHS and RHS swapped, and update the lower
+///bound with the larger one.
+static APInt estimateBitMaskedAndLowerBound(const ConstantRange &LHS,
+const ConstantRange &RHS) {
+  auto BitWidth = LHS.getBitWidth();
+  // If either is full set or unsigned wrapped, then the range must contain '0'
+  // which leads the lower bound to 0.
+  if ((LHS.isFullSet() || RHS.isFullSet()) ||
+  (LHS.isWrappedSet() || RHS.isWrappedSet()))
+return APInt::getZero(BitWidth);
+
+  auto LLo = LHS.getLower();
+  auto LHi = LHS.getUpper() - 1;
+  auto RLo = RHS.getLower();
+  auto RHi = RHS.getUpper() - 1;
+
+  // Calculate the mask for the higher common bits.
+  auto Mask = ~((LLo ^ LHi) | (RLo ^ RHi) | (LLo ^ RLo));
+  unsigned LeadingOnes = Mask.countLeadingOnes();
+  Mask.clearLowBits(BitWidth - LeadingOnes);
+
+  auto estimateBound = [BitWidth, &Mask](APInt ALo, const APInt &BLo,
+ const APInt &BHi) {
+unsigned LeadingOnes = ((BLo & BHi) | Mask).countLeadingOnes();
+unsigned StartBit = BitWidth - LeadingOnes;
+ALo.clearLowBits(StartBit);

dtcxzyw wrote:

Use `ALo.clearHighBits(LeadingOnes)`?


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


[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

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


@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'00101'1,  ; LLo
+///  10'1'0]  ; LHi
+///   RHS = [10'1'0,  ; RLo
+///  10'1'1]  ; RHi
+///
+/// we know that the higher 2 bits of the result is always 10; and we also
+/// notice that RHS[1:6] are always 1, so the result[1:6] can no be less than

dtcxzyw wrote:

```suggestion
/// notice that RHS[1:6] are always 1, so the result[1:6] cannot be less than
```

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


[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

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


@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'00101'1,  ; LLo
+///  10'1'0]  ; LHi
+///   RHS = [10'1'0,  ; RLo
+///  10'1'1]  ; RHi
+///
+/// we know that the higher 2 bits of the result is always 10; and we also
+/// notice that RHS[1:6] are always 1, so the result[1:6] can no be less than
+/// LHS[1:6] (i.e., 00101). Thus, the lower bound is 10'00101'0.
+///
+/// The algorithm is as follows,
+/// 1. we first calculate a mask to find the higher common bits by
+///   Mask = ~((LLo ^ LHi) | (LLo ^ LHi) | (LLo ^ RLo));
+///   Mask = clear all non-leading-ones bits in Mask;
+///in the example, the Mask is set to 11'0'0;
+/// 2. calculate a new mask by setting all common leading bits to 1 in RHS, and
+///keeping the longest leading ones (i.e., 11'1'0 in the example).
+/// 3. return (LLo & new mask) as the lower bound;
+/// 4. repeat the step 2 and 3 with LHS and RHS swapped, and update the lower
+///bound with the larger one.
+static APInt estimateBitMaskedAndLowerBound(const ConstantRange &LHS,
+const ConstantRange &RHS) {
+  auto BitWidth = LHS.getBitWidth();
+  // If either is full set or unsigned wrapped, then the range must contain '0'
+  // which leads the lower bound to 0.
+  if ((LHS.isFullSet() || RHS.isFullSet()) ||
+  (LHS.isWrappedSet() || RHS.isWrappedSet()))
+return APInt::getZero(BitWidth);
+
+  auto LLo = LHS.getLower();
+  auto LHi = LHS.getUpper() - 1;
+  auto RLo = RHS.getLower();
+  auto RHi = RHS.getUpper() - 1;
+
+  // Calculate the mask for the higher common bits.
+  auto Mask = ~((LLo ^ LHi) | (RLo ^ RHi) | (LLo ^ RLo));
+  unsigned LeadingOnes = Mask.countLeadingOnes();
+  Mask.clearLowBits(BitWidth - LeadingOnes);

dtcxzyw wrote:

Use `Mask.clearHighBits(Mask.countLeadingOnes())`?


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


[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

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

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


[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

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

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

LGTM. Thank you!
Please update the PR description and wait for additional approval from other 
reviewers.


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


[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Stephen Senran Zhang via cfe-commits


@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'00101'1,  ; LLo
+///  10'1'0]  ; LHi
+///   RHS = [10'1'0,  ; RLo
+///  10'1'1]  ; RHi
+///
+/// we know that the higher 2 bits of the result is always 10; and we also
+/// notice that RHS[1:6] are always 1, so the result[1:6] can no be less than
+/// LHS[1:6] (i.e., 00101). Thus, the lower bound is 10'00101'0.
+///
+/// The algorithm is as follows,
+/// 1. we first calculate a mask to find the higher common bits by
+///   Mask = ~((LLo ^ LHi) | (LLo ^ LHi) | (LLo ^ RLo));
+///   Mask = clear all non-leading-ones bits in Mask;
+///in the example, the Mask is set to 11'0'0;
+/// 2. calculate a new mask by setting all common leading bits to 1 in RHS, and
+///keeping the longest leading ones (i.e., 11'1'0 in the example).
+/// 3. return (LLo & new mask) as the lower bound;
+/// 4. repeat the step 2 and 3 with LHS and RHS swapped, and update the lower
+///bound with the larger one.
+static APInt estimateBitMaskedAndLowerBound(const ConstantRange &LHS,
+const ConstantRange &RHS) {
+  auto BitWidth = LHS.getBitWidth();
+  // If either is full set or unsigned wrapped, then the range must contain '0'
+  // which leads the lower bound to 0.
+  if ((LHS.isFullSet() || RHS.isFullSet()) ||
+  (LHS.isWrappedSet() || RHS.isWrappedSet()))
+return APInt::getZero(BitWidth);
+
+  auto LLo = LHS.getLower();
+  auto LHi = LHS.getUpper() - 1;
+  auto RLo = RHS.getLower();
+  auto RHi = RHS.getUpper() - 1;
+
+  // Calculate the mask for the higher common bits.
+  auto Mask = ~((LLo ^ LHi) | (RLo ^ RHi) | (LLo ^ RLo));
+  unsigned LeadingOnes = Mask.countLeadingOnes();
+  Mask.clearLowBits(BitWidth - LeadingOnes);
+
+  auto estimateBound = [BitWidth, &Mask](APInt ALo, const APInt &BLo,
+ const APInt &BHi) {
+unsigned LeadingOnes = ((BLo & BHi) | Mask).countLeadingOnes();
+unsigned StartBit = BitWidth - LeadingOnes;
+ALo.clearLowBits(StartBit);

zsrkmyn wrote:

Sorry, but can you elaborate it? I'm afraid they're not same.

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


[clang] [clang-format] Skip line splices when sorting C++ includes (PR #120680)

2024-12-24 Thread via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] fix incorrect argument names in documentation for ExtraArgs and ExtraArgsBefore (PR #120963)

2024-12-24 Thread via cfe-commits

float3 wrote:

I adjusted headerfilterregex as well as per 
https://github.com/llvm/llvm-project/pull/111405

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


[clang-tools-extra] [clang-tidy] fix incorrect argument names in documentation for ExtraArgs and ExtraArgsBefore (PR #120963)

2024-12-24 Thread via cfe-commits

https://github.com/float3 updated 
https://github.com/llvm/llvm-project/pull/120963

>From 5f4415685c116e4b05759b46186c34e210b7b7a3 Mon Sep 17 00:00:00 2001
From: hill 
Date: Mon, 23 Dec 2024 14:21:46 +0100
Subject: [PATCH 1/2] [clang-tidy] fix incorrect argument names in
 documentation for ExtraArgs and ExtraArgsBefore

---
 clang-tools-extra/docs/clang-tidy/index.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/index.rst 
b/clang-tools-extra/docs/clang-tidy/index.rst
index f053e57e8d4c84..2d23ee57c681ec 100644
--- a/clang-tools-extra/docs/clang-tidy/index.rst
+++ b/clang-tools-extra/docs/clang-tidy/index.rst
@@ -282,8 +282,8 @@ An overview of all the command-line options:
globs can be specified as a list instead of 
a
string.
 ExcludeHeaderFilterRegex - Same as '--exclude-header-filter'.
-ExtraArgs- Same as '--extra-args'.
-ExtraArgsBefore  - Same as '--extra-args-before'.
+ExtraArgs- Same as '--extra-arg'.
+ExtraArgsBefore  - Same as '--extra-arg-before'.
 FormatStyle  - Same as '--format-style'.
 HeaderFileExtensions - File extensions to consider to determine if 
a
given diagnostic is located in a header 
file.

>From c02bd7dae6d89587a627c2230cd77bdb5159777b Mon Sep 17 00:00:00 2001
From: hill 
Date: Tue, 24 Dec 2024 09:01:09 +
Subject: [PATCH 2/2] [clang-tidy] sync clangtidymain.cpp

---
 clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index b8d843cba71330..6e41f04f24951f 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -54,12 +54,12 @@ Configuration files:
  globs can be specified as a list instead of a
  string.
   ExcludeHeaderFilterRegex - Same as '--exclude-header-filter'.
-  ExtraArgs- Same as '--extra-args'.
-  ExtraArgsBefore  - Same as '--extra-args-before'.
+  ExtraArgs- Same as '--extra-arg'.
+  ExtraArgsBefore  - Same as '--extra-arg-before'.
   FormatStyle  - Same as '--format-style'.
   HeaderFileExtensions - File extensions to consider to determine if a
  given diagnostic is located in a header file.
-  HeaderFilterRegex- Same as '--header-filter-regex'.
+  HeaderFilterRegex- Same as '--header-filter'.
   ImplementationFileExtensions - File extensions to consider to determine if a
  given diagnostic is located in an
  implementation file.

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


[clang] [llvm] Clang/buildFMulAdd: Use negated attribute (PR #121038)

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

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/121038

Use negated attribute if negMul or negAdd. So that we can lower
fneg+fmuladd to fmul+fsub if needed.

1) It can save one machine instruction:
fneg/fmul/fadd vs fmul/fsub
2) In strict mode, `c-a*b` may be different with `c+(-a)*b`.

>From c474a905f473d0844caf6ad7dd7b6ff338d01d34 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Tue, 24 Dec 2024 04:16:16 +
Subject: [PATCH 1/6] Support attribute negated

---
 llvm/docs/LangRef.rst |  8 
 llvm/include/llvm/Bitcode/LLVMBitCodes.h  |  1 +
 llvm/include/llvm/IR/Attributes.td|  3 +++
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp |  2 ++
 .../SelectionDAG/SelectionDAGBuilder.cpp  | 20 ++-
 llvm/lib/Transforms/Utils/CodeExtractor.cpp   |  1 +
 6 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7e01331b20c570..9e5f39530b1679 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1573,6 +1573,14 @@ Currently, only the following parameter attributes are 
defined:
 | pinf  | Positive infinity|   512 |
 +---+--+---+
 
+``negated``
+The function parameter marked with this attribute is negated from
+its opposite number by the frontend like Clang. The middle end or
+backend should convert it back if possible. For example, `c-a*b`
+is different with `c+(-a)*b`. Since we have only `fmuladd`,
+this attribute on `a` is to mark that we are working on `c-a*b`.
+So that we can convert `c+(-a)*b` to `fmsub` instruction
+or `fmul`/`fsub`.
 
 ``alignstack()``
 This indicates the alignment that should be considered by the backend when
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h 
b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 21fd27d9838db7..7e9d174db22026 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -788,6 +788,7 @@ enum AttributeKindCodes {
   ATTR_KIND_NO_EXT = 99,
   ATTR_KIND_NO_DIVERGENCE_SOURCE = 100,
   ATTR_KIND_SANITIZE_TYPE = 101,
+  ATTR_KIND_NEGATED = 102,
 };
 
 enum ComdatSelectionKindCodes {
diff --git a/llvm/include/llvm/IR/Attributes.td 
b/llvm/include/llvm/IR/Attributes.td
index 61955cf883c3f1..baeca5d53f3c46 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -162,6 +162,9 @@ def Memory : IntAttr<"memory", IntersectCustom, [FnAttr]>;
 /// Forbidden floating-point classes.
 def NoFPClass : IntAttr<"nofpclass", IntersectCustom, [ParamAttr, RetAttr]>;
 
+/// Converted from the opposite number
+def Negated : EnumAttr<"negated", IntersectAnd, [ParamAttr, RetAttr]>;
+
 /// Function must be optimized for size first.
 def MinSize : EnumAttr<"minsize", IntersectPreserve, [FnAttr]>;
 
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp 
b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index b4efd3928a2e6f..e87c9d2e13883d 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -755,6 +755,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind 
Kind) {
 return bitc::ATTR_KIND_MEMORY;
   case Attribute::NoFPClass:
 return bitc::ATTR_KIND_NOFPCLASS;
+  case Attribute::Negated:
+return bitc::ATTR_KIND_NEGATED;
   case Attribute::Naked:
 return bitc::ATTR_KIND_NAKED;
   case Attribute::Nest:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index f8d7c3ef7bbe71..a9de7e25a4eb6a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -8360,10 +8360,28 @@ void SelectionDAGBuilder::visitConstrainedFPIntrinsic(
 // Break fmuladd into fmul and fadd.
 if (TM.Options.AllowFPOpFusion == FPOpFusion::Strict ||
 !TLI.isFMAFasterThanFMulAndFAdd(DAG.getMachineFunction(), VT)) {
+  auto PrevNode = FPI.getPrevNode();
+  bool convertToFMULSUB = false;
+  if (PrevNode && PrevNode->getOpcode() == Instruction::FNeg) {
+if (PrevNode->getName() == FPI.getOperand(0)->getName() &&
+FPI.getAttributes().getParamAttrs(0).hasAttribute(
+Attribute::Negated)) {
+  Opers[1] = DAG.getNode(ISD::FNEG, sdl, VT, Opers[1]).getValue(0);
+  convertToFMULSUB = true;
+} else if (PrevNode->getName() == FPI.getOperand(1)->getName() &&
+   FPI.getAttributes().getParamAttrs(1).hasAttribute(
+   Attribute::Negated)) {
+  Opers[2] = DAG.getNode(ISD::FNEG, sdl, VT, Opers[2]).getValue(0);
+  convertToFMULSUB = true;
+}
+  }
   Opers.pop_back();
   SDValue Mul = DAG.getNode(ISD::STRICT_FMUL, sdl, VTs, Opers, Flags);
   pushOutChain(Mul, EB);
-  Opcode = ISD::STRICT_FADD;
+  if (convertToFMULSUB)
+Opcode = 

[clang] [llvm] Clang/buildFMulAdd: Use negated attribute (PR #121038)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: YunQiang Su (wzssyqa)


Changes

Use negated attribute if negMul or negAdd. So that we can lower
fneg+fmuladd to fmul+fsub if needed.

1) It can save one machine instruction:
fneg/fmul/fadd vs fmul/fsub
2) In strict mode, `c-a*b` may be different with `c+(-a)*b`.

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


7 Files Affected:

- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+4) 
- (modified) clang/test/CodeGen/constrained-math-builtins.c (+3-3) 
- (modified) llvm/docs/LangRef.rst (+6) 
- (modified) llvm/include/llvm/Bitcode/LLVMBitCodes.h (+1) 
- (modified) llvm/include/llvm/IR/Attributes.td (+3) 
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+2) 
- (modified) llvm/lib/Transforms/Utils/CodeExtractor.cpp (+1) 


``diff
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 4b71bd730ce12c..14d73de055d8ec 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4120,6 +4120,10 @@ static Value* buildFMulAdd(llvm::Instruction *MulOp, 
Value *Addend,
 CGF.CGM.getIntrinsic(llvm::Intrinsic::experimental_constrained_fmuladd,
  Addend->getType()),
 {MulOp0, MulOp1, Addend});
+if (negMul)
+  dyn_cast(FMulAdd)->addParamAttr(0, 
llvm::Attribute::Negated);
+if (negAdd)
+  dyn_cast(FMulAdd)->addParamAttr(2, 
llvm::Attribute::Negated);
   } else {
 FMulAdd = Builder.CreateCall(
 CGF.CGM.getIntrinsic(llvm::Intrinsic::fmuladd, Addend->getType()),
diff --git a/clang/test/CodeGen/constrained-math-builtins.c 
b/clang/test/CodeGen/constrained-math-builtins.c
index 68b9e75283c547..f044f15e98918b 100644
--- a/clang/test/CodeGen/constrained-math-builtins.c
+++ b/clang/test/CodeGen/constrained-math-builtins.c
@@ -392,12 +392,12 @@ void bar(float f) {
 
   // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
   // CHECK: fneg
-  // CHECK: call double @llvm.experimental.constrained.fmuladd.f64(double 
%{{.*}}, double %{{.*}}, double %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call double @llvm.experimental.constrained.fmuladd.f64(double 
%{{.*}}, double %{{.*}}, double negated %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
   // CHECK: fneg
   // CHECK: call x86_fp80 @llvm.experimental.constrained.fmuladd.f80(x86_fp80 
%{{.*}}, x86_fp80 %{{.*}}, x86_fp80 %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
   // CHECK: fneg
   // CHECK: fneg
-  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
negated %{{.*}}, float %{{.*}}, float negated %{{.*}}, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: fneg
-  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
negated %{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
 };
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7e01331b20c570..bf37e6a788c4b6 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1573,6 +1573,12 @@ Currently, only the following parameter attributes are 
defined:
 | pinf  | Positive infinity|   512 |
 +---+--+---+
 
+``negated``
+The function parameter marked with this attribute is negated from
+its opposite number by the frontend like Clang. The middle end or
+backend should convert it back if possible. For example if -(a*b)
+is converted to (-a)*b, the arg0 of `fmul` instruction should be
+marked with `negated` attribute.
 
 ``alignstack()``
 This indicates the alignment that should be considered by the backend when
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h 
b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 21fd27d9838db7..7e9d174db22026 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -788,6 +788,7 @@ enum AttributeKindCodes {
   ATTR_KIND_NO_EXT = 99,
   ATTR_KIND_NO_DIVERGENCE_SOURCE = 100,
   ATTR_KIND_SANITIZE_TYPE = 101,
+  ATTR_KIND_NEGATED = 102,
 };
 
 enum ComdatSelectionKindCodes {
diff --git a/llvm/include/llvm/IR/Attributes.td 
b/llvm/include/llvm/IR/Attributes.td
index 61955cf883c3f1..baeca5d53f3c46 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -162,6 +162,9 @@ def Memory : IntAttr<"memory", IntersectCustom, [FnAttr]>;
 /// Forbidden floating-po

[clang] [llvm] Clang/buildFMulAdd: Use negated attribute (PR #121038)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: YunQiang Su (wzssyqa)


Changes

Use negated attribute if negMul or negAdd. So that we can lower
fneg+fmuladd to fmul+fsub if needed.

1) It can save one machine instruction:
fneg/fmul/fadd vs fmul/fsub
2) In strict mode, `c-a*b` may be different with `c+(-a)*b`.

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


7 Files Affected:

- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+4) 
- (modified) clang/test/CodeGen/constrained-math-builtins.c (+3-3) 
- (modified) llvm/docs/LangRef.rst (+6) 
- (modified) llvm/include/llvm/Bitcode/LLVMBitCodes.h (+1) 
- (modified) llvm/include/llvm/IR/Attributes.td (+3) 
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+2) 
- (modified) llvm/lib/Transforms/Utils/CodeExtractor.cpp (+1) 


``diff
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 4b71bd730ce12c..14d73de055d8ec 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4120,6 +4120,10 @@ static Value* buildFMulAdd(llvm::Instruction *MulOp, 
Value *Addend,
 CGF.CGM.getIntrinsic(llvm::Intrinsic::experimental_constrained_fmuladd,
  Addend->getType()),
 {MulOp0, MulOp1, Addend});
+if (negMul)
+  dyn_cast(FMulAdd)->addParamAttr(0, 
llvm::Attribute::Negated);
+if (negAdd)
+  dyn_cast(FMulAdd)->addParamAttr(2, 
llvm::Attribute::Negated);
   } else {
 FMulAdd = Builder.CreateCall(
 CGF.CGM.getIntrinsic(llvm::Intrinsic::fmuladd, Addend->getType()),
diff --git a/clang/test/CodeGen/constrained-math-builtins.c 
b/clang/test/CodeGen/constrained-math-builtins.c
index 68b9e75283c547..f044f15e98918b 100644
--- a/clang/test/CodeGen/constrained-math-builtins.c
+++ b/clang/test/CodeGen/constrained-math-builtins.c
@@ -392,12 +392,12 @@ void bar(float f) {
 
   // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
   // CHECK: fneg
-  // CHECK: call double @llvm.experimental.constrained.fmuladd.f64(double 
%{{.*}}, double %{{.*}}, double %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call double @llvm.experimental.constrained.fmuladd.f64(double 
%{{.*}}, double %{{.*}}, double negated %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
   // CHECK: fneg
   // CHECK: call x86_fp80 @llvm.experimental.constrained.fmuladd.f80(x86_fp80 
%{{.*}}, x86_fp80 %{{.*}}, x86_fp80 %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
   // CHECK: fneg
   // CHECK: fneg
-  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
negated %{{.*}}, float %{{.*}}, float negated %{{.*}}, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: fneg
-  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
negated %{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
 };
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7e01331b20c570..bf37e6a788c4b6 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1573,6 +1573,12 @@ Currently, only the following parameter attributes are 
defined:
 | pinf  | Positive infinity|   512 |
 +---+--+---+
 
+``negated``
+The function parameter marked with this attribute is negated from
+its opposite number by the frontend like Clang. The middle end or
+backend should convert it back if possible. For example if -(a*b)
+is converted to (-a)*b, the arg0 of `fmul` instruction should be
+marked with `negated` attribute.
 
 ``alignstack()``
 This indicates the alignment that should be considered by the backend when
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h 
b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 21fd27d9838db7..7e9d174db22026 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -788,6 +788,7 @@ enum AttributeKindCodes {
   ATTR_KIND_NO_EXT = 99,
   ATTR_KIND_NO_DIVERGENCE_SOURCE = 100,
   ATTR_KIND_SANITIZE_TYPE = 101,
+  ATTR_KIND_NEGATED = 102,
 };
 
 enum ComdatSelectionKindCodes {
diff --git a/llvm/include/llvm/IR/Attributes.td 
b/llvm/include/llvm/IR/Attributes.td
index 61955cf883c3f1..baeca5d53f3c46 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -162,6 +162,9 @@ def Memory : IntAttr<"memory", IntersectCustom, [FnAttr]>;
 /// Forbidden floating-point classe

[clang] [clang] Fix issue #117960 (PR #121039)

2024-12-24 Thread via cfe-commits

https://github.com/thebrandre created 
https://github.com/llvm/llvm-project/pull/121039

This commit fixes implicit integer conversions for  _opaque-enum-declarations_ 
inside a class template with a specified _enum-base_ (see [dcl.enum]).

Previously, the promotion type of the instantiated enum was set only in 
`Sema::ActOnEnumBody`, which is not called if there are no curly braces are 
after the enum-base. This fixes GitHub issue #117960.

>From 38eea8da39d50316061611dc0eefa471e282c7b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Brand?= 
Date: Tue, 24 Dec 2024 09:54:56 +0100
Subject: [PATCH] Fix implicit integer conversion for enum declared in class
 template

Previously, the promotion type of the instantiated enum was set only in 
`Sema::ActOnEnumBody`,
which is not called if there are no curly braces are after the enum-base.
This fixes GitHub issue #117960.
---
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  3 +
 .../SemaCXX/enum-base-in-class-template.cpp   | 66 +++
 2 files changed, 69 insertions(+)
 create mode 100644 clang/test/SemaCXX/enum-base-in-class-template.cpp

diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index e058afe81da589..4d39fd409795b6 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1620,6 +1620,9 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl 
*D) {
   if (isDeclWithinFunction(D) ? D == Def : Def && !Enum->isScoped()) {
 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Enum);
 InstantiateEnumDefinition(Enum, Def);
+  } else {
+if (D->isFixed() && !Def)
+  Enum->setPromotionType(Enum->getIntegerType());
   }
 
   return Enum;
diff --git a/clang/test/SemaCXX/enum-base-in-class-template.cpp 
b/clang/test/SemaCXX/enum-base-in-class-template.cpp
new file mode 100644
index 00..012bef9785cbaf
--- /dev/null
+++ b/clang/test/SemaCXX/enum-base-in-class-template.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only %s -verify
+
+// This program causes clang 19 and earlier to crash because
+// EnumDecl::PromotionType has not been set on the instantiated enum.
+// See GitHub Issue #117960.
+namespace Issue117960 {
+template 
+struct A {
+  enum E : T;
+};
+
+int b = A::E{} + 0;
+}
+
+
+namespace test {
+template 
+struct IsSame {
+  static constexpr bool check() { return false; }
+};
+
+template 
+struct IsSame {
+  static constexpr bool check() { return true; }
+};
+}  // namespace test
+
+
+template 
+struct S1 {
+  enum E : T;
+};
+// checks if EnumDecl::PromotionType is set
+int X1 = S1::E{} + 0;
+int Y1 = S1::E{} + 0;
+static_assert(test::IsSame::E{}+0), int>::check(), "");
+static_assert(test::IsSame::E{}+0), unsigned>::check(), 
"");
+char Z1 = S1::E(-1) + 0; // expected-warning{{implicit conversion 
from 'unsigned int' to 'char'}}
+
+template 
+struct S2 {
+  enum E : typename Traits::IntegerType;
+};
+
+template 
+struct Traits {
+  typedef T IntegerType;
+};
+
+int X2 = S2>::E{} + 0;
+int Y2 = S2>::E{} + 0;
+static_assert(test::IsSame>::E{}+0), int>::check(), 
"");
+static_assert(test::IsSame>::E{}+0), 
unsigned>::check(), "");
+
+
+template 
+struct S3 {
+  enum E : unsigned;
+};
+
+int X3 = S3::E{} + 0;
+
+// fails in clang 19 and earlier (see the discussion on GitHub Issue #117960):
+static_assert(test::IsSame::E{}+0), unsigned>::check(), "");
+

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


[clang] [llvm] Clang/buildFMulAdd: Use negated attribute (PR #121038)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: YunQiang Su (wzssyqa)


Changes

Use negated attribute if negMul or negAdd. So that we can lower
fneg+fmuladd to fmul+fsub if needed.

1) It can save one machine instruction:
fneg/fmul/fadd vs fmul/fsub
2) In strict mode, `c-a*b` may be different with `c+(-a)*b`.

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


7 Files Affected:

- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+4) 
- (modified) clang/test/CodeGen/constrained-math-builtins.c (+3-3) 
- (modified) llvm/docs/LangRef.rst (+6) 
- (modified) llvm/include/llvm/Bitcode/LLVMBitCodes.h (+1) 
- (modified) llvm/include/llvm/IR/Attributes.td (+3) 
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+2) 
- (modified) llvm/lib/Transforms/Utils/CodeExtractor.cpp (+1) 


``diff
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 4b71bd730ce12c..14d73de055d8ec 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4120,6 +4120,10 @@ static Value* buildFMulAdd(llvm::Instruction *MulOp, 
Value *Addend,
 CGF.CGM.getIntrinsic(llvm::Intrinsic::experimental_constrained_fmuladd,
  Addend->getType()),
 {MulOp0, MulOp1, Addend});
+if (negMul)
+  dyn_cast(FMulAdd)->addParamAttr(0, 
llvm::Attribute::Negated);
+if (negAdd)
+  dyn_cast(FMulAdd)->addParamAttr(2, 
llvm::Attribute::Negated);
   } else {
 FMulAdd = Builder.CreateCall(
 CGF.CGM.getIntrinsic(llvm::Intrinsic::fmuladd, Addend->getType()),
diff --git a/clang/test/CodeGen/constrained-math-builtins.c 
b/clang/test/CodeGen/constrained-math-builtins.c
index 68b9e75283c547..f044f15e98918b 100644
--- a/clang/test/CodeGen/constrained-math-builtins.c
+++ b/clang/test/CodeGen/constrained-math-builtins.c
@@ -392,12 +392,12 @@ void bar(float f) {
 
   // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
   // CHECK: fneg
-  // CHECK: call double @llvm.experimental.constrained.fmuladd.f64(double 
%{{.*}}, double %{{.*}}, double %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call double @llvm.experimental.constrained.fmuladd.f64(double 
%{{.*}}, double %{{.*}}, double negated %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
   // CHECK: fneg
   // CHECK: call x86_fp80 @llvm.experimental.constrained.fmuladd.f80(x86_fp80 
%{{.*}}, x86_fp80 %{{.*}}, x86_fp80 %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
   // CHECK: fneg
   // CHECK: fneg
-  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
negated %{{.*}}, float %{{.*}}, float negated %{{.*}}, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: fneg
-  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.strict")
+  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32(float 
negated %{{.*}}, float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", 
metadata !"fpexcept.strict")
 };
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7e01331b20c570..bf37e6a788c4b6 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1573,6 +1573,12 @@ Currently, only the following parameter attributes are 
defined:
 | pinf  | Positive infinity|   512 |
 +---+--+---+
 
+``negated``
+The function parameter marked with this attribute is negated from
+its opposite number by the frontend like Clang. The middle end or
+backend should convert it back if possible. For example if -(a*b)
+is converted to (-a)*b, the arg0 of `fmul` instruction should be
+marked with `negated` attribute.
 
 ``alignstack()``
 This indicates the alignment that should be considered by the backend when
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h 
b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 21fd27d9838db7..7e9d174db22026 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -788,6 +788,7 @@ enum AttributeKindCodes {
   ATTR_KIND_NO_EXT = 99,
   ATTR_KIND_NO_DIVERGENCE_SOURCE = 100,
   ATTR_KIND_SANITIZE_TYPE = 101,
+  ATTR_KIND_NEGATED = 102,
 };
 
 enum ComdatSelectionKindCodes {
diff --git a/llvm/include/llvm/IR/Attributes.td 
b/llvm/include/llvm/IR/Attributes.td
index 61955cf883c3f1..baeca5d53f3c46 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -162,6 +162,9 @@ def Memory : IntAttr<"memory", IntersectCustom, [FnAttr]>;
 /// Forbidden floating-poin

[clang] [llvm] Clang/buildFMulAdd: Use negated attribute (PR #121038)

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

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


[clang] [Clang][MIPS] Create specific targets for MIPS PE/COFF (PR #121040)

2024-12-24 Thread Hervé Poussineau via cfe-commits

https://github.com/hpoussin created 
https://github.com/llvm/llvm-project/pull/121040

Implement GNU and MSVC variants.
When using them, _WIN32 and _M_MRX000/_MIPS_ macros are correctly defined.

From cc5d9af37b0d78f4caeb05ce4f7203a8bcde644b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= 
Date: Sun, 22 Oct 2023 17:01:02 +0200
Subject: [PATCH] [Clang][MIPS] Create specific targets for MIPS PE/COFF

Implement GNU and MSVC variants.
When using them, _WIN32 and _M_MRX000/_MIPS_ macros are correctly defined.
---
 clang/lib/Basic/Targets.cpp   |  8 +++
 clang/lib/Basic/Targets/Mips.cpp  | 59 +++
 clang/lib/Basic/Targets/Mips.h| 37 
 .../test/Preprocessor/predefined-win-macros.c | 16 +
 4 files changed, 120 insertions(+)

diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 706a391023b3a3..d0815ad33bc759 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -297,6 +297,14 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::NaCl:
   return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::Win32:
+  switch (Triple.getEnvironment()) {
+  case llvm::Triple::GNU:
+return std::make_unique(Triple, Opts);
+  case llvm::Triple::MSVC:
+  default: // Assume MSVC for unknown environments
+return std::make_unique(Triple, Opts);
+  }
 default:
   return std::make_unique(Triple, Opts);
 }
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 174bc9d2ab9967..d56995e3ccc48e 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -304,3 +304,62 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
&Diags) const {
 
   return true;
 }
+
+WindowsMipsTargetInfo::WindowsMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsTargetInfo(Triple, Opts), Triple(Triple) {}
+
+void WindowsMipsTargetInfo::getVisualStudioDefines(
+const LangOptions &Opts, MacroBuilder &Builder) const {
+  Builder.defineMacro("_M_MRX000", "4000");
+}
+
+TargetInfo::BuiltinVaListKind
+WindowsMipsTargetInfo::getBuiltinVaListKind() const {
+  return TargetInfo::CharPtrBuiltinVaList;
+}
+
+TargetInfo::CallingConvCheckResult
+WindowsMipsTargetInfo::checkCallingConvention(CallingConv CC) const {
+  switch (CC) {
+  case CC_X86StdCall:
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;
+  case CC_C:
+  case CC_OpenCLKernel:
+  case CC_PreserveMost:
+  case CC_PreserveAll:
+  case CC_Swift:
+  case CC_SwiftAsync:
+return CCCR_OK;
+  default:
+return CCCR_Warning;
+  }
+}
+
+// Windows MIPS, MS (C++) ABI
+MicrosoftMipsTargetInfo::MicrosoftMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsMipsTargetInfo(Triple, Opts) {
+  TheCXXABI.set(TargetCXXABI::Microsoft);
+}
+
+void MicrosoftMipsTargetInfo::getTargetDefines(const LangOptions &Opts,
+   MacroBuilder &Builder) const {
+  WindowsMipsTargetInfo::getTargetDefines(Opts, Builder);
+  WindowsMipsTargetInfo::getVisualStudioDefines(Opts, Builder);
+}
+
+MinGWMipsTargetInfo::MinGWMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsMipsTargetInfo(Triple, Opts) {
+  TheCXXABI.set(TargetCXXABI::GenericMIPS);
+}
+
+void MinGWMipsTargetInfo::getTargetDefines(const LangOptions &Opts,
+   MacroBuilder &Builder) const {
+  WindowsMipsTargetInfo::getTargetDefines(Opts, Builder);
+  Builder.defineMacro("_MIPS_");
+}
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 8acaf56523b218..7ddcd57053cb2b 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
 
+#include "OSTargets.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/Support/Compiler.h"
@@ -450,6 +451,42 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 return std::make_pair(32, 32);
   }
 };
+
+class LLVM_LIBRARY_VISIBILITY WindowsMipsTargetInfo
+: public WindowsTargetInfo {
+  const llvm::Triple Triple;
+
+public:
+  WindowsMipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
+
+  void getVisualStudioDefines(const LangOptions &Opts,
+  MacroBuilder &Builder) const;
+
+  BuiltinVaListKind getBuiltinVaListKind() const override;
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
+};
+
+// Windows MIPS, MS (C++) ABI
+class LLVM_L

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

2024-12-24 Thread Hervé Poussineau via cfe-commits

https://github.com/hpoussin created 
https://github.com/llvm/llvm-project/pull/121041

None

From 63841bfbc4367d7ffca989d5cdecf74cdc32db2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= 
Date: Fri, 10 Nov 2023 23:06:52 +0100
Subject: [PATCH] [Clang][MIPS] Create correct linker arguments for Windows
 toolchains

---
 clang/lib/CodeGen/CodeGenModule.cpp |  2 ++
 clang/lib/CodeGen/TargetInfo.h  |  3 +++
 clang/lib/CodeGen/Targets/Mips.cpp  | 23 +++
 clang/test/CodeGen/pragma-comment.c |  1 +
 4 files changed, 29 insertions(+)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index c49f7631488285..2ec12eb8b7b04e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -119,6 +119,8 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
   case llvm::Triple::mipsel:
 if (Triple.getOS() == llvm::Triple::NaCl)
   return createPNaClTargetCodeGenInfo(CGM);
+else if (Triple.getOS() == llvm::Triple::Win32)
+  return createWindowsMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true);
 return createMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true);
 
   case llvm::Triple::mips64:
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index ab3142bdea684e..4a66683a3b91fd 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -522,6 +522,9 @@ createM68kTargetCodeGenInfo(CodeGenModule &CGM);
 std::unique_ptr
 createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
 
+std::unique_ptr
+createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
+
 std::unique_ptr
 createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
 
diff --git a/clang/lib/CodeGen/Targets/Mips.cpp 
b/clang/lib/CodeGen/Targets/Mips.cpp
index 06d9b6d4a57615..e7601564f67d1d 100644
--- a/clang/lib/CodeGen/Targets/Mips.cpp
+++ b/clang/lib/CodeGen/Targets/Mips.cpp
@@ -105,6 +105,24 @@ class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
 return SizeOfUnwindException;
   }
 };
+
+class WindowsMIPSTargetCodeGenInfo : public MIPSTargetCodeGenInfo {
+public:
+  WindowsMIPSTargetCodeGenInfo(CodeGenTypes &CGT, bool IsO32)
+: MIPSTargetCodeGenInfo(CGT, IsO32) {}
+
+  void getDependentLibraryOption(llvm::StringRef Lib,
+ llvm::SmallString<24> &Opt) const override {
+Opt = "/DEFAULTLIB:";
+Opt += qualifyWindowsLibrary(Lib);
+  }
+
+  void getDetectMismatchOption(llvm::StringRef Name,
+   llvm::StringRef Value,
+   llvm::SmallString<32> &Opt) const override {
+Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
+  }
+};
 }
 
 void MipsABIInfo::CoerceToIntArgs(
@@ -436,3 +454,8 @@ std::unique_ptr
 CodeGen::createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32) {
   return std::make_unique(CGM.getTypes(), IsOS32);
 }
+
+std::unique_ptr
+CodeGen::createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32) {
+  return std::make_unique(CGM.getTypes(), 
IsOS32);
+}
diff --git a/clang/test/CodeGen/pragma-comment.c 
b/clang/test/CodeGen/pragma-comment.c
index a4746f5c47bf6b..a966840f7c26fc 100644
--- a/clang/test/CodeGen/pragma-comment.c
+++ b/clang/test/CodeGen/pragma-comment.c
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -fms-extensions -emit-llvm -o - 
| FileCheck -check-prefix ELF %s --implicit-check-not llvm.linker.options
 // RUN: %clang_cc1 %s -triple x86_64-sie-ps5 -fms-extensions -emit-llvm -o - | 
FileCheck -check-prefix ELF %s --implicit-check-not llvm.linker.options
 // RUN: %clang_cc1 %s -triple aarch64-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple mipsel-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
 
 #pragma comment(lib, "msvcrt.lib")
 #pragma comment(lib, "kernel32")

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


[clang] [Clang][MIPS] Send correct architecture for MinGW toolchains (PR #121042)

2024-12-24 Thread Hervé Poussineau via cfe-commits

https://github.com/hpoussin created 
https://github.com/llvm/llvm-project/pull/121042

'mipspe' name was chosen by binutils, when the project was able to create 
executables for Windows CE/MIPS.

From 932c9cea721b45ffeee2e3f77be903241beab33a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= 
Date: Fri, 10 Nov 2023 23:09:05 +0100
Subject: [PATCH] [Clang][MIPS] Send correct architecture for MinGW toolchains

'mipspe' name was chosen by binutils, when the project was able to create
executables for Windows CE/MIPS.
---
 clang/lib/Driver/ToolChains/MinGW.cpp | 3 +++
 clang/test/Driver/mingw.cpp   | 4 
 2 files changed, 7 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 963de81027ca9f..9f0c6160a309ec 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -138,6 +138,9 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 else
   CmdArgs.push_back("arm64pe");
 break;
+  case llvm::Triple::mipsel:
+CmdArgs.push_back("mipspe");
+break;
   default:
 D.Diag(diag::err_target_unknown_triple) << TC.getEffectiveTriple().str();
   }
diff --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp
index 9790c86a364f85..66da0c97f41668 100644
--- a/clang/test/Driver/mingw.cpp
+++ b/clang/test/Driver/mingw.cpp
@@ -85,6 +85,10 @@
 // RUN:   | FileCheck %s --check-prefix CHECK_MINGW_EC_LINK
 // CHECK_MINGW_EC_LINK: "-m" "arm64ecpe"
 
+// RUN: %clang --target=mipsel-windows-gnu -### -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK_MINGW_MIPSPE
+// CHECK_MINGW_MIPSPE: "-m" "mipspe"
+
 // RUN: %clang --target=i686-windows-gnu -fms-hotpatch -### -- %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix=FUNCTIONPADMIN
 // FUNCTIONPADMIN: "--functionpadmin"

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


[clang] [Clang][MIPS] Send correct architecture for MinGW toolchains (PR #121042)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Hervé Poussineau (hpoussin)


Changes

'mipspe' name was chosen by binutils, when the project was able to create 
executables for Windows CE/MIPS.

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/MinGW.cpp (+3) 
- (modified) clang/test/Driver/mingw.cpp (+4) 


``diff
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 963de81027ca9f..9f0c6160a309ec 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -138,6 +138,9 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 else
   CmdArgs.push_back("arm64pe");
 break;
+  case llvm::Triple::mipsel:
+CmdArgs.push_back("mipspe");
+break;
   default:
 D.Diag(diag::err_target_unknown_triple) << TC.getEffectiveTriple().str();
   }
diff --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp
index 9790c86a364f85..66da0c97f41668 100644
--- a/clang/test/Driver/mingw.cpp
+++ b/clang/test/Driver/mingw.cpp
@@ -85,6 +85,10 @@
 // RUN:   | FileCheck %s --check-prefix CHECK_MINGW_EC_LINK
 // CHECK_MINGW_EC_LINK: "-m" "arm64ecpe"
 
+// RUN: %clang --target=mipsel-windows-gnu -### -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK_MINGW_MIPSPE
+// CHECK_MINGW_MIPSPE: "-m" "mipspe"
+
 // RUN: %clang --target=i686-windows-gnu -fms-hotpatch -### -- %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix=FUNCTIONPADMIN
 // FUNCTIONPADMIN: "--functionpadmin"

``




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


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

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Hervé Poussineau (hpoussin)


Changes



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


4 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+2) 
- (modified) clang/lib/CodeGen/TargetInfo.h (+3) 
- (modified) clang/lib/CodeGen/Targets/Mips.cpp (+23) 
- (modified) clang/test/CodeGen/pragma-comment.c (+1) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index c49f7631488285..2ec12eb8b7b04e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -119,6 +119,8 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
   case llvm::Triple::mipsel:
 if (Triple.getOS() == llvm::Triple::NaCl)
   return createPNaClTargetCodeGenInfo(CGM);
+else if (Triple.getOS() == llvm::Triple::Win32)
+  return createWindowsMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true);
 return createMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true);
 
   case llvm::Triple::mips64:
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index ab3142bdea684e..4a66683a3b91fd 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -522,6 +522,9 @@ createM68kTargetCodeGenInfo(CodeGenModule &CGM);
 std::unique_ptr
 createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
 
+std::unique_ptr
+createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
+
 std::unique_ptr
 createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
 
diff --git a/clang/lib/CodeGen/Targets/Mips.cpp 
b/clang/lib/CodeGen/Targets/Mips.cpp
index 06d9b6d4a57615..e7601564f67d1d 100644
--- a/clang/lib/CodeGen/Targets/Mips.cpp
+++ b/clang/lib/CodeGen/Targets/Mips.cpp
@@ -105,6 +105,24 @@ class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
 return SizeOfUnwindException;
   }
 };
+
+class WindowsMIPSTargetCodeGenInfo : public MIPSTargetCodeGenInfo {
+public:
+  WindowsMIPSTargetCodeGenInfo(CodeGenTypes &CGT, bool IsO32)
+: MIPSTargetCodeGenInfo(CGT, IsO32) {}
+
+  void getDependentLibraryOption(llvm::StringRef Lib,
+ llvm::SmallString<24> &Opt) const override {
+Opt = "/DEFAULTLIB:";
+Opt += qualifyWindowsLibrary(Lib);
+  }
+
+  void getDetectMismatchOption(llvm::StringRef Name,
+   llvm::StringRef Value,
+   llvm::SmallString<32> &Opt) const override {
+Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
+  }
+};
 }
 
 void MipsABIInfo::CoerceToIntArgs(
@@ -436,3 +454,8 @@ std::unique_ptr
 CodeGen::createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32) {
   return std::make_unique(CGM.getTypes(), IsOS32);
 }
+
+std::unique_ptr
+CodeGen::createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32) {
+  return std::make_unique(CGM.getTypes(), 
IsOS32);
+}
diff --git a/clang/test/CodeGen/pragma-comment.c 
b/clang/test/CodeGen/pragma-comment.c
index a4746f5c47bf6b..a966840f7c26fc 100644
--- a/clang/test/CodeGen/pragma-comment.c
+++ b/clang/test/CodeGen/pragma-comment.c
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -fms-extensions -emit-llvm -o - 
| FileCheck -check-prefix ELF %s --implicit-check-not llvm.linker.options
 // RUN: %clang_cc1 %s -triple x86_64-sie-ps5 -fms-extensions -emit-llvm -o - | 
FileCheck -check-prefix ELF %s --implicit-check-not llvm.linker.options
 // RUN: %clang_cc1 %s -triple aarch64-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple mipsel-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
 
 #pragma comment(lib, "msvcrt.lib")
 #pragma comment(lib, "kernel32")

``




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


[clang] [Clang][MIPS] Create specific targets for MIPS PE/COFF (PR #121040)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Hervé Poussineau (hpoussin)


Changes

Implement GNU and MSVC variants.
When using them, _WIN32 and _M_MRX000/_MIPS_ macros are correctly defined.

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


4 Files Affected:

- (modified) clang/lib/Basic/Targets.cpp (+8) 
- (modified) clang/lib/Basic/Targets/Mips.cpp (+59) 
- (modified) clang/lib/Basic/Targets/Mips.h (+37) 
- (modified) clang/test/Preprocessor/predefined-win-macros.c (+16) 


``diff
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 706a391023b3a3..d0815ad33bc759 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -297,6 +297,14 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::NaCl:
   return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::Win32:
+  switch (Triple.getEnvironment()) {
+  case llvm::Triple::GNU:
+return std::make_unique(Triple, Opts);
+  case llvm::Triple::MSVC:
+  default: // Assume MSVC for unknown environments
+return std::make_unique(Triple, Opts);
+  }
 default:
   return std::make_unique(Triple, Opts);
 }
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 174bc9d2ab9967..d56995e3ccc48e 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -304,3 +304,62 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
&Diags) const {
 
   return true;
 }
+
+WindowsMipsTargetInfo::WindowsMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsTargetInfo(Triple, Opts), Triple(Triple) {}
+
+void WindowsMipsTargetInfo::getVisualStudioDefines(
+const LangOptions &Opts, MacroBuilder &Builder) const {
+  Builder.defineMacro("_M_MRX000", "4000");
+}
+
+TargetInfo::BuiltinVaListKind
+WindowsMipsTargetInfo::getBuiltinVaListKind() const {
+  return TargetInfo::CharPtrBuiltinVaList;
+}
+
+TargetInfo::CallingConvCheckResult
+WindowsMipsTargetInfo::checkCallingConvention(CallingConv CC) const {
+  switch (CC) {
+  case CC_X86StdCall:
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;
+  case CC_C:
+  case CC_OpenCLKernel:
+  case CC_PreserveMost:
+  case CC_PreserveAll:
+  case CC_Swift:
+  case CC_SwiftAsync:
+return CCCR_OK;
+  default:
+return CCCR_Warning;
+  }
+}
+
+// Windows MIPS, MS (C++) ABI
+MicrosoftMipsTargetInfo::MicrosoftMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsMipsTargetInfo(Triple, Opts) {
+  TheCXXABI.set(TargetCXXABI::Microsoft);
+}
+
+void MicrosoftMipsTargetInfo::getTargetDefines(const LangOptions &Opts,
+   MacroBuilder &Builder) const {
+  WindowsMipsTargetInfo::getTargetDefines(Opts, Builder);
+  WindowsMipsTargetInfo::getVisualStudioDefines(Opts, Builder);
+}
+
+MinGWMipsTargetInfo::MinGWMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsMipsTargetInfo(Triple, Opts) {
+  TheCXXABI.set(TargetCXXABI::GenericMIPS);
+}
+
+void MinGWMipsTargetInfo::getTargetDefines(const LangOptions &Opts,
+   MacroBuilder &Builder) const {
+  WindowsMipsTargetInfo::getTargetDefines(Opts, Builder);
+  Builder.defineMacro("_MIPS_");
+}
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 8acaf56523b218..7ddcd57053cb2b 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
 
+#include "OSTargets.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/Support/Compiler.h"
@@ -450,6 +451,42 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 return std::make_pair(32, 32);
   }
 };
+
+class LLVM_LIBRARY_VISIBILITY WindowsMipsTargetInfo
+: public WindowsTargetInfo {
+  const llvm::Triple Triple;
+
+public:
+  WindowsMipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
+
+  void getVisualStudioDefines(const LangOptions &Opts,
+  MacroBuilder &Builder) const;
+
+  BuiltinVaListKind getBuiltinVaListKind() const override;
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
+};
+
+// Windows MIPS, MS (C++) ABI
+class LLVM_LIBRARY_VISIBILITY MicrosoftMipsTargetInfo
+: public WindowsMipsTargetInfo {
+public:
+  MicrosoftMipsTargetInfo(const llvm::Triple &Triple,
+  const TargetOptions &Opts);
+
+  void getTargetDefines(const LangOptions &Opts,
+MacroBuilder &Bu

[clang] [clang] Fix issue #117960 (PR #121039)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (thebrandre)


Changes

This commit fixes implicit integer conversions for  _opaque-enum-declarations_ 
inside a class template with a specified _enum-base_ (see [dcl.enum]).

Previously, the promotion type of the instantiated enum was set only in 
`Sema::ActOnEnumBody`, which is not called if there are no curly braces are 
after the enum-base. This fixes GitHub issue #117960.

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+3) 
- (added) clang/test/SemaCXX/enum-base-in-class-template.cpp (+66) 


``diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index e058afe81da589..4d39fd409795b6 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1620,6 +1620,9 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl 
*D) {
   if (isDeclWithinFunction(D) ? D == Def : Def && !Enum->isScoped()) {
 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Enum);
 InstantiateEnumDefinition(Enum, Def);
+  } else {
+if (D->isFixed() && !Def)
+  Enum->setPromotionType(Enum->getIntegerType());
   }
 
   return Enum;
diff --git a/clang/test/SemaCXX/enum-base-in-class-template.cpp 
b/clang/test/SemaCXX/enum-base-in-class-template.cpp
new file mode 100644
index 00..012bef9785cbaf
--- /dev/null
+++ b/clang/test/SemaCXX/enum-base-in-class-template.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only %s -verify
+
+// This program causes clang 19 and earlier to crash because
+// EnumDecl::PromotionType has not been set on the instantiated enum.
+// See GitHub Issue #117960.
+namespace Issue117960 {
+template 
+struct A {
+  enum E : T;
+};
+
+int b = A::E{} + 0;
+}
+
+
+namespace test {
+template 
+struct IsSame {
+  static constexpr bool check() { return false; }
+};
+
+template 
+struct IsSame {
+  static constexpr bool check() { return true; }
+};
+}  // namespace test
+
+
+template 
+struct S1 {
+  enum E : T;
+};
+// checks if EnumDecl::PromotionType is set
+int X1 = S1::E{} + 0;
+int Y1 = S1::E{} + 0;
+static_assert(test::IsSame::E{}+0), int>::check(), "");
+static_assert(test::IsSame::E{}+0), unsigned>::check(), 
"");
+char Z1 = S1::E(-1) + 0; // expected-warning{{implicit conversion 
from 'unsigned int' to 'char'}}
+
+template 
+struct S2 {
+  enum E : typename Traits::IntegerType;
+};
+
+template 
+struct Traits {
+  typedef T IntegerType;
+};
+
+int X2 = S2>::E{} + 0;
+int Y2 = S2>::E{} + 0;
+static_assert(test::IsSame>::E{}+0), int>::check(), 
"");
+static_assert(test::IsSame>::E{}+0), 
unsigned>::check(), "");
+
+
+template 
+struct S3 {
+  enum E : unsigned;
+};
+
+int X3 = S3::E{} + 0;
+
+// fails in clang 19 and earlier (see the discussion on GitHub Issue #117960):
+static_assert(test::IsSame::E{}+0), unsigned>::check(), "");
+

``




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


[clang] [llvm] Clang/buildFMulAdd: Use negated attribute (PR #121038)

2024-12-24 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 4cb2a519db10f54815c8a4ccd5accbedc1cdfd07 
9a8925b18e609ac646b2c16da81264a261545513 --extensions cpp,h,c -- 
clang/lib/CodeGen/CGExprScalar.cpp 
clang/test/CodeGen/constrained-math-builtins.c 
llvm/include/llvm/Bitcode/LLVMBitCodes.h 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp 
llvm/lib/Transforms/Utils/CodeExtractor.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 14d73de055..367ca42053 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4121,9 +4121,11 @@ static Value* buildFMulAdd(llvm::Instruction *MulOp, 
Value *Addend,
  Addend->getType()),
 {MulOp0, MulOp1, Addend});
 if (negMul)
-  dyn_cast(FMulAdd)->addParamAttr(0, 
llvm::Attribute::Negated);
+  dyn_cast(FMulAdd)->addParamAttr(0,
+  
llvm::Attribute::Negated);
 if (negAdd)
-  dyn_cast(FMulAdd)->addParamAttr(2, 
llvm::Attribute::Negated);
+  dyn_cast(FMulAdd)->addParamAttr(2,
+  
llvm::Attribute::Negated);
   } else {
 FMulAdd = Builder.CreateCall(
 CGF.CGM.getIntrinsic(llvm::Intrinsic::fmuladd, Addend->getType()),

``




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


[clang] [clang] Fix issue #117960 (PR #121039)

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


[clang] [llvm] Clang/buildFMulAdd: Use negated attribute (PR #121038)

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

wzssyqa wrote:

Depends on https://github.com/llvm/llvm-project/pull/121027

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


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

2024-12-24 Thread Hervé Poussineau via cfe-commits

https://github.com/hpoussin updated 
https://github.com/llvm/llvm-project/pull/121041

From 946baa36101b99bfd512a0b7dbca757a93f68891 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= 
Date: Fri, 10 Nov 2023 23:06:52 +0100
Subject: [PATCH] [Clang][MIPS] Create correct linker arguments for Windows
 toolchains

---
 clang/lib/CodeGen/CodeGenModule.cpp |  2 ++
 clang/lib/CodeGen/TargetInfo.h  |  3 +++
 clang/lib/CodeGen/Targets/Mips.cpp  | 22 ++
 clang/test/CodeGen/pragma-comment.c |  1 +
 4 files changed, 28 insertions(+)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index c49f7631488285..2ec12eb8b7b04e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -119,6 +119,8 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
   case llvm::Triple::mipsel:
 if (Triple.getOS() == llvm::Triple::NaCl)
   return createPNaClTargetCodeGenInfo(CGM);
+else if (Triple.getOS() == llvm::Triple::Win32)
+  return createWindowsMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true);
 return createMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true);
 
   case llvm::Triple::mips64:
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index ab3142bdea684e..4a66683a3b91fd 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -522,6 +522,9 @@ createM68kTargetCodeGenInfo(CodeGenModule &CGM);
 std::unique_ptr
 createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
 
+std::unique_ptr
+createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
+
 std::unique_ptr
 createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
 
diff --git a/clang/lib/CodeGen/Targets/Mips.cpp 
b/clang/lib/CodeGen/Targets/Mips.cpp
index 06d9b6d4a57615..771a85c84b3571 100644
--- a/clang/lib/CodeGen/Targets/Mips.cpp
+++ b/clang/lib/CodeGen/Targets/Mips.cpp
@@ -105,6 +105,23 @@ class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
 return SizeOfUnwindException;
   }
 };
+
+class WindowsMIPSTargetCodeGenInfo : public MIPSTargetCodeGenInfo {
+public:
+  WindowsMIPSTargetCodeGenInfo(CodeGenTypes &CGT, bool IsO32)
+  : MIPSTargetCodeGenInfo(CGT, IsO32) {}
+
+  void getDependentLibraryOption(llvm::StringRef Lib,
+ llvm::SmallString<24> &Opt) const override {
+Opt = "/DEFAULTLIB:";
+Opt += qualifyWindowsLibrary(Lib);
+  }
+
+  void getDetectMismatchOption(llvm::StringRef Name, llvm::StringRef Value,
+   llvm::SmallString<32> &Opt) const override {
+Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
+  }
+};
 }
 
 void MipsABIInfo::CoerceToIntArgs(
@@ -436,3 +453,8 @@ std::unique_ptr
 CodeGen::createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32) {
   return std::make_unique(CGM.getTypes(), IsOS32);
 }
+
+std::unique_ptr
+CodeGen::createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32) {
+  return std::make_unique(CGM.getTypes(), 
IsOS32);
+}
diff --git a/clang/test/CodeGen/pragma-comment.c 
b/clang/test/CodeGen/pragma-comment.c
index a4746f5c47bf6b..a966840f7c26fc 100644
--- a/clang/test/CodeGen/pragma-comment.c
+++ b/clang/test/CodeGen/pragma-comment.c
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -fms-extensions -emit-llvm -o - 
| FileCheck -check-prefix ELF %s --implicit-check-not llvm.linker.options
 // RUN: %clang_cc1 %s -triple x86_64-sie-ps5 -fms-extensions -emit-llvm -o - | 
FileCheck -check-prefix ELF %s --implicit-check-not llvm.linker.options
 // RUN: %clang_cc1 %s -triple aarch64-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple mipsel-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
 
 #pragma comment(lib, "msvcrt.lib")
 #pragma comment(lib, "kernel32")

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


[clang] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr` Matcher (PR #120996)

2024-12-24 Thread Nathan Ridge via cfe-commits

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


[clang] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr` Matcher (PR #120996)

2024-12-24 Thread Nathan Ridge via cfe-commits


@@ -556,6 +556,22 @@ TEST_P(ASTMatchersTest, DeclRefExpr) {
  Reference));
 }
 
+TEST_P(ASTMatchersTest, DependentScopeDeclRefExpr) {
+  if (!GetParam().isCXX() || GetParam().hasDelayedTemplateParsing()) {
+// FIXME: Add a test for `dependentScopeDeclRefExpr()` that does not depend

HighCommander4 wrote:

The concept of template-dependence (and thus `DependentScopeDeclRefExpr` nodes) 
only exist in C++, so it's expected that the test depends on C++.

Based on some other tests that check this condition, please revise the comment 
to instead say:

```
// FIXME: Fix this test to work with delayed template parsing.
```

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


[clang] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr` Matcher (PR #120996)

2024-12-24 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 commented:

Thanks, this looks pretty good!

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


[clang] Reapply "[Clang] Improve diagnostics for expansion length mismatch" (PR #121044)

2024-12-24 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/121044

... and "[Clang] fix missing initialization of original number of expansions"

This reverts commit acecf68c8b7c3c625cfa00f00f8ddc8f15baae44.

>From aa008450981a80a2d26e687df33f10038aa50a9c Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Tue, 24 Dec 2024 13:06:44 +0800
Subject: [PATCH] Reapply "[Clang] Improve diagnostics for expansion length
 mismatch"

... and "[Clang] fix missing initialization of original number of expansions"

This reverts commit acecf68c8b7c3c625cfa00f00f8ddc8f15baae44.

Co-authored-by: Matheus Izvekov 
---
 clang/include/clang/Sema/Sema.h   |   8 +-
 clang/include/clang/Sema/SemaInternal.h   |   4 +-
 clang/lib/AST/ExprCXX.cpp |   2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   2 +-
 clang/lib/Sema/SemaTemplateDeduction.cpp  |   7 +-
 clang/lib/Sema/SemaTemplateVariadic.cpp   | 318 +-
 clang/lib/Sema/TreeTransform.h|   1 +
 .../CXX/temp/temp.decls/temp.variadic/p5.cpp  |  50 +++
 .../SemaTemplate/cxx1z-fold-expressions.cpp   |   2 +-
 clang/test/SemaTemplate/pack-deduction.cpp|  51 ++-
 10 files changed, 275 insertions(+), 170 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5ee7ea48cc983c..4a726ef809551e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -230,9 +230,11 @@ void threadSafetyCleanup(BeforeSet *Cache);
 
 // FIXME: No way to easily map from TemplateTypeParmTypes to
 // TemplateTypeParmDecls, so we have this horrible PointerUnion.
-typedef std::pair,
-  SourceLocation>
-UnexpandedParameterPack;
+using UnexpandedParameterPack = std::pair<
+llvm::PointerUnion<
+const TemplateTypeParmType *, const SubstTemplateTypeParmPackType *,
+const SubstNonTypeTemplateParmPackExpr *, const NamedDecl *>,
+SourceLocation>;
 
 /// Describes whether we've seen any nullability information for the given
 /// file.
diff --git a/clang/include/clang/Sema/SemaInternal.h 
b/clang/include/clang/Sema/SemaInternal.h
index 27cda71989726d..acf6c8146d70d4 100644
--- a/clang/include/clang/Sema/SemaInternal.h
+++ b/clang/include/clang/Sema/SemaInternal.h
@@ -72,10 +72,10 @@ inline std::pair getDepthAndIndex(const 
NamedDecl *ND) {
 /// Retrieve the depth and index of an unexpanded parameter pack.
 inline std::pair
 getDepthAndIndex(UnexpandedParameterPack UPP) {
-  if (const auto *TTP = UPP.first.dyn_cast())
+  if (const auto *TTP = dyn_cast(UPP.first))
 return std::make_pair(TTP->getDepth(), TTP->getIndex());
 
-  return getDepthAndIndex(cast(UPP.first));
+  return getDepthAndIndex(cast(UPP.first));
 }
 
 class TypoCorrectionConsumer : public VisibleDeclConsumer {
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index fc09d24fc30cb4..715b819bfb96bb 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1734,7 +1734,7 @@ PackIndexingExpr *PackIndexingExpr::Create(
 NamedDecl *PackIndexingExpr::getPackDecl() const {
   if (auto *D = dyn_cast(getPackIdExpression()); D) {
 NamedDecl *ND = dyn_cast(D->getDecl());
-assert(ND && "exected a named decl");
+assert(ND && "expected a named decl");
 return ND;
   }
   assert(false && "invalid declaration kind in pack indexing expression");
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c5a72cf812ebc9..bf5f31c3a5ca4c 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17496,7 +17496,7 @@ DeclResult Sema::ActOnTemplatedFriendTag(
   unsigned FriendDeclDepth = TempParamLists.front()->getDepth();
   for (UnexpandedParameterPack &U : Unexpanded) {
 if (getDepthAndIndex(U).first >= FriendDeclDepth) {
-  auto *ND = U.first.dyn_cast();
+  auto *ND = dyn_cast(U.first);
   if (!ND)
 ND = cast(U.first)->getDecl();
   Diag(U.second, diag::friend_template_decl_malformed_pack_expansion)
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index fad20b37a7d9a2..1b541aa665a71a 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -868,8 +868,11 @@ class PackDeductionScope {
   SmallVector Unexpanded;
   S.collectUnexpandedParameterPacks(Pattern, Unexpanded);
   for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
-unsigned Depth, Index;
-std::tie(Depth, Index) = getDepthAndIndex(Unexpanded[I]);
+UnexpandedParameterPack U = Unexpanded[I];
+if (isa(U.first))
+  continue;
+auto [Depth, Index] = getDepthAndIndex(U);
 if (Depth == Info.getDeducedDepth())
   AddPack(Index);
   }
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index c8452db6bc9014..b9e52080d62a96 100644
--- a/clang/lib/Sema/SemaTemplateVariadic

[clang] Bulk port 64-bit x86 builtins to TableGen (PR #121043)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Chandler Carruth (chandlerc)


Changes

This PR follows https://github.com/llvm/llvm-project/pull/120831 (the PR 
contains both, only review the last
commit here as the other commit will be reviewed on the other PR).

Similar to that PR, this does a very mechanical port of X86 builtins to
TableGen. There is a *lot* of improvement available here to use TableGen
more effectively and collapse repeated structures. But those can now be
follow-up PRs that restructure *within* the `.td` file.

The current structure produces a file that exactly matches the original
X-macros except for the differences outlined in 
https://github.com/llvm/llvm-project/pull/120831:

- Horizontal whitespace
- `long long` types now use `long long` outside of OpenCL, but switch to
  `long` in OpenCL (if relevant at all).

Otherwise, only the order of builtins change, and no tests regress.

---

Patch is 532.86 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/121043.diff


9 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsBase.td (+8-3) 
- (removed) clang/include/clang/Basic/BuiltinsX86.def (-2225) 
- (modified) clang/include/clang/Basic/BuiltinsX86.td (+5377-5) 
- (added) clang/include/clang/Basic/BuiltinsX86Base.td (+28) 
- (added) clang/include/clang/Basic/BuiltinsX86_64.td (+485) 
- (modified) clang/include/clang/Basic/CMakeLists.txt (+4) 
- (modified) clang/include/clang/Basic/TargetBuiltins.h (+1-3) 
- (modified) clang/lib/Basic/Targets/X86.cpp (+1-9) 
- (modified) clang/utils/TableGen/ClangBuiltinsEmitter.cpp (+24) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsBase.td 
b/clang/include/clang/Basic/BuiltinsBase.td
index cff182f3f282cb..afed3c815d3290 100644
--- a/clang/include/clang/Basic/BuiltinsBase.td
+++ b/clang/include/clang/Basic/BuiltinsBase.td
@@ -95,9 +95,6 @@ class CustomEntry {
 }
 
 class AtomicBuiltin : Builtin;
-class TargetBuiltin : Builtin {
-  string Features = "";
-}
 
 class LibBuiltin : Builtin {
   string Header = header;
@@ -122,6 +119,14 @@ class OCL_DSELangBuiltin : LangBuiltin<"OCL_DSE">;
 class OCL_GASLangBuiltin : LangBuiltin<"OCL_GAS">;
 class OCLLangBuiltin : LangBuiltin<"ALL_OCL_LANGUAGES">;
 
+class TargetBuiltin : Builtin {
+  string Features = "";
+}
+class TargetLibBuiltin : TargetBuiltin {
+  string Header;
+  string Languages = "ALL_LANGUAGES";
+}
+
 class Template substitutions,
list affixes,
bit as_prefix = 0> {
diff --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
deleted file mode 100644
index 352b3a9ec594a7..00
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ /dev/null
@@ -1,2225 +0,0 @@
-//===--- BuiltinsX86.def - X86 Builtin function database *- C++ 
-*-===//
-//
-// 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
-//
-//===--===//
-//
-// This file defines the X86-specific builtin function database.  Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-// FIXME: Ideally we would be able to pull this information from what
-// LLVM already knows about X86 builtins. We need to match the LLVM
-// definition anyway, since code generation will lower to the
-// intrinsic if one exists.
-
-#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
-#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
-#endif
-
-#if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
-#  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) 
BUILTIN(ID, TYPE, ATTRS)
-#endif
-
-// MMX
-//
-// All MMX instructions will be generated via builtins. Any MMX vector
-// types (<1 x i64>, <2 x i32>, etc.) that aren't used by these builtins will 
be
-// expanded by the back-end.
-// FIXME: _mm_prefetch must be a built-in because it takes a compile-time 
constant
-// argument and our prior approach of using a #define to the current built-in
-// doesn't work in the presence of re-declaration of _mm_prefetch for windows.
-TARGET_BUILTIN(_mm_prefetch, "vcC*i", "nc", "mmx")
-
-// SSE intrinsics.
-
-TARGET_BUILTIN(__builtin_ia32_ldmxcsr, "vUi", "n", "sse")
-TARGET_HEADER_BUILTIN(_mm_setcsr, "vUi", "nh",XMMINTRIN_H, ALL_LANGUAGES, 
"sse")
-TARGET_BUILTIN(__builtin_ia32_stmxcsr, "Ui", "n", "sse")
-TARGET_HEADER_BUILTIN(_mm_getcsr, "Ui", "nh", XMMINTRIN_H, ALL_LANGUAGES, 
"sse")
-TARGET_BUILTIN(__builtin_ia32_cvtss2si, "iV4f", "ncV:128:", "sse")
-TARGET_BUILTIN(__builtin_ia32_cvttss2si, "iV4f", "ncV:128:", "sse")
-TARGET_BUILTIN(__builtin_ia32_movmskps, "iV4f", "nV:128:",

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Stephen Senran Zhang via cfe-commits

https://github.com/zsrkmyn updated 
https://github.com/llvm/llvm-project/pull/120352

>From 9c49208195b25c6cf5bdbd0f6d85ed5f8348812d Mon Sep 17 00:00:00 2001
From: Senran Zhang 
Date: Tue, 17 Dec 2024 16:15:25 +0800
Subject: [PATCH] [ConstantRange] Estimate tighter lower (upper) bounds for
 masked binary and (or)

Co-author: Yingwei Zheng (@dtcxzyw)
---
 clang/test/CodeGen/AArch64/fpm-helpers.c  | 18 ++--
 llvm/lib/IR/ConstantRange.cpp | 76 ++--
 .../SCCP/range-and-or-bit-masked.ll   | 88 +++
 llvm/unittests/IR/ConstantRangeTest.cpp   | 16 
 4 files changed, 183 insertions(+), 15 deletions(-)
 create mode 100644 llvm/test/Transforms/SCCP/range-and-or-bit-masked.ll

diff --git a/clang/test/CodeGen/AArch64/fpm-helpers.c 
b/clang/test/CodeGen/AArch64/fpm-helpers.c
index 4bced01d5c71fa..6264b5caeb4f50 100644
--- a/clang/test/CodeGen/AArch64/fpm-helpers.c
+++ b/clang/test/CodeGen/AArch64/fpm-helpers.c
@@ -35,7 +35,7 @@ extern "C" {
 //
 fpm_t test_init() { return __arm_fpm_init(); }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_src1_1(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -6) i64 @test_src1_1(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 -8
@@ -44,7 +44,7 @@ fpm_t test_src1_1() {
   return __arm_set_fpm_src1_format(INIT_ONES, __ARM_FPM_E5M2);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_src1_2(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -6) i64 @test_src1_2(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 1
@@ -53,7 +53,7 @@ fpm_t test_src1_2() {
   return __arm_set_fpm_src1_format(INIT_ZERO, __ARM_FPM_E4M3);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_src2_1(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -48) i64 @test_src2_1(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 -57
@@ -62,7 +62,7 @@ fpm_t test_src2_1() {
   return __arm_set_fpm_src2_format(INIT_ONES, __ARM_FPM_E5M2);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_src2_2(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -48) i64 @test_src2_2(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 8
@@ -71,7 +71,7 @@ fpm_t test_src2_2() {
   return __arm_set_fpm_src2_format(INIT_ZERO, __ARM_FPM_E4M3);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_dst1_1(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -384) i64 @test_dst1_1(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 -449
@@ -80,7 +80,7 @@ fpm_t test_dst1_1() {
   return __arm_set_fpm_dst_format(INIT_ONES, __ARM_FPM_E5M2);
 }
 
-// CHECK-LABEL: define dso_local noundef i64 @test_dst2_2(
+// CHECK-LABEL: define dso_local noundef range(i64 0, -384) i64 @test_dst2_2(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 64
@@ -139,21 +139,21 @@ fpm_t test_lscale() { return 
__arm_set_fpm_lscale(INIT_ZERO, 127); }
 //
 fpm_t test_lscale2() { return __arm_set_fpm_lscale2(INIT_ZERO, 63); }
 
-// CHECK-LABEL: define dso_local noundef range(i64 0, 4294967296) i64 
@test_nscale_1(
+// CHECK-LABEL: define dso_local noundef range(i64 0, 4278190081) i64 
@test_nscale_1(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 2147483648
 //
 fpm_t test_nscale_1() { return __arm_set_fpm_nscale(INIT_ZERO, -128); }
 
-// CHECK-LABEL: define dso_local noundef range(i64 0, 4294967296) i64 
@test_nscale_2(
+// CHECK-LABEL: define dso_local noundef range(i64 0, 4278190081) i64 
@test_nscale_2(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 2130706432
 //
 fpm_t test_nscale_2() { return __arm_set_fpm_nscale(INIT_ZERO, 127); }
 
-// CHECK-LABEL: define dso_local noundef range(i64 0, 4294967296) i64 
@test_nscale_3(
+// CHECK-LABEL: define dso_local noundef range(i64 0, 4278190081) i64 
@test_nscale_3(
 // CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 4278190080
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index d81a292916fdea..f778494b1917fe 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'00101'1,  ; LLo
+///  10'1'0]  ; LHi
+///   RHS = [10'1'0,  ; RLo
+///  10'1'1]  ; RHi
+///
+/// we know that the higher 2 bits of the

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Stephen Senran Zhang via cfe-commits

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


[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

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


@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'00101'1,  ; LLo
+///  10'1'0]  ; LHi
+///   RHS = [10'1'0,  ; RLo
+///  10'1'1]  ; RHi
+///
+/// we know that the higher 2 bits of the result is always 10; and we also
+/// notice that RHS[1:6] are always 1, so the result[1:6] can no be less than
+/// LHS[1:6] (i.e., 00101). Thus, the lower bound is 10'00101'0.
+///
+/// The algorithm is as follows,
+/// 1. we first calculate a mask to find the higher common bits by
+///   Mask = ~((LLo ^ LHi) | (LLo ^ LHi) | (LLo ^ RLo));
+///   Mask = clear all non-leading-ones bits in Mask;
+///in the example, the Mask is set to 11'0'0;
+/// 2. calculate a new mask by setting all common leading bits to 1 in RHS, and
+///keeping the longest leading ones (i.e., 11'1'0 in the example).
+/// 3. return (LLo & new mask) as the lower bound;
+/// 4. repeat the step 2 and 3 with LHS and RHS swapped, and update the lower
+///bound with the larger one.
+static APInt estimateBitMaskedAndLowerBound(const ConstantRange &LHS,
+const ConstantRange &RHS) {
+  auto BitWidth = LHS.getBitWidth();
+  // If either is full set or unsigned wrapped, then the range must contain '0'
+  // which leads the lower bound to 0.
+  if ((LHS.isFullSet() || RHS.isFullSet()) ||
+  (LHS.isWrappedSet() || RHS.isWrappedSet()))
+return APInt::getZero(BitWidth);
+
+  auto LLo = LHS.getLower();
+  auto LHi = LHS.getUpper() - 1;
+  auto RLo = RHS.getLower();
+  auto RHi = RHS.getUpper() - 1;
+
+  // Calculate the mask for the higher common bits.
+  auto Mask = ~((LLo ^ LHi) | (RLo ^ RHi) | (LLo ^ RLo));
+  unsigned LeadingOnes = Mask.countLeadingOnes();
+  Mask.clearLowBits(BitWidth - LeadingOnes);
+
+  auto estimateBound = [BitWidth, &Mask](APInt ALo, const APInt &BLo,
+ const APInt &BHi) {
+unsigned LeadingOnes = ((BLo & BHi) | Mask).countLeadingOnes();
+unsigned StartBit = BitWidth - LeadingOnes;
+ALo.clearLowBits(StartBit);

dtcxzyw wrote:

Oops, ignore me.


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


[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Stephen Senran Zhang via cfe-commits


@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'00101'1,  ; LLo
+///  10'1'0]  ; LHi
+///   RHS = [10'1'0,  ; RLo
+///  10'1'1]  ; RHi
+///
+/// we know that the higher 2 bits of the result is always 10; and we also
+/// notice that RHS[1:6] are always 1, so the result[1:6] can no be less than

zsrkmyn wrote:

Thanks! Resolved.

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


[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2024-12-24 Thread Mariya Podchishchaeva via cfe-commits


@@ -20008,6 +20008,87 @@ bool Sema::IsValueInFlagEnum(const EnumDecl *ED, const 
llvm::APInt &Val,
   return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
 }
 
+bool Sema::ComputeBestEnumProperties(ASTContext &Context, EnumDecl *Enum,
+ bool is_cpp, bool isPacked,

Fznamznon wrote:

Hmm, then I wonder if it makes sense to make it a method of ASTContext instead 
of method of Sema? Usually ASTContext is used to query type information, so it 
might make sense.

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


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

2024-12-24 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

> > > Sure, I can test it. Just to confirm, what branch/commit should I be 
> > > testing?
> > 
> > 
> > This PR has everything in it so you can just test it. There are 3 commits 
> > on this branch that won't land here (they're under review in their own 
> > PRs), but I've got them all here so you can just test this PR.
> 
> Unfortunely it still looks like there are a bunch of failures. They do look 
> different from before though. I've uploaded the test log here: 
> [dropbox.com/scl/fi/d6e334heik4wp2dlztlq8/log_test.35a7fd79c471cdebd416ba711dbae6970e0e8550.zip?rlkey=kdkeo4897mw3642f9jyn4cmd0&dl=0](https://www.dropbox.com/scl/fi/d6e334heik4wp2dlztlq8/log_test.35a7fd79c471cdebd416ba711dbae6970e0e8550.zip?rlkey=kdkeo4897mw3642f9jyn4cmd0&dl=0)

Hmm, this looks like I just didn't fix "enough".

I've sent out #121043 and rebased this PR on top of that as well. Can you take 
another spin?

This PR should be the right branch, incorporating all the other changes.

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


[clang] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr` Matcher (PR #120996)

2024-12-24 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/120996

>From a0b71504fa31e55d42cb54e349838b2669f6fde5 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Mon, 23 Dec 2024 19:42:30 +0100
Subject: [PATCH 1/2] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr`
 Matcher

---
 clang/docs/LibASTMatchersReference.html   |  6 +
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 10 +
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp |  2 ++
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 clang/unittests/AST/ASTImporterTest.cpp   |  3 ---
 .../ASTMatchers/ASTMatchersNodeTest.cpp   | 22 +++
 7 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index f18e9cf1341696..ddc99020604c94 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1842,6 +1842,12 @@ Node Matchers
   if (x) {}
 
 
+MatcherStmt>dependentScopeDeclRefExprMatcherDependentScopeDeclRefExpr>...
+Matches 
expressions that refer to dependent scope declarations.
+
+Example matches T::v
+   template  class X : T { void f() { T::v; } };
+
 
 MatcherStmt>declStmtMatcherDeclStmt>...
 Matches declaration 
statements.
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b984ecaefecaf..2a84a4704f0c21 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1101,6 +1101,8 @@ AST Matchers
 
 - Ensure ``pointee`` matches Objective-C pointer types.
 
+- Add ``dependentScopeDeclRefExpr`` matcher to match expressions that refer to 
dependent scope declarations.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 897aa25dc95cc1..22e2546ab81e0a 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2125,6 +2125,16 @@ extern const internal::VariadicDynCastAllOfMatcher expr;
 extern const internal::VariadicDynCastAllOfMatcher
 declRefExpr;
 
+/// Matches expressions that refer to dependent scope declarations.
+///
+/// example matches T::v;
+/// \code
+///  template  class X : T { void f() { T::v; } };
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+dependentScopeDeclRefExpr;
+
 /// Matches a reference to an ObjCIvar.
 ///
 /// Example: matches "a" in "init" method:
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index bf9dc5f2373f9e..8c744eebbdfb50 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -924,6 +924,8 @@ const internal::VariadicDynCastAllOfMatcher
 const internal::VariadicDynCastAllOfMatcher cxxFoldExpr;
 const internal::VariadicDynCastAllOfMatcher expr;
 const internal::VariadicDynCastAllOfMatcher declRefExpr;
+const internal::VariadicDynCastAllOfMatcher
+dependentScopeDeclRefExpr;
 const internal::VariadicDynCastAllOfMatcher 
objcIvarRefExpr;
 const internal::VariadicDynCastAllOfMatcher blockExpr;
 const internal::VariadicDynCastAllOfMatcher ifStmt;
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 837633fb2f0601..685d626d2978bf 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -222,6 +222,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(decompositionDecl);
   REGISTER_MATCHER(declCountIs);
   REGISTER_MATCHER(declRefExpr);
+  REGISTER_MATCHER(dependentScopeDeclRefExpr);
   REGISTER_MATCHER(declStmt);
   REGISTER_MATCHER(declaratorDecl);
   REGISTER_MATCHER(decltypeType);
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index f3f314b723dfc6..ec062a5cc953b8 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3172,9 +3172,6 @@ TEST_P(ImportDecl, ImportFieldOrder) {
  recordDecl(hasFieldOrder({"b", "a"})));
 }
 
-const internal::VariadicDynCastAllOfMatcher
-dependentScopeDeclRefExpr;
-
 TEST_P(ImportExpr, DependentScopeDeclRefExpr) {
   MatchVerifier Verifier;
   testImport("template  struct S { static T foo; };"
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 9bc287e07224aa..89897f1b3230a6 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -556,6 +556,22 @@ TEST_P(ASTMatchersTest, DeclRefExpr) {
  

[clang] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr` Matcher (PR #120996)

2024-12-24 Thread Amr Hesham via cfe-commits


@@ -556,6 +556,22 @@ TEST_P(ASTMatchersTest, DeclRefExpr) {
  Reference));
 }
 
+TEST_P(ASTMatchersTest, DependentScopeDeclRefExpr) {
+  if (!GetParam().isCXX() || GetParam().hasDelayedTemplateParsing()) {
+// FIXME: Add a test for `dependentScopeDeclRefExpr()` that does not depend

AmrDeveloper wrote:

Thank you, I updated it :D

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


[clang] [Clang][MIPS] Send correct architecture for MinGW toolchains (PR #121042)

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


@@ -85,6 +85,10 @@
 // RUN:   | FileCheck %s --check-prefix CHECK_MINGW_EC_LINK
 // CHECK_MINGW_EC_LINK: "-m" "arm64ecpe"
 
+// RUN: %clang --target=mipsel-windows-gnu -### -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK_MINGW_MIPSPE
+// CHECK_MINGW_MIPSPE: "-m" "mipspe"

wzssyqa wrote:

Is it supported by binutils now?

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-24 Thread A. Jiang via cfe-commits


@@ -0,0 +1,623 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/constructible.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template 
+struct extract_last : extract_last {};
+
+template 
+struct extract_last {
+  using type = T;
+};

frederick-vs-ja wrote:

Please use __ugly names for non-standard internal names (except for member 
`type`/`value`). Ditto below.
```suggestion
template 
struct __extract_last : __extract_last <_Tail...> {};

template 
struct __extract_last<_Tp> {
  using type = _Tp;
};
```

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

2024-12-24 Thread A. Jiang via cfe-commits


@@ -0,0 +1,623 @@
+// -*- C++ -*-

frederick-vs-ja wrote:

Do we need to add anything to `__cxx03` subdirectory for implementing a C++26 
feature?

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


[clang-tools-extra] 8e1cb96 - [analyzer] Split alpha core Identical Expression tests (#119543)

2024-12-24 Thread via cfe-commits

Author: vabridgers
Date: 2024-12-24T07:21:14-06:00
New Revision: 8e1cb96db84a70b2c803c28a359c8bb71395f35e

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

LOG: [analyzer] Split alpha core Identical Expression tests (#119543)

Split the remnant test from PR #114715, "Remove alpha.core.IdenticalExpr
Checker" into seperate tests for misc-redundant-expression and
bugprone-branch-clone per review comment requests.

-

Co-authored-by: einvbri 

Added: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-2.cpp
clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression-2.cpp

Modified: 


Removed: 

clang-tools-extra/test/clang-tidy/checkers/bugprone/alpha-core-identicalexpr.cpp



diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-2.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-2.cpp
new file mode 100644
index 00..b91ac6a550c5a7
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-2.cpp
@@ -0,0 +1,768 @@
+// RUN: %check_clang_tidy %s bugprone-branch-clone %t --
+
+/* Only one expected warning per function allowed at the very end. */
+
+int func(void)
+{
+  return 0;
+}
+
+int func2(void)
+{
+  return 0;
+}
+
+int funcParam(int a)
+{
+  return 0;
+}
+
+/* '!=' operator*/
+
+
+/* '!=' with int pointer */
+
+int checkNotEqualIntPointerLiteralCompare1(void) {
+  int* p = 0;
+  return (p != 0); // no warning
+}
+
+int checkNotEqualIntPointerLiteralCompare2(void) {
+  return (6 != 7); // no warning
+}
+
+int checkNotEqualIntPointerDeclCompare1(void) {
+  int k = 3;
+  int* f = &k;
+  int* g = &k;
+  return (f != g); // no warning
+}
+
+int checkNotEqualCastIntPointerDeclCompare11(void) {
+  int k = 7;
+  int* f = &k;
+  return ((int*)f != (int*)f);
+}
+int checkNotEqualCastIntPointerDeclCompare12(void) {
+  int k = 7;
+  int* f = &k;
+  return ((int*)((char*)f) != (int*)f); // no warning
+}
+int checkNotEqualBinaryOpIntPointerCompare1(void) {
+  int k = 7;
+  int res;
+  int* f= &k;
+  res = (f + 4 != f + 4);
+  return (0);
+}
+int checkNotEqualBinaryOpIntPointerCompare2(void) {
+  int k = 7;
+  int* f = &k;
+  int* g = &k;
+  return (f + 4 != g + 4); // no warning
+}
+
+
+int checkNotEqualBinaryOpIntPointerCompare3(void) {
+  int k = 7;
+  int res;
+  int* f= &k;
+  res = ((int*)f + 4 != (int*)f + 4);
+  return (0);
+}
+int checkNotEqualBinaryOpIntPointerCompare4(void) {
+  int k = 7;
+  int res;
+  int* f= &k;
+  res = ((int*)f + 4 != (int*)((char*)f) + 4);  // no warning
+  return (0);
+}
+
+int checkNotEqualNestedBinaryOpIntPointerCompare1(void) {
+  int res;
+  int k = 7;
+  int t= 1;
+  int* u= &k+2;
+  int* f= &k+3;
+  res = ((f + (3)*t) != (f + (3)*t));
+  return (0);
+}
+
+int checkNotEqualNestedBinaryOpIntPointerCompare2(void) {
+  int res;
+  int k = 7;
+  int t= 1;
+  int* u= &k+2;
+  int* f= &k+3;
+  res = (((3)*t + f) != (f + (3)*t));  // no warning
+  return (0);
+}
+/*   end '!=' int*  */
+
+/* '!=' with function*/
+
+int checkNotEqualSameFunction() {
+  unsigned a = 0;
+  unsigned b = 1;
+  int res = (a+func() != a+func());  // no warning
+  return (0);
+}
+
+int checkNotEqualDifferentFunction() {
+  unsigned a = 0;
+  unsigned b = 1;
+  int res = (a+func() != a+func2());  // no warning
+  return (0);
+}
+
+int checkNotEqualSameFunctionSameParam() {
+  unsigned a = 0;
+  unsigned b = 1;
+  int res = (a+funcParam(a) != a+funcParam(a));  // no warning
+  return (0);
+}
+
+int checkNotEqualSameFunctionDifferentParam() {
+  unsigned a = 0;
+  unsigned b = 1;
+  int res = (a+funcParam(a) != a+funcParam(b));  // no warning
+  return (0);
+}
+
+/*   end '!=' with function*/
+
+/*   end '!=' */
+
+
+/* Checking use of identical expressions in conditional operator*/
+
+unsigned test_unsigned(unsigned a) {
+  unsigned b = 1;
+  a = a > 5 ? b : b;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: conditional operator with 
identical true and false expressions [bugprone-branch-clone]
+  return a;
+}
+
+void test_signed() {
+  int a = 0;
+  a = a > 5 ? a : a;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: conditional operator with 
identical true and false expressions [bugprone-branch-clone]
+}
+
+void test_bool(bool a) {
+  a = a > 0 ? a : a;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: conditional operator with 
identical true and false expressions [bugprone-branch-clone]
+}
+
+void test_float() {
+  float a = 0;
+  float b = 0;
+  a = a > 5 ? a : a;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: conditional operator with 
identical true and false expressions [bugprone-branch-clone]
+}
+
+const char *test_string() {
+  float a = 0;
+  return a > 5 ? "abc" : "abc";
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: conditional operator with 
identical tru

[clang-tools-extra] [analyzer] Split alpha core Identical Expression tests (PR #119543)

2024-12-24 Thread via cfe-commits

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

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

https://github.com/philnik777 requested changes to this pull request.

Please make sure you're following the [libc++ Coding 
Guidelines](https://libcxx.llvm.org/CodingGuidelines.html).

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


[clang] [clang] Catch missing format attributes (PR #105479)

2024-12-24 Thread Budimir Aranđelović via cfe-commits

https://github.com/budimirarandjelovichtec updated 
https://github.com/llvm/llvm-project/pull/105479

From 848ebcab9ac0a526b01f56090c50594031d6b33e Mon Sep 17 00:00:00 2001
From: budimirarandjelovicsyrmia 
Date: Fri, 5 Apr 2024 15:20:37 +0200
Subject: [PATCH] [clang] Catch missing format attributes

---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 -
 .../clang/Basic/DiagnosticSemaKinds.td|   4 +
 clang/include/clang/Sema/Attr.h   |   7 +
 clang/include/clang/Sema/Sema.h   |   5 +
 clang/lib/Sema/SemaChecking.cpp   |   4 +-
 clang/lib/Sema/SemaDecl.cpp   |   2 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 179 +++-
 clang/test/Sema/attr-format-missing.c | 259 ++
 clang/test/Sema/attr-format-missing.cpp   | 189 +
 10 files changed, 648 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/Sema/attr-format-missing.c
 create mode 100644 clang/test/Sema/attr-format-missing.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b984ecaefecaf..b2e21a02825e09 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -734,6 +734,8 @@ Improvements to Clang's diagnostics
   require(scope); // Warning!  Requires mu1.
 }
 
+- Clang now diagnoses missing format attributes for non-template functions and 
class/struct/union members. (#GH60718)
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 3ac490d30371b1..0a97b7a1d92e01 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -536,7 +536,6 @@ def MainReturnType : DiagGroup<"main-return-type">;
 def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
-def : DiagGroup<"missing-format-attribute">;
 def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 330ae045616aba..857cce9fe6a44f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1055,6 +1055,10 @@ def err_opencl_invalid_param : Error<
   "declaring function parameter of type %0 is not allowed%select{; did you 
forget * ?|}1">;
 def err_opencl_invalid_return : Error<
   "declaring function return value of type %0 is not allowed %select{; did you 
forget * ?|}1">;
+def warn_missing_format_attribute : Warning<
+  "diagnostic behavior may be improved by adding the %0 format attribute to 
the declaration of %1">,
+  InGroup>, DefaultIgnore;
+def note_format_function : Note<"%0 format function">;
 def warn_pragma_options_align_reset_failed : Warning<
   "#pragma options align=reset failed: %0">,
   InGroup;
diff --git a/clang/include/clang/Sema/Attr.h b/clang/include/clang/Sema/Attr.h
index 3f0b10212789a4..37c124ca7b454a 100644
--- a/clang/include/clang/Sema/Attr.h
+++ b/clang/include/clang/Sema/Attr.h
@@ -123,6 +123,13 @@ inline bool isInstanceMethod(const Decl *D) {
   return false;
 }
 
+inline bool checkIfMethodHasImplicitObjectParameter(const Decl *D) {
+  if (const auto *MethodDecl = dyn_cast(D))
+return MethodDecl->isInstance() &&
+   !MethodDecl->hasCXXExplicitFunctionObjectParameter();
+  return false;
+}
+
 /// Diagnose mutually exclusive attributes when present on a given
 /// declaration. Returns true if diagnosed.
 template 
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5ee7ea48cc983c..5cbd15441b7d96 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4603,6 +4603,11 @@ class Sema final : public SemaBase {
 
   enum class RetainOwnershipKind { NS, CF, OS };
 
+  void DetectMissingFormatAttributes(const FunctionDecl *Callee,
+ ArrayRef Args,
+ SourceLocation Loc);
+  void EmitMissingFormatAttributesDiagnostic(const FunctionDecl *Caller);
+
   UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
   StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
 
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index ce846ae88c38b4..de1c5fcdff27d6 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3452,8 +3452,10 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
 }
   }
 
-  if (FD)
+  if (FD) {
 diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
+DetectMissingFormatAttributes(FD, Args, Loc);
+  }
 }
 
 void S

[clang] [clang] Catch missing format attributes (PR #105479)

2024-12-24 Thread Budimir Aranđelović via cfe-commits

https://github.com/budimirarandjelovichtec updated 
https://github.com/llvm/llvm-project/pull/105479

From 1a096f6829e412b92613510f72c75c8d0c932491 Mon Sep 17 00:00:00 2001
From: budimirarandjelovicsyrmia 
Date: Fri, 5 Apr 2024 15:20:37 +0200
Subject: [PATCH] [clang] Catch missing format attributes

---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 -
 .../clang/Basic/DiagnosticSemaKinds.td|   4 +
 clang/include/clang/Sema/Attr.h   |   7 +
 clang/include/clang/Sema/Sema.h   |   5 +
 clang/lib/Sema/SemaChecking.cpp   |   4 +-
 clang/lib/Sema/SemaDecl.cpp   |   2 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 179 +++-
 clang/test/Sema/attr-format-missing.c | 259 ++
 clang/test/Sema/attr-format-missing.cpp   | 189 +
 10 files changed, 648 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/Sema/attr-format-missing.c
 create mode 100644 clang/test/Sema/attr-format-missing.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a85ef60b7b58ba..05758192e4fde4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -708,6 +708,8 @@ Improvements to Clang's diagnostics
 
 - Fix -Wdangling false positives on conditional operators (#120206).
 
+- Clang now diagnoses missing format attributes for non-template functions and 
class/struct/union members. (#GH60718)
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 3ac490d30371b1..0a97b7a1d92e01 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -536,7 +536,6 @@ def MainReturnType : DiagGroup<"main-return-type">;
 def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
-def : DiagGroup<"missing-format-attribute">;
 def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 491bc83c1e1297..b07eb9daecf22d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1055,6 +1055,10 @@ def err_opencl_invalid_param : Error<
   "declaring function parameter of type %0 is not allowed%select{; did you 
forget * ?|}1">;
 def err_opencl_invalid_return : Error<
   "declaring function return value of type %0 is not allowed %select{; did you 
forget * ?|}1">;
+def warn_missing_format_attribute : Warning<
+  "diagnostic behavior may be improved by adding the %0 format attribute to 
the declaration of %1">,
+  InGroup>, DefaultIgnore;
+def note_format_function : Note<"%0 format function">;
 def warn_pragma_options_align_reset_failed : Warning<
   "#pragma options align=reset failed: %0">,
   InGroup;
diff --git a/clang/include/clang/Sema/Attr.h b/clang/include/clang/Sema/Attr.h
index 3f0b10212789a4..37c124ca7b454a 100644
--- a/clang/include/clang/Sema/Attr.h
+++ b/clang/include/clang/Sema/Attr.h
@@ -123,6 +123,13 @@ inline bool isInstanceMethod(const Decl *D) {
   return false;
 }
 
+inline bool checkIfMethodHasImplicitObjectParameter(const Decl *D) {
+  if (const auto *MethodDecl = dyn_cast(D))
+return MethodDecl->isInstance() &&
+   !MethodDecl->hasCXXExplicitFunctionObjectParameter();
+  return false;
+}
+
 /// Diagnose mutually exclusive attributes when present on a given
 /// declaration. Returns true if diagnosed.
 template 
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5ee7ea48cc983c..5cbd15441b7d96 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4603,6 +4603,11 @@ class Sema final : public SemaBase {
 
   enum class RetainOwnershipKind { NS, CF, OS };
 
+  void DetectMissingFormatAttributes(const FunctionDecl *Callee,
+ ArrayRef Args,
+ SourceLocation Loc);
+  void EmitMissingFormatAttributesDiagnostic(const FunctionDecl *Caller);
+
   UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
   StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
 
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e703a62ff9cf18..3fcca6d1e96f92 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3452,8 +3452,10 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
 }
   }
 
-  if (FD)
+  if (FD) {
 diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
+DetectMissingFormatAttributes(FD, Args, Loc);
+ 

[clang-tools-extra] [clang-tidy] fix incorrect argument names in documentation for ExtraArgs and ExtraArgsBefore (PR #120963)

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

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

LGTM, thanks!

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


[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-24 Thread via cfe-commits

amane-ame wrote:

Ping.

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


[clang] Reapply "[Clang] Improve diagnostics for expansion length mismatch" (PR #121044)

2024-12-24 Thread Younan Zhang via cfe-commits

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


[clang] [clang][Sema] Move computing enum width and type to a separate function (PR #120965)

2024-12-24 Thread Ilia Kuklin via cfe-commits


@@ -20008,6 +20008,87 @@ bool Sema::IsValueInFlagEnum(const EnumDecl *ED, const 
llvm::APInt &Val,
   return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
 }
 
+bool Sema::ComputeBestEnumProperties(ASTContext &Context, EnumDecl *Enum,
+ bool is_cpp, bool isPacked,

kuilpd wrote:

Maybe better to put this function into `EnumDecl` itself? It has `ASTContext` 
within it filled on both Sema and LLDB side, and then `EnumDecl`  can fill it's 
own `BestType` and `BestPromotionType` fields using this function. 

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


[clang] [Clang][MIPS] Send correct architecture for MinGW toolchains (PR #121042)

2024-12-24 Thread Hervé Poussineau via cfe-commits


@@ -85,6 +85,10 @@
 // RUN:   | FileCheck %s --check-prefix CHECK_MINGW_EC_LINK
 // CHECK_MINGW_EC_LINK: "-m" "arm64ecpe"
 
+// RUN: %clang --target=mipsel-windows-gnu -### -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK_MINGW_MIPSPE
+// CHECK_MINGW_MIPSPE: "-m" "mipspe"

hpoussin wrote:

No, binutils removed support for "mipspe" target in 2.31 (2018)

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


[clang] [llvm] [AArch64] Add Neon FP8 conversion intrinsics (PR #119033)

2024-12-24 Thread Momchil Velikov via cfe-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/119033

>From db963803f1a84b7deae31330e9c2f74df85a01cd Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Fri, 6 Dec 2024 13:09:23 +
Subject: [PATCH 1/7] [AArch64] Refactor implementation of FP8 types (NFC)

* The FP8 scalar type (`__mfp8`) was described as a vector type
* The FP8 vector types were described/assumed to have
  integer element type (the element type ought to be `__mfp8`),
* Add support for `m` type specifier (denoting `__mfp8`)
  in `DecodeTypeFromStr` and create SVE builtin prototypes using
  the specifier, instead of `int8_t`.
---
 clang/include/clang/AST/Type.h|  5 +++
 .../clang/Basic/AArch64SVEACLETypes.def   | 24 +---
 clang/lib/AST/ASTContext.cpp  | 37 +++
 clang/lib/AST/ItaniumMangle.cpp   |  5 +++
 clang/lib/AST/Type.cpp|  4 +-
 clang/lib/CodeGen/CodeGenTypes.cpp| 13 +--
 clang/lib/CodeGen/Targets/AArch64.cpp |  7 +++-
 clang/utils/TableGen/SveEmitter.cpp   |  4 +-
 8 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 09c98f642852fc..aa313719a65755 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2518,6 +2518,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isFloat32Type() const;
   bool isDoubleType() const;
   bool isBFloat16Type() const;
+  bool isMFloat8Type() const;
   bool isFloat128Type() const;
   bool isIbm128Type() const;
   bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
@@ -8532,6 +8533,10 @@ inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
+inline bool Type::isMFloat8Type() const {
+  return isSpecificBuiltinType(BuiltinType::MFloat8);
+}
+
 inline bool Type::isFloat128Type() const {
   return isSpecificBuiltinType(BuiltinType::Float128);
 }
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def 
b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 063cac1f4a58ee..6b704b386536c9 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -57,6 +57,11 @@
 //  - IsBF true for vector of brain float elements.
 
//===--===//
 
+#ifndef SVE_SCALAR_TYPE
+#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
+  SVE_TYPE(Name, Id, SingletonId)
+#endif
+
 #ifndef SVE_VECTOR_TYPE
 #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
   SVE_TYPE(Name, Id, SingletonId)
@@ -72,6 +77,11 @@
   SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, false, true)
 #endif
 
+#ifndef SVE_VECTOR_TYPE_MFLOAT
+#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, 
ElBits, NF) \
+  SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, false, false)
+#endif
+
 #ifndef SVE_VECTOR_TYPE_FLOAT
 #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, 
ElBits, NF) \
   SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, true, false)
@@ -125,8 +135,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", 
SveFloat64, SveFloat64Ty
 
 SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, 
SveBFloat16Ty, 8, 16, 1)
 
-// This is a 8 bits opaque type.
-SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t",  SveMFloat8, 
SveMFloat8Ty, 16, 8, 1, false)
+SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t",  SveMFloat8, 
SveMFloat8Ty, 16, 8, 1)
 
 //
 // x2
@@ -148,7 +157,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", 
"svfloat64x2_t", SveFloat64x2, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", 
SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, 
SveMFloat8x2Ty, 16, 8, 2, false)
+SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, 
SveMFloat8x2Ty, 16, 8, 2)
 
 //
 // x3
@@ -170,7 +179,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", 
"svfloat64x3_t", SveFloat64x3, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", 
SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, 
SveMFloat8x3Ty, 16, 8, 3, false)
+SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, 
SveMFloat8x3Ty, 16, 8, 3)
 
 //
 // x4
@@ -192,7 +201,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", 
"svfloat64x4_t", SveFloat64x4, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", 
SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, 
SveMFloat8x4T

[clang] [AArch64] Refactor implementation of FP8 types (NFC) (PR #118969)

2024-12-24 Thread Momchil Velikov via cfe-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/118969

>From db963803f1a84b7deae31330e9c2f74df85a01cd Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Fri, 6 Dec 2024 13:09:23 +
Subject: [PATCH] [AArch64] Refactor implementation of FP8 types (NFC)

* The FP8 scalar type (`__mfp8`) was described as a vector type
* The FP8 vector types were described/assumed to have
  integer element type (the element type ought to be `__mfp8`),
* Add support for `m` type specifier (denoting `__mfp8`)
  in `DecodeTypeFromStr` and create SVE builtin prototypes using
  the specifier, instead of `int8_t`.
---
 clang/include/clang/AST/Type.h|  5 +++
 .../clang/Basic/AArch64SVEACLETypes.def   | 24 +---
 clang/lib/AST/ASTContext.cpp  | 37 +++
 clang/lib/AST/ItaniumMangle.cpp   |  5 +++
 clang/lib/AST/Type.cpp|  4 +-
 clang/lib/CodeGen/CodeGenTypes.cpp| 13 +--
 clang/lib/CodeGen/Targets/AArch64.cpp |  7 +++-
 clang/utils/TableGen/SveEmitter.cpp   |  4 +-
 8 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 09c98f642852fc..aa313719a65755 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2518,6 +2518,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isFloat32Type() const;
   bool isDoubleType() const;
   bool isBFloat16Type() const;
+  bool isMFloat8Type() const;
   bool isFloat128Type() const;
   bool isIbm128Type() const;
   bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
@@ -8532,6 +8533,10 @@ inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
+inline bool Type::isMFloat8Type() const {
+  return isSpecificBuiltinType(BuiltinType::MFloat8);
+}
+
 inline bool Type::isFloat128Type() const {
   return isSpecificBuiltinType(BuiltinType::Float128);
 }
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def 
b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 063cac1f4a58ee..6b704b386536c9 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -57,6 +57,11 @@
 //  - IsBF true for vector of brain float elements.
 
//===--===//
 
+#ifndef SVE_SCALAR_TYPE
+#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
+  SVE_TYPE(Name, Id, SingletonId)
+#endif
+
 #ifndef SVE_VECTOR_TYPE
 #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
   SVE_TYPE(Name, Id, SingletonId)
@@ -72,6 +77,11 @@
   SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, false, true)
 #endif
 
+#ifndef SVE_VECTOR_TYPE_MFLOAT
+#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, 
ElBits, NF) \
+  SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, false, false)
+#endif
+
 #ifndef SVE_VECTOR_TYPE_FLOAT
 #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, 
ElBits, NF) \
   SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, true, false)
@@ -125,8 +135,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", 
SveFloat64, SveFloat64Ty
 
 SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, 
SveBFloat16Ty, 8, 16, 1)
 
-// This is a 8 bits opaque type.
-SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t",  SveMFloat8, 
SveMFloat8Ty, 16, 8, 1, false)
+SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t",  SveMFloat8, 
SveMFloat8Ty, 16, 8, 1)
 
 //
 // x2
@@ -148,7 +157,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", 
"svfloat64x2_t", SveFloat64x2, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", 
SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, 
SveMFloat8x2Ty, 16, 8, 2, false)
+SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, 
SveMFloat8x2Ty, 16, 8, 2)
 
 //
 // x3
@@ -170,7 +179,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", 
"svfloat64x3_t", SveFloat64x3, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", 
SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, 
SveMFloat8x3Ty, 16, 8, 3, false)
+SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, 
SveMFloat8x3Ty, 16, 8, 3)
 
 //
 // x4
@@ -192,7 +201,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", 
"svfloat64x4_t", SveFloat64x4, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", 
SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, 
SveMFloat8x4Ty, 1

[clang] [Clang][AArch64] Allow FP8 Neon vector types to be used by __builtin_shufflevector (PR #119031)

2024-12-24 Thread Momchil Velikov via cfe-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/119031

>From db963803f1a84b7deae31330e9c2f74df85a01cd Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Fri, 6 Dec 2024 13:09:23 +
Subject: [PATCH 1/3] [AArch64] Refactor implementation of FP8 types (NFC)

* The FP8 scalar type (`__mfp8`) was described as a vector type
* The FP8 vector types were described/assumed to have
  integer element type (the element type ought to be `__mfp8`),
* Add support for `m` type specifier (denoting `__mfp8`)
  in `DecodeTypeFromStr` and create SVE builtin prototypes using
  the specifier, instead of `int8_t`.
---
 clang/include/clang/AST/Type.h|  5 +++
 .../clang/Basic/AArch64SVEACLETypes.def   | 24 +---
 clang/lib/AST/ASTContext.cpp  | 37 +++
 clang/lib/AST/ItaniumMangle.cpp   |  5 +++
 clang/lib/AST/Type.cpp|  4 +-
 clang/lib/CodeGen/CodeGenTypes.cpp| 13 +--
 clang/lib/CodeGen/Targets/AArch64.cpp |  7 +++-
 clang/utils/TableGen/SveEmitter.cpp   |  4 +-
 8 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 09c98f642852fc..aa313719a65755 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2518,6 +2518,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isFloat32Type() const;
   bool isDoubleType() const;
   bool isBFloat16Type() const;
+  bool isMFloat8Type() const;
   bool isFloat128Type() const;
   bool isIbm128Type() const;
   bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
@@ -8532,6 +8533,10 @@ inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
+inline bool Type::isMFloat8Type() const {
+  return isSpecificBuiltinType(BuiltinType::MFloat8);
+}
+
 inline bool Type::isFloat128Type() const {
   return isSpecificBuiltinType(BuiltinType::Float128);
 }
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def 
b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 063cac1f4a58ee..6b704b386536c9 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -57,6 +57,11 @@
 //  - IsBF true for vector of brain float elements.
 
//===--===//
 
+#ifndef SVE_SCALAR_TYPE
+#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
+  SVE_TYPE(Name, Id, SingletonId)
+#endif
+
 #ifndef SVE_VECTOR_TYPE
 #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
   SVE_TYPE(Name, Id, SingletonId)
@@ -72,6 +77,11 @@
   SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, false, true)
 #endif
 
+#ifndef SVE_VECTOR_TYPE_MFLOAT
+#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, 
ElBits, NF) \
+  SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, false, false)
+#endif
+
 #ifndef SVE_VECTOR_TYPE_FLOAT
 #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, 
ElBits, NF) \
   SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, true, false)
@@ -125,8 +135,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", 
SveFloat64, SveFloat64Ty
 
 SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, 
SveBFloat16Ty, 8, 16, 1)
 
-// This is a 8 bits opaque type.
-SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t",  SveMFloat8, 
SveMFloat8Ty, 16, 8, 1, false)
+SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t",  SveMFloat8, 
SveMFloat8Ty, 16, 8, 1)
 
 //
 // x2
@@ -148,7 +157,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", 
"svfloat64x2_t", SveFloat64x2, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", 
SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, 
SveMFloat8x2Ty, 16, 8, 2, false)
+SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, 
SveMFloat8x2Ty, 16, 8, 2)
 
 //
 // x3
@@ -170,7 +179,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", 
"svfloat64x3_t", SveFloat64x3, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", 
SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, 
SveMFloat8x3Ty, 16, 8, 3, false)
+SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, 
SveMFloat8x3Ty, 16, 8, 3)
 
 //
 // x4
@@ -192,7 +201,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", 
"svfloat64x4_t", SveFloat64x4, Sv
 
 SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", 
SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4)
 
-SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, 
SveMFloat8x4T

[clang] 8dbb337 - [analyzer] Simplify CallEvent castArgToParamTypeIfNeeded (#120981)

2024-12-24 Thread via cfe-commits

Author: Balazs Benics
Date: 2024-12-24T17:05:38+01:00
New Revision: 8dbb33762cfb8d8606d28a71293f437ddffee4af

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

LOG: [analyzer] Simplify CallEvent castArgToParamTypeIfNeeded (#120981)

I noticed recently that this code (that I wrote xD) uses the
`getRuntimeDefinition()` which isn't quite necessary for the simple task
this function was designed for.

Why would it be better not using this API here?
I'm experimenting with improving how virtual functions are inlined,
where depending on our ability of deducing the dynamic type of the
object we may end up with inaccurate type information. Such inaccuracy
would mean that we may have multiple runtime definitions. After that,
this code would become ambiguous.

To resolve this, I decided to refactor this and use a simpler - but
equivalent approach.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/CallEvent.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp 
b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index 0fdef7487b9814..bb4a39f68280cd 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -435,27 +435,27 @@ static SVal processArgument(SVal Value, const Expr 
*ArgumentExpr,
 /// runtime definition don't match in terms of argument and parameter count.
 static SVal castArgToParamTypeIfNeeded(const CallEvent &Call, unsigned ArgIdx,
SVal ArgVal, SValBuilder &SVB) {
-  const FunctionDecl *RTDecl =
-  Call.getRuntimeDefinition().getDecl()->getAsFunction();
   const auto *CallExprDecl = dyn_cast_or_null(Call.getDecl());
-
-  if (!RTDecl || !CallExprDecl)
+  if (!CallExprDecl)
 return ArgVal;
 
+  const FunctionDecl *Definition = CallExprDecl;
+  Definition->hasBody(Definition);
+
   // The function decl of the Call (in the AST) will not have any parameter
   // declarations, if it was 'only' declared without a prototype. However, the
   // engine will find the appropriate runtime definition - basically a
   // redeclaration, which has a function body (and a function prototype).
-  if (CallExprDecl->hasPrototype() || !RTDecl->hasPrototype())
+  if (CallExprDecl->hasPrototype() || !Definition->hasPrototype())
 return ArgVal;
 
   // Only do this cast if the number arguments at the callsite matches with
   // the parameters at the runtime definition.
-  if (Call.getNumArgs() != RTDecl->getNumParams())
+  if (Call.getNumArgs() != Definition->getNumParams())
 return UnknownVal();
 
   const Expr *ArgExpr = Call.getArgExpr(ArgIdx);
-  const ParmVarDecl *Param = RTDecl->getParamDecl(ArgIdx);
+  const ParmVarDecl *Param = Definition->getParamDecl(ArgIdx);
   return SVB.evalCast(ArgVal, Param->getType(), ArgExpr->getType());
 }
 



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


[clang] [analyzer] Simplify CallEvent castArgToParamTypeIfNeeded (PR #120981)

2024-12-24 Thread Balazs Benics via cfe-commits

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


[clang] [Clang][Xtensa] Add Xtensa target. (PR #118008)

2024-12-24 Thread Alexey Gerenkov via cfe-commits

https://github.com/gerekon updated 
https://github.com/llvm/llvm-project/pull/118008

>From 55b08ec540d18d50011ef9fb0e301e1f7650ca9e Mon Sep 17 00:00:00 2001
From: Andrei Safronov 
Date: Thu, 1 Jun 2023 00:42:37 +0300
Subject: [PATCH] [Clang][Xtensa] Add Xtensa target.

---
 clang/include/clang/Basic/TargetInfo.h |   9 +-
 clang/lib/AST/ASTContext.cpp   |  39 
 clang/lib/Basic/CMakeLists.txt |   1 +
 clang/lib/Basic/Targets.cpp|   4 +
 clang/lib/Basic/Targets/Xtensa.cpp |  35 +++
 clang/lib/Basic/Targets/Xtensa.h   | 111 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp |   5 +
 clang/test/Preprocessor/init.c | 249 +
 clang/test/Preprocessor/stdint.c   | 107 +
 9 files changed, 559 insertions(+), 1 deletion(-)
 create mode 100644 clang/lib/Basic/Targets/Xtensa.cpp
 create mode 100644 clang/lib/Basic/Targets/Xtensa.h

diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 82bd537b242c1c..f2905f30a7c34b 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -358,7 +358,14 @@ class TargetInfo : public TransferrableTargetInfo,
 //void *__saved_reg_area_end_pointer;
 //void *__overflow_area_pointer;
 //} va_list;
-HexagonBuiltinVaList
+HexagonBuiltinVaList,
+
+// typedef struct __va_list_tag {
+//int* __va_stk;
+//int* __va_reg;
+//int __va_ndx;
+//} va_list;
+XtensaABIBuiltinVaList
   };
 
 protected:
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 6ec927e13a7552..8b4ae58e8427a9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -9751,6 +9751,43 @@ static TypedefDecl *CreateHexagonBuiltinVaListDecl(const 
ASTContext *Context) {
   return Context->buildImplicitTypedef(VaListTagArrayType, 
"__builtin_va_list");
 }
 
+static TypedefDecl *
+CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context) {
+  // typedef struct __va_list_tag {
+  RecordDecl *VaListTagDecl = Context->buildImplicitRecord("__va_list_tag");
+
+  VaListTagDecl->startDefinition();
+
+  // int* __va_stk;
+  // int* __va_reg;
+  // int __va_ndx;
+  constexpr size_t NumFields = 3;
+  QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
+Context->getPointerType(Context->IntTy),
+Context->IntTy};
+  const char *FieldNames[NumFields] = {"__va_stk", "__va_reg", "__va_ndx"};
+
+  // Create fields
+  for (unsigned i = 0; i < NumFields; ++i) {
+FieldDecl *Field = FieldDecl::Create(
+*Context, VaListTagDecl, SourceLocation(), SourceLocation(),
+&Context->Idents.get(FieldNames[i]), FieldTypes[i], /*TInfo=*/nullptr,
+/*BitWidth=*/nullptr,
+/*Mutable=*/false, ICIS_NoInit);
+Field->setAccess(AS_public);
+VaListTagDecl->addDecl(Field);
+  }
+  VaListTagDecl->completeDefinition();
+  Context->VaListTagDecl = VaListTagDecl;
+  QualType VaListTagType = Context->getRecordType(VaListTagDecl);
+
+  // } __va_list_tag;
+  TypedefDecl *VaListTagTypedefDecl =
+  Context->buildImplicitTypedef(VaListTagType, "__builtin_va_list");
+
+  return VaListTagTypedefDecl;
+}
+
 static TypedefDecl *CreateVaListDecl(const ASTContext *Context,
  TargetInfo::BuiltinVaListKind Kind) {
   switch (Kind) {
@@ -9772,6 +9809,8 @@ static TypedefDecl *CreateVaListDecl(const ASTContext 
*Context,
 return CreateSystemZBuiltinVaListDecl(Context);
   case TargetInfo::HexagonBuiltinVaList:
 return CreateHexagonBuiltinVaListDecl(Context);
+  case TargetInfo::XtensaABIBuiltinVaList:
+return CreateXtensaABIBuiltinVaListDecl(Context);
   }
 
   llvm_unreachable("Unhandled __builtin_va_list type kind");
diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index e11e1ac4a6fa63..331dfbb3f4b67e 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -120,6 +120,7 @@ add_clang_library(clangBasic
   Targets/WebAssembly.cpp
   Targets/X86.cpp
   Targets/XCore.cpp
+  Targets/Xtensa.cpp
   TokenKinds.cpp
   TypeTraits.cpp
   Version.cpp
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 706a391023b3a3..f44559cb68cdd2 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -40,6 +40,7 @@
 #include "Targets/WebAssembly.h"
 #include "Targets/X86.h"
 #include "Targets/XCore.h"
+#include "Targets/Xtensa.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticFrontend.h"
 #include "llvm/ADT/StringExtras.h"
@@ -743,6 +744,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 default:
 return std::make_unique(Triple, Opts);
 }
+
+  case llvm::Triple::xtensa:
+return std::make_unique(Triple, Opts);
   }
 }
 } // namespace targets
diff --git a/clang/lib/Basic/

[clang] [AArch64] Implement FP8 SVE/SME reinterpret intrinsics (PR #121063)

2024-12-24 Thread Jonathan Thackray via cfe-commits

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

LGTM

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


[clang] [OpenMP] Codegen support for masked combined construct (PR #120520)

2024-12-24 Thread Alexey Bataev via cfe-commits

alexey-bataev wrote:

Split into several separate patches, one for each directive

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


[clang] [llvm] [Clang] [OpenMP] Add support for '#pragma omp stripe'. (PR #119891)

2024-12-24 Thread Alexey Bataev via cfe-commits

alexey-bataev wrote:

Aldo, update OpenMPSupport page

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


[clang] [llvm] [Clang] [OpenMP] Add support for '#pragma omp stripe'. (PR #119891)

2024-12-24 Thread Alexey Bataev via cfe-commits


@@ -5621,6 +5623,81 @@ class OMPTileDirective final : public 
OMPLoopTransformationDirective {
   }
 };
 
+class OMPStripeDirective final : public OMPLoopTransformationDirective {
+  friend class ASTStmtReader;
+  friend class OMPExecutableDirective;
+
+  /// Default list of offsets.
+  enum {
+PreInitsOffset = 0,
+TransformedStmtOffset,
+  };
+
+  explicit OMPStripeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
+  unsigned NumLoops)
+  : OMPLoopTransformationDirective(OMPStripeDirectiveClass,
+   llvm::omp::OMPD_stripe, StartLoc, 
EndLoc,
+   NumLoops) {
+setNumGeneratedLoops(3 * NumLoops);

alexey-bataev wrote:

Tile might have just a bug, do you really use 3 * NumLoops generated loops?

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


[clang] [llvm] [Clang] [OpenMP] Add support for '#pragma omp stripe'. (PR #119891)

2024-12-24 Thread Alexey Bataev via cfe-commits


@@ -1179,6 +1179,13 @@ def OMP_Tile : Directive<"tile"> {
   let association = AS_Loop;
   let category = CA_Executable;
 }
+def OMP_Stripe : Directive<"stripe"> {
+  let allowedOnceClauses = [
+VersionedClause,

alexey-bataev wrote:

Sounds good

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


[clang] [llvm] [Clang] [OpenMP] Add support for '#pragma omp stripe'. (PR #119891)

2024-12-24 Thread Zahira Ammarguellat via cfe-commits


@@ -5621,6 +5623,81 @@ class OMPTileDirective final : public 
OMPLoopTransformationDirective {
   }
 };
 
+class OMPStripeDirective final : public OMPLoopTransformationDirective {
+  friend class ASTStmtReader;
+  friend class OMPExecutableDirective;
+
+  /// Default list of offsets.
+  enum {
+PreInitsOffset = 0,
+TransformedStmtOffset,
+  };
+
+  explicit OMPStripeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
+  unsigned NumLoops)
+  : OMPLoopTransformationDirective(OMPStripeDirectiveClass,
+   llvm::omp::OMPD_stripe, StartLoc, 
EndLoc,
+   NumLoops) {
+setNumGeneratedLoops(3 * NumLoops);

zahiraam wrote:

I see. Let me take a deeper look at this.

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


[clang] [SYCL] Basic diagnostics for the sycl_kernel_entry_point attribute. (PR #120327)

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

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

>From 6ed96d3bf22c5da5af995ea5ffe083baf91594bb Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Fri, 1 Nov 2024 16:03:24 -0700
Subject: [PATCH 1/8] [SYCL] Basic diagnostics for the sycl_kernel_entry_point
 attribute.

The `sycl_kernel_entry_point` attribute is used to declare a function that
defines a pattern for an offload kernel entry point. 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 function is
required to have a `void` return type. The function must not be a non-static
member function, be deleted or defaulted, be declared with the `constexpr` or
`consteval` specifiers, be declared with the `[[noreturn]]` attribute, be a
coroutine, or accept variadic arguments.

Diagnostics are not yet provided for the following:
- Use of a type as a kernel name that does not satisfy the forward
  declarability requirements specified in section 5.2, "Naming of kernels",
  of the SYCL 2020 specification.
- Use of a type as a parameter of the attributed function that does not
  satisfy the kernel parameter requirements specified in section 4.12.4,
  "Rules for parameter passing to kernels", of the SYCL 2020 specification
  (each such function parameter constitutes a kernel parameter).
- Use of language features that are not permitted in device functions as
  specified in section 5.4, "Language restrictions for device functions",
  of the SYCL 2020 specification.

There are several issues noted by various FIXME comments.
- The diagnostic generated for kernel name conflicts needs additional work
  to better detail the relevant source locations; such as the location of
  each declaration as well as the original source of each kernel name.
- A number of the tests illustrate spurious errors being produced due to
  attributes that appertain to function templates being instantiated too
  early (during overload resolution as opposed to after an overload is
  selected).
---
 clang/include/clang/AST/ASTContext.h  |  10 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  23 ++
 clang/include/clang/Sema/SemaSYCL.h   |   2 +
 clang/lib/AST/ASTContext.cpp  |  13 +
 clang/lib/Sema/SemaDecl.cpp   |  30 ++-
 clang/lib/Sema/SemaSYCL.cpp   | 126 +
 clang/lib/Sema/SemaTemplate.cpp   |   2 +
 clang/lib/Serialization/ASTReaderDecl.cpp |  13 +-
 .../ast-dump-sycl-kernel-entry-point.cpp  |  23 +-
 ...-kernel-entry-point-attr-appertainment.cpp | 255 ++
 .../sycl-kernel-entry-point-attr-grammar.cpp  |  15 --
 ...el-entry-point-attr-kernel-name-module.cpp | 104 +++
 ...ernel-entry-point-attr-kernel-name-pch.cpp |  36 +++
 ...cl-kernel-entry-point-attr-kernel-name.cpp |  87 ++
 .../sycl-kernel-entry-point-attr-sfinae.cpp   |  65 +
 16 files changed, 784 insertions(+), 21 deletions(-)
 create mode 100644 
clang/test/SemaSYCL/sycl-kernel-entry-point-attr-appertainment.cpp
 create mode 100644 
clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-module.cpp
 create mode 100644 
clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-pch.cpp
 create mode 100644 
clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-kernel-entry-point-attr-sfinae.cpp

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1e89a6805ce9c6..0e07c5d6ce8fba 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3360,6 +3360,16 @@ class ASTContext : public RefCountedBase {
   /// this function.
   void registerSYCLEntryPointFunction(FunctionDecl *FD);
 
+  /// Given a type used as a SYCL kernel name, returns a reference to the
+  /// metadata generated from the corresponding SYCL kernel entry point.
+  /// Aborts if the provided type is not a registered SYCL kernel name.
+  const SYCLKernelInfo &getSYCLKernelInfo(QualType T) const;
+
+  /// Returns a pointer to the metadata generated from the corresponding
+  /// SYCLkernel entry point if the provided type corresponds to a registered
+  /// SYCL kernel name. Returns a null pointer otherwise.
+  const SYCLKernelInfo *findSYCLKernelInfo(QualType T) const;
+
   
//======//
   //Statistics
   
//======//
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 3ac490d3

[clang] [Clang][MIPS] Create specific targets for MIPS PE/COFF (PR #121040)

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

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


[clang] 970f65a - [Clang][MIPS] Create specific targets for MIPS PE/COFF (#121040)

2024-12-24 Thread via cfe-commits

Author: Hervé Poussineau
Date: 2024-12-25T09:26:31+08:00
New Revision: 970f65a98a681831e308860e7004e066f5152791

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

LOG: [Clang][MIPS] Create specific targets for MIPS PE/COFF (#121040)

Implement GNU and MSVC variants.
When using them, _WIN32 and _M_MRX000/_MIPS_ macros are correctly
defined.

Added: 


Modified: 
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/Mips.cpp
clang/lib/Basic/Targets/Mips.h
clang/test/Preprocessor/predefined-win-macros.c

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 706a391023b3a3..d0815ad33bc759 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -297,6 +297,14 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::NaCl:
   return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::Win32:
+  switch (Triple.getEnvironment()) {
+  case llvm::Triple::GNU:
+return std::make_unique(Triple, Opts);
+  case llvm::Triple::MSVC:
+  default: // Assume MSVC for unknown environments
+return std::make_unique(Triple, Opts);
+  }
 default:
   return std::make_unique(Triple, Opts);
 }

diff  --git a/clang/lib/Basic/Targets/Mips.cpp 
b/clang/lib/Basic/Targets/Mips.cpp
index 174bc9d2ab9967..d56995e3ccc48e 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -304,3 +304,62 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
&Diags) const {
 
   return true;
 }
+
+WindowsMipsTargetInfo::WindowsMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsTargetInfo(Triple, Opts), Triple(Triple) {}
+
+void WindowsMipsTargetInfo::getVisualStudioDefines(
+const LangOptions &Opts, MacroBuilder &Builder) const {
+  Builder.defineMacro("_M_MRX000", "4000");
+}
+
+TargetInfo::BuiltinVaListKind
+WindowsMipsTargetInfo::getBuiltinVaListKind() const {
+  return TargetInfo::CharPtrBuiltinVaList;
+}
+
+TargetInfo::CallingConvCheckResult
+WindowsMipsTargetInfo::checkCallingConvention(CallingConv CC) const {
+  switch (CC) {
+  case CC_X86StdCall:
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;
+  case CC_C:
+  case CC_OpenCLKernel:
+  case CC_PreserveMost:
+  case CC_PreserveAll:
+  case CC_Swift:
+  case CC_SwiftAsync:
+return CCCR_OK;
+  default:
+return CCCR_Warning;
+  }
+}
+
+// Windows MIPS, MS (C++) ABI
+MicrosoftMipsTargetInfo::MicrosoftMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsMipsTargetInfo(Triple, Opts) {
+  TheCXXABI.set(TargetCXXABI::Microsoft);
+}
+
+void MicrosoftMipsTargetInfo::getTargetDefines(const LangOptions &Opts,
+   MacroBuilder &Builder) const {
+  WindowsMipsTargetInfo::getTargetDefines(Opts, Builder);
+  WindowsMipsTargetInfo::getVisualStudioDefines(Opts, Builder);
+}
+
+MinGWMipsTargetInfo::MinGWMipsTargetInfo(const llvm::Triple &Triple,
+ const TargetOptions &Opts)
+: WindowsMipsTargetInfo(Triple, Opts) {
+  TheCXXABI.set(TargetCXXABI::GenericMIPS);
+}
+
+void MinGWMipsTargetInfo::getTargetDefines(const LangOptions &Opts,
+   MacroBuilder &Builder) const {
+  WindowsMipsTargetInfo::getTargetDefines(Opts, Builder);
+  Builder.defineMacro("_MIPS_");
+}

diff  --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 8acaf56523b218..7ddcd57053cb2b 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
 
+#include "OSTargets.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/Support/Compiler.h"
@@ -450,6 +451,42 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 return std::make_pair(32, 32);
   }
 };
+
+class LLVM_LIBRARY_VISIBILITY WindowsMipsTargetInfo
+: public WindowsTargetInfo {
+  const llvm::Triple Triple;
+
+public:
+  WindowsMipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
+
+  void getVisualStudioDefines(const LangOptions &Opts,
+  MacroBuilder &Builder) const;
+
+  BuiltinVaListKind getBuiltinVaListKind() const override;
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
+};
+
+// Windows MIPS, MS (C++) ABI
+class LLVM_LIBRARY_VISIBILITY MicrosoftMipsTargetInfo
+: publ

[clang] [SYCL] Basic diagnostics for the sycl_kernel_entry_point attribute. (PR #120327)

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

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

>From 6ed96d3bf22c5da5af995ea5ffe083baf91594bb Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Fri, 1 Nov 2024 16:03:24 -0700
Subject: [PATCH 1/7] [SYCL] Basic diagnostics for the sycl_kernel_entry_point
 attribute.

The `sycl_kernel_entry_point` attribute is used to declare a function that
defines a pattern for an offload kernel entry point. 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 function is
required to have a `void` return type. The function must not be a non-static
member function, be deleted or defaulted, be declared with the `constexpr` or
`consteval` specifiers, be declared with the `[[noreturn]]` attribute, be a
coroutine, or accept variadic arguments.

Diagnostics are not yet provided for the following:
- Use of a type as a kernel name that does not satisfy the forward
  declarability requirements specified in section 5.2, "Naming of kernels",
  of the SYCL 2020 specification.
- Use of a type as a parameter of the attributed function that does not
  satisfy the kernel parameter requirements specified in section 4.12.4,
  "Rules for parameter passing to kernels", of the SYCL 2020 specification
  (each such function parameter constitutes a kernel parameter).
- Use of language features that are not permitted in device functions as
  specified in section 5.4, "Language restrictions for device functions",
  of the SYCL 2020 specification.

There are several issues noted by various FIXME comments.
- The diagnostic generated for kernel name conflicts needs additional work
  to better detail the relevant source locations; such as the location of
  each declaration as well as the original source of each kernel name.
- A number of the tests illustrate spurious errors being produced due to
  attributes that appertain to function templates being instantiated too
  early (during overload resolution as opposed to after an overload is
  selected).
---
 clang/include/clang/AST/ASTContext.h  |  10 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  23 ++
 clang/include/clang/Sema/SemaSYCL.h   |   2 +
 clang/lib/AST/ASTContext.cpp  |  13 +
 clang/lib/Sema/SemaDecl.cpp   |  30 ++-
 clang/lib/Sema/SemaSYCL.cpp   | 126 +
 clang/lib/Sema/SemaTemplate.cpp   |   2 +
 clang/lib/Serialization/ASTReaderDecl.cpp |  13 +-
 .../ast-dump-sycl-kernel-entry-point.cpp  |  23 +-
 ...-kernel-entry-point-attr-appertainment.cpp | 255 ++
 .../sycl-kernel-entry-point-attr-grammar.cpp  |  15 --
 ...el-entry-point-attr-kernel-name-module.cpp | 104 +++
 ...ernel-entry-point-attr-kernel-name-pch.cpp |  36 +++
 ...cl-kernel-entry-point-attr-kernel-name.cpp |  87 ++
 .../sycl-kernel-entry-point-attr-sfinae.cpp   |  65 +
 16 files changed, 784 insertions(+), 21 deletions(-)
 create mode 100644 
clang/test/SemaSYCL/sycl-kernel-entry-point-attr-appertainment.cpp
 create mode 100644 
clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-module.cpp
 create mode 100644 
clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-pch.cpp
 create mode 100644 
clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-kernel-entry-point-attr-sfinae.cpp

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1e89a6805ce9c6..0e07c5d6ce8fba 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3360,6 +3360,16 @@ class ASTContext : public RefCountedBase {
   /// this function.
   void registerSYCLEntryPointFunction(FunctionDecl *FD);
 
+  /// Given a type used as a SYCL kernel name, returns a reference to the
+  /// metadata generated from the corresponding SYCL kernel entry point.
+  /// Aborts if the provided type is not a registered SYCL kernel name.
+  const SYCLKernelInfo &getSYCLKernelInfo(QualType T) const;
+
+  /// Returns a pointer to the metadata generated from the corresponding
+  /// SYCLkernel entry point if the provided type corresponds to a registered
+  /// SYCL kernel name. Returns a null pointer otherwise.
+  const SYCLKernelInfo *findSYCLKernelInfo(QualType T) const;
+
   
//======//
   //Statistics
   
//======//
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 3ac490d3

[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

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


@@ -2474,6 +2480,11 @@ class AnnotatingParser {
   Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
 Current.setType(TT_StringInConcatenation);
   }
+} else if (Style.isCpp() && Current.is(tok::kw_using)) {
+  if (Current.Next && Current.Next->Next && Current.Next->Next->Next) {
+if (Current.Next->Next->Next->isTypeName(LangOpts))

owenca wrote:

IMO this is too simplistic to be very useful. See the general syntax 
[here](https://en.cppreference.com/w/cpp/language/type_alias). Also, this 
doesn't work at all if the `using` statement is in a header file.

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


[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

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


@@ -38,6 +40,10 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+// TODO: Add new Type modifiers
+llvm::SmallVector castIdentifiers{"__type_identity_t",
+   "remove_reference_t"};

owenca wrote:

What about `std::vector`, `std::whatever`, `foo::bar`, etc?

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-24 Thread Chris B via cfe-commits

https://github.com/llvm-beanz approved this pull request.


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


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

2024-12-24 Thread via cfe-commits


@@ -11077,6 +11077,221 @@ TEST_F(FormatTest, 
WrapsTemplateDeclarationsWithComments) {
   Style);
 }
 
+TEST_F(FormatTest, BreakBeforeTemplateClose) {

leijurv wrote:

Sorry if I misunderstood, but, I thought I added that here: 
![Screenshot_20241224-154618](https://github.com/user-attachments/assets/ce0a3af9-421e-48a9-a8ec-9b443f26b324)


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


[clang] [llvm] [openmp] [OpenMP] Use generic IR for the OpenMP DeviceRTL (PR #119091)

2024-12-24 Thread via cfe-commits

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


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


[clang] [llvm] [openmp] [OpenMP] Use generic IR for the OpenMP DeviceRTL (PR #119091)

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

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


[clang] [clang-format] Skip line splices when sorting C++ includes (PR #120680)

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

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


[clang] 141c544 - [clang-format] Skip line splices when sorting C++ includes (#120680)

2024-12-24 Thread via cfe-commits

Author: Owen Pan
Date: 2024-12-24T21:47:53-08:00
New Revision: 141c544c03702ac7c50522373ad781ede3685e0a

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

LOG: [clang-format] Skip line splices when sorting C++ includes (#120680)

Fixes #109864.

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index dcaac4b0d42cc5..95129a8fe9240c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3246,8 +3246,15 @@ tooling::Replacements sortCppIncludes(const FormatStyle 
&Style, StringRef Code,
   SmallVector RawStringMatches;
   std::string RawStringTermination = ")\"";
 
-  for (;;) {
-auto Pos = Code.find('\n', SearchFrom);
+  for (const auto Size = Code.size(); SearchFrom < Size;) {
+size_t Pos = SearchFrom;
+if (Code[SearchFrom] != '\n') {
+  do { // Search for the first newline while skipping line splices.
+++Pos;
+Pos = Code.find('\n', Pos);
+  } while (Pos != StringRef::npos && Code[Pos - 1] == '\\');
+}
+
 StringRef Line =
 Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
 

diff  --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index 31753825646373..cb3f8c73a04871 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -984,6 +984,18 @@ TEST_F(SortIncludesTest, SortAndDeduplicateIncludes) {
 "#include \n"
 "#include "));
 
+  verifyFormat("/* COPYRIGHT *\\\n"
+   "\\* (C) 2024  */\n"
+   "\n"
+   "#include \n"
+   "#include ",
+   sort("/* COPYRIGHT *\\\n"
+"\\* (C) 2024  */\n"
+"\n"
+"#include \n"
+"#include \n"
+"#include "));
+
   Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
   verifyFormat("#include \n"
"#include \n"



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


[clang] [Clang] fix for heterogeneous chip's host side's MaybeODRUseExprs clear (PR #121085)

2024-12-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (fuaq)


Changes



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


1 Files Affected:

- (modified) clang/lib/Sema/SemaStmtAsm.cpp (+6) 


``diff
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index a0b203fbdfec21..5ff11fac9ca5f7 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -240,6 +240,12 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, 
bool IsSimple,
  Expr *asmString, MultiExprArg clobbers,
  unsigned NumLabels,
  SourceLocation RParenLoc) {
+  struct _Cleaner {
+Sema &S;
+~_Cleaner() {
+  S.DiscardCleanupsInEvaluationContext();
+}
+  } _C{*this};
   unsigned NumClobbers = clobbers.size();
   StringLiteral **Constraints =
 reinterpret_cast(constraints.data());

``




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


[clang] [Clang] fix for heterogeneous chip's host side's MaybeODRUseExprs clear (PR #121085)

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


[clang] [Clang] fix for heterogeneous chip's host side's MaybeODRUseExprs clear (PR #121085)

2024-12-24 Thread via cfe-commits

https://github.com/fuaq created https://github.com/llvm/llvm-project/pull/121085

None

>From 0009c75d7ac422444f426fdb7db463865c3b78fe Mon Sep 17 00:00:00 2001
From: fuanqi 
Date: Tue, 24 Dec 2024 19:47:31 -0800
Subject: [PATCH] [Clang] fix for heterogeneous chip's host side's
 MaybeODRUseExprs clear

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

diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index a0b203fbdfec21..5ff11fac9ca5f7 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -240,6 +240,12 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, 
bool IsSimple,
  Expr *asmString, MultiExprArg clobbers,
  unsigned NumLabels,
  SourceLocation RParenLoc) {
+  struct _Cleaner {
+Sema &S;
+~_Cleaner() {
+  S.DiscardCleanupsInEvaluationContext();
+}
+  } _C{*this};
   unsigned NumClobbers = clobbers.size();
   StringLiteral **Constraints =
 reinterpret_cast(constraints.data());

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


[clang] [clang-format] Skip line splices when sorting C++ includes (PR #120680)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-aarch64-sve-vla-2stage` running on `linaro-g3-04` while building `clang` 
at step 11 "build stage 2".

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


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

```
Step 11 (build stage 2) failure: 'ninja' (failure)
...
[8332/8795] Building CXX object 
tools/flang/tools/f18-parse-demo/CMakeFiles/f18-parse-demo.dir/f18-parse-demo.cpp.o
[8333/8795] Linking CXX static library lib/libHLFIRTransforms.a
[8334/8795] Linking CXX executable bin/f18-parse-demo
[8335/8795] Linking CXX executable tools/flang/unittests/Evaluate/logical.test
[8336/8795] Linking CXX executable tools/flang/unittests/Evaluate/real.test
[8337/8795] Linking CXX executable tools/flang/unittests/Evaluate/integer.test
[8338/8795] Linking CXX executable 
tools/flang/unittests/Evaluate/expression.test
[8339/8795] Linking CXX executable tools/flang/unittests/Evaluate/folding.test
[8340/8795] Linking CXX static library lib/libFortranLower.a
[8341/8795] Building CXX object 
tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o
FAILED: 
tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage1.install/bin/clang++
 -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -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/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/tools/flang/lib/Frontend
 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/llvm/flang/lib/Frontend
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/llvm/flang/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/tools/flang/include
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/llvm/llvm/include 
-isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/llvm/llvm/../mlir/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/tools/mlir/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/tools/clang/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/llvm/llvm/../clang/include
 -mcpu=neoverse-512tvb -mllvm -scalable-vectorization=preferred -mllvm 
-treat-scalable-fixed-error-as-warning=false -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -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 -Wno-comment -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-string-conversion 
-Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument 
-Wstring-conversion   -Wcovered-switch-default -Wno-nested-anon-types 
-O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD 
-MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o 
-MF 
tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o.d 
-o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o 
-c 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/llvm/flang/lib/Frontend/FrontendActions.cpp
Killed
command timed out: 1200 seconds without output running [b'ninja'], attempting 
to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=3839.337225

```



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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqciac (Load-Store Adress calculation) extension (PR #121037)

2024-12-24 Thread Craig Topper via cfe-commits

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


[clang] [llvm] [Clang] [OpenMP] Add support for '#pragma omp stripe'. (PR #119891)

2024-12-24 Thread Alexey Bataev via cfe-commits


@@ -1179,6 +1179,13 @@ def OMP_Tile : Directive<"tile"> {
   let association = AS_Loop;
   let category = CA_Executable;
 }
+def OMP_Stripe : Directive<"stripe"> {
+  let allowedOnceClauses = [
+VersionedClause,

alexey-bataev wrote:

Yes, should be 60

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


[clang] Reapply "[Clang] Improve diagnostics for expansion length mismatch" (PR #121044)

2024-12-24 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

Thanks! I think I completely missed the fact these were both reverted.

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


  1   2   >