[clang] [RISCV] Disallow target attribute use in multiversioning (PR #85899)

2024-04-08 Thread Kito Cheng via cfe-commits

https://github.com/kito-cheng approved this pull request.

LGTM :)

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


[clang] [Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (PR #86526)

2024-04-08 Thread via cfe-commits

cor3ntin wrote:

I wanted to make you aware of this new core issue 
https://cplusplus.github.io/CWG/issues/2876.html (which i think we should have 
tests for). Thanks

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


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty (PR #87866)

2024-04-08 Thread YunQiang Su via cfe-commits

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


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


[clang] Clang: Return new layout path if cannot find CRT (PR #87319)

2024-04-08 Thread YunQiang Su via cfe-commits

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


[clang] Clang: Return new layout path if cannot find CRT (PR #87319)

2024-04-08 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Replaced by: https://github.com/llvm/llvm-project/issues/87150

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


[clang] [llvm] [RISCV] Zimop/Zcmop are ratified (PR #87966)

2024-04-08 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/87966

Remove them from experimental.

See also:
https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc


>From 5b312a80cdc3396e3e35d906176f56349392d437 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Mon, 8 Apr 2024 15:33:19 +0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 clang/test/Driver/riscv-profiles.c| 26 +++---
 .../test/Preprocessor/riscv-target-features.c | 36 +--
 llvm/docs/RISCVUsage.rst  |  6 
 llvm/lib/Support/RISCVISAInfo.cpp | 26 +++---
 llvm/lib/Target/RISCV/RISCVFeatures.td|  4 +--
 llvm/lib/Target/RISCV/RISCVInstrInfoZcmop.td  |  2 --
 llvm/lib/Target/RISCV/RISCVInstrInfoZimop.td  |  2 --
 llvm/test/CodeGen/RISCV/attributes.ll | 16 -
 .../test/CodeGen/RISCV/rv32zimop-intrinsic.ll |  2 +-
 .../test/CodeGen/RISCV/rv64zimop-intrinsic.ll |  2 +-
 llvm/test/MC/RISCV/attribute-arch.s   |  2 +-
 llvm/test/MC/RISCV/compressed-zicfiss.s   | 12 +++
 llvm/test/MC/RISCV/rv32zcmop-invalid.s|  2 +-
 llvm/test/MC/RISCV/rv32zimop-invalid.s|  2 +-
 llvm/test/MC/RISCV/rvzcmop-valid.s| 12 +++
 llvm/test/MC/RISCV/rvzimop-valid.s| 12 +++
 llvm/unittests/Support/RISCVISAInfoTest.cpp   |  4 +--
 17 files changed, 78 insertions(+), 90 deletions(-)

diff --git a/clang/test/Driver/riscv-profiles.c 
b/clang/test/Driver/riscv-profiles.c
index ec9206f2f45370..647567d4c971f4 100644
--- a/clang/test/Driver/riscv-profiles.c
+++ b/clang/test/Driver/riscv-profiles.c
@@ -111,7 +111,7 @@
 // RVA22S64: "-target-feature" "+svinval"
 // RVA22S64: "-target-feature" "+svpbmt"
 
-// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva23u64 
-menable-experimental-extensions \
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva23u64 \
 // RUN:   | FileCheck -check-prefix=RVA23U64 %s
 // RVA23U64: "-target-feature" "+m"
 // RVA23U64: "-target-feature" "+a"
@@ -133,13 +133,13 @@
 // RVA23U64: "-target-feature" "+zihintntl"
 // RVA23U64: "-target-feature" "+zihintpause"
 // RVA23U64: "-target-feature" "+zihpm"
-// RVA23U64: "-target-feature" "+experimental-zimop"
+// RVA23U64: "-target-feature" "+zimop"
 // RVA23U64: "-target-feature" "+za64rs"
 // RVA23U64: "-target-feature" "+zawrs"
 // RVA23U64: "-target-feature" "+zfa"
 // RVA23U64: "-target-feature" "+zfhmin"
 // RVA23U64: "-target-feature" "+zcb"
-// RVA23U64: "-target-feature" "+experimental-zcmop"
+// RVA23U64: "-target-feature" "+zcmop"
 // RVA23U64: "-target-feature" "+zba"
 // RVA23U64: "-target-feature" "+zbb"
 // RVA23U64: "-target-feature" "+zbs"
@@ -172,13 +172,13 @@
 // RVA23S64: "-target-feature" "+zihintntl"
 // RVA23S64: "-target-feature" "+zihintpause"
 // RVA23S64: "-target-feature" "+zihpm"
-// RVA23S64: "-target-feature" "+experimental-zimop"
+// RVA23S64: "-target-feature" "+zimop"
 // RVA23S64: "-target-feature" "+za64rs"
 // RVA23S64: "-target-feature" "+zawrs"
 // RVA23S64: "-target-feature" "+zfa"
 // RVA23S64: "-target-feature" "+zfhmin"
 // RVA23S64: "-target-feature" "+zcb"
-// RVA23S64: "-target-feature" "+experimental-zcmop"
+// RVA23S64: "-target-feature" "+zcmop"
 // RVA23S64: "-target-feature" "+zba"
 // RVA23S64: "-target-feature" "+zbb"
 // RVA23S64: "-target-feature" "+zbs"
@@ -207,7 +207,7 @@
 // RVA23S64: "-target-feature" "+svnapot"
 // RVA23S64: "-target-feature" "+svpbmt"
 
-// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvb23u64 
-menable-experimental-extensions \
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvb23u64 \
 // RUN:   | FileCheck -check-prefix=RVB23U64 %s
 // RVB23U64: "-target-feature" "+m"
 // RVB23U64: "-target-feature" "+a"
@@ -228,12 +228,12 @@
 // RVB23U64: "-target-feature" "+zihintntl"
 // RVB23U64: "-target-feature" "+zihintpause"
 // RVB23U64: "-target-feature" "+zihpm"
-// RVB23U64: "-target-feature" "+experimental-zimop"
+// RVB23U64: "-target-feature" "+zimop"
 // RVB23U64: "-target-feature" "+za64rs"
 // RVB23U64: "-target-feature" "+zawrs"
 // RVB23U64: "-target-feature" "+zfa"
 // RVB23U64: "-target-feature" "+zcb"
-// RVB23U64: "-target-feature" "+experimental-zcmop"
+// RVB23U64: "-target-feature" "+zcmop"
 // RVB23U64: "-target-feature" "+zba"
 // RVB23U64: "-target-feature" "+zbb"
 // RVB23U64: "-target-feature" "+zbs"
@@ -261,12 +261,12 @@
 // RVB23S64: "-target-feature" "+zihintntl"
 // RVB23S64: "-target-feature" "+zihintpause"
 // RVB23S64: "-target-feature" "+zihpm"
-// RVB23S64: "-target-feature" "+experimental-zimop"
+// RVB23S64: "-target-feature" "+zimop"
 // RVB23S64: "-target-feature" "+za64rs"
 // RVB23S64: "-target-feature" "+zawrs"
 // RVB23S64: "-target-feature" "+zfa"
 // RVB23S64: "-target-feature" "+zcb"
-// RVB23S64:

[clang] [llvm] [RISCV] Zimop/Zcmop are ratified (PR #87966)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Pengcheng Wang (wangpc-pp)


Changes

Remove them from experimental.

See also:
https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc


---

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


17 Files Affected:

- (modified) clang/test/Driver/riscv-profiles.c (+13-13) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+18-18) 
- (modified) llvm/docs/RISCVUsage.rst (-6) 
- (modified) llvm/lib/Support/RISCVISAInfo.cpp (+12-14) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+2-2) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZcmop.td (-2) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZimop.td (-2) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+8-8) 
- (modified) llvm/test/CodeGen/RISCV/rv32zimop-intrinsic.ll (+1-1) 
- (modified) llvm/test/CodeGen/RISCV/rv64zimop-intrinsic.ll (+1-1) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+1-1) 
- (modified) llvm/test/MC/RISCV/compressed-zicfiss.s (+6-6) 
- (modified) llvm/test/MC/RISCV/rv32zcmop-invalid.s (+1-1) 
- (modified) llvm/test/MC/RISCV/rv32zimop-invalid.s (+1-1) 
- (modified) llvm/test/MC/RISCV/rvzcmop-valid.s (+6-6) 
- (modified) llvm/test/MC/RISCV/rvzimop-valid.s (+6-6) 
- (modified) llvm/unittests/Support/RISCVISAInfoTest.cpp (+2-2) 


``diff
diff --git a/clang/test/Driver/riscv-profiles.c 
b/clang/test/Driver/riscv-profiles.c
index ec9206f2f45370..647567d4c971f4 100644
--- a/clang/test/Driver/riscv-profiles.c
+++ b/clang/test/Driver/riscv-profiles.c
@@ -111,7 +111,7 @@
 // RVA22S64: "-target-feature" "+svinval"
 // RVA22S64: "-target-feature" "+svpbmt"
 
-// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva23u64 
-menable-experimental-extensions \
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva23u64 \
 // RUN:   | FileCheck -check-prefix=RVA23U64 %s
 // RVA23U64: "-target-feature" "+m"
 // RVA23U64: "-target-feature" "+a"
@@ -133,13 +133,13 @@
 // RVA23U64: "-target-feature" "+zihintntl"
 // RVA23U64: "-target-feature" "+zihintpause"
 // RVA23U64: "-target-feature" "+zihpm"
-// RVA23U64: "-target-feature" "+experimental-zimop"
+// RVA23U64: "-target-feature" "+zimop"
 // RVA23U64: "-target-feature" "+za64rs"
 // RVA23U64: "-target-feature" "+zawrs"
 // RVA23U64: "-target-feature" "+zfa"
 // RVA23U64: "-target-feature" "+zfhmin"
 // RVA23U64: "-target-feature" "+zcb"
-// RVA23U64: "-target-feature" "+experimental-zcmop"
+// RVA23U64: "-target-feature" "+zcmop"
 // RVA23U64: "-target-feature" "+zba"
 // RVA23U64: "-target-feature" "+zbb"
 // RVA23U64: "-target-feature" "+zbs"
@@ -172,13 +172,13 @@
 // RVA23S64: "-target-feature" "+zihintntl"
 // RVA23S64: "-target-feature" "+zihintpause"
 // RVA23S64: "-target-feature" "+zihpm"
-// RVA23S64: "-target-feature" "+experimental-zimop"
+// RVA23S64: "-target-feature" "+zimop"
 // RVA23S64: "-target-feature" "+za64rs"
 // RVA23S64: "-target-feature" "+zawrs"
 // RVA23S64: "-target-feature" "+zfa"
 // RVA23S64: "-target-feature" "+zfhmin"
 // RVA23S64: "-target-feature" "+zcb"
-// RVA23S64: "-target-feature" "+experimental-zcmop"
+// RVA23S64: "-target-feature" "+zcmop"
 // RVA23S64: "-target-feature" "+zba"
 // RVA23S64: "-target-feature" "+zbb"
 // RVA23S64: "-target-feature" "+zbs"
@@ -207,7 +207,7 @@
 // RVA23S64: "-target-feature" "+svnapot"
 // RVA23S64: "-target-feature" "+svpbmt"
 
-// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvb23u64 
-menable-experimental-extensions \
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvb23u64 \
 // RUN:   | FileCheck -check-prefix=RVB23U64 %s
 // RVB23U64: "-target-feature" "+m"
 // RVB23U64: "-target-feature" "+a"
@@ -228,12 +228,12 @@
 // RVB23U64: "-target-feature" "+zihintntl"
 // RVB23U64: "-target-feature" "+zihintpause"
 // RVB23U64: "-target-feature" "+zihpm"
-// RVB23U64: "-target-feature" "+experimental-zimop"
+// RVB23U64: "-target-feature" "+zimop"
 // RVB23U64: "-target-feature" "+za64rs"
 // RVB23U64: "-target-feature" "+zawrs"
 // RVB23U64: "-target-feature" "+zfa"
 // RVB23U64: "-target-feature" "+zcb"
-// RVB23U64: "-target-feature" "+experimental-zcmop"
+// RVB23U64: "-target-feature" "+zcmop"
 // RVB23U64: "-target-feature" "+zba"
 // RVB23U64: "-target-feature" "+zbb"
 // RVB23U64: "-target-feature" "+zbs"
@@ -261,12 +261,12 @@
 // RVB23S64: "-target-feature" "+zihintntl"
 // RVB23S64: "-target-feature" "+zihintpause"
 // RVB23S64: "-target-feature" "+zihpm"
-// RVB23S64: "-target-feature" "+experimental-zimop"
+// RVB23S64: "-target-feature" "+zimop"
 // RVB23S64: "-target-feature" "+za64rs"
 // RVB23S64: "-target-feature" "+zawrs"
 // RVB23S64: "-target-feature" "+zfa"
 // RVB23S64: "-target-feature" "+zcb"
-// RVB23S64: "-target-feature" "+experimental-zcmop"
+// RVB23S64: "-target-feature" "+zcmop"
 // RVB23S64: "-target-feature" "+zba"
 // RVB23S64: "-target-feature" "+zbb"
 // RVB23S64: "-target-feature" "+zbs"
@@ -284,7 +284,7 @@

[clang] [llvm] [RISCV] Zimop/Zcmop are ratified (PR #87966)

2024-04-08 Thread Kito Cheng via cfe-commits

https://github.com/kito-cheng approved this pull request.

LGTM :)

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


[clang] [clang] Add tests for some CWG 5xx issues (PR #87909)

2024-04-08 Thread via cfe-commits


@@ -265,6 +269,18 @@ namespace dr527 { // dr527: na
   int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x;
 }
 
+namespace dr528 { // dr528: 2.7

cor3ntin wrote:

This is NAD, should we not say that?

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


[clang] [clang] Add tests for some CWG 5xx issues (PR #87909)

2024-04-08 Thread via cfe-commits


@@ -1568,6 +1568,18 @@ namespace dr391 { // dr391: 2.8 c++11
 }
 
 // dr392 is in dr392.cpp
+
+namespace dr393 { // dr393: 2.7
+
+template 
+struct S {};
+
+void f1(S);
+void f2(S);
+void g(int(*S::*)[]);

cor3ntin wrote:

Can you add the January 2013 examples ? (both valid and invalid)

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


[clang] [clang] Add tests for some CWG 5xx issues (PR #87909)

2024-04-08 Thread via cfe-commits


@@ -661,6 +680,10 @@ namespace dr553 {
 }
 
 // dr554: na
+
+// dr555: na

cor3ntin wrote:

It might be worth copying these tests.
I agree that the changes are non-behavioral but I'd like @AaronBallman to give 
a second opinion

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


[clang] 364028a - [RISCV] Zimop/Zcmop are ratified

2024-04-08 Thread via cfe-commits

Author: Pengcheng Wang
Date: 2024-04-08T16:40:02+08:00
New Revision: 364028a1a51689d2b33d3ec50c426fbeac269679

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

LOG: [RISCV] Zimop/Zcmop are ratified

Remove them from experimental.

See also:
https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc

Reviewers: kito-cheng

Reviewed By: kito-cheng

Pull Request: https://github.com/llvm/llvm-project/pull/87966

Added: 


Modified: 
clang/test/Driver/riscv-profiles.c
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/lib/Target/RISCV/RISCVInstrInfoZcmop.td
llvm/lib/Target/RISCV/RISCVInstrInfoZimop.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/CodeGen/RISCV/rv32zimop-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zimop-intrinsic.ll
llvm/test/MC/RISCV/attribute-arch.s
llvm/test/MC/RISCV/compressed-zicfiss.s
llvm/test/MC/RISCV/rv32zcmop-invalid.s
llvm/test/MC/RISCV/rv32zimop-invalid.s
llvm/test/MC/RISCV/rvzcmop-valid.s
llvm/test/MC/RISCV/rvzimop-valid.s
llvm/unittests/Support/RISCVISAInfoTest.cpp

Removed: 




diff  --git a/clang/test/Driver/riscv-profiles.c 
b/clang/test/Driver/riscv-profiles.c
index ec9206f2f45370..647567d4c971f4 100644
--- a/clang/test/Driver/riscv-profiles.c
+++ b/clang/test/Driver/riscv-profiles.c
@@ -111,7 +111,7 @@
 // RVA22S64: "-target-feature" "+svinval"
 // RVA22S64: "-target-feature" "+svpbmt"
 
-// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva23u64 
-menable-experimental-extensions \
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva23u64 \
 // RUN:   | FileCheck -check-prefix=RVA23U64 %s
 // RVA23U64: "-target-feature" "+m"
 // RVA23U64: "-target-feature" "+a"
@@ -133,13 +133,13 @@
 // RVA23U64: "-target-feature" "+zihintntl"
 // RVA23U64: "-target-feature" "+zihintpause"
 // RVA23U64: "-target-feature" "+zihpm"
-// RVA23U64: "-target-feature" "+experimental-zimop"
+// RVA23U64: "-target-feature" "+zimop"
 // RVA23U64: "-target-feature" "+za64rs"
 // RVA23U64: "-target-feature" "+zawrs"
 // RVA23U64: "-target-feature" "+zfa"
 // RVA23U64: "-target-feature" "+zfhmin"
 // RVA23U64: "-target-feature" "+zcb"
-// RVA23U64: "-target-feature" "+experimental-zcmop"
+// RVA23U64: "-target-feature" "+zcmop"
 // RVA23U64: "-target-feature" "+zba"
 // RVA23U64: "-target-feature" "+zbb"
 // RVA23U64: "-target-feature" "+zbs"
@@ -172,13 +172,13 @@
 // RVA23S64: "-target-feature" "+zihintntl"
 // RVA23S64: "-target-feature" "+zihintpause"
 // RVA23S64: "-target-feature" "+zihpm"
-// RVA23S64: "-target-feature" "+experimental-zimop"
+// RVA23S64: "-target-feature" "+zimop"
 // RVA23S64: "-target-feature" "+za64rs"
 // RVA23S64: "-target-feature" "+zawrs"
 // RVA23S64: "-target-feature" "+zfa"
 // RVA23S64: "-target-feature" "+zfhmin"
 // RVA23S64: "-target-feature" "+zcb"
-// RVA23S64: "-target-feature" "+experimental-zcmop"
+// RVA23S64: "-target-feature" "+zcmop"
 // RVA23S64: "-target-feature" "+zba"
 // RVA23S64: "-target-feature" "+zbb"
 // RVA23S64: "-target-feature" "+zbs"
@@ -207,7 +207,7 @@
 // RVA23S64: "-target-feature" "+svnapot"
 // RVA23S64: "-target-feature" "+svpbmt"
 
-// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvb23u64 
-menable-experimental-extensions \
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvb23u64 \
 // RUN:   | FileCheck -check-prefix=RVB23U64 %s
 // RVB23U64: "-target-feature" "+m"
 // RVB23U64: "-target-feature" "+a"
@@ -228,12 +228,12 @@
 // RVB23U64: "-target-feature" "+zihintntl"
 // RVB23U64: "-target-feature" "+zihintpause"
 // RVB23U64: "-target-feature" "+zihpm"
-// RVB23U64: "-target-feature" "+experimental-zimop"
+// RVB23U64: "-target-feature" "+zimop"
 // RVB23U64: "-target-feature" "+za64rs"
 // RVB23U64: "-target-feature" "+zawrs"
 // RVB23U64: "-target-feature" "+zfa"
 // RVB23U64: "-target-feature" "+zcb"
-// RVB23U64: "-target-feature" "+experimental-zcmop"
+// RVB23U64: "-target-feature" "+zcmop"
 // RVB23U64: "-target-feature" "+zba"
 // RVB23U64: "-target-feature" "+zbb"
 // RVB23U64: "-target-feature" "+zbs"
@@ -261,12 +261,12 @@
 // RVB23S64: "-target-feature" "+zihintntl"
 // RVB23S64: "-target-feature" "+zihintpause"
 // RVB23S64: "-target-feature" "+zihpm"
-// RVB23S64: "-target-feature" "+experimental-zimop"
+// RVB23S64: "-target-feature" "+zimop"
 // RVB23S64: "-target-feature" "+za64rs"
 // RVB23S64: "-target-feature" "+zawrs"
 // RVB23S64: "-target-feature" "+zfa"
 // RVB23S64: "-target-feature" "+zcb"
-// RVB23S64: "-target-feature" "+experimental-zcmop"
+// RVB23S64: "-target-feature" "+zcmop"
 // RVB23S64: "-target-feature" "+zba"
 // RVB23S64: "-target-feature" "+zbb"
 // RVB23S64: "-target-featur

[clang] [llvm] [RISCV] Zimop/Zcmop are ratified (PR #87966)

2024-04-08 Thread Pengcheng Wang via cfe-commits

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


[clang] [llvm] [NFC] Fix misspellings of effects (PR #87795)

2024-04-08 Thread via cfe-commits

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


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


[clang] [clang][analyzer] Add "pedantic" mode to StreamChecker. (PR #87322)

2024-04-08 Thread Balázs Kéri via cfe-commits

https://github.com/balazske updated 
https://github.com/llvm/llvm-project/pull/87322

From 79bbe640c0d60744f484db9965865455b0b15246 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Tue, 2 Apr 2024 09:59:48 +0200
Subject: [PATCH 1/3] [clang][analyzer] Add "pedantic" mode to StreamChecker.

The checker may create failure branches for all stream write operations
only if the new option "pedantic" is set to true.
Result of the write operations is often not checked in typical code.
If failure branches are created the checker will warn for unchecked
write operations and generate a lot of "false positives" (these are
valid warnings but the programmer does not care about this problem).
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td |  8 +++
 .../StaticAnalyzer/Checkers/StreamChecker.cpp | 32 +++--
 clang/test/Analysis/stream-errno-note.c   |  1 +
 clang/test/Analysis/stream-errno.c|  1 +
 clang/test/Analysis/stream-error.c|  1 +
 clang/test/Analysis/stream-note.c |  2 +
 clang/test/Analysis/stream-pedantic.c | 71 +++
 .../Analysis/stream-stdlibraryfunctionargs.c  |  3 +
 clang/test/Analysis/stream.c  | 12 ++--
 9 files changed, 121 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/Analysis/stream-pedantic.c

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 5fe5c9286dabb7..570e0849e0124b 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -604,6 +604,14 @@ def PthreadLockChecker : Checker<"PthreadLock">,
 def StreamChecker : Checker<"Stream">,
   HelpText<"Check stream handling functions">,
   WeakDependencies<[NonNullParamChecker]>,
+  CheckerOptions<[
+CmdLineOption
+  ]>,
   Documentation;
 
 def SimpleStreamChecker : Checker<"SimpleStream">,
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 069e3a633c1214..337420c3b25df3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -297,6 +297,9 @@ class StreamChecker : public Checker FnDescriptions = {
   {{{"fopen"}, 2}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
@@ -945,6 +948,10 @@ void StreamChecker::evalFreadFwrite(const FnDescription 
*Desc,
   }
 
   // Add transition for the failed state.
+  // At write, add failure case only if "pedantic mode" is on.
+  if (!IsFread && !PedanticMode)
+return;
+
   NonLoc RetVal = makeRetVal(C, E.CE).castAs();
   ProgramStateRef StateFailed =
   State->BindExpr(E.CE, C.getLocationContext(), RetVal);
@@ -1059,6 +1066,9 @@ void StreamChecker::evalFputx(const FnDescription *Desc, 
const CallEvent &Call,
 
   // Add transition for the failed state. The resulting value of the file
   // position indicator for the stream is indeterminate.
+  if (!PedanticMode)
+return;
+
   ProgramStateRef StateFailed = E.bindReturnValue(State, C, *EofVal);
   StateFailed = E.setStreamState(
   StateFailed, StreamState::getOpened(Desc, ErrorFError, true));
@@ -1094,6 +1104,9 @@ void StreamChecker::evalFprintf(const FnDescription *Desc,
 
   // Add transition for the failed state. The resulting value of the file
   // position indicator for the stream is indeterminate.
+  if (!PedanticMode)
+return;
+
   StateFailed = E.setStreamState(
   StateFailed, StreamState::getOpened(Desc, ErrorFError, true));
   C.addTransition(StateFailed, E.getFailureNoteTag(this, C));
@@ -1264,16 +1277,18 @@ void StreamChecker::evalFseek(const FnDescription 
*Desc, const CallEvent &Call,
   if (!E.Init(Desc, Call, C, State))
 return;
 
-  // Bifurcate the state into failed and non-failed.
-  // Return zero on success, -1 on error.
+  // Add success state.
   ProgramStateRef StateNotFailed = E.bindReturnValue(State, C, 0);
-  ProgramStateRef StateFailed = E.bindReturnValue(State, C, -1);
-
   // No failure: Reset the state to opened with no error.
   StateNotFailed =
   E.setStreamState(StateNotFailed, StreamState::getOpened(Desc));
   C.addTransition(StateNotFailed);
 
+  // Add failure state.
+  if (!PedanticMode)
+return;
+
+  ProgramStateRef StateFailed = E.bindReturnValue(State, C, -1);
   // At error it is possible that fseek fails but sets none of the error flags.
   // If fseek failed, assume that the file position becomes indeterminate in 
any
   // case.
@@ -1316,6 +1331,10 @@ void StreamChecker::evalFsetpos(const FnDescription 
*Desc,
 
   StateNotFailed = E.setStreamState(
   StateNotFailed, StreamState::getOpened(Desc, ErrorNone, false));
+  C.addTransition(StateNotFailed);
+
+  if (!PedanticMode)
+return;
 
   // At failure ferror could be set.
   // The standards do not tell what happens with the file position at failure.
@@ -1324,7 +1343,6 @@ void StreamChecker::evalFset

[clang] [Clang][Sema] set declaration invalid earlier to prevent crash in calculating record layout (PR #87173)

2024-04-08 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/87173

>From 51f3dc24417eb0b74f029b85b47519b6d152 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Sun, 31 Mar 2024 09:38:05 +0800
Subject: [PATCH] [Clang][Sema] set declaration invalid earlier to prevent
 crash in calculating record layout

---
 clang/docs/ReleaseNotes.rst  | 2 ++
 clang/include/clang/Sema/Scope.h | 6 ++
 clang/lib/Parse/ParseDeclCXX.cpp | 5 +
 clang/lib/Sema/SemaDecl.cpp  | 7 +++
 clang/test/SemaCXX/PR75221.cpp   | 6 ++
 5 files changed, 26 insertions(+)
 create mode 100644 clang/test/SemaCXX/PR75221.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28e8ddb3c41c3e..1c541af8657dbb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -504,6 +504,8 @@ Bug Fixes to C++ Support
 - Fix crash when inheriting from a cv-qualified type. Fixes:
   (`#35603 `_)
 - Fix a crash when the using enum declaration uses an anonymous enumeration. 
Fixes (#GH86790).
+- Fix a crash caused by defined struct in a type alias template when the 
structure
+  has fields with dependent type. Fixes (#GH75221).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Scope.h b/clang/include/clang/Sema/Scope.h
index 099c2739e8603a..1752a25111a775 100644
--- a/clang/include/clang/Sema/Scope.h
+++ b/clang/include/clang/Sema/Scope.h
@@ -156,6 +156,9 @@ class Scope {
 /// This is the scope of an OpenACC Compute Construct, which restricts
 /// jumping into/out of it.
 OpenACCComputeConstructScope = 0x1000,
+
+/// This is a scope of type alias declaration.
+TypeAliasScope = 0x2000,
   };
 
 private:
@@ -580,6 +583,9 @@ class Scope {
   /// if/switch/while/for statement.
   bool isControlScope() const { return getFlags() & Scope::ControlScope; }
 
+  /// Determine whether this scope is a type alias scope.
+  bool isTypeAliasScope() const { return getFlags() & Scope::TypeAliasScope; }
+
   /// Returns if rhs has a higher scope depth than this.
   ///
   /// The caller is responsible for calling this only if one of the two scopes
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 861a25dc5103c1..270d09f8c9580c 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -799,6 +799,11 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration(
 ProhibitAttributes(PrefixAttrs);
 
 Decl *DeclFromDeclSpec = nullptr;
+Scope *CurScope = getCurScope();
+if (CurScope)
+  CurScope->setFlags(Scope::ScopeFlags::TypeAliasScope |
+ CurScope->getFlags());
+
 Decl *AD = ParseAliasDeclarationAfterDeclarator(
 TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
 return Actions.ConvertDeclToDeclGroup(AD, DeclFromDeclSpec);
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c790dab72dd721..b47824ef3d8498 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -19622,6 +19622,13 @@ void Sema::ActOnFields(Scope *S, SourceLocation 
RecLoc, Decl *EnclosingDecl,
   // Okay, we successfully defined 'Record'.
   if (Record) {
 bool Completed = false;
+if (S && S->getParent()) {
+  Scope *Parent = S->getParent();
+  if (Parent && Parent->isTypeAliasScope() &&
+  Parent->isTemplateParamScope())
+Record->setInvalidDecl();
+}
+
 if (CXXRecord) {
   if (!CXXRecord->isInvalidDecl()) {
 // Set access bits correctly on the directly-declared conversions.
diff --git a/clang/test/SemaCXX/PR75221.cpp b/clang/test/SemaCXX/PR75221.cpp
new file mode 100644
index 00..b342e347c5606a
--- /dev/null
+++ b/clang/test/SemaCXX/PR75221.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -verify -std=c++11 -fsyntax-only %s
+
+template  using foo = struct foo { // expected-error {{'foo' cannot 
be defined in a type alias template}}
+  T size = 0;
+};
+foo a;

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


[clang] [Clang][Sema] set declaration invalid earlier to prevent crash in calculating record layout (PR #87173)

2024-04-08 Thread Qizhi Hu via cfe-commits

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


[clang] cf7d36f - [NFC] Fix misspellings of effects (#87795)

2024-04-08 Thread via cfe-commits

Author: Zentrik
Date: 2024-04-08T11:18:59+02:00
New Revision: cf7d36fe342c5c5ac39150ca0b4b70a3d17ae66b

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

LOG: [NFC] Fix misspellings of effects (#87795)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
llvm/lib/Transforms/Scalar/NewGVN.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 6cc88679458140..845a5f9b390dc4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -30,7 +30,7 @@
 // was not consciously intended, and therefore it might have been unreachable.
 //
 // This checker uses eval::Call for modeling pure functions (functions without
-// side effets), for which their `Summary' is a precise model. This avoids
+// side effects), for which their `Summary' is a precise model. This avoids
 // unnecessary invalidation passes. Conflicts with other checkers are unlikely
 // because if the function has no other effects, other checkers would probably
 // never want to improve upon the modeling done by this checker.

diff  --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp 
b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 9caaf720ec9138..056be8629b9617 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -4019,7 +4019,7 @@ bool NewGVN::eliminateInstructions(Function &F) {
   // dominated defs as dead.
   if (Def) {
 // For anything in this case, what and how we value number
-// guarantees that any side-effets that would have occurred (ie
+// guarantees that any side-effects that would have occurred (ie
 // throwing, etc) can be proven to either still occur (because it's
 // dominated by something that has the same side-effects), or never
 // occur.  Otherwise, we would not have been able to prove it value



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


[clang] [llvm] [NFC] Fix misspellings of effects (PR #87795)

2024-04-08 Thread via cfe-commits

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


[clang] [clang] Add tests for some CWG 5xx issues (PR #87909)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits

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

>From 222f444f91d477bbc1ab2657a7f820740031f765 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 7 Apr 2024 10:52:10 +0300
Subject: [PATCH 1/2] [clang] Add tests for some CWG 5xx issues

---
 clang/test/CXX/drs/dr15xx.cpp |  2 +-
 clang/test/CXX/drs/dr19xx.cpp |  2 +-
 clang/test/CXX/drs/dr3xx.cpp  | 12 
 clang/test/CXX/drs/dr5xx.cpp  | 37 +++
 clang/www/cxx_dr_status.html  | 16 +++
 5 files changed, 59 insertions(+), 10 deletions(-)

diff --git a/clang/test/CXX/drs/dr15xx.cpp b/clang/test/CXX/drs/dr15xx.cpp
index 195c0fa610d579..6e3ad41c748fb1 100644
--- a/clang/test/CXX/drs/dr15xx.cpp
+++ b/clang/test/CXX/drs/dr15xx.cpp
@@ -555,7 +555,7 @@ auto DR1579_lambda_invalid = []() -> GenericMoveOnly {
 #endif
 } // end namespace dr1579
 
-namespace dr1584 {
+namespace dr1584 { // dr1584: 7 drafting 2015-05
 #if __cplusplus >= 201103L
   // Deducing function types from cv-qualified types
   template void f(const T *); // #dr1584-f
diff --git a/clang/test/CXX/drs/dr19xx.cpp b/clang/test/CXX/drs/dr19xx.cpp
index 716b1476831ed9..f8c1581f08540e 100644
--- a/clang/test/CXX/drs/dr19xx.cpp
+++ b/clang/test/CXX/drs/dr19xx.cpp
@@ -34,7 +34,7 @@ namespace dr1902 { // dr1902: 3.7
 #endif
 }
 
-namespace dr1903 {
+namespace dr1903 { // dr1903: 2.7
   namespace A {
 struct a {};
 int a;
diff --git a/clang/test/CXX/drs/dr3xx.cpp b/clang/test/CXX/drs/dr3xx.cpp
index 483ebf7a08aadb..6165835e2c183d 100644
--- a/clang/test/CXX/drs/dr3xx.cpp
+++ b/clang/test/CXX/drs/dr3xx.cpp
@@ -1568,6 +1568,18 @@ namespace dr391 { // dr391: 2.8 c++11
 }
 
 // dr392 is in dr392.cpp
+
+namespace dr393 { // dr393: 2.7
+
+template 
+struct S {};
+
+void f1(S);
+void f2(S);
+void g(int(*S::*)[]);
+
+} // namespace dr393
+
 // dr394: na
 
 namespace dr395 { // dr395: 3.0
diff --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index 426b368b390ae6..981b9d1afca970 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -18,6 +18,10 @@ namespace std {
 void *operator new(size_t, std::align_val_t); // 
#dr5xx-global-operator-new-aligned
 #endif
 
+namespace std {
+  struct type_info;
+}
+
 namespace dr500 { // dr500: dup 372
   class D;
   class A {
@@ -265,6 +269,18 @@ namespace dr527 { // dr527: na
   int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x;
 }
 
+namespace dr528 { // dr528: 2.7
+
+struct S; // #dr528-S
+
+void f() {
+  typeid(S);
+  // expected-error@-1 {{'typeid' of incomplete type 'S'}}
+  //   expected-note@#dr528-S {{forward declaration of 'dr528::S'}}
+}
+
+} // namespace dr528
+
 namespace dr530 { // dr530: yes
   template struct S { enum { N = 1 }; };
   template struct T { enum { N = 1 }; };
@@ -618,6 +634,8 @@ namespace dr548 { // dr548: dup 482
   template void dr548::f();
 }
 
+// dr550: dup 393
+
 namespace dr551 { // dr551: yes c++11
   // FIXME: This obviously should apply in C++98 mode too.
   template void f() {}
@@ -641,6 +659,7 @@ namespace dr552 { // dr552: yes
   X x;
 }
 
+// dr553: 2.7
 struct dr553_class {
   friend void *operator new(size_t, dr553_class);
 };
@@ -661,6 +680,10 @@ namespace dr553 {
 }
 
 // dr554: na
+
+// dr555: na
+// NB: name lookup cases that issue briefly touches are covered in our test 
for CWG466
+
 // dr556: na
 
 namespace dr557 { // dr557: 3.1
@@ -689,6 +712,20 @@ namespace dr558 { // dr558: 2.9
 
 template struct dr559 { typedef int T; dr559::T u; }; // dr559: yes
 
+namespace dr560 { // dr560: 16
+
+template 
+struct Outer {
+  struct Inner {
+Inner* self();
+  };
+};
+template 
+Outer::Inner* Outer::Inner::self() { return this; }
+// cxx98-17-error@-1 {{missing 'typename' prior to dependent type name 
Outer::Inner; implicit 'typename' is a C++20 extension}}
+
+} // namespace dr560
+
 namespace dr561 { // dr561: yes
   template void f(int);
   template void g(T t) {
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index a4c133c13c493f..15318bab81359b 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -2398,7 +2398,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/393.html";>393
 CD4
 Pointer to array of unknown bound in template argument list in 
parameter
-Unknown
+Clang 2.7
   
   
 https://cplusplus.github.io/CWG/issues/394.html";>394
@@ -3208,7 +3208,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/528.html";>528
 NAD
 Why are incomplete class types not allowed with typeid?
-Unknown
+Clang 2.7
   
   
 https://cplusplus.github.io/CWG/issues/529.html";>529
@@ -3342,7 +3342,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/550.html";>550
 dup
 Pointer to array of unknown bound in parameter declarations
-Unknown
+Duplicate of 393
   
   

[clang] [llvm] [NFC] Fix misspellings of effects (PR #87795)

2024-04-08 Thread via cfe-commits

cor3ntin wrote:

Thanks!

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


[clang] [llvm] [NFC] Fix misspellings of effects (PR #87795)

2024-04-08 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang] [clang] Add tests for some CWG 5xx issues (PR #87909)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits


@@ -265,6 +269,18 @@ namespace dr527 { // dr527: na
   int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x;
 }
 
+namespace dr528 { // dr528: 2.7

Endilll wrote:

For NAD issues, we write tests that check for status quo, and report the first 
version where we exhibit the behavior CWG wants.

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


[clang] [clang] Add tests for some CWG 5xx issues (PR #87909)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits


@@ -661,6 +680,10 @@ namespace dr553 {
 }
 
 // dr554: na
+
+// dr555: na

Endilll wrote:

I'm not keen to copy tests for an issue that is officially recognized as 
duplicate.

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


[clang] [clang] Add tests for some CWG 5xx issues (PR #87909)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits


@@ -1568,6 +1568,18 @@ namespace dr391 { // dr391: 2.8 c++11
 }
 
 // dr392 is in dr392.cpp
+
+namespace dr393 { // dr393: 2.7
+
+template 
+struct S {};
+
+void f1(S);
+void f2(S);
+void g(int(*S::*)[]);

Endilll wrote:

Done.

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


[clang-tools-extra] [clangd] Add config option to allow detection of unused system headers (PR #87208)

2024-04-08 Thread Vadim D. via cfe-commits

vvd170501 wrote:

Ping

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


[clang] [clang-tools-extra] [clang analysis] ExprMutationAnalyzer avoid infinite recursion for recursive forwarding reference (PR #87954)

2024-04-08 Thread Piotr Zegar via cfe-commits


@@ -45,6 +51,19 @@ class ExprMutationAnalyzer {
   using MutationFinder = const Stmt *(ExprMutationAnalyzer::*)(const Expr *);
   using ResultMap = llvm::DenseMap;
 
+  ExprMutationAnalyzer(const Stmt &Stm, ASTContext &Context, Cache 
*ParentCache)
+  : Stm(Stm), Context(Context) {
+if (ParentCache != nullptr) {
+  CrossAnalysisCache = ParentCache;
+} else {
+  CrossAnalysisCache = std::make_unique();
+}

PiotrZSL wrote:

maybe better use shared_ptr instead of this mess with variant.

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


[clang] [ARM64EC] Add support for parsing __vectorcall (PR #87725)

2024-04-08 Thread Jacek Caban via cfe-commits

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


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


[clang] [clang][analyzer] Add "pedantic" mode to StreamChecker. (PR #87322)

2024-04-08 Thread via cfe-commits
=?utf-8?q?Balázs_Kéri?= ,
=?utf-8?q?Balázs_Kéri?= 
Message-ID:
In-Reply-To: 


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

Thanks for the update! Feel free to merge the commit and initiate the de-alpha 
process.

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


[clang] [ARM64EC] Fix compilation of intrin.h in ARM64EC mode. (PR #87717)

2024-04-08 Thread Jacek Caban via cfe-commits

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

>  (If we actually need some of these intrinsics in ARM64EC mode, we can 
> revisit later.)

FWIW, most of them are provided by MSVC/Windows SDK via `softintrin.h` 
(included from `intrin.h`) as functions, not actual intrisics.

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


[libclc] 8461d90 - [libclc] Restore linking against dynamic libLLVM for out-of-tree builds

2024-04-08 Thread Fraser Cormack via cfe-commits

Author: Fraser Cormack
Date: 2024-04-08T11:05:38+01:00
New Revision: 8461d901a770516cf2069fe3bce979a6f8fc8d76

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

LOG: [libclc] Restore linking against dynamic libLLVM for out-of-tree builds

This fixes a regression where building against an installation without
the static libraries would fail. This just reinstates the old behaviour
for out-of-tree builds, assuming that in-tree builds (which still aren't
officially supported) will have the static libraries available. We can
refine this as we move towards supporting in-tree builds.

Added: 


Modified: 
libclc/CMakeLists.txt

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 21e5cac688227d..8750a65a717f9b 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -122,7 +122,11 @@ set(LLVM_LINK_COMPONENTS
   IRReader
   Support
 )
-add_llvm_utility( prepare_builtins utils/prepare-builtins.cpp )
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  add_llvm_executable( prepare_builtins utils/prepare-builtins.cpp )
+else()
+  add_llvm_utility( prepare_builtins utils/prepare-builtins.cpp )
+endif()
 target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} )
 # These were not properly reported in early LLVM and we don't need them
 target_compile_options( prepare_builtins PRIVATE -fno-rtti -fno-exceptions )



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


[libclc] [libclc] Fix a couple of issues preventing in-tree builds (PR #87505)

2024-04-08 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

> This change broke standalone build against LLVM dylib — it now insists on 
> linking to non-existing static libraries:
> 
> ```
> FAILED: prepare_builtins 
> : && /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -march=znver2 
> --param=l1-cache-size=32 --param=l1-cache-line-size=64 -O2 -pipe 
> -frecord-gcc-switches -Wl,-O1 -Wl,--as-needed 
> -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,-rpath-link,  
> -Wl,--gc-sections 
> CMakeFiles/prepare_builtins.dir/utils/prepare-builtins.cpp.o -o 
> prepare_builtins  -Wl,-rpath,"\$ORIGIN/../lib64:/usr/lib/llvm/17/lib64"  
> -lLLVMBitReader  -lLLVMBitWriter  -lLLVMCore  -lLLVMIRReader  
> /usr/lib/llvm/17/lib64/libLLVMSupport.a  -lrt  -ldl  -lm  /usr/lib64/libz3.so 
>  /usr/lib64/libz.so  /usr/lib64/libzstd.so  /usr/lib64/libtinfo.so  
> /usr/lib/llvm/17/lib64/libLLVMDemangle.a && :
> /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
> cannot find -lLLVMBitReader: No such file or directory
> /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
> cannot find -lLLVMBitWriter: No such file or directory
> /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
> cannot find -lLLVMCore: No such file or directory
> /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
> cannot find -lLLVMIRReader: No such file or directory
> collect2: error: ld returned 1 exit status
> ```
> 
> Given that it apparently doesn't fix in-tree builds fully, please revert and 
> let's figure out how to do it properly without breaking its primary use case.

Ach, sorry about that, thanks for catching that. It's tricky without CI to 
catch this kind of thing, though that was particularly silly of me. I actually 
struggled to build LLVM locally with the kind of configuration that only has 
dynamic libraries available to reproduce.

That said, I've pushed 8461d901a770516cf2069fe3bce979a6f8fc8d76 which should 
just re-instate the old behaviour for out-of-tree builds. If that doesn't fix 
the issue then I'll revert properly - please let me know, thanks.

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


[clang] [analyzer] `canReasonAbout` does not support `nonloc::LazyCompoundVal` (PR #87521)

2024-04-08 Thread Andrew V. Teylu via cfe-commits

https://github.com/aytey updated https://github.com/llvm/llvm-project/pull/87521

>From 1f70839ea1607f151c9f7eb390fcb974b32a54ca Mon Sep 17 00:00:00 2001
From: "Andrew V. Teylu" 
Date: Wed, 3 Apr 2024 17:18:08 +0100
Subject: [PATCH 1/3] [analyzer] `canReasonAbout` does not support
 `nonloc::LazyCompoundVal`

This PR makes two modifications to the {Simple, Range} constraint managers:

* `nonloc::LazyCompoundVal` is now explicitly not able to be reasoned about; and

* When we have something that cannot be reasoned about, we return an unmodified 
state (and do not attempt to simplify)

For the added test-case, testing under `main` will either hit an 
`llvm_unreachable` (or go off the rails for other reasons). After this change, 
the test-case passes successfully.

The change stating "Non-integer types are not supported" for 
`nonloc::LazyCompoundVal` follows the same logic inside of 
`RangedConstraintManager::assumeSymUnsupported`. However, when a 
`nonloc::LazyCompoundVal`, we don't want to call 
`RangedConstraintManager::assumeSymUnsupported` because this will attempt to 
work with the `Sym` or `State` in a way that isn't compatible with a 
`nonloc::LazyCompoundVal`.
---
 .../Core/RangeConstraintManager.cpp |  4 
 .../Core/SimpleConstraintManager.cpp| 10 +++---
 clang/test/Analysis/non_loc_compound.cpp| 17 +
 3 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Analysis/non_loc_compound.cpp

diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index c6f87b45ab887a..1f3e5711bcc71c 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2836,6 +2836,10 @@ bool RangeConstraintManager::canReasonAbout(SVal X) 
const {
 return false;
   }
 
+  // Non-integer types are not supported.
+  if (X.getAs())
+return false;
+
   return true;
 }
 
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
index 8ca2cdb9d3ab7a..b84a68ab93ef90 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -57,10 +57,14 @@ ProgramStateRef 
SimpleConstraintManager::assumeAux(ProgramStateRef State,
   // We cannot reason about SymSymExprs, and can only reason about some
   // SymIntExprs.
   if (!canReasonAbout(Cond)) {
-// Just add the constraint to the expression without trying to simplify.
 SymbolRef Sym = Cond.getAsSymbol();
-assert(Sym);
-return assumeSymUnsupported(State, Sym, Assumption);
+if (Sym) {
+  // this will simplify the symbol, so only call this if we have a
+  // symbol.
+  return assumeSymUnsupported(State, Sym, Assumption);
+} else {
+  return State;
+}
   }
 
   switch (Cond.getKind()) {
diff --git a/clang/test/Analysis/non_loc_compound.cpp 
b/clang/test/Analysis/non_loc_compound.cpp
new file mode 100644
index 00..b76ecb8d56635c
--- /dev/null
+++ b/clang/test/Analysis/non_loc_compound.cpp
@@ -0,0 +1,17 @@
+// REQUIRES: crash-recovery, asserts
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=alpha.cplusplus.InvalidatedIterator \
+// RUN:   -analyzer-config aggressive-binary-operation-simplification=true \
+// RUN:   2>&1
+
+struct node {};
+struct prop : node {};
+struct bitvec : node {
+  prop operator==(bitvec) { return prop(); }
+  bitvec extend(); // { return *this; }
+};
+void convert() {
+  bitvec input;
+  bitvec output(input.extend());
+  output == input;
+}

>From 9f552209d9ce9bbddca247a46f79b331388908bf Mon Sep 17 00:00:00 2001
From: "Andrew V. Teylu" 
Date: Wed, 3 Apr 2024 17:18:08 +0100
Subject: [PATCH 2/3] [analyzer] `canReasonAbout` does not support
 `nonloc::LazyCompoundVal`

This PR makes two modifications to the {Simple, Range} constraint managers:

* `nonloc::LazyCompoundVal` is now explicitly not able to be reasoned about; and

* When we have something that cannot be reasoned about, we return an unmodified 
state (and do not attempt to simplify)

For the added test-case, testing under `main` will either hit an 
`llvm_unreachable` (or go off the rails for other reasons). After this change, 
the test-case passes successfully.

The change stating "Non-integer types are not supported" for 
`nonloc::LazyCompoundVal` follows the same logic inside of 
`RangedConstraintManager::assumeSymUnsupported`. However, when a 
`nonloc::LazyCompoundVal`, we don't want to call 
`RangedConstraintManager::assumeSymUnsupported` because this will attempt to 
work with the `Sym` or `State` in a way that isn't compatible with a 
`nonloc::LazyCompoundVal`.
---
 .../Core/RangeConstraintManager.cpp |  4 
 .../Core/SimpleConstraintManager.cpp| 10 +++---
 clang/test/Analysis/non_loc_compound.cpp| 17 +
 3 fi

[clang] c2067c1 - [clang][analyzer] Add "pedantic" mode to StreamChecker. (#87322)

2024-04-08 Thread via cfe-commits

Author: Balázs Kéri
Date: 2024-04-08T12:19:03+02:00
New Revision: c2067c1f471ac54312cb5e1e0efd4ea5fd21cc79

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

LOG: [clang][analyzer] Add "pedantic" mode to StreamChecker. (#87322)

The checker may create failure branches for all stream write operations
only if the new option "pedantic" is set to true.
Result of the write operations is often not checked in typical code. If
failure branches are created the checker will warn for unchecked write
operations and generate a lot of "false positives" (these are valid
warnings but the programmer does not care about this problem).

Added: 
clang/test/Analysis/stream-pedantic.c

Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
clang/test/Analysis/stream-errno-note.c
clang/test/Analysis/stream-errno.c
clang/test/Analysis/stream-error.c
clang/test/Analysis/stream-note.c
clang/test/Analysis/stream-stdlibraryfunctionargs.c
clang/test/Analysis/stream.c

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index f188f18ba5557e..fb748d23a53d01 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -3138,10 +3138,16 @@ are detected:
   allowed in this state.
 * Invalid 3rd ("``whence``") argument to ``fseek``.
 
-The checker does not track the correspondence between integer file descriptors
-and ``FILE *`` pointers. Operations on standard streams like ``stdin`` are not
-treated specially and are therefore often not recognized (because these streams
-are usually not opened explicitly by the program, and are global variables).
+The stream operations are by this checker usually split into two cases, a 
success
+and a failure case. However, in the case of write operations (like ``fwrite``,
+``fprintf`` and even ``fsetpos``) this behavior could produce a large amount of
+unwanted reports on projects that don't have error checks around the write
+operations, so by default the checker assumes that write operations always 
succeed.
+This behavior can be controlled by the ``Pedantic`` flag: With
+``-analyzer-config alpha.unix.Stream:Pedantic=true`` the checker will model the
+cases where a write operation fails and report situations where this leads to
+erroneous behavior. (The default is ``Pedantic=false``, where write operations
+are assumed to succeed.)
 
 .. code-block:: c
 
@@ -3196,6 +3202,13 @@ are usually not opened explicitly by the program, and 
are global variables).
fclose(p);
  }
 
+**Limitations**
+
+The checker does not track the correspondence between integer file descriptors
+and ``FILE *`` pointers. Operations on standard streams like ``stdin`` are not
+treated specially and are therefore often not recognized (because these streams
+are usually not opened explicitly by the program, and are global variables).
+
 .. _alpha-unix-cstring-BufferOverlap:
 
 alpha.unix.cstring.BufferOverlap (C)

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 5fe5c9286dabb7..9aa1c6ddfe4492 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -604,6 +604,15 @@ def PthreadLockChecker : Checker<"PthreadLock">,
 def StreamChecker : Checker<"Stream">,
   HelpText<"Check stream handling functions">,
   WeakDependencies<[NonNullParamChecker]>,
+  CheckerOptions<[
+CmdLineOption
+  ]>,
   Documentation;
 
 def SimpleStreamChecker : Checker<"SimpleStream">,

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 069e3a633c1214..31c756ab0c5812 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -297,6 +297,9 @@ class StreamChecker : public Checker FnDescriptions = {
   {{{"fopen"}, 2}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
@@ -945,6 +948,10 @@ void StreamChecker::evalFreadFwrite(const FnDescription 
*Desc,
   }
 
   // Add transition for the failed state.
+  // At write, add failure case only if "pedantic mode" is on.
+  if (!IsFread && !PedanticMode)
+return;
+
   NonLoc RetVal = makeRetVal(C, E.CE).castAs();
   ProgramStateRef StateFailed =
   State->BindExpr(E.CE, C.getLocationContext(), RetVal);
@@ -1057,6 +1064,9 @@ void StreamChecker::evalFputx(const FnDescription *Desc, 
const CallEvent &Call,
 C.addTransition(StateNotFailed);
   }
 
+  if (!PedanticMode)
+r

[clang] [clang][analyzer] Add "pedantic" mode to StreamChecker. (PR #87322)

2024-04-08 Thread Balázs Kéri via cfe-commits

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


[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)

2024-04-08 Thread Fraser Cormack via cfe-commits


@@ -27,31 +36,51 @@ set( LIBCLC_TARGETS_TO_BUILD "all"
 
 option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal 
support." OFF )
 
-find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-include(AddLLVM)
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

frasercrmck wrote:

Yeah, I think you're right. I'm not 100%, but other LLVM sub-projects do it so 
I think we should too.

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


[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)

2024-04-08 Thread Fraser Cormack via cfe-commits


@@ -358,3 +399,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 endif()
   endforeach( d )
 endforeach( t )
+
+if( NOT LIBCLC_STANDALONE_BUILD )
+  add_subdirectory( test )

frasercrmck wrote:

Ach yeah sorry, I have another path locally which adds some LIT tests - this 
should be in that one. I'll remove it for now, and we can maybe decide whether 
or not to add LIT testing to this PR or not.

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


[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)

2024-04-08 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/87622

>From b87c2862491aed03f883d6b124a845b0d7c47699 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Wed, 3 Apr 2024 16:09:30 +0100
Subject: [PATCH] [libclc] Refactor build system to allow in-tree builds

The previous build system was adding custom "OpenCL" and "LLVM IR"
languages in CMake to build the builtin libraries. This was making it
harder to build in-tree because the tool binaries needed to be present
at configure time.

This commit refactors the build system to use custom commands to build
the bytecode files one by one, and link them all together into the final
bytecode library. It also enables in-tree builds by aliasing the
clang/llvm-link/etc. tool targets to internal targets, which are
imported from the LLVM installation directory when building out of tree.

Diffing (with llvm-diff) all of the final bytecode libraries in an
out-of-tree configuration against those built using the current tip
system shows no changes. Note that there are textual changes to metadata
IDs which confuse regular diff, and that llvm-diff 14 and below may show
false-positives.

This commit also removes a file listed in one of the SOURCEs which
didn't exist and which was preventing the use of
ENABLE_RUNTIME_SUBNORMAL when configuring CMake.
---
 libclc/CMakeLists.txt | 233 ++
 libclc/cmake/CMakeCLCCompiler.cmake.in|   9 -
 libclc/cmake/CMakeCLCInformation.cmake|  12 -
 libclc/cmake/CMakeDetermineCLCCompiler.cmake  |  18 --
 .../cmake/CMakeDetermineLLAsmCompiler.cmake   |  24 --
 libclc/cmake/CMakeLLAsmCompiler.cmake.in  |  10 -
 libclc/cmake/CMakeLLAsmInformation.cmake  |  12 -
 libclc/cmake/CMakeTestCLCCompiler.cmake   |  56 -
 libclc/cmake/CMakeTestLLAsmCompiler.cmake |  56 -
 libclc/cmake/modules/AddLibclc.cmake  | 153 
 libclc/generic/lib/SOURCES|   1 -
 llvm/tools/CMakeLists.txt |   3 +
 12 files changed, 293 insertions(+), 294 deletions(-)
 delete mode 100644 libclc/cmake/CMakeCLCCompiler.cmake.in
 delete mode 100644 libclc/cmake/CMakeCLCInformation.cmake
 delete mode 100644 libclc/cmake/CMakeDetermineCLCCompiler.cmake
 delete mode 100644 libclc/cmake/CMakeDetermineLLAsmCompiler.cmake
 delete mode 100644 libclc/cmake/CMakeLLAsmCompiler.cmake.in
 delete mode 100644 libclc/cmake/CMakeLLAsmInformation.cmake
 delete mode 100644 libclc/cmake/CMakeTestCLCCompiler.cmake
 delete mode 100644 libclc/cmake/CMakeTestLLAsmCompiler.cmake
 create mode 100644 libclc/cmake/modules/AddLibclc.cmake

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 8750a65a717f9b..e509a61f51b927 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -4,6 +4,15 @@ project( libclc VERSION 0.2.0 LANGUAGES CXX C)
 
 set(CMAKE_CXX_STANDARD 17)
 
+# Add path for custom modules
+list( INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake/modules" )
+
+set( LIBCLC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
+set( LIBCLC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
+set( LIBCLC_OBJFILE_DIR ${LIBCLC_BINARY_DIR}/obj.libclc.dir )
+
+include( AddLibclc )
+
 include( GNUInstallDirs )
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
   amdgcn-amdhsa/lib/SOURCES;
@@ -27,31 +36,51 @@ set( LIBCLC_TARGETS_TO_BUILD "all"
 
 option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal 
support." OFF )
 
-find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-include(AddLLVM)
+if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL 
CMAKE_CURRENT_SOURCE_DIR )
+  # Out-of-tree configuration
+  set( LIBCLC_STANDALONE_BUILD TRUE )
 
-message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" )
+  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
+  include(AddLLVM)
 
-if( LLVM_PACKAGE_VERSION VERSION_LESS LIBCLC_MIN_LLVM )
-  message( FATAL_ERROR "libclc needs at least LLVM ${LIBCLC_MIN_LLVM}" )
-endif()
+  message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" )
 
-find_program( LLVM_CLANG clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
-find_program( LLVM_AS llvm-as PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
-find_program( LLVM_LINK llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
-find_program( LLVM_OPT opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
-find_program( LLVM_SPIRV llvm-spirv PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
+  if( LLVM_PACKAGE_VERSION VERSION_LESS LIBCLC_MIN_LLVM )
+message( FATAL_ERROR "libclc needs at least LLVM ${LIBCLC_MIN_LLVM}" )
+  endif()
+
+  # Import required tools as targets
+  foreach( tool clang llvm-as llvm-link opt )
+find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
+add_executable( libclc::${tool} IMPORTED GLOBAL )
+set_target_properties( libclc::${tool} PROPERTIES IMPORTED_LOCATION 
${LLVM_TOOL_${tool}} )
+  endforeach()
+else()
+  # In-tree configuration
+ 

[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)

2024-04-08 Thread Fraser Cormack via cfe-commits

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


[clang] [clang-format] Added unittest of TableGen formatting w.r.t. block type calculation. (PR #87924)

2024-04-08 Thread Hirofumi Nakamura via cfe-commits


@@ -290,6 +290,16 @@ TEST_F(FormatTestTableGen, MultiClass) {
"}\n");
 }
 
+TEST_F(FormatTestTableGen, MultiClassesWithPasteOperator) {
+  // This is a sensitive example for the handling of the paste operators in
+  // brace type calculation.
+  verifyFormat("multiclass MultiClass1 {\n"
+   "  def : Def#x;\n"
+   "  def : Def#y;\n"
+   "}\n"
+   "multiclass MultiClass2 { def : Def#x; }\n");

hnakamura5 wrote:

I come to notice that they are not required. I will make a patch for whole this 
file later.

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


[clang] 5a855d5 - [clang-format] Added unittest of TableGen formatting w.r.t. block type calculation. (#87924)

2024-04-08 Thread via cfe-commits

Author: Hirofumi Nakamura
Date: 2024-04-08T21:12:12+09:00
New Revision: 5a855d51272608e2122c45d86676aa2247a11d19

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

LOG: [clang-format] Added unittest of TableGen formatting w.r.t. block type 
calculation. (#87924)

Added: 


Modified: 
clang/unittests/Format/FormatTestTableGen.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTestTableGen.cpp 
b/clang/unittests/Format/FormatTestTableGen.cpp
index 8ca6bf97e5a6b1..d235c85c8eaa0f 100644
--- a/clang/unittests/Format/FormatTestTableGen.cpp
+++ b/clang/unittests/Format/FormatTestTableGen.cpp
@@ -290,6 +290,16 @@ TEST_F(FormatTestTableGen, MultiClass) {
"}\n");
 }
 
+TEST_F(FormatTestTableGen, MultiClassesWithPasteOperator) {
+  // This is a sensitive example for the handling of the paste operators in
+  // brace type calculation.
+  verifyFormat("multiclass MultiClass1 {\n"
+   "  def : Def#x;\n"
+   "  def : Def#y;\n"
+   "}\n"
+   "multiclass MultiClass2 { def : Def#x; }\n");
+}
+
 TEST_F(FormatTestTableGen, Defm) {
   verifyFormat("defm : Multiclass<0>;\n");
 



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


[clang] [clang-format] Added unittest of TableGen formatting w.r.t. block type calculation. (PR #87924)

2024-04-08 Thread Hirofumi Nakamura via cfe-commits

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


[clang] [LinkerWrapper] Do not include config files for device linking (PR #87659)

2024-04-08 Thread via cfe-commits

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


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


[clang] 86b0918 - [LinkerWrapper] Do not include config files for device linking (#87659)

2024-04-08 Thread via cfe-commits

Author: Joseph Huber
Date: 2024-04-08T07:14:52-05:00
New Revision: 86b0918e8e5f8e1aacebf4ba8901fc66aed3412f

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

LOG: [LinkerWrapper] Do not include config files for device linking (#87659)

Summary:
The device linking phase only wants to create the necessary commands to
emit the device binary. There were issues where the user's default
config file was being used and passing incompatible arguments to the
device compilation step. Simply disable this since we do not want any
additional arguments to these clang invocations.

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index c60be2789bd61e..73e695a67093e6 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -458,6 +458,7 @@ Expected clang(ArrayRef InputFiles, 
const ArgList &Args) {
   StringRef OptLevel = Args.getLastArgValue(OPT_opt_level, "O2");
   SmallVector CmdArgs{
   *ClangPath,
+  "--no-default-config",
   "-o",
   *TempFileOrErr,
   Args.MakeArgString("--target=" + Triple.getTriple()),



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


[clang] [LinkerWrapper] Do not include config files for device linking (PR #87659)

2024-04-08 Thread Joseph Huber via cfe-commits

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


[clang] [clang-format] Added unittest of TableGen formatting w.r.t. block type calculation. (PR #87924)

2024-04-08 Thread Hirofumi Nakamura via cfe-commits

hnakamura5 wrote:

Thank you!

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


[clang] [zOS] Turn CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT on for zOS (PR #87797)

2024-04-08 Thread via cfe-commits

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


[clang] [zOS] Turn CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT on for zOS (PR #87797)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (bahareh-farhadi)


Changes

PR 
[https://github.com/llvm/llvm-project/pull/84461](https://github.com/llvm/llvm-project/pull/84461)
 disabled `clang/unittests/Interpreter/InterpreterExtensionsTest.cpp` for AIX 
by turning on `CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT`.
This PR turns `CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT` on for zOS as 
well, since LLJIT cannot be created on zOS either. 

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


1 Files Affected:

- (modified) clang/unittests/Interpreter/InterpreterExtensionsTest.cpp (+1-1) 


``diff
diff --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp 
b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
index 1ba865a79ed778..b971cd550dc507 100644
--- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
@@ -30,7 +30,7 @@
 
 #include 
 
-#if defined(_AIX)
+#if defined(_AIX) || defined(__MVS__)
 #define CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
 #endif
 

``




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


[clang] [clang-format] Remove trailing newlines in TableGen formatting test. (PR #87983)

2024-04-08 Thread Hirofumi Nakamura via cfe-commits

https://github.com/hnakamura5 created 
https://github.com/llvm/llvm-project/pull/87983

Refactoring suggested here https://github.com/llvm/llvm-project/pull/87924 .

>From d55a0986ed175dbc18c073507691321a30952979 Mon Sep 17 00:00:00 2001
From: hnakamura5 
Date: Mon, 8 Apr 2024 21:20:04 +0900
Subject: [PATCH] [clang-format] Remove trailing newline in TableGen formatting
 test.

---
 clang/unittests/Format/FormatTestTableGen.cpp | 103 +-
 1 file changed, 51 insertions(+), 52 deletions(-)

diff --git a/clang/unittests/Format/FormatTestTableGen.cpp 
b/clang/unittests/Format/FormatTestTableGen.cpp
index d235c85c8eaa0f..79b6961b00b42a 100644
--- a/clang/unittests/Format/FormatTestTableGen.cpp
+++ b/clang/unittests/Format/FormatTestTableGen.cpp
@@ -72,7 +72,7 @@ TEST_F(FormatTestTableGen, LiteralsAndIdentifiers) {
"  let 0startID = $TokVarName;\n"
"  let 0xstartInteger = 0x42;\n"
"  let someIdentifier = $TokVarName;\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, BangOperators) {
@@ -101,22 +101,22 @@ TEST_F(FormatTestTableGen, BangOperators) {
"  \"zerozero\",\n"
"  true:  // default\n"
"  \"positivepositive\");\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, Include) {
-  verifyFormat("include \"test/IncludeFile.h\"\n");
+  verifyFormat("include \"test/IncludeFile.h\"");
 }
 
 TEST_F(FormatTestTableGen, Types) {
-  verifyFormat("def Types : list, bits<3>, list> {}\n");
+  verifyFormat("def Types : list, bits<3>, list> {}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue1_SingleLiterals) {
   verifyFormat("def SimpleValue {\n"
"  let Integer = 42;\n"
"  let String = \"some string\";\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue1_MultilineString) {
@@ -129,7 +129,7 @@ TEST_F(FormatTestTableGen, SimpleValue1_MultilineString) {
   "delimited by \\[{ and }\\]. It  can break across lines and the line "
   "breaks are retained in the string. \n"
   
"(https://llvm.org/docs/TableGen/ProgRef.html#grammar-token-TokCode)}];\n"
-  "}\n";
+  "}";
   StringRef DefWithCodeMessedUp =
   "def SimpleValueCode {  let  \n"
   "Code=   \n"
@@ -139,7 +139,7 @@ TEST_F(FormatTestTableGen, SimpleValue1_MultilineString) {
   "breaks are retained in the string. \n"
   "(https://llvm.org/docs/TableGen/ProgRef.html#grammar-token-TokCode)}] 
\n"
   " ;  \n"
-  "   }\n";
+  "   }";
   verifyFormat(DefWithCode, DefWithCodeMessedUp);
 }
 
@@ -147,15 +147,15 @@ TEST_F(FormatTestTableGen, SimpleValue2) {
   verifyFormat("def SimpleValue2 {\n"
"  let True = true;\n"
"  let False = false;\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue3) {
-  verifyFormat("class SimpleValue3 { int Question = ?; }\n");
+  verifyFormat("class SimpleValue3 { int Question = ?; }");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue4) {
-  verifyFormat("def SimpleValue4 { let ValueList = {1, 2, 3}; }\n");
+  verifyFormat("def SimpleValue4 { let ValueList = {1, 2, 3}; }");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue5) {
@@ -166,7 +166,7 @@ TEST_F(FormatTestTableGen, SimpleValue5) {
"  list>;\n"
"  let SquareBitsListWithType = [ {1, 2},\n"
" {3, 4} ]>>;\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue6) {
@@ -184,15 +184,15 @@ TEST_F(FormatTestTableGen, SimpleValue6) {
"  );\n"
"  let DAGArgBang = (!cast(\"Some\") i32:$src1,\n"
"  i32:$src2);\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue7) {
-  verifyFormat("def SimpleValue7 { let Identifier = SimpleValue; }\n");
+  verifyFormat("def SimpleValue7 { let Identifier = SimpleValue; }");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue8) {
-  verifyFormat("def SimpleValue8 { let Class = SimpleValue3<3>; }\n");
+  verifyFormat("def SimpleValue8 { let Class = SimpleValue3<3>; }");
 }
 
 TEST_F(FormatTestTableGen, ValueSuffix) {
@@ -203,19 +203,18 @@ TEST_F(FormatTestTableGen, ValueSuffix) {
"  let Slice1 = value[1, ];\n"
"  let Slice2 = value[4...7, 17, 2...3, 4];\n"
"  let Field = value.field;\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, PasteOperator) {
-  verifyFormat(
-  "def Paste#\"Operator\" { string Paste = \"Paste\"#operator; }\n");
+  verifyFormat("def Paste#\"Operator\" { string Paste = \"Paste\"#operator; 
}");
 
   verifyFormat("def [\"Traring\", \"Paste\"]# {\n"
"  string X = Traring#;\n"
"  stri

[clang] [zOS] Turn CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT on for zOS (PR #87797)

2024-04-08 Thread Abhina Sree via cfe-commits

https://github.com/abhina-sree approved this pull request.

LGTM

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


[clang] [clang-format] Remove trailing newlines in TableGen formatting test. (PR #87983)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Hirofumi Nakamura (hnakamura5)


Changes

Refactoring suggested here https://github.com/llvm/llvm-project/pull/87924 .

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


1 Files Affected:

- (modified) clang/unittests/Format/FormatTestTableGen.cpp (+51-52) 


``diff
diff --git a/clang/unittests/Format/FormatTestTableGen.cpp 
b/clang/unittests/Format/FormatTestTableGen.cpp
index d235c85c8eaa0f..79b6961b00b42a 100644
--- a/clang/unittests/Format/FormatTestTableGen.cpp
+++ b/clang/unittests/Format/FormatTestTableGen.cpp
@@ -72,7 +72,7 @@ TEST_F(FormatTestTableGen, LiteralsAndIdentifiers) {
"  let 0startID = $TokVarName;\n"
"  let 0xstartInteger = 0x42;\n"
"  let someIdentifier = $TokVarName;\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, BangOperators) {
@@ -101,22 +101,22 @@ TEST_F(FormatTestTableGen, BangOperators) {
"  \"zerozero\",\n"
"  true:  // default\n"
"  \"positivepositive\");\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, Include) {
-  verifyFormat("include \"test/IncludeFile.h\"\n");
+  verifyFormat("include \"test/IncludeFile.h\"");
 }
 
 TEST_F(FormatTestTableGen, Types) {
-  verifyFormat("def Types : list, bits<3>, list> {}\n");
+  verifyFormat("def Types : list, bits<3>, list> {}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue1_SingleLiterals) {
   verifyFormat("def SimpleValue {\n"
"  let Integer = 42;\n"
"  let String = \"some string\";\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue1_MultilineString) {
@@ -129,7 +129,7 @@ TEST_F(FormatTestTableGen, SimpleValue1_MultilineString) {
   "delimited by \\[{ and }\\]. It  can break across lines and the line "
   "breaks are retained in the string. \n"
   
"(https://llvm.org/docs/TableGen/ProgRef.html#grammar-token-TokCode)}];\n"
-  "}\n";
+  "}";
   StringRef DefWithCodeMessedUp =
   "def SimpleValueCode {  let  \n"
   "Code=   \n"
@@ -139,7 +139,7 @@ TEST_F(FormatTestTableGen, SimpleValue1_MultilineString) {
   "breaks are retained in the string. \n"
   "(https://llvm.org/docs/TableGen/ProgRef.html#grammar-token-TokCode)}] 
\n"
   " ;  \n"
-  "   }\n";
+  "   }";
   verifyFormat(DefWithCode, DefWithCodeMessedUp);
 }
 
@@ -147,15 +147,15 @@ TEST_F(FormatTestTableGen, SimpleValue2) {
   verifyFormat("def SimpleValue2 {\n"
"  let True = true;\n"
"  let False = false;\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue3) {
-  verifyFormat("class SimpleValue3 { int Question = ?; }\n");
+  verifyFormat("class SimpleValue3 { int Question = ?; }");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue4) {
-  verifyFormat("def SimpleValue4 { let ValueList = {1, 2, 3}; }\n");
+  verifyFormat("def SimpleValue4 { let ValueList = {1, 2, 3}; }");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue5) {
@@ -166,7 +166,7 @@ TEST_F(FormatTestTableGen, SimpleValue5) {
"  list>;\n"
"  let SquareBitsListWithType = [ {1, 2},\n"
" {3, 4} ]>>;\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue6) {
@@ -184,15 +184,15 @@ TEST_F(FormatTestTableGen, SimpleValue6) {
"  );\n"
"  let DAGArgBang = (!cast(\"Some\") i32:$src1,\n"
"  i32:$src2);\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue7) {
-  verifyFormat("def SimpleValue7 { let Identifier = SimpleValue; }\n");
+  verifyFormat("def SimpleValue7 { let Identifier = SimpleValue; }");
 }
 
 TEST_F(FormatTestTableGen, SimpleValue8) {
-  verifyFormat("def SimpleValue8 { let Class = SimpleValue3<3>; }\n");
+  verifyFormat("def SimpleValue8 { let Class = SimpleValue3<3>; }");
 }
 
 TEST_F(FormatTestTableGen, ValueSuffix) {
@@ -203,19 +203,18 @@ TEST_F(FormatTestTableGen, ValueSuffix) {
"  let Slice1 = value[1, ];\n"
"  let Slice2 = value[4...7, 17, 2...3, 4];\n"
"  let Field = value.field;\n"
-   "}\n");
+   "}");
 }
 
 TEST_F(FormatTestTableGen, PasteOperator) {
-  verifyFormat(
-  "def Paste#\"Operator\" { string Paste = \"Paste\"#operator; }\n");
+  verifyFormat("def Paste#\"Operator\" { string Paste = \"Paste\"#operator; 
}");
 
   verifyFormat("def [\"Traring\", \"Paste\"]# {\n"
"  string X = Traring#;\n"
"  string Y = List<\"Operator\">#;\n"
"  string Z = [\"Traring\", \"Paste\", \"Traring\", 
\"Paste\",\n"
"  \"Trar

[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

2024-04-08 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/87361

>From b8a626116b0719c1acf75e9e7300df8e2bf82f99 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Tue, 2 Apr 2024 18:00:05 +0200
Subject: [PATCH 1/2] [Clang] Reduce the size of Decl and classes derived from
 it

---
 clang/include/clang/AST/DeclBase.h| 66 ++-
 clang/lib/AST/DeclBase.cpp| 29 ++
 clang/lib/Serialization/ASTReaderDecl.cpp |  2 +-
 3 files changed, 62 insertions(+), 35 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 47ed6d0d1db0df..172bd581b527c8 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -268,17 +268,34 @@ class alignas(8) Decl {
   ///   }
   ///   void A::f(); // SemanticDC == namespace 'A'
   ///// LexicalDC == global namespace
-  llvm::PointerUnion DeclCtx;
+  llvm::PointerIntPair<
+  llvm::PointerIntPair, 1,
+   bool>,
+  1, bool>
+  DeclCtxWithInvalidDeclAndHasAttrs;
 
-  bool isInSemaDC() const { return DeclCtx.is(); }
-  bool isOutOfSemaDC() const { return DeclCtx.is(); }
+  bool isInSemaDC() const {
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.is();
+  }
+
+  bool isOutOfSemaDC() const {
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.is();
+  }
 
   MultipleDC *getMultipleDC() const {
-return DeclCtx.get();
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.get();
   }
 
   DeclContext *getSemanticDC() const {
-return DeclCtx.get();
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.get();
   }
 
   /// Loc - The location of this decl.
@@ -288,14 +305,6 @@ class alignas(8) Decl {
   LLVM_PREFERRED_TYPE(Kind)
   unsigned DeclKind : 7;
 
-  /// InvalidDecl - This indicates a semantic error occurred.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned InvalidDecl :  1;
-
-  /// HasAttrs - This indicates whether the decl has attributes or not.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned HasAttrs : 1;
-
   /// Implicit - Whether this declaration was implicitly generated by
   /// the implementation rather than explicitly written by the user.
   LLVM_PREFERRED_TYPE(bool)
@@ -393,21 +402,22 @@ class alignas(8) Decl {
 protected:
   Decl(Kind DK, DeclContext *DC, SourceLocation L)
   : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
-DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(false), HasAttrs(false),
-Implicit(false), Used(false), Referenced(false),
+DeclCtxWithInvalidDeclAndHasAttrs({DC, false}, false), Loc(L),
+DeclKind(DK), Implicit(false), Used(false), Referenced(false),
 TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
 IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
 CacheValidAndLinkage(llvm::to_underlying(Linkage::Invalid)) {
-if (StatisticsEnabled) add(DK);
+if (StatisticsEnabled)
+  add(DK);
   }
 
   Decl(Kind DK, EmptyShell Empty)
-  : DeclKind(DK), InvalidDecl(false), HasAttrs(false), Implicit(false),
-Used(false), Referenced(false), TopLevelDeclInObjCContainer(false),
-Access(AS_none), FromASTFile(0),
+  : DeclKind(DK), Implicit(false), Used(false), Referenced(false),
+TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
 IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
 CacheValidAndLinkage(llvm::to_underlying(Linkage::Invalid)) {
-if (StatisticsEnabled) add(DK);
+if (StatisticsEnabled)
+  add(DK);
   }
 
   virtual ~Decl();
@@ -520,7 +530,7 @@ class alignas(8) Decl {
 return AccessSpecifier(Access);
   }
 
-  bool hasAttrs() const { return HasAttrs; }
+  bool hasAttrs() const { return 
DeclCtxWithInvalidDeclAndHasAttrs.getPointer().getInt(); }
 
   void setAttrs(const AttrVec& Attrs) {
 return setAttrsImpl(Attrs, getASTContext());
@@ -549,13 +559,16 @@ class alignas(8) Decl {
   }
 
   template  void dropAttrs() {
-if (!HasAttrs) return;
+if (!hasAttrs()) return;
 
 AttrVec &Vec = getAttrs();
 llvm::erase_if(Vec, [](Attr *A) { return isa(A); });
 
-if (Vec.empty())
-  HasAttrs = false;
+if (Vec.empty()) {
+  auto InnerPtr = DeclCtxWithInvalidDeclAndHasAttrs.getPointer();
+  InnerPtr.setInt(false);
+  DeclCtxWithInvalidDeclAndHasAttrs.setPointer(InnerPtr);
+}
   }
 
   template  void dropAttr() { dropAttrs(); }
@@ -590,7 +603,10 @@ class alignas(8) Decl {
   /// setInvalidDecl - Indicates the Decl had a semantic error. This
   /// allows for graceful error recovery.
   void setInvalidDecl(bool Invalid = true);
-  bool isInvalidDecl() const { return (bool) InvalidDecl; }
+
+  bool isInvalidDecl() const {
+return DeclCtxWithInvalidDeclAndHasAttrs.getInt();
+

[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

2024-04-08 Thread Nikolas Klauser via cfe-commits


@@ -268,17 +268,34 @@ class alignas(8) Decl {
   ///   }
   ///   void A::f(); // SemanticDC == namespace 'A'
   ///// LexicalDC == global namespace
-  llvm::PointerUnion DeclCtx;
+  llvm::PointerIntPair<

philnik777 wrote:

IDK. I'm personally not a huge fan of manual bit twiddling, since it's way to 
easy to get things wrong. I much rather let the compiler do it.

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


[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nikolas Klauser (philnik777)


Changes

Class | Old size (in bytes) | New size (in bytes)
--|-|
Decl  | 40  | 32
AccessSpecDecl| 40  | 40
BlockDecl | 128 | 120
CapturedDecl  | 88  | 80
EmptyDecl | 40  | 32
ExportDecl| 80  | 72
ExternCContextDecl| 72  | 64
FileScopeAsmDecl  | 56  | 48
FriendDecl| 64  | 56
FriendTemplateDecl| 64  | 64
ImplicitConceptSpecializationDecl | 40  | 40
ImportDecl| 56  | 48
LifetimeExtendedTemporaryDecl | 72  | 64
LinkageSpecDecl   | 80  | 72
NamedDecl | 48  | 40
ObjCPropertyImplDecl  | 96  | 88
PragmaCommentDecl | 40  | 40
PragmaDetectMismatchDecl  | 48  | 40
RequiresExprBodyDecl  | 72  | 64
StaticAssertDecl  | 64  | 56
TopLevelStmtDecl  | 88  | 80
TranslationUnitDecl   | 104 | 96
BaseUsingDecl | 56  | 48
UsingDecl | 88  | 80
UsingEnumDecl | 72  | 64
HLSLBufferDecl| 96  | 88
LabelDecl | 80  | 72
NamespaceAliasDecl| 96  | 88
NamespaceDecl | 112 | 104
ObjCCompatibleAliasDecl   | 56  | 48
ObjCContainerDecl | 88  | 80
ObjCMethodDecl| 136 | 128
ObjCPropertyDecl  | 128 | 120
TemplateDecl  | 64  | 56
BuiltinTemplateDecl   | 72  | 64
TypeDecl  | 64  | 56
UnresolvedUsingIfExistsDecl   | 48  | 40
UsingDirectiveDecl| 88  | 80
UsingPackDecl | 64  | 56
UsingShadowDecl   | 80  | 72
ValueDecl | 56  | 48

When parsing libc++'s `` header the used memory is reduced from 
42.8MB to 42.5MB.



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


3 Files Affected:

- (modified) clang/include/clang/AST/DeclBase.h (+44-25) 
- (modified) clang/lib/AST/DeclBase.cpp (+22-9) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 47ed6d0d1db0df..9a3f8c41de387e 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -268,17 +268,37 @@ class alignas(8) Decl {
   ///   }
   ///   void A::f(); // SemanticDC == namespace 'A'
   ///// LexicalDC == global namespace
-  llvm::PointerUnion DeclCtx;
 
-  bool isInSemaDC() const { return DeclCtx.is(); }
-  bool isOutOfSemaDC() const { return DeclCtx.is(); }
+  // Compress the InvalidDecl and HasAttrs bits into DeclCtx to keep Decl below
+  // 32 bytes in size
+  llvm::PointerIntPair<
+  llvm::PointerIntPair, 1,
+   bool>,
+  1, bool>
+  DeclCtxWithInvalidDeclAndHasAttrs;
+
+  bool isInSemaDC() const {
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.is();
+  }
+
+  bool isOutOfSemaDC() const {
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.is();
+  }
 
   MultipleDC *getMultipleDC() const {
-return DeclCtx.get();
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.get();
   }
 
   DeclContext *getSemanticDC() const {
-return DeclCtx.get();
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.get();
   }
 
   /// Loc - The location of this decl.
@@ -288,14 +308,6 @@ class alignas(8) Decl {
   LLVM_PREFERRED_TYPE(Kind)
   unsigned DeclKind : 7;
 
-  /// InvalidDecl - This indicates a semantic error occurred.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned InvalidDecl :  1;
-
-  /// HasAttrs - This indicates whether the decl has attributes or not.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned HasAttrs : 1;
-
   /// Implicit - Whether this declaration was implicitly generated by
   /// the impl

[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Nikolas Klauser (philnik777)


Changes

Class | Old size (in bytes) | New size (in bytes)
--|-|
Decl  | 40  | 32
AccessSpecDecl| 40  | 40
BlockDecl | 128 | 120
CapturedDecl  | 88  | 80
EmptyDecl | 40  | 32
ExportDecl| 80  | 72
ExternCContextDecl| 72  | 64
FileScopeAsmDecl  | 56  | 48
FriendDecl| 64  | 56
FriendTemplateDecl| 64  | 64
ImplicitConceptSpecializationDecl | 40  | 40
ImportDecl| 56  | 48
LifetimeExtendedTemporaryDecl | 72  | 64
LinkageSpecDecl   | 80  | 72
NamedDecl | 48  | 40
ObjCPropertyImplDecl  | 96  | 88
PragmaCommentDecl | 40  | 40
PragmaDetectMismatchDecl  | 48  | 40
RequiresExprBodyDecl  | 72  | 64
StaticAssertDecl  | 64  | 56
TopLevelStmtDecl  | 88  | 80
TranslationUnitDecl   | 104 | 96
BaseUsingDecl | 56  | 48
UsingDecl | 88  | 80
UsingEnumDecl | 72  | 64
HLSLBufferDecl| 96  | 88
LabelDecl | 80  | 72
NamespaceAliasDecl| 96  | 88
NamespaceDecl | 112 | 104
ObjCCompatibleAliasDecl   | 56  | 48
ObjCContainerDecl | 88  | 80
ObjCMethodDecl| 136 | 128
ObjCPropertyDecl  | 128 | 120
TemplateDecl  | 64  | 56
BuiltinTemplateDecl   | 72  | 64
TypeDecl  | 64  | 56
UnresolvedUsingIfExistsDecl   | 48  | 40
UsingDirectiveDecl| 88  | 80
UsingPackDecl | 64  | 56
UsingShadowDecl   | 80  | 72
ValueDecl | 56  | 48

When parsing libc++'s `` header the used memory is reduced from 
42.8MB to 42.5MB.



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


3 Files Affected:

- (modified) clang/include/clang/AST/DeclBase.h (+44-25) 
- (modified) clang/lib/AST/DeclBase.cpp (+22-9) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 47ed6d0d1db0df..9a3f8c41de387e 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -268,17 +268,37 @@ class alignas(8) Decl {
   ///   }
   ///   void A::f(); // SemanticDC == namespace 'A'
   ///// LexicalDC == global namespace
-  llvm::PointerUnion DeclCtx;
 
-  bool isInSemaDC() const { return DeclCtx.is(); }
-  bool isOutOfSemaDC() const { return DeclCtx.is(); }
+  // Compress the InvalidDecl and HasAttrs bits into DeclCtx to keep Decl below
+  // 32 bytes in size
+  llvm::PointerIntPair<
+  llvm::PointerIntPair, 1,
+   bool>,
+  1, bool>
+  DeclCtxWithInvalidDeclAndHasAttrs;
+
+  bool isInSemaDC() const {
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.is();
+  }
+
+  bool isOutOfSemaDC() const {
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.is();
+  }
 
   MultipleDC *getMultipleDC() const {
-return DeclCtx.get();
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.get();
   }
 
   DeclContext *getSemanticDC() const {
-return DeclCtx.get();
+return DeclCtxWithInvalidDeclAndHasAttrs.getPointer()
+.getPointer()
+.get();
   }
 
   /// Loc - The location of this decl.
@@ -288,14 +308,6 @@ class alignas(8) Decl {
   LLVM_PREFERRED_TYPE(Kind)
   unsigned DeclKind : 7;
 
-  /// InvalidDecl - This indicates a semantic error occurred.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned InvalidDecl :  1;
-
-  /// HasAttrs - This indicates whether the decl has attributes or not.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned HasAttrs : 1;
-
   /// Implicit - Whether this declaration was implicitly generated by
   /// 

[clang] 8c6e045 - [zOS] Turn CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT on for zOS (#87797)

2024-04-08 Thread via cfe-commits

Author: bahareh-farhadi
Date: 2024-04-08T08:35:28-04:00
New Revision: 8c6e0459c49da298f3b911fc3699c2254a20d882

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

LOG: [zOS] Turn CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT on for zOS 
(#87797)

PR
[https://github.com/llvm/llvm-project/pull/84461](https://github.com/llvm/llvm-project/pull/84461)
disabled `clang/unittests/Interpreter/InterpreterExtensionsTest.cpp` for
AIX by turning on `CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT`.
This PR turns `CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT` on for
zOS as well, since LLJIT cannot be created on zOS either.

Co-authored-by: Bahareh 

Added: 


Modified: 
clang/unittests/Interpreter/InterpreterExtensionsTest.cpp

Removed: 




diff  --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp 
b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
index 1ba865a79ed778..b971cd550dc507 100644
--- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
@@ -30,7 +30,7 @@
 
 #include 
 
-#if defined(_AIX)
+#if defined(_AIX) || defined(__MVS__)
 #define CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
 #endif
 



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


[clang] [zOS] Turn CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT on for zOS (PR #87797)

2024-04-08 Thread Abhina Sree via cfe-commits

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


[clang] [zOS] Turn CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT on for zOS (PR #87797)

2024-04-08 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits


@@ -688,22 +689,45 @@ class Environment {
   /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body.
   void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl);
 
+  static PrValueToResultObject
+  buildResultObjectMap(DataflowAnalysisContext *DACtx,
+   const FunctionDecl *FuncDecl,
+   RecordStorageLocation *ThisPointeeLoc,
+   RecordStorageLocation *LocForRecordReturnVal);
+
   // `DACtx` is not null and not owned by this object.
   DataflowAnalysisContext *DACtx;
 
-  // FIXME: move the fields `CallStack`, `ReturnVal`, `ReturnLoc` and
-  // `ThisPointeeLoc` into a separate call-context object, shared between
-  // environments in the same call.
+  // FIXME: move the fields `CallStack`, `ResultObjectMap`, `ReturnVal`,
+  // `ReturnLoc` and `ThisPointeeLoc` into a separate call-context object,
+  // shared between environments in the same call.
   // https://github.com/llvm/llvm-project/issues/59005
 
   // `DeclContext` of the block being analysed if provided.
   std::vector CallStack;
 
-  // Value returned by the function (if it has non-reference return type).
+  // Maps from prvalues of record type to their result objects. Shared between
+  // all environments for the same function.
+  // FIXME: It's somewhat unsatisfactory that we have to use a `shared_ptr`
+  // here, though the cost is acceptable: The overhead of a `shared_ptr` is
+  // incurred when it is copied, and this happens only relatively rarely (when
+  // we fork the environment). The need for a `shared_ptr` will go away once we
+  // introduce a shared call-context object (see above).
+  std::shared_ptr ResultObjectMap;

martinboehme wrote:

> What would be the model for something like:
> 
> ```
> while (cond)
> {
>   f();
> }
> ```
> 
> where `f` returns a value. Do we have the same storage location for the 
> prvalue in all iterations?

Let me clarify what you're asking.

I think what you mean is that `f()` is declared like this, correct?

```cxx
struct S {};
S f();
```

In this case, there is indeed no glvalue of type `S` -- just the prvalue for 
the call `f()`. Normally, of course, prvalues don't have storage locations, but 
in this case, because there isn't an actual result object, we treat the 
`CallExpr` as if it was a `MaterializeTemporaryExpr` (see comment in 
`ResultObjectVisitor::VisitExpr()`).

(Just making sure up to here that we agree on the setting -- do you agree with 
all of the above?)

First of all, yes, we use the same storage location on all iterations of the 
loop -- witness the call to `DACtx.getStableStorageLocation(*E)`.

> In that case, the location is in fact a "summary" for the different 
> iterations.

I'm not sure I would agree with this. Let's assume this was a case where we 
actually have a `MaterializeTemporaryExpr` (imagine we're accessing some member 
of `S`, i.e. assume the expression in the loop is actually 
`f().some_member_fn()`). Then the compiler's codegen would very likely place 
the temporary in the same storage location on every iteration of the loop. 
(Sure, nothing in the standard mandates this AFAIK, but it's almost certainly 
what the compiler is going to do.) So the stable storage location that we use 
for the expression isn't a "summary" storage location, but it reflects the fact 
that the generated code, too, would use the same storage location.

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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits


@@ -688,22 +689,45 @@ class Environment {
   /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body.
   void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl);
 
+  static PrValueToResultObject
+  buildResultObjectMap(DataflowAnalysisContext *DACtx,
+   const FunctionDecl *FuncDecl,
+   RecordStorageLocation *ThisPointeeLoc,
+   RecordStorageLocation *LocForRecordReturnVal);
+
   // `DACtx` is not null and not owned by this object.
   DataflowAnalysisContext *DACtx;
 
-  // FIXME: move the fields `CallStack`, `ReturnVal`, `ReturnLoc` and
-  // `ThisPointeeLoc` into a separate call-context object, shared between
-  // environments in the same call.
+  // FIXME: move the fields `CallStack`, `ResultObjectMap`, `ReturnVal`,
+  // `ReturnLoc` and `ThisPointeeLoc` into a separate call-context object,
+  // shared between environments in the same call.
   // https://github.com/llvm/llvm-project/issues/59005
 
   // `DeclContext` of the block being analysed if provided.
   std::vector CallStack;
 
-  // Value returned by the function (if it has non-reference return type).
+  // Maps from prvalues of record type to their result objects. Shared between
+  // all environments for the same function.
+  // FIXME: It's somewhat unsatisfactory that we have to use a `shared_ptr`
+  // here, though the cost is acceptable: The overhead of a `shared_ptr` is
+  // incurred when it is copied, and this happens only relatively rarely (when
+  // we fork the environment). The need for a `shared_ptr` will go away once we
+  // introduce a shared call-context object (see above).
+  std::shared_ptr ResultObjectMap;

martinboehme wrote:

> Would it make sense for this to be owned by the `DataflowAnalysisContext`?

Unfortunately, no.

The `DataflowAnalysisContext` is shared by the whole analysis -- which may span 
several functions if we're doing a context-sensitive analysis.

In contrast, the result object map is specific to a given function, just like 
some of the other fields that are in `Environment` (`CallStack`, `ReturnVal`, 
`ReturnLoc` and `ThisPointeeLoc`). See the comment above saying that we should 
create a call-context object (which would be a per-function data structure) and 
move all of these fields to it.

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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits


@@ -385,6 +388,185 @@ getFieldsGlobalsAndFuncs(const Stmt &S, FieldSet &Fields,
   }
 }
 
+namespace {
+
+// Visitor that builds a map from record prvalues to result objects.
+// This traverses the body of the function to be analyzed; for each result
+// object that it encounters, it propagates the storage location of the result
+// object to all record prvalues that can initialize it.
+class ResultObjectVisitor : public RecursiveASTVisitor {
+public:
+  // `ResultObjectMap` will be filled with a map from record prvalues to result
+  // object. If the function being analyzed returns a record by value,
+  // `LocForRecordReturnVal` is the location to which this record should be
+  // written; otherwise, it is null.
+  explicit ResultObjectVisitor(
+  llvm::DenseMap &ResultObjectMap,
+  RecordStorageLocation *LocForRecordReturnVal,
+  DataflowAnalysisContext &DACtx)
+  : ResultObjectMap(ResultObjectMap),
+LocForRecordReturnVal(LocForRecordReturnVal), DACtx(DACtx) {}
+
+  bool shouldVisitImplicitCode() { return true; }
+
+  bool shouldVisitLambdaBody() const { return false; }
+
+  // Traverse all member and base initializers of `Ctor`. This function is not
+  // called by `RecursiveASTVisitor`; it should be called manually if we are
+  // analyzing a constructor. `ThisPointeeLoc` is the storage location that
+  // `this` points to.
+  void TraverseConstructorInits(const CXXConstructorDecl *Ctor,
+RecordStorageLocation *ThisPointeeLoc) {
+assert(ThisPointeeLoc != nullptr);
+for (const CXXCtorInitializer *Init : Ctor->inits()) {
+  Expr *InitExpr = Init->getInit();
+  if (FieldDecl *Field = Init->getMember();
+  Field != nullptr && Field->getType()->isRecordType()) {
+PropagateResultObject(InitExpr, cast(
+ThisPointeeLoc->getChild(*Field)));
+  } else if (Init->getBaseClass()) {
+PropagateResultObject(InitExpr, ThisPointeeLoc);
+  }
+
+  // Ensure that any result objects within `InitExpr` (e.g. temporaries)
+  // are also propagated to the prvalues that initialize them.
+  TraverseStmt(InitExpr);
+
+  // If this is a `CXXDefaultInitExpr`, also propagate any result objects
+  // within the default expression.
+  if (auto *DefaultInit = dyn_cast(InitExpr))
+TraverseStmt(DefaultInit->getExpr());
+}
+  }
+
+  bool TraverseBindingDecl(BindingDecl *BD) {
+// `RecursiveASTVisitor` doesn't traverse holding variables for

martinboehme wrote:

Interesting point!

This makes sense to me, but I expect that making this change to 
`RecursiveASTVisitor` would require followon changes elsewhere, so I'll handle 
this here for now. I've put this on my list of things to investigate.

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


[clang] [AArch64][PAC][clang][ELF] Support PAuth ABI core info (PR #85235)

2024-04-08 Thread Daniil Kovalev via cfe-commits

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


[clang] [Clang][Sema] Fix the lambda call expression inside of a type alias declaration (PR #82310)

2024-04-08 Thread Qizhi Hu via cfe-commits

jcsxky wrote:

Still crash on
```cpp
template constexpr auto x = F();
template constexpr int a() { return 1; }

template 
struct A {
using Func = decltype(
[](T) {
return x<[] constexpr { return a(); }>;
// return x<[] constexpr { return b(); }>;
}.template operator()('2')
);
};
A::Func y;
```

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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits


@@ -460,25 +460,35 @@ class TransferVisitor : public 
ConstStmtVisitor {
 // So make sure we have a value if we didn't propagate one above.
 if (S->isPRValue() && S->getType()->isRecordType()) {
   if (Env.getValue(*S) == nullptr) {
-Value *Val = Env.createValue(S->getType());
-// We're guaranteed to always be able to create a value for record
-// types.
-assert(Val != nullptr);
-Env.setValue(*S, *Val);
+auto &Loc = Env.getResultObjectLocation(*S);
+Env.initializeFieldsWithValues(Loc);
+refreshRecordValue(Loc, Env);
   }
 }
   }
 
   void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
 const Expr *InitExpr = S->getExpr();
 assert(InitExpr != nullptr);
-propagateValueOrStorageLocation(*InitExpr, *S, Env);
+if (!(S->getType()->isRecordType() && S->isPRValue()))
+  propagateValueOrStorageLocation(*InitExpr, *S, Env);
   }
 
   void VisitCXXConstructExpr(const CXXConstructExpr *S) {
 const CXXConstructorDecl *ConstructorDecl = S->getConstructor();
 assert(ConstructorDecl != nullptr);
 
+// `CXXConstructExpr` can have array type if default-initializing an array
+// of records. We don't handle this specifically beyond potentially 
inlining
+// the call.
+if (!S->getType()->isRecordType()) {
+  transferInlineCall(S, ConstructorDecl);
+  return;
+}
+
+RecordStorageLocation &Loc = Env.getResultObjectLocation(*S);

martinboehme wrote:

A `CXXConstructExpr` is always a prvalue, and any prvalue of record type has a 
result object location. This is simply the precondition of 
`getResultObjectLocation()`, so I'm not sure adding an extra comment here would 
have value?

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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits


@@ -688,71 +682,51 @@ class TransferVisitor : public 
ConstStmtVisitor {
   return;
 }
 
-llvm::DenseMap FieldLocs;
-RecordInitListHelper InitListHelper(S);
+RecordStorageLocation &Loc = Env.getResultObjectLocation(*S);
+Env.setValue(*S, refreshRecordValue(Loc, Env));
 
-for (auto [Base, Init] : InitListHelper.base_inits()) {
-  assert(Base->getType().getCanonicalType() ==
- Init->getType().getCanonicalType());
-  auto *BaseVal = Env.get(*Init);
-  if (!BaseVal)
-BaseVal = cast(Env.createValue(Init->getType()));
-  // Take ownership of the fields of the `RecordValue` for the base class
-  // and incorporate them into the "flattened" set of fields for the
-  // derived class.
-  auto Children = BaseVal->getLoc().children();
-  FieldLocs.insert(Children.begin(), Children.end());
-}
+// Initialization of base classes and fields of record type happens when we
+// visit the nested `CXXConstructExpr` or `InitListExpr` for that base 
class
+// or field. We therefore only need to deal with fields of non-record type
+// here.
 
-for (auto [Field, Init] : InitListHelper.field_inits()) {
-  assert(
-  // The types are same, or
-  Field->getType().getCanonicalType().getUnqualifiedType() ==
-  Init->getType().getCanonicalType().getUnqualifiedType() ||
-  // The field's type is T&, and initializer is T
-  (Field->getType()->isReferenceType() &&
-   Field->getType().getCanonicalType()->getPointeeType() ==
-   Init->getType().getCanonicalType()));
-  auto& Loc = Env.createObject(Field->getType(), Init);
-  FieldLocs.insert({Field, &Loc});
-}
+RecordInitListHelper InitListHelper(S);

martinboehme wrote:

I think you mean why is there _no_ handling of `base_inits()`?

This is explained in the comment above:

```cxx
// Initialization of base classes and fields of record type happens when we
// visit the nested `CXXConstructExpr` or `InitListExpr` for that base class
// or field. We therefore only need to deal with fields of non-record type
// here.
```

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


[clang] 2921a09 - Make the argument -Xcuda-ptxas visible to the driver in cl-mode

2024-04-08 Thread Luke Drummond via cfe-commits

Author: Jefferson Le Quellec
Date: 2024-04-08T14:11:43+01:00
New Revision: 2921a0928c71f4ee652a2478283e47ab5ffebf58

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

LOG: Make the argument -Xcuda-ptxas visible to the driver in cl-mode

It has been noticed that the arguments are being passed twice to ptxas.
This also has been fixed by filtering out the arguments before appending
them to the new DAL created by CudaToolChain::TranslateArgs.

github:https://github.com/llvm/llvm-project/pull/86807

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Cuda.cpp
clang/test/Driver/cuda-external-tools.cu

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 827d9d7c0c18e4..f745e573eb2686 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1003,7 +1003,8 @@ def : Joined<["-"], "Xclang=">, Group,
 def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">,
   HelpText<"Pass  to fatbinary invocation">, MetaVarName<"">;
 def Xcuda_ptxas : Separate<["-"], "Xcuda-ptxas">,
-  HelpText<"Pass  to the ptxas assembler">, MetaVarName<"">;
+  HelpText<"Pass  to the ptxas assembler">, MetaVarName<"">,
+  Visibility<[ClangOption, CLOption]>;
 def Xopenmp_target : Separate<["-"], "Xopenmp-target">, 
Group,
   HelpText<"Pass  to the target offloading toolchain.">, 
MetaVarName<"">;
 def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">, 
Group,

diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 5f0b516e1a1a08..6634e6d818b33e 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -990,7 +990,10 @@ CudaToolChain::TranslateArgs(const 
llvm::opt::DerivedArgList &Args,
   }
 
   for (Arg *A : Args) {
-DAL->append(A);
+// Make sure flags are not duplicated.
+if (!llvm::is_contained(*DAL, A)) {
+  DAL->append(A);
+}
   }
 
   if (!BoundArch.empty()) {

diff  --git a/clang/test/Driver/cuda-external-tools.cu 
b/clang/test/Driver/cuda-external-tools.cu
index 946e144fce38fb..d9564d026b4faa 100644
--- a/clang/test/Driver/cuda-external-tools.cu
+++ b/clang/test/Driver/cuda-external-tools.cu
@@ -86,6 +86,12 @@
 // RUN:   -Xcuda-fatbinary -bar1 -Xcuda-ptxas -foo2 -Xcuda-fatbinary -bar2 %s 
2>&1 \
 // RUN: | FileCheck -check-prefixes=CHECK,SM35,PTXAS-EXTRA,FATBINARY-EXTRA %s
 
+// Check -Xcuda-ptxas with clang-cl
+// RUN: %clang_cl -### -c -Xcuda-ptxas -foo1 \
+// RUN:   --offload-arch=sm_35 --cuda-path=%S/Inputs/CUDA/usr/local/cuda \
+// RUN:   -Xcuda-ptxas -foo2 %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,SM35,PTXAS-EXTRA %s
+
 // MacOS spot-checks
 // RUN: %clang -### --target=x86_64-apple-macosx -O0 -c %s 2>&1 \
 // RUN:   --offload-arch=sm_35 --cuda-path=%S/Inputs/CUDA/usr/local/cuda \
@@ -140,6 +146,8 @@
 // CHECK-SAME: "[[PTXFILE]]"
 // PTXAS-EXTRA-SAME: "-foo1"
 // PTXAS-EXTRA-SAME: "-foo2"
+// CHECK-NOT: "-foo1"
+// CHECK-NOT: "-foo2"
 // RDC-SAME: "-c"
 // CHECK-NOT: "-c"
 



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


[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-08 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

@erichkeane PR updated. 

When we encounter a class member access expression with a nested-name-specifier 
that is invalid, should we simply ignore it and instead use the type of the 
object expression as the lookup context? This is the current behavior, but it 
leads to lots of duplicate diagnostics. For example:
```cpp
struct A
{
using I = int;
};

void f(A* x)
{
x->I::z; // error: 'A::I' (aka 'int') is not a class, namespace, or 
enumeration
   // error: no member named 'z' in 'A'
}
```
IMO we should just return `ExprError` from `BuildMemberReferenceExpr` and thus 
not emit the second error.

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


[clang] [CLANG][DRIVER] Resolve Argument Visibility and Duplication Issue for Cuda ToolChain (PR #86807)

2024-04-08 Thread via cfe-commits

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


[clang] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (PR #87987)

2024-04-08 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/87987

This relands #87149.

The previous commit exposed failures on some targets. The reason is only a few 
targets support COFF ObjectFormatType on Windows: 
https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/Triple.cpp#L835-L842

With #87149, the targets don't support COFF will report "warning: argument 
unused during compilation: '-gcodeview-command-line' 
[-Wunused-command-line-argument]" in the test gcodeview-command-line.c

This patch limits gcodeview-command-line.c only run on targets support COFF.

>From 6d3dbfaa7c5fb6acb5e6cae70455567030c50cf8 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 8 Apr 2024 11:10:58 +0800
Subject: [PATCH 1/2] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only
 for COFF format (#87149)"

This reverts commit cd7517859eef14d8b38cec2d52c0625a58c645a2.
---
 clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
 clang/test/Misc/win32-elf.c| 5 +
 2 files changed, 7 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Misc/win32-elf.c

diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

>From a716712ee5fd797c47fecbe7a608675889917c77 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 8 Apr 2024 21:00:33 +0800
Subject: [PATCH 2/2] Linux gcodeview test for a few targets

---
 clang/test/Driver/gcodeview-command-line.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"

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


[clang] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (PR #87987)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Phoebe Wang (phoebewang)


Changes

This relands #87149.

The previous commit exposed failures on some targets. The reason is only a few 
targets support COFF ObjectFormatType on Windows: 
https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/Triple.cpp#L835-L842

With #87149, the targets don't support COFF will report "warning: 
argument unused during compilation: '-gcodeview-command-line' 
[-Wunused-command-line-argument]" in the test gcodeview-command-line.c

This patch limits gcodeview-command-line.c only run on targets support COFF.

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


3 Files Affected:

- (modified) clang/lib/Driver/ToolChains/MSVC.h (+2-3) 
- (modified) clang/test/Driver/gcodeview-command-line.c (+1) 
- (added) clang/test/Misc/win32-elf.c (+5) 


``diff
diff --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
   /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
   /// override the default.
   llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override 
{
-return getTriple().isOSBinFormatMachO()
-   ? llvm::codegenoptions::DIF_DWARF
-   : llvm::codegenoptions::DIF_CodeView;
+return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
+   : llvm::codegenoptions::DIF_DWARF;
   }
 
   /// Set the debugger tuning to "default", since we're definitely not tuning
diff --git a/clang/test/Driver/gcodeview-command-line.c 
b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
 
 // ON-NOT: "-gno-codview-commandline"
 // OFF: "-gno-codeview-command-line"
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -0,0 +1,5 @@
+// Check that basic use of win32-elf targets works.
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
+
+// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | 
FileCheck %s -check-prefix=DEBUG-INFO
+// DEBUG-INFO: -dwarf-version={{.*}}

``




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


[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format" (PR #87987)

2024-04-08 Thread Phoebe Wang via cfe-commits

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


[clang] Match against all plugins when parsing microsoft attributes (PR #86426)

2024-04-08 Thread Erich Keane via cfe-commits


@@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins
 Bug Fixes to Attribute Support
 ^^
 
+- Clang now correctly matches plugin attributes with microsoft ``[attribute]`` 
syntax.

erichkeane wrote:

> Microsoft attributes use single brackets, c++11 attributes use `[[]]`

Ah, woops!  I saw that later on and fixed it in my suggestion, but not the 
message above.  But please capitalize 'Microsoft' as suggested.

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


[clang] [clang] Introduce `SemaHLSL` (PR #87912)

2024-04-08 Thread Chris B via cfe-commits


@@ -0,0 +1,37 @@
+//===- SemaHLSL.h - Semantic Analysis for HLSL constructs 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// This file declares semantic analysis for HLSL constructs.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_SEMA_SEMAHLSL_H
+#define LLVM_CLANG_SEMA_SEMAHLSL_H
+
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaBase.h"
+
+namespace clang {
+
+class SemaHLSL : public SemaBase {
+public:
+  SemaHLSL(Sema &S);
+
+  Decl *ActOnStartHLSLBuffer(Scope *BufferScope, bool CBuffer,
+ SourceLocation KwLoc, IdentifierInfo *Ident,
+ SourceLocation IdentLoc, SourceLocation LBrace);
+  void ActOnFinishHLSLBuffer(Decl *Dcl, SourceLocation RBrace);

llvm-beanz wrote:

nit: Since we're moving these into a class that has HLSL in the name which is 
accessed through a method named `HLSL()` should we maybe remove HLSL from the 
method names?

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


[clang] [clang] Introduce `SemaHLSL` (PR #87912)

2024-04-08 Thread Chris B via cfe-commits

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

I really like this direction. Thank you for taking the initiative on cleaning 
Sema up!

I had one small comment below, but you can take it or leave it.

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


[clang] [clang] Introduce `SemaHLSL` (PR #87912)

2024-04-08 Thread Chris B via cfe-commits

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


[clang] Match against all plugins when parsing microsoft attributes (PR #86426)

2024-04-08 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 5d7fd6a04a6748936dece9d90481b2ba4ec97e53 
6ba913fb0d3efdb17ae481ccad63ccde2170d4e2 -- 
clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp 
clang/test/Frontend/ms-attributes.cpp clang/lib/Parse/ParseDeclCXX.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp 
b/clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp
index 571d6f8624..dd252f7d5b 100644
--- a/clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp
+++ b/clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp
@@ -25,34 +25,35 @@ using namespace clang;
 namespace {
 
 struct ExampleAttrInfo : public ParsedAttrInfo {
-ExampleAttrInfo() {
-// Can take up to 1 optional argument.
-OptArgs = 1;
-
-// Only Microsoft-style [ms_example] supported.
-// e.g.:
-// [ms_example] class C {};
-// [ms_example] void f() {}
-static constexpr Spelling S[] = {
-{ParsedAttr::AS_Microsoft, "ms_example"}
-};
-Spellings = S;
-}
-
-bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) 
const override {
-// This attribute can be applied to any declaration.
-if (!isa(D)) {
-S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
-<< Attr << Attr.isRegularKeywordAttribute() << "classes";
-}
-return true;
-}
-
-AttrHandling handleDeclAttribute(Sema &S, Decl *D, const ParsedAttr &Attr) 
const override {
-// Add an annotation to the declaration.
-D->addAttr(AnnotateAttr::Create(S.Context, "ms_example", nullptr, 0, 
Attr.getRange()));
-return AttributeApplied;
+  ExampleAttrInfo() {
+// Can take up to 1 optional argument.
+OptArgs = 1;
+
+// Only Microsoft-style [ms_example] supported.
+// e.g.:
+// [ms_example] class C {};
+// [ms_example] void f() {}
+static constexpr Spelling S[] = {{ParsedAttr::AS_Microsoft, "ms_example"}};
+Spellings = S;
+  }
+
+  bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr,
+const Decl *D) const override {
+// This attribute can be applied to any declaration.
+if (!isa(D)) {
+  S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
+  << Attr << Attr.isRegularKeywordAttribute() << "classes";
 }
+return true;
+  }
+
+  AttrHandling handleDeclAttribute(Sema &S, Decl *D,
+   const ParsedAttr &Attr) const override {
+// Add an annotation to the declaration.
+D->addAttr(AnnotateAttr::Create(S.Context, "ms_example", nullptr, 0,
+Attr.getRange()));
+return AttributeApplied;
+  }
 };
 
 } // namespace
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 619f7f88bf..b323f053c4 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -5064,8 +5064,8 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes 
&Attrs) {
 
 // For HLSL we want to handle all attributes, but for MSVC compat, we
 // silently ignore unknown Microsoft attributes.
-int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, 
nullptr,
-II, getTargetInfo(), getLangOpts());
+int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft,
+nullptr, II, getTargetInfo(), getLangOpts());
 if (getLangOpts().HLSL || Attr != 0) {
   bool AttrParsed = false;
   if (Tok.is(tok::l_paren)) {

``




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


[libclc] [llvm] [WIP] Libclc tests (PR #87989)

2024-04-08 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/87989

None

>From b87c2862491aed03f883d6b124a845b0d7c47699 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Wed, 3 Apr 2024 16:09:30 +0100
Subject: [PATCH 1/2] [libclc] Refactor build system to allow in-tree builds

The previous build system was adding custom "OpenCL" and "LLVM IR"
languages in CMake to build the builtin libraries. This was making it
harder to build in-tree because the tool binaries needed to be present
at configure time.

This commit refactors the build system to use custom commands to build
the bytecode files one by one, and link them all together into the final
bytecode library. It also enables in-tree builds by aliasing the
clang/llvm-link/etc. tool targets to internal targets, which are
imported from the LLVM installation directory when building out of tree.

Diffing (with llvm-diff) all of the final bytecode libraries in an
out-of-tree configuration against those built using the current tip
system shows no changes. Note that there are textual changes to metadata
IDs which confuse regular diff, and that llvm-diff 14 and below may show
false-positives.

This commit also removes a file listed in one of the SOURCEs which
didn't exist and which was preventing the use of
ENABLE_RUNTIME_SUBNORMAL when configuring CMake.
---
 libclc/CMakeLists.txt | 233 ++
 libclc/cmake/CMakeCLCCompiler.cmake.in|   9 -
 libclc/cmake/CMakeCLCInformation.cmake|  12 -
 libclc/cmake/CMakeDetermineCLCCompiler.cmake  |  18 --
 .../cmake/CMakeDetermineLLAsmCompiler.cmake   |  24 --
 libclc/cmake/CMakeLLAsmCompiler.cmake.in  |  10 -
 libclc/cmake/CMakeLLAsmInformation.cmake  |  12 -
 libclc/cmake/CMakeTestCLCCompiler.cmake   |  56 -
 libclc/cmake/CMakeTestLLAsmCompiler.cmake |  56 -
 libclc/cmake/modules/AddLibclc.cmake  | 153 
 libclc/generic/lib/SOURCES|   1 -
 llvm/tools/CMakeLists.txt |   3 +
 12 files changed, 293 insertions(+), 294 deletions(-)
 delete mode 100644 libclc/cmake/CMakeCLCCompiler.cmake.in
 delete mode 100644 libclc/cmake/CMakeCLCInformation.cmake
 delete mode 100644 libclc/cmake/CMakeDetermineCLCCompiler.cmake
 delete mode 100644 libclc/cmake/CMakeDetermineLLAsmCompiler.cmake
 delete mode 100644 libclc/cmake/CMakeLLAsmCompiler.cmake.in
 delete mode 100644 libclc/cmake/CMakeLLAsmInformation.cmake
 delete mode 100644 libclc/cmake/CMakeTestCLCCompiler.cmake
 delete mode 100644 libclc/cmake/CMakeTestLLAsmCompiler.cmake
 create mode 100644 libclc/cmake/modules/AddLibclc.cmake

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 8750a65a717f9b..e509a61f51b927 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -4,6 +4,15 @@ project( libclc VERSION 0.2.0 LANGUAGES CXX C)
 
 set(CMAKE_CXX_STANDARD 17)
 
+# Add path for custom modules
+list( INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake/modules" )
+
+set( LIBCLC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
+set( LIBCLC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
+set( LIBCLC_OBJFILE_DIR ${LIBCLC_BINARY_DIR}/obj.libclc.dir )
+
+include( AddLibclc )
+
 include( GNUInstallDirs )
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
   amdgcn-amdhsa/lib/SOURCES;
@@ -27,31 +36,51 @@ set( LIBCLC_TARGETS_TO_BUILD "all"
 
 option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal 
support." OFF )
 
-find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-include(AddLLVM)
+if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL 
CMAKE_CURRENT_SOURCE_DIR )
+  # Out-of-tree configuration
+  set( LIBCLC_STANDALONE_BUILD TRUE )
 
-message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" )
+  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
+  include(AddLLVM)
 
-if( LLVM_PACKAGE_VERSION VERSION_LESS LIBCLC_MIN_LLVM )
-  message( FATAL_ERROR "libclc needs at least LLVM ${LIBCLC_MIN_LLVM}" )
-endif()
+  message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" )
 
-find_program( LLVM_CLANG clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
-find_program( LLVM_AS llvm-as PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
-find_program( LLVM_LINK llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
-find_program( LLVM_OPT opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
-find_program( LLVM_SPIRV llvm-spirv PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
+  if( LLVM_PACKAGE_VERSION VERSION_LESS LIBCLC_MIN_LLVM )
+message( FATAL_ERROR "libclc needs at least LLVM ${LIBCLC_MIN_LLVM}" )
+  endif()
+
+  # Import required tools as targets
+  foreach( tool clang llvm-as llvm-link opt )
+find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
+add_executable( libclc::${tool} IMPORTED GLOBAL )
+set_target_properties( libclc::${tool} PROPERTIES IMPORTED_LOCATION 
${LLVM_TOOL_${tool}} )
+  endforeach()
+else()
+  # In-tree config

[libclc] [llvm] [WIP] Libclc tests (PR #87989)

2024-04-08 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
8461d901a770516cf2069fe3bce979a6f8fc8d76...29c9a184c11ed0ba46a8c91b6fbeea828c9fce0d
 libclc/test/lit.cfg.py
``





View the diff from darker here.


``diff
--- lit.cfg.py  2024-04-08 13:26:14.00 +
+++ lit.cfg.py  2024-04-08 13:29:55.745880 +
@@ -8,42 +8,47 @@
 from lit.llvm.subst import FindTool
 
 # Configuration file for the 'lit' test runner.
 
 # name: The name of this test suite.
-config.name = 'libclc'
+config.name = "libclc"
 
 # testFormat: The test format to use to interpret tests.
 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.cl', ]
+config.suffixes = [
+".cl",
+]
 
 # test_source_root: The root path where tests are located.
 config.test_source_root = os.path.join(os.path.dirname(__file__))
 
 # test_exec_root: The root path where tests should be run.
-config.test_exec_root = os.path.join(config.test_run_dir, 'test')
+config.test_exec_root = os.path.join(config.test_run_dir, "test")
 
 llvm_config.use_default_substitutions()
 
-target = lit_config.params.get('target', '')
-builtins = lit_config.params.get('builtins', '')
+target = lit_config.params.get("target", "")
+builtins = lit_config.params.get("builtins", "")
 
 clang_flags = [
-  "-fno-builtin",
-  "-target", target,
-  "-Xclang", "-mlink-builtin-bitcode",
-  "-Xclang", os.path.join(config.libclc_lib_dir, builtins),
-  "-nogpulib",
+"-fno-builtin",
+"-target",
+target,
+"-Xclang",
+"-mlink-builtin-bitcode",
+"-Xclang",
+os.path.join(config.libclc_lib_dir, builtins),
+"-nogpulib",
 ]
 
-cpu = lit_config.params.get('cpu', '')
+cpu = lit_config.params.get("cpu", "")
 if cpu:
 clang_flags.append(f"-mcpu={cpu}")
 
 llvm_config.use_clang(additional_flags=clang_flags)
 
-tools = ['llvm-dis', 'not']
+tools = ["llvm-dis", "not"]
 tool_dirs = [config.llvm_tools_dir]
 
 llvm_config.add_tool_substitutions(tools, tool_dirs)

``




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


[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-08 Thread Bhuminjay Soni via cfe-commits

11happy wrote:

Humble reminder! @PiotrZSL

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


[clang] [clang] Introduce `SemaHLSL` (PR #87912)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,37 @@
+//===- SemaHLSL.h - Semantic Analysis for HLSL constructs 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// This file declares semantic analysis for HLSL constructs.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_SEMA_SEMAHLSL_H
+#define LLVM_CLANG_SEMA_SEMAHLSL_H
+
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaBase.h"
+
+namespace clang {
+
+class SemaHLSL : public SemaBase {
+public:
+  SemaHLSL(Sema &S);
+
+  Decl *ActOnStartHLSLBuffer(Scope *BufferScope, bool CBuffer,
+ SourceLocation KwLoc, IdentifierInfo *Ident,
+ SourceLocation IdentLoc, SourceLocation LBrace);
+  void ActOnFinishHLSLBuffer(Decl *Dcl, SourceLocation RBrace);

Endilll wrote:

While `HLSL()` has to be used to access them from outside, it's not going to be 
there when accessed from within `SemaHLSL`. As I know very little about HLSL, I 
decided to leave the renaming to a subsequent PR.

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


[clang] 0e87366 - TextNodeDumper.cpp - remove empty switch to fix MSVC "switch statement contains 'default' but no 'case' labels" warning. NFC.

2024-04-08 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2024-04-08T14:31:46+01:00
New Revision: 0e8736694f752898ed7957a11a11c42f8f6a98d1

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

LOG: TextNodeDumper.cpp - remove empty switch to fix MSVC "switch statement 
contains 'default' but no 'case' labels" warning. NFC.

Added: 


Modified: 
clang/lib/AST/TextNodeDumper.cpp

Removed: 




diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 0ffbf47c9a2f4e..f498de6374348e 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -390,14 +390,6 @@ void TextNodeDumper::Visit(const OpenACCClause *C) {
   {
 ColorScope Color(OS, ShowColors, AttrColor);
 OS << C->getClauseKind();
-
-// Handle clauses with parens for types that have no children, likely
-// because there is no sub expression.
-switch (C->getClauseKind()) {
-default:
-  // Nothing to do here.
-  break;
-}
   }
   dumpPointer(C);
   dumpSourceRange(SourceRange(C->getBeginLoc(), C->getEndLoc()));



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


[clang] f139387 - Fix MSVC "not all control paths return a value" warning. NFC.

2024-04-08 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2024-04-08T14:31:46+01:00
New Revision: f139387fb6e76a5249e8d7c2d124565e6b566ef4

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

LOG: Fix MSVC "not all control paths return a value" warning. NFC.

Added: 


Modified: 
clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp

Removed: 




diff  --git a/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp 
b/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
index 1fa988f93bdd5c..cc252d51e3b677 100644
--- a/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
+++ b/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
@@ -81,8 +81,9 @@ const DiagnosticBuilder &operator<<(const DiagnosticBuilder 
&DB,
 return DB;
   case FileType::Invalid:
   case FileType::All:
-llvm_unreachable("Unexpected file type for diagnostics.");
+break;
   }
+  llvm_unreachable("Unexpected file type for diagnostics.");
 }
 
 const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,



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


[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-08 Thread Erich Keane via cfe-commits

erichkeane wrote:

> @erichkeane PR updated.
> 
> When we encounter a class member access expression with a 
> nested-name-specifier that is invalid, should we simply ignore it and instead 
> use the type of the object expression as the lookup context? This is the 
> current behavior, but it leads to lots of duplicate diagnostics. For example:
> 
> ```c++
> struct A
> {
> using I = int;
> };
> 
> void f(A* x)
> {
> x->I::z; // error: 'A::I' (aka 'int') is not a class, namespace, or 
> enumeration
>// error: no member named 'z' in 'A'
> }
> ```
> 
> IMO we should just return `ExprError` from `BuildMemberReferenceExpr` and 
> thus not emit the second error.

Sorry, I'm not really getting the question here.  Obviously that 2nd error is 
invalid and we shouldn't be emitting it, and doing the `::z` lookup inside of 
`A` seems wrong to me.  But I'm not sure I get the issue.

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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits

https://github.com/martinboehme updated 
https://github.com/llvm/llvm-project/pull/87320

>From 2d2aa88aab3e47e41588397471a90c03bb55d900 Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Tue, 2 Apr 2024 08:00:00 +
Subject: [PATCH 1/2] [clang][dataflow] Propagate locations from result objects
 to initializers.

Previously, we were propagating storage locations the other way around, i.e.
from initializers to result objects, using `RecordValue::getLoc()`. This gave
the wrong behavior in some cases -- see the newly added or fixed tests in this
patch.

In addition, this patch now unblocks removing the `RecordValue` class entirely,
as we no longer need `RecordValue::getLoc()`.

With this patch, the test `TransferTest.DifferentReferenceLocInJoin` started to
fail because the framework now always uses the same storge location for a
`MaterializeTemporaryExpr`, meaning that the code under test no longer set up
the desired state where a variable of reference type is mapped to two different
storage locations in environments being joined. Rather than trying to modify
this test to set up the test condition again, I have chosen to replace the test
with an equivalent test in DataflowEnvironmentTest.cpp that sets up the test
condition directly; because this test is more direct, it will also be less
brittle in the face of future changes.
---
 .../FlowSensitive/DataflowEnvironment.h   |  64 ++-
 .../FlowSensitive/DataflowEnvironment.cpp | 402 +-
 clang/lib/Analysis/FlowSensitive/Transfer.cpp | 172 
 .../TypeErasedDataflowAnalysis.cpp|  13 +-
 .../FlowSensitive/DataflowEnvironmentTest.cpp |  43 ++
 .../Analysis/FlowSensitive/TransferTest.cpp   | 172 +---
 6 files changed, 582 insertions(+), 284 deletions(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index c30bccd06674a4..dc3a9c239552be 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -30,6 +30,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
 #include 
 #include 
 
@@ -330,17 +331,6 @@ class Environment {
   /// location of the result object to pass in `this`, even though prvalues are
   /// otherwise not associated with storage locations.
   ///
-  /// FIXME: Currently, this simply returns a stable storage location for `E`,
-  /// but this doesn't do the right thing in scenarios like the following:
-  /// ```
-  /// MyClass c = some_condition()? MyClass(foo) : MyClass(bar);
-  /// ```
-  /// Here, `MyClass(foo)` and `MyClass(bar)` will have two different storage
-  /// locations, when in fact their storage locations should be the same.
-  /// Eventually, we want to propagate storage locations from result objects
-  /// down to the prvalues that initialize them, similar to the way that this 
is
-  /// done in Clang's CodeGen.
-  ///
   /// Requirements:
   ///  `E` must be a prvalue of record type.
   RecordStorageLocation &
@@ -448,7 +438,13 @@ class Environment {
   /// Initializes the fields (including synthetic fields) of `Loc` with values,
   /// unless values of the field type are not supported or we hit one of the
   /// limits at which we stop producing values.
-  void initializeFieldsWithValues(RecordStorageLocation &Loc);
+  /// If `Type` is provided, initializes only those fields that are modeled for
+  /// `Type`; this is intended for use in cases where `Loc` is a derived type
+  /// and we only want to initialize the fields of a base type.
+  void initializeFieldsWithValues(RecordStorageLocation &Loc, QualType Type);
+  void initializeFieldsWithValues(RecordStorageLocation &Loc) {
+initializeFieldsWithValues(Loc, Loc.getType());
+  }
 
   /// Assigns `Val` as the value of `Loc` in the environment.
   void setValue(const StorageLocation &Loc, Value &Val);
@@ -639,6 +635,9 @@ class Environment {
   LLVM_DUMP_METHOD void dump(raw_ostream &OS) const;
 
 private:
+  using PrValueToResultObject =
+  llvm::DenseMap;
+
   // The copy-constructor is for use in fork() only.
   Environment(const Environment &) = default;
 
@@ -668,8 +667,10 @@ class Environment {
   /// Initializes the fields (including synthetic fields) of `Loc` with values,
   /// unless values of the field type are not supported or we hit one of the
   /// limits at which we stop producing values (controlled by `Visited`,
-  /// `Depth`, and `CreatedValuesCount`).
-  void initializeFieldsWithValues(RecordStorageLocation &Loc,
+  /// `Depth`, and `CreatedValuesCount`). If `Type` is different from
+  /// `Loc.getType()`, initializes only those fields that are modeled for
+  /// `Type`.
+  void initializeFieldsWithValues(RecordStorageLocation &Loc, QualType Type,
   llvm::DenseSet &Visited, int Depth,
  

[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

2024-04-08 Thread Erich Keane via cfe-commits

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


[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

2024-04-08 Thread Erich Keane via cfe-commits

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


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


[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

2024-04-08 Thread Erich Keane via cfe-commits


@@ -268,17 +268,34 @@ class alignas(8) Decl {
   ///   }
   ///   void A::f(); // SemanticDC == namespace 'A'
   ///// LexicalDC == global namespace
-  llvm::PointerUnion DeclCtx;
+  llvm::PointerIntPair<

erichkeane wrote:

I don't think it ends up being 'manual bit twiddling' so much as 3 values in an 
enum, and I also found the `getPointer().getPointer()` pretty mind-bending, but 
at least it is somewhat well hidden in stuff we won't touch for a while, so I 
won't insist.

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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits


@@ -460,25 +460,35 @@ class TransferVisitor : public 
ConstStmtVisitor {
 // So make sure we have a value if we didn't propagate one above.
 if (S->isPRValue() && S->getType()->isRecordType()) {
   if (Env.getValue(*S) == nullptr) {
-Value *Val = Env.createValue(S->getType());
-// We're guaranteed to always be able to create a value for record
-// types.
-assert(Val != nullptr);
-Env.setValue(*S, *Val);
+auto &Loc = Env.getResultObjectLocation(*S);
+Env.initializeFieldsWithValues(Loc);
+refreshRecordValue(Loc, Env);
   }
 }
   }
 
   void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
 const Expr *InitExpr = S->getExpr();
 assert(InitExpr != nullptr);
-propagateValueOrStorageLocation(*InitExpr, *S, Env);
+if (!(S->getType()->isRecordType() && S->isPRValue()))

martinboehme wrote:

Done. While I'm here, converted this to an early-out (which then also aligns 
better with the comment).

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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits


@@ -385,6 +388,185 @@ getFieldsGlobalsAndFuncs(const Stmt &S, FieldSet &Fields,
   }
 }
 
+namespace {
+
+// Visitor that builds a map from record prvalues to result objects.
+// This traverses the body of the function to be analyzed; for each result
+// object that it encounters, it propagates the storage location of the result
+// object to all record prvalues that can initialize it.
+class ResultObjectVisitor : public RecursiveASTVisitor {
+public:
+  // `ResultObjectMap` will be filled with a map from record prvalues to result
+  // object. If the function being analyzed returns a record by value,
+  // `LocForRecordReturnVal` is the location to which this record should be
+  // written; otherwise, it is null.
+  explicit ResultObjectVisitor(
+  llvm::DenseMap &ResultObjectMap,
+  RecordStorageLocation *LocForRecordReturnVal,
+  DataflowAnalysisContext &DACtx)
+  : ResultObjectMap(ResultObjectMap),
+LocForRecordReturnVal(LocForRecordReturnVal), DACtx(DACtx) {}
+
+  bool shouldVisitImplicitCode() { return true; }
+
+  bool shouldVisitLambdaBody() const { return false; }
+
+  // Traverse all member and base initializers of `Ctor`. This function is not
+  // called by `RecursiveASTVisitor`; it should be called manually if we are
+  // analyzing a constructor. `ThisPointeeLoc` is the storage location that
+  // `this` points to.
+  void TraverseConstructorInits(const CXXConstructorDecl *Ctor,
+RecordStorageLocation *ThisPointeeLoc) {
+assert(ThisPointeeLoc != nullptr);
+for (const CXXCtorInitializer *Init : Ctor->inits()) {
+  Expr *InitExpr = Init->getInit();
+  if (FieldDecl *Field = Init->getMember();
+  Field != nullptr && Field->getType()->isRecordType()) {
+PropagateResultObject(InitExpr, cast(
+ThisPointeeLoc->getChild(*Field)));
+  } else if (Init->getBaseClass()) {
+PropagateResultObject(InitExpr, ThisPointeeLoc);
+  }
+
+  // Ensure that any result objects within `InitExpr` (e.g. temporaries)
+  // are also propagated to the prvalues that initialize them.
+  TraverseStmt(InitExpr);
+
+  // If this is a `CXXDefaultInitExpr`, also propagate any result objects
+  // within the default expression.
+  if (auto *DefaultInit = dyn_cast(InitExpr))
+TraverseStmt(DefaultInit->getExpr());
+}
+  }
+
+  bool TraverseBindingDecl(BindingDecl *BD) {
+// `RecursiveASTVisitor` doesn't traverse holding variables for
+// `BindingDecl`s by itself, so we need to tell it to.
+if (VarDecl *HoldingVar = BD->getHoldingVar())
+  TraverseDecl(HoldingVar);
+return RecursiveASTVisitor::TraverseBindingDecl(BD);
+  }
+
+  bool VisitVarDecl(VarDecl *VD) {
+if (VD->getType()->isRecordType() && VD->hasInit())
+  PropagateResultObject(
+  VD->getInit(),
+  &cast(DACtx.getStableStorageLocation(*VD)));
+return true;
+  }
+
+  bool VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *MTE) {
+if (MTE->getType()->isRecordType())
+  PropagateResultObject(
+  MTE->getSubExpr(),
+  &cast(DACtx.getStableStorageLocation(*MTE)));
+return true;
+  }
+
+  bool VisitReturnStmt(ReturnStmt *Return) {
+Expr *RetValue = Return->getRetValue();
+if (RetValue != nullptr && RetValue->getType()->isRecordType() &&
+RetValue->isPRValue())
+  PropagateResultObject(RetValue, LocForRecordReturnVal);
+return true;
+  }
+
+  bool VisitExpr(Expr *E) {
+// Clang's AST can have record-type prvalues without a result object -- for
+// example as full-expressions contained in a compound statement or as
+// arguments of call expressions. We notice this if we get here and a
+// storage location has not yet been associated with `E`. In this case,
+// treat this as if it was a `MaterializeTemporaryExpr`.
+if (E->isPRValue() && E->getType()->isRecordType() &&
+!ResultObjectMap.contains(E))
+  PropagateResultObject(
+  E, &cast(DACtx.getStableStorageLocation(*E)));
+return true;
+  }
+
+  // Assigns `Loc` as the result object location of `E`, then propagates the
+  // location to all lower-level prvalues that initialize the same object as
+  // `E` (or one of its base classes or member variables).
+  void PropagateResultObject(Expr *E, RecordStorageLocation *Loc) {
+if (!E->isPRValue() || !E->getType()->isRecordType()) {
+  assert(false);
+  // Ensure we don't propagate the result object if we hit this in a
+  // release build.
+  return;
+}
+
+ResultObjectMap[E] = Loc;
+
+// The following AST node kinds are "original initializers": They are the
+// lowest-level AST node that initializes a given object, and nothing
+// below them can initialize the same object (or part of it).
+if (isa(E) || isa(E) || isa(E) ||
+isa(E) || isa(E) ||
+isa(E)) {
+  return;
+}
+
+

[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-08 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

> Sorry, I'm not really getting the question here. Obviously that 2nd error is 
> invalid and we shouldn't be emitting it, and doing the `::z` lookup inside of 
> `A` seems wrong to me. But I'm not sure I get the issue.

We currently emit the second error. I'm asking if we shouldn't emit it (and 
your response suggests that we shouldn't)

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


[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

2024-04-08 Thread Piotr Zegar via cfe-commits

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

LGTM,
Would be good to run it on llvm or any other code base, and check what it found.

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


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits

martinboehme wrote:

I think all comments should be addressed.

@Xazax-hun Should be ready for further review.

@ymand LMK if you have any additional comments.

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


[clang] [clang-tools-extra] [clang-tidy][dataflow] Add `bugprone-null-check-after-dereference` check (PR #84166)

2024-04-08 Thread via cfe-commits


@@ -110,6 +110,12 @@ New checks
   Detects error-prone Curiously Recurring Template Pattern usage, when the CRTP
   can be constructed outside itself and the derived class.
 
+- New :doc:`bugprone-null-check-after-dereference
+  ` check.
+
+  This check identifies redundant pointer null-checks, by finding cases where

EugeneZelenko wrote:

Please omit `This check`.

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


[clang] [clang-tools-extra] [clang-tidy][dataflow] Add `bugprone-null-check-after-dereference` check (PR #84166)

2024-04-08 Thread via cfe-commits


@@ -217,34 +231,72 @@ void matchDereferenceExpr(const Stmt *stmt,
   Env.assume(Env.arena().makeNot(getVal(kIsNull, *RootValue).formula()));
 }
 
-void matchCastExpr(const CastExpr *cond, const MatchFinder::MatchResult 
&Result,
-   NullPointerAnalysisModel::TransferArgs &Data) {
-  auto [IsNonnullBranch, Env] = Data;
-
+void matchNullCheckExpr(const Expr *NullCheck,
+const MatchFinder::MatchResult &Result,
+Environment &Env) {
   const auto *Var = Result.Nodes.getNodeAs(kVar);
   assert(Var != nullptr);
 
-  Value *RootValue = getValue(*Var, Env);
-
-  Value *NewRootValue = Env.createValue(Var->getType());
+  // (bool)p or (p != nullptr)
+  bool IsNonnullOp = true;
+  if (auto *BinOp = dyn_cast(NullCheck);

EugeneZelenko wrote:

`
```suggestion
  if (const auto *BinOp = dyn_cast(NullCheck);
```

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


[libclc] [libclc] Fix a couple of issues preventing in-tree builds (PR #87505)

2024-04-08 Thread Michał Górny via cfe-commits

mgorny wrote:

Thanks. This seems to fix that problem. However, now I'm seeing missing dep in 
build ordering:

```
[1793/1922] cd /tmp/portage/dev-libs/libclc-19.0.0./work/libclc_build && 
/usr/lib/llvm/17/bin/llvm-spirv --spirv-max-version=1.1 -o spirv-mesa3d-.spv 
builtins.opt.spirv-mesa3d-.bc
FAILED: spirv-mesa3d-.spv 
/tmp/portage/dev-libs/libclc-19.0.0./work/libclc_build/spirv-mesa3d-.spv 
cd /tmp/portage/dev-libs/libclc-19.0.0./work/libclc_build && 
/usr/lib/llvm/17/bin/llvm-spirv --spirv-max-version=1.1 -o spirv-mesa3d-.spv 
builtins.opt.spirv-mesa3d-.bc
No such file or directory
[1794/1922] /usr/lib/llvm/17/bin/clang -DCLC_SPIRV64 -D__CLC_INTERNAL 
-I/usr/lib/llvm/17/include 
-I/tmp/portage/dev-libs/libclc-19.0.0./work/libclc/generic/include 
-cl-no-stdinc -target spir64-- -fno-builtin -nostdlib -O0 
-finline-hint-functions -I 
/tmp/portage/dev-libs/libclc-19.0.0./work/libclc/generic/lib/shared -MD -MT 
CMakeFiles/builtins.link.spirv64-mesa3d-.dir/generic/lib/shared/vload.bc -MF 
CMakeFiles/builtins.link.spirv64-mesa3d-.dir/generic/lib/shared/vload.bc.d -o 
CMakeFiles/builtins.link.spirv64-mesa3d-.dir/generic/lib/shared/vload.bc -c 
/tmp/portage/dev-libs/libclc-19.0.0./work/libclc/generic/lib/shared/vload.cl
 -emit-llvm
[1795/1922] cd /tmp/portage/dev-libs/libclc-19.0.0./work/libclc_build && 
/usr/lib/llvm/17/bin/opt -o builtins.opt.spirv-mesa3d-.bc 
/tmp/portage/dev-libs/libclc-19.0.0./work/libclc_build/builtins.link.spirv-mesa3d-.bc
```

Note that `builtins.link.spirv-mesa3d-.bc` is generated in step 1795, while 
it's used in 1793. Not sure if it's related, but I've never seen that one 
before.

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


[clang] [OpenACC] Implement Sema work for OpenACC Clauses (PR #87821)

2024-04-08 Thread Erich Keane via cfe-commits

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

>From ca5f957bb002d79997e630cdf1aaad5703ea2ba4 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Fri, 5 Apr 2024 10:53:47 -0700
Subject: [PATCH 1/2] [OpenACC] Implement Sema work for OpenACC Clauses

Now that we have AST nodes for OpenACC Clauses, this patch adds their
creation to Sema and makes the Parser call all the required functions.
This also redoes TreeTransform to work with the clauses/make sure they
are transformed.

Much of this is NFC, since there is no clause we can test this behavior
with.  However, there IS one noticable change; we are now no longer
diagnosing that a clause is 'not implemented' unless it there was no
errors parsing its parameters.  This is because it cleans up how we
create and diagnose clauses.
---
 .../clang/Basic/DiagnosticSemaKinds.td|   2 +
 clang/include/clang/Parse/Parser.h|  34 +-
 clang/include/clang/Sema/SemaOpenACC.h|  39 +-
 clang/lib/Parse/ParseOpenACC.cpp  | 142 +++--
 clang/lib/Sema/SemaOpenACC.cpp|  69 ++-
 clang/lib/Sema/TreeTransform.h|  79 ++-
 clang/test/ParserOpenACC/parse-clauses.c  | 573 +++---
 clang/test/ParserOpenACC/parse-clauses.cpp|   9 +-
 clang/test/ParserOpenACC/parse-wait-clause.c  | 102 ++--
 9 files changed, 540 insertions(+), 509 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index df57f5e6ce11ba..238931770da3a2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12252,6 +12252,8 @@ def warn_acc_clause_unimplemented
 def err_acc_construct_appertainment
 : Error<"OpenACC construct '%0' cannot be used here; it can only "
 "be used in a statement context">;
+def err_acc_clause_appertainment
+: Error<"OpenACC '%1' clause not valid on '%0' directive">;
 def err_acc_branch_in_out_compute_construct
 : Error<"invalid %select{branch|return|throw}0 %select{out of|into}1 "
 "OpenACC Compute Construct">;
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 580bf2a5d79df5..8bc929b1dfe4bb 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -41,6 +41,7 @@ namespace clang {
   class InMessageExpressionRAIIObject;
   class PoisonSEHIdentifiersRAIIObject;
   class OMPClause;
+  class OpenACCClause;
   class ObjCTypeParamList;
   struct OMPTraitProperty;
   struct OMPTraitSelector;
@@ -3594,11 +3595,26 @@ class Parser : public CodeCompletionHandler {
 OpenACCDirectiveKind DirKind;
 SourceLocation StartLoc;
 SourceLocation EndLoc;
-// TODO OpenACC: Add Clause list here once we have a type for that.
+SmallVector Clauses;
 // 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.
   };
 
+  /// Represents the 'error' state of parsing an OpenACC Clause, and stores
+  /// whether we can continue parsing, or should give up on the directive.
+  enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
+
+  /// A type to represent the state of parsing an OpenACC Clause. Situations
+  /// that result in an OpenACCClause pointer are a success and can continue
+  /// parsing, however some other situations can also continue.
+  /// FIXME: This is better represented as a std::expected when we get C++23.
+  using OpenACCClauseParseResult =
+  llvm::PointerIntPair;
+
+  OpenACCClauseParseResult OpenACCCanContinue();
+  OpenACCClauseParseResult OpenACCCannotContinue();
+  OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
+
   /// Parses the OpenACC directive (the entire pragma) including the clause
   /// list, but does not produce the main AST node.
   OpenACCDirectiveParseInfo ParseOpenACCDirective();
@@ -3613,12 +3629,18 @@ class Parser : public CodeCompletionHandler {
   bool ParseOpenACCClauseVarList(OpenACCClauseKind Kind);
   /// Parses any parameters for an OpenACC Clause, including required/optional
   /// parens.
-  bool ParseOpenACCClauseParams(OpenACCDirectiveKind DirKind,
-OpenACCClauseKind Kind);
-  /// Parses a single clause in a clause-list for OpenACC.
-  bool ParseOpenACCClause(OpenACCDirectiveKind DirKind);
+  OpenACCClauseParseResult
+  ParseOpenACCClauseParams(ArrayRef ExistingClauses,
+   OpenACCDirectiveKind DirKind, OpenACCClauseKind 
Kind,
+   SourceLocation ClauseLoc);
+  /// Parses a single clause in a clause-list for OpenACC. Returns nullptr on
+  /// error.
+  OpenACCClauseParseResult
+  ParseOpenACCClause(ArrayRef ExistingClauses,
+ OpenACCDirectiveKind DirKind);
   /// Parses the clause-list for an OpenACC directive.
-  void ParseOpenACCClauseList(OpenACCDirectiveKind

[clang] [OpenACC] Implement Sema work for OpenACC Clauses (PR #87821)

2024-04-08 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 f6357bb4283e72d1248b9c7eb67d98bea71d5f50 
27da3822961873340af021a5cbf136a155b5f110 -- clang/include/clang/Parse/Parser.h 
clang/include/clang/Sema/SemaOpenACC.h clang/lib/Parse/ParseOpenACC.cpp 
clang/lib/Sema/SemaOpenACC.cpp clang/lib/Sema/TreeTransform.h 
clang/test/ParserOpenACC/parse-clauses.c 
clang/test/ParserOpenACC/parse-clauses.cpp 
clang/test/ParserOpenACC/parse-wait-clause.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Sema/SemaOpenACC.h 
b/clang/include/clang/Sema/SemaOpenACC.h
index bd27418e4c..f6db366572 100644
--- a/clang/include/clang/Sema/SemaOpenACC.h
+++ b/clang/include/clang/Sema/SemaOpenACC.h
@@ -21,7 +21,7 @@
 #include "clang/Sema/SemaBase.h"
 
 namespace clang {
-  class OpenACCClause;
+class OpenACCClause;
 
 class SemaOpenACC : public SemaBase {
 public:

``




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


[libclc] [libclc] Fix a couple of issues preventing in-tree builds (PR #87505)

2024-04-08 Thread Michał Górny via cfe-commits

mgorny wrote:

```
  set( spv_suffix ${arch_suffix}.spv )
  add_custom_command( OUTPUT "${spv_suffix}"
COMMAND ${LLVM_SPIRV} ${spvflags} -o "${spv_suffix}" 
${builtins_opt_lib_tgt}
DEPENDS ${builtins_link_lib_tgt} )
```

I think that ought to be `DEPENDS ${builtins_opt_lib_tgt}`. Do you need me to 
send a PR for that?

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


[clang] [OpenACC] Implement Sema work for OpenACC Clauses (PR #87821)

2024-04-08 Thread Alexey Bataev via cfe-commits


@@ -37,6 +37,32 @@ bool diagnoseConstructAppertainment(SemaOpenACC &S, 
OpenACCDirectiveKind K,
   }
   return false;
 }
+
+bool doesClauseApplyToDirective(OpenACCDirectiveKind DirectiveKind,
+OpenACCClauseKind ClauseKind) {
+  switch (ClauseKind) {
+// FIXME: For each clause as we implement them, we can add the
+// 'legalization' list here.
+  default:
+// Do nothing so we can go to the 'unimplemented' diagnostic instead.
+return true;
+  }
+  llvm_unreachable("Invalid clause kind");
+}
+
+/// Destruct and deallocate any clauses that aren't going to be used because
+/// they don't have a Construct to attach to.
+void DestroyUnusedClauses(ASTContext &Ctx,

alexey-bataev wrote:

Why do you need to delete unused clauses? Maybe just keep them unused and just 
ignore?

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


[clang] [OpenACC] Implement Sema work for OpenACC Clauses (PR #87821)

2024-04-08 Thread Alexey Bataev via cfe-commits


@@ -82,22 +119,22 @@ bool 
SemaOpenACC::ActOnStartStmtDirective(OpenACCDirectiveKind K,
   return diagnoseConstructAppertainment(*this, K, StartLoc, /*IsStmt=*/true);
 }
 
-StmtResult SemaOpenACC::ActOnEndStmtDirective(OpenACCDirectiveKind K,
-  SourceLocation StartLoc,
-  SourceLocation EndLoc,
-  StmtResult AssocStmt) {
+StmtResult SemaOpenACC::ActOnEndStmtDirective(
+OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation EndLoc,
+MutableArrayRef Clauses, StmtResult AssocStmt) {

alexey-bataev wrote:

```suggestion
ArrayRef Clauses, StmtResult AssocStmt) {
```

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


  1   2   3   4   >