[clang] [HLSL] add BuiltinsHLSL and set it up as target builtins. (PR #81902)

2024-02-15 Thread Farzon Lotfi via cfe-commits

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


[clang] [HLSL] Vector standard conversions (PR #71098)

2024-02-15 Thread Nico Weber via cfe-commits

nico wrote:

Is this causing these crashes? http://45.33.8.238/linux/130945/step_7.txt

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


[clang] [clang][dataflow] Fix crash on unions introduced in ba279934c6ab09d5394a89d8318651aefd8d565b (PR #81918)

2024-02-15 Thread Yitzhak Mandelbaum via cfe-commits

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


[clang] 60cb09b - [clang][dataflow] Fix crash on unions introduced in ba279934c6ab09d5394a89d8318651aefd8d565b (#81918)

2024-02-15 Thread via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2024-02-15T16:19:10-05:00
New Revision: 60cb09ba4f0ad6602483b40625a272eeebdcdc45

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

LOG: [clang][dataflow] Fix crash on unions introduced in 
ba279934c6ab09d5394a89d8318651aefd8d565b (#81918)

The commit was itself a crash fix, but inadvertently changed the
behavior for unions, which results in crashes.

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index fc7395457f551d..513f22d8aa0f9c 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -663,6 +663,12 @@ class TransferVisitor : public 
ConstStmtVisitor {
   void VisitInitListExpr(const InitListExpr *S) {
 QualType Type = S->getType();
 
+if (Type->isUnionType()) {
+  if (auto *Val = Env.createValue(Type))
+Env.setValue(*S, *Val);
+  return;
+}
+
 if (!Type->isStructureOrClassType()) {
   // Until array initialization is implemented, we don't need to care about
   // cases where `getNumInits() > 1`.

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 87e6e83d2e03a9..a65b0446ac7818 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2367,6 +2367,27 @@ TEST(TransferTest, InitListExprAsXValue) {
   });
 }
 
+TEST(TransferTest, InitListExprAsUnion) {
+  // This is a crash repro.
+  std::string Code = R"cc(
+class target {
+  union {
+int *a;
+bool *b;
+  } F;
+
+ public:
+  constexpr target() : F{nullptr} {}
+};
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+// Just verify that it doesn't crash.
+  });
+}
+
 TEST(TransferTest, CopyConstructor) {
   std::string Code = R"(
 struct A {



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


[clang] [libc] [llvm] [openmp] [libc] Rework the GPU build to be a regular target (PR #81921)

2024-02-15 Thread Joseph Huber via cfe-commits

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


[clang] [libc] [llvm] [openmp] [libc] Rework the GPU build to be a regular target (PR #81921)

2024-02-15 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/81921

>From 5fdaa384ebc962429950b79098dee0581c74f4f3 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Tue, 13 Feb 2024 21:08:02 -0600
Subject: [PATCH] [libc] Rework the GPU build to be a regular target

Summary:
This is a massive patch because it reworks the entire build and
everything that depends on it. This is not split up because various bots
would fail otherwise. I will attempt to describe the necessary changes
here.

This patch completely reworks how the GPU build is built and targeted.
Previously, we used a standard runtimes build and handled both NVPTX and
AMDGPU in a single build via multi-targeting. This added a lot of
divergence in the build system and prevented us from doing various
things like building for the CPU / GPU at the same time, or exporting
the startup libraries or running tests without a full rebuild.

The new appraoch is to handle the GPU builds as strict cross-compiling
runtimes. The first step required
https://github.com/llvm/llvm-project/pull/81557 to allow the `LIBC`
target to build for the GPU without touching the other targets. This
means that the GPU uses all the same handling as the other builds in
`libc`.

The new expected way to build the GPU libc is with
`LLVM_LIBC_RUNTIME_TARGETS=amdgcn-amd-amdhsa;nvptx64-nvidia-cuda`.

The second step was reworking how we generated the embedded GPU library
by moving it into the library install step. Where we previously had one
`libcgpu.a` we now have `libcgpu-amdgpu.a` and `libcgpu-nvptx.a`. This
patch includes the necessary clang / OpenMP changes to make that not
break the bots when this lands.

We unfortunately still require that the NVPTX target has an `internal`
target for tests. This is because the NVPTX target needs to do LTO for
the provided version (The offloading toolchain can handle it) but cannot
use it for the native toolchain which is used for making tests.

This approach is vastly suprerior in every way, allowing us to treat the
GPU as a standard cross-compiling target. We can now install the GPU
utilities to do things like use the offload tests and other fun things.

Depends on https://github.com/llvm/llvm-project/pull/81557
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|  37 +-
 clang/test/Driver/openmp-offload-gpu.c|  14 +-
 libc/CMakeLists.txt   |  20 +-
 .../cmake/modules/LLVMLibCArchitectures.cmake |  28 +-
 libc/cmake/modules/LLVMLibCCheckMPFR.cmake|   2 +-
 libc/cmake/modules/LLVMLibCHeaderRules.cmake  |   2 +-
 libc/cmake/modules/LLVMLibCLibraryRules.cmake | 141 +--
 libc/cmake/modules/LLVMLibCObjectRules.cmake  | 395 --
 libc/cmake/modules/LLVMLibCTestRules.cmake|  71 ++--
 .../modules/prepare_libc_gpu_build.cmake  | 102 ++---
 libc/include/CMakeLists.txt   |   6 +-
 libc/lib/CMakeLists.txt   |  43 +-
 libc/src/__support/File/CMakeLists.txt|   2 +-
 libc/src/__support/GPU/CMakeLists.txt |   2 +-
 libc/src/__support/OSUtil/CMakeLists.txt  |   2 +-
 libc/src/__support/RPC/CMakeLists.txt |   2 +-
 libc/src/math/CMakeLists.txt  |  16 +-
 libc/src/math/gpu/vendor/CMakeLists.txt   |   1 -
 libc/src/stdio/CMakeLists.txt |   2 +-
 libc/src/stdlib/CMakeLists.txt|   4 +-
 libc/src/string/CMakeLists.txt|  12 +-
 libc/startup/gpu/CMakeLists.txt   |  35 +-
 libc/startup/gpu/amdgpu/CMakeLists.txt|  12 -
 libc/startup/gpu/nvptx/CMakeLists.txt |  11 +-
 libc/test/CMakeLists.txt  |   6 +-
 libc/test/IntegrationTest/CMakeLists.txt  |  16 -
 libc/test/UnitTest/CMakeLists.txt |   2 +-
 libc/test/src/__support/CMakeLists.txt|  49 ++-
 libc/test/src/__support/CPP/CMakeLists.txt|   2 +-
 libc/test/src/__support/File/CMakeLists.txt   |   2 +-
 libc/test/src/errno/CMakeLists.txt|   2 +-
 libc/test/src/math/CMakeLists.txt |  20 +-
 libc/test/src/math/smoke/CMakeLists.txt   |   8 +-
 libc/test/src/stdio/CMakeLists.txt|   2 +-
 libc/test/src/stdlib/CMakeLists.txt   |   6 +-
 libc/test/utils/UnitTest/CMakeLists.txt   |   2 +-
 libc/utils/CMakeLists.txt |   2 +-
 libc/utils/MPFRWrapper/CMakeLists.txt |   2 +-
 libc/utils/gpu/CMakeLists.txt |   4 +-
 libc/utils/gpu/loader/CMakeLists.txt  |  42 +-
 libc/utils/gpu/loader/amdgpu/CMakeLists.txt   |   6 +-
 libc/utils/gpu/loader/nvptx/CMakeLists.txt|  10 +-
 libc/utils/gpu/server/CMakeLists.txt  |   9 +
 llvm/CMakeLists.txt   |   8 +
 llvm/cmake/modules/HandleLLVMOptions.cmake|   7 +
 llvm/runtimes/CMakeLists.txt  |   6 +-
 openmp/libomptarget/CMakeLists.txt|   9 +-
 .../plugins-nextgen/common/CMakeLists.txt |   6 +-
 .../plugins-nextgen/common/src/RPC.cpp|   3 +-

[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-02-15 Thread Alexey Bataev via cfe-commits

alexey-bataev wrote:

I already told, that you don't need the changes neither in sema, nor in stmt 
class. All function changes are in codegen, no other changes are required.

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


[clang] [llvm] [RFC][AMDGPU] Use `bf16` instead of `i16` for bfloat (PR #80908)

2024-02-15 Thread Stanislav Mekhanoshin via cfe-commits


@@ -0,0 +1,8 @@
+# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -disassemble -show-encoding < %s | 
FileCheck %s
+# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1200 -disassemble -show-encoding < %s | 
FileCheck %s
+
+# CHECK: v_dot2_bf16_bf16 v5, v1, v2, 0x42c8

rampitec wrote:

Add encoding to the check lines. Currently it is broken and encoded value is 
different from decoded one.

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


[clang] [libc] [llvm] [openmp] [libc] Rework the GPU build to be a regular target (PR #81921)

2024-02-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Joseph Huber (jhuber6)


Changes

Summary:
This is a massive patch because it reworks the entire build and
everything that depends on it. This is not split up because various bots
would fail otherwise. I will attempt to describe the necessary changes
here.

This patch completely reworks how the GPU build is built and targeted.
Previously, we used a standard runtimes build and handled both NVPTX and
AMDGPU in a single build via multi-targeting. This added a lot of
divergence in the build system and prevented us from doing various
things like building for the CPU / GPU at the same time, or exporting
the startup libraries or running tests without a full rebuild.

The new appraoch is to handle the GPU builds as strict cross-compiling
runtimes. The first step required
https://github.com/llvm/llvm-project/pull/81557 to allow the `LIBC`
target to build for the GPU without touching the other targets. This
means that the GPU uses all the same handling as the other builds in
`libc`.

The new expected way to build the GPU libc is with
`LLVM_LIBC_RUNTIME_TARGETS=amdgcn-amd-amdhsa;nvptx64-nvidia-cuda`.

The second step was reworking how we generated the embedded GPU library
by moving it into the library install step. Where we previously had one
`libcgpu.a` we now have `libcgpu-amdgpu.a` and `libcgpu-nvptx.a`. This
patch includes the necessary clang / OpenMP changes to make that not
break the bots when this lands.

We unfortunately still require that the NVPTX target has an `internal`
target for tests. This is because the NVPTX target needs to do LTO for
the provided version (The offloading toolchain can handle it) but cannot
use it for the native toolchain which is used for making tests.

This approach is vastly suprerior in every way, allowing us to treat the
GPU as a standard cross-compiling target. We can now install the GPU
utilities to do things like use the offload tests and other fun things.

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


---

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


50 Files Affected:

- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+63-31) 
- (modified) clang/test/Driver/openmp-offload-gpu.c (+11-3) 
- (modified) libc/CMakeLists.txt (+10-10) 
- (modified) libc/cmake/modules/LLVMLibCArchitectures.cmake (+16-12) 
- (modified) libc/cmake/modules/LLVMLibCCheckMPFR.cmake (+1-1) 
- (modified) libc/cmake/modules/LLVMLibCHeaderRules.cmake (+1-1) 
- (modified) libc/cmake/modules/LLVMLibCLibraryRules.cmake (+117-24) 
- (modified) libc/cmake/modules/LLVMLibCObjectRules.cmake (+78-317) 
- (modified) libc/cmake/modules/LLVMLibCTestRules.cmake (+44-27) 
- (modified) libc/cmake/modules/prepare_libc_gpu_build.cmake (+36-66) 
- (modified) libc/include/CMakeLists.txt (+3-3) 
- (modified) libc/lib/CMakeLists.txt (+41-6) 
- (modified) libc/src/__support/File/CMakeLists.txt (+1-1) 
- (modified) libc/src/__support/GPU/CMakeLists.txt (+1-1) 
- (modified) libc/src/__support/OSUtil/CMakeLists.txt (+1-1) 
- (modified) libc/src/__support/RPC/CMakeLists.txt (+1-1) 
- (modified) libc/src/math/CMakeLists.txt (+14-2) 
- (modified) libc/src/math/gpu/vendor/CMakeLists.txt (-1) 
- (modified) libc/src/stdio/CMakeLists.txt (+1-1) 
- (modified) libc/src/stdlib/CMakeLists.txt (+2-2) 
- (modified) libc/src/string/CMakeLists.txt (+6-6) 
- (modified) libc/startup/gpu/CMakeLists.txt (+13-22) 
- (modified) libc/startup/gpu/amdgpu/CMakeLists.txt (-12) 
- (modified) libc/startup/gpu/nvptx/CMakeLists.txt (+2-9) 
- (modified) libc/test/CMakeLists.txt (+3-3) 
- (modified) libc/test/IntegrationTest/CMakeLists.txt (-16) 
- (modified) libc/test/UnitTest/CMakeLists.txt (+1-1) 
- (modified) libc/test/src/__support/CMakeLists.txt (+26-23) 
- (modified) libc/test/src/__support/CPP/CMakeLists.txt (+1-1) 
- (modified) libc/test/src/__support/File/CMakeLists.txt (+1-1) 
- (modified) libc/test/src/errno/CMakeLists.txt (+1-1) 
- (modified) libc/test/src/math/CMakeLists.txt (+12-8) 
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+4-4) 
- (modified) libc/test/src/stdio/CMakeLists.txt (+1-1) 
- (modified) libc/test/src/stdlib/CMakeLists.txt (+3-3) 
- (modified) libc/test/utils/UnitTest/CMakeLists.txt (+1-1) 
- (modified) libc/utils/CMakeLists.txt (+1-1) 
- (modified) libc/utils/MPFRWrapper/CMakeLists.txt (+1-1) 
- (modified) libc/utils/gpu/CMakeLists.txt (+3-1) 
- (modified) libc/utils/gpu/loader/CMakeLists.txt (+26-16) 
- (modified) libc/utils/gpu/loader/amdgpu/CMakeLists.txt (+3-3) 
- (modified) libc/utils/gpu/loader/nvptx/CMakeLists.txt (+5-5) 
- (modified) libc/utils/gpu/server/CMakeLists.txt (+9) 
- (modified) llvm/CMakeLists.txt (+8) 
- (modified) llvm/cmake/modules/HandleLLVMOptions.cmake (+7) 
- (modified) llvm/runtimes/CMakeLists.txt (+3-3) 
- (modified) openmp/libomptarget/CMakeLists.txt (+1-8) 
- (modified) openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt (+5-1) 
-

[clang] [libc] [llvm] [openmp] [libc] Rework the GPU build to be a regular target (PR #81921)

2024-02-15 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 created 
https://github.com/llvm/llvm-project/pull/81921

Summary:
This is a massive patch because it reworks the entire build and
everything that depends on it. This is not split up because various bots
would fail otherwise. I will attempt to describe the necessary changes
here.

This patch completely reworks how the GPU build is built and targeted.
Previously, we used a standard runtimes build and handled both NVPTX and
AMDGPU in a single build via multi-targeting. This added a lot of
divergence in the build system and prevented us from doing various
things like building for the CPU / GPU at the same time, or exporting
the startup libraries or running tests without a full rebuild.

The new appraoch is to handle the GPU builds as strict cross-compiling
runtimes. The first step required
https://github.com/llvm/llvm-project/pull/81557 to allow the `LIBC`
target to build for the GPU without touching the other targets. This
means that the GPU uses all the same handling as the other builds in
`libc`.

The new expected way to build the GPU libc is with
`LLVM_LIBC_RUNTIME_TARGETS=amdgcn-amd-amdhsa;nvptx64-nvidia-cuda`.

The second step was reworking how we generated the embedded GPU library
by moving it into the library install step. Where we previously had one
`libcgpu.a` we now have `libcgpu-amdgpu.a` and `libcgpu-nvptx.a`. This
patch includes the necessary clang / OpenMP changes to make that not
break the bots when this lands.

We unfortunately still require that the NVPTX target has an `internal`
target for tests. This is because the NVPTX target needs to do LTO for
the provided version (The offloading toolchain can handle it) but cannot
use it for the native toolchain which is used for making tests.

This approach is vastly suprerior in every way, allowing us to treat the
GPU as a standard cross-compiling target. We can now install the GPU
utilities to do things like use the offload tests and other fun things.

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


>From 2f71ab85f56da2eb5d5a86bbee6479231a7129e5 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Tue, 13 Feb 2024 21:08:02 -0600
Subject: [PATCH] [libc] Rework the GPU build to be a regular target

Summary:
This is a massive patch because it reworks the entire build and
everything that depends on it. This is not split up because various bots
would fail otherwise. I will attempt to describe the necessary changes
here.

This patch completely reworks how the GPU build is built and targeted.
Previously, we used a standard runtimes build and handled both NVPTX and
AMDGPU in a single build via multi-targeting. This added a lot of
divergence in the build system and prevented us from doing various
things like building for the CPU / GPU at the same time, or exporting
the startup libraries or running tests without a full rebuild.

The new appraoch is to handle the GPU builds as strict cross-compiling
runtimes. The first step required
https://github.com/llvm/llvm-project/pull/81557 to allow the `LIBC`
target to build for the GPU without touching the other targets. This
means that the GPU uses all the same handling as the other builds in
`libc`.

The new expected way to build the GPU libc is with
`LLVM_LIBC_RUNTIME_TARGETS=amdgcn-amd-amdhsa;nvptx64-nvidia-cuda`.

The second step was reworking how we generated the embedded GPU library
by moving it into the library install step. Where we previously had one
`libcgpu.a` we now have `libcgpu-amdgpu.a` and `libcgpu-nvptx.a`. This
patch includes the necessary clang / OpenMP changes to make that not
break the bots when this lands.

We unfortunately still require that the NVPTX target has an `internal`
target for tests. This is because the NVPTX target needs to do LTO for
the provided version (The offloading toolchain can handle it) but cannot
use it for the native toolchain which is used for making tests.

This approach is vastly suprerior in every way, allowing us to treat the
GPU as a standard cross-compiling target. We can now install the GPU
utilities to do things like use the offload tests and other fun things.

Depends on https://github.com/llvm/llvm-project/pull/81557
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|  94 +++--
 clang/test/Driver/openmp-offload-gpu.c|  14 +-
 libc/CMakeLists.txt   |  20 +-
 .../cmake/modules/LLVMLibCArchitectures.cmake |  28 +-
 libc/cmake/modules/LLVMLibCCheckMPFR.cmake|   2 +-
 libc/cmake/modules/LLVMLibCHeaderRules.cmake  |   2 +-
 libc/cmake/modules/LLVMLibCLibraryRules.cmake | 141 +--
 libc/cmake/modules/LLVMLibCObjectRules.cmake  | 395 --
 libc/cmake/modules/LLVMLibCTestRules.cmake|  71 ++--
 .../modules/prepare_libc_gpu_build.cmake  | 102 ++---
 libc/include/CMakeLists.txt   |   6 +-
 libc/lib/CMakeLists.txt   |  47 ++-
 libc/src/__support/File/CMakeLists.txt|   2 +-
 libc/src/__support/GPU/CMakeLists.txt |   2 +-
 lib

[clang] [clangd] Fix C++20 modules crash (PR #81919)

2024-02-15 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: None (CLRN)


Changes

This fix partially reverts 
https://github.com/llvm/llvm-project/commit/a0b6747804e46665ecfd00295b60432bfe1775b6.

The serialization part is restored to the state prior to the mentioned commit 
as it causing issue with reading back Decl.
ODR checks logic is kept in place.

Close https://github.com/llvm/llvm-project/issues/80570.

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


3 Files Affected:

- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+7-14) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+3-6) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+2-6) 


``diff
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index ffba04f28782ea..4e58301a6b8eef 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -804,10 +804,8 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
   ED->setScopedUsingClassTag(EnumDeclBits.getNextBit());
   ED->setFixed(EnumDeclBits.getNextBit());
 
-  if (!shouldSkipCheckingODR(ED)) {
-ED->setHasODRHash(true);
-ED->ODRHash = Record.readInt();
-  }
+  ED->setHasODRHash(true);
+  ED->ODRHash = Record.readInt();
 
   // If this is a definition subject to the ODR, and we already have a
   // definition, merge this one into it.
@@ -1102,10 +1100,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   if (FD->isExplicitlyDefaulted())
 FD->setDefaultLoc(readSourceLocation());
 
-  if (!shouldSkipCheckingODR(FD)) {
-FD->ODRHash = Record.readInt();
-FD->setHasODRHash(true);
-  }
+  FD->ODRHash = Record.readInt();
+  FD->setHasODRHash(true);
 
   if (FD->isDefaulted()) {
 if (unsigned NumLookups = Record.readInt()) {
@@ -1981,12 +1977,9 @@ void ASTDeclReader::ReadCXXDefinitionData(
 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
 #undef FIELD
 
-  // We only perform ODR checks for decls not in GMF.
-  if (!shouldSkipCheckingODR(D)) {
-// Note: the caller has deserialized the IsLambda bit already.
-Data.ODRHash = Record.readInt();
-Data.HasODRHash = true;
-  }
+  // Note: the caller has deserialized the IsLambda bit already.
+  Data.ODRHash = Record.readInt();
+  Data.HasODRHash = true;
 
   if (Record.readInt()) {
 Reader.DefinitionSource[D] =
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 740bec586a5e33..31789cfb289154 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6068,12 +6068,9 @@ void ASTRecordWriter::AddCXXDefinitionData(const 
CXXRecordDecl *D) {
 
   Record->push_back(DefinitionBits);
 
-  // We only perform ODR checks for decls not in GMF.
-  if (!shouldSkipCheckingODR(D)) {
-// getODRHash will compute the ODRHash if it has not been previously
-// computed.
-Record->push_back(D->getODRHash());
-  }
+  // getODRHash will compute the ODRHash if it has not been previously
+  // computed.
+  Record->push_back(D->getODRHash());
 
   bool ModulesDebugInfo =
   Writer->Context->getLangOpts().ModulesDebugInfo && !D->isDependentType();
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index f224075643e998..496c0fdbe0ebf6 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -493,9 +493,7 @@ void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {
   EnumDeclBits.addBit(D->isFixed());
   Record.push_back(EnumDeclBits);
 
-  // We only perform ODR checks for decls not in GMF.
-  if (!shouldSkipCheckingODR(D))
-Record.push_back(D->getODRHash());
+  Record.push_back(D->getODRHash());
 
   if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) 
{
 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
@@ -703,9 +701,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
   if (D->isExplicitlyDefaulted())
 Record.AddSourceLocation(D->getDefaultLoc());
 
-  // We only perform ODR checks for decls not in GMF.
-  if (!shouldSkipCheckingODR(D))
-Record.push_back(D->getODRHash());
+  Record.push_back(D->getODRHash());
 
   if (D->isDefaulted()) {
 if (auto *FDI = D->getDefaultedFunctionInfo()) {

``




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


[clang] [clang][dataflow] Fix crash on unions introduced in ba279934c6ab09d5394a89d8318651aefd8d565b (PR #81918)

2024-02-15 Thread Christopher Di Bella via cfe-commits

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


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


[clang] [clangd] Fix C++20 modules crash (PR #81919)

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


[clang] [clangd] Fix C++20 modules crash (PR #81919)

2024-02-15 Thread via cfe-commits

https://github.com/CLRN created https://github.com/llvm/llvm-project/pull/81919

This fix partially reverts 
https://github.com/llvm/llvm-project/commit/a0b6747804e46665ecfd00295b60432bfe1775b6.

The serialization part is restored to the state prior to the mentioned commit 
as it causing issue with reading back Decl.
ODR checks logic is kept in place.

Close https://github.com/llvm/llvm-project/issues/80570.

>From dae725e0c48837a18aa9b90945de0b86a33890ff Mon Sep 17 00:00:00 2001
From: clrn 
Date: Thu, 15 Feb 2024 20:41:34 +
Subject: [PATCH] [clangd] Fix C++20 modules crash

This fix partially reverts 
https://github.com/llvm/llvm-project/commit/a0b6747804e46665ecfd00295b60432bfe1775b6.

The serialization part is restored to the state prior to the mentioned commit 
as it causing issue with reading back Decl.
ODR checks logic is kept in place.

Close https://github.com/llvm/llvm-project/issues/80570.
---
 clang/lib/Serialization/ASTReaderDecl.cpp | 21 +++--
 clang/lib/Serialization/ASTWriter.cpp |  9 +++--
 clang/lib/Serialization/ASTWriterDecl.cpp |  8 ++--
 3 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index ffba04f28782ea..4e58301a6b8eef 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -804,10 +804,8 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
   ED->setScopedUsingClassTag(EnumDeclBits.getNextBit());
   ED->setFixed(EnumDeclBits.getNextBit());
 
-  if (!shouldSkipCheckingODR(ED)) {
-ED->setHasODRHash(true);
-ED->ODRHash = Record.readInt();
-  }
+  ED->setHasODRHash(true);
+  ED->ODRHash = Record.readInt();
 
   // If this is a definition subject to the ODR, and we already have a
   // definition, merge this one into it.
@@ -1102,10 +1100,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   if (FD->isExplicitlyDefaulted())
 FD->setDefaultLoc(readSourceLocation());
 
-  if (!shouldSkipCheckingODR(FD)) {
-FD->ODRHash = Record.readInt();
-FD->setHasODRHash(true);
-  }
+  FD->ODRHash = Record.readInt();
+  FD->setHasODRHash(true);
 
   if (FD->isDefaulted()) {
 if (unsigned NumLookups = Record.readInt()) {
@@ -1981,12 +1977,9 @@ void ASTDeclReader::ReadCXXDefinitionData(
 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
 #undef FIELD
 
-  // We only perform ODR checks for decls not in GMF.
-  if (!shouldSkipCheckingODR(D)) {
-// Note: the caller has deserialized the IsLambda bit already.
-Data.ODRHash = Record.readInt();
-Data.HasODRHash = true;
-  }
+  // Note: the caller has deserialized the IsLambda bit already.
+  Data.ODRHash = Record.readInt();
+  Data.HasODRHash = true;
 
   if (Record.readInt()) {
 Reader.DefinitionSource[D] =
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 740bec586a5e33..31789cfb289154 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6068,12 +6068,9 @@ void ASTRecordWriter::AddCXXDefinitionData(const 
CXXRecordDecl *D) {
 
   Record->push_back(DefinitionBits);
 
-  // We only perform ODR checks for decls not in GMF.
-  if (!shouldSkipCheckingODR(D)) {
-// getODRHash will compute the ODRHash if it has not been previously
-// computed.
-Record->push_back(D->getODRHash());
-  }
+  // getODRHash will compute the ODRHash if it has not been previously
+  // computed.
+  Record->push_back(D->getODRHash());
 
   bool ModulesDebugInfo =
   Writer->Context->getLangOpts().ModulesDebugInfo && !D->isDependentType();
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index f224075643e998..496c0fdbe0ebf6 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -493,9 +493,7 @@ void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {
   EnumDeclBits.addBit(D->isFixed());
   Record.push_back(EnumDeclBits);
 
-  // We only perform ODR checks for decls not in GMF.
-  if (!shouldSkipCheckingODR(D))
-Record.push_back(D->getODRHash());
+  Record.push_back(D->getODRHash());
 
   if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) 
{
 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
@@ -703,9 +701,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
   if (D->isExplicitlyDefaulted())
 Record.AddSourceLocation(D->getDefaultLoc());
 
-  // We only perform ODR checks for decls not in GMF.
-  if (!shouldSkipCheckingODR(D))
-Record.push_back(D->getODRHash());
+  Record.push_back(D->getODRHash());
 
   if (D->isDefaulted()) {
 if (auto *FDI = D->getDefaultedFunctionInfo()) {

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


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-02-15 Thread David Pagan via cfe-commits

ddpagan wrote:

Ping.

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


[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #67592)

2024-02-15 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/67592

>From 55b67a58ef8b9856e5f0a8f535b8617f59711dec Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Wed, 27 Sep 2023 11:59:04 -0700
Subject: [PATCH 01/16] Fix value of __FUNCTION__ and __func__ in MSVC mode.

---
 clang/lib/AST/Expr.cpp|  9 ++-
 clang/lib/AST/TypePrinter.cpp | 21 +-
 clang/test/Analysis/eval-predefined-exprs.cpp |  4 +-
 .../CodeGenCXX/mangle-nttp-anon-union.cpp |  2 +-
 clang/test/CodeGenCXX/predefined-expr.cpp | 18 -
 clang/test/SemaCXX/source_location.cpp| 72 +++
 6 files changed, 99 insertions(+), 27 deletions(-)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index af82ca0784af41..49f3495c090f19 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -773,8 +773,8 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const 
Decl *CurrentDecl) {
   }
   if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) {
 const auto &LO = Context.getLangOpts();
-if (((IK == Func || IK == Function) && !LO.MicrosoftExt) ||
-(IK == LFunction && LO.MicrosoftExt))
+if (((IK == Function || IK == Func) && !LO.MicrosoftExt) ||
+((IK == LFunction || IK == Func) && LO.MicrosoftExt))
   return FD->getNameAsString();
 
 SmallString<256> Name;
@@ -804,7 +804,10 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, 
const Decl *CurrentDecl) {
 PrintingPolicy Policy(LO);
 PrettyCallbacks PrettyCB(LO);
 Policy.Callbacks = &PrettyCB;
-Policy.UseClassForTemplateArgument = LO.MicrosoftExt;
+if (IK == Function && LO.MicrosoftExt) {
+  Policy.UseClassForTemplateArgument = LO.MicrosoftExt;
+  Policy.MSVCFormatting = LO.MicrosoftExt;
+}
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 3771a29f26b173..8a7cf85cdf126b 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2195,6 +2195,7 @@ printTo(raw_ostream &OS, ArrayRef Args, const 
PrintingPolicy &Policy,
 llvm::SmallVector OrigArgs;
 for (const TA &A : Args)
   OrigArgs.push_back(getArgument(A));
+
 while (!Args.empty() && getArgument(Args.back()).getIsDefaulted())
   Args = Args.drop_back();
   }
@@ -2218,10 +2219,24 @@ printTo(raw_ostream &OS, ArrayRef Args, const 
PrintingPolicy &Policy,
 } else {
   if (!FirstArg)
 OS << Comma;
-  if (Policy.UseClassForTemplateArgument &&
-  Argument.getKind() == TemplateArgument::Type)
-OS << "class ";
 
+  if (Policy.MSVCFormatting && Policy.UseClassForTemplateArgument &&
+  Argument.getKind() == TemplateArgument::Type &&
+  !Argument.getAsType()->isBuiltinType()) {
+const Type *Ty = Argument.getAsType().getTypePtr();
+const char *kw;
+if (Ty->isStructureType())
+  kw = "struct ";
+else if (Ty->isClassType())
+  kw = "class ";
+else if (Ty->isUnionType())
+  kw = "union ";
+else if (Ty->isEnumeralType())
+  kw = "enum ";
+else
+  llvm_unreachable("argument type not expected");
+OS << kw;
+  }
   // Tries to print the argument with location info if exists.
   printArgument(Arg, Policy, ArgOS,
 TemplateParameterList::shouldIncludeTypeForArgument(
diff --git a/clang/test/Analysis/eval-predefined-exprs.cpp 
b/clang/test/Analysis/eval-predefined-exprs.cpp
index 7be441eb5bad94..a6bac5ee9d486d 100644
--- a/clang/test/Analysis/eval-predefined-exprs.cpp
+++ b/clang/test/Analysis/eval-predefined-exprs.cpp
@@ -56,7 +56,7 @@ struct A {
 clang_analyzer_dump(__FUNCTION__);
 clang_analyzer_dump(__PRETTY_FUNCTION__);
 #ifdef ANALYZER_MS
-// expected-warning@-4 {{&Element{"A::A",0 S64b,char}}}
+// expected-warning@-4 {{&Element{"A",0 S64b,char}}}
 // expected-warning@-4 {{&Element{"A::A",0 S64b,char}}}
 #else
 // expected-warning@-7 {{&Element{"A",0 S64b,char}}}
@@ -80,7 +80,7 @@ struct A {
 clang_analyzer_dump(__FUNCTION__);
 clang_analyzer_dump(__PRETTY_FUNCTION__);
 #ifdef ANALYZER_MS
-// expected-warning@-4 {{&Element{"A::~A",0 S64b,char}}}
+// expected-warning@-4 {{&Element{"~A",0 S64b,char}}}
 // expected-warning@-4 {{&Element{"A::~A",0 S64b,char}}}
 #else
 // expected-warning@-7 {{&Element{"~A",0 S64b,char}}}
diff --git a/clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp 
b/clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp
index 78fa7c378c88d5..1982a3eeb94129 100644
--- a/clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp
+++ b/clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c++20 -emit-llvm %s -o - -triple=x86_64-linux-gnu | 
FileCheck %s
-// RUN: %clang_cc1 -std=c++20 -emit-llvm %s -o - -triple=x86_64-linux-gnu | 
llvm-cxxfilt -n | FileCheck %s --check-prefix D

[clang] [HLSL] Vector standard conversions (PR #71098)

2024-02-15 Thread Chris B via cfe-commits

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


[clang] [clang][dataflow] Fix crash on unions introduced in ba279934c6ab09d5394a89d8318651aefd8d565b (PR #81918)

2024-02-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yitzhak Mandelbaum (ymand)


Changes

The commit was itself a crash fix, but inadvertently changed the behavior for 
unions, which results in crashes.


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


2 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/Transfer.cpp (+6) 
- (modified) clang/unittests/Analysis/FlowSensitive/TransferTest.cpp (+21) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index fc7395457f551d..513f22d8aa0f9c 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -663,6 +663,12 @@ class TransferVisitor : public 
ConstStmtVisitor {
   void VisitInitListExpr(const InitListExpr *S) {
 QualType Type = S->getType();
 
+if (Type->isUnionType()) {
+  if (auto *Val = Env.createValue(Type))
+Env.setValue(*S, *Val);
+  return;
+}
+
 if (!Type->isStructureOrClassType()) {
   // Until array initialization is implemented, we don't need to care about
   // cases where `getNumInits() > 1`.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 87e6e83d2e03a9..a65b0446ac7818 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2367,6 +2367,27 @@ TEST(TransferTest, InitListExprAsXValue) {
   });
 }
 
+TEST(TransferTest, InitListExprAsUnion) {
+  // This is a crash repro.
+  std::string Code = R"cc(
+class target {
+  union {
+int *a;
+bool *b;
+  } F;
+
+ public:
+  constexpr target() : F{nullptr} {}
+};
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+// Just verify that it doesn't crash.
+  });
+}
+
 TEST(TransferTest, CopyConstructor) {
   std::string Code = R"(
 struct A {

``




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


[clang] [clang][dataflow] Fix crash on unions introduced in ba279934c6ab09d5394a89d8318651aefd8d565b (PR #81918)

2024-02-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis

Author: Yitzhak Mandelbaum (ymand)


Changes

The commit was itself a crash fix, but inadvertently changed the behavior for 
unions, which results in crashes.


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


2 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/Transfer.cpp (+6) 
- (modified) clang/unittests/Analysis/FlowSensitive/TransferTest.cpp (+21) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index fc7395457f551d..513f22d8aa0f9c 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -663,6 +663,12 @@ class TransferVisitor : public 
ConstStmtVisitor {
   void VisitInitListExpr(const InitListExpr *S) {
 QualType Type = S->getType();
 
+if (Type->isUnionType()) {
+  if (auto *Val = Env.createValue(Type))
+Env.setValue(*S, *Val);
+  return;
+}
+
 if (!Type->isStructureOrClassType()) {
   // Until array initialization is implemented, we don't need to care about
   // cases where `getNumInits() > 1`.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 87e6e83d2e03a9..a65b0446ac7818 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2367,6 +2367,27 @@ TEST(TransferTest, InitListExprAsXValue) {
   });
 }
 
+TEST(TransferTest, InitListExprAsUnion) {
+  // This is a crash repro.
+  std::string Code = R"cc(
+class target {
+  union {
+int *a;
+bool *b;
+  } F;
+
+ public:
+  constexpr target() : F{nullptr} {}
+};
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+// Just verify that it doesn't crash.
+  });
+}
+
 TEST(TransferTest, CopyConstructor) {
   std::string Code = R"(
 struct A {

``




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


[clang] [clang][dataflow] Fix crash on unions introduced in ba279934c6ab09d5394a89d8318651aefd8d565b (PR #81918)

2024-02-15 Thread Yitzhak Mandelbaum via cfe-commits

https://github.com/ymand created https://github.com/llvm/llvm-project/pull/81918

The commit was itself a crash fix, but inadvertently changed the behavior for 
unions, which results in crashes.


>From 86f1b2d4dded22eef613b9d92a4010e16fd1edc7 Mon Sep 17 00:00:00 2001
From: Yitzhak Mandelbaum 
Date: Thu, 15 Feb 2024 20:47:51 +
Subject: [PATCH] [clang][dataflow] Fix crash on unions introduced in
 ba279934c6ab09d5394a89d8318651aefd8d565b

The commit was itself a crash fix, but inadvertently changed the behavior for 
unions, which results in crashes.
---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp |  6 ++
 .../Analysis/FlowSensitive/TransferTest.cpp   | 21 +++
 2 files changed, 27 insertions(+)

diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index fc7395457f551d..513f22d8aa0f9c 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -663,6 +663,12 @@ class TransferVisitor : public 
ConstStmtVisitor {
   void VisitInitListExpr(const InitListExpr *S) {
 QualType Type = S->getType();
 
+if (Type->isUnionType()) {
+  if (auto *Val = Env.createValue(Type))
+Env.setValue(*S, *Val);
+  return;
+}
+
 if (!Type->isStructureOrClassType()) {
   // Until array initialization is implemented, we don't need to care about
   // cases where `getNumInits() > 1`.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 87e6e83d2e03a9..a65b0446ac7818 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2367,6 +2367,27 @@ TEST(TransferTest, InitListExprAsXValue) {
   });
 }
 
+TEST(TransferTest, InitListExprAsUnion) {
+  // This is a crash repro.
+  std::string Code = R"cc(
+class target {
+  union {
+int *a;
+bool *b;
+  } F;
+
+ public:
+  constexpr target() : F{nullptr} {}
+};
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+// Just verify that it doesn't crash.
+  });
+}
+
 TEST(TransferTest, CopyConstructor) {
   std::string Code = R"(
 struct A {

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-02-15 Thread David Goldman via cfe-commits

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


[clang-tools-extra] edfc859 - Add support for renaming objc methods, even those with multiple selector pieces (#76466)

2024-02-15 Thread via cfe-commits

Author: David Goldman
Date: 2024-02-15T15:53:37-05:00
New Revision: edfc859af89e44207bf499b5d702aa26a7357da4

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

LOG: Add support for renaming objc methods, even those with multiple selector 
pieces (#76466)

This adds support for  renaming Objective-C methods, which are unique since 
their method names can be split across multiple tokens.

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/Rename.h
clang-tools-extra/clangd/test/rename.test
clang-tools-extra/clangd/unittests/RenameTests.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index a87da252b7a7e9..3e097cbeed5929 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -844,14 +844,17 @@ void ClangdLSPServer::onWorkspaceSymbol(
 }
 
 void ClangdLSPServer::onPrepareRename(const TextDocumentPositionParams &Params,
-  Callback> Reply) {
+  Callback Reply) {
   Server->prepareRename(
   Params.textDocument.uri.file(), Params.position, /*NewName*/ 
std::nullopt,
   Opts.Rename,
   [Reply = std::move(Reply)](llvm::Expected Result) mutable {
 if (!Result)
   return Reply(Result.takeError());
-return Reply(std::move(Result->Target));
+PrepareRenameResult PrepareResult;
+PrepareResult.range = Result->Target;
+PrepareResult.placeholder = Result->Placeholder;
+return Reply(std::move(PrepareResult));
   });
 }
 

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 79579c22b788a9..6a9f097d551ae6 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -134,7 +134,7 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
   void onWorkspaceSymbol(const WorkspaceSymbolParams &,
  Callback>);
   void onPrepareRename(const TextDocumentPositionParams &,
-   Callback>);
+   Callback);
   void onRename(const RenameParams &, Callback);
   void onHover(const TextDocumentPositionParams &,
Callback>);

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index a6370649f5ad1c..f93a941a5c27e4 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -1187,6 +1187,15 @@ bool fromJSON(const llvm::json::Value &Params, 
RenameParams &R,
  O.map("position", R.position) && O.map("newName", R.newName);
 }
 
+llvm::json::Value toJSON(const PrepareRenameResult &PRR) {
+  if (PRR.placeholder.empty())
+return toJSON(PRR.range);
+  return llvm::json::Object{
+  {"range", toJSON(PRR.range)},
+  {"placeholder", PRR.placeholder},
+  };
+}
+
 llvm::json::Value toJSON(const DocumentHighlight &DH) {
   return llvm::json::Object{
   {"range", toJSON(DH.range)},

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index e88c804692568f..dc3fdb5b5f6c9b 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1436,6 +1436,14 @@ struct RenameParams {
 };
 bool fromJSON(const llvm::json::Value &, RenameParams &, llvm::json::Path);
 
+struct PrepareRenameResult {
+  /// Range of the string to rename.
+  Range range;
+  /// Placeholder text to use in the editor if non-empty.
+  std::string placeholder;
+};
+llvm::json::Value toJSON(const PrepareRenameResult &PRR);
+
 enum class DocumentHighlightKind { Text = 1, Read = 2, Write = 3 };
 
 /// A document highlight is a range inside a text document which deserves
@@ -1969,6 +1977,28 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &, const 
ASTNode &);
 } // namespace clang
 
 namespace llvm {
+
+template <> struct DenseMapInfo {
+  using Range = clang::clangd::Range;
+  static inline Range getEmptyKey() {
+static clang::clangd::Position Tomb{-1, -1};
+static Range R{Tomb, Tomb};
+return R;
+  }
+  static inline Range getTombstoneKey() {
+static clang::clangd::Position Tomb{-2, -2};
+static Range R{Tomb, Tomb};
+return R;
+  }
+  static unsigned getHashValue(const Range &Val) {
+return llvm::hash_combine(Val.start.line, Val.start.character, 
Val.end.line,
+ 

[clang] [clang] Move `AvailabilityInfo` into AST library (PR #81897)

2024-02-15 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/81897

>From 2779a90bb248bd48840a17f72cdc68691a397577 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 15 Feb 2024 10:36:45 -0800
Subject: [PATCH] [clang] Move `AvailabilityInfo` into AST library

Previously this class was only used by ExtractAPI, but it will soon also
be needed by InstallAPI. This patch should not change availbility
behavior but just centralizes the information next to what already is
captured about availability for ast traversal.
---
 clang/include/clang/AST/Availability.h| 52 +
 clang/include/clang/ExtractAPI/API.h  |  2 +-
 .../clang/ExtractAPI/AvailabilityInfo.h   | 76 ---
 .../clang/ExtractAPI/ExtractAPIVisitor.h  |  2 +-
 .../Availability.cpp} | 21 -
 clang/lib/AST/CMakeLists.txt  |  1 +
 clang/lib/ExtractAPI/CMakeLists.txt   |  1 -
 7 files changed, 72 insertions(+), 83 deletions(-)
 delete mode 100644 clang/include/clang/ExtractAPI/AvailabilityInfo.h
 rename clang/lib/{ExtractAPI/AvailabilityInfo.cpp => AST/Availability.cpp} 
(63%)

diff --git a/clang/include/clang/AST/Availability.h 
b/clang/include/clang/AST/Availability.h
index 527fc4b59a5f4d..ae3acbeffe7f18 100644
--- a/clang/include/clang/AST/Availability.h
+++ b/clang/include/clang/AST/Availability.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_AST_AVAILABILITY_H
 
 #include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/VersionTuple.h"
 
@@ -57,6 +58,57 @@ class AvailabilitySpec {
   bool isOtherPlatformSpec() const { return Version.empty(); }
 };
 
+class Decl;
+
+/// Storage of availability attributes for a declaration.
+struct AvailabilityInfo {
+  /// The domain is the platform for which this availability info applies to.
+  llvm::SmallString<32> Domain;
+  VersionTuple Introduced;
+  VersionTuple Deprecated;
+  VersionTuple Obsoleted;
+  bool UnconditionallyDeprecated = false;
+  bool UnconditionallyUnavailable = false;
+
+  AvailabilityInfo() = default;
+
+  /// Determine if this AvailabilityInfo represents the default availability.
+  bool isDefault() const { return *this == AvailabilityInfo(); }
+
+  /// Check if the symbol is unconditionally deprecated.
+  ///
+  /// i.e. \code __attribute__((deprecated)) \endcode
+  bool isUnconditionallyDeprecated() const { return UnconditionallyDeprecated; 
}
+
+  /// Check if the symbol is unconditionally unavailable.
+  ///
+  /// i.e. \code __attribute__((unavailable)) \endcode
+  bool isUnconditionallyUnavailable() const {
+return UnconditionallyUnavailable;
+  }
+
+  AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
+   VersionTuple O, bool UD, bool UU)
+  : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O),
+UnconditionallyDeprecated(UD), UnconditionallyUnavailable(UU) {}
+
+  friend bool operator==(const AvailabilityInfo &Lhs,
+ const AvailabilityInfo &Rhs);
+
+public:
+  static AvailabilityInfo createFromDecl(const Decl *Decl);
+};
+
+inline bool operator==(const AvailabilityInfo &Lhs,
+   const AvailabilityInfo &Rhs) {
+  return std::tie(Lhs.Introduced, Lhs.Deprecated, Lhs.Obsoleted,
+  Lhs.UnconditionallyDeprecated,
+  Lhs.UnconditionallyUnavailable) ==
+ std::tie(Rhs.Introduced, Rhs.Deprecated, Rhs.Obsoleted,
+  Rhs.UnconditionallyDeprecated,
+  Rhs.UnconditionallyUnavailable);
+}
+
 } // end namespace clang
 
 #endif
diff --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index 0a0f1bd1e95f7f..b220db294101d8 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -18,12 +18,12 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_API_H
 #define LLVM_CLANG_EXTRACTAPI_API_H
 
+#include "clang/AST/Availability.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
-#include "clang/ExtractAPI/AvailabilityInfo.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
diff --git a/clang/include/clang/ExtractAPI/AvailabilityInfo.h 
b/clang/include/clang/ExtractAPI/AvailabilityInfo.h
deleted file mode 100644
index 3b8d6f46ed56d2..00
--- a/clang/include/clang/ExtractAPI/AvailabilityInfo.h
+++ /dev/null
@@ -1,76 +0,0 @@
-//===- ExtractAPI/AvailabilityInfo.h - Availability Info *- 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
-//
-//===--===//
-///
-

[clang] [C++] Fix parsing of _Alignas in local declarations (PR #81915)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify=expected,cpp
+// RUN: %clang_cc1 -x c %s -fsyntax-only -verify=expected,c
+
+// Ensure that we correctly parse _Alignas as an extension in C++.
+_Alignas(64) int i1;
+_Alignas(long long) int i2;
+int volatile _Alignas(64) i3; // Test strange ordering
+
+void foo(void) {
+  // We previously rejected these valid declarations.
+  _Alignas(8) char i4;
+  _Alignas(char) char i5;
+
+  (void)(int _Alignas(64))0; // expected-warning {{'_Alignas' attribute 
ignored when parsing type}}
+  // FIXME: C and C++ should both diagnose the same way, as being ignored.

AaronBallman wrote:

Note: I plan to fix this in a follow-up

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


[clang] [C++] Fix parsing of _Alignas in local declarations (PR #81915)

2024-02-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Aaron Ballman (AaronBallman)


Changes

We support '_Alignas' from C11 as an extension in C++. However, we were not 
correctly parsing its use in local variable declarations. This patch addresses 
that issue.

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/lib/Parse/ParseTentative.cpp (+3) 
- (added) clang/test/SemaCXX/_Alignas.cpp (+25) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 608d855abf5d06..16f79a349c20c8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -259,6 +259,9 @@ Bug Fixes to C++ Support
   some of (`#80510 `).
 - Clang now ignores top-level cv-qualifiers on function parameters in template 
partial orderings.
   (`#75404 `_)
+- No longer reject valid use of the ``_Alignas`` specifier when declaring a
+  local variable, which is supported as a C11 extension in C++. Previously, it
+  was only accepted at namespace scope but not at local function scope.
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Parse/ParseTentative.cpp 
b/clang/lib/Parse/ParseTentative.cpp
index 299e46f4be9a2c..ea17c3e3252ec2 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1842,6 +1842,9 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext 
AllowImplicitTypename,
 #include "clang/Basic/TransformTypeTraits.def"
 return TPResult::True;
 
+  // C11 _Alignas
+  case tok::kw__Alignas:
+return TPResult::True;
   // C11 _Atomic
   case tok::kw__Atomic:
 return TPResult::True;
diff --git a/clang/test/SemaCXX/_Alignas.cpp b/clang/test/SemaCXX/_Alignas.cpp
new file mode 100644
index 00..4e892745580ed6
--- /dev/null
+++ b/clang/test/SemaCXX/_Alignas.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify=expected,cpp
+// RUN: %clang_cc1 -x c %s -fsyntax-only -verify=expected,c
+
+// Ensure that we correctly parse _Alignas as an extension in C++.
+_Alignas(64) int i1;
+_Alignas(long long) int i2;
+int volatile _Alignas(64) i3; // Test strange ordering
+
+void foo(void) {
+  // We previously rejected these valid declarations.
+  _Alignas(8) char i4;
+  _Alignas(char) char i5;
+
+  (void)(int _Alignas(64))0; // expected-warning {{'_Alignas' attribute 
ignored when parsing type}}
+  // FIXME: C and C++ should both diagnose the same way, as being ignored.
+  (void)(_Alignas(64) int)0; // c-error {{expected expression}} \
+cpp-warning {{'_Alignas' attribute ignored 
when parsing type}}
+}
+
+struct S {
+  _Alignas(int) int i;
+  _Alignas(64) int j;
+};
+
+void bar(_Alignas(8) char c1, char _Alignas(char) c2); // expected-error 2 
{{'_Alignas' attribute cannot be applied to a function parameter}}

``




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


[clang] [HLSL] add BuiltinsHLSL and set it up as target builtins. (PR #81902)

2024-02-15 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl updated 
https://github.com/llvm/llvm-project/pull/81902

>From 97022e196fdad0f4aff9e628607e3c24bef863df Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Thu, 15 Feb 2024 13:46:55 -0500
Subject: [PATCH] [HLSL] add BuiltinsHLSL and set it up as target builtins.

1. This change moves hlsl specific builtins from Builtins.td
to BuiltinsHLSL.td.
2. Adds changes to the build system to build BuiltinsHLSL.td.
3. Setups HLSL builtins as TargetBuiltins.
---
 clang/include/clang/Basic/Builtins.td  |  6 --
 clang/include/clang/Basic/BuiltinsHLSL.td  | 15 +++
 clang/include/clang/Basic/CMakeLists.txt   |  6 +-
 clang/include/clang/Basic/TargetBuiltins.h | 10 ++
 clang/lib/Basic/Targets/DirectX.cpp| 13 +
 clang/lib/Basic/Targets/DirectX.h  |  4 +---
 6 files changed, 44 insertions(+), 10 deletions(-)
 create mode 100644 clang/include/clang/Basic/BuiltinsHLSL.td

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index df74026c5d2d50..1936c38f64cfff 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4512,12 +4512,6 @@ def GetDeviceSideMangledName : LangBuiltin<"CUDA_LANG"> {
 }
 
 // HLSL
-def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> {
-  let Spellings = ["__builtin_hlsl_wave_active_count_bits"];
-  let Attributes = [NoThrow, Const];
-  let Prototype = "unsigned int(bool)";
-}
-
 def HLSLCreateHandle : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_create_handle"];
   let Attributes = [NoThrow, Const];
diff --git a/clang/include/clang/Basic/BuiltinsHLSL.td 
b/clang/include/clang/Basic/BuiltinsHLSL.td
new file mode 100644
index 00..738cabf5ffb85d
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsHLSL.td
@@ -0,0 +1,15 @@
+//===--- BuiltinsHLSL.td - HLSL 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_wave_active_count_bits"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "unsigned int(bool)";
+}
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 7785fb430c069b..01233eb44feffc 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -65,7 +65,11 @@ clang_tablegen(BuiltinsBPF.inc -gen-clang-builtins
   SOURCE BuiltinsBPF.td
   TARGET ClangBuiltinsBPF)
 
-clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins
+clang_tablegen(BuiltinsHLSL.inc -gen-clang-builtins
+  SOURCE BuiltinsHLSL.td
+  TARGET ClangBuiltinsHLSL)
+
+  clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins
   SOURCE BuiltinsRISCV.td
   TARGET ClangBuiltinsRISCV)
 
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index 4333830bf34f24..15cf111ae5e9e5 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -89,6 +89,16 @@ namespace clang {
   };
   }
 
+  /// HLSL builtins
+  namespace hlsl {
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsHLSL.inc"
+LastTSBuiltin
+  };
+  } // namespace hlsl
+
   /// PPC builtins
   namespace PPC {
 enum {
diff --git a/clang/lib/Basic/Targets/DirectX.cpp 
b/clang/lib/Basic/Targets/DirectX.cpp
index 0dd27e6e93b33b..83cc049e5963aa 100644
--- a/clang/lib/Basic/Targets/DirectX.cpp
+++ b/clang/lib/Basic/Targets/DirectX.cpp
@@ -12,11 +12,24 @@
 
 #include "DirectX.h"
 #include "Targets.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetBuiltins.h"
 
 using namespace clang;
 using namespace clang::targets;
 
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+  {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#include "clang/Basic/BuiltinsHLSL.inc"
+};
+
 void DirectXTargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   DefineStd(Builder, "DIRECTX", Opts);
 }
+
+ArrayRef DirectXTargetInfo::getTargetBuiltins() const {
+  return llvm::ArrayRef(BuiltinInfo,
+clang::hlsl::LastTSBuiltin - Builtin::FirstTSBuiltin);
+}
diff --git a/clang/lib/Basic/Targets/DirectX.h 
b/clang/lib/Basic/Targets/DirectX.h
index acfcc8c47ba950..99c9522b0dd542 100644
--- a/clang/lib/Basic/Targets/DirectX.h
+++ b/clang/lib/Basic/Targets/DirectX.h
@@ -73,9 +73,7 @@ class LLVM_LIBRARY_VISIBILITY Dir

[clang] [compiler-rt] [llvm] [InstrProf] Single byte counters in coverage (PR #75425)

2024-02-15 Thread via cfe-commits


@@ -1519,38 +1543,53 @@ struct CounterCoverageMappingBuilder
 }
 
 // Create Branch Region around condition.
-createBranchRegion(S->getCond(), BodyCount,
-   subtractCounters(CondCount, BodyCount));
+if (!llvm::EnableSingleByteCoverage)
+  createBranchRegion(S->getCond(), BodyCount,
+ subtractCounters(CondCount, BodyCount));

gulfemsavrun wrote:

We are currently interested in enabling single byte counters mode for line 
coverage. But, if there is any interest, we might consider supporting branch 
coverage in single byte counters mode as well. Branch coverage is more tricky, 
though. Because it already inserts additional counters and in order to support 
single byte counters mode, we need to insert more counters. We need to think 
about associating counters with the relevant AST nodes for branch coverage.

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


[clang] [HLSL] add BuiltinsHLSL and set it up as target builtins. (PR #81902)

2024-02-15 Thread Justin Bogner via cfe-commits

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

Hm, on further thought tying the "HLSL" intrinsics to the DirectX backend as 
target intrinsics like this is probably going to shoot us in the foot with 
respect to SPIR-V. I think we need to rethink this, and if we are going with 
target intrinsics they should probably be DirectX branded rather than HLSL...

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


[clang] [clang-format] Support of TableGen basic format restrictions. (PR #81611)

2024-02-15 Thread Björn Schäpers via cfe-commits

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


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


[clang] [llvm] [AMDGPU] Emit a waitcnt instruction after each memory instruction (PR #79236)

2024-02-15 Thread Jun Wang via cfe-commits


@@ -603,14 +626,69 @@ class SIGfx12CacheControl : public SIGfx11CacheControl {
   SIAtomicAddrSpace AddrSpace, SIMemOp Op,
   bool IsVolatile,
   bool IsNonTemporal) const override;
+
+  bool
+  handleNonAtomicForPreciseMemory(MachineBasicBlock::iterator &MI) override;
+  bool handleAtomicForPreciseMemory(MachineBasicBlock::iterator &MI,
+bool ret) override;
+};
+
+#if 0
+class SIPreciseMemorySupport {
+protected:
+  const GCNSubtarget &ST;
+  const SIInstrInfo *TII = nullptr;
+
+  IsaVersion IV;
+
+  SIPreciseMemorySupport(const GCNSubtarget &ST) : ST(ST) {
+TII = ST.getInstrInfo();
+IV = getIsaVersion(ST.getCPU());
+  }
+
+public:
+  static std::unique_ptr create(const GCNSubtarget 
&ST);
+
+  virtual bool handleNonAtomic(MachineBasicBlock::iterator &MI) = 0;
+  /// Handles atomic instruction \p MI with \p ret indicating whether \p MI
+  /// returns a result.
+  virtual bool handleAtomic(MachineBasicBlock::iterator &MI, bool ret) = 0;
+};
+
+class SIGfx9PreciseMemorySupport : public SIPreciseMemorySupport {
+public:
+  SIGfx9PreciseMemorySupport(const GCNSubtarget &ST)
+  : SIPreciseMemorySupport(ST) {}
+  bool handleNonAtomic(MachineBasicBlock::iterator &MI) override;
+  bool handleAtomic(MachineBasicBlock::iterator &MI, bool ret) override;
 };
 
+class SIGfx10And11PreciseMemorySupport : public SIPreciseMemorySupport {
+public:
+  SIGfx10And11PreciseMemorySupport(const GCNSubtarget &ST)
+  : SIPreciseMemorySupport(ST) {}
+  bool handleNonAtomic(MachineBasicBlock::iterator &MI) override;
+  bool handleAtomic(MachineBasicBlock::iterator &MI, bool ret) override;
+};
+
+std::unique_ptr
+SIPreciseMemorySupport::create(const GCNSubtarget &ST) {
+  GCNSubtarget::Generation Generation = ST.getGeneration();
+  if (Generation < AMDGPUSubtarget::GFX10)
+return std::make_unique(ST);
+  return std::make_unique(ST);
+}
+#endif
+
 class SIMemoryLegalizer final : public MachineFunctionPass {
 private:
 
   /// Cache Control.
   std::unique_ptr CC = nullptr;
 
+  /// Precise Memory support.
+  bool PM = false;

jwanggit86 wrote:

Changed "PM" to "PrecMem".

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


[clang] [llvm] [AMDGPU] Emit a waitcnt instruction after each memory instruction (PR #79236)

2024-02-15 Thread Jun Wang via cfe-commits


@@ -603,14 +626,69 @@ class SIGfx12CacheControl : public SIGfx11CacheControl {
   SIAtomicAddrSpace AddrSpace, SIMemOp Op,
   bool IsVolatile,
   bool IsNonTemporal) const override;
+
+  bool
+  handleNonAtomicForPreciseMemory(MachineBasicBlock::iterator &MI) override;
+  bool handleAtomicForPreciseMemory(MachineBasicBlock::iterator &MI,
+bool ret) override;
+};
+
+#if 0

jwanggit86 wrote:

Done.

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


[clang] [llvm] [AMDGPU] Emit a waitcnt instruction after each memory instruction (PR #79236)

2024-02-15 Thread Jun Wang via cfe-commits


@@ -603,14 +626,69 @@ class SIGfx12CacheControl : public SIGfx11CacheControl {
   SIAtomicAddrSpace AddrSpace, SIMemOp Op,
   bool IsVolatile,
   bool IsNonTemporal) const override;
+
+  bool
+  handleNonAtomicForPreciseMemory(MachineBasicBlock::iterator &MI) override;
+  bool handleAtomicForPreciseMemory(MachineBasicBlock::iterator &MI,
+bool ret) override;

jwanggit86 wrote:

Changed "ret" to "IsAtomicWithRet".

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


[clang] [clang] Do less advertising for unresolved issues in `cxx_dr_status.html` (PR #78836)

2024-02-15 Thread Vlad Serebrennikov via cfe-commits

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


[clang] df81055 - [clang] Do less advertising for unresolved issues in `cxx_dr_status.html` (#78836)

2024-02-15 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-02-15T23:45:56+04:00
New Revision: df81055955d564dccfd43a9faeb2f54c8c998f68

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

LOG: [clang] Do less advertising for unresolved issues in `cxx_dr_status.html` 
(#78836)

This patch places additional requirement on tests for open issues to
specify what do they test, and reduce their advertising on
`cxx_dr_status.html`.

Tests for open issues have to either provide date of the proposed
resolution they test, or a paper number that attempts to resolve the
issue. Examples from this patch: `// dr1223: 17 drafting 2023-05-12`,
`// dr2049: 18 drafting P2308R1`, `// dr2335: no drafting 2018-06`.

Tests for open issues are no longer advertised in `cxx_dr_status.html`
as tests for resolved issues. Instead, they are specified as `Not
Resolved*` (note the asterisk). Such statuses have a tooltip with the
following kind of text:
`Clang 17 implements 2023-05-12 resolution`
`Clang does not implement 2018-06-04 resolution` 
`Clang 18 implements P2308R1 resolution`
I admit that the wording is a bit crude, but I tried to minimize amount
of boilerplate in the `make_cxx_dr_status`. Hopefully, this whole setup
matches [C++ compiler
support](https://en.cppreference.com/w/cpp/compiler_support) page on
cppreference enough for people to catch up.

This patch also implement a quality-of-life feature for users of
`make_cxx_dr_status`: now script is able to report multiple bad `// dr`
comments in a single run.

This has also been discussed in a PR for CWG472 test:
https://github.com/llvm/llvm-project/pull/67948

Added: 


Modified: 
clang/test/CXX/drs/dr12xx.cpp
clang/test/CXX/drs/dr18xx.cpp
clang/test/CXX/drs/dr20xx.cpp
clang/test/CXX/drs/dr2335.cpp
clang/test/CXX/drs/dr24xx.cpp
clang/test/CXX/drs/dr25xx.cpp
clang/test/CXX/drs/dr4xx.cpp
clang/www/cxx_dr_status.html
clang/www/make_cxx_dr_status

Removed: 




diff  --git a/clang/test/CXX/drs/dr12xx.cpp b/clang/test/CXX/drs/dr12xx.cpp
index cb4cc5aef17371..da5dd02a00677c 100644
--- a/clang/test/CXX/drs/dr12xx.cpp
+++ b/clang/test/CXX/drs/dr12xx.cpp
@@ -32,7 +32,7 @@ namespace dr1213 { // dr1213: 7
 }
 
 #if __cplusplus >= 201103L
-namespace dr1223 { // dr1223: 17 drafting
+namespace dr1223 { // dr1223: 17 drafting 2023-05-12
 struct M;
 template 
 struct V;

diff  --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index 37ea450137ac5e..a7cee4ef8902f9 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -366,7 +366,7 @@ namespace dr1881 { // dr1881: 7
   static_assert(!__is_standard_layout(D), "");
 }
 
-namespace dr1890 { // dr1890: no drafting
+namespace dr1890 { // dr1890: no drafting 2018-06-04
 // FIXME: current consensus for CWG2335 is that the examples are well-formed.
 namespace ex1 {
 #if __cplusplus >= 201402L

diff  --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index f7f37379e61ad1..96f2572cfb524d 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -90,7 +90,7 @@ namespace dr2026 { // dr2026: 11
   }
 }
 
-namespace dr2049 { // dr2049: 18 drafting
+namespace dr2049 { // dr2049: 18 drafting P2308R1
 #if __cplusplus >= 202302L
 template  struct X {};
 X<> a;

diff  --git a/clang/test/CXX/drs/dr2335.cpp b/clang/test/CXX/drs/dr2335.cpp
index d143aaf7cb0ac0..33eebb2c4a5c57 100644
--- a/clang/test/CXX/drs/dr2335.cpp
+++ b/clang/test/CXX/drs/dr2335.cpp
@@ -10,7 +10,7 @@
 // expected-no-diagnostics
 #endif
 
-namespace dr2335 { // dr2335: no drafting
+namespace dr2335 { // dr2335: no drafting 2018-06
 // FIXME: current consensus is that the examples are well-formed.
 #if __cplusplus >= 201402L
 namespace ex1 {

diff  --git a/clang/test/CXX/drs/dr24xx.cpp b/clang/test/CXX/drs/dr24xx.cpp
index 66e9cf5a677f80..ae8dda3351f48e 100644
--- a/clang/test/CXX/drs/dr24xx.cpp
+++ b/clang/test/CXX/drs/dr24xx.cpp
@@ -45,7 +45,7 @@ void fallthrough(int n) {
 #endif
 }
 
-namespace dr2450 { // dr2450: 18 review
+namespace dr2450 { // dr2450: 18 review P2308R1
 #if __cplusplus >= 202302L
 struct S {int a;};
 template 
@@ -59,7 +59,7 @@ f<{.a= 0}>();
 #endif
 }
 
-namespace dr2459 { // dr2459: 18 drafting
+namespace dr2459 { // dr2459: 18 drafting P2308R1
 #if __cplusplus >= 202302L
 struct A {
   constexpr A(float) {}

diff  --git a/clang/test/CXX/drs/dr25xx.cpp b/clang/test/CXX/drs/dr25xx.cpp
index b1e54804fc895c..9fc7cf59485caa 100644
--- a/clang/test/CXX/drs/dr25xx.cpp
+++ b/clang/test/CXX/drs/dr25xx.cpp
@@ -85,7 +85,7 @@ using ::dr2521::operator""_div;
 
 
 #if __cplusplus >= 202302L
-namespace dr2553 { // dr2553: 18 review
+namespace dr2553 { // dr2553: 18 review 2023-07-14
 struct B {
   virtual void f(this B&); 
   // since-cxx23-error@-1 {{an explicit

[clang] [clang] Do less advertising for unresolved issues in `cxx_dr_status.html` (PR #78836)

2024-02-15 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Windows CI didn't pass due to unrelated test failure. Landing.

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


[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-02-15 Thread John McCall via cfe-commits

rjmccall wrote:

> @rjmccall fixed feedback
> 
> > You should handle compound assignments.
> 
> I believe I already support compound assignments (and PrePostIncDec), if I am 
> not missing something? 😃

Ah, maybe you are, sorry.  I was expecting it in `CGExpr.cpp` and forgot that 
that code was actually in `CGExprScalar.cpp`.

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


[clang] [compiler-rt] [asan][windows] Eliminate the static asan runtime on windows (PR #81677)

2024-02-15 Thread via cfe-commits

zmodem wrote:

I think @rnk has the deepest knowledge here.

Just to double check, when you say "Eliminate the static asan runtime", you 
mean the use case it was supporting will still keep working, but in a different 
way right?

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


[clang] 6a8ab12 - [clang][Interp] Properly emit call ops to invalid functions

2024-02-15 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-02-15T20:17:51+01:00
New Revision: 6a8ab129300bfdf7cc58e023b06e0aada4458205

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

LOG: [clang][Interp] Properly emit call ops to invalid functions

Just like everywhere else, we can't just abort compilation because
a function is invalid. We need to emit the Call op and let later
interpretation handle the failure.

This fixes a long standing FIXME comment.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/Interp.cpp
clang/test/AST/Interp/cxx20.cpp
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index db6d818eef334b..e4b48c4e946f13 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2835,14 +2835,6 @@ bool ByteCodeExprGen::VisitCallExpr(const 
CallExpr *E) {
 const Function *Func = getFunction(FuncDecl);
 if (!Func)
   return false;
-// If the function is being compiled right now, this is a recursive call.
-// In that case, the function can't be valid yet, even though it will be
-// later.
-// If the function is already fully compiled but not constexpr, it was
-// found to be faulty earlier on, so bail out.
-if (Func->isFullyCompiled() && !Func->isConstexpr())
-  return false;
-
 assert(HasRVO == Func->hasRVO());
 
 bool HasQualifier = false;

diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index 2338f88569db8b..2a51f18adf02c5 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -477,6 +477,11 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const 
Function *F) {
 if (!DiagDecl->isDefined() && S.checkingPotentialConstantExpression())
   return false;
 
+// If the declaration is defined _and_ declared 'constexpr', the below
+// diagnostic doesn't add anything useful.
+if (DiagDecl->isDefined() && DiagDecl->isConstexpr())
+  return false;
+
 S.FFDiag(Loc, diag::note_constexpr_invalid_function, 1)
   << DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
 S.Note(DiagDecl->getLocation(), diag::note_declared_at);

diff  --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp
index 0af553a77892e6..0fc5d977b59f4c 100644
--- a/clang/test/AST/Interp/cxx20.cpp
+++ b/clang/test/AST/Interp/cxx20.cpp
@@ -230,15 +230,13 @@ namespace ConstThis {
   // ref-note {{declared const here}}
 int a;
   public:
-constexpr Foo() { // expected-note {{declared here}}
+constexpr Foo() {
   this->a = 10;
   T = 13; // expected-error {{cannot assign to non-static data member 'T' 
with const-qualified type}} \
   // ref-error {{cannot assign to non-static data member 'T' with 
const-qualified type}}
 }
   };
   constexpr Foo F; // expected-error {{must be initialized by a constant 
expression}} \
-   // FIXME: The following note is wrong. \
-   // expected-note {{undefined constructor 'Foo' cannot be 
used in a constant expression}} \
// ref-error {{must be initialized by a constant 
expression}}
 
 

diff  --git a/clang/test/AST/Interp/records.cpp 
b/clang/test/AST/Interp/records.cpp
index 93da831f3bda0a..62f1f1d6e426c3 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -1232,10 +1232,9 @@ namespace InheritedConstructor {
 namespace InvalidCtorInitializer {
   struct X {
 int Y;
-constexpr X() // expected-note {{declared here}}
+constexpr X()
 : Y(fo_o_()) {} // both-error {{use of undeclared identifier 'fo_o_'}}
   };
   // no crash on evaluating the constexpr ctor.
-  constexpr int Z = X().Y; // both-error {{constexpr variable 'Z' must be 
initialized by a constant expression}} \
-   // expected-note {{undefined constructor 'X'}}
+  constexpr int Z = X().Y; // both-error {{constexpr variable 'Z' must be 
initialized by a constant expression}}
 }



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


[clang] a1155f6 - [NFC] Clang-format const array declarations

2024-02-15 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2024-02-15T13:16:21-06:00
New Revision: a1155f68f5d5c7013ca1deb312a2e1e4f71ef544

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

LOG: [NFC] Clang-format const array declarations

This just updates indentation of constant array declarations to be
style conformant.

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 9381b8c6626b64..5c6d463bb895df 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -123,43 +123,42 @@ CompareDerivedToBaseConversions(Sema &S, SourceLocation 
Loc,
 /// GetConversionRank - Retrieve the implicit conversion rank
 /// corresponding to the given implicit conversion kind.
 ImplicitConversionRank clang::GetConversionRank(ImplicitConversionKind Kind) {
-  static const ImplicitConversionRank
-Rank[] = {
-ICR_Exact_Match,
-ICR_Exact_Match,
-ICR_Exact_Match,
-ICR_Exact_Match,
-ICR_Exact_Match,
-ICR_Exact_Match,
-ICR_Promotion,
-ICR_Promotion,
-ICR_Promotion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_OCL_Scalar_Widening,
-ICR_Complex_Real_Conversion,
-ICR_Conversion,
-ICR_Conversion,
-ICR_Writeback_Conversion,
-ICR_Exact_Match, // NOTE(gbiv): This may not be completely right --
- // it was omitted by the patch that added
- // ICK_Zero_Event_Conversion
-ICR_Exact_Match, // NOTE(ctopper): This may not be completely right --
- // it was omitted by the patch that added
- // ICK_Zero_Queue_Conversion
-ICR_C_Conversion,
-ICR_C_Conversion_Extension,
-ICR_Conversion,
+  static const ImplicitConversionRank Rank[] = {
+  ICR_Exact_Match,
+  ICR_Exact_Match,
+  ICR_Exact_Match,
+  ICR_Exact_Match,
+  ICR_Exact_Match,
+  ICR_Exact_Match,
+  ICR_Promotion,
+  ICR_Promotion,
+  ICR_Promotion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_OCL_Scalar_Widening,
+  ICR_Complex_Real_Conversion,
+  ICR_Conversion,
+  ICR_Conversion,
+  ICR_Writeback_Conversion,
+  ICR_Exact_Match, // NOTE(gbiv): This may not be completely right --
+   // it was omitted by the patch that added
+   // ICK_Zero_Event_Conversion
+  ICR_Exact_Match, // NOTE(ctopper): This may not be completely right --
+   // it was omitted by the patch that added
+   // ICK_Zero_Queue_Conversion
+  ICR_C_Conversion,
+  ICR_C_Conversion_Extension,
+  ICR_Conversion,
   };
   static_assert(std::size(Rank) == (int)ICK_Num_Conversion_Kinds);
   return Rank[(int)Kind];
@@ -167,39 +166,39 @@ ImplicitConversionRank 
clang::GetConversionRank(ImplicitConversionKind Kind) {
 
 /// GetImplicitConversionName - Return the name of this kind of
 /// implicit conversion.
-static const char* GetImplicitConversionName(ImplicitConversionKind Kind) {
-  static const char* const Name[] = {
-"No conversion",
-"Lvalue-to-rvalue",
-"Array-to-pointer",
-"Function-to-pointer",
-"Function pointer conversion",
-"Qualification",
-"Integral promotion",
-"Floating point promotion",
-"Complex promotion",
-"Integral conversion",
-"Floating conversion",
-"Complex conversion",
-"Floating-integral conversion",
-"Pointer conversion",
-"Pointer-to-member conversion",
-"Boolean conversion",
-"Compatible-types conversion",
-"Derived-to-base conversion",
-"Vector conversion",
-"SVE Vector conversion",
-"RVV Vector conversion",
-"Vector splat",
-"Complex-real conversion",
-"Block Pointer conversion",
-"Transparent Union Conversion",
-"Writeback conversion",
-"OpenCL Zero Event Conversion",
-"OpenCL Zero Queue Conversion",
-"C specific type conversion",
-"Incompatible pointer conversion",
-"Fixed point conversion",
+static const char *GetImplicitConversionName(ImplicitConversionKind Kind) {
+  static const char *const Name[] = {
+  "No conversion",
+  "Lvalue-to-rvalue",
+  "Array-to-pointer",
+  "Function-to-pointer",
+  "Function pointer conversion",
+  "Qualification",
+  "Integral promotion

[clang] Revert "[X86][clang] Lift _BitInt() supported max width." (PR #81175)

2024-02-15 Thread John McCall via cfe-commits

rjmccall wrote:

There's no such thing as "this is impossible to do".  Clang, as the frontend, 
is responsible for emitting IR that has gets the effect we want.  If that means 
contorting the IR we generate to do ugly things like memcpying into a 
temporary, that's our life.

I am not surprised that we do not get any sort of reliable behavior from 
backends for `iNNN` when that's not architectural-legal.  I'm pretty sure I 
raised that concern during the review.

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


[clang] [alpha.webkit.UncountedCallArgsChecker] Detect & ignore trivial function calls. (PR #81808)

2024-02-15 Thread Artem Dergachev via cfe-commits

haoNoQ wrote:

Fix merged, thanks!

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


[clang] Fix uncounted-obj-arg.cpp for Windows. (PR #81903)

2024-02-15 Thread Artem Dergachev via cfe-commits

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


[clang] efad188 - Fix uncounted-obj-arg.cpp for Windows. (#81903)

2024-02-15 Thread via cfe-commits

Author: Ryosuke Niwa
Date: 2024-02-15T11:12:17-08:00
New Revision: efad1885bfbda7f456e0e6e1db660fe55515a4b9

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

LOG: Fix uncounted-obj-arg.cpp for Windows. (#81903)

Added: 


Modified: 
clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp

Removed: 




diff  --git a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp 
b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
index 156a2480901bf0..338e1b685122bc 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
@@ -107,7 +107,7 @@ class RefCounted {
 return 0;
   }
   void *trivial15() { return static_cast(this); }
-  unsigned long trivial16() { return reinterpret_cast(this); }
+  unsigned long trivial16() { return *reinterpret_cast(this); }
   RefCounted& trivial17() const { return const_cast(*this); }
   RefCounted& trivial18() const { RELEASE_ASSERT(this, "this must be not 
null"); return const_cast(*this); }
   void trivial19() const { return; }



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


[clang] [compiler-rt] [asan][windows] Eliminate the static asan runtime on windows (PR #81677)

2024-02-15 Thread Charlie Barto via cfe-commits

barcharcraz wrote:

> This is long description, but it does not explain WHY. Could you please add 
> some explanation there?

Sure, the reason is to greatly simplify how asan works on windows, and to fix a 
bunch of bugs with asan+static CRT. Before this change there was a bunch of 
code that would redirect calls from various dlls into the executable if the 
asan runtime was statically linked, this code has never worked all that well, 
and it was a nightmare to fix. Additionally, statically linked DLLs didn't work 
with the previous scheme and weak symbols didn't work with /MD.

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


[clang] Fix uncounted-obj-arg.cpp for Windows. (PR #81903)

2024-02-15 Thread Artem Dergachev via cfe-commits

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

This probably works thanks!

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


[clang] [alpha.webkit.UncountedCallArgsChecker] Detect & ignore trivial function calls. (PR #81808)

2024-02-15 Thread Ryosuke Niwa via cfe-commits

rniwa wrote:

Fixing the test in https://github.com/llvm/llvm-project/pull/81903

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


[clang] Fix uncounted-obj-arg.cpp for Windows. (PR #81903)

2024-02-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ryosuke Niwa (rniwa)


Changes



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


1 Files Affected:

- (modified) clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp (+1-1) 


``diff
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp 
b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
index 156a2480901bf0..338e1b685122bc 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
@@ -107,7 +107,7 @@ class RefCounted {
 return 0;
   }
   void *trivial15() { return static_cast(this); }
-  unsigned long trivial16() { return reinterpret_cast(this); }
+  unsigned long trivial16() { return *reinterpret_cast(this); }
   RefCounted& trivial17() const { return const_cast(*this); }
   RefCounted& trivial18() const { RELEASE_ASSERT(this, "this must be not 
null"); return const_cast(*this); }
   void trivial19() const { return; }

``




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


[clang] [HLSL] add BuiltinsHLSL and set it up as target builtins. (PR #81902)

2024-02-15 Thread Justin Bogner via cfe-commits

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


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


[clang] [COFF][Aarch64] Add _InterlockedAdd64 intrinsic (PR #81849)

2024-02-15 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

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


[clang] Fix uncounted-obj-arg.cpp for Windows. (PR #81903)

2024-02-15 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa created https://github.com/llvm/llvm-project/pull/81903

None

>From e3a45512e1a10c341b7172ddd3c2c8d42368110b Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Thu, 15 Feb 2024 10:58:13 -0800
Subject: [PATCH] Fix uncounted-obj-arg.cpp for Windows.

---
 clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp 
b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
index 156a2480901bf0..338e1b685122bc 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
@@ -107,7 +107,7 @@ class RefCounted {
 return 0;
   }
   void *trivial15() { return static_cast(this); }
-  unsigned long trivial16() { return reinterpret_cast(this); }
+  unsigned long trivial16() { return *reinterpret_cast(this); }
   RefCounted& trivial17() const { return const_cast(*this); }
   RefCounted& trivial18() const { RELEASE_ASSERT(this, "this must be not 
null"); return const_cast(*this); }
   void trivial19() const { return; }

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


[clang] [HLSL] add BuiltinsHLSL and set it up as target builtins. (PR #81902)

2024-02-15 Thread Farzon Lotfi via cfe-commits

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


[clang] [llvm] [AMDGPU] Emit a waitcnt instruction after each memory instruction (PR #79236)

2024-02-15 Thread Jun Wang via cfe-commits


@@ -167,6 +167,10 @@ def FeatureCuMode : SubtargetFeature<"cumode",
   "Enable CU wavefront execution mode"
 >;
 
+def FeaturePreciseMemory

jwanggit86 wrote:

Thanks for the suggestion. It looks it would work. However, I'm not sure the 
extra overhead is worth it just for having a shorter name in the backend. After 
all this is not going to be a commonly used option, and the name in the backend 
is not exposed to end user.


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


[clang] [HLSL] add BuiltinsHLSL and set it up as target builtins. (PR #81902)

2024-02-15 Thread Farzon Lotfi via cfe-commits

farzonl wrote:

create handle test:
```
D:\projects\llvm-project>python ..\directx-llvm-build\bin\llvm-lit.py -sv 
clang\test\CodeGenHLSL\builtins\create_handle.hlsl
llvm-lit.py: D:\projects\llvm-project\llvm\utils\lit\lit\llvm\config.py:57: 
note: using lit tools: C:\Program Files\Git\usr\bin
llvm-lit.py: D:\projects\llvm-project\llvm\utils\lit\lit\llvm\config.py:502: 
note: using clang: d:\projects\directx-llvm-build\bin\clang.exe
-- Testing: 1 tests, 1 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..

Testing Time: 6.71s

Total Discovered Tests: 1
  Passed: 1 (100.00%)
```
WaveActiveCountBits Sema Tests:
```
D:\projects\llvm-project>python ..\directx-llvm-build\bin\llvm-lit.py -sv 
clang\test\SemaHLSL\WaveBuiltinAvailability.hlsl
llvm-lit.py: D:\projects\llvm-project\llvm\utils\lit\lit\llvm\config.py:57: 
note: using lit tools: C:\Program Files\Git\usr\bin
llvm-lit.py: D:\projects\llvm-project\llvm\utils\lit\lit\llvm\config.py:502: 
note: using clang: d:\projects\directx-llvm-build\bin\clang.exe
-- Testing: 1 tests, 1 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..

Testing Time: 0.37s

Total Discovered Tests: 1
  Passed: 1 (100.00%)

D:\projects\llvm-project>python ..\directx-llvm-build\bin\llvm-lit.py -sv 
clang\test\SemaHLSL\Wave.hlsl
llvm-lit.py: D:\projects\llvm-project\llvm\utils\lit\lit\llvm\config.py:57: 
note: using lit tools: C:\Program Files\Git\usr\bin
llvm-lit.py: D:\projects\llvm-project\llvm\utils\lit\lit\llvm\config.py:502: 
note: using clang: d:\projects\directx-llvm-build\bin\clang.exe
-- Testing: 1 tests, 1 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..

Testing Time: 0.28s

Total Discovered Tests: 1
  Passed: 1 (100.00%)
```

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


[clang] [HLSL] add BuiltinsHLSL and set it up as target builtins. (PR #81902)

2024-02-15 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-directx

@llvm/pr-subscribers-hlsl

Author: Farzon Lotfi (farzonl)


Changes

1. This change moves hlsl specific builtins from Builtins.td to BuiltinsHLSL.td.
2. Adds changes to the build system to build BuiltinsHLSL.td.
3. Setups HLSL builtins as TargetBuiltins.

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


6 Files Affected:

- (modified) clang/include/clang/Basic/Builtins.td (-13) 
- (added) clang/include/clang/Basic/BuiltinsHLSL.td (+21) 
- (modified) clang/include/clang/Basic/CMakeLists.txt (+5-1) 
- (modified) clang/include/clang/Basic/TargetBuiltins.h (+10) 
- (modified) clang/lib/Basic/Targets/DirectX.cpp (+13) 
- (modified) clang/lib/Basic/Targets/DirectX.h (+1-3) 


``diff
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index df74026c5d2d50..2943911b662191 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4511,19 +4511,6 @@ def GetDeviceSideMangledName : LangBuiltin<"CUDA_LANG"> {
   let Prototype = "char const*(...)";
 }
 
-// HLSL
-def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> {
-  let Spellings = ["__builtin_hlsl_wave_active_count_bits"];
-  let Attributes = [NoThrow, Const];
-  let Prototype = "unsigned int(bool)";
-}
-
-def HLSLCreateHandle : LangBuiltin<"HLSL_LANG"> {
-  let Spellings = ["__builtin_hlsl_create_handle"];
-  let Attributes = [NoThrow, Const];
-  let Prototype = "void*(unsigned char)";
-}
-
 // Builtins for XRay.
 def XRayCustomEvent : Builtin {
   let Spellings = ["__xray_customevent"];
diff --git a/clang/include/clang/Basic/BuiltinsHLSL.td 
b/clang/include/clang/Basic/BuiltinsHLSL.td
new file mode 100644
index 00..98088f920a9940
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsHLSL.td
@@ -0,0 +1,21 @@
+//===--- BuiltinsHLSL.td - HLSL 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_wave_active_count_bits"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "unsigned int(bool)";
+}
+
+def HLSLCreateHandle : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_create_handle"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void*(unsigned char)";
+}
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 7785fb430c069b..01233eb44feffc 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -65,7 +65,11 @@ clang_tablegen(BuiltinsBPF.inc -gen-clang-builtins
   SOURCE BuiltinsBPF.td
   TARGET ClangBuiltinsBPF)
 
-clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins
+clang_tablegen(BuiltinsHLSL.inc -gen-clang-builtins
+  SOURCE BuiltinsHLSL.td
+  TARGET ClangBuiltinsHLSL)
+
+  clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins
   SOURCE BuiltinsRISCV.td
   TARGET ClangBuiltinsRISCV)
 
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index 4333830bf34f24..15cf111ae5e9e5 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -89,6 +89,16 @@ namespace clang {
   };
   }
 
+  /// HLSL builtins
+  namespace hlsl {
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsHLSL.inc"
+LastTSBuiltin
+  };
+  } // namespace hlsl
+
   /// PPC builtins
   namespace PPC {
 enum {
diff --git a/clang/lib/Basic/Targets/DirectX.cpp 
b/clang/lib/Basic/Targets/DirectX.cpp
index 0dd27e6e93b33b..83cc049e5963aa 100644
--- a/clang/lib/Basic/Targets/DirectX.cpp
+++ b/clang/lib/Basic/Targets/DirectX.cpp
@@ -12,11 +12,24 @@
 
 #include "DirectX.h"
 #include "Targets.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetBuiltins.h"
 
 using namespace clang;
 using namespace clang::targets;
 
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+  {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#include "clang/Basic/BuiltinsHLSL.inc"
+};
+
 void DirectXTargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   DefineStd(Builder, "DIRECTX", Opts);
 }
+
+ArrayRef DirectXTargetInfo::getTargetBuiltins() const {
+  return llvm::ArrayRef(BuiltinInfo,
+clang::hlsl::LastTSBuiltin - Builtin::FirstTSBuiltin);
+}
diff --git a/clang/lib/Basic/Targets/DirectX.h 
b/clang/lib/Ba

[clang] [HLSL] add BuiltinsHLSL and set it up as target builtins. (PR #81902)

2024-02-15 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl created 
https://github.com/llvm/llvm-project/pull/81902

1. This change moves hlsl specific builtins from Builtins.td to BuiltinsHLSL.td.
2. Adds changes to the build system to build BuiltinsHLSL.td.
3. Setups HLSL builtins as TargetBuiltins.

>From 1c86da726134e9d4a659fb5b1ab149b5df80f378 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Thu, 15 Feb 2024 13:46:55 -0500
Subject: [PATCH] [HLSL] add BuiltinsHLSL and set it up as target builtins.

1. This change moves hlsl specific builtins from Builtins.td
to BuiltinsHLSL.td.
2. Adds changes to the build system to build BuiltinsHLSL.td.
3. Setups HLSL builtins as TargetBuiltins.
---
 clang/include/clang/Basic/Builtins.td  | 13 -
 clang/include/clang/Basic/BuiltinsHLSL.td  | 21 +
 clang/include/clang/Basic/CMakeLists.txt   |  6 +-
 clang/include/clang/Basic/TargetBuiltins.h | 10 ++
 clang/lib/Basic/Targets/DirectX.cpp| 13 +
 clang/lib/Basic/Targets/DirectX.h  |  4 +---
 6 files changed, 50 insertions(+), 17 deletions(-)
 create mode 100644 clang/include/clang/Basic/BuiltinsHLSL.td

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index df74026c5d2d50..2943911b662191 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4511,19 +4511,6 @@ def GetDeviceSideMangledName : LangBuiltin<"CUDA_LANG"> {
   let Prototype = "char const*(...)";
 }
 
-// HLSL
-def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> {
-  let Spellings = ["__builtin_hlsl_wave_active_count_bits"];
-  let Attributes = [NoThrow, Const];
-  let Prototype = "unsigned int(bool)";
-}
-
-def HLSLCreateHandle : LangBuiltin<"HLSL_LANG"> {
-  let Spellings = ["__builtin_hlsl_create_handle"];
-  let Attributes = [NoThrow, Const];
-  let Prototype = "void*(unsigned char)";
-}
-
 // Builtins for XRay.
 def XRayCustomEvent : Builtin {
   let Spellings = ["__xray_customevent"];
diff --git a/clang/include/clang/Basic/BuiltinsHLSL.td 
b/clang/include/clang/Basic/BuiltinsHLSL.td
new file mode 100644
index 00..98088f920a9940
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsHLSL.td
@@ -0,0 +1,21 @@
+//===--- BuiltinsHLSL.td - HLSL 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_wave_active_count_bits"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "unsigned int(bool)";
+}
+
+def HLSLCreateHandle : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_create_handle"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void*(unsigned char)";
+}
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 7785fb430c069b..01233eb44feffc 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -65,7 +65,11 @@ clang_tablegen(BuiltinsBPF.inc -gen-clang-builtins
   SOURCE BuiltinsBPF.td
   TARGET ClangBuiltinsBPF)
 
-clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins
+clang_tablegen(BuiltinsHLSL.inc -gen-clang-builtins
+  SOURCE BuiltinsHLSL.td
+  TARGET ClangBuiltinsHLSL)
+
+  clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins
   SOURCE BuiltinsRISCV.td
   TARGET ClangBuiltinsRISCV)
 
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index 4333830bf34f24..15cf111ae5e9e5 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -89,6 +89,16 @@ namespace clang {
   };
   }
 
+  /// HLSL builtins
+  namespace hlsl {
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsHLSL.inc"
+LastTSBuiltin
+  };
+  } // namespace hlsl
+
   /// PPC builtins
   namespace PPC {
 enum {
diff --git a/clang/lib/Basic/Targets/DirectX.cpp 
b/clang/lib/Basic/Targets/DirectX.cpp
index 0dd27e6e93b33b..83cc049e5963aa 100644
--- a/clang/lib/Basic/Targets/DirectX.cpp
+++ b/clang/lib/Basic/Targets/DirectX.cpp
@@ -12,11 +12,24 @@
 
 #include "DirectX.h"
 #include "Targets.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetBuiltins.h"
 
 using namespace clang;
 using namespace clang::targets;
 
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+  {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#include "clang/Basic/BuiltinsHLSL.inc"
+};
+
 void DirectXTargetInfo::getTargetDefines(cons

[clang] [alpha.webkit.UncountedCallArgsChecker] Detect & ignore trivial function calls. (PR #81808)

2024-02-15 Thread Artem Dergachev via cfe-commits

haoNoQ wrote:

Oh, this sort of stuff usually happens because the default target triple in the 
test is the target triple for the host machine, so you'll get different 
target-specific compiler behavior on different buildbots, in particular 
`sizeof(unsigned long)` may be different. You can add eg. `-triple 
x86_64-darwin` to freeze the triple and force windows bots to cross-compile for 
mac. This probably doesn't affect your test.

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


[clang] [compiler-rt] [llvm] [InstrProf] Single byte counters in coverage (PR #75425)

2024-02-15 Thread Alan Phipps via cfe-commits


@@ -1519,38 +1543,53 @@ struct CounterCoverageMappingBuilder
 }
 
 // Create Branch Region around condition.
-createBranchRegion(S->getCond(), BodyCount,
-   subtractCounters(CondCount, BodyCount));
+if (!llvm::EnableSingleByteCoverage)
+  createBranchRegion(S->getCond(), BodyCount,
+ subtractCounters(CondCount, BodyCount));

evodius96 wrote:

I may have missed it, but do you plan to handle branch regions at some point 
with explicit byte counters?

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


[clang] [clang] Do less advertising for unresolved issues in `cxx_dr_status.html` (PR #78836)

2024-02-15 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/78836

>From c931f87fdabe83e1e3507f0e52ebb3201a41cb82 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 20 Jan 2024 12:04:32 +0300
Subject: [PATCH 1/5] [clang] Stop reporting unresolved issues in
 `cxx_dr_status.html`

This patch prevents tests for unresolved issues to report availability (e.g. 
`no` or `18`) on `cxx_dr_status.html` page. But it still checks whether 
specified status matches status on the official list, preventing tests going 
out of date.

Because of aforementioned points, availability comment syntax is now simpler 
for tests for unresolved issues. What was previously written as `// dr2345: 18 
drafting` is now simply `// dr2345: drafting`.

This has been discussed in a PR for CWG472 test: 
https://github.com/llvm/llvm-project/pull/67948#discussion_r1452506341
---
 clang/test/CXX/drs/dr12xx.cpp |  2 +-
 clang/test/CXX/drs/dr18xx.cpp |  2 +-
 clang/test/CXX/drs/dr20xx.cpp |  2 +-
 clang/test/CXX/drs/dr2335.cpp |  2 +-
 clang/test/CXX/drs/dr23xx.cpp |  2 +-
 clang/test/CXX/drs/dr24xx.cpp |  4 +--
 clang/test/CXX/drs/dr25xx.cpp |  8 +++---
 clang/www/cxx_dr_status.html  | 22 -
 clang/www/make_cxx_dr_status  | 46 ---
 9 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/clang/test/CXX/drs/dr12xx.cpp b/clang/test/CXX/drs/dr12xx.cpp
index cb4cc5aef17371..aaedbe916dc213 100644
--- a/clang/test/CXX/drs/dr12xx.cpp
+++ b/clang/test/CXX/drs/dr12xx.cpp
@@ -32,7 +32,7 @@ namespace dr1213 { // dr1213: 7
 }
 
 #if __cplusplus >= 201103L
-namespace dr1223 { // dr1223: 17 drafting
+namespace dr1223 { // dr1223: drafting
 struct M;
 template 
 struct V;
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index 0245f03986dd73..f6c94f32506cb2 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -331,7 +331,7 @@ namespace dr1881 { // dr1881: 7
   static_assert(!__is_standard_layout(D), "");
 }
 
-namespace dr1890 { // dr1890: no drafting
+namespace dr1890 { // dr1890: drafting
 // FIXME: current consensus for CWG2335 is that the examples are well-formed.
 namespace ex1 {
 #if __cplusplus >= 201402L
diff --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index f7f37379e61ad1..016ba4e2ccb85d 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -90,7 +90,7 @@ namespace dr2026 { // dr2026: 11
   }
 }
 
-namespace dr2049 { // dr2049: 18 drafting
+namespace dr2049 { // dr2049: drafting
 #if __cplusplus >= 202302L
 template  struct X {};
 X<> a;
diff --git a/clang/test/CXX/drs/dr2335.cpp b/clang/test/CXX/drs/dr2335.cpp
index d143aaf7cb0ac0..ac0193db06bdb7 100644
--- a/clang/test/CXX/drs/dr2335.cpp
+++ b/clang/test/CXX/drs/dr2335.cpp
@@ -10,7 +10,7 @@
 // expected-no-diagnostics
 #endif
 
-namespace dr2335 { // dr2335: no drafting
+namespace dr2335 { // dr2335: drafting
 // FIXME: current consensus is that the examples are well-formed.
 #if __cplusplus >= 201402L
 namespace ex1 {
diff --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp
index d8556998315c77..0f87904c860b61 100644
--- a/clang/test/CXX/drs/dr23xx.cpp
+++ b/clang/test/CXX/drs/dr23xx.cpp
@@ -57,7 +57,7 @@ void g() {
 } //namespace dr2303
 #endif
 
-namespace dr2311 {  // dr2311: 18 open
+namespace dr2311 {  // dr2311: open
 #if __cplusplus >= 201707L
 template
 void test() {
diff --git a/clang/test/CXX/drs/dr24xx.cpp b/clang/test/CXX/drs/dr24xx.cpp
index 66e9cf5a677f80..a4d40fa96b66f4 100644
--- a/clang/test/CXX/drs/dr24xx.cpp
+++ b/clang/test/CXX/drs/dr24xx.cpp
@@ -45,7 +45,7 @@ void fallthrough(int n) {
 #endif
 }
 
-namespace dr2450 { // dr2450: 18 review
+namespace dr2450 { // dr2450: review
 #if __cplusplus >= 202302L
 struct S {int a;};
 template 
@@ -59,7 +59,7 @@ f<{.a= 0}>();
 #endif
 }
 
-namespace dr2459 { // dr2459: 18 drafting
+namespace dr2459 { // dr2459: drafting
 #if __cplusplus >= 202302L
 struct A {
   constexpr A(float) {}
diff --git a/clang/test/CXX/drs/dr25xx.cpp b/clang/test/CXX/drs/dr25xx.cpp
index 502f03271d9afe..b28abc4166e3a0 100644
--- a/clang/test/CXX/drs/dr25xx.cpp
+++ b/clang/test/CXX/drs/dr25xx.cpp
@@ -83,7 +83,7 @@ using ::dr2521::operator""_div;
 
 
 #if __cplusplus >= 202302L
-namespace dr2553 { // dr2553: 18 review
+namespace dr2553 { // dr2553: review
 struct B {
   virtual void f(this B&); 
   // since-cxx23-error@-1 {{an explicit object parameter cannot appear in a 
virtual function}}
@@ -101,7 +101,7 @@ struct D : B {
 #endif
 
 #if __cplusplus >= 202302L
-namespace dr2554 { // dr2554: 18 review
+namespace dr2554 { // dr2554: review
 struct B {
   virtual void f(); // #dr2554-g
 };
@@ -128,7 +128,7 @@ struct D3 : B {
 #endif
 
 #if __cplusplus >= 202302L
-namespace dr2561 { // dr2561: 18 review
+namespace dr2561 { // dr2561: review
 struct C {
 constexpr C(auto) { }
 };
@@ -143,7 +143,7 @@ void foo() {
 #endif
 
 
-namespace dr2565 { // dr2565: 16 

[clang] [clang] Move `AvailabilityInfo` into AST library (PR #81897)

2024-02-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Cyndy Ishida (cyndyishida)


Changes

Previously this class was only used by ExtractAPI, but it will soon also be 
needed by InstallAPI. This patch should not change availability behavior but 
just centralizes the information next to what already is captured about 
availability for AST traversal.

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


7 Files Affected:

- (modified) clang/include/clang/AST/Availability.h (+51) 
- (modified) clang/include/clang/ExtractAPI/API.h (+1-1) 
- (removed) clang/include/clang/ExtractAPI/AvailabilityInfo.h (-76) 
- (modified) clang/include/clang/ExtractAPI/ExtractAPIVisitor.h (+1-1) 
- (renamed) clang/lib/AST/Availability.cpp (+17-4) 
- (modified) clang/lib/AST/CMakeLists.txt (+1) 
- (modified) clang/lib/ExtractAPI/CMakeLists.txt (-1) 


``diff
diff --git a/clang/include/clang/AST/Availability.h 
b/clang/include/clang/AST/Availability.h
index 527fc4b59a5f4d..ff0018b0452dda 100644
--- a/clang/include/clang/AST/Availability.h
+++ b/clang/include/clang/AST/Availability.h
@@ -57,6 +57,57 @@ class AvailabilitySpec {
   bool isOtherPlatformSpec() const { return Version.empty(); }
 };
 
+class Decl;
+
+/// Storage of availability attributes for a declaration.
+struct AvailabilityInfo {
+  /// The domain for which this availability info item applies.
+  std::string Domain;
+  VersionTuple Introduced;
+  VersionTuple Deprecated;
+  VersionTuple Obsoleted;
+  bool UnconditionallyDeprecated = false;
+  bool UnconditionallyUnavailable = false;
+
+  AvailabilityInfo() = default;
+
+  /// Determine if this AvailabilityInfo represents the default availability.
+  bool isDefault() const { return *this == AvailabilityInfo(); }
+
+  /// Check if the symbol is unconditionally deprecated.
+  ///
+  /// i.e. \code __attribute__((deprecated)) \endcode
+  bool isUnconditionallyDeprecated() const { return UnconditionallyDeprecated; 
}
+
+  /// Check if the symbol is unconditionally unavailable.
+  ///
+  /// i.e. \code __attribute__((unavailable)) \endcode
+  bool isUnconditionallyUnavailable() const {
+return UnconditionallyUnavailable;
+  }
+
+  AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
+   VersionTuple O, bool UD, bool UU)
+  : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O),
+UnconditionallyDeprecated(UD), UnconditionallyUnavailable(UU) {}
+
+  friend bool operator==(const AvailabilityInfo &Lhs,
+ const AvailabilityInfo &Rhs);
+
+public:
+  static AvailabilityInfo createFromDecl(const Decl *Decl);
+};
+
+inline bool operator==(const AvailabilityInfo &Lhs,
+   const AvailabilityInfo &Rhs) {
+  return std::tie(Lhs.Introduced, Lhs.Deprecated, Lhs.Obsoleted,
+  Lhs.UnconditionallyDeprecated,
+  Lhs.UnconditionallyUnavailable) ==
+ std::tie(Rhs.Introduced, Rhs.Deprecated, Rhs.Obsoleted,
+  Rhs.UnconditionallyDeprecated,
+  Rhs.UnconditionallyUnavailable);
+}
+
 } // end namespace clang
 
 #endif
diff --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index 0a0f1bd1e95f7f..b220db294101d8 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -18,12 +18,12 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_API_H
 #define LLVM_CLANG_EXTRACTAPI_API_H
 
+#include "clang/AST/Availability.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
-#include "clang/ExtractAPI/AvailabilityInfo.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
diff --git a/clang/include/clang/ExtractAPI/AvailabilityInfo.h 
b/clang/include/clang/ExtractAPI/AvailabilityInfo.h
deleted file mode 100644
index 3b8d6f46ed56d2..00
--- a/clang/include/clang/ExtractAPI/AvailabilityInfo.h
+++ /dev/null
@@ -1,76 +0,0 @@
-//===- ExtractAPI/AvailabilityInfo.h - Availability Info *- 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
-//
-//===--===//
-///
-/// \file
-/// This file defines the AvailabilityInfo struct that collects availability
-/// attributes of a symbol.
-///
-//===--===//
-
-#ifndef LLVM_CLANG_EXTRACTAPI_AVAILABILITY_INFO_H
-#define LLVM_CLANG_EXTRACTAPI_AVAILABILITY_INFO_H
-
-#include "clang/AST/Decl.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Support/VersionTuple.h"
-#include "llvm/Support/raw_ostream.h"
-
-namespace clang {
-namespace extractapi {
-
-/// Stores availability attr

[clang] [clang] Move `AvailabilityInfo` into AST library (PR #81897)

2024-02-15 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/81897

Previously this class was only used by ExtractAPI, but it will soon also be 
needed by InstallAPI. This patch should not change availability behavior but 
just centralizes the information next to what already is captured about 
availability for AST traversal.

>From e80d3e4310c8bc35ad0f8ac530f51903beb7b000 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 15 Feb 2024 10:36:45 -0800
Subject: [PATCH] [clang] Move `AvailabilityInfo` into AST library

Previously this class was only used by ExtractAPI, but it will soon also
be needed by InstallAPI. This patch should not change availbility
behavior but just centralizes the information next to what already is
captured about availability for ast traversal.
---
 clang/include/clang/AST/Availability.h| 51 +
 clang/include/clang/ExtractAPI/API.h  |  2 +-
 .../clang/ExtractAPI/AvailabilityInfo.h   | 76 ---
 .../clang/ExtractAPI/ExtractAPIVisitor.h  |  2 +-
 .../Availability.cpp} | 21 -
 clang/lib/AST/CMakeLists.txt  |  1 +
 clang/lib/ExtractAPI/CMakeLists.txt   |  1 -
 7 files changed, 71 insertions(+), 83 deletions(-)
 delete mode 100644 clang/include/clang/ExtractAPI/AvailabilityInfo.h
 rename clang/lib/{ExtractAPI/AvailabilityInfo.cpp => AST/Availability.cpp} 
(63%)

diff --git a/clang/include/clang/AST/Availability.h 
b/clang/include/clang/AST/Availability.h
index 527fc4b59a5f4d..ff0018b0452dda 100644
--- a/clang/include/clang/AST/Availability.h
+++ b/clang/include/clang/AST/Availability.h
@@ -57,6 +57,57 @@ class AvailabilitySpec {
   bool isOtherPlatformSpec() const { return Version.empty(); }
 };
 
+class Decl;
+
+/// Storage of availability attributes for a declaration.
+struct AvailabilityInfo {
+  /// The domain for which this availability info item applies.
+  std::string Domain;
+  VersionTuple Introduced;
+  VersionTuple Deprecated;
+  VersionTuple Obsoleted;
+  bool UnconditionallyDeprecated = false;
+  bool UnconditionallyUnavailable = false;
+
+  AvailabilityInfo() = default;
+
+  /// Determine if this AvailabilityInfo represents the default availability.
+  bool isDefault() const { return *this == AvailabilityInfo(); }
+
+  /// Check if the symbol is unconditionally deprecated.
+  ///
+  /// i.e. \code __attribute__((deprecated)) \endcode
+  bool isUnconditionallyDeprecated() const { return UnconditionallyDeprecated; 
}
+
+  /// Check if the symbol is unconditionally unavailable.
+  ///
+  /// i.e. \code __attribute__((unavailable)) \endcode
+  bool isUnconditionallyUnavailable() const {
+return UnconditionallyUnavailable;
+  }
+
+  AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
+   VersionTuple O, bool UD, bool UU)
+  : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O),
+UnconditionallyDeprecated(UD), UnconditionallyUnavailable(UU) {}
+
+  friend bool operator==(const AvailabilityInfo &Lhs,
+ const AvailabilityInfo &Rhs);
+
+public:
+  static AvailabilityInfo createFromDecl(const Decl *Decl);
+};
+
+inline bool operator==(const AvailabilityInfo &Lhs,
+   const AvailabilityInfo &Rhs) {
+  return std::tie(Lhs.Introduced, Lhs.Deprecated, Lhs.Obsoleted,
+  Lhs.UnconditionallyDeprecated,
+  Lhs.UnconditionallyUnavailable) ==
+ std::tie(Rhs.Introduced, Rhs.Deprecated, Rhs.Obsoleted,
+  Rhs.UnconditionallyDeprecated,
+  Rhs.UnconditionallyUnavailable);
+}
+
 } // end namespace clang
 
 #endif
diff --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index 0a0f1bd1e95f7f..b220db294101d8 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -18,12 +18,12 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_API_H
 #define LLVM_CLANG_EXTRACTAPI_API_H
 
+#include "clang/AST/Availability.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
-#include "clang/ExtractAPI/AvailabilityInfo.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
diff --git a/clang/include/clang/ExtractAPI/AvailabilityInfo.h 
b/clang/include/clang/ExtractAPI/AvailabilityInfo.h
deleted file mode 100644
index 3b8d6f46ed56d2..00
--- a/clang/include/clang/ExtractAPI/AvailabilityInfo.h
+++ /dev/null
@@ -1,76 +0,0 @@
-//===- ExtractAPI/AvailabilityInfo.h - Availability Info *- 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
-//
-//===---

[clang] [HLSL] Expose `half` types and intrinsics always (PR #81782)

2024-02-15 Thread Chris B via cfe-commits

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


[clang] e82659f - [HLSL] Expose `half` types and intrinsics always (#81782)

2024-02-15 Thread via cfe-commits

Author: Chris B
Date: 2024-02-15T12:29:22-06:00
New Revision: e82659fff2f07b5ea1d94e0d8bcb9c540d6bede1

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

LOG: [HLSL] Expose `half` types and intrinsics always (#81782)

We previously made an implmenetation error when adding `half` overloads
for HLSL library functionalitly. The `half` type is always defined in
HLSL and `half` intrinsics should not be conditionally included.

When native 16-bit types are disabled `half` is a unique 32-bit float
type with lesser promotion rank than `float`.

Fixes #81049

Added: 


Modified: 
clang/lib/Headers/hlsl/hlsl_basic_types.h
clang/lib/Headers/hlsl/hlsl_intrinsics.h
clang/test/CodeGenHLSL/builtins/abs.hlsl
clang/test/CodeGenHLSL/builtins/ceil.hlsl
clang/test/CodeGenHLSL/builtins/cos.hlsl
clang/test/CodeGenHLSL/builtins/floor.hlsl
clang/test/CodeGenHLSL/builtins/log.hlsl
clang/test/CodeGenHLSL/builtins/log10.hlsl
clang/test/CodeGenHLSL/builtins/log2.hlsl
clang/test/CodeGenHLSL/builtins/max.hlsl
clang/test/CodeGenHLSL/builtins/min.hlsl
clang/test/CodeGenHLSL/builtins/pow.hlsl
clang/test/CodeGenHLSL/builtins/reversebits.hlsl
clang/test/CodeGenHLSL/builtins/sin.hlsl
clang/test/CodeGenHLSL/builtins/trunc.hlsl

Removed: 




diff  --git a/clang/lib/Headers/hlsl/hlsl_basic_types.h 
b/clang/lib/Headers/hlsl/hlsl_basic_types.h
index e96fa90b1ce469..3d0d296aadca3a 100644
--- a/clang/lib/Headers/hlsl/hlsl_basic_types.h
+++ b/clang/lib/Headers/hlsl/hlsl_basic_types.h
@@ -56,11 +56,9 @@ typedef vector uint64_t2;
 typedef vector uint64_t3;
 typedef vector uint64_t4;
 
-#ifdef __HLSL_ENABLE_16_BIT
 typedef vector half2;
 typedef vector half3;
 typedef vector half4;
-#endif
 
 typedef vector float2;
 typedef vector float3;

diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index a8b36d29c78607..f87ac977997962 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -21,6 +21,13 @@ namespace hlsl {
 #define _HLSL_AVAILABILITY(environment, version)   
\
   __attribute__((availability(environment, introduced = version)))
 
+#ifdef __HLSL_ENABLE_16_BIT
+#define _HLSL_16BIT_AVAILABILITY(environment, version) 
\
+  __attribute__((availability(environment, introduced = version)))
+#else
+#define _HLSL_16BIT_AVAILABILITY(environment, version)
+#endif
+
 
//===--===//
 // abs builtins
 
//===--===//
@@ -42,20 +49,20 @@ int16_t3 abs(int16_t3);
 _HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
 int16_t4 abs(int16_t4);
+#endif
 
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
 half abs(half);
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
 half2 abs(half2);
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
 half3 abs(half3);
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
 half4 abs(half4);
-#endif
 
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
 int abs(int);
@@ -102,20 +109,18 @@ double4 abs(double4);
 /// the input value, \a Val.
 /// \param Val The input value.
 
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
 half ceil(half);
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
 half2 ceil(half2);
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
 half3 ceil(half3);
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
 half4 ceil(half4);
-#endif
 
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
 float ceil(float);
@@ -143,20 +148,18 @@ double4 ceil(double4);
 /// \brief Returns the cosine of the input value, \a Val.
 /// \param Val The input value.
 
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
 half cos(half);
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
 half2 cos(half2);
-_HLSL_AVA

[clang] [HLSL] Expose `half` types and intrinsics always (PR #81782)

2024-02-15 Thread David Peixotto via cfe-commits

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


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


[clang] [HLSL] Expose `half` types and intrinsics always (PR #81782)

2024-02-15 Thread David Peixotto via cfe-commits


@@ -42,20 +49,20 @@ int16_t3 abs(int16_t3);
 _HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
 int16_t4 abs(int16_t4);
+#endif
 
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)

dmpots wrote:

Ah ok. So this isn't changing how the enabling of 16bit types are working. It 
just lets the 32-bit half overloads work in earlier shader models.

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


[clang] [clang] Refactor target attribute mangling. (PR #81893)

2024-02-15 Thread Erich Keane via cfe-commits

erichkeane wrote:

> I wonder if this should be a part of the Targets in CodeGen instead of here?

Hrm, this is a bad idea as the rest of mangling is in AST, but having mangling 
outside of AST seems to be the problem here.  

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


[clang] [clang] Refactor target attribute mangling. (PR #81893)

2024-02-15 Thread Erich Keane via cfe-commits


@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
 #define LLVM_CLANG_BASIC_TARGETINFO_H
 
+#include "clang/AST/Attr.h"

erichkeane wrote:

Basic shouldn't be referencing AST (IIRC, it shouldn't reference anything but 
basic or llvm), this ends up being an unfortunate layering violation.

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


[clang] [clang] Refactor target attribute mangling. (PR #81893)

2024-02-15 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

I wonder if this should be a part of the Targets in CodeGen instead of here?

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


[clang] [clang] Refactor target attribute mangling. (PR #81893)

2024-02-15 Thread Erich Keane via cfe-commits

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


[clang] [alpha.webkit.UncountedCallArgsChecker] Detect & ignore trivial function calls. (PR #81808)

2024-02-15 Thread Ryosuke Niwa via cfe-commits

rniwa wrote:

> @rniwa the test you modified in this change seems to be failing on at least 
> one bot. Can you take a look or revert if you need time to investigate?
> 
> https://lab.llvm.org/buildbot/#/builders/123/builds/25095

Oh, interesting. I suppose this is due to:
```
# | error: 'expected-error' diagnostics seen but not expected: 
# |   File 
C:\b\slave\clang-x64-windows-msvc\llvm-project\clang\test\Analysis\Checkers\WebKit\uncounted-obj-arg.cpp
 Line 110: cast from pointer to smaller type 'unsigned long' loses information
```

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


[clang] [clang] Refactor target attribute mangling. (PR #81893)

2024-02-15 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 8bda8cfae6aa3c32cca7997ab64771e6a78f3e61 
81ff9395020405dfb123ac6872839432583e067f -- 
clang/include/clang/Basic/TargetInfo.h clang/lib/Basic/TargetInfo.cpp 
clang/lib/Basic/Targets/AArch64.cpp clang/lib/Basic/Targets/AArch64.h 
clang/lib/CodeGen/CodeGenModule.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index c17fd4949e..70fe0b6dbc 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -568,22 +568,22 @@ std::string 
TargetInfo::getManglingSuffixFromStr(StringRef AttrStr) const {
"Features should always have a prefix.");
 return multiVersionSortPriority(LHS.substr(1)) >
multiVersionSortPriority(RHS.substr(1));
-   });
-
-   bool IsFirst = true;
-   if (!Info.CPU.empty()) {
- IsFirst = false;
- ManglingSuffix.append(Twine("arch_", Info.CPU).str());
-   }
-
-   for (StringRef Feat : Info.Features) {
- if (!IsFirst)
-   ManglingSuffix.append("_");
- IsFirst = false;
- ManglingSuffix.append(Feat.substr(1).str());
-   }
-
-   return ManglingSuffix;
+  });
+
+  bool IsFirst = true;
+  if (!Info.CPU.empty()) {
+IsFirst = false;
+ManglingSuffix.append(Twine("arch_", Info.CPU).str());
+  }
+
+  for (StringRef Feat : Info.Features) {
+if (!IsFirst)
+  ManglingSuffix.append("_");
+IsFirst = false;
+ManglingSuffix.append(Feat.substr(1).str());
+  }
+
+  return ManglingSuffix;
 }
 
 ParsedTargetAttr TargetInfo::parseTargetAttr(StringRef Features) const {

``




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


[clang] [compiler-rt] [llvm] [InstrProf] Single byte counters in coverage (PR #75425)

2024-02-15 Thread Ellis Hoag via cfe-commits

ellishg wrote:

LGTM, but I'm less familiar with the clang coverage code. So I'll give others 
some time to accept. 

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


[clang] [clang] Refactor target attribute mangling. (PR #81893)

2024-02-15 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-aarch64

@llvm/pr-subscribers-clang-codegen

Author: Alexandros Lamprineas (labrinea)


Changes

Before this patch all of the 'target', 'target_version' and 'target_clones' 
attributes were sharing a common mangling logic across different targets. 
However we would like to differenciate this logic, therefore I have moved the 
default path to TargetInfo and provided overrides for AArch64. This way we can 
resolve feature aliases without affecting the name mangling The PR #80540 demonstrates a motivating case.

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


5 Files Affected:

- (modified) clang/include/clang/Basic/TargetInfo.h (+8) 
- (modified) clang/lib/Basic/TargetInfo.cpp (+51) 
- (modified) clang/lib/Basic/Targets/AArch64.cpp (+27) 
- (modified) clang/lib/Basic/Targets/AArch64.h (+7) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+13-95) 


``diff
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 2f80234c0dc7e3..7ea4e0c0197761 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
 #define LLVM_CLANG_BASIC_TARGETINFO_H
 
+#include "clang/AST/Attr.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/CodeGenOptions.h"
@@ -1321,6 +1322,13 @@ class TargetInfo : public TransferrableTargetInfo,
 return isValidCPUName(Name);
   }
 
+  virtual std::string getManglingSuffixFromAttr(TargetAttr *Attr) const;
+  virtual std::string getManglingSuffixFromAttr(TargetVersionAttr *Attr) const;
+  virtual std::string getManglingSuffixFromAttr(TargetClonesAttr *Attr,
+unsigned VersionIndex) const;
+
+  virtual std::string getManglingSuffixFromStr(StringRef AttrStr) const;
+
   virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const;
 
   /// Determine whether this TargetInfo supports tune in target attribute.
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 08fb0f2bb1bad6..c17fd4949ef0cd 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -535,6 +535,57 @@ bool TargetInfo::initFeatureMap(
   return true;
 }
 
+std::string TargetInfo::getManglingSuffixFromAttr(TargetAttr *Attr) const {
+  if (Attr->isDefaultVersion())
+return {};
+
+  return getManglingSuffixFromStr(Attr->getFeaturesStr());
+}
+
+std::string
+TargetInfo::getManglingSuffixFromAttr(TargetVersionAttr *Attr) const {
+  return getManglingSuffixFromStr(Attr->getNamesStr());
+}
+
+std::string TargetInfo::getManglingSuffixFromAttr(TargetClonesAttr *Attr,
+  unsigned Index) const {
+  std::string Suffix = getManglingSuffixFromStr(Attr->getFeatureStr(Index));
+  Suffix.append("." + Twine(Attr->getMangledIndex(Index)).str());
+  return Suffix;
+}
+
+std::string TargetInfo::getManglingSuffixFromStr(StringRef AttrStr) const {
+  if (AttrStr == "default")
+return ".default";
+
+  std::string ManglingSuffix(".");
+  ParsedTargetAttr Info = parseTargetAttr(AttrStr);
+
+  llvm::sort(Info.Features, [this](StringRef LHS, StringRef RHS) {
+// Multiversioning doesn't allow "no-${feature}", so we can
+// only have "+" prefixes here.
+assert(LHS.starts_with("+") && RHS.starts_with("+") &&
+   "Features should always have a prefix.");
+return multiVersionSortPriority(LHS.substr(1)) >
+   multiVersionSortPriority(RHS.substr(1));
+   });
+
+   bool IsFirst = true;
+   if (!Info.CPU.empty()) {
+ IsFirst = false;
+ ManglingSuffix.append(Twine("arch_", Info.CPU).str());
+   }
+
+   for (StringRef Feat : Info.Features) {
+ if (!IsFirst)
+   ManglingSuffix.append("_");
+ IsFirst = false;
+ ManglingSuffix.append(Feat.substr(1).str());
+   }
+
+   return ManglingSuffix;
+}
+
 ParsedTargetAttr TargetInfo::parseTargetAttr(StringRef Features) const {
   ParsedTargetAttr Ret;
   if (Features == "default")
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c49461bd20eeec..d288c431a46207 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1105,6 +1105,33 @@ bool AArch64TargetInfo::initFeatureMap(
   return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
 }
 
+std::string AArch64TargetInfo::getManglingSuffixFromAttr(TargetClonesAttr 
*Attr,
+ unsigned Index) const 
{
+  return getManglingSuffixFromStr(Attr->getFeatureStr(Index));
+}
+
+std::string AArch64TargetInfo::getManglingSuffixFromStr(StringRef Str) const {
+  if (Str == "default")
+return ".default";
+
+  std::string ManglingSuffix("._");
+  SmallVector Features;
+  Str.split(Features, "+");
+  for (auto &Feat : Features)
+Feat = Feat.trim();
+
+  // TODO Lexic

[clang] [clang] Refactor target attribute mangling. (PR #81893)

2024-02-15 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea created 
https://github.com/llvm/llvm-project/pull/81893

Before this patch all of the 'target', 'target_version' and 'target_clones' 
attributes were sharing a common mangling logic across different targets. 
However we would like to differenciate this logic, therefore I have moved the 
default path to TargetInfo and provided overrides for AArch64. This way we can 
resolve feature aliases without affecting the name mangling The PR #80540 
demonstrates a motivating case.

>From 81ff9395020405dfb123ac6872839432583e067f Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Thu, 15 Feb 2024 15:53:51 +
Subject: [PATCH] [clang] Refactor target attribute mangling.

Before this patch all of the 'target', 'target_version' and 'target_clones'
attributes were sharing a common mangling logic across different targets.
However we would like to differenciate this logic, therefore I have moved
the default path to TargetInfo and provided overrides for AArch64. This
way we can resolve feature aliases without affecting the name mangling
The PR #80540 demonstrates a motivating case.
---
 clang/include/clang/Basic/TargetInfo.h |   8 ++
 clang/lib/Basic/TargetInfo.cpp |  51 
 clang/lib/Basic/Targets/AArch64.cpp|  27 +++
 clang/lib/Basic/Targets/AArch64.h  |   7 ++
 clang/lib/CodeGen/CodeGenModule.cpp| 108 +++--
 5 files changed, 106 insertions(+), 95 deletions(-)

diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 2f80234c0dc7e3..7ea4e0c0197761 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
 #define LLVM_CLANG_BASIC_TARGETINFO_H
 
+#include "clang/AST/Attr.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/CodeGenOptions.h"
@@ -1321,6 +1322,13 @@ class TargetInfo : public TransferrableTargetInfo,
 return isValidCPUName(Name);
   }
 
+  virtual std::string getManglingSuffixFromAttr(TargetAttr *Attr) const;
+  virtual std::string getManglingSuffixFromAttr(TargetVersionAttr *Attr) const;
+  virtual std::string getManglingSuffixFromAttr(TargetClonesAttr *Attr,
+unsigned VersionIndex) const;
+
+  virtual std::string getManglingSuffixFromStr(StringRef AttrStr) const;
+
   virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const;
 
   /// Determine whether this TargetInfo supports tune in target attribute.
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 08fb0f2bb1bad6..c17fd4949ef0cd 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -535,6 +535,57 @@ bool TargetInfo::initFeatureMap(
   return true;
 }
 
+std::string TargetInfo::getManglingSuffixFromAttr(TargetAttr *Attr) const {
+  if (Attr->isDefaultVersion())
+return {};
+
+  return getManglingSuffixFromStr(Attr->getFeaturesStr());
+}
+
+std::string
+TargetInfo::getManglingSuffixFromAttr(TargetVersionAttr *Attr) const {
+  return getManglingSuffixFromStr(Attr->getNamesStr());
+}
+
+std::string TargetInfo::getManglingSuffixFromAttr(TargetClonesAttr *Attr,
+  unsigned Index) const {
+  std::string Suffix = getManglingSuffixFromStr(Attr->getFeatureStr(Index));
+  Suffix.append("." + Twine(Attr->getMangledIndex(Index)).str());
+  return Suffix;
+}
+
+std::string TargetInfo::getManglingSuffixFromStr(StringRef AttrStr) const {
+  if (AttrStr == "default")
+return ".default";
+
+  std::string ManglingSuffix(".");
+  ParsedTargetAttr Info = parseTargetAttr(AttrStr);
+
+  llvm::sort(Info.Features, [this](StringRef LHS, StringRef RHS) {
+// Multiversioning doesn't allow "no-${feature}", so we can
+// only have "+" prefixes here.
+assert(LHS.starts_with("+") && RHS.starts_with("+") &&
+   "Features should always have a prefix.");
+return multiVersionSortPriority(LHS.substr(1)) >
+   multiVersionSortPriority(RHS.substr(1));
+   });
+
+   bool IsFirst = true;
+   if (!Info.CPU.empty()) {
+ IsFirst = false;
+ ManglingSuffix.append(Twine("arch_", Info.CPU).str());
+   }
+
+   for (StringRef Feat : Info.Features) {
+ if (!IsFirst)
+   ManglingSuffix.append("_");
+ IsFirst = false;
+ ManglingSuffix.append(Feat.substr(1).str());
+   }
+
+   return ManglingSuffix;
+}
+
 ParsedTargetAttr TargetInfo::parseTargetAttr(StringRef Features) const {
   ParsedTargetAttr Ret;
   if (Features == "default")
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c49461bd20eeec..d288c431a46207 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1105,6 +1105,33 @@ bool AArch64TargetInfo::initFeatureMap(
   return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
 }
 
+std::string AAr

[clang] [OpenACC][NFC] Implement basic OpenACC Sema infrastructure (PR #81874)

2024-02-15 Thread Erich Keane via cfe-commits

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


[clang] 24144d7 - [OpenACC][NFC] Implement basic OpenACC Sema infrastructure (#81874)

2024-02-15 Thread via cfe-commits

Author: Erich Keane
Date: 2024-02-15T10:10:05-08:00
New Revision: 24144d726fefefb0245eb1c2700606002355f4fe

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

LOG: [OpenACC][NFC] Implement basic OpenACC Sema infrastructure (#81874)

This patch is split off from #81659, and contains just the Sema
infrastructure that we can later use to implement semantic analysis of
OpenACC constructs.

Added: 
clang/lib/Sema/SemaOpenACC.cpp

Modified: 
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseOpenACC.cpp
clang/lib/Sema/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index da18cf88edcc92..69b9e837fe8bef 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3572,7 +3572,21 @@ class Parser : public CodeCompletionHandler {
   StmtResult ParseOpenACCDirectiveStmt();
 
 private:
-  void ParseOpenACCDirective();
+  /// A struct to hold the information that got parsed by 
ParseOpenACCDirective,
+  /// so that the callers of it can use that to construct the appropriate AST
+  /// nodes.
+  struct OpenACCDirectiveParseInfo {
+OpenACCDirectiveKind DirKind;
+SourceLocation StartLoc;
+SourceLocation EndLoc;
+// TODO OpenACC: Add Clause list here once we have a type for that.
+// TODO OpenACC: As we implement support for the Atomic, Routine, Cache, 
and
+// Wait constructs, we likely want to put that information in here as well.
+  };
+
+  /// Parses the OpenACC directive (the entire pragma) including the clause
+  /// list, but does not produce the main AST node.
+  OpenACCDirectiveParseInfo ParseOpenACCDirective();
   /// Helper that parses an ID Expression based on the language options.
   ExprResult ParseOpenACCIDExpression();
   /// Parses the variable list for the `cache` construct.

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 978949a9803ac8..53f06bcaeca166 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -41,6 +41,7 @@
 #include "clang/Basic/DarwinSDKInfo.h"
 #include "clang/Basic/ExpressionTraits.h"
 #include "clang/Basic/Module.h"
+#include "clang/Basic/OpenACCKinds.h"
 #include "clang/Basic/OpenCLOptions.h"
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/PragmaKinds.h"
@@ -12701,6 +12702,46 @@ class Sema final {
   OMPClause *ActOnOpenMPXBareClause(SourceLocation StartLoc,
 SourceLocation EndLoc);
 
+  
//======//
+  // OpenACC directives and clauses.
+
+  /// Called after parsing an OpenACC Clause so that it can be checked.
+  bool ActOnOpenACCClause(OpenACCClauseKind ClauseKind,
+  SourceLocation StartLoc);
+
+  /// Called after the construct has been parsed, but clauses haven't been
+  /// parsed.  This allows us to diagnose not-implemented, as well as set up 
any
+  /// state required for parsing the clauses.
+  void ActOnOpenACCConstruct(OpenACCDirectiveKind K, SourceLocation StartLoc);
+
+  /// Called after the directive, including its clauses, have been parsed and
+  /// parsing has consumed the 'annot_pragma_openacc_end' token. This DOES
+  /// happen before any associated declarations or statements have been parsed.
+  /// This function is only called when we are parsing a 'statement' context.
+  bool ActOnStartOpenACCStmtDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc);
+
+  /// Called after the directive, including its clauses, have been parsed and
+  /// parsing has consumed the 'annot_pragma_openacc_end' token. This DOES
+  /// happen before any associated declarations or statements have been parsed.
+  /// This function is only called when we are parsing a 'Decl' context.
+  bool ActOnStartOpenACCDeclDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc);
+  /// Called when we encounter an associated statement for our construct, this
+  /// should check legality of the statement as it appertains to this 
Construct.
+  StmtResult ActOnOpenACCAssociatedStmt(OpenACCDirectiveKind K,
+StmtResult AssocStmt);
+
+  /// Called after the directive has been completely parsed, including the
+  /// declaration group or associated statement.
+  StmtResult ActOnEndOpenACCStmtDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc,
+  SourceLocation EndLoc,
+  StmtResult AssocStmt);
+  /// Called after the directive has been completely parsed, inc

[clang-tools-extra] [clang-tidy] Fix handling of parentheses in bugprone-non-zero-enum-to-bool-conversion (PR #81890)

2024-02-15 Thread via cfe-commits

llvmbot wrote:




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

Author: Piotr Zegar (PiotrZSL)


Changes

Properly ignore parentheses in bitwise operators.

Closes #81515

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


3 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp 
(+1-1) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+5) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
 (+2) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
index 918b6e3824f0b1..e0323848870bd7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
@@ -64,7 +64,7 @@ void 
NonZeroEnumToBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
  EnumIgnoreList)))
 .bind("enum"),
 unless(declRefExpr(to(enumConstantDecl(,
-unless(ignoringImplicit(ExcludedOperators,
+unless(ignoringParenImpCasts(ExcludedOperators,
unless(hasAncestor(staticAssertDecl(
   .bind("cast"),
   this);
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a1b95d2a2020fe..2b714186c57d45 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -112,6 +112,11 @@ New check aliases
 Changes in existing checks
 ^^
 
+- Improved :doc:`bugprone-non-zero-enum-to-bool-conversion
+  ` check by
+  eliminating false positives resulting from direct usage of bitwise operators
+  within parentheses.
+
 - Improved :doc:`bugprone-suspicious-include
   ` check by replacing the local
   options `HeaderFileExtensions` and `ImplementationFileExtensions` by the
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
index 794e7b20c8ca53..3375f69b591119 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
@@ -122,6 +122,8 @@ CustomOperatorEnum operator&(CustomOperatorEnum a, 
CustomOperatorEnum b) { retur
 
 void testCustomOperator(CustomOperatorEnum e) {
 if (e & E1) {}
+if ((e & E1)) {}
+if (!(e & E1)) {}
 }
 
 }

``




https://github.com/llvm/llvm-project/pull/81890
___
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 handling of parentheses in bugprone-non-zero-enum-to-bool-conversion (PR #81890)

2024-02-15 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL created 
https://github.com/llvm/llvm-project/pull/81890

Properly ignore parentheses in bitwise operators.

Closes #81515

>From 3b8defafd16cd83e86c9922d7527217a470734a3 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Thu, 15 Feb 2024 17:53:49 +
Subject: [PATCH] [clang-tidy] Fix handling of parentheses in
 bugprone-non-zero-enum-to-bool-conversion

Properly ignore parentheses in bitwise operators.

Closes: #81515
---
 .../clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp | 2 +-
 clang-tools-extra/docs/ReleaseNotes.rst  | 5 +
 .../checkers/bugprone/non-zero-enum-to-bool-conversion.cpp   | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
index 918b6e3824f0b1..e0323848870bd7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
@@ -64,7 +64,7 @@ void 
NonZeroEnumToBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
  EnumIgnoreList)))
 .bind("enum"),
 unless(declRefExpr(to(enumConstantDecl(,
-unless(ignoringImplicit(ExcludedOperators,
+unless(ignoringParenImpCasts(ExcludedOperators,
unless(hasAncestor(staticAssertDecl(
   .bind("cast"),
   this);
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a1b95d2a2020fe..2b714186c57d45 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -112,6 +112,11 @@ New check aliases
 Changes in existing checks
 ^^
 
+- Improved :doc:`bugprone-non-zero-enum-to-bool-conversion
+  ` check by
+  eliminating false positives resulting from direct usage of bitwise operators
+  within parentheses.
+
 - Improved :doc:`bugprone-suspicious-include
   ` check by replacing the local
   options `HeaderFileExtensions` and `ImplementationFileExtensions` by the
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
index 794e7b20c8ca53..3375f69b591119 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
@@ -122,6 +122,8 @@ CustomOperatorEnum operator&(CustomOperatorEnum a, 
CustomOperatorEnum b) { retur
 
 void testCustomOperator(CustomOperatorEnum e) {
 if (e & E1) {}
+if ((e & E1)) {}
+if (!(e & E1)) {}
 }
 
 }

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


[clang] 8bda8cf - [clang][NFC] Fix buildbot failure in drs/23xx.cpp

2024-02-15 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-02-15T20:58:44+03:00
New Revision: 8bda8cfae6aa3c32cca7997ab64771e6a78f3e61

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

LOG: [clang][NFC] Fix buildbot failure in drs/23xx.cpp

This is a follow-up to 630548a11423a40c5496cec78001374bfb8ff741, which fixed 
builtbot failure https://lab.llvm.org/buildbot/#/builders/188/builds/41930

Added: 


Modified: 
clang/test/CXX/drs/dr23xx.cpp

Removed: 




diff  --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp
index ad941f606141c8..812d95a39b638d 100644
--- a/clang/test/CXX/drs/dr23xx.cpp
+++ b/clang/test/CXX/drs/dr23xx.cpp
@@ -186,7 +186,7 @@ namespace dr2358 { // dr2358: 16
 // CWG2363 was closed as NAD, but its resolution does affirm that
 // a friend declaration cannot have an opaque-enumm-specifier.
 namespace dr2363 { // dr2363: yes
-
+#if __cplusplus >= 201103L
 enum class E0;
 enum E1 : int;
 
@@ -214,6 +214,7 @@ struct A {
   // expected-error@-2 {{elaborated enum specifier cannot be declared as a 
friend}}
   // expected-note@-3 {{remove 'enum class' to befriend an enum}}
 };
+#endif
 } // namespace dr2363
 
 namespace dr2370 { // dr2370: no



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


[clang] Reapply "[Clang][Sema] Diagnose function/variable templates that shadow their own template parameters (#78274)" (PR #79683)

2024-02-15 Thread Krystian Stasiowski via cfe-commits


@@ -885,16 +885,19 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation 
PointOfInstantiation,
 /// that the template parameter 'PrevDecl' is being shadowed by a new
 /// declaration at location Loc. Returns true to indicate that this is
 /// an error, and false otherwise.
-void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) 
{
+void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl,
+   bool IssueWarning) {

sdkrystian wrote:

I applied the suggested changes, so this should be good to go once cor3ntin 
responds 

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


[clang] Reapply "[Clang][Sema] Diagnose function/variable templates that shadow their own template parameters (#78274)" (PR #79683)

2024-02-15 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/79683

>From 0d4a6d155b5d70970b63f4337507098ea938f627 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 16 Jan 2024 08:05:33 -0500
Subject: [PATCH] Reapply "[Clang][Sema] Diagnose function/variable templates
 that shadow their own template parameters (#78274)"

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ++
 clang/include/clang/Sema/Scope.h  |  7 
 clang/include/clang/Sema/Sema.h   | 16 -
 clang/lib/Sema/Scope.cpp  |  3 ++
 clang/lib/Sema/SemaDecl.cpp   | 31 +---
 clang/lib/Sema/SemaDeclCXX.cpp| 13 +++
 clang/lib/Sema/SemaTemplate.cpp   | 36 +--
 .../test/CXX/temp/temp.res/temp.local/p6.cpp  | 22 +---
 9 files changed, 88 insertions(+), 45 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9473867c1f231f..71654bc7bef345 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -42,6 +42,8 @@ C/C++ Language Potentially Breaking Changes
 
 C++ Specific Potentially Breaking Changes
 -
+- Clang now diagnoses function/variable templates that shadow their own 
template parameters, e.g. ``template void T();``.
+  This error can be disabled via `-Wno-strict-primary-template-shadow` for 
compatibility with previous versions of clang.
 
 ABI Changes in This Version
 ---
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1c0ebbe4e68343..e71218c390f722 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4966,6 +4966,9 @@ def err_template_param_shadow : Error<
   "declaration of %0 shadows template parameter">;
 def ext_template_param_shadow : ExtWarn<
   err_template_param_shadow.Summary>, InGroup;
+def ext_compat_template_param_shadow : ExtWarn<
+  err_template_param_shadow.Summary>, InGroup<
+  DiagGroup<"strict-primary-template-shadow">>, DefaultError;
 def note_template_param_here : Note<"template parameter is declared here">;
 def note_template_param_external : Note<
   "template parameter from hidden source: %0">;
diff --git a/clang/include/clang/Sema/Scope.h b/clang/include/clang/Sema/Scope.h
index 9e81706cd2aa1d..27c73b537a8636 100644
--- a/clang/include/clang/Sema/Scope.h
+++ b/clang/include/clang/Sema/Scope.h
@@ -200,6 +200,10 @@ class Scope {
   /// other template parameter scopes as parents.
   Scope *TemplateParamParent;
 
+  /// DeclScopeParent - This is a direct link to the immediately containing
+  /// DeclScope, i.e. scope which can contain declarations.
+  Scope *DeclParent;
+
   /// DeclsInScope - This keeps track of all declarations in this scope.  When
   /// the declaration is added to the scope, it is set as the current
   /// declaration for the identifier in the IdentifierTable.  When the scope is
@@ -299,6 +303,9 @@ class Scope {
   Scope *getTemplateParamParent() { return TemplateParamParent; }
   const Scope *getTemplateParamParent() const { return TemplateParamParent; }
 
+  Scope *getDeclParent() { return DeclParent; }
+  const Scope *getDeclParent() const { return DeclParent; }
+
   /// Returns the depth of this scope. The translation-unit has scope depth 0.
   unsigned getDepth() const { return Depth; }
 
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 59eab0185ae632..711e6f17440a65 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -8315,7 +8315,21 @@ class Sema final {
   TemplateSpecializationKind TSK,
   bool Complain = true);
 
-  void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
+  /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
+  /// that the template parameter 'PrevDecl' is being shadowed by a new
+  /// declaration at location Loc. Returns true to indicate that this is
+  /// an error, and false otherwise.
+  ///
+  /// \param Loc The location of the declaration that shadows a template
+  ///parameter.
+  ///
+  /// \param PrevDecl The template parameter that the declaration shadows.
+  ///
+  /// \param SupportedForCompatibility Whether to issue the diagnostic as
+  ///a warning for compatibility with older versions of clang.
+  ///Ignored when MSVC compatibility is enabled.
+  void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl,
+   bool SupportedForCompatibility = false);
   TemplateDecl *AdjustDeclIfTemplate(Decl *&Decl);
 
   NamedDecl *ActOnTypeParameter(Scope *S, bool Typename,
diff --git a/clang/lib/Sema/Scope.cpp b/clang/lib/Sema/Scope.cpp
index

[clang] [HLSL] Expose `half` types and intrinsics always (PR #81782)

2024-02-15 Thread Justin Bogner via cfe-commits

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


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


[clang] [HLSL] Expose `half` types and intrinsics always (PR #81782)

2024-02-15 Thread Chris B via cfe-commits


@@ -42,20 +49,20 @@ int16_t3 abs(int16_t3);
 _HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
 int16_t4 abs(int16_t4);
+#endif
 
-_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)

llvm-beanz wrote:

This is complicated. `half` is a valid type regardless of whether or not 16bit 
types are enabled, and `half` is a _distinctly different_ type when 16-bit 
types are enabled. What this does is put the availability annotation on the 
16-bit `half` type's overloads, but not the 32-bit `half` type's overloads.

That way if you're writing a shader for SM 6.0, using 32-bit `half` you get 
don't get blocked by the SM 6.2 availability annotation.

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=c23 -std=c23 %s -Wpre-c2x-compat
+// RUN: %clang_cc1 -fsyntax-only -verify=c17 -std=c17 %s
+
+

AaronBallman wrote:

```suggestion

```

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -1382,6 +1382,20 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy 
&Policy) {
   ThreadStorageClassSpec = TSCS_unspecified;
   ThreadStorageClassSpecLoc = SourceLocation();
 }
+if (S.getLangOpts().C23 &&
+getConstexprSpecifier() == ConstexprSpecKind::Constexpr) {
+  S.Diag(ConstexprLoc, diag::err_invalid_decl_spec_combination)
+  << DeclSpec::getSpecifierName(getThreadStorageClassSpec())
+  << SourceRange(getThreadStorageClassSpecLoc());
+}
+  }
+
+  if (S.getLangOpts().C23 &&

AaronBallman wrote:

I think we need something similar here for mixing `typedef` and `constexpr`. A 
potential test case would be:
```
typedef constexpr int Foo;
constexpr typedef int Bar;
```

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -8569,6 +8571,37 @@ static bool checkForConflictWithNonVisibleExternC(Sema 
&S, const T *ND,
   return false;
 }
 
+static bool CheckC23ConstexprVarType(Sema &SemaRef, SourceLocation VarLoc,
+ QualType T) {
+
+  if (T->isVariableArrayType()) {
+SemaRef.Diag(VarLoc, diag::err_c23_constexpr_invalid_type) << T;
+return true;
+  }
+
+  // Arrays are qualified by their element type, so get the base type (this
+  // works on non-arrays as well).
+  T = SemaRef.Context.getBaseElementType(T);
+
+  // C23 6.7.1p4: An object declared with storage-class specifier constexpr or
+  // any of its members, even recursively, shall not have an atomic type, or a
+  // variably modified type, or a type that is volatile or restrict qualified.
+  if (T->isAtomicType() || T.isVolatileQualified() || T.isRestrictQualified()) 
{
+SemaRef.Diag(VarLoc, diag::err_c23_constexpr_invalid_type) << T;
+return true;
+  }
+
+  if (T->isRecordType()) {
+const RecordDecl *RD = T->getAsRecordDecl();
+if (llvm::any_of(RD->fields(), [&SemaRef, VarLoc](const FieldDecl *F) {
+  return CheckC23ConstexprVarType(SemaRef, VarLoc, F->getType());
+}))
+  return true;
+  }

AaronBallman wrote:

Test case to consider involving indirect fields:
```
struct S {
  union {
volatile int i;
  };
  int j;
};

constexpr struct S s = {}; // Error
```
https://godbolt.org/z/rE15hqGxa

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,296 @@
+// RUN: %clang_cc1 -std=c2x -verify -triple x86_64 -pedantic -Wno-conversion 
-Wno-constant-conversion -Wno-div-by-zero %s
+
+// Check that constexpr only applies to variables.
+constexpr void f0() {} // expected-error {{'constexpr' can only be used in 
variable declarations}}
+constexpr const int f1() { return 0; } // expected-error {{'constexpr' can 
only be used in variable declarations}}
+
+constexpr struct S1 { int f; }; //expected-error {{struct cannot be marked 
constexpr}}
+constexpr struct S2 ; // expected-error {{struct cannot be marked constexpr}}
+constexpr union U1; // expected-error {{union cannot be marked constexpr}}
+constexpr union U2 {int a; float b;}; // expected-error {{union cannot be 
marked constexpr}}
+constexpr enum E1 {A = 1, B = 2} ; // expected-error {{enum cannot be marked 
constexpr}}
+struct S3 {
+  static constexpr int f = 0; // expected-error {{type name does not allow 
storage class}}
+  // expected-error@-1 {{type name does not allow constexpr}}
+  // expected-error@-2 {{expected ';' at end}}
+  constexpr int f1 = 0;
+  // expected-error@-1 {{type name does not allow constexpr}}
+  // expected-error@-2 {{expected ';' at end}}
+};
+
+constexpr; // expected-error {{'constexpr' can only be used in variable 
declarations}}
+constexpr int V1 = 3;
+constexpr float V2 = 7.0;
+int V3 = (constexpr)3; // expected-error {{expected expression}}
+
+void f2() {
+  constexpr int a = 0;
+  constexpr float b = 1.7f;
+}
+
+// Check how constexpr works with other storage-class specifiers.
+constexpr auto V4 = 1;
+constexpr static auto V5 = 1;
+constexpr static const auto V6 = 1;
+constexpr static const int V7 = 1;
+constexpr static int V8 = 1;
+constexpr auto Ulong = 1L;
+constexpr auto CompoundLiteral = (int){13};
+constexpr auto DoubleCast = (double)(1 / 3);
+constexpr auto String = "this is a string";
+constexpr signed auto Long = 1L; // expected-error {{'auto' cannot be signed 
or unsigned}}
+_Static_assert(_Generic(Ulong, long : 1));
+_Static_assert(_Generic(CompoundLiteral, int : 1));
+_Static_assert(_Generic(DoubleCast, double : 1));
+_Static_assert(_Generic(String, char* : 1));
+
+void f3(constexpr register int P1) { // expected-error {{function parameter 
cannot be constexpr}}
+  constexpr register int V9 = 0;
+  constexpr register auto V10 = 0.0;
+}
+
+constexpr thread_local int V11 = 38; // expected-error {{cannot combine with 
previous '_Thread_local' declaration specifier}}
+constexpr static thread_local double V12 = 38; // expected-error {{cannot 
combine with previous '_Thread_local' declaration specifier}}
+constexpr extern thread_local char V13; // expected-error {{cannot combine 
with previous '_Thread_local' declaration specifier}}
+// expected-error@-1 {{cannot combine with previous 'extern' declaration 
specifier}}
+// expected-error@-2 {{constexpr variable declaration must be a definition}}
+constexpr thread_local short V14 = 38; // expected-error {{cannot combine with 
previous '_Thread_local' declaration specifier}}
+
+// Check how constexpr works with qualifiers.
+constexpr _Atomic int V15 = 0; // expected-error {{constexpr variable cannot 
have type 'const _Atomic(int)'}}
+constexpr _Atomic(int) V16 = 0; // expected-error {{constexpr variable cannot 
have type 'const _Atomic(int)'}}
+
+constexpr volatile int V17 = 0; // expected-error {{constexpr variable cannot 
have type 'const volatile int'}}
+
+constexpr int * restrict V18 = 0; // expected-error {{constexpr variable 
cannot have type 'int *const restrict'}}

AaronBallman wrote:

Another test case to consider adding: `constexpr int * restrict * Foo = 0; // 
Accepted`

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -13823,7 +13869,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
   VDecl->setStorageClass(SC_Extern);
 
 // C99 6.7.8p4. All file scoped initializers need to be constant.
-if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl())
+// Avoid double diagnoses for constexpr variables.

AaronBallman wrote:

```suggestion
// Avoid duplicate diagnostics for constexpr variables.
```

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -8569,6 +8571,37 @@ static bool checkForConflictWithNonVisibleExternC(Sema 
&S, const T *ND,
   return false;
 }
 
+static bool CheckC23ConstexprVarType(Sema &SemaRef, SourceLocation VarLoc,
+ QualType T) {
+
+  if (T->isVariableArrayType()) {
+SemaRef.Diag(VarLoc, diag::err_c23_constexpr_invalid_type) << T;
+return true;
+  }
+
+  // Arrays are qualified by their element type, so get the base type (this
+  // works on non-arrays as well).
+  T = SemaRef.Context.getBaseElementType(T);
+
+  // C23 6.7.1p4: An object declared with storage-class specifier constexpr or

AaronBallman wrote:

```suggestion
  // C23 6.7.1p5: An object declared with storage-class specifier constexpr or
```

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -std=c2x -verify -triple x86_64 -pedantic -Wno-conversion 
-Wno-constant-conversion %s

AaronBallman wrote:

```suggestion
// RUN: %clang_cc1 -std=c23 -verify -triple x86_64 -pedantic -Wno-conversion 
-Wno-constant-conversion %s
```

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,296 @@
+// RUN: %clang_cc1 -std=c2x -verify -triple x86_64 -pedantic -Wno-conversion 
-Wno-constant-conversion -Wno-div-by-zero %s
+
+// Check that constexpr only applies to variables.
+constexpr void f0() {} // expected-error {{'constexpr' can only be used in 
variable declarations}}
+constexpr const int f1() { return 0; } // expected-error {{'constexpr' can 
only be used in variable declarations}}
+
+constexpr struct S1 { int f; }; //expected-error {{struct cannot be marked 
constexpr}}
+constexpr struct S2 ; // expected-error {{struct cannot be marked constexpr}}
+constexpr union U1; // expected-error {{union cannot be marked constexpr}}
+constexpr union U2 {int a; float b;}; // expected-error {{union cannot be 
marked constexpr}}
+constexpr enum E1 {A = 1, B = 2} ; // expected-error {{enum cannot be marked 
constexpr}}
+struct S3 {
+  static constexpr int f = 0; // expected-error {{type name does not allow 
storage class}}
+  // expected-error@-1 {{type name does not allow constexpr}}
+  // expected-error@-2 {{expected ';' at end}}
+  constexpr int f1 = 0;
+  // expected-error@-1 {{type name does not allow constexpr}}
+  // expected-error@-2 {{expected ';' at end}}
+};
+
+constexpr; // expected-error {{'constexpr' can only be used in variable 
declarations}}
+constexpr int V1 = 3;
+constexpr float V2 = 7.0;
+int V3 = (constexpr)3; // expected-error {{expected expression}}
+
+void f2() {
+  constexpr int a = 0;
+  constexpr float b = 1.7f;
+}
+
+// Check how constexpr works with other storage-class specifiers.
+constexpr auto V4 = 1;
+constexpr static auto V5 = 1;
+constexpr static const auto V6 = 1;
+constexpr static const int V7 = 1;
+constexpr static int V8 = 1;
+constexpr auto Ulong = 1L;
+constexpr auto CompoundLiteral = (int){13};
+constexpr auto DoubleCast = (double)(1 / 3);
+constexpr auto String = "this is a string";

AaronBallman wrote:

This should be diagnosed as an error because it's a pointer declaration and the 
initializer is not a null pointer value.

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -2487,14 +2487,19 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
   if (!getType().isConstant(C) || getType().isVolatileQualified())
 return false;
 
-  // In C++, const, non-volatile variables of integral or enumeration types
-  // can be used in constant expressions.
-  if (getType()->isIntegralOrEnumerationType())
+  // In C++, but not in C, const, non-volatile variables of integral or
+  // enumeration types can be used in constant expressions.
+  if (getType()->isIntegralOrEnumerationType() && !Lang.C23)

AaronBallman wrote:

We might want to relax this in the future because we *do* allow const, 
non-volatile integer variables in constant expressions in C: 
https://godbolt.org/z/jc1h49Wox

But I think the code is fine for now because I think the function is not 
accurate in other ways:
```
  // Function parameters are never usable in constant expressions.
  if (isa(this))
return false;
```
which is not quite the case: https://godbolt.org/z/Kdq9xY617 and yet is the 
case: https://godbolt.org/z/1zEGsbYfn

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -9237,6 +9282,22 @@ static FunctionDecl *CreateNewFunctionDecl(Sema 
&SemaRef, Declarator &D,
   FunctionDecl *NewFD = nullptr;
   bool isInline = D.getDeclSpec().isInlineSpecified();
 
+  ConstexprSpecKind ConstexprKind = D.getDeclSpec().getConstexprSpecifier();
+  if (ConstexprKind == ConstexprSpecKind::Constinit ||
+  (SemaRef.getLangOpts().C23 &&
+   ConstexprKind == ConstexprSpecKind::Constexpr)) {
+
+if (SemaRef.getLangOpts().C23)
+  SemaRef.Diag(D.getDeclSpec().getConstexprSpecLoc(),
+   diag::err_c23_constexpr_not_variable);

AaronBallman wrote:

> > Hmmm, I'm not certain we need to change anything here
> 
> Well, without that move for C we silently create `FunctionDecl` and exit 
> whether it has `constexpr` specifier or not.
> 
> > it would be more clear to say that a function cannot be constexpr in C 
> > instead of saying you declared something constexpr that isn't a variable. 
> > WDYT?
> 
> I don't seem to have a problem with this particular message, for C++ similar 
> invalid use cases clang says and does the same. But If that will help users, 
> ok. I also use `err_c23_constexpr_not_variable` message when diagnosing 
> constexpr applied to a type declaration. Should I add more specific message 
> for this case as well?

Sorry, I meant that your changes here might be fine as-is, not that no changes 
were needed here.

> I also use `err_c23_constexpr_not_variable` message when diagnosing constexpr 
> applied to a type declaration. Should I add more specific message for this 
> case as well?

I'm thinking more that we should use `err_constexpr_wrong_decl_kind` in C as 
well (I had suggested that above). But perhaps that's painful because of 
`consteval` and `constinit` support in C++, so maybe it's best to ignore that 
suggestion here and above...

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


[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -1862,6 +1862,17 @@ class StringLiteral final
 llvm_unreachable("Unsupported character width!");
   }
 
+  // Get code unit but preserve sign info.
+  int64_t getCodeUnitS(size_t I, uint64_t BitWidth) const {

AaronBallman wrote:

CC @cor3ntin @tahonermann for opinions on everything related to the word 
combination "code unit" ;-)

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


[clang] [alpha.webkit.UncountedCallArgsChecker] Detect & ignore trivial function calls. (PR #81808)

2024-02-15 Thread via cfe-commits

dyung wrote:

@rniwa the test you modified in this change seems to be failing on at least one 
bot. Can you take a look or revert if you need time to investigate?

https://lab.llvm.org/buildbot/#/builders/123/builds/25095

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


[clang] Reapply "[Clang][Sema] Diagnose function/variable templates that shadow their own template parameters (#78274)" (PR #79683)

2024-02-15 Thread Aaron Ballman via cfe-commits


@@ -885,16 +885,19 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation 
PointOfInstantiation,
 /// that the template parameter 'PrevDecl' is being shadowed by a new
 /// declaration at location Loc. Returns true to indicate that this is
 /// an error, and false otherwise.
-void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) 
{
+void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl,
+   bool IssueWarning) {

AaronBallman wrote:

> @AaronBallman In VS20222 the javadocs show up even when they are attached to 
> the definition... but I'll move them to the declaration to be on the safe 
> side :)

For me, that only happens if the definition is in the same TU as the use. When 
I tried outside of SemaTemplate.cpp (such as the uses in SemaDecl.cpp), no docs 
appeared in the tooltip.

> While I mostly agree with changing the name to SupportedAsExtension, I don't 
> think the change to the diagnostic selection logic is quite right. When MSVC 
> compatibility is enabled, template parameter shadowing is always allowed 
> (read: there are no cases where shadowing would be an error with MSVC 
> compatibility enabled), so we should issue the MSVC specific diagnostic 
> regardless of SupportedAsExtension.

Good point!

> Perhaps we name it SupportedForCompatibility instead?

I could be okay with that; @cor3ntin WDYT?

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


[clang] [OpenACC][NFC] Implement basic OpenACC Sema infrastructure (PR #81874)

2024-02-15 Thread Erich Keane via cfe-commits

https://github.com/erichkeane updated 
https://github.com/llvm/llvm-project/pull/81874

>From 35700522a658571e2abad279f327f4160fdb6c9d Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Thu, 15 Feb 2024 08:41:58 -0800
Subject: [PATCH 1/3] [OpenACC][NFC] Implement basic OpenACC Sema
 infrastructure

This patch is split off from #81659, and contains just the Sema
infrastructure that we can later use to implement semantic analysis of
OpenACC constructs.
---
 clang/include/clang/Parse/Parser.h | 16 +-
 clang/include/clang/Sema/Sema.h| 41 ++
 clang/lib/Parse/ParseOpenACC.cpp   | 47 +-
 clang/lib/Sema/CMakeLists.txt  |  1 +
 clang/lib/Sema/SemaOpenACC.cpp | 47 ++
 5 files changed, 143 insertions(+), 9 deletions(-)
 create mode 100644 clang/lib/Sema/SemaOpenACC.cpp

diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index da18cf88edcc92..69b9e837fe8bef 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3572,7 +3572,21 @@ class Parser : public CodeCompletionHandler {
   StmtResult ParseOpenACCDirectiveStmt();
 
 private:
-  void ParseOpenACCDirective();
+  /// A struct to hold the information that got parsed by 
ParseOpenACCDirective,
+  /// so that the callers of it can use that to construct the appropriate AST
+  /// nodes.
+  struct OpenACCDirectiveParseInfo {
+OpenACCDirectiveKind DirKind;
+SourceLocation StartLoc;
+SourceLocation EndLoc;
+// TODO OpenACC: Add Clause list here once we have a type for that.
+// TODO OpenACC: As we implement support for the Atomic, Routine, Cache, 
and
+// Wait constructs, we likely want to put that information in here as well.
+  };
+
+  /// Parses the OpenACC directive (the entire pragma) including the clause
+  /// list, but does not produce the main AST node.
+  OpenACCDirectiveParseInfo ParseOpenACCDirective();
   /// Helper that parses an ID Expression based on the language options.
   ExprResult ParseOpenACCIDExpression();
   /// Parses the variable list for the `cache` construct.
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ed933f27f8df6b..ec4c451c584612 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -41,6 +41,7 @@
 #include "clang/Basic/DarwinSDKInfo.h"
 #include "clang/Basic/ExpressionTraits.h"
 #include "clang/Basic/Module.h"
+#include "clang/Basic/OpenACCKinds.h"
 #include "clang/Basic/OpenCLOptions.h"
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/PragmaKinds.h"
@@ -12704,6 +12705,46 @@ class Sema final {
   OMPClause *ActOnOpenMPXBareClause(SourceLocation StartLoc,
 SourceLocation EndLoc);
 
+  
//======//
+  // OpenACC directives and clauses.
+
+  /// Called after parsing an OpenACC Clause so that it can be checked.
+  bool ActOnOpenACCClause(OpenACCClauseKind ClauseKind,
+  SourceLocation StartLoc);
+
+  /// Called after the construct has been parsed, but clauses haven't been
+  /// parsed.  This allows us to diagnose not-implemented, as well as set up 
any
+  /// state required for parsing the clauses.
+  void ActOnOpenACCConstruct(OpenACCDirectiveKind K, SourceLocation StartLoc);
+
+  /// Called after the directive, including its clauses, have been parsed and
+  /// parsing has consumed the 'annot_pragma_openacc_end' token. This DOES
+  /// happen before any associated declarations or statements have been parsed.
+  /// This function is only called when we are parsing a 'statement' context.
+  bool ActOnStartOpenACCStmtDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc);
+
+  /// Called after the directive, including its clauses, have been parsed and
+  /// parsing has consumed the 'annot_pragma_openacc_end' token. This DOES
+  /// happen before any associated declarations or statements have been parsed.
+  /// This function is only called when we are parsing a 'Decl' context.
+  bool ActOnStartOpenACCDeclDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc);
+  /// Called when we encounter an associated statement for our construct, this
+  /// should check legality of the statement as it appertains to this 
Construct.
+  StmtResult ActOnOpenACCAssociatedStmt(OpenACCDirectiveKind K,
+StmtResult AssocStmt);
+
+  /// Called after the directive has been completely parsed, including the
+  /// declaration group or associated statement.
+  StmtResult ActOnEndOpenACCStmtDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc,
+  SourceLocation EndLoc,
+  StmtResult AssocStmt);
+  /// Called after the dir

[clang] [llvm] [MC/DC] Refactor: Make `MCDCParams` as `std::variant` (PR #81227)

2024-02-15 Thread via cfe-commits

LW-archlinux wrote:

Commit 75f0d40507ea3f7c99dd3250ff0fbe6dab341910 breaks build for a multilib 
32-bit clang build.

See https://github.com/llvm/llvm-project/issues/81880

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


[clang] [OpenACC][NFC] Implement basic OpenACC Sema infrastructure (PR #81874)

2024-02-15 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 46122082a61ef5bb2871d2d9158739133ad0e113 
2b4b7d8cbc02d44eb1c0302f9d92e42ef8d9aff4 -- clang/lib/Sema/SemaOpenACC.cpp 
clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h 
clang/lib/Parse/ParseOpenACC.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp
index a122880aa1..8157656246 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -1231,4 +1231,3 @@ StmtResult Parser::ParseOpenACCDirectiveStmt() {
   return getActions().ActOnEndOpenACCStmtDirective(
   DirInfo.DirKind, DirInfo.StartLoc, DirInfo.EndLoc, AssocStmt);
 }
-

``




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


[clang] [OpenACC][NFC] Implement basic OpenACC Sema infrastructure (PR #81874)

2024-02-15 Thread Erich Keane via cfe-commits

https://github.com/erichkeane updated 
https://github.com/llvm/llvm-project/pull/81874

>From 35700522a658571e2abad279f327f4160fdb6c9d Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Thu, 15 Feb 2024 08:41:58 -0800
Subject: [PATCH 1/2] [OpenACC][NFC] Implement basic OpenACC Sema
 infrastructure

This patch is split off from #81659, and contains just the Sema
infrastructure that we can later use to implement semantic analysis of
OpenACC constructs.
---
 clang/include/clang/Parse/Parser.h | 16 +-
 clang/include/clang/Sema/Sema.h| 41 ++
 clang/lib/Parse/ParseOpenACC.cpp   | 47 +-
 clang/lib/Sema/CMakeLists.txt  |  1 +
 clang/lib/Sema/SemaOpenACC.cpp | 47 ++
 5 files changed, 143 insertions(+), 9 deletions(-)
 create mode 100644 clang/lib/Sema/SemaOpenACC.cpp

diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index da18cf88edcc92..69b9e837fe8bef 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3572,7 +3572,21 @@ class Parser : public CodeCompletionHandler {
   StmtResult ParseOpenACCDirectiveStmt();
 
 private:
-  void ParseOpenACCDirective();
+  /// A struct to hold the information that got parsed by 
ParseOpenACCDirective,
+  /// so that the callers of it can use that to construct the appropriate AST
+  /// nodes.
+  struct OpenACCDirectiveParseInfo {
+OpenACCDirectiveKind DirKind;
+SourceLocation StartLoc;
+SourceLocation EndLoc;
+// TODO OpenACC: Add Clause list here once we have a type for that.
+// TODO OpenACC: As we implement support for the Atomic, Routine, Cache, 
and
+// Wait constructs, we likely want to put that information in here as well.
+  };
+
+  /// Parses the OpenACC directive (the entire pragma) including the clause
+  /// list, but does not produce the main AST node.
+  OpenACCDirectiveParseInfo ParseOpenACCDirective();
   /// Helper that parses an ID Expression based on the language options.
   ExprResult ParseOpenACCIDExpression();
   /// Parses the variable list for the `cache` construct.
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ed933f27f8df6b..ec4c451c584612 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -41,6 +41,7 @@
 #include "clang/Basic/DarwinSDKInfo.h"
 #include "clang/Basic/ExpressionTraits.h"
 #include "clang/Basic/Module.h"
+#include "clang/Basic/OpenACCKinds.h"
 #include "clang/Basic/OpenCLOptions.h"
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/PragmaKinds.h"
@@ -12704,6 +12705,46 @@ class Sema final {
   OMPClause *ActOnOpenMPXBareClause(SourceLocation StartLoc,
 SourceLocation EndLoc);
 
+  
//======//
+  // OpenACC directives and clauses.
+
+  /// Called after parsing an OpenACC Clause so that it can be checked.
+  bool ActOnOpenACCClause(OpenACCClauseKind ClauseKind,
+  SourceLocation StartLoc);
+
+  /// Called after the construct has been parsed, but clauses haven't been
+  /// parsed.  This allows us to diagnose not-implemented, as well as set up 
any
+  /// state required for parsing the clauses.
+  void ActOnOpenACCConstruct(OpenACCDirectiveKind K, SourceLocation StartLoc);
+
+  /// Called after the directive, including its clauses, have been parsed and
+  /// parsing has consumed the 'annot_pragma_openacc_end' token. This DOES
+  /// happen before any associated declarations or statements have been parsed.
+  /// This function is only called when we are parsing a 'statement' context.
+  bool ActOnStartOpenACCStmtDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc);
+
+  /// Called after the directive, including its clauses, have been parsed and
+  /// parsing has consumed the 'annot_pragma_openacc_end' token. This DOES
+  /// happen before any associated declarations or statements have been parsed.
+  /// This function is only called when we are parsing a 'Decl' context.
+  bool ActOnStartOpenACCDeclDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc);
+  /// Called when we encounter an associated statement for our construct, this
+  /// should check legality of the statement as it appertains to this 
Construct.
+  StmtResult ActOnOpenACCAssociatedStmt(OpenACCDirectiveKind K,
+StmtResult AssocStmt);
+
+  /// Called after the directive has been completely parsed, including the
+  /// declaration group or associated statement.
+  StmtResult ActOnEndOpenACCStmtDirective(OpenACCDirectiveKind K,
+  SourceLocation StartLoc,
+  SourceLocation EndLoc,
+  StmtResult AssocStmt);
+  /// Called after the dir

<    1   2   3   4   >