[PATCH] D147909: [clang] Implement CWG 2397

2023-04-11 Thread Younan Zhang via Phabricator via cfe-commits
zyounan added a comment.

Thank you for the suggestion and I've updated my patch. :)




Comment at: clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/cwg2397.cpp:11
+}
+
+void g() {

aaron.ballman wrote:
> I think it'd be good to also show a constexpr test, like:
> ```
> constexpr int foo() {
>   int a[] = { 1, 2, 3 };
>   auto ()[3] = a;
> 
>   return c[2];
> }
> 
> static_assert(foo() == 3, "");
> ```
> to prove that we actually perform the assignment properly, not just figure 
> out the deduced type correctly.
Indeed. I will enable it only with C++14 or later. (I didn't come up a way to 
get around the restriction for C++11, though.)



Comment at: clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp:5
   int b[5];
-  auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}}
-  auto *c[5] = b; // expected-error{{'c' declared as array of 'auto *'}}
+  auto a[5] = b; // expected-error{{variable 'a' with type 'auto[5]' has 
incompatible initializer of type 'int[5]'}}
+  auto *c[5] = b; // expected-error{{variable 'c' with type 'auto *[5]' has 
incompatible initializer of type 'int[5]'}}

aaron.ballman wrote:
> I've seen worse diagnostics, but the phrasing here is interesting -- if you 
> use `int a[5] = b;` instead of `auto`, you get `array initializer must be an 
> initializer list` as a diagnostic, so I wonder why we're getting such a 
> drastically different diagnostic for `auto`. Same for the diagnostic below.
You're right that such diagnostic looks a bit strange but FYI, GCC now emits 
diagnostic like so:
```
auto a[5] = b; // error: unable to deduce 'auto [5]' from 'b'
int c[5] = b;  // error: array must be initialized with a brace-enclosed 
initializer
```
I agree that what we expect here is to emit messages just like `int a[5] = b;` 
would produce with respect to better understandability, however, the 
`err_auto_var_deduction_failure` error is actually emitted due to type 
deduction failure, whereas `err_array_init_not_init_list` would be produced 
**later** by initialization error IIUC. So, IMHO such message makes sence as 
per what standard says, that for each type `P`, after being substituted with 
deduced `A`, shall be **compatible** with type `A`. 
[temp.deduct.type/1](https://eel.is/c++draft/temp.deduct.type#1.sentence-1)

// Feel free to correct me if I'm wrong :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147909/new/

https://reviews.llvm.org/D147909

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


[PATCH] D147909: [clang] Implement CWG 2397

2023-04-11 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 512656.
zyounan marked an inline comment as done.
zyounan added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147909/new/

https://reviews.llvm.org/D147909

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/cwg2397.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
  clang/test/CXX/drs/dr23xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -14189,7 +14189,7 @@
 https://wg21.link/cwg2397;>2397
 CD6
 auto specifier for pointers and references to arrays
-Unknown
+Clang 17
   
   
 https://wg21.link/cwg2398;>2398
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -197,3 +197,14 @@
   // void g(A a) { a.operator decltype(B()) B::*(); }
   // void g2(A a) { a.operator B decltype(B())::*(); }
 }
+
+#if __cplusplus >= 201103L
+namespace dr2397 { // dr2397: 17
+  void foo() {
+int a[5];
+
+auto ()[5] = a;
+auto (*c)[5] = 
+  }
+} // namespace dr2397
+#endif
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
@@ -2,6 +2,6 @@
 
 void f() {
   int b[5];
-  auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}}
-  auto *c[5] = b; // expected-error{{'c' declared as array of 'auto *'}}
+  auto a[5] = b; // expected-error{{variable 'a' with type 'auto[5]' has incompatible initializer of type 'int[5]'}}
+  auto *c[5] = b; // expected-error{{variable 'c' with type 'auto *[5]' has incompatible initializer of type 'int[5]'}}
 }
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/cwg2397.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/cwg2397.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
+
+void f() {
+  int a[5];
+  auto (*b)[5] = 
+  auto ()[5] = a;
+  auto (&)[5] = static_cast(a);
+  auto e[] = {0}; // expected-error{{cannot deduce actual type for variable 'e' with type 'auto[]' from initializer list}}
+  static_assert(__is_same(decltype(b), int (*)[5]), "");
+  static_assert(__is_same(decltype(c), int (&)[5]), "");
+  static_assert(__is_same(decltype(d), int (&&)[5]), "");
+}
+
+#if __cplusplus >= 201402L
+
+constexpr int g() {
+  int a[] = {1, 2, 3};
+  auto ()[3] = a;
+  return b[1];
+}
+
+static_assert(g() == 2, "");
+
+#endif
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5130,17 +5130,6 @@
   D.setInvalidType(true);
 }
   }
-  const AutoType *AT = T->getContainedAutoType();
-  // Allow arrays of auto if we are a generic lambda parameter.
-  // i.e. [](auto ()[5]) { return array[0]; }; OK
-  if (AT && D.getContext() != DeclaratorContext::LambdaExprParameter) {
-// We've already diagnosed this for decltype(auto).
-if (!AT->isDecltypeAuto())
-  S.Diag(DeclType.Loc, diag::err_illegal_decl_array_of_auto)
-  << getPrintableNameForEntity(Name) << T;
-T = QualType();
-break;
-  }
 
   // Array parameters can be marked nullable as well, although it's not
   // necessary if they're marked 'static'.
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2314,8 +2314,6 @@
 def err_binding_cannot_appear_in_own_initializer : Error<
   "binding %0 cannot appear in the initializer of its own "
   "decomposition declaration">;
-def err_illegal_decl_array_of_auto : Error<
-  "'%0' declared as array of %1">;
 def err_new_array_of_auto : Error<
   "cannot allocate array of 'auto'">;
 def err_auto_not_allowed : Error<
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -103,6 +103,8 @@
 
 Resolutions to C++ Defect Reports
 ^
+- Implemented `DR2397 `_ which allows ``auto`` specifier for pointers
+  and reference to arrays.
 
 C Language Changes
 --
___
cfe-commits 

[PATCH] D148066: [RISCV] Add Smaia and Ssaia extensions support

2023-04-11 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 512655.
4vtomat added a comment.

Resolved Kito's comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148066/new/

https://reviews.llvm.org/D148066

Files:
  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/RISCVSystemOperands.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/hypervisor-csr-names.s
  llvm/test/MC/RISCV/machine-csr-names.s
  llvm/test/MC/RISCV/rv32-hypervisor-csr-names.s
  llvm/test/MC/RISCV/rv32-machine-csr-names.s
  llvm/test/MC/RISCV/rv32-only-csr-names.s
  llvm/test/MC/RISCV/rv32-supervisor-csr-names.s
  llvm/test/MC/RISCV/rvi-aliases-valid.s
  llvm/test/MC/RISCV/supervisor-csr-names.s

Index: llvm/test/MC/RISCV/supervisor-csr-names.s
===
--- llvm/test/MC/RISCV/supervisor-csr-names.s
+++ llvm/test/MC/RISCV/supervisor-csr-names.s
@@ -319,3 +319,63 @@
 csrrs t1, sstateen3, zero
 # uimm12
 csrrs t2, 0x10F, zero
+
+#
+# Advanced Interrupt Architecture (Smaia and Ssaia)
+#
+
+# siselect
+# name
+# CHECK-INST: csrrs t1, siselect, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x00,0x15]
+# CHECK-INST-ALIAS: csrr t1, siselect
+# uimm12
+# CHECK-INST: csrrs t2, siselect, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x00,0x15]
+# CHECK-INST-ALIAS: csrr t2, siselect
+# name
+csrrs t1, siselect, zero
+# uimm12
+csrrs t2, 0x150, zero
+
+# sireg
+# name
+# CHECK-INST: csrrs t1, sireg, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x10,0x15]
+# CHECK-INST-ALIAS: csrr t1, sireg
+# uimm12
+# CHECK-INST: csrrs t2, sireg, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x10,0x15]
+# CHECK-INST-ALIAS: csrr t2, sireg
+# name
+csrrs t1, sireg, zero
+# uimm12
+csrrs t2, 0x151, zero
+
+# stopei
+# name
+# CHECK-INST: csrrs t1, stopei, zero
+# CHECK-ENC: encoding: [0x73,0x23,0xc0,0x15]
+# CHECK-INST-ALIAS: csrr t1, stopei
+# uimm12
+# CHECK-INST: csrrs t2, stopei, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0xc0,0x15]
+# CHECK-INST-ALIAS: csrr t2, stopei
+# name
+csrrs t1, stopei, zero
+# uimm12
+csrrs t2, 0x15C, zero
+
+# stopi
+# name
+# CHECK-INST: csrrs t1, stopi, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x00,0xdb]
+# CHECK-INST-ALIAS: csrr t1, stopi
+# uimm12
+# CHECK-INST: csrrs t2, stopi, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x00,0xdb]
+# CHECK-INST-ALIAS: csrr t2, stopi
+# name
+csrrs t1, stopi, zero
+# uimm12
+csrrs t2, 0xDB0, zero
Index: llvm/test/MC/RISCV/rvi-aliases-valid.s
===
--- llvm/test/MC/RISCV/rvi-aliases-valid.s
+++ llvm/test/MC/RISCV/rvi-aliases-valid.s
@@ -207,8 +207,8 @@
 # CHECK-S-OBJ: rdtime s9
 rdtime x25
 
-# CHECK-S-OBJ-NOALIAS: csrrs  s0, 336, zero
-# CHECK-S-OBJ: csrr s0, 336
+# CHECK-S-OBJ-NOALIAS: csrrs s0, siselect, zero
+# CHECK-S-OBJ: csrr s0, siselect
 csrr x8, 0x150
 # CHECK-S-OBJ-NOALIAS: csrrw zero, sscratch, s1
 # CHECK-S-OBJ: csrw sscratch, s1
@@ -220,8 +220,8 @@
 # CHECK-S-OBJ: csrc 4095, s7
 csrc 0xfff, x23
 
-# CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 15
-# CHECK-S-OBJ: csrwi 336, 15
+# CHECK-S-OBJ-NOALIAS: csrrwi zero, siselect, 15
+# CHECK-S-OBJ: csrwi siselect, 15
 csrwi 0x150, 0xf
 # CHECK-S-OBJ-NOALIAS: csrrsi zero, 4095, 16
 # CHECK-S-OBJ: csrsi 4095, 16
@@ -230,18 +230,18 @@
 # CHECK-S-OBJ: csrci sscratch, 17
 csrci 0x140, 0x11
 
-# CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 7
-# CHECK-S-OBJ: csrwi 336, 7
+# CHECK-S-OBJ-NOALIAS: csrrwi zero, siselect, 7
+# CHECK-S-OBJ: csrwi siselect, 7
 csrw 0x150, 7
-# CHECK-S-OBJ-NOALIAS: csrrsi zero, 336, 7
-# CHECK-S-OBJ: csrsi 336, 7
+# CHECK-S-OBJ-NOALIAS: csrrsi zero, siselect, 7
+# CHECK-S-OBJ: csrsi siselect, 7
 csrs 0x150, 7
-# CHECK-S-OBJ-NOALIAS: csrrci zero, 336, 7
-# CHECK-S-OBJ: csrci 336, 7
+# CHECK-S-OBJ-NOALIAS: csrrci zero, siselect, 7
+# CHECK-S-OBJ: csrci siselect, 7
 csrc 0x150, 7
 
-# CHECK-S-OBJ-NOALIAS: csrrwi t0, 336, 15
-# CHECK-S-OBJ: csrrwi t0, 336, 15
+# CHECK-S-OBJ-NOALIAS: csrrwi t0, siselect, 15
+# CHECK-S-OBJ: csrrwi t0, siselect, 15
 csrrw t0, 0x150, 0xf
 # CHECK-S-OBJ-NOALIAS: csrrsi t0, 4095, 16
 # CHECK-S-OBJ: csrrsi t0, 4095, 16
Index: llvm/test/MC/RISCV/rv32-supervisor-csr-names.s
===
--- llvm/test/MC/RISCV/rv32-supervisor-csr-names.s
+++ llvm/test/MC/RISCV/rv32-supervisor-csr-names.s
@@ -21,3 +21,35 @@
 csrrs t1, stimecmph, zero
 # uimm12
 csrrs t2, 0x15D, zero
+
+#
+# Advanced Interrupt Architecture (Smaia and Ssaia)
+#
+
+# sieh
+# name
+# CHECK-INST: csrrs t1, sieh, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x40,0x11]
+# CHECK-INST-ALIAS: csrr t1, sieh
+# uimm12
+# CHECK-INST: csrrs t2, sieh, zero
+# 

[PATCH] D148066: [RISCV] Add Smaia and Ssaia extensions support

2023-04-11 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

You need to update `llvm/docs/RISCVUsage.rst` too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148066/new/

https://reviews.llvm.org/D148066

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


[PATCH] D148066: [RISCV] Add Smaia and Ssaia extensions support

2023-04-11 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
jdoerfert, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, 
psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

This patch implements 1.0-RC3:
https://github.com/riscv/riscv-aia/releases/download/1.0-RC3/riscv-interrupts-1.0-RC3.pdf


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148066

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVSystemOperands.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/hypervisor-csr-names.s
  llvm/test/MC/RISCV/machine-csr-names.s
  llvm/test/MC/RISCV/rv32-hypervisor-csr-names.s
  llvm/test/MC/RISCV/rv32-machine-csr-names.s
  llvm/test/MC/RISCV/rv32-only-csr-names.s
  llvm/test/MC/RISCV/rv32-supervisor-csr-names.s
  llvm/test/MC/RISCV/rvi-aliases-valid.s
  llvm/test/MC/RISCV/supervisor-csr-names.s

Index: llvm/test/MC/RISCV/supervisor-csr-names.s
===
--- llvm/test/MC/RISCV/supervisor-csr-names.s
+++ llvm/test/MC/RISCV/supervisor-csr-names.s
@@ -319,3 +319,63 @@
 csrrs t1, sstateen3, zero
 # uimm12
 csrrs t2, 0x10F, zero
+
+#
+# Advanced Interrupt Architecture (Smaia and Ssaia)
+#
+
+# siselect
+# name
+# CHECK-INST: csrrs t1, siselect, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x00,0x15]
+# CHECK-INST-ALIAS: csrr t1, siselect
+# uimm12
+# CHECK-INST: csrrs t2, siselect, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x00,0x15]
+# CHECK-INST-ALIAS: csrr t2, siselect
+# name
+csrrs t1, siselect, zero
+# uimm12
+csrrs t2, 0x150, zero
+
+# sireg
+# name
+# CHECK-INST: csrrs t1, sireg, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x10,0x15]
+# CHECK-INST-ALIAS: csrr t1, sireg
+# uimm12
+# CHECK-INST: csrrs t2, sireg, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x10,0x15]
+# CHECK-INST-ALIAS: csrr t2, sireg
+# name
+csrrs t1, sireg, zero
+# uimm12
+csrrs t2, 0x151, zero
+
+# stopei
+# name
+# CHECK-INST: csrrs t1, stopei, zero
+# CHECK-ENC: encoding: [0x73,0x23,0xc0,0x15]
+# CHECK-INST-ALIAS: csrr t1, stopei
+# uimm12
+# CHECK-INST: csrrs t2, stopei, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0xc0,0x15]
+# CHECK-INST-ALIAS: csrr t2, stopei
+# name
+csrrs t1, stopei, zero
+# uimm12
+csrrs t2, 0x15C, zero
+
+# stopi
+# name
+# CHECK-INST: csrrs t1, stopi, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x00,0xdb]
+# CHECK-INST-ALIAS: csrr t1, stopi
+# uimm12
+# CHECK-INST: csrrs t2, stopi, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x00,0xdb]
+# CHECK-INST-ALIAS: csrr t2, stopi
+# name
+csrrs t1, stopi, zero
+# uimm12
+csrrs t2, 0xDB0, zero
Index: llvm/test/MC/RISCV/rvi-aliases-valid.s
===
--- llvm/test/MC/RISCV/rvi-aliases-valid.s
+++ llvm/test/MC/RISCV/rvi-aliases-valid.s
@@ -207,8 +207,8 @@
 # CHECK-S-OBJ: rdtime s9
 rdtime x25
 
-# CHECK-S-OBJ-NOALIAS: csrrs  s0, 336, zero
-# CHECK-S-OBJ: csrr s0, 336
+# CHECK-S-OBJ-NOALIAS: csrrs s0, siselect, zero
+# CHECK-S-OBJ: csrr s0, siselect
 csrr x8, 0x150
 # CHECK-S-OBJ-NOALIAS: csrrw zero, sscratch, s1
 # CHECK-S-OBJ: csrw sscratch, s1
@@ -220,8 +220,8 @@
 # CHECK-S-OBJ: csrc 4095, s7
 csrc 0xfff, x23
 
-# CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 15
-# CHECK-S-OBJ: csrwi 336, 15
+# CHECK-S-OBJ-NOALIAS: csrrwi zero, siselect, 15
+# CHECK-S-OBJ: csrwi siselect, 15
 csrwi 0x150, 0xf
 # CHECK-S-OBJ-NOALIAS: csrrsi zero, 4095, 16
 # CHECK-S-OBJ: csrsi 4095, 16
@@ -230,18 +230,18 @@
 # CHECK-S-OBJ: csrci sscratch, 17
 csrci 0x140, 0x11
 
-# CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 7
-# CHECK-S-OBJ: csrwi 336, 7
+# CHECK-S-OBJ-NOALIAS: csrrwi zero, siselect, 7
+# CHECK-S-OBJ: csrwi siselect, 7
 csrw 0x150, 7
-# CHECK-S-OBJ-NOALIAS: csrrsi zero, 336, 7
-# CHECK-S-OBJ: csrsi 336, 7
+# CHECK-S-OBJ-NOALIAS: csrrsi zero, siselect, 7
+# CHECK-S-OBJ: csrsi siselect, 7
 csrs 0x150, 7
-# CHECK-S-OBJ-NOALIAS: csrrci zero, 336, 7
-# CHECK-S-OBJ: csrci 336, 7
+# CHECK-S-OBJ-NOALIAS: csrrci zero, siselect, 7
+# CHECK-S-OBJ: csrci siselect, 7
 csrc 0x150, 7
 
-# CHECK-S-OBJ-NOALIAS: csrrwi t0, 336, 15
-# CHECK-S-OBJ: csrrwi t0, 336, 15
+# CHECK-S-OBJ-NOALIAS: csrrwi t0, siselect, 15
+# CHECK-S-OBJ: csrrwi t0, siselect, 15
 csrrw t0, 0x150, 0xf
 # CHECK-S-OBJ-NOALIAS: csrrsi t0, 4095, 16
 # CHECK-S-OBJ: csrrsi t0, 4095, 16
Index: llvm/test/MC/RISCV/rv32-supervisor-csr-names.s
===
--- 

[PATCH] D146054: [RISCV] Add -print-supported-marchs and -march=help support

2023-04-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4236
+
+// Use the -march=help flag as the dummy input to cc1.
+Actions.clear();

craig.topper wrote:
> MaskRay wrote:
> > Why is the code needed? Can --print-supported-extensions reuse the approach 
> > of `OPT_print_supported_cpus`?
> @MaskRay are you just asking to use the same block of code for both cases?
Yes, this should reuse some code with the `OPT_print_supported_cpus` handler.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146054/new/

https://reviews.llvm.org/D146054

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


[PATCH] D147935: [RISCV] Add SiFive extension support

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Is there a different patch with the .td for these intrinsics?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147935/new/

https://reviews.llvm.org/D147935

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


[PATCH] D147733: Set rounding_mode to tonearest in presence of a #pragma STDC FENV_ACCESS OFF.

2023-04-11 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor accepted this revision.
andrew.w.kaylor added a comment.

Looks good to me.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147733/new/

https://reviews.llvm.org/D147733

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


[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148029/new/

https://reviews.llvm.org/D148029

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


[PATCH] D147867: [Windows SEH] Fix ehcleanup crash for Windows -EHa

2023-04-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/CodeGen/windows-seh-EHa-CppCatchReturn.cpp:27
+
+// FIXME: We may need to generate llvm.seh.scope.end or remove 
llvm.seh.scope.begin.
+void qux() {

If a scope never ends because there's an "unreachable", that's fine, I think.  
The scope never dynamically ends (unless an exception is thrown).  The backend 
deals with the same sort of thing for other constructs with a "begin" and 
"end".  For example, a cleanuppad might not have a matching cleanupret.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147867/new/

https://reviews.llvm.org/D147867

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:2262
+  /// Return true if the given vector types are lax-compatible RVV vector 
types,
+  /// false otherwise.
+  bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);

erichkeane wrote:
> craig.topper wrote:
> > erichkeane wrote:
> > > Same here, what is 'lax compatible' mean here? And RVV?
> > Do you have the same comment for the AArch64 equivalent on line 2252?
> I do NOW!
I mentioned -flax-vector-conversions=. Is that sufficient?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11390
+ResType = llvm::ScalableVectorType::get(
+llvm::Type::getIntNTy(getVMContext(), XLen), 64 / XLen);
+break;

erichkeane wrote:
> craig.topper wrote:
> > jrtc27 wrote:
> > > erichkeane wrote:
> > > > craig.topper wrote:
> > > > > erichkeane wrote:
> > > > > > Where is 'XLen' from here?  
> > > > > It's a member of RISCVABIInfo. It's 64 for riscv64 triple and 32 for 
> > > > > riscv32 triple.
> > > > Well, the name is awful :)  I'd probably suggest a re-name and hiding 
> > > > it behind a function call (since that way it can be done on the triple, 
> > > > rather than an initialized variable perhaps?), but I'm not really in 
> > > > charge of this target info.
> > > It's not for anyone in the RISC-V space, since it is defined by the 
> > > architecture and used pervasively (and means the X register LENgth, i.e. 
> > > how many bits in the x0-x31 GPRs). Using anything else in a RISC-V ABI 
> > > context would be worse from a RISC-V perspective. In a random LLVM 
> > > checkout I have I see 1118 instances of `/xlen/i` in 
> > > llvm/lib/Target/RISCV alone.
> > It's the term in the RISC-V spec for the size of our integer registers. 
> > Anyone working on RISC-V should be familiar with it.
> Based on Jessica's post, perhaps it is not an issue.  Just was jarring to see 
> something as impenetrable. I'd perhaps suggest something like `XRegisterLen` 
> to make it clear what 'X' is, but just a suggestion for the next folks who 
> are finding their way into contributing patches, despite perhaps not yet 
> being RISCV experts.
I rewrote it using ConvertType and getTypeSize.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D144064: [-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions

2023-04-11 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88f7f018e23b: [-Wunsafe-buffer-usage] Match unsafe pointers 
being casted to bool or… (authored by ziqingluo-90).

Changed prior to commit:
  https://reviews.llvm.org/D144064?vs=506733=512600#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144064/new/

https://reviews.llvm.org/D144064

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
@@ -13,12 +13,30 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:42}:"()[x]"
 }
 
+void address_to_bool(int x) {
+  int * p = new int[10];
+  bool a = (bool) [5];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"()[5]"
+  bool b = (bool) [x];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"()[x]"
+
+  bool a1 = [5];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:18}:"()[5]"
+  bool b1 = [x];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:18}:"()[x]"
+
+  if ([5]) {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:12}:"()[5]"
+return;
+  }
+}
+
 void call_argument(int x) {
   int * p = new int[10];
 
   f((unsigned long) [5], [x]);
-  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:21-[[@LINE-1]]:26}:"()[5]"
-  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:33}:"()[x]"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:21-[[@LINE-1]]:26}:"()[5]"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:33}:"()[x]"
 }
 
 void ignore_unsafe_calls(int x) {
@@ -55,9 +73,26 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:5-[[@LINE-1]]:10}:"p.data()"
 }
 
-// CHECK-NOT: fix-it
+void pointer_subtraction(int x) {
+  int * p = new int[10];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::span p"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:13-[[@LINE-2]]:13}:"{"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:24-[[@LINE-3]]:24}:", 10}"
+
+  int n = [9] - [4];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:16}:"()[9]"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:19-[[@LINE-2]]:24}:"()[4]"
+  if ([9] - [x]) {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:12}:"()[9]"
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:20}:"()[x]"
+return;
+  }
+}
+
 // To test multiple function declarations, each of which carries
-// different incomplete informations:
+// different incomplete informations.
+// no fix-it in the rest of this test:
+
 [[clang::unsafe_buffer_usage]]
 void unsafe_g(void*);
 
@@ -65,8 +100,9 @@
 
 void multiple_unsafe_fundecls() {
   int * p = new int[10];
-
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
   unsafe_g([5]);
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
 }
 
 void unsafe_h(void*);
@@ -78,6 +114,7 @@
 
 void multiple_unsafe_fundecls2() {
   int * p = new int[10];
-
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
   unsafe_h([5]);
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
 }
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -163,24 +163,40 @@
 isInUnspecifiedPointerContext(internal::Matcher InnerMatcher) {
   // A UPC can be
   // 1. an argument of a function call (except the callee has [[unsafe_...]]
-  // attribute), or
-  // 2. the operand of a cast operation; or
+  //attribute), or
+  // 2. the operand of a pointer-to-(integer or bool) cast operation; or
   // 3. the operand of a comparator operation; or
+  // 4. the operand of a pointer subtraction operation
+  //(i.e., computing the distance between two pointers); or ...
+
   auto CallArgMatcher =
   callExpr(forEachArgumentWithParam(InnerMatcher,
   hasPointerType() /* array also decays to pointer type*/),
   unless(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage);
 
   auto CastOperandMatcher =
-  explicitCastExpr(hasCastKind(CastKind::CK_PointerToIntegral),
-   castSubExpr(allOf(hasPointerType(), InnerMatcher)));
+  castExpr(anyOf(hasCastKind(CastKind::CK_PointerToIntegral),
+		 hasCastKind(CastKind::CK_PointerToBoolean)),
+	   castSubExpr(allOf(hasPointerType(), InnerMatcher)));
 
   auto CompOperandMatcher =
   binaryOperator(hasAnyOperatorName("!=", "==", "<", "<=", ">", ">="),
  eachOf(hasLHS(allOf(hasPointerType(), InnerMatcher)),
 hasRHS(allOf(hasPointerType(), InnerMatcher;
 
-  return stmt(anyOf(CallArgMatcher, 

[clang] 88f7f01 - [-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions

2023-04-11 Thread Ziqing Luo via cfe-commits

Author: Ziqing Luo
Date: 2023-04-11T15:09:51-07:00
New Revision: 88f7f018e23b24d3c31dd2b4f3cd68481d1739c1

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

LOG: [-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or 
participating in pointer subtractions

Add two new unique cases to the Unspecified Pointer Context (UPC),
under which we match unsafe operation patterns:
- A pointer being casted to a boolean value is in a UPC;
- A pointer participating in pointer subtraction is in a UPC.

Reviewed by: NoQ (Artem Dergachev), malavikasamak (Malavika Samak)

Differential revision: https://reviews.llvm.org/D144064

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp

clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index fdc7584ad6ff1..6a597c8851002 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -163,24 +163,40 @@ static internal::Matcher
 isInUnspecifiedPointerContext(internal::Matcher InnerMatcher) {
   // A UPC can be
   // 1. an argument of a function call (except the callee has [[unsafe_...]]
-  // attribute), or
-  // 2. the operand of a cast operation; or
+  //attribute), or
+  // 2. the operand of a pointer-to-(integer or bool) cast operation; or
   // 3. the operand of a comparator operation; or
+  // 4. the operand of a pointer subtraction operation
+  //(i.e., computing the distance between two pointers); or ...
+
   auto CallArgMatcher =
   callExpr(forEachArgumentWithParam(InnerMatcher,
   hasPointerType() /* array also decays to pointer type*/),
   unless(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage);
 
   auto CastOperandMatcher =
-  explicitCastExpr(hasCastKind(CastKind::CK_PointerToIntegral),
-   castSubExpr(allOf(hasPointerType(), InnerMatcher)));
+  castExpr(anyOf(hasCastKind(CastKind::CK_PointerToIntegral),
+hasCastKind(CastKind::CK_PointerToBoolean)),
+  castSubExpr(allOf(hasPointerType(), InnerMatcher)));
 
   auto CompOperandMatcher =
   binaryOperator(hasAnyOperatorName("!=", "==", "<", "<=", ">", ">="),
  eachOf(hasLHS(allOf(hasPointerType(), InnerMatcher)),
 hasRHS(allOf(hasPointerType(), InnerMatcher;
 
-  return stmt(anyOf(CallArgMatcher, CastOperandMatcher, CompOperandMatcher));
+  // A matcher that matches pointer subtractions:
+  auto PtrSubtractionMatcher =
+  binaryOperator(hasOperatorName("-"),
+// Note that here we need both LHS and RHS to be
+// pointer. Then the inner matcher can match any of
+// them:
+allOf(hasLHS(hasPointerType()),
+  hasRHS(hasPointerType())),
+eachOf(hasLHS(InnerMatcher),
+   hasRHS(InnerMatcher)));
+
+  return stmt(anyOf(CallArgMatcher, CastOperandMatcher, CompOperandMatcher,
+   PtrSubtractionMatcher));
   // FIXME: any more cases? (UPC excludes the RHS of an assignment.  For now we
   // don't have to check that.)
 }

diff  --git 
a/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
index 8fdbc4bed4f6d..474e7495e3e1d 100644
--- 
a/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
+++ 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
@@ -13,12 +13,30 @@ void address_to_integer(int x) {
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:42}:"()[x]"
 }
 
+void address_to_bool(int x) {
+  int * p = new int[10];
+  bool a = (bool) [5];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"()[5]"
+  bool b = (bool) [x];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"()[x]"
+
+  bool a1 = [5];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:18}:"()[5]"
+  bool b1 = [x];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:18}:"()[x]"
+
+  if ([5]) {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:12}:"()[5]"
+return;
+  }
+}
+
 void call_argument(int x) {
   int * p = new int[10];
 
   f((unsigned long) [5], [x]);
-  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:21-[[@LINE-1]]:26}:"()[5]"
-  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:33}:"()[x]"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:21-[[@LINE-1]]:26}:"()[5]"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:33}:"()[x]"
 }
 
 void ignore_unsafe_calls(int x) {
@@ -55,9 +73,26 @@ 

[PATCH] D143364: [RISCV] Support scalar/fix-length vector NTLH intrinsic with different domain

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

What if we attached the domain as a separate RISC-V specific metadata and 
didn't change the nontemporal format? If optimizations drop the RISC-V specific 
part it would still be nontemporal, but get the default domain?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143364/new/

https://reviews.llvm.org/D143364

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


[PATCH] D148024: [clang-format] Don't modify template arguments on the LHS of assignment

2023-04-11 Thread Emilia Dreamer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5dc94b3356bd: [clang-format] Dont modify template 
arguments on the LHS of assignment (authored by rymiel).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148024/new/

https://reviews.llvm.org/D148024

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -270,6 +270,18 @@
   ASSERT_EQ(Tokens.size(), 19u) << Tokens;
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
+
+  Tokens = annotate("template * = nullptr> void 
f();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::ampamp, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1819,7 +1819,7 @@
  Previous && Previous->Previous &&
  !Previous->Previous->isOneOf(tok::comma, tok::semi);
  Previous = Previous->Previous) {
-  if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
+  if (Previous->isOneOf(tok::r_square, tok::r_paren, tok::greater)) {
 Previous = Previous->MatchingParen;
 if (!Previous)
   break;


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -270,6 +270,18 @@
   ASSERT_EQ(Tokens.size(), 19u) << Tokens;
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
+
+  Tokens = annotate("template * = nullptr> void f();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::ampamp, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1819,7 +1819,7 @@
  Previous && Previous->Previous &&
  !Previous->Previous->isOneOf(tok::comma, tok::semi);
  Previous = Previous->Previous) {
-  if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
+  if (Previous->isOneOf(tok::r_square, tok::r_paren, tok::greater)) {
 Previous = Previous->MatchingParen;
 if (!Previous)
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5dc94b3 - [clang-format] Don't modify template arguments on the LHS of assignment

2023-04-11 Thread Emilia Dreamer via cfe-commits

Author: Emilia Dreamer
Date: 2023-04-12T00:33:17+03:00
New Revision: 5dc94b3356bd861d304e1ab61f7bb9ef33bf46b3

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

LOG: [clang-format] Don't modify template arguments on the LHS of assignment

After clang-format has determined that an equals sign starts an
expression, it will also go backwards and modify any star/amp/ampamp
binary operators on the left side of the assignment to be
pointers/references instead.

There already exists logic to skip over contents of parentheses and
square brackets, but this patch also expands that logic to apply to
angle brackets. This is so that binary operators inside of template
arguments would not be touched, primary arguments to non-type template
parameters.

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

Reviewed By: owenpan, MyDeveloperDay, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D148024

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index e7de8fd9a2174..18fccca622caa 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1819,7 +1819,7 @@ class AnnotatingParser {
  Previous && Previous->Previous &&
  !Previous->Previous->isOneOf(tok::comma, tok::semi);
  Previous = Previous->Previous) {
-  if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
+  if (Previous->isOneOf(tok::r_square, tok::r_paren, tok::greater)) {
 Previous = Previous->MatchingParen;
 if (!Previous)
   break;

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 0fc6442773936..facd0060d0fde 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -270,6 +270,18 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
   ASSERT_EQ(Tokens.size(), 19u) << Tokens;
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
+
+  Tokens = annotate("template * = nullptr> void 
f();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::ampamp, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {



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


[clang] 8af5756 - Revert (4) "[Assignment Tracking] Enable by default"

2023-04-11 Thread via cfe-commits

Author: OCHyams
Date: 2023-04-11T22:25:16+01:00
New Revision: 8af575657b1dc1113640286b3649842c2473c2cf

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

LOG: Revert (4) "[Assignment Tracking] Enable by default"

This reverts commit a0525f09ac1eda3fbb74e8708b3aa5b7379df0c2 which
lands D146987.

Buildbot: https://lab.llvm.org/buildbot/#/builders/70/builds/36214

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/CodeGen/assignment-tracking/flag.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0e3c7b708071f..5e008fc9b26ee 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5815,7 +5815,7 @@ def experimental_assignment_tracking_EQ : Joined<["-"], 
"fexperimental-assignmen
   Group, CodeGenOpts<"EnableAssignmentTracking">,
   NormalizedValuesScope<"CodeGenOptions::AssignmentTrackingOpts">,
   Values<"disabled,enabled,forced">, 
NormalizedValues<["Disabled","Enabled","Forced"]>,
-  MarshallingInfoEnum, "Enabled">;
+  MarshallingInfoEnum, "Disabled">;
 
 } // let Flags = [CC1Option, NoDriverOption]
 

diff  --git a/clang/test/CodeGen/assignment-tracking/flag.cpp 
b/clang/test/CodeGen/assignment-tracking/flag.cpp
index 3bd974fe07c6c..aa1f054dae4d7 100644
--- a/clang/test/CodeGen/assignment-tracking/flag.cpp
+++ b/clang/test/CodeGen/assignment-tracking/flag.cpp
@@ -8,10 +8,10 @@
 // RUN: -emit-llvm  %s -o - -fexperimental-assignment-tracking=disabled 
-O1\
 // RUN: | FileCheck %s --check-prefixes=DISABLE
 
- Enabled by default:
+ Disabled by default:
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone   
\
 // RUN: -emit-llvm  %s -o - -O1
\
-// RUN: | FileCheck %s --check-prefixes=ENABLE
+// RUN: | FileCheck %s --check-prefixes=DISABLE
 
  Disabled at O0 unless forced.
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone   
\



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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D145088#4258856 , @erichkeane 
wrote:

> So I don't see any handling of the dependent version of this, we probably 
> need tests for those at minimum.

Does SVE handle the dependent version?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D147969: Add InsertBraces to ChromiumStyle

2023-04-11 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:1699
 ChromiumStyle.DerivePointerAlignment = false;
+ChromiumStyle.InsertBraces = true;
 if (Language == FormatStyle::LK_ObjC)

owenpan wrote:
> aaron.ballman wrote:
> > HazardyKnusperkeks wrote:
> > > MyDeveloperDay wrote:
> > > > This is an code modifying feature, we agreed that all code modifying 
> > > > features would be off by default, opt in only
> > > Now the question arises if //default// simply only applies to 
> > > `LLVMStyle`, since that's the //default// when nothing is stated, or if 
> > > other styles are free to enable such features in their style //by 
> > > default//.
> > > 
> > > I'd say if chromium wants to do that, they should be allowed to.
> > The community reacted pretty strongly to clang-format mutating code in ways 
> > that may change the meaning of code unless there is an explicit opt-in. The 
> > reason for that is because the opt-in + documentation is what informs the 
> > user that the feature may break their code, so removing that opt-in for the 
> > Chromium style means those users have no idea about the dangers. (In 
> > general, users take a dim view of a formatting tool that breaks code.)
> > 
> > Personally, I think if the Chromium *project* wants that to be the default, 
> > they can use .clang-format files in their version control to make it so, 
> > but I don't think the Chromium *style* built into clang-format should allow 
> > it by default because that may be used by a wider audience than just 
> > Chromium developers. Basically, I think we want to be conservative with 
> > formatting features that can potentially break code (once we start breaking 
> > user code with a formatting tool, that tool gets pulled out of affected 
> > people's CI pipelines pretty quickly, which I think we generally want to 
> > avoid).
> I'm with @MyDeveloperDay and @aaron.ballman on this.
I personally would feel quite uncomfortable about going against what we agreed 
in the RFC.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147969/new/

https://reviews.llvm.org/D147969

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


[PATCH] D147263: Fix an assertion failure in unwrapSugar

2023-04-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147263/new/

https://reviews.llvm.org/D147263

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D145088#4259209 , @craig.topper 
wrote:

> In D145088#4259197 , @erichkeane 
> wrote:
>
>> has this had an RFC btw?  I don't believe I've seen one, and this looks like 
>> we probably need one.
>
> It has not had an RFC. It's almost a direct copy of AArch64's implementation, 
> but changed for RISC-V. Do you know if there was an RFC for AArch64?

There was for SVE, is that what you mean?  I believe most of that went through 
extensive RFC.

The Sema & before stuff seems fine to me, CodeGen is owned by others, so it'll 
be up to them.  I'm not super up on what RFCs happened/were required for this 
for AArch64, but I'd suggest we at least have the implementers of the AArch64 
implementation review this as well.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:11390
+ResType = llvm::ScalableVectorType::get(
+llvm::Type::getIntNTy(getVMContext(), XLen), 64 / XLen);
+break;

craig.topper wrote:
> jrtc27 wrote:
> > erichkeane wrote:
> > > craig.topper wrote:
> > > > erichkeane wrote:
> > > > > Where is 'XLen' from here?  
> > > > It's a member of RISCVABIInfo. It's 64 for riscv64 triple and 32 for 
> > > > riscv32 triple.
> > > Well, the name is awful :)  I'd probably suggest a re-name and hiding it 
> > > behind a function call (since that way it can be done on the triple, 
> > > rather than an initialized variable perhaps?), but I'm not really in 
> > > charge of this target info.
> > It's not for anyone in the RISC-V space, since it is defined by the 
> > architecture and used pervasively (and means the X register LENgth, i.e. 
> > how many bits in the x0-x31 GPRs). Using anything else in a RISC-V ABI 
> > context would be worse from a RISC-V perspective. In a random LLVM checkout 
> > I have I see 1118 instances of `/xlen/i` in llvm/lib/Target/RISCV alone.
> It's the term in the RISC-V spec for the size of our integer registers. 
> Anyone working on RISC-V should be familiar with it.
Based on Jessica's post, perhaps it is not an issue.  Just was jarring to see 
something as impenetrable. I'd perhaps suggest something like `XRegisterLen` to 
make it clear what 'X' is, but just a suggestion for the next folks who are 
finding their way into contributing patches, despite perhaps not yet being 
RISCV experts.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D145088#4259197 , @erichkeane 
wrote:

> has this had an RFC btw?  I don't believe I've seen one, and this looks like 
> we probably need one.

It has not had an RFC. It's almost a direct copy of AArch64's implementation, 
but changed for RISC-V. Do you know if there was an RFC for AArch64?




Comment at: clang/lib/CodeGen/TargetInfo.cpp:11390
+ResType = llvm::ScalableVectorType::get(
+llvm::Type::getIntNTy(getVMContext(), XLen), 64 / XLen);
+break;

jrtc27 wrote:
> erichkeane wrote:
> > craig.topper wrote:
> > > erichkeane wrote:
> > > > Where is 'XLen' from here?  
> > > It's a member of RISCVABIInfo. It's 64 for riscv64 triple and 32 for 
> > > riscv32 triple.
> > Well, the name is awful :)  I'd probably suggest a re-name and hiding it 
> > behind a function call (since that way it can be done on the triple, rather 
> > than an initialized variable perhaps?), but I'm not really in charge of 
> > this target info.
> It's not for anyone in the RISC-V space, since it is defined by the 
> architecture and used pervasively (and means the X register LENgth, i.e. how 
> many bits in the x0-x31 GPRs). Using anything else in a RISC-V ABI context 
> would be worse from a RISC-V perspective. In a random LLVM checkout I have I 
> see 1118 instances of `/xlen/i` in llvm/lib/Target/RISCV alone.
It's the term in the RISC-V spec for the size of our integer registers. Anyone 
working on RISC-V should be familiar with it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11390
+ResType = llvm::ScalableVectorType::get(
+llvm::Type::getIntNTy(getVMContext(), XLen), 64 / XLen);
+break;

erichkeane wrote:
> craig.topper wrote:
> > erichkeane wrote:
> > > Where is 'XLen' from here?  
> > It's a member of RISCVABIInfo. It's 64 for riscv64 triple and 32 for 
> > riscv32 triple.
> Well, the name is awful :)  I'd probably suggest a re-name and hiding it 
> behind a function call (since that way it can be done on the triple, rather 
> than an initialized variable perhaps?), but I'm not really in charge of this 
> target info.
It's not for anyone in the RISC-V space, since it is defined by the 
architecture and used pervasively (and means the X register LENgth, i.e. how 
many bits in the x0-x31 GPRs). Using anything else in a RISC-V ABI context 
would be worse from a RISC-V perspective. In a random LLVM checkout I have I 
see 1118 instances of `/xlen/i` in llvm/lib/Target/RISCV alone.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

has this had an RFC btw?  I don't believe I've seen one, and this looks like we 
probably need one.




Comment at: clang/include/clang/AST/ASTContext.h:2262
+  /// Return true if the given vector types are lax-compatible RVV vector 
types,
+  /// false otherwise.
+  bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);

craig.topper wrote:
> erichkeane wrote:
> > Same here, what is 'lax compatible' mean here? And RVV?
> Do you have the same comment for the AArch64 equivalent on line 2252?
I do NOW!



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11369
+  llvm::ScalableVectorType *ResType = nullptr;
+  switch (BT->getKind()) {
+  default:

craig.topper wrote:
> erichkeane wrote:
> > I wonder if at least the inner type can be picked up ConvertType instead.  
> > There doesn't seem to be obvious rhyme/reason to the last argument to 
> > ScalableVectorType, so it might not solve that.
> > 
> > However, it'll solve the long problem.
> The last argument is 64 / sizeof(element). I should replace the 64 with 
> RISCV::RVVBitsPerBlock.
In that case, I'd suggest putting the 'math' in here.  It would be much less 
difficult to read the tea leaves.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11390
+ResType = llvm::ScalableVectorType::get(
+llvm::Type::getIntNTy(getVMContext(), XLen), 64 / XLen);
+break;

craig.topper wrote:
> erichkeane wrote:
> > Where is 'XLen' from here?  
> It's a member of RISCVABIInfo. It's 64 for riscv64 triple and 32 for riscv32 
> triple.
Well, the name is awful :)  I'd probably suggest a re-name and hiding it behind 
a function call (since that way it can be done on the triple, rather than an 
initialized variable perhaps?), but I'm not really in charge of this target 
info.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:2262
+  /// Return true if the given vector types are lax-compatible RVV vector 
types,
+  /// false otherwise.
+  bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);

erichkeane wrote:
> Same here, what is 'lax compatible' mean here? And RVV?
Do you have the same comment for the AArch64 equivalent on line 2252?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11369
+  llvm::ScalableVectorType *ResType = nullptr;
+  switch (BT->getKind()) {
+  default:

erichkeane wrote:
> I wonder if at least the inner type can be picked up ConvertType instead.  
> There doesn't seem to be obvious rhyme/reason to the last argument to 
> ScalableVectorType, so it might not solve that.
> 
> However, it'll solve the long problem.
The last argument is 64 / sizeof(element). I should replace the 64 with 
RISCV::RVVBitsPerBlock.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11371
+  default:
+llvm_unreachable("unexpected builtin type for SVE vector!");
+  case BuiltinType::SChar:

I need to fix this SVE usage here.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11390
+ResType = llvm::ScalableVectorType::get(
+llvm::Type::getIntNTy(getVMContext(), XLen), 64 / XLen);
+break;

erichkeane wrote:
> Where is 'XLen' from here?  
It's a member of RISCVABIInfo. It's 64 for riscv64 triple and 32 for riscv32 
triple.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D147969: Add InsertBraces to ChromiumStyle

2023-04-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/Format.cpp:1699
 ChromiumStyle.DerivePointerAlignment = false;
+ChromiumStyle.InsertBraces = true;
 if (Language == FormatStyle::LK_ObjC)

aaron.ballman wrote:
> HazardyKnusperkeks wrote:
> > MyDeveloperDay wrote:
> > > This is an code modifying feature, we agreed that all code modifying 
> > > features would be off by default, opt in only
> > Now the question arises if //default// simply only applies to `LLVMStyle`, 
> > since that's the //default// when nothing is stated, or if other styles are 
> > free to enable such features in their style //by default//.
> > 
> > I'd say if chromium wants to do that, they should be allowed to.
> The community reacted pretty strongly to clang-format mutating code in ways 
> that may change the meaning of code unless there is an explicit opt-in. The 
> reason for that is because the opt-in + documentation is what informs the 
> user that the feature may break their code, so removing that opt-in for the 
> Chromium style means those users have no idea about the dangers. (In general, 
> users take a dim view of a formatting tool that breaks code.)
> 
> Personally, I think if the Chromium *project* wants that to be the default, 
> they can use .clang-format files in their version control to make it so, but 
> I don't think the Chromium *style* built into clang-format should allow it by 
> default because that may be used by a wider audience than just Chromium 
> developers. Basically, I think we want to be conservative with formatting 
> features that can potentially break code (once we start breaking user code 
> with a formatting tool, that tool gets pulled out of affected people's CI 
> pipelines pretty quickly, which I think we generally want to avoid).
I'm with @MyDeveloperDay and @aaron.ballman on this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147969/new/

https://reviews.llvm.org/D147969

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


[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 added a comment.

ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147572/new/

https://reviews.llvm.org/D147572

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


[PATCH] D148034: [clang][driver] Disable GP relaxation with RISC-V ShadowCallStack

2023-04-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

Sorry, we cannot do this. See https://reviews.llvm.org/D147983#4259132 
I added --[no-]relax-gp to GNU ld master branch recently, which isn't in a 
released binutils version yet.
Passing `--no-relax-gp` will break almost all GNU ld users.

For lld, we have made a decision to not enable global pointer relaxation by 
default, so this option isn't really needed.
It doesn't hurt to receive the option, though, once lld supports the options.

I wonder whether we can let GCC autoconf for certain `riscv*-` target triples 
(perhaps just some Linux's) detect `ld --relax-gp` support and set `--relax-gp` 
in linker specs and change GNU ld to default to `--no-relax-gp` in the future,
given someone's stance on 
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/371


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148034/new/

https://reviews.llvm.org/D148034

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


[clang] a0525f0 - Reapply (3) "[Assignment Tracking] Enable by default"

2023-04-11 Thread via cfe-commits

Author: OCHyams
Date: 2023-04-11T21:15:03+01:00
New Revision: a0525f09ac1eda3fbb74e8708b3aa5b7379df0c2

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

LOG: Reapply (3) "[Assignment Tracking] Enable by default"

Re-land D146987.

This reverts commit 4f1954ed67c12aca3fd3e67151185c64dc941768 which
reverts D146987.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/CodeGen/assignment-tracking/flag.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 5e008fc9b26ee..0e3c7b708071f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5815,7 +5815,7 @@ def experimental_assignment_tracking_EQ : Joined<["-"], 
"fexperimental-assignmen
   Group, CodeGenOpts<"EnableAssignmentTracking">,
   NormalizedValuesScope<"CodeGenOptions::AssignmentTrackingOpts">,
   Values<"disabled,enabled,forced">, 
NormalizedValues<["Disabled","Enabled","Forced"]>,
-  MarshallingInfoEnum, "Disabled">;
+  MarshallingInfoEnum, "Enabled">;
 
 } // let Flags = [CC1Option, NoDriverOption]
 

diff  --git a/clang/test/CodeGen/assignment-tracking/flag.cpp 
b/clang/test/CodeGen/assignment-tracking/flag.cpp
index aa1f054dae4d7..3bd974fe07c6c 100644
--- a/clang/test/CodeGen/assignment-tracking/flag.cpp
+++ b/clang/test/CodeGen/assignment-tracking/flag.cpp
@@ -8,10 +8,10 @@
 // RUN: -emit-llvm  %s -o - -fexperimental-assignment-tracking=disabled 
-O1\
 // RUN: | FileCheck %s --check-prefixes=DISABLE
 
- Disabled by default:
+ Enabled by default:
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone   
\
 // RUN: -emit-llvm  %s -o - -O1
\
-// RUN: | FileCheck %s --check-prefixes=DISABLE
+// RUN: | FileCheck %s --check-prefixes=ENABLE
 
  Disabled at O0 unless forced.
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone   
\



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


[PATCH] D147357: [clang-tidy] Add bugprone-optional-value-conversion check

2023-04-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL planned changes to this revision.
PiotrZSL added a comment.

TODO: Fix pointers, Add more tests, consider free standing value extraction 
functions like boost::get


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147357/new/

https://reviews.llvm.org/D147357

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


[PATCH] D147357: [clang-tidy] Add bugprone-optional-value-conversion check

2023-04-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 512559.
PiotrZSL marked 3 inline comments as done.
PiotrZSL added a comment.

Add fixes, add suport for std:move, fixed operator*() calls, added more tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147357/new/

https://reviews.llvm.org/D147357

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone/optional-value-conversion.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp
@@ -0,0 +1,111 @@
+// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-optional-value-conversion %t -- --fix-notes
+
+namespace std {
+  template
+  struct optional
+  {
+  constexpr optional() noexcept;
+  constexpr optional(T&&) noexcept;
+  constexpr optional(const T&) noexcept;
+  template
+  constexpr optional(U&&) noexcept;
+  const T *() const;
+  T *();
+  const T () const;
+  T ();
+  T value_or(T) const;
+  };
+
+  template 
+  T&& move(T ) {
+return static_cast(x);
+  }
+}
+
+void takeOptionalValue(std::optional);
+void takeOptionalRef(const std::optional&);
+void takeOptionalRRef(std::optional&&);
+void takeOtherOptional(std::optional);
+
+void incorrect(std::optional param)
+{
+  std::optional* ptr = 
+  takeOptionalValue(**ptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(*ptr);
+  takeOptionalValue(*param);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalValue(param.value());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalValue(param.operator*());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalRef(*param);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalRef(param);
+  takeOptionalRef(param.value());
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalRef(param);
+  takeOptionalRef(param.operator*());
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalRef(param);
+  std::optional p = *param;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: std::optional p = param;
+
+  takeOptionalValue(std::move(**ptr));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(std::move(*ptr));
+  takeOptionalValue(std::move(*param));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(std::move(param));
+  takeOptionalValue(std::move(param.value()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional 

[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-11 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon updated this revision to Diff 512554.
agozillon added a comment.

Adding missing newline


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148038/new/

https://reviews.llvm.org/D148038

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/LangOptions.h
  flang/include/flang/Tools/CrossToolHelpers.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/omp-frontend-forwarding.f90
  flang/test/Lower/OpenMP/omp-host-ir-flag.f90
  mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td

Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
@@ -71,7 +71,7 @@
   InterfaceMethod<
   /*description=*/[{
 Get the IsDeviceAttr attribute on the current module if it exists and return
-its value, if it doesn't exit it returns false by default.
+its value, if it doesn't exist it returns false by default.
   }],
   /*retTy=*/"bool",
   /*methodName=*/"getIsDevice",
@@ -138,6 +138,34 @@
  targetCPU.str(),
  targetFeatures.str()));
   }]>,
+  InterfaceMethod<
+  /*description=*/[{
+Set a StringAttr on the current module containing the host IR file path. This 
+file path is used in two-phase compilation during the device phase to generate
+device side LLVM IR when lowering MLIR. 
+  }],
+  /*retTy=*/"void",
+  /*methodName=*/"setHostIRFilePath", 
+  (ins "std::string":$hostIRFilePath), [{}], [{
+$_op->setAttr(
+  mlir::StringAttr::get($_op->getContext(), llvm::Twine{"omp.host_ir_filepath"}),
+mlir::StringAttr::get($_op->getContext(), hostIRFilePath));
+   }]>,
+  InterfaceMethod<
+  /*description=*/[{
+Find the host-ir file path StringAttr from the current module if it exists and 
+return its contained value, if it doesn't exist it returns an empty string. This 
+file path is used in two-phase compilation during the device phase to generate
+device side LLVM IR when lowering MLIR. 
+  }],
+  /*retTy=*/"llvm::StringRef",
+  /*methodName=*/"getHostIRFilePath", 
+  (ins), [{}], [{
+if (Attribute filepath = $_op->getAttr("omp.host_ir_filepath"))
+  if (filepath.isa())
+return filepath.dyn_cast().getValue();
+return {};
+  }]>
   ];
 }
 
Index: flang/test/Lower/OpenMP/omp-host-ir-flag.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/omp-host-ir-flag.f90
@@ -0,0 +1,6 @@
+!RUN: %flang_fc1 -emit-llvm-bc -fopenmp -o %t.bc %s 2>&1
+!RUN: %flang_fc1 -emit-mlir -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -o - %s 2>&1 | FileCheck %s
+
+!CHECK: module attributes {{{.*}}, omp.host_ir_filepath = "{{.*}}.bc", omp.is_device = #omp.isdevice{{.*}}}
+subroutine omp_subroutine()
+end subroutine omp_subroutine
Index: flang/test/Driver/omp-frontend-forwarding.f90
===
--- flang/test/Driver/omp-frontend-forwarding.f90
+++ flang/test/Driver/omp-frontend-forwarding.f90
@@ -11,15 +11,15 @@
 ! RUN: %flang -### -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-DEVICE %s
 ! CHECK-OPENMP-IS-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
 
-! Testing fembed-offload-object and fopenmp-is-device
+! Testing appropriate flags are gnerated and appropriately assigned by the driver when offloading
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a \
 ! RUN: --target=aarch64-unknown-linux-gnu \
-! RUN:   | FileCheck %s --check-prefixes=CHECK-OPENMP-EMBED
-! CHECK-OPENMP-EMBED: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}}.f90"
-! CHECK-OPENMP-EMBED-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
-! CHECK-OPENMP-EMBED: "{{[^"]*}}clang-offload-packager{{.*}} "--image=file={{.*}}.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"
-! CHECK-OPENMP-EMBED-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}} "-fembed-offload-object={{.*}}.out" {{.*}}.bc"
+! RUN:   | FileCheck %s --check-prefix=OPENMP-OFFLOAD-ARGS
+! OPENMP-OFFLOAD-ARGS: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}}.f90"
+! OPENMP-OFFLOAD-ARGS-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp" {{.*}} "-fopenmp-host-ir-file-path" "{{.*}}.bc" 

[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

The changes seem reasonable to me.




Comment at: clang/include/clang/AST/RawCommentList.h:122
+StringRef Text = getRawText(SourceMgr);
+if (Text.size() < 6 || Text[0] != '/')
+  return false;

cor3ntin wrote:
> aaron.ballman wrote:
> > Just to double-check, we don't have to worry about there being leading 
> > whitespace in `Text` do we?
> Afaict, we always have a valid comment, starting with / (and ending with / 
> for a multi line comment). We might not have a comment valid for 
> documentation purposes.
Excellent -- I was poking around and it seemed like we do trim the text before 
forming the comment object, so yay.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148029/new/

https://reviews.llvm.org/D148029

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


[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-11 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon created this revision.
Herald added subscribers: bviyer, sunshaoce, Moerafaat, zero9178, bzcheeseman, 
sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, thopre, guansong, yaxunl.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
Herald added a reviewer: kiranchandramohan.
Herald added projects: Flang, All.
agozillon requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1, stephenneuendorffer, 
nicolasvasilache, jdoerfert, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: nicolasvasilache.
Herald added projects: clang, MLIR.

This patch ports the fopenmp-host-ir-file-path flag from Clang to Flang-new, 
this flag is added by the driver to the device pass when doing two phase 
compilation (device + host).

This flag is then applied to the module when compiling during the OpenMP device 
phase. This file can then be utilised during lowering of the OpenMP dialect to 
LLVM-IR, which allows the device and host to maintain 1:1 mapping of OpenMP 
metadata for variables during lowering via the OpenMPIRBuilders 
loadOffloadInfoMetadata facilities (which is used for declare target and I 
believe target regions as well).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148038

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/LangOptions.h
  flang/include/flang/Tools/CrossToolHelpers.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/omp-frontend-forwarding.f90
  flang/test/Lower/OpenMP/omp-host-ir-flag.f90
  mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td

Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
@@ -71,7 +71,7 @@
   InterfaceMethod<
   /*description=*/[{
 Get the IsDeviceAttr attribute on the current module if it exists and return
-its value, if it doesn't exit it returns false by default.
+its value, if it doesn't exist it returns false by default.
   }],
   /*retTy=*/"bool",
   /*methodName=*/"getIsDevice",
@@ -138,6 +138,34 @@
  targetCPU.str(),
  targetFeatures.str()));
   }]>,
+  InterfaceMethod<
+  /*description=*/[{
+Set a StringAttr on the current module containing the host IR file path. This 
+file path is used in two-phase compilation during the device phase to generate
+device side LLVM IR when lowering MLIR. 
+  }],
+  /*retTy=*/"void",
+  /*methodName=*/"setHostIRFilePath", 
+  (ins "std::string":$hostIRFilePath), [{}], [{
+$_op->setAttr(
+  mlir::StringAttr::get($_op->getContext(), llvm::Twine{"omp.host_ir_filepath"}),
+mlir::StringAttr::get($_op->getContext(), hostIRFilePath));
+   }]>,
+  InterfaceMethod<
+  /*description=*/[{
+Find the host-ir file path StringAttr from the current module if it exists and 
+return its contained value, if it doesn't exist it returns an empty string. This 
+file path is used in two-phase compilation during the device phase to generate
+device side LLVM IR when lowering MLIR. 
+  }],
+  /*retTy=*/"llvm::StringRef",
+  /*methodName=*/"getHostIRFilePath", 
+  (ins), [{}], [{
+if (Attribute filepath = $_op->getAttr("omp.host_ir_filepath"))
+  if (filepath.isa())
+return filepath.dyn_cast().getValue();
+return {};
+  }]>
   ];
 }
 
Index: flang/test/Lower/OpenMP/omp-host-ir-flag.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/omp-host-ir-flag.f90
@@ -0,0 +1,6 @@
+!RUN: %flang_fc1 -emit-llvm-bc -fopenmp -o %t.bc %s 2>&1
+!RUN: %flang_fc1 -emit-mlir -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -o - %s 2>&1 | FileCheck %s
+
+!CHECK: module attributes {{{.*}}, omp.host_ir_filepath = "{{.*}}.bc", omp.is_device = #omp.isdevice{{.*}}}
+subroutine omp_subroutine()
+end subroutine omp_subroutine
\ No newline at end of file
Index: flang/test/Driver/omp-frontend-forwarding.f90
===
--- flang/test/Driver/omp-frontend-forwarding.f90
+++ flang/test/Driver/omp-frontend-forwarding.f90
@@ -11,15 +11,15 @@
 ! RUN: %flang -### -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-DEVICE %s
 ! CHECK-OPENMP-IS-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
 
-! Testing 

[PATCH] D147969: Add InsertBraces to ChromiumStyle

2023-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Format/Format.cpp:1699
 ChromiumStyle.DerivePointerAlignment = false;
+ChromiumStyle.InsertBraces = true;
 if (Language == FormatStyle::LK_ObjC)

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > This is an code modifying feature, we agreed that all code modifying 
> > features would be off by default, opt in only
> Now the question arises if //default// simply only applies to `LLVMStyle`, 
> since that's the //default// when nothing is stated, or if other styles are 
> free to enable such features in their style //by default//.
> 
> I'd say if chromium wants to do that, they should be allowed to.
The community reacted pretty strongly to clang-format mutating code in ways 
that may change the meaning of code unless there is an explicit opt-in. The 
reason for that is because the opt-in + documentation is what informs the user 
that the feature may break their code, so removing that opt-in for the Chromium 
style means those users have no idea about the dangers. (In general, users take 
a dim view of a formatting tool that breaks code.)

Personally, I think if the Chromium *project* wants that to be the default, 
they can use .clang-format files in their version control to make it so, but I 
don't think the Chromium *style* built into clang-format should allow it by 
default because that may be used by a wider audience than just Chromium 
developers. Basically, I think we want to be conservative with formatting 
features that can potentially break code (once we start breaking user code with 
a formatting tool, that tool gets pulled out of affected people's CI pipelines 
pretty quickly, which I think we generally want to avoid).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147969/new/

https://reviews.llvm.org/D147969

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


[PATCH] D147946: [clang-tidy] support nested inline namespace in c++20 for modernize-concat-nested-namespaces

2023-04-11 Thread Congcong Cai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32aaacc609e7: [clang-tidy] support nested inline namespace 
in c++20 for modernize-concat… (authored by HerrCai0907).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147946/new/

https://reviews.llvm.org/D147946

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp
@@ -1,13 +1,13 @@
 // RUN: cp %S/Inputs/concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
-// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: %check_clang_tidy -std=c++17 -check-suffix=NORMAL %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
 // RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
 // Restore header file and re-run with c++20:
 // RUN: cp %S/Inputs/concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
-// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: %check_clang_tidy -std=c++20 -check-suffixes=NORMAL,CPP20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
 // RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
 
 #include "modernize-concat-nested-namespaces.h"
-// CHECK-MESSAGES-DAG: modernize-concat-nested-namespaces.h:1:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-NORMAL-DAG: modernize-concat-nested-namespaces.h:1:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 
 namespace n1 {}
 
@@ -20,12 +20,6 @@
 }
 } // namespace n2
 
-namespace n5 {
-inline namespace inline_ns {
-void t();
-} // namespace inline_ns
-} // namespace n5
-
 namespace n6 {
 namespace [[deprecated]] attr_ns {
 void t();
@@ -42,17 +36,17 @@
 
 namespace n9 {
 namespace n10 {
-// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n9::n10
+// CHECK-MESSAGES-NORMAL-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-FIXES-NORMAL: namespace n9::n10
 void t();
 } // namespace n10
 } // namespace n9
-// CHECK-FIXES: }
+// CHECK-FIXES-NORMAL: }
 
 namespace n11 {
 namespace n12 {
-// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n11::n12
+// CHECK-MESSAGES-NORMAL-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-FIXES-NORMAL: namespace n11::n12
 namespace n13 {
 void t();
 }
@@ -61,7 +55,7 @@
 }
 } // namespace n12
 } // namespace n11
-// CHECK-FIXES: }
+// CHECK-FIXES-NORMAL: }
 
 namespace n15 {
 namespace n16 {
@@ -75,13 +69,13 @@
 namespace n18 {
 namespace n19 {
 namespace n20 {
-// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n18::n19::n20
+// CHECK-MESSAGES-NORMAL-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-FIXES-NORMAL: namespace n18::n19::n20
 void t();
 } // namespace n20
 } // namespace n19
 } // namespace n18
-// CHECK-FIXES: }
+// CHECK-FIXES-NORMAL: }
 
 namespace n21 {
 void t();
@@ -98,38 +92,36 @@
 namespace {
 namespace n24 {
 namespace n25 {
-// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n24::n25
+// CHECK-MESSAGES-NORMAL-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-FIXES-NORMAL: namespace n24::n25
 void t();
 } // namespace n25
 } // namespace n24
-// CHECK-FIXES: }
+// CHECK-FIXES-NORMAL: }
 } // namespace
 } // namespace n23
 
 namespace n26::n27 {
 namespace n28 {
 namespace n29::n30 {
-// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: 

[clang-tools-extra] 32aaacc - [clang-tidy] support nested inline namespace in c++20 for modernize-concat-nested-namespaces

2023-04-11 Thread Congcong Cai via cfe-commits

Author: Congcong Cai
Date: 2023-04-11T21:28:11+02:00
New Revision: 32aaacc609e7a0523d498b244e081ac6f3df532b

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

LOG: [clang-tidy] support nested inline namespace in c++20 for 
modernize-concat-nested-namespaces

Fixed https://github.com/llvm/llvm-project/issues/56022
c++20 support namespace like `namespace a::inline b {}`.
If an inline namespace is not the first, it can be concatened.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D147946

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.rst

clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
index beaa4eeaeb5e7..d24b613015d8e 100644
--- a/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
@@ -30,30 +30,6 @@ static StringRef getRawStringRef(const SourceRange ,
   return Lexer::getSourceText(TextRange, Sources, LangOpts);
 }
 
-static bool unsupportedNamespace(const NamespaceDecl ) {
-  return ND.isAnonymousNamespace() || ND.isInlineNamespace() ||
- !ND.attrs().empty();
-}
-
-static bool singleNamedNamespaceChild(const NamespaceDecl ) {
-  NamespaceDecl::decl_range Decls = ND.decls();
-  if (std::distance(Decls.begin(), Decls.end()) != 1)
-return false;
-
-  const auto *ChildNamespace = dyn_cast(*Decls.begin());
-  return ChildNamespace && !unsupportedNamespace(*ChildNamespace);
-}
-
-template 
-static void concatNamespace(NamespaceName , R &,
-F &) {
-  for (auto const  : Range) {
-ConcatNameSpace.append(Stringify(V));
-if (V != Range.back())
-  ConcatNameSpace.append("::");
-  }
-}
-
 std::optional
 NS::getCleanedNamespaceFrontRange(const SourceManager ,
   const LangOptions ) const {
@@ -90,19 +66,53 @@ SourceRange NS::getNamespaceBackRange(const SourceManager 
,
 return getDefaultNamespaceBackRange();
   SourceRange TokRange = SourceRange{Tok->getLocation(), Tok->getEndLoc()};
   StringRef TokText = getRawStringRef(TokRange, SM, LangOpts);
-  std::string CloseComment = ("namespace " + getName()).str();
+  NamespaceName CloseComment{"namespace "};
+  appendCloseComment(CloseComment);
   // current fix hint in readability/NamespaceCommentCheck.cpp use single line
   // comment
-  if (TokText != "// " + CloseComment && TokText != "//" + CloseComment)
+  constexpr size_t L = sizeof("//") - 1U;
+  if (TokText.take_front(L) == "//" &&
+  TokText.drop_front(L).trim() != CloseComment)
 return getDefaultNamespaceBackRange();
   return SourceRange{front()->getRBraceLoc(), Tok->getEndLoc()};
 }
 
-NamespaceName NS::getName() const {
-  NamespaceName Name{};
-  concatNamespace(Name, *this,
-  [](const NamespaceDecl *ND) { return ND->getName(); });
-  return Name;
+void NS::appendName(NamespaceName ) const {
+  for (const NamespaceDecl *ND : *this) {
+if (ND->isInlineNamespace())
+  Str.append("inline ");
+Str.append(ND->getName());
+if (ND != back())
+  Str.append("::");
+  }
+}
+void NS::appendCloseComment(NamespaceName ) const {
+  if (size() == 1)
+Str.append(back()->getName());
+  else
+appendName(Str);
+}
+
+bool ConcatNestedNamespacesCheck::unsupportedNamespace(const NamespaceDecl ,
+   bool IsChild) const {
+  if (ND.isAnonymousNamespace() || !ND.attrs().empty())
+return true;
+  if (getLangOpts().CPlusPlus20) {
+// C++20 support inline nested namespace
+bool IsFirstNS = IsChild || !Namespaces.empty();
+return ND.isInlineNamespace() && !IsFirstNS;
+  }
+  return ND.isInlineNamespace();
+}
+
+bool ConcatNestedNamespacesCheck::singleNamedNamespaceChild(
+const NamespaceDecl ) const {
+  NamespaceDecl::decl_range Decls = ND.decls();
+  if (std::distance(Decls.begin(), Decls.end()) != 1)
+return false;
+
+  const auto *ChildNamespace = dyn_cast(*Decls.begin());
+  return ChildNamespace && !unsupportedNamespace(*ChildNamespace, true);
 }
 
 void ConcatNestedNamespacesCheck::registerMatchers(
@@ -137,8 +147,11 @@ void ConcatNestedNamespacesCheck::reportDiagnostic(
   SourceRange LastRBrace = Backs.pop_back_val();
 
   NamespaceName ConcatNameSpace{"namespace "};
-  concatNamespace(ConcatNameSpace, Namespaces,
-  

[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/include/clang/AST/RawCommentList.h:122
+StringRef Text = getRawText(SourceMgr);
+if (Text.size() < 6 || Text[0] != '/')
+  return false;

aaron.ballman wrote:
> Just to double-check, we don't have to worry about there being leading 
> whitespace in `Text` do we?
Afaict, we always have a valid comment, starting with / (and ending with / for 
a multi line comment). We might not have a comment valid for documentation 
purposes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148029/new/

https://reviews.llvm.org/D148029

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


[PATCH] D143364: [RISCV] Support scalar/fix-length vector NTLH intrinsic with different domain

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Code like `llvm::combineMetadataForCSE` assumes that the !nontemporal metadata 
can be copied from one node if both nodes have it. If the 2 nodes have 
different values we need a rule of which one to pick. We can't just pick 
arbitrarily.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143364/new/

https://reviews.llvm.org/D143364

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


[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/RawCommentList.h:122
+StringRef Text = getRawText(SourceMgr);
+if (Text.size() < 6 || Text[0] != '/')
+  return false;

Just to double-check, we don't have to worry about there being leading 
whitespace in `Text` do we?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148029/new/

https://reviews.llvm.org/D148029

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


[PATCH] D147895: [clang-format] Handle Verilog assertions and loops

2023-04-11 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:844
 "};");
-  ASSERT_EQ(Tokens.size(), 44u);
+  ASSERT_EQ(Tokens.size(), 44u) << Tokens;
   EXPECT_TOKEN(Tokens[13], tok::kw_requires, TT_RequiresClause);

sstwcw wrote:
> HazardyKnusperkeks wrote:
> > Unrelated, I'd prefer it as a single commit.
> How should I name the separate commit?
I'd go with
[clang-format][NFC] Output tokens on test assert
or similar.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147895/new/

https://reviews.llvm.org/D147895

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


[PATCH] D147969: Add InsertBraces to ChromiumStyle

2023-04-11 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/Format.cpp:1699
 ChromiumStyle.DerivePointerAlignment = false;
+ChromiumStyle.InsertBraces = true;
 if (Language == FormatStyle::LK_ObjC)

MyDeveloperDay wrote:
> This is an code modifying feature, we agreed that all code modifying features 
> would be off by default, opt in only
Now the question arises if //default// simply only applies to `LLVMStyle`, 
since that's the //default// when nothing is stated, or if other styles are 
free to enable such features in their style //by default//.

I'd say if chromium wants to do that, they should be allowed to.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147969/new/

https://reviews.llvm.org/D147969

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


[PATCH] D148035: [clang] Add test for CWG1837

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa7aedd8ea3f: [clang] Add test for CWG1837 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148035/new/

https://reviews.llvm.org/D148035

Files:
  clang/test/CXX/drs/dr18xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -10829,7 +10829,7 @@
 https://wg21.link/cwg1837;>1837
 CD6
 Use of this in friend and local class 
declarations
-Unknown
+Clang 3.3
   
   
 https://wg21.link/cwg1838;>1838
Index: clang/test/CXX/drs/dr18xx.cpp
===
--- clang/test/CXX/drs/dr18xx.cpp
+++ clang/test/CXX/drs/dr18xx.cpp
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-error@+1 {{variadic macro}}
@@ -59,6 +60,43 @@
 #endif
 }
 
+namespace dr1837 { // dr1837: 3.3
+#if __cplusplus >= 201103L
+  template 
+  struct Fish { static const bool value = true; };
+
+  struct Other {
+int p();
+auto q() -> decltype(p()) *;
+  };
+
+  class Outer {
+friend auto Other::q() -> decltype(this->p()) *; // expected-error 
{{invalid use of 'this'}}
+int g();
+int f() {
+  extern void f(decltype(this->g()) *);
+  struct Inner {
+static_assert(Fishg())>::value, ""); // expected-error 
{{invalid use of 'this'}}
+enum { X = Fishf())>::value }; // expected-error 
{{invalid use of 'this'}}
+struct Inner2 : Fishg())> { }; // expected-error 
{{invalid use of 'this'}}
+friend void f(decltype(this->g()) *); // expected-error {{invalid use 
of 'this'}}
+friend auto Other::q() -> decltype(this->p()) *; // expected-error 
{{invalid use of 'this'}}
+  };
+  return 0;
+}
+  };
+
+  struct A {
+int f();
+bool b = [] {
+  struct Local {
+static_assert(sizeof(this->f()) == sizeof(int), "");
+  };
+};
+  };
+#endif
+}
+
 namespace dr1872 { // dr1872: 9
 #if __cplusplus >= 201103L
   template struct A : T {


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -10829,7 +10829,7 @@
 https://wg21.link/cwg1837;>1837
 CD6
 Use of this in friend and local class declarations
-Unknown
+Clang 3.3
   
   
 https://wg21.link/cwg1838;>1838
Index: clang/test/CXX/drs/dr18xx.cpp
===
--- clang/test/CXX/drs/dr18xx.cpp
+++ clang/test/CXX/drs/dr18xx.cpp
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-error@+1 {{variadic macro}}
@@ -59,6 +60,43 @@
 #endif
 }
 
+namespace dr1837 { // dr1837: 3.3
+#if __cplusplus >= 201103L
+  template 
+  struct Fish { static const bool value = true; };
+
+  struct Other {
+int p();
+auto q() -> decltype(p()) *;
+  };
+
+  class Outer {
+friend auto Other::q() -> decltype(this->p()) *; // expected-error {{invalid use of 'this'}}
+int 

[clang] aa7aedd - [clang] Add test for CWG1837

2023-04-11 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-04-11T22:15:11+03:00
New Revision: aa7aedd8ea3f75ddfb3004b81f09c5f653bc8fec

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

LOG: [clang] Add test for CWG1837

[[https://wg21.link/p1787 | P1787]]: CWG1837 is resolved by restricting `this` 
to referring to the innermost enclosing class.
Wording: see changes to [expr.prim.this] and [expr.prim.lambda].

Reviewed By: #clang-language-wg, erichkeane

Differential Revision: https://reviews.llvm.org/D148035

Added: 


Modified: 
clang/test/CXX/drs/dr18xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index 55f79295934c..02739cd2c000 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-error@+1 {{variadic macro}}
@@ -59,6 +60,43 @@ namespace dr1822 { // dr1822: yes
 #endif
 }
 
+namespace dr1837 { // dr1837: 3.3
+#if __cplusplus >= 201103L
+  template 
+  struct Fish { static const bool value = true; };
+
+  struct Other {
+int p();
+auto q() -> decltype(p()) *;
+  };
+
+  class Outer {
+friend auto Other::q() -> decltype(this->p()) *; // expected-error 
{{invalid use of 'this'}}
+int g();
+int f() {
+  extern void f(decltype(this->g()) *);
+  struct Inner {
+static_assert(Fishg())>::value, ""); // expected-error 
{{invalid use of 'this'}}
+enum { X = Fishf())>::value }; // expected-error 
{{invalid use of 'this'}}
+struct Inner2 : Fishg())> { }; // expected-error 
{{invalid use of 'this'}}
+friend void f(decltype(this->g()) *); // expected-error {{invalid use 
of 'this'}}
+friend auto Other::q() -> decltype(this->p()) *; // expected-error 
{{invalid use of 'this'}}
+  };
+  return 0;
+}
+  };
+
+  struct A {
+int f();
+bool b = [] {
+  struct Local {
+static_assert(sizeof(this->f()) == sizeof(int), "");
+  };
+};
+  };
+#endif
+}
+
 namespace dr1872 { // dr1872: 9
 #if __cplusplus >= 201103L
   template struct A : T {

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 67350fa35938..bac8a52c2d5b 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -10829,7 +10829,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg1837;>1837
 CD6
 Use of this in friend and local class 
declarations
-Unknown
+Clang 3.3
   
   
 https://wg21.link/cwg1838;>1838



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


[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D147073#4258664 , @zequanwu wrote:

> In D147073#4258529 , @aaron.ballman 
> wrote:
>
>> In D147073#4258426 , @zequanwu 
>> wrote:
>>
>>> In D147073#4258396 , 
>>> @aaron.ballman wrote:
>>>
 In D147073#4258384 , @hans wrote:

> Again not an expert here, but lgtm.
>
> (Nit: the 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1528-L1530
>  link in the description seems to point to the wrong code now, since main 
> changed. Here is a link for 16.0.1: 
> https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536)

 I'm confused -- I thought D147569  
 resolved the issue and so this patch is no longer needed?
>>>
>>> D147569  fixes 
>>> https://github.com/llvm/llvm-project/issues/45481. This one fixes another 
>>> issue crbug.com/1427933. Their stack trace look similar but not caused by 
>>> the same issue.
>>>
>>> Updated the link in summary to: 
>>> https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536
>>
>> Thank you for clarifying, I was confused. :-)
>>
>> I don't think the changes here are correct either -- it's glossing over an 
>> issue that we're not properly tracking the source location in the AST. 
>> Playing around with the reduced example is interesting though. If you remove 
>> the default argument in the `T` constructor, the issue goes away. If you 
>> stop using a forward declaration in the instantiation of `T`, the issue goes 
>> away. If `S1` isn't a template, the issue goes away (but the issue will come 
>> back if you then make `foo()` a template instead of `S1`). So it seems that 
>> something about template instantiation is dropping the source location 
>> information (perhaps) and we should be trying to track down where that is to 
>> fix the root cause rather than work around it here for coverage mapping 
>> alone. (The end location being incorrect can impact other things that are 
>> harder to test because it'll be for things like fix-its that don't work 
>> properly, which are easy to miss.)
>
> I agree that the real fix is to fix the source location information. If I 
> just change [1] to `SourceRange Locs = SourceRange(LParenOrBraceLoc, 
> RParenOrBraceLoc);`, the crash is gone. However, as the "FIXME" comment in 
> [1] says, it's an intended work-around to drop source locations here. So, I'm 
> assuming this kind of source location work-around could happen in multiple 
> places in clang, and could happen in the future as a temporary work-around. 
> Instead of crashing clang coverage for those work-around, we can at least 
> skip coverage info for those expressions/statements.
>
> [1]: 
> https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1538

Ugh, that workaround is unfortunate.

You are correct that this same situation may come up in the future, but each 
time it happens, I think it's a bug in the FE that needs to be addressed. I 
worry that silencing the issues here will 1) lead to the actual bug staying in 
the code base forever, and 2) be used as justification for making the same 
workaround elsewhere in the code base, perhaps so often that it becomes "the 
way things are supposed to work".

Perhaps a way to split the middle would be to assert that the source locations 
are valid in coverage mapping, but then do the right thing in non-asserts 
builds instead of crashing. This way, we don't lose the benefit of knowing the 
issues happen in development builds, but we don't punish users of coverage 
mapping with the released product. WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147073/new/

https://reviews.llvm.org/D147073

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


[PATCH] D143364: [RISCV] Support scalar/fix-length vector NTLH intrinsic with different domain

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:19975
+llvm::Type *ResTy = ConvertType(E->getType());
+ConstantInt *Mode = llvm::cast(Ops[1]);
+

Is `llvm::` needed on the `cast`? I think cast is imported into the clang 
namespace.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:19975
+llvm::Type *ResTy = ConvertType(E->getType());
+ConstantInt *Mode = llvm::cast(Ops[1]);
+

craig.topper wrote:
> Is `llvm::` needed on the `cast`? I think cast is imported into the clang 
> namespace.
You can drop llvm:: on ConstantInt in the cast since you didn't need it for the 
`ConstantInt *Mode` part.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:19990
+  case RISCV::BI__builtin_riscv_ntl_store: {
+ConstantInt *Mode = llvm::cast(Ops[2]);
+

Same comments as above



Comment at: clang/lib/Headers/riscv_ntlh.h:24
+
+#define __riscv_ntl_load(PTR, DOMAIN) __builtin_riscv_ntl_load(PTR, DOMAIN)
+#define __riscv_ntl_store(PTR, VAL, DOMAIN)
\

Need parentheses around PTR and DOMAIN in the expansion.

```
#define __riscv_ntl_load(PTR, DOMAIN) __builtin_riscv_ntl_load((PTR), (DOMAIN))
```



Comment at: clang/lib/Headers/riscv_ntlh.h:26
+#define __riscv_ntl_store(PTR, VAL, DOMAIN)
\
+  __builtin_riscv_ntl_store(PTR, VAL, DOMAIN)
+

Same here



Comment at: clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c:115
+  __riscv_ntl_store(, 1.0, __RISCV_NTLH_ALL);  // CHECK: store 
double{{.*}}align 8, !nontemporal !7
+
+}

Do we need to test vectors?



Comment at: clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c:119
+
+// CHECK: !4 = !{i32 2}
+// CHECK: !5 = !{i32 3}

There are multiple places in the LangRef that say the nontemporal node can only 
have value of 1.

```
The optional !nontemporal metadata must reference a single metadata name 
 corresponding to a metadata node with one i32 entry of value 1.
```

At the very least those need to be updated.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZihintntl.td:14
 
-let hasSideEffects = 0, mayLoad = 0, mayStore = 0, Size = 4 in {
-  def PseudoNTLALL :  Pseudo<(outs), (ins), [], "ntl.all">, 
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0, Size = 4, isCodeGenOnly = 1 
in {
+  def PseudoNTLP1   :  Pseudo<(outs), (ins), [], "ntl.p1">, 

Doesn't Pseudo already set isCodeGenOnly=1?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143364/new/

https://reviews.llvm.org/D143364

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


[PATCH] D147839: [clang] Add test for CWG2007

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4beecef8f40: [clang] Add test for CWG2007 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147839/new/

https://reviews.llvm.org/D147839

Files:
  clang/test/CXX/drs/dr20xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -11849,7 +11849,7 @@
 https://wg21.link/cwg2007;>2007
 CD6
 Argument-dependent lookup for operator=
-Unknown
+Clang 3.4
   
   
 https://wg21.link/cwg2008;>2008
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -3,12 +3,22 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 #define static_assert(...) _Static_assert(__VA_ARGS__)
 #endif
 
+namespace dr2007 { // dr2007: 3.4
+template struct A { typename T::error e; };
+template struct B { };
+B > b1;
+B > b2 = b1;
+int a = b2[0]; // expected-error {{does not provide a subscript operator}}
+int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+}
+
 namespace dr2026 { // dr2026: 11
   template struct X {};
 


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -11849,7 +11849,7 @@
 https://wg21.link/cwg2007;>2007
 CD6
 Argument-dependent lookup for operator=
-Unknown
+Clang 3.4
   
   
 https://wg21.link/cwg2008;>2008
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -3,12 +3,22 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 #define static_assert(...) _Static_assert(__VA_ARGS__)
 #endif
 
+namespace dr2007 { // dr2007: 3.4
+template struct A { typename T::error e; };
+template struct B { };
+B > b1;
+B > b2 = b1;
+int a = b2[0]; // expected-error {{does not provide a subscript operator}}
+int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+}
+
 namespace dr2026 { // dr2026: 11
   template struct X {};
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a4beece - [clang] Add test for CWG2007

2023-04-11 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-04-11T22:13:43+03:00
New Revision: a4beecef8f40ad0d42f61e7c495acb2d2d819b10

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

LOG: [clang] Add test for CWG2007

[[https://wg21.link/p1787 | P1787]]: CWG2007 is resolved by skipping 
unqualified lookup for operators that must be member functions.
Wording: For the operators =, [], or ->, the set of non-member candidates is 
empty; otherwise, it includes the result of the unqualified lookup for 
operator@... ([over.match.oper]/3)

Reviewed By: #clang-language-wg, shafik

Differential Revision: https://reviews.llvm.org/D147839

Added: 


Modified: 
clang/test/CXX/drs/dr20xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index c167f41397c1..61fdb81854a4 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -3,12 +3,22 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 #define static_assert(...) _Static_assert(__VA_ARGS__)
 #endif
 
+namespace dr2007 { // dr2007: 3.4
+template struct A { typename T::error e; };
+template struct B { };
+B > b1;
+B > b2 = b1;
+int a = b2[0]; // expected-error {{does not provide a subscript operator}}
+int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+}
+
 namespace dr2026 { // dr2026: 11
   template struct X {};
 

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 863e20a57e2c..67350fa35938 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -11849,7 +11849,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg2007;>2007
 CD6
 Argument-dependent lookup for operator=
-Unknown
+Clang 3.4
   
   
 https://wg21.link/cwg2008;>2008



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


[PATCH] D147839: [clang] Add test for CWG2007

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill updated this revision to Diff 512543.
Endill added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147839/new/

https://reviews.llvm.org/D147839

Files:
  clang/test/CXX/drs/dr20xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -11849,7 +11849,7 @@
 https://wg21.link/cwg2007;>2007
 CD6
 Argument-dependent lookup for operator=
-Unknown
+Clang 3.4
   
   
 https://wg21.link/cwg2008;>2008
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -3,12 +3,22 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 #define static_assert(...) _Static_assert(__VA_ARGS__)
 #endif
 
+namespace dr2007 { // dr2007: 3.4
+template struct A { typename T::error e; };
+template struct B { };
+B > b1;
+B > b2 = b1;
+int a = b2[0]; // expected-error {{does not provide a subscript operator}}
+int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+}
+
 namespace dr2026 { // dr2026: 11
   template struct X {};
 


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -11849,7 +11849,7 @@
 https://wg21.link/cwg2007;>2007
 CD6
 Argument-dependent lookup for operator=
-Unknown
+Clang 3.4
   
   
 https://wg21.link/cwg2008;>2008
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -3,12 +3,22 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 #define static_assert(...) _Static_assert(__VA_ARGS__)
 #endif
 
+namespace dr2007 { // dr2007: 3.4
+template struct A { typename T::error e; };
+template struct B { };
+B > b1;
+B > b2 = b1;
+int a = b2[0]; // expected-error {{does not provide a subscript operator}}
+int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+}
+
 namespace dr2026 { // dr2026: 11
   template struct X {};
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147946: [clang-tidy] support nested inline namespace in c++20 for modernize-concat-nested-namespaces

2023-04-11 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 512541.
HerrCai0907 added a comment.

update acc. comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147946/new/

https://reviews.llvm.org/D147946

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp
@@ -1,13 +1,13 @@
 // RUN: cp %S/Inputs/concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
-// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: %check_clang_tidy -std=c++17 -check-suffix=NORMAL %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
 // RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
 // Restore header file and re-run with c++20:
 // RUN: cp %S/Inputs/concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
-// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: %check_clang_tidy -std=c++20 -check-suffixes=NORMAL,CPP20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
 // RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
 
 #include "modernize-concat-nested-namespaces.h"
-// CHECK-MESSAGES-DAG: modernize-concat-nested-namespaces.h:1:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-NORMAL-DAG: modernize-concat-nested-namespaces.h:1:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 
 namespace n1 {}
 
@@ -20,12 +20,6 @@
 }
 } // namespace n2
 
-namespace n5 {
-inline namespace inline_ns {
-void t();
-} // namespace inline_ns
-} // namespace n5
-
 namespace n6 {
 namespace [[deprecated]] attr_ns {
 void t();
@@ -42,17 +36,17 @@
 
 namespace n9 {
 namespace n10 {
-// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n9::n10
+// CHECK-MESSAGES-NORMAL-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-FIXES-NORMAL: namespace n9::n10
 void t();
 } // namespace n10
 } // namespace n9
-// CHECK-FIXES: }
+// CHECK-FIXES-NORMAL: }
 
 namespace n11 {
 namespace n12 {
-// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n11::n12
+// CHECK-MESSAGES-NORMAL-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-FIXES-NORMAL: namespace n11::n12
 namespace n13 {
 void t();
 }
@@ -61,7 +55,7 @@
 }
 } // namespace n12
 } // namespace n11
-// CHECK-FIXES: }
+// CHECK-FIXES-NORMAL: }
 
 namespace n15 {
 namespace n16 {
@@ -75,13 +69,13 @@
 namespace n18 {
 namespace n19 {
 namespace n20 {
-// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n18::n19::n20
+// CHECK-MESSAGES-NORMAL-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-FIXES-NORMAL: namespace n18::n19::n20
 void t();
 } // namespace n20
 } // namespace n19
 } // namespace n18
-// CHECK-FIXES: }
+// CHECK-FIXES-NORMAL: }
 
 namespace n21 {
 void t();
@@ -98,38 +92,36 @@
 namespace {
 namespace n24 {
 namespace n25 {
-// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n24::n25
+// CHECK-MESSAGES-NORMAL-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-FIXES-NORMAL: namespace n24::n25
 void t();
 } // namespace n25
 } // namespace n24
-// CHECK-FIXES: }
+// CHECK-FIXES-NORMAL: }
 } // namespace
 } // namespace n23
 
 namespace n26::n27 {
 namespace n28 {
 namespace n29::n30 {
-// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: 

[PATCH] D147848: [clang] Add test for CWG2370

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfeb93d28b02c: [clang] Add test for CWG2370 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147848/new/

https://reviews.llvm.org/D147848

Files:
  clang/test/CXX/drs/dr23xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -14027,7 +14027,7 @@
 https://wg21.link/cwg2370;>2370
 CD6
 friend declarations of namespace-scope functions
-Unknown
+No
   
   
 https://wg21.link/cwg2371;>2371
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -2,7 +2,9 @@
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
+
 
 #if __cplusplus >= 201103L
 namespace dr2338 { // dr2338: 12
@@ -169,6 +171,20 @@
 } //namespace dr2303
 #endif
 
+namespace dr2370 { // dr2370: no
+namespace N {
+typedef int type;
+void g(type);
+void h(type);
+} // namespace N
+class C {
+  typedef N::type N_type;
+  // FIXME: `type` should be searched for in N
+  // friend void N::g(type);
+  friend void N::h(N_type);
+};
+} // namespace dr2370
+
 // dr2385: na
 
 namespace dr2394 { // dr2394: 15


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -14027,7 +14027,7 @@
 https://wg21.link/cwg2370;>2370
 CD6
 friend declarations of namespace-scope functions
-Unknown
+No
   
   
 https://wg21.link/cwg2371;>2371
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -2,7 +2,9 @@
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+
 
 #if __cplusplus >= 201103L
 namespace dr2338 { // dr2338: 12
@@ -169,6 +171,20 @@
 } //namespace dr2303
 #endif
 
+namespace dr2370 { // dr2370: no
+namespace N {
+typedef int type;
+void g(type);
+void h(type);
+} // namespace N
+class C {
+  typedef N::type N_type;
+  // FIXME: `type` should be searched for in N
+  // friend void N::g(type);
+  friend void N::h(N_type);
+};
+} // namespace dr2370
+
 // dr2385: na
 
 namespace dr2394 { // dr2394: 15
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] feb93d2 - [clang] Add test for CWG2370

2023-04-11 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-04-11T22:04:02+03:00
New Revision: feb93d28b02c41ca6b069ec1f9e62fdfbb4c8b6c

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

LOG: [clang] Add test for CWG2370

[[https://wg21.link/p1787 | P1787]]: CWG2370 is resolved by performing a search 
in (only) the immediate scope of any friend, per the [[ 
http://wiki.edg.com/bin/view/Wg21sandiego2018/CoreWorkingGroup#Core_issue_2370_friend_declarati
 | CWG opinion from San Diego ]].
Wording: In a friend declaration declarator whose declarator-id is a 
qualified-id whose lookup context is a class or namespace S, lookup for an 
unqualified name that appears after the declarator-id performs a search in the 
scope associated with S. If that lookup finds nothing, it undergoes unqualified 
name lookup. ([basic.lookup.unqual]/6).

Clarification for P1787 description: when applied to the test in this patch, 
"immediate scope" refers to `N`, and "(only)" refers to the fact that `type` is 
not searched in parent scope of `N`. See example after the wording if 
additional clarification is needed. The most relevant line there is `friend 
void A::f(F);  // OK`.

Reviewed By: #clang-language-wg, shafik

Differential Revision: https://reviews.llvm.org/D147848

Added: 


Modified: 
clang/test/CXX/drs/dr23xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp
index a60aa8e5609c6..4f16746aad8be 100644
--- a/clang/test/CXX/drs/dr23xx.cpp
+++ b/clang/test/CXX/drs/dr23xx.cpp
@@ -2,7 +2,9 @@
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors 2>&1 | FileCheck %s
+
 
 #if __cplusplus >= 201103L
 namespace dr2338 { // dr2338: 12
@@ -169,6 +171,20 @@ void g() {
 } //namespace dr2303
 #endif
 
+namespace dr2370 { // dr2370: no
+namespace N {
+typedef int type;
+void g(type);
+void h(type);
+} // namespace N
+class C {
+  typedef N::type N_type;
+  // FIXME: `type` should be searched for in N
+  // friend void N::g(type);
+  friend void N::h(N_type);
+};
+} // namespace dr2370
+
 // dr2385: na
 
 namespace dr2394 { // dr2394: 15

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 6e234f63fc015..863e20a57e2cd 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -14027,7 +14027,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg2370;>2370
 CD6
 friend declarations of namespace-scope functions
-Unknown
+No
   
   
 https://wg21.link/cwg2371;>2371



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


[PATCH] D148035: [clang] Add test for CWG1837

2023-04-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This seems right based on the paper listed/standardeeze.  Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148035/new/

https://reviews.llvm.org/D148035

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


[PATCH] D148035: [clang] Add test for CWG1837

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill updated this revision to Diff 512538.
Endill added a comment.

minor fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148035/new/

https://reviews.llvm.org/D148035

Files:
  clang/test/CXX/drs/dr18xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -10829,7 +10829,7 @@
 https://wg21.link/cwg1837;>1837
 CD6
 Use of this in friend and local class 
declarations
-Unknown
+Clang 3.3
   
   
 https://wg21.link/cwg1838;>1838
Index: clang/test/CXX/drs/dr18xx.cpp
===
--- clang/test/CXX/drs/dr18xx.cpp
+++ clang/test/CXX/drs/dr18xx.cpp
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-error@+1 {{variadic macro}}
@@ -59,6 +60,43 @@
 #endif
 }
 
+namespace dr1837 { // dr1837: 3.3
+#if __cplusplus >= 201103L
+  template 
+  struct Fish { static const bool value = true; };
+
+  struct Other {
+int p();
+auto q() -> decltype(p()) *;
+  };
+
+  class Outer {
+friend auto Other::q() -> decltype(this->p()) *; // expected-error 
{{invalid use of 'this'}}
+int g();
+int f() {
+  extern void f(decltype(this->g()) *);
+  struct Inner {
+static_assert(Fishg())>::value, ""); // expected-error 
{{invalid use of 'this'}}
+enum { X = Fishf())>::value }; // expected-error 
{{invalid use of 'this'}}
+struct Inner2 : Fishg())> { }; // expected-error 
{{invalid use of 'this'}}
+friend void f(decltype(this->g()) *); // expected-error {{invalid use 
of 'this'}}
+friend auto Other::q() -> decltype(this->p()) *; // expected-error 
{{invalid use of 'this'}}
+  };
+  return 0;
+}
+  };
+
+  struct A {
+int f();
+bool b = [] {
+  struct Local {
+static_assert(sizeof(this->f()) == sizeof(int), "");
+  };
+};
+  };
+#endif
+}
+
 namespace dr1872 { // dr1872: 9
 #if __cplusplus >= 201103L
   template struct A : T {


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -10829,7 +10829,7 @@
 https://wg21.link/cwg1837;>1837
 CD6
 Use of this in friend and local class declarations
-Unknown
+Clang 3.3
   
   
 https://wg21.link/cwg1838;>1838
Index: clang/test/CXX/drs/dr18xx.cpp
===
--- clang/test/CXX/drs/dr18xx.cpp
+++ clang/test/CXX/drs/dr18xx.cpp
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-error@+1 {{variadic macro}}
@@ -59,6 +60,43 @@
 #endif
 }
 
+namespace dr1837 { // dr1837: 3.3
+#if __cplusplus >= 201103L
+  template 
+  struct Fish { static const bool value = true; };
+
+  struct Other {
+int p();
+auto q() -> decltype(p()) *;
+  };
+
+  class Outer {
+friend auto Other::q() -> decltype(this->p()) *; // expected-error {{invalid use of 'this'}}
+int g();
+int f() {
+  extern void f(decltype(this->g()) *);
+  struct Inner {
+static_assert(Fishg())>::value, ""); // 

[PATCH] D148035: [clang] Add test for CWG1837

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : CWG1837 is resolved by restricting this to 
referring to the innermost enclosing class.
Wording: see changes to [expr.prim.this] and [expr.prim.lambda]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148035

Files:
  clang/test/CXX/drs/dr18xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -10829,7 +10829,7 @@
 https://wg21.link/cwg1837;>1837
 CD6
 Use of this in friend and local class 
declarations
-Unknown
+Clang 3.3
   
   
 https://wg21.link/cwg1838;>1838
Index: clang/test/CXX/drs/dr18xx.cpp
===
--- clang/test/CXX/drs/dr18xx.cpp
+++ clang/test/CXX/drs/dr18xx.cpp
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-error@+1 {{variadic macro}}
@@ -59,6 +60,43 @@
 #endif
 }
 
+namespace dr1837 { // dr1837: 3.3
+#if __cplusplus >= 201103L
+  template 
+  struct Fish { static const bool value = true; };
+
+  struct Other {
+int p();
+auto q() -> decltype(p()) *;
+  };
+
+  class Outer {
+friend auto Other::q() -> decltype(this->p()) *; // expected-error 
{{invalid use of 'this'}}
+int g();
+int f() {
+  extern void f(decltype(this->g()) *);
+  struct Inner {
+static_assert(Fishg())>::value, ""); // expected-error 
{{invalid use of 'this'}}
+enum { X = Fishf())>::value }; // expected-error 
{{invalid use of 'this'}}
+struct Inner2 : Fishg())> { }; // expected-error 
{{invalid use of 'this'}}
+friend void f(decltype(this->g()) *); // expected-error {{invalid use 
of 'this'}}
+friend auto Other::q() -> decltype(this->p()) *; // expected-error 
{{invalid use of 'this'}}
+  };
+  return 0;
+}
+  };
+
+  struct A {
+int f();
+auto b = [] {
+  struct Local {
+static_assert(sizeof(this->f()) == sizeof(int), "");
+  };
+};
+  };
+#endif
+}
+
 namespace dr1872 { // dr1872: 9
 #if __cplusplus >= 201103L
   template struct A : T {


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -10829,7 +10829,7 @@
 https://wg21.link/cwg1837;>1837
 CD6
 Use of this in friend and local class declarations
-Unknown
+Clang 3.3
   
   
 https://wg21.link/cwg1838;>1838
Index: clang/test/CXX/drs/dr18xx.cpp
===
--- clang/test/CXX/drs/dr18xx.cpp
+++ clang/test/CXX/drs/dr18xx.cpp
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-error@+1 {{variadic macro}}
@@ -59,6 +60,43 @@
 #endif
 }
 
+namespace dr1837 { // dr1837: 3.3
+#if __cplusplus >= 201103L
+  template 
+  struct Fish { static const bool value = true; };
+
+  struct Other {
+int p();
+auto q() -> decltype(p()) *;
+  };
+
+  

[PATCH] D147256: [DebugInfo] Fix file path separator when targeting windows.

2023-04-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D147256#4258419 , @zequanwu wrote:

> In D147256#4257797 , @hans wrote:
>
>> In D147256#4249527 , @zequanwu 
>> wrote:
>>
>>> - Add a `-use-target-path-separator` flag for llc.
>>> - Add test for llc with that flag.
>>
>> But where does `TM.Options.ObjectFilenameForDebug` come from? Presumably it 
>> comes from Clang at some point, so is there any chance we can fix it "at the 
>> source" instead?
>
> `TM.Options.ObjectFilenameForDebug` either comes from llc's `-o` or 
> clang-cl's `object-file-name=` which is translated from `/Fo[ObjectFileName]`.
>
> For Chromium, the `/Fo[ObjectFileName]` we pass to clang-cl is the same when 
> building on Windows and targeting Windows from Linux. The problem comes 
> `llvm::sys::path::remove_dots(PathStore, /*remove_dot_dot=*/true);` in 
> `CodeViewDebug.cpp`. That function always convert the path to use host's path 
> separator. And I don't think we can write a `remove_dots` function that 
> doesn't change path separator, because `\` can only be used as path separator 
> on Windows but is a valid path character on Linux.
>
> Or we could just not use `llvm::sys::path::remove_dots`, use the user's input 
> as it is for object file path.

Well, MSVC cl removes redundant dots so we shouldn't remove 
`llvm::sys::path::remove_dots`. 
Generally, I think it's okay to use target path separator for object file path 
in codeview when user input is not an absolute path, because we can only 
generate codeview when targeting on windows.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147256/new/

https://reviews.llvm.org/D147256

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


[PATCH] D141307: Add -f[no-]loop-versioning option

2023-04-11 Thread Mats Petersson via Phabricator via cfe-commits
Leporacanthicus updated this revision to Diff 512532.
Leporacanthicus added a comment.

Rebase only.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141307/new/

https://reviews.llvm.org/D141307

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/version-loops.f90

Index: flang/test/Driver/version-loops.f90
===
--- /dev/null
+++ flang/test/Driver/version-loops.f90
@@ -0,0 +1,54 @@
+! Test that flang-new forwards the -f{no-,}version-loops-for-stride 
+! options corredly to flang-new -fc1 for different variants of optimisation
+! and explicit flags.
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O3 \
+! RUN:   | FileCheck %s
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O2 \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O2
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O2 -fversion-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O2-with
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O4 \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O4
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -Ofast \
+! RUN:   | FileCheck %s --check-prefix=CHECK-Ofast
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -Ofast -fno-version-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-Ofast-no
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O3 -fno-version-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O3-no
+  
+! CHECK: "-fversion-loops-for-stride"
+! CHECK: "-O3"
+
+! CHECK-O2-NOT: "-fversion-loops-for-stride"
+! CHECK-O2: "-O2"  
+
+! CHECK-O2-with: "-fversion-loops-for-stride"
+! CHECK-O2-with: "-O2"  
+  
+! CHECK-O4: "-fversion-loops-for-stride"
+! CHECK-O4: "-O3"
+
+! CHECK-Ofast: "-ffast-math"
+! CHECK-Ofast: "-fversion-loops-for-stride"
+! CHECK-Ofast: "-O3"
+
+! CHECK-Ofast-no: "-ffast-math"
+! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride"
+! CHECK-Ofast-no: "-O3"
+
+! CHECK-O3-no-NOT: "-fversion-loops-for-stride"
+! CHECK-O3-no: "-O3"
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -15,6 +15,8 @@
 ! RUN: -fassociative-math \
 ! RUN: -freciprocal-math \
 ! RUN: -fpass-plugin=Bye%pluginext \
+! RUN: -fversion-loops-for-stride \
+! RUN: -mllvm -print-before-all\
 ! RUN: -mllvm -print-before-all \
 ! RUN: -save-temps=obj \
 ! RUN: -P \
@@ -34,5 +36,6 @@
 ! CHECK: "-freciprocal-math"
 ! CHECK: "-fconvert=little-endian"
 ! CHECK: "-fpass-plugin=Bye
+! CHECK: "-fversion-loops-for-stride"  
 ! CHECK: "-mllvm" "-print-before-all"
 ! CHECK: "-save-temps=obj"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -48,6 +48,8 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
+! HELP-NEXT: -fno-version-loops-for-stride
+! HELP-NEXT:Do not create unit-strided loops (default)
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
@@ -55,6 +57,8 @@
 ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names
+! HELP-NEXT: -fversion-loops-for-stride
+! HELP-NEXT:Create unit-strided versions of loops
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -gline-tables-only Emit debug line number tables only
 ! HELP-NEXT: -g Generate source-level debug information
@@ -143,6 +147,8 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
+! 

[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2023-04-11 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/test/Preprocessor/riscv-target-features.c:51
 // CHECK-NOT: __riscv_zcf {{.*$}}
+// CHECK-NOT: __riscv_zcmp
 // CHECK-NOT: __riscv_h {{.*$}}

Does this really belong in an MC patch?



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:2307
+OperandMatchResultTy RISCVAsmParser::parseReglist(OperandVector ) {
+  // Rlist grammar: {ra [, s0[-sN]]} (UABI)
+  // XRlist :{x1 [, x8[-x9][, x18[-xN]]]} (UABI)

What's UABI, a term that I've only really seen in the Linux community, got to 
do with assembly?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132819/new/

https://reviews.llvm.org/D132819

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


[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D148029#4258800 , @shafik wrote:

> Do we have a test that covers valid doxygen comments? I was looking and I 
> don't see an obvious one.

AFAICT, some in `CommentTextTest.cpp` - not that many though.




Comment at: clang/lib/Sema/Sema.cpp:2404
   break;
+case RawComment::RCK_Invalid:
+  // FIXME: are there other scenarios that could produce an invalid

shafik wrote:
> I don't get why we don't have to handle the other `RawComment` cases here.
Because they can't be `isAlmostTrailingComment` - which checks whether you 
forgot an additional `*` or `/`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148029/new/

https://reviews.llvm.org/D148029

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

So I don't see any handling of the dependent version of this, we probably need 
tests for those at minimum.




Comment at: clang/docs/ReleaseNotes.rst:355
+- Added ``attribute(riscv_rvv_vector_bits(__RISCV_RVV_VLEN_BITS))`` to allow
+  the size of a RVV scalable type to be specified. This allows scalable vector
+  types to be used in structs or in global variables.

Would love it if we defined "RVV" here.



Comment at: clang/include/clang/AST/ASTContext.h:2262
+  /// Return true if the given vector types are lax-compatible RVV vector 
types,
+  /// false otherwise.
+  bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);

Same here, what is 'lax compatible' mean here? And RVV?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11369
+  llvm::ScalableVectorType *ResType = nullptr;
+  switch (BT->getKind()) {
+  default:

I wonder if at least the inner type can be picked up ConvertType instead.  
There doesn't seem to be obvious rhyme/reason to the last argument to 
ScalableVectorType, so it might not solve that.

However, it'll solve the long problem.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:11390
+ResType = llvm::ScalableVectorType::get(
+llvm::Type::getIntNTy(getVMContext(), XLen), 64 / XLen);
+break;

Where is 'XLen' from here?  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D147920: [clang] Add test for CWG399

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added inline comments.



Comment at: clang/test/CXX/drs/dr3xx.cpp:1439
+
+namespace dr399 { // dr399: 11
+  // NB: reuse dr244 test 

shafik wrote:
> Endill wrote:
> > Despite a couple of FIXME in CWG244 test (out of dozens of examples), it 
> > claims full availability since Clang 11. I'd take a more conservative 
> > approach, declaring partial support, but I think that declaring different 
> > availability for the same test would bring unnecessary confusion. So I 
> > followed CWG244 availability.
> > 
> > Alternative is to demote CWG244 to partial, but I'm not sure we should go 
> > back on our claims for CWG support that has been out for so long.
> I think the bugs are not awful, we should file bug reports if we don't 
> already have them. Some of them seem like they should be not too bad to fix.
> 
> CC @aaron.ballman to get a second opinion
If we are to file bug reports, I'm not sure what wording makes those examples 
ill-formed. Is it [[ http://eel.is/c++draft/basic.lookup#qual.general-4.6 | 
qual.general-4.6 ]]: `The type-name that is or contains Q shall refer to its 
(original) lookup context (ignoring cv-qualification) under the interpretation 
established by at least one (successful) lookup performed.`? I interpret it as 
requiring names to the left and to the right of `~` to be found in the same 
scope (lookup context; `namespace dr244` in our case). Could it actually mean 
that they have to refer to the same type?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147920/new/

https://reviews.llvm.org/D147920

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145088/new/

https://reviews.llvm.org/D145088

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


[PATCH] D148034: [clang][driver] Disable GP relaxation with RISC-V ShadowCallStack

2023-04-11 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth created this revision.
paulkirth added reviewers: phosek, mcgrathr, jrtc27, craig.topper, 
aaron.ballman.
Herald added subscribers: VincentWu, vkmr, luismarques, sameer.abuasal, 
s.egerton, Jim, PkmX, rogfer01, shiva0217, kito-cheng, simoncook, asb, 
arichardson.
Herald added a project: All.
paulkirth requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

GP linker relaxation conflicts with the use of `x3` (`gp`) register as
the SCS register on RISC-V. To avoid incompatibility, we pass the
`--no-relax-gp` to the linker.

Depends on D147983 , D148031 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148034

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -738,18 +738,32 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-ELF-RISCV32 %s
 // CHECK-SHADOWCALLSTACK-ELF-RISCV32: '-fsanitize=shadow-call-stack' only 
allowed with '-ffixed-x18'
 
+// RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
+// RUN: --target=riscv32-unknown-linux -fuse-ld=ld -ffixed-x18 \
+// RUN:   | FileCheck 
--check-prefix=CHECK-SHADOWCALLSTACK-ELF-RISCV32-FIXED-X18 %s
+// CHECK-SHADOWCALLSTACK-ELF-RISCV32-FIXED-X18: --no-relax-gp
+// CHECK-SHADOWCALLSTACK-ELF-RISCV32-FIXED-X18-NOT: error:
+
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
 // RUN: --target=riscv64-unknown-linux -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64 %s
 // CHECK-SHADOWCALLSTACK-LINUX-RISCV64: '-fsanitize=shadow-call-stack' only 
allowed with '-ffixed-x18'
 
+// RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
+// RUN: --target=riscv64-unknown-linux -fuse-ld=ld -ffixed-x18 \
+// RUN:   | FileCheck 
--check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64-FIXED-X18 %s
+// CHECK-SHADOWCALLSTACK-LINUX-RISCV64-FIXED-X18: --no-relax-gp
+// CHECK-SHADOWCALLSTACK-LINUX-RISCV64-FIXED-X18-NOT: error:
+
 // RUN: %clang -target riscv64-linux-android -fsanitize=shadow-call-stack %s 
-### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-SHADOWCALLSTACK-ANDROID-RISCV64
+// CHECK-SHADOWCALLSTACK-ANDROID-RISCV64: --no-relax-gp
 // CHECK-SHADOWCALLSTACK-ANDROID-RISCV64-NOT: error:
 
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
 // RUN: --target=riscv64-unknown-fuchsia -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-FUCHSIA-RISCV64 %s
+// CHECK-SHADOWCALLSTACK-FUCHSIA-RISCV64: --no-relax-gp
 // CHECK-SHADOWCALLSTACK-FUCHSIA-RISCV64-NOT: error:
 
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1183,6 +1183,9 @@
   CmdArgs.push_back("--android-memtag-stack");
   }
 
+  if (SanArgs.hasShadowCallStack() && TC.getTriple().isRISCV())
+CmdArgs.push_back("--no-relax-gp");
+
   return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
 }
 


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -738,18 +738,32 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-ELF-RISCV32 %s
 // CHECK-SHADOWCALLSTACK-ELF-RISCV32: '-fsanitize=shadow-call-stack' only allowed with '-ffixed-x18'
 
+// RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
+// RUN: --target=riscv32-unknown-linux -fuse-ld=ld -ffixed-x18 \
+// RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-ELF-RISCV32-FIXED-X18 %s
+// CHECK-SHADOWCALLSTACK-ELF-RISCV32-FIXED-X18: --no-relax-gp
+// CHECK-SHADOWCALLSTACK-ELF-RISCV32-FIXED-X18-NOT: error:
+
 // RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
 // RUN: --target=riscv64-unknown-linux -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64 %s
 // CHECK-SHADOWCALLSTACK-LINUX-RISCV64: '-fsanitize=shadow-call-stack' only allowed with '-ffixed-x18'
 
+// RUN: %clang -fsanitize=shadow-call-stack -### %s 2>&1 \
+// RUN: --target=riscv64-unknown-linux -fuse-ld=ld -ffixed-x18 \
+// RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-RISCV64-FIXED-X18 %s
+// CHECK-SHADOWCALLSTACK-LINUX-RISCV64-FIXED-X18: --no-relax-gp
+// CHECK-SHADOWCALLSTACK-LINUX-RISCV64-FIXED-X18-NOT: error:
+
 // RUN: %clang -target riscv64-linux-android -fsanitize=shadow-call-stack %s -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-SHADOWCALLSTACK-ANDROID-RISCV64
+// CHECK-SHADOWCALLSTACK-ANDROID-RISCV64: --no-relax-gp
 // 

[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:2404
   break;
+case RawComment::RCK_Invalid:
+  // FIXME: are there other scenarios that could produce an invalid

I don't get why we don't have to handle the other `RawComment` cases here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148029/new/

https://reviews.llvm.org/D148029

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


[PATCH] D147924: [clang-tidy] Exclude template instantiations in modernize-use-override

2023-04-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 512529.
PiotrZSL edited the summary of this revision.
PiotrZSL added a comment.

Introduce option IgnoreTemplateInstantiations.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147924/new/

https://reviews.llvm.org/D147924

Files:
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-override.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-override-templates.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-override-templates.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-override-templates.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-override.IgnoreTemplateInstantiations, value: true}]}"
+
+struct Base {
+  virtual void foo();
+};
+
+struct Base2 {
+  virtual void foo2();
+};
+
+template
+struct Derived : T {
+  virtual void foo();
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES-NOT: {{^}}  void foo() override;{{$}}
+  virtual void foo2();
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES-NOT: {{^}}  void foo2() override;{{$}}
+};
+
+void test() {
+  Derived b;
+  Derived b2;
+}
+
+template
+struct BaseS {
+  virtual void boo();
+};
+
+template<>
+struct BaseS {
+  virtual void boo2();
+};
+
+struct BaseU {
+  virtual void boo3();
+};
+
+template
+struct Derived2 : BaseS, BaseU {
+  virtual void boo();
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES-NOT: {{^}}  void boo() override;{{$}}
+  virtual void boo2();
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES-NOT: {{^}}  void boo2() override;{{$}}
+  virtual void boo3();
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  void boo3() override;{{$}}
+};
Index: clang-tools-extra/docs/clang-tidy/checks/modernize/use-override.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize/use-override.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize/use-override.rst
@@ -27,6 +27,11 @@
 
If set to `true`, this check will not diagnose destructors. Default is `false`.
 
+.. option:: IgnoreTemplateInstantiations
+
+   If set to `true`, instructs this check to ignore virtual function overrides
+   that are part of template instantiations. Default is `false`.
+
 .. option:: AllowOverrideAndFinal
 
If set to `true`, this check will not diagnose ``override`` as redundant
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -242,6 +242,11 @@
   functions containing macros or preprocessor directives, and out-of-line special
   member functions in unions.
 
+- Improved :doc:`modernize-use-override
+  ` check with new
+  `IgnoreTemplateInstantiations` option to optionally ignore virtual function
+  overrides that are part of template instantiations.
+
 - Fixed reading `HungarianNotation.CString.*` options in
   :doc:`readability-identifier-naming
   ` check.
Index: clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
+++ clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
@@ -27,6 +27,7 @@
 
 private:
   const bool IgnoreDestructors;
+  const bool IgnoreTemplateInstantiations;
   const bool AllowOverrideAndFinal;
   const StringRef OverrideSpelling;
   const StringRef FinalSpelling;
Index: clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -18,24 +18,35 @@
 UseOverrideCheck::UseOverrideCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   IgnoreDestructors(Options.get("IgnoreDestructors", false)),
+  IgnoreTemplateInstantiations(
+  Options.get("IgnoreTemplateInstantiations", false)),
   

[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Do we have a test that covers valid doxygen comments? I was looking and I don't 
see an obvious one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148029/new/

https://reviews.llvm.org/D148029

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


[PATCH] D147920: [clang] Add test for CWG399

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added a comment.

In D147920#4258680 , @shafik wrote:

> In D147920#4257369 , @Endill wrote:
>
>> I think I haven't stressed it enough, but this whole test is copied from 
>> dr244, which is written by Richard.
>
> Understood, I appreciate the patience in explaining what I am missing. 
> Sometimes that means things could be explained better.

No worries. Those DRs are involved enough that it could be challenging to 
understand the context quickly.




Comment at: clang/test/CXX/drs/dr3xx.cpp:1492
+// This is technically ill-formed; G is looked up in 'N::' and is not 
found.
+// Rejecting this seems correct, but most compilers accept, so we do also.
+f.N::F::~G(); // expected-error {{qualified destructor name only found in 
lexical scope; omit the qualifier to find this type name by unqualified lookup}}

shafik wrote:
> Endill wrote:
> > shafik wrote:
> > > You say we accept the next line but it has an `expected-error` on it?
> > It's an error because of `-pedantic-errors`. It's a warning by default.
> That makes a lot more sense, I was wondering what was I missing.
> 
> Can we note that in the comment b/c it is pretty confusing otherwise. 
> 
> I wonder if there is a good reason to not make this ill-formed by default? 
> Worth a bug report.
> Can we note that in the comment b/c it is pretty confusing otherwise.

I get where you come from, but all DR testing is done under `-pedantic-errors`. 
Do you have ideas for a more systematic approach? One of the options is to use 
`-Wpedantic` instead, but I expect that to require a decent amount of 
mechanical replacements for existing tests, which LLVM community doesn't 
appreciate, as far as I know. I'll edit the comment if we won't come up with 
something better.

> I wonder if there is a good reason to not make this ill-formed by default? 
> Worth a bug report.

Does the fact that we accepted such code since (at least) 3.5 through 10 make 
for a good reason? https://godbolt.org/z/16GYWh3Po


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147920/new/

https://reviews.llvm.org/D147920

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-11 Thread Anubhab Ghosh via Phabricator via cfe-commits
argentite added inline comments.



Comment at: clang/lib/Interpreter/Offload.cpp:90-91
+  PTXCode += '\0';
+  while (PTXCode.size() % 8)
+PTXCode += '\0';
+  return PTXCode.str();

Hahnfeld wrote:
> Is padding to 8 bytes a requirement for PTX? Maybe add a coment...
This was actually in original Cling implementation but it does not seem to be 
required.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-11 Thread Anubhab Ghosh via Phabricator via cfe-commits
argentite updated this revision to Diff 512521.
argentite marked 3 inline comments as done.
argentite added a comment.

Combined IncrementalCompilerBuilder and IncrementalCudaCompilerBuilder
Added --cuda-path support
Use sys::fs::createTemporaryFile() instead of hardcoding the path
Other minor refactoring

I am planning to have the in-memory fat binary file as a separate patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/Offload.cpp
  clang/lib/Interpreter/Offload.h
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -23,6 +23,10 @@
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
 #include 
 
+static llvm::cl::opt CudaEnabled("cuda", llvm::cl::Hidden);
+static llvm::cl::opt CudaPath("cuda-path", llvm::cl::Hidden);
+static llvm::cl::opt OffloadArch("offload-arch", llvm::cl::Hidden);
+
 static llvm::cl::list
 ClangArgs("Xcc",
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
@@ -90,9 +94,40 @@
 return 0;
   }
 
+  clang::IncrementalCompilerBuilder CB;
+  CB.SetCompilerArgs(ClangArgv);
+
+  llvm::SmallString<128> CudaTempFile;
+  std::unique_ptr DeviceCI;
+  if (CudaEnabled) {
+// initialize NVPTX backend
+LLVMInitializeNVPTXTargetInfo();
+LLVMInitializeNVPTXTarget();
+LLVMInitializeNVPTXTargetMC();
+LLVMInitializeNVPTXAsmPrinter();
+
+if (!CudaPath.empty())
+  CB.SetCudaSDK(CudaPath);
+
+if (OffloadArch.empty()) {
+  OffloadArch = "sm_35";
+}
+CB.SetOffloadArch(OffloadArch);
+
+llvm::sys::fs::createTemporaryFile("clang-repl", "fatbin", CudaTempFile);
+CB.SetCudaTempFatbinFile(CudaTempFile);
+
+DeviceCI = ExitOnErr(CB.CreateCudaDevice());
+  }
+
   // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It
   // can replace the boilerplate code for creation of the compiler instance.
-  auto CI = ExitOnErr(clang::IncrementalCompilerBuilder::create(ClangArgv));
+  std::unique_ptr CI;
+  if (CudaEnabled) {
+CI = ExitOnErr(CB.CreateCudaHost());
+  } else {
+CI = ExitOnErr(CB.CreateCpp());
+  }
 
   // Set an error handler, so that any LLVM backend diagnostics go through our
   // error handler.
@@ -101,8 +136,23 @@
 
   // Load any requested plugins.
   CI->LoadRequestedPlugins();
+  if (CudaEnabled)
+DeviceCI->LoadRequestedPlugins();
+
+  std::unique_ptr Interp;
+  if (CudaEnabled) {
+Interp = ExitOnErr(clang::Interpreter::createWithCUDA(
+std::move(CI), std::move(DeviceCI), CudaTempFile));
+
+if (CudaPath.empty()) {
+  ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+} else {
+  auto CudaRuntimeLibPath = CudaPath + "/lib/libcudart.so";
+  ExitOnErr(Interp->LoadDynamicLibrary(CudaRuntimeLibPath.c_str()));
+}
+  } else
+Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
 
-  auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
   for (const std::string  : OptInputs) {
 if (auto Err = Interp->ParseAndExecute(input))
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
@@ -138,6 +188,9 @@
 }
   }
 
+  if (!CudaTempFile.empty())
+llvm::sys::fs::remove(CudaTempFile);
+
   // Our error handler depends on the Diagnostics object, which we're
   // potentially about to delete. Uninstall the handler now so that any
   // later errors use the default handling behavior instead.
Index: clang/lib/Interpreter/Offload.h
===
--- /dev/null
+++ clang/lib/Interpreter/Offload.h
@@ -0,0 +1,46 @@
+//===--- Offload.h - CUDA Offloading *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements classes required for offloading to CUDA devices.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_INTERPRETER_OFFLOAD_H
+#define LLVM_CLANG_LIB_INTERPRETER_OFFLOAD_H
+
+#include "IncrementalParser.h"
+#include "llvm/Support/FileSystem.h"
+
+namespace clang {
+
+class IncrementalCUDADeviceParser : public IncrementalParser {
+public:
+  IncrementalCUDADeviceParser(std::unique_ptr 

[PATCH] D143813: [ClangFE] Check that __sync builtins are naturally aligned.

2023-04-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D143813#4257943 , @jonpa wrote:

> I don't understand the first argument - I thought it was supposed to be just 
> an address...

It's a statement expression. 
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

The value of the last subexpression serves as the value of the entire construct.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143813/new/

https://reviews.llvm.org/D143813

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


[PATCH] D147986: [RISCV] Print a better error message when a rv32 CPU is used on rv64 and vice versa.

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88d631198255: [RISCV] Print a better error message when a 
rv32 CPU is used on rv64 and vice… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147986/new/

https://reviews.llvm.org/D147986

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-cpus.c


Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -173,7 +173,7 @@
 // FAIL-MCPU-NAME: error: unsupported argument 'generic-rv321' to option 
'-mcpu='
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 
-march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
-// MISMATCH-ARCH: error: unsupported argument 'generic-rv32' to option '-mcpu='
+// MISMATCH-ARCH: cpu 'generic-rv32' does not support rv64
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv64 | FileCheck 
-check-prefix=MISMATCH-MCPU %s
-// MISMATCH-MCPU: error: unsupported argument 'generic-rv64' to option '-mcpu='
+// MISMATCH-MCPU: error: cpu 'generic-rv64' does not support rv32
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -49,11 +49,20 @@
 }
 
 // Get features except standard extension feature
-static bool getRISCFeaturesFromMcpu(const llvm::Triple , StringRef Mcpu,
+static void getRISCFeaturesFromMcpu(const Driver , const Arg *A,
+const llvm::Triple ,
+StringRef Mcpu,
 std::vector ) {
   bool Is64Bit = Triple.isRISCV64();
   llvm::RISCV::CPUKind CPUKind = llvm::RISCV::parseCPUKind(Mcpu);
-  return llvm::RISCV::checkCPUKind(CPUKind, Is64Bit);
+  if (!llvm::RISCV::checkCPUKind(CPUKind, Is64Bit)) {
+// Try inverting Is64Bit in case the CPU is valid, but for the wrong 
target.
+if (llvm::RISCV::checkCPUKind(CPUKind, !Is64Bit))
+  D.Diag(clang::diag::err_drv_invalid_riscv_cpu_name_for_target) << Mcpu 
<< Is64Bit;
+else
+  D.Diag(clang::diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << Mcpu;
+  }
 }
 
 void riscv::getRISCVTargetFeatures(const Driver , const llvm::Triple ,
@@ -70,9 +79,8 @@
 StringRef CPU = A->getValue();
 if (CPU == "native")
   CPU = llvm::sys::getHostCPUName();
-if (!getRISCFeaturesFromMcpu(Triple, CPU, Features))
-  D.Diag(clang::diag::err_drv_unsupported_option_argument)
-  << A->getSpelling() << CPU;
+
+getRISCFeaturesFromMcpu(D, A, Triple, CPU, Features);
   }
 
   // Handle features corresponding to "-ffixed-X" options
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -29,6 +29,8 @@
   "invalid arch name '%0'">;
 def err_drv_invalid_riscv_arch_name : Error<
   "invalid arch name '%0', %1">;
+def err_drv_invalid_riscv_cpu_name_for_target : Error<
+  "cpu '%0' does not support rv%select{32|64}1">;
 def warn_drv_invalid_arch_name_with_suggestion : Warning<
   "ignoring invalid /arch: argument '%0'; for %select{64|32}1-bit expected one 
of %2">,
   InGroup;


Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -173,7 +173,7 @@
 // FAIL-MCPU-NAME: error: unsupported argument 'generic-rv321' to option '-mcpu='
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 -march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
-// MISMATCH-ARCH: error: unsupported argument 'generic-rv32' to option '-mcpu='
+// MISMATCH-ARCH: cpu 'generic-rv32' does not support rv64
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv64 | FileCheck -check-prefix=MISMATCH-MCPU %s
-// MISMATCH-MCPU: error: unsupported argument 'generic-rv64' to option '-mcpu='
+// MISMATCH-MCPU: error: cpu 'generic-rv64' does not support rv32
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -49,11 +49,20 @@
 }
 
 // Get features except standard extension feature
-static bool getRISCFeaturesFromMcpu(const llvm::Triple , StringRef Mcpu,
+static void getRISCFeaturesFromMcpu(const Driver , const Arg *A,
+const llvm::Triple ,
+StringRef Mcpu,
   

[PATCH] D147978: [RISCV] Remove getCPUFeaturesExceptStdExt.

2023-04-11 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e2d8a352888: [RISCV] Remove getCPUFeaturesExceptStdExt. 
(authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147978/new/

https://reviews.llvm.org/D147978

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-cpus.c
  llvm/include/llvm/TargetParser/RISCVTargetParser.h
  llvm/lib/TargetParser/RISCVTargetParser.cpp

Index: llvm/lib/TargetParser/RISCVTargetParser.cpp
===
--- llvm/lib/TargetParser/RISCVTargetParser.cpp
+++ llvm/lib/TargetParser/RISCVTargetParser.cpp
@@ -85,22 +85,6 @@
 #include "llvm/TargetParser/RISCVTargetParserDef.inc"
 }
 
-// Get all features except standard extension feature
-bool getCPUFeaturesExceptStdExt(CPUKind Kind,
-std::vector ) {
-  const CPUInfo  = RISCVCPUInfo[static_cast(Kind)];
-
-  if (Info.isInvalid())
-return false;
-
-  if (Info.is64Bit())
-Features.push_back("+64bit");
-  else
-Features.push_back("-64bit");
-
-  return true;
-}
-
 bool isX18ReservedByDefault(const Triple ) {
   // X18 is reserved for the ShadowCallStack ABI (even when not enabled).
   return TT.isOSFuchsia() || TT.isAndroid();
Index: llvm/include/llvm/TargetParser/RISCVTargetParser.h
===
--- llvm/include/llvm/TargetParser/RISCVTargetParser.h
+++ llvm/include/llvm/TargetParser/RISCVTargetParser.h
@@ -39,7 +39,6 @@
 StringRef getMArchFromMcpu(StringRef CPU);
 void fillValidCPUArchList(SmallVectorImpl , bool IsRV64);
 void fillValidTuneCPUArchList(SmallVectorImpl , bool IsRV64);
-bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector );
 
 bool isX18ReservedByDefault(const Triple );
 
Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -7,20 +7,17 @@
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=rocket-rv64 | FileCheck -check-prefix=MCPU-ROCKET64 %s
 // MCPU-ROCKET64: "-nostdsysteminc" "-target-cpu" "rocket-rv64"
 // MCPU-ROCKET64: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-ROCKET64: "-target-feature" "+64bit"
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr1-base | FileCheck -check-prefix=MCPU-SYNTACORE-SCR1-BASE %s
 // MCPU-SYNTACORE-SCR1-BASE: "-target-cpu" "syntacore-scr1-base"
 // MCPU-SYNTACORE-SCR1-BASE: "-target-feature" "+c"
 // MCPU-SYNTACORE-SCR1-BASE: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-SYNTACORE-SCR1-BASE: "-target-feature" "-64bit"
 // MCPU-SYNTACORE-SCR1-BASE: "-target-abi" "ilp32"
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr1-max | FileCheck -check-prefix=MCPU-SYNTACORE-SCR1-MAX %s
 // MCPU-SYNTACORE-SCR1-MAX: "-target-cpu" "syntacore-scr1-max"
 // MCPU-SYNTACORE-SCR1-MAX: "-target-feature" "+m" "-target-feature" "+c"
 // MCPU-SYNTACORE-SCR1-MAX: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-SYNTACORE-SCR1-MAX: "-target-feature" "-64bit"
 // MCPU-SYNTACORE-SCR1-MAX: "-target-abi" "ilp32"
 
 // We cannot check much for -mcpu=native, but it should be replaced by a valid CPU string.
@@ -92,7 +89,6 @@
 // MCPU-ABI-SIFIVE-S21: "-target-feature" "+m" "-target-feature" "+a"
 // MCPU-ABI-SIFIVE-S21: "-target-feature" "+c"
 // MCPU-ABI-SIFIVE-S21: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-ABI-SIFIVE-S21: "-target-feature" "+64bit"
 // MCPU-ABI-SIFIVE-S21: "-target-abi" "lp64"
 
 // mcpu with mabi option
@@ -101,7 +97,6 @@
 // MCPU-ABI-SIFIVE-S51: "-target-feature" "+m" "-target-feature" "+a"
 // MCPU-ABI-SIFIVE-S51: "-target-feature" "+c"
 // MCPU-ABI-SIFIVE-S51: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-ABI-SIFIVE-S51: "-target-feature" "+64bit"
 // MCPU-ABI-SIFIVE-S51: "-target-abi" "lp64"
 
 // mcpu with default march
@@ -110,7 +105,6 @@
 // MCPU-SIFIVE-S54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
 // MCPU-SIFIVE-S54: "-target-feature" "+c"
 // MCPU-SIFIVE-S54: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-SIFIVE-S54: "-target-feature" "+64bit"
 // MCPU-SIFIVE-S54: "-target-abi" "lp64d"
 
 // mcpu with mabi option
@@ -119,7 +113,6 @@
 // MCPU-SIFIVE-S76: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
 // MCPU-SIFIVE-S76: "-target-feature" "+c"
 // MCPU-SIFIVE-S76: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-SIFIVE-S76: "-target-feature" "+64bit"
 // MCPU-SIFIVE-S76: "-target-abi" "lp64d"
 
 // mcpu with default march
@@ -128,7 +121,6 @@
 // MCPU-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
 // MCPU-SIFIVE-U54: "-target-feature" "+c"
 // 

[clang] 88d6311 - [RISCV] Print a better error message when a rv32 CPU is used on rv64 and vice versa.

2023-04-11 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-04-11T10:41:50-07:00
New Revision: 88d6311982557acf2dd04ce101aca077ac311012

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

LOG: [RISCV] Print a better error message when a rv32 CPU is used on rv64 and 
vice versa.

Instead of rejecting the CPU outright with no information, try
to diagnose that it doesn't match the triple.

Differential Revision: https://reviews.llvm.org/D147986

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-cpus.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 2c6bb0aa9331..1efe7573028e 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -29,6 +29,8 @@ def err_drv_invalid_arch_name : Error<
   "invalid arch name '%0'">;
 def err_drv_invalid_riscv_arch_name : Error<
   "invalid arch name '%0', %1">;
+def err_drv_invalid_riscv_cpu_name_for_target : Error<
+  "cpu '%0' does not support rv%select{32|64}1">;
 def warn_drv_invalid_arch_name_with_suggestion : Warning<
   "ignoring invalid /arch: argument '%0'; for %select{64|32}1-bit expected one 
of %2">,
   InGroup;

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 88744210..7cf01ad8a72b 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -49,11 +49,20 @@ static bool getArchFeatures(const Driver , StringRef Arch,
 }
 
 // Get features except standard extension feature
-static bool getRISCFeaturesFromMcpu(const llvm::Triple , StringRef Mcpu,
+static void getRISCFeaturesFromMcpu(const Driver , const Arg *A,
+const llvm::Triple ,
+StringRef Mcpu,
 std::vector ) {
   bool Is64Bit = Triple.isRISCV64();
   llvm::RISCV::CPUKind CPUKind = llvm::RISCV::parseCPUKind(Mcpu);
-  return llvm::RISCV::checkCPUKind(CPUKind, Is64Bit);
+  if (!llvm::RISCV::checkCPUKind(CPUKind, Is64Bit)) {
+// Try inverting Is64Bit in case the CPU is valid, but for the wrong 
target.
+if (llvm::RISCV::checkCPUKind(CPUKind, !Is64Bit))
+  D.Diag(clang::diag::err_drv_invalid_riscv_cpu_name_for_target) << Mcpu 
<< Is64Bit;
+else
+  D.Diag(clang::diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << Mcpu;
+  }
 }
 
 void riscv::getRISCVTargetFeatures(const Driver , const llvm::Triple ,
@@ -70,9 +79,8 @@ void riscv::getRISCVTargetFeatures(const Driver , const 
llvm::Triple ,
 StringRef CPU = A->getValue();
 if (CPU == "native")
   CPU = llvm::sys::getHostCPUName();
-if (!getRISCFeaturesFromMcpu(Triple, CPU, Features))
-  D.Diag(clang::diag::err_drv_unsupported_option_argument)
-  << A->getSpelling() << CPU;
+
+getRISCFeaturesFromMcpu(D, A, Triple, CPU, Features);
   }
 
   // Handle features corresponding to "-ffixed-X" options

diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index a57cbf1e0e25..b107d89773e1 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -173,7 +173,7 @@
 // FAIL-MCPU-NAME: error: unsupported argument 'generic-rv321' to option 
'-mcpu='
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 
-march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
-// MISMATCH-ARCH: error: unsupported argument 'generic-rv32' to option '-mcpu='
+// MISMATCH-ARCH: cpu 'generic-rv32' does not support rv64
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv64 | FileCheck 
-check-prefix=MISMATCH-MCPU %s
-// MISMATCH-MCPU: error: unsupported argument 'generic-rv64' to option '-mcpu='
+// MISMATCH-MCPU: error: cpu 'generic-rv64' does not support rv32



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


[clang] 5e2d8a3 - [RISCV] Remove getCPUFeaturesExceptStdExt.

2023-04-11 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-04-11T10:41:46-07:00
New Revision: 5e2d8a35288802f94df8c60513e7a835b27e621d

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

LOG: [RISCV] Remove getCPUFeaturesExceptStdExt.

This function was used to force +64bit or -64bit into the feature
string basd on -mcpu.

It's not entirely clear to me why this was needed.  This informationo
is redundant with the triple. RISCVTargetInfo::initFeatureMap
independently recomputes it from the triple for the feature map.

It is ultimately needed in the backend, but that should be handled
by RISCVSubtarget processing the CPU name.

Differential Revision: https://reviews.llvm.org/D147978

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-cpus.c
llvm/include/llvm/TargetParser/RISCVTargetParser.h
llvm/lib/TargetParser/RISCVTargetParser.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index da120d95b42f..88744210 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -53,8 +53,7 @@ static bool getRISCFeaturesFromMcpu(const llvm::Triple 
, StringRef Mcpu,
 std::vector ) {
   bool Is64Bit = Triple.isRISCV64();
   llvm::RISCV::CPUKind CPUKind = llvm::RISCV::parseCPUKind(Mcpu);
-  return llvm::RISCV::checkCPUKind(CPUKind, Is64Bit) &&
- llvm::RISCV::getCPUFeaturesExceptStdExt(CPUKind, Features);
+  return llvm::RISCV::checkCPUKind(CPUKind, Is64Bit);
 }
 
 void riscv::getRISCVTargetFeatures(const Driver , const llvm::Triple ,

diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 7a08b8c10956..a57cbf1e0e25 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -7,20 +7,17 @@
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=rocket-rv64 | FileCheck 
-check-prefix=MCPU-ROCKET64 %s
 // MCPU-ROCKET64: "-nostdsysteminc" "-target-cpu" "rocket-rv64"
 // MCPU-ROCKET64: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-ROCKET64: "-target-feature" "+64bit"
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr1-base | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR1-BASE %s
 // MCPU-SYNTACORE-SCR1-BASE: "-target-cpu" "syntacore-scr1-base"
 // MCPU-SYNTACORE-SCR1-BASE: "-target-feature" "+c"
 // MCPU-SYNTACORE-SCR1-BASE: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
-// MCPU-SYNTACORE-SCR1-BASE: "-target-feature" "-64bit"
 // MCPU-SYNTACORE-SCR1-BASE: "-target-abi" "ilp32"
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr1-max | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR1-MAX %s
 // MCPU-SYNTACORE-SCR1-MAX: "-target-cpu" "syntacore-scr1-max"
 // MCPU-SYNTACORE-SCR1-MAX: "-target-feature" "+m" "-target-feature" "+c"
 // MCPU-SYNTACORE-SCR1-MAX: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
-// MCPU-SYNTACORE-SCR1-MAX: "-target-feature" "-64bit"
 // MCPU-SYNTACORE-SCR1-MAX: "-target-abi" "ilp32"
 
 // We cannot check much for -mcpu=native, but it should be replaced by a valid 
CPU string.
@@ -92,7 +89,6 @@
 // MCPU-ABI-SIFIVE-S21: "-target-feature" "+m" "-target-feature" "+a"
 // MCPU-ABI-SIFIVE-S21: "-target-feature" "+c"
 // MCPU-ABI-SIFIVE-S21: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
-// MCPU-ABI-SIFIVE-S21: "-target-feature" "+64bit"
 // MCPU-ABI-SIFIVE-S21: "-target-abi" "lp64"
 
 // mcpu with mabi option
@@ -101,7 +97,6 @@
 // MCPU-ABI-SIFIVE-S51: "-target-feature" "+m" "-target-feature" "+a"
 // MCPU-ABI-SIFIVE-S51: "-target-feature" "+c"
 // MCPU-ABI-SIFIVE-S51: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
-// MCPU-ABI-SIFIVE-S51: "-target-feature" "+64bit"
 // MCPU-ABI-SIFIVE-S51: "-target-abi" "lp64"
 
 // mcpu with default march
@@ -110,7 +105,6 @@
 // MCPU-SIFIVE-S54: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
 // MCPU-SIFIVE-S54: "-target-feature" "+c"
 // MCPU-SIFIVE-S54: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-SIFIVE-S54: "-target-feature" "+64bit"
 // MCPU-SIFIVE-S54: "-target-abi" "lp64d"
 
 // mcpu with mabi option
@@ -119,7 +113,6 @@
 // MCPU-SIFIVE-S76: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
 // MCPU-SIFIVE-S76: "-target-feature" "+c"
 // MCPU-SIFIVE-S76: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
-// MCPU-SIFIVE-S76: "-target-feature" "+64bit"
 // MCPU-SIFIVE-S76: "-target-abi" "lp64d"
 
 // mcpu with default march
@@ -128,7 +121,6 @@
 // MCPU-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
 // MCPU-SIFIVE-U54: "-target-feature" 

[PATCH] D147660: [PS4][clang] Pass -flto-jobs argument to orbis-ld

2023-04-11 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147660/new/

https://reviews.llvm.org/D147660

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


[PATCH] D147660: [PS4][clang] Pass -flto-jobs argument to orbis-ld

2023-04-11 Thread Matthew Voss via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG393a1c3b4fcd: [PS4][clang] Pass -flto-jobs argument to 
orbis-ld (authored by ormris).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147660/new/

https://reviews.llvm.org/D147660

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/lto-jobs.c


Index: clang/test/Driver/lto-jobs.c
===
--- clang/test/Driver/lto-jobs.c
+++ clang/test/Driver/lto-jobs.c
@@ -7,6 +7,11 @@
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s
 //
 // CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5"
+//
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin -flto-jobs=5 2> %t
+// RUN: FileCheck -check-prefix=CHECK-PS4-LINK-THIN-JOBS-ACTION < %t %s
+//
+// CHECK-PS4-LINK-THIN-JOBS-ACTION: "-lto-thin-debug-options= 
-generate-arange-section -threads=5"
 
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 
-flto-jobs=5 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -180,6 +180,14 @@
 if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
   AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
 
+StringRef Parallelism = getLTOParallelism(Args, D);
+if (!Parallelism.empty()) {
+  if (IsPS4)
+AddCodeGenFlag(Twine("-threads=") + Parallelism);
+  else
+CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + 
Parallelism));
+}
+
 if (IsPS4) {
   const char *Prefix = nullptr;
   if (D.getLTOMode() == LTOK_Thin)
@@ -193,12 +201,6 @@
 }
   }
 
-  if (IsPS5 && UseLTO) {
-StringRef Parallelism = getLTOParallelism(Args, D);
-if (!Parallelism.empty())
-  CmdArgs.push_back(Args.MakeArgString("-plugin-opt=jobs=" + Parallelism));
-  }
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 


Index: clang/test/Driver/lto-jobs.c
===
--- clang/test/Driver/lto-jobs.c
+++ clang/test/Driver/lto-jobs.c
@@ -7,6 +7,11 @@
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s
 //
 // CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5"
+//
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin -flto-jobs=5 2> %t
+// RUN: FileCheck -check-prefix=CHECK-PS4-LINK-THIN-JOBS-ACTION < %t %s
+//
+// CHECK-PS4-LINK-THIN-JOBS-ACTION: "-lto-thin-debug-options= -generate-arange-section -threads=5"
 
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -180,6 +180,14 @@
 if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
   AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
 
+StringRef Parallelism = getLTOParallelism(Args, D);
+if (!Parallelism.empty()) {
+  if (IsPS4)
+AddCodeGenFlag(Twine("-threads=") + Parallelism);
+  else
+CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + Parallelism));
+}
+
 if (IsPS4) {
   const char *Prefix = nullptr;
   if (D.getLTOMode() == LTOK_Thin)
@@ -193,12 +201,6 @@
 }
   }
 
-  if (IsPS5 && UseLTO) {
-StringRef Parallelism = getLTOParallelism(Args, D);
-if (!Parallelism.empty())
-  CmdArgs.push_back(Args.MakeArgString("-plugin-opt=jobs=" + Parallelism));
-  }
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 393a1c3 - [PS4][clang] Pass -flto-jobs argument to orbis-ld

2023-04-11 Thread Matthew Voss via cfe-commits

Author: Matthew Voss
Date: 2023-04-11T10:33:16-07:00
New Revision: 393a1c3b4fcded56a1078d2c01c69af2f2ec05cf

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

LOG: [PS4][clang] Pass -flto-jobs argument to orbis-ld

Pass -flto-jobs to orbis-ld correctly.

Differential Revision: https://reviews.llvm.org/D147660

Added: 


Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/lto-jobs.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 71c6b650e1f52..b280abb0d58b7 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -180,6 +180,14 @@ void tools::PScpu::Linker::ConstructJob(Compilation , 
const JobAction ,
 if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
   AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
 
+StringRef Parallelism = getLTOParallelism(Args, D);
+if (!Parallelism.empty()) {
+  if (IsPS4)
+AddCodeGenFlag(Twine("-threads=") + Parallelism);
+  else
+CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + 
Parallelism));
+}
+
 if (IsPS4) {
   const char *Prefix = nullptr;
   if (D.getLTOMode() == LTOK_Thin)
@@ -193,12 +201,6 @@ void tools::PScpu::Linker::ConstructJob(Compilation , 
const JobAction ,
 }
   }
 
-  if (IsPS5 && UseLTO) {
-StringRef Parallelism = getLTOParallelism(Args, D);
-if (!Parallelism.empty())
-  CmdArgs.push_back(Args.MakeArgString("-plugin-opt=jobs=" + Parallelism));
-  }
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 

diff  --git a/clang/test/Driver/lto-jobs.c b/clang/test/Driver/lto-jobs.c
index 443f8abced788..5402442ce6972 100644
--- a/clang/test/Driver/lto-jobs.c
+++ b/clang/test/Driver/lto-jobs.c
@@ -7,6 +7,11 @@
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s
 //
 // CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5"
+//
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin -flto-jobs=5 2> %t
+// RUN: FileCheck -check-prefix=CHECK-PS4-LINK-THIN-JOBS-ACTION < %t %s
+//
+// CHECK-PS4-LINK-THIN-JOBS-ACTION: "-lto-thin-debug-options= 
-generate-arange-section -threads=5"
 
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 
-flto-jobs=5 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s



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


[PATCH] D147839: [clang] Add test for CWG2007

2023-04-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added a comment.

In D147839#4258681 , @shafik wrote:

> In D147839#4257394 , @Endill wrote:
>
>> Replace unary `&` with `__builtin_addressof()`. It prevents unnecessary 
>> template instantiation (presumably to find overloaded unary `&`), and make 
>> Clang compliant since 3.4
>
> Nice approach!

Credits go to Aaron, actually. We discussed this DR during his office hours 
yesterday.

In D147839#4258682 , @shafik wrote:

> LGTM, thank you again for all the effort in documenting these and adding 
> tests, it is much appreciated.

Thank you for giving them thorough review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147839/new/

https://reviews.llvm.org/D147839

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


[PATCH] D147839: [clang] Add test for CWG2007

2023-04-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM, thank you again for all the effort in documenting these and adding tests, 
it is much appreciated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147839/new/

https://reviews.llvm.org/D147839

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


[PATCH] D147839: [clang] Add test for CWG2007

2023-04-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

In D147839#4257394 , @Endill wrote:

> Replace unary `&` with `__builtin_addressof()`. It prevents unnecessary 
> template instantiation (presumably to find overloaded unary `&`), and make 
> Clang compliant since 3.4

Nice approach!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147839/new/

https://reviews.llvm.org/D147839

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


[PATCH] D147920: [clang] Add test for CWG399

2023-04-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

In D147920#4257369 , @Endill wrote:

> I think I haven't stressed it enough, but this whole test is copied from 
> dr244, which is written by Richard.

Understood, I appreciate the patience in explaining what I am missing. 
Sometimes that means things could be explained better.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147920/new/

https://reviews.llvm.org/D147920

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


[PATCH] D147920: [clang] Add test for CWG399

2023-04-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a subscriber: aaron.ballman.
shafik added inline comments.



Comment at: clang/test/CXX/drs/dr3xx.cpp:1439
+
+namespace dr399 { // dr399: 11
+  // NB: reuse dr244 test 

Endill wrote:
> Despite a couple of FIXME in CWG244 test (out of dozens of examples), it 
> claims full availability since Clang 11. I'd take a more conservative 
> approach, declaring partial support, but I think that declaring different 
> availability for the same test would bring unnecessary confusion. So I 
> followed CWG244 availability.
> 
> Alternative is to demote CWG244 to partial, but I'm not sure we should go 
> back on our claims for CWG support that has been out for so long.
I think the bugs are not awful, we should file bug reports if we don't already 
have them. Some of them seem like they should be not too bad to fix.

CC @aaron.ballman to get a second opinion



Comment at: clang/test/CXX/drs/dr3xx.cpp:1492
+// This is technically ill-formed; G is looked up in 'N::' and is not 
found.
+// Rejecting this seems correct, but most compilers accept, so we do also.
+f.N::F::~G(); // expected-error {{qualified destructor name only found in 
lexical scope; omit the qualifier to find this type name by unqualified lookup}}

Endill wrote:
> shafik wrote:
> > You say we accept the next line but it has an `expected-error` on it?
> It's an error because of `-pedantic-errors`. It's a warning by default.
That makes a lot more sense, I was wondering what was I missing.

Can we note that in the comment b/c it is pretty confusing otherwise. 

I wonder if there is a good reason to not make this ill-formed by default? 
Worth a bug report.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147920/new/

https://reviews.llvm.org/D147920

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


[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D147073#4258529 , @aaron.ballman 
wrote:

> In D147073#4258426 , @zequanwu 
> wrote:
>
>> In D147073#4258396 , 
>> @aaron.ballman wrote:
>>
>>> In D147073#4258384 , @hans wrote:
>>>
 Again not an expert here, but lgtm.

 (Nit: the 
 https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1528-L1530
  link in the description seems to point to the wrong code now, since main 
 changed. Here is a link for 16.0.1: 
 https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536)
>>>
>>> I'm confused -- I thought D147569  
>>> resolved the issue and so this patch is no longer needed?
>>
>> D147569  fixes 
>> https://github.com/llvm/llvm-project/issues/45481. This one fixes another 
>> issue crbug.com/1427933. Their stack trace look similar but not caused by 
>> the same issue.
>>
>> Updated the link in summary to: 
>> https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536
>
> Thank you for clarifying, I was confused. :-)
>
> I don't think the changes here are correct either -- it's glossing over an 
> issue that we're not properly tracking the source location in the AST. 
> Playing around with the reduced example is interesting though. If you remove 
> the default argument in the `T` constructor, the issue goes away. If you stop 
> using a forward declaration in the instantiation of `T`, the issue goes away. 
> If `S1` isn't a template, the issue goes away (but the issue will come back 
> if you then make `foo()` a template instead of `S1`). So it seems that 
> something about template instantiation is dropping the source location 
> information (perhaps) and we should be trying to track down where that is to 
> fix the root cause rather than work around it here for coverage mapping 
> alone. (The end location being incorrect can impact other things that are 
> harder to test because it'll be for things like fix-its that don't work 
> properly, which are easy to miss.)

I agree that the real fix is to fix the source location information. If I just 
change [1] to `SourceRange Locs = SourceRange(LParenOrBraceLoc, 
RParenOrBraceLoc);`, the crash is gone. However, as the "FIXME" comment in [1] 
says, it's an intended work-around to drop source locations here. So, I'm 
assuming this kind of source location work-around could happen in multiple 
places in clang, and could happen in the future as a temporary work-around. 
Instead of crashing clang coverage for those work-around, we can at least skip 
coverage info for those expressions/statements.

[1]: 
https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1538


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147073/new/

https://reviews.llvm.org/D147073

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


[PATCH] D147848: [clang] Add test for CWG2370

2023-04-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/CXX/drs/dr23xx.cpp:182
+  typedef N::type N_type;
+  // FIXME: `type` should be searched for in N
+  // friend void N::g(type);

Endill wrote:
> shafik wrote:
> > The implementation seems to all accept this example: 
> > https://godbolt.org/z/vE6bEP6xa
> > 
> > but the examples from the `p1787` have a decidely mixed conformance: 
> > https://godbolt.org/z/dhq7oEKaY
> > 
> > but the `A::F(F)` you point out in your example clang does get wrong and 
> > gcc does not. So at minimum please file bug reports against the examples 
> > that clang does not get right from `p1787` and we need to dig into why your 
> > example above seems to not the same since that is what you intended. 
> Are you sure behavior is different for my `N::g(type)` when compared to 
> `A::f(F)`? Clang is the only one to reject both examples: 
> https://godbolt.org/z/MKb6fE8K5
Oh wow, I someone how missed the commented line of code and thought you were 
referring to the uncomment line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147848/new/

https://reviews.llvm.org/D147848

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


[PATCH] D148031: [clang][driver][NFC] Add hasShadowCallStack to SanitizerArgs

2023-04-11 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth created this revision.
paulkirth added reviewers: phosek, abrachet, dvyukov, vitalybuka, aaron.ballman.
Herald added a project: All.
paulkirth requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, we can't check if ShadowCallStack is present in Args the same
way we handle other sanitizers. This is preparatory work for planned
driver changes to how we handle ShadowCallStack.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148031

Files:
  clang/include/clang/Driver/SanitizerArgs.h


Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -119,6 +119,10 @@
 return MemtagMode;
   }
 
+  bool hasShadowCallStack() const {
+return Sanitizers.has(SanitizerKind::ShadowCallStack);
+  }
+
   bool requiresPIE() const;
   bool needsUnwindTables() const;
   bool needsLTO() const;


Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -119,6 +119,10 @@
 return MemtagMode;
   }
 
+  bool hasShadowCallStack() const {
+return Sanitizers.has(SanitizerKind::ShadowCallStack);
+  }
+
   bool requiresPIE() const;
   bool needsUnwindTables() const;
   bool needsLTO() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 512505.
cor3ntin added a comment.

Add release note


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148029/new/

https://reviews.llvm.org/D148029

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/Sema.cpp
  clang/test/Lexer/comment-escape.c

Index: clang/test/Lexer/comment-escape.c
===
--- clang/test/Lexer/comment-escape.c
+++ clang/test/Lexer/comment-escape.c
@@ -1,6 +1,38 @@
-// RUN: %clang -fsyntax-only %s 
+// RUN: %clang -fsyntax-only -Wdocumentation %s
 // rdar://6757323
 // foo \
 
 #define blork 32
 
+// GH62054
+
+/**<*\
+/
+//expected-warning@-2 {{escaped newline between}} \
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+/**<*\	
+/
+//expected-warning@-2 {{escaped newline between}} \
+//expected-warning@-2 {{backslash and newline separated by space}} \
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+
+/*<*\
+/
+//expected-warning@-2 {{escaped newline between}}  \
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+/*<*\	
+/
+//expected-warning@-2 {{escaped newline between}} \
+//expected-warning@-2 {{backslash and newline separated by space}} \
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+/\
+*<**/
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+/\
+/<*
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -2390,7 +2390,7 @@
   SourceMgr.isInSystemHeader(Comment.getBegin()))
 return;
   RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false);
-  if (RC.isAlmostTrailingComment()) {
+  if (RC.isAlmostTrailingComment() || RC.hasUnsupportedSplice(SourceMgr)) {
 SourceRange MagicMarkerRange(Comment.getBegin(),
  Comment.getBegin().getLocWithOffset(3));
 StringRef MagicMarkerText;
@@ -2401,6 +2401,11 @@
 case RawComment::RCK_OrdinaryC:
   MagicMarkerText = "/**<";
   break;
+case RawComment::RCK_Invalid:
+  // FIXME: are there other scenarios that could produce an invalid
+  // raw comment here?
+  Diag(Comment.getBegin(), diag::warn_splice_in_doxygen_comment);
+  return;
 default:
   llvm_unreachable("if this is an almost Doxygen comment, "
"it should be ordinary");
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11377,6 +11377,8 @@
 let CategoryName = "Documentation Issue" in {
 def warn_not_a_doxygen_trailing_member_comment : Warning<
   "not a Doxygen trailing comment">, InGroup, DefaultIgnore;
+def warn_splice_in_doxygen_comment : Warning<
+  "line splicing in Doxygen comments are not supported">, InGroup, DefaultIgnore;
 } // end of documentation issue category
 
 let CategoryName = "Nullability Issue" in {
Index: clang/include/clang/AST/RawCommentList.h
===
--- clang/include/clang/AST/RawCommentList.h
+++ clang/include/clang/AST/RawCommentList.h
@@ -115,6 +115,17 @@
 return extractBriefText(Context);
   }
 
+  bool hasUnsupportedSplice(const SourceManager ) const {
+if (!isInvalid())
+  return false;
+StringRef Text = getRawText(SourceMgr);
+if (Text.size() < 6 || Text[0] != '/')
+  return false;
+if (Text[1] == '*')
+  return Text[Text.size() - 1] != '/' || Text[Text.size() - 2] != '*';
+return Text[1] != '/';
+  }
+
   /// Returns sanitized comment text, suitable for presentation in editor UIs.
   /// E.g. will transform:
   /// // This is a long multiline comment.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -290,6 +290,8 @@
   (`#61142 `_)
 - Clang now better diagnose placeholder types constrained with a concept that is
   not a type concept.
+- Fix crash when a doc comment contains a line splicing.
+  (`#62054 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143813: [ClangFE] Check that __sync builtins are naturally aligned.

2023-04-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I think the issue is that you're calling EmitPointerWithAlignment() on the 
argument, then calling EmitScalarExpr on the same argument.  Essentially, 
emitting the argument twice.  If emitting the argument has side-effects, that 
will cause an issue.  Sorry, should have spotted that while reviewing. Should 
be straightforward to fix, though; just make CheckAtomicAlignment return the 
computed pointer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143813/new/

https://reviews.llvm.org/D143813

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


[PATCH] D148029: [Clang] Fix crash caused by line splicing in doc comment

2023-04-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Because the comment parser does not support slices,
we emit a warning for comments that do contain
a splice within their delimiter, and do not add them as
documentation comment.

Fixes #62054


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148029

Files:
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/Sema.cpp
  clang/test/Lexer/comment-escape.c

Index: clang/test/Lexer/comment-escape.c
===
--- clang/test/Lexer/comment-escape.c
+++ clang/test/Lexer/comment-escape.c
@@ -1,6 +1,38 @@
-// RUN: %clang -fsyntax-only %s 
+// RUN: %clang -fsyntax-only -Wdocumentation %s
 // rdar://6757323
 // foo \
 
 #define blork 32
 
+// GH62054
+
+/**<*\
+/
+//expected-warning@-2 {{escaped newline between}} \
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+/**<*\	
+/
+//expected-warning@-2 {{escaped newline between}} \
+//expected-warning@-2 {{backslash and newline separated by space}} \
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+
+/*<*\
+/
+//expected-warning@-2 {{escaped newline between}}  \
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+/*<*\	
+/
+//expected-warning@-2 {{escaped newline between}} \
+//expected-warning@-2 {{backslash and newline separated by space}} \
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+/\
+*<**/
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
+
+/\
+/<*
+//expected-warning@-2 {{line splicing in Doxygen comments are not supported}}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -2390,7 +2390,7 @@
   SourceMgr.isInSystemHeader(Comment.getBegin()))
 return;
   RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false);
-  if (RC.isAlmostTrailingComment()) {
+  if (RC.isAlmostTrailingComment() || RC.hasUnsupportedSplice(SourceMgr)) {
 SourceRange MagicMarkerRange(Comment.getBegin(),
  Comment.getBegin().getLocWithOffset(3));
 StringRef MagicMarkerText;
@@ -2401,6 +2401,11 @@
 case RawComment::RCK_OrdinaryC:
   MagicMarkerText = "/**<";
   break;
+case RawComment::RCK_Invalid:
+  // FIXME: are there other scenarios that could produce an invalid
+  // raw comment here?
+  Diag(Comment.getBegin(), diag::warn_splice_in_doxygen_comment);
+  return;
 default:
   llvm_unreachable("if this is an almost Doxygen comment, "
"it should be ordinary");
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11377,6 +11377,8 @@
 let CategoryName = "Documentation Issue" in {
 def warn_not_a_doxygen_trailing_member_comment : Warning<
   "not a Doxygen trailing comment">, InGroup, DefaultIgnore;
+def warn_splice_in_doxygen_comment : Warning<
+  "line splicing in Doxygen comments are not supported">, InGroup, DefaultIgnore;
 } // end of documentation issue category
 
 let CategoryName = "Nullability Issue" in {
Index: clang/include/clang/AST/RawCommentList.h
===
--- clang/include/clang/AST/RawCommentList.h
+++ clang/include/clang/AST/RawCommentList.h
@@ -115,6 +115,17 @@
 return extractBriefText(Context);
   }
 
+  bool hasUnsupportedSplice(const SourceManager ) const {
+if (!isInvalid())
+  return false;
+StringRef Text = getRawText(SourceMgr);
+if (Text.size() < 6 || Text[0] != '/')
+  return false;
+if (Text[1] == '*')
+  return Text[Text.size() - 1] != '/' || Text[Text.size() - 2] != '*';
+return Text[1] != '/';
+  }
+
   /// Returns sanitized comment text, suitable for presentation in editor UIs.
   /// E.g. will transform:
   /// // This is a long multiline comment.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D147073#4258426 , @zequanwu wrote:

> In D147073#4258396 , @aaron.ballman 
> wrote:
>
>> In D147073#4258384 , @hans wrote:
>>
>>> Again not an expert here, but lgtm.
>>>
>>> (Nit: the 
>>> https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1528-L1530
>>>  link in the description seems to point to the wrong code now, since main 
>>> changed. Here is a link for 16.0.1: 
>>> https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536)
>>
>> I'm confused -- I thought D147569  
>> resolved the issue and so this patch is no longer needed?
>
> D147569  fixes 
> https://github.com/llvm/llvm-project/issues/45481. This one fixes another 
> issue crbug.com/1427933. Their stack trace look similar but not caused by the 
> same issue.
>
> Updated the link in summary to: 
> https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536

Thank you for clarifying, I was confused. :-)

I don't think the changes here are correct either -- it's glossing over an 
issue that we're not properly tracking the source location in the AST. Playing 
around with the reduced example is interesting though. If you remove the 
default argument in the `T` constructor, the issue goes away. If you stop using 
a forward declaration in the instantiation of `T`, the issue goes away. If `S1` 
isn't a template, the issue goes away (but the issue will come back if you then 
make `foo()` a template instead of `S1`). So it seems that something about 
template instantiation is dropping the source location information (perhaps) 
and we should be trying to track down where that is to fix the root cause 
rather than work around it here for coverage mapping alone. (The end location 
being incorrect can impact other things that are harder to test because it'll 
be for things like fix-its that don't work properly, which are easy to miss.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147073/new/

https://reviews.llvm.org/D147073

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


[PATCH] D148024: [clang-format] Don't modify template arguments on the LHS of assignment

2023-04-11 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel created this revision.
rymiel added a project: clang-format.
rymiel added reviewers: owenpan, MyDeveloperDay, HazardyKnusperkeks.
Herald added projects: All, clang.
Herald added a subscriber: cfe-commits.
rymiel requested review of this revision.

After clang-format has determined that an equals sign starts an
expression, it will also go backwards and modify any star/amp/ampamp
binary operators on the left side of the assignment to be
pointers/references instead.

There already exists logic to skip over contents of parentheses and
square brackets, but this patch also expands that logic to apply to
angle brackets. This is so that binary operators inside of template
arguments would not be touched, primary arguments to non-type template
parameters.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148024

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -270,6 +270,18 @@
   ASSERT_EQ(Tokens.size(), 19u) << Tokens;
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
+
+  Tokens = annotate("template * = nullptr> void 
f();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::ampamp, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1819,7 +1819,7 @@
  Previous && Previous->Previous &&
  !Previous->Previous->isOneOf(tok::comma, tok::semi);
  Previous = Previous->Previous) {
-  if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
+  if (Previous->isOneOf(tok::r_square, tok::r_paren, tok::greater)) {
 Previous = Previous->MatchingParen;
 if (!Previous)
   break;


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -270,6 +270,18 @@
   ASSERT_EQ(Tokens.size(), 19u) << Tokens;
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("Foo a = {};");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
+
+  Tokens = annotate("template * = nullptr> void f();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::ampamp, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1819,7 +1819,7 @@
  Previous && Previous->Previous &&
  !Previous->Previous->isOneOf(tok::comma, tok::semi);
  Previous = Previous->Previous) {
-  if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
+  if (Previous->isOneOf(tok::r_square, tok::r_paren, tok::greater)) {
 Previous = Previous->MatchingParen;
 if (!Previous)
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-11 Thread Simeon Ehrig via Phabricator via cfe-commits
SimeonEhrig added a comment.

Except using an in-memory solution for generated fatbin code, the code looks 
good to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

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


[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to X3

2023-04-11 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 512489.
paulkirth marked 2 inline comments as done.
paulkirth added a comment.

Add spaces to parantheticals. Shorten link to discussion on psABI.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146463/new/

https://reviews.llvm.org/D146463

Files:
  clang/docs/ShadowCallStack.rst
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/test/shadowcallstack/lit.cfg.py
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/TargetParser/RISCVTargetParser.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVSubtarget.cpp
  llvm/lib/TargetParser/RISCVTargetParser.cpp
  llvm/test/CodeGen/RISCV/reserved-regs.ll
  llvm/test/CodeGen/RISCV/saverestore-scs.ll
  llvm/test/CodeGen/RISCV/shadowcallstack.ll

Index: llvm/test/CodeGen/RISCV/shadowcallstack.ll
===
--- llvm/test/CodeGen/RISCV/shadowcallstack.ll
+++ llvm/test/CodeGen/RISCV/shadowcallstack.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=riscv32 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
 ; RUN:   | FileCheck %s --check-prefix=RV32
-; RUN: llc -mtriple=riscv64 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
 ; RUN:   | FileCheck %s --check-prefix=RV64
 
 define void @f1() shadowcallstack {
@@ -34,9 +34,9 @@
 define i32 @f3() shadowcallstack {
 ; RV32-LABEL: f3:
 ; RV32:   # %bb.0:
-; RV32-NEXT:sw ra, 0(s2)
-; RV32-NEXT:addi s2, s2, 4
-; RV32-NEXT:.cfi_escape 0x16, 0x12, 0x02, 0x82, 0x7c #
+; RV32-NEXT:sw ra, 0(gp)
+; RV32-NEXT:addi gp, gp, 4
+; RV32-NEXT:.cfi_escape 0x16, 0x03, 0x02, 0x73, 0x7c #
 ; RV32-NEXT:addi sp, sp, -16
 ; RV32-NEXT:.cfi_def_cfa_offset 16
 ; RV32-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
@@ -44,16 +44,16 @@
 ; RV32-NEXT:call bar@plt
 ; RV32-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32-NEXT:addi sp, sp, 16
-; RV32-NEXT:lw ra, -4(s2)
-; RV32-NEXT:addi s2, s2, -4
-; RV32-NEXT:.cfi_restore s2
+; RV32-NEXT:lw ra, -4(gp)
+; RV32-NEXT:addi gp, gp, -4
+; RV32-NEXT:.cfi_restore gp
 ; RV32-NEXT:ret
 ;
 ; RV64-LABEL: f3:
 ; RV64:   # %bb.0:
-; RV64-NEXT:sd ra, 0(s2)
-; RV64-NEXT:addi s2, s2, 8
-; RV64-NEXT:.cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78 #
+; RV64-NEXT:sd ra, 0(gp)
+; RV64-NEXT:addi gp, gp, 8
+; RV64-NEXT:.cfi_escape 0x16, 0x03, 0x02, 0x73, 0x78 #
 ; RV64-NEXT:addi sp, sp, -16
 ; RV64-NEXT:.cfi_def_cfa_offset 16
 ; RV64-NEXT:sd ra, 8(sp) # 8-byte Folded Spill
@@ -61,9 +61,9 @@
 ; RV64-NEXT:call bar@plt
 ; RV64-NEXT:ld ra, 8(sp) # 8-byte Folded Reload
 ; RV64-NEXT:addi sp, sp, 16
-; RV64-NEXT:ld ra, -8(s2)
-; RV64-NEXT:addi s2, s2, -8
-; RV64-NEXT:.cfi_restore s2
+; RV64-NEXT:ld ra, -8(gp)
+; RV64-NEXT:addi gp, gp, -8
+; RV64-NEXT:.cfi_restore gp
 ; RV64-NEXT:ret
   %res = call i32 @bar()
   %res1 = add i32 %res, 1
@@ -73,72 +73,72 @@
 define i32 @f4() shadowcallstack {
 ; RV32-LABEL: f4:
 ; RV32:   # %bb.0:
-; RV32-NEXT:sw ra, 0(s2)
-; RV32-NEXT:addi s2, s2, 4
-; RV32-NEXT:.cfi_escape 0x16, 0x12, 0x02, 0x82, 0x7c #
+; RV32-NEXT:sw ra, 0(gp)
+; RV32-NEXT:addi gp, gp, 4
+; RV32-NEXT:.cfi_escape 0x16, 0x03, 0x02, 0x73, 0x7c #
 ; RV32-NEXT:addi sp, sp, -16
 ; RV32-NEXT:.cfi_def_cfa_offset 16
 ; RV32-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
 ; RV32-NEXT:sw s0, 8(sp) # 4-byte Folded Spill
 ; RV32-NEXT:sw s1, 4(sp) # 4-byte Folded Spill
-; RV32-NEXT:sw s3, 0(sp) # 4-byte Folded Spill
+; RV32-NEXT:sw s2, 0(sp) # 4-byte Folded Spill
 ; RV32-NEXT:.cfi_offset ra, -4
 ; RV32-NEXT:.cfi_offset s0, -8
 ; RV32-NEXT:.cfi_offset s1, -12
-; RV32-NEXT:.cfi_offset s3, -16
+; RV32-NEXT:.cfi_offset s2, -16
 ; RV32-NEXT:call bar@plt
 ; RV32-NEXT:mv s0, a0
 ; RV32-NEXT:call bar@plt
 ; RV32-NEXT:mv s1, a0
 ; RV32-NEXT:call bar@plt
-; RV32-NEXT:mv s3, a0
+; RV32-NEXT:mv s2, a0
 ; RV32-NEXT:call bar@plt
 ; RV32-NEXT:add s0, s0, s1
-; RV32-NEXT:add a0, s3, a0
+; RV32-NEXT:add a0, s2, a0
 ; RV32-NEXT:add a0, s0, a0
 ; RV32-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32-NEXT:lw s0, 8(sp) # 4-byte Folded Reload
 ; RV32-NEXT:lw s1, 4(sp) # 4-byte Folded Reload
-; RV32-NEXT:lw s3, 0(sp) # 4-byte Folded Reload
+; RV32-NEXT:lw s2, 0(sp) # 4-byte Folded Reload
 ; RV32-NEXT:addi sp, sp, 16
-; RV32-NEXT:lw ra, -4(s2)
-; RV32-NEXT:addi s2, s2, -4
-; RV32-NEXT:.cfi_restore s2
+; RV32-NEXT:lw ra, -4(gp)
+; RV32-NEXT:addi gp, gp, -4
+; RV32-NEXT:.cfi_restore gp
 ; RV32-NEXT:ret
 ;
 ; RV64-LABEL: f4:
 ; 

[PATCH] D145441: [AMDGPU] Define data layout entries for buffers

2023-04-11 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 updated this revision to Diff 512488.
krzysz00 added a comment.

Rebase, since we have addrspace 128


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145441/new/

https://reviews.llvm.org/D145441

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.h
  llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-rtn.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-non-integral-address-spaces.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.atomic.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2darraymsaa.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.3d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.store.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.image.atomic.dim.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.add.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.i8.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.add.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f16.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.load.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.sample.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/addrspacecast-captured.ll
  llvm/test/CodeGen/AMDGPU/annotate-kernel-features-hsa.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-intrinsics-mmo-offsets.ll

[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D147073#4258396 , @aaron.ballman 
wrote:

> In D147073#4258384 , @hans wrote:
>
>> Again not an expert here, but lgtm.
>>
>> (Nit: the 
>> https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1528-L1530
>>  link in the description seems to point to the wrong code now, since main 
>> changed. Here is a link for 16.0.1: 
>> https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536)
>
> I'm confused -- I thought D147569  resolved 
> the issue and so this patch is no longer needed?

D147569  fixes 
https://github.com/llvm/llvm-project/issues/45481. This one fixes another issue 
crbug.com/1427933. Their stack trace look similar but not caused by the same 
issue.

Updated the link in summary to: 
https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147073/new/

https://reviews.llvm.org/D147073

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


[PATCH] D147256: [DebugInfo] Fix file path separator when targeting windows.

2023-04-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D147256#4257797 , @hans wrote:

> In D147256#4249527 , @zequanwu 
> wrote:
>
>> - Add a `-use-target-path-separator` flag for llc.
>> - Add test for llc with that flag.
>
> But where does `TM.Options.ObjectFilenameForDebug` come from? Presumably it 
> comes from Clang at some point, so is there any chance we can fix it "at the 
> source" instead?

`TM.Options.ObjectFilenameForDebug` either comes from llc's `-o` or clang-cl's 
`object-file-name=` which is translated from `/Fo[ObjectFileName]`.

For Chromium, the `/Fo[ObjectFileName]` we pass to clang-cl is the same when 
building on Windows and targeting Windows from Linux. The problem comes 
`llvm::sys::path::remove_dots(PathStore, /*remove_dot_dot=*/true);` in 
`CodeViewDebug.cpp`. That function always convert the path to use host's path 
separator. And I don't think we can write a `remove_dots` function that doesn't 
change path separator, because `\` can only be used as path separator on 
Windows but is a valid path character on Linux.

Or we could just not use `llvm::sys::path::remove_dots`, use the user's input 
as it is for object file path.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147256/new/

https://reviews.llvm.org/D147256

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


[PATCH] D138777: [clang-tidy] Add check bugprone-multiple-new-in-one-expression.

2023-04-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp:91
+  ExceptionType, ExceptionReferenceType)));
+  auto BadAllocCatchingTryBlock = cxxTryStmt(hasHandlerFor(CatchBadAllocType));
+

PiotrZSL wrote:
> what about: ```catch(...)```
`hasHandlerFor` checks for it (and it is used in the test).



Comment at: 
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp:102
+  hasAnyArgument(
+  expr(HasNewExpr1, unless(equalsBoundNode("arg2"))).bind("arg1")),
+  hasAnyArgument(

PiotrZSL wrote:
> this doesnt look valid, arg2 isn't known at this point yet, so this could be 
> removed.
> and this may not work for case like this:
> 
> ```callSomething({new A,  new B});```  
> Most probably this equalsBoundNode should be on HasNewExpr2 level, to avoid 
> duplicated newExpr, not arguments of call
> 
> and image situation like this:
> 
> ```
> try {
>   something(std::shared_ptr(new int), std::shared_ptr(new int));
> } catch(const std::bad_alloc&) {}
> ```
> this in theory could also produce false-positive.
> 
> other issue is that first call could be anything, maloc, new, calloc, 
> wzalloc, operator new(), it doesn't need to be just new.
> You could try to use some simple way of checking this like, 
> isBeforeInTransationUnit
> 
> And this will also produce false-positive if we use `new(std::nothrow)` on 
> second.
> There are some "utils" to check sequence order, maybe would be good to 
> investigate them.
I am not an expert in how AST matchers work exactly, but this code works with 
the provided tests and the results look correct. I did not experience that two 
`new` in the same argument is matched, this is why the 
`unless(equalsBoundNode(...))` is added. The "arg1" and "arg2" nodes are the 
direct expressions in the function call, not descendants, and a `new` in the 
same argument (any descendant) is not matched twice in this way. Otherwise this 
would show up in failed tests.

The code `something(std::shared_ptr(new int), std::shared_ptr(new 
int))` should produce warning (it may be possible that result of the first `new 
int` is not passed to `shared_ptr` before the other `new int` is called that 
fails, good solution is use of `std::make_shared` in such case). The test code 
`(void)f(g(new A), new B);` is somewhat similar AST, the `new A` should be 
found in all cases because `hasDescendant` is used at `HasNewExpr1` and 2.

Probably `unless(equalsBoundNode("arg2"))` can be removed, it is enough to have 
one of these checks.

`InitListExpr` is not handled by the current code, I need to add this case (it 
has fixed evaluation order).



Comment at: 
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp:102
+  hasAnyArgument(
+  expr(HasNewExpr1, unless(equalsBoundNode("arg2"))).bind("arg1")),
+  hasAnyArgument(

balazske wrote:
> PiotrZSL wrote:
> > this doesnt look valid, arg2 isn't known at this point yet, so this could 
> > be removed.
> > and this may not work for case like this:
> > 
> > ```callSomething({new A,  new B});```  
> > Most probably this equalsBoundNode should be on HasNewExpr2 level, to avoid 
> > duplicated newExpr, not arguments of call
> > 
> > and image situation like this:
> > 
> > ```
> > try {
> >   something(std::shared_ptr(new int), std::shared_ptr(new int));
> > } catch(const std::bad_alloc&) {}
> > ```
> > this in theory could also produce false-positive.
> > 
> > other issue is that first call could be anything, maloc, new, calloc, 
> > wzalloc, operator new(), it doesn't need to be just new.
> > You could try to use some simple way of checking this like, 
> > isBeforeInTransationUnit
> > 
> > And this will also produce false-positive if we use `new(std::nothrow)` on 
> > second.
> > There are some "utils" to check sequence order, maybe would be good to 
> > investigate them.
> I am not an expert in how AST matchers work exactly, but this code works with 
> the provided tests and the results look correct. I did not experience that 
> two `new` in the same argument is matched, this is why the 
> `unless(equalsBoundNode(...))` is added. The "arg1" and "arg2" nodes are the 
> direct expressions in the function call, not descendants, and a `new` in the 
> same argument (any descendant) is not matched twice in this way. Otherwise 
> this would show up in failed tests.
> 
> The code `something(std::shared_ptr(new int), std::shared_ptr(new 
> int))` should produce warning (it may be possible that result of the first 
> `new int` is not passed to `shared_ptr` before the other `new int` is called 
> that fails, good solution is use of `std::make_shared` in such case). The 
> test code `(void)f(g(new A), new B);` is somewhat similar AST, the `new A` 
> 

[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D147073#4258384 , @hans wrote:

> Again not an expert here, but lgtm.
>
> (Nit: the 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1528-L1530
>  link in the description seems to point to the wrong code now, since main 
> changed. Here is a link for 16.0.1: 
> https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536)

I'm confused -- I thought D147569  resolved 
the issue and so this patch is no longer needed?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147073/new/

https://reviews.llvm.org/D147073

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


[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-11 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Again not an expert here, but lgtm.

(Nit: the 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1528-L1530
 link in the description seems to point to the wrong code now, since main 
changed. Here is a link for 16.0.1: 
https://github.com/llvm/llvm-project/blob/llvmorg-16.0.1/clang/lib/Sema/SemaExprCXX.cpp#L1536)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147073/new/

https://reviews.llvm.org/D147073

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


[PATCH] D143467: [PowerPC] Add target feature requirement to builtins

2023-04-11 Thread Kamau Bridgeman via Phabricator via cfe-commits
kamaub requested changes to this revision.
kamaub added a comment.
This revision now requires changes to proceed.

Sorry I should have requested changes before for this comment below, but I do 
want these test moved to codegen and expanded, please let me know if anything 
is unclear.

In D143467#4241667 , @kamaub wrote:

> Can you add a PowerPC codegen test case for `__attribute__((target(`? All of 
> the updated test cases seem to only test `-target-feature`.
> The only test case we have for `__attribute((target(` is a sema test 
> `./clang/test/Sema/ppc-attr-target-inline.c`.
>
> Converting the deleted `clang/test/Sema/ppc-mma-builtins.c` and 
> `clang/test/Sema/ppc-paired-vector-builtins.c` to a codegen test cases
> like `clang/test/CodeGen/PowerPC/builtins-ppc-htm.c` using FileCheck seems 
> like a nice solution since it would reintroduce the testing
> for `+paired-vector-memops,-mma` situations, as well as a for 
> `__attribute__((target("no-mma")))`




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143467/new/

https://reviews.llvm.org/D143467

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


[PATCH] D147876: [clang-tidy] Support specifying checks as a list in the config file

2023-04-11 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

> When the `.clang-tidy` file is checked into the source control(git). It means 
> that anyone who contributes to the project will need to ensure that they have 
> a version of clang-tidy that will be able to read the file.
> This can cause problems as binaries of clang-tidy aren't always provided for 
> specific versions on certain platforms.

Isn't that expected though? All projects have expectations on the required 
dependencies to build their code. For example LLVM requires a compiler with 
C++17 support and a modern CMake that needs to be downloaded from the CMake 
website on older Ubuntu versions. Granted, those are backwards-compatible 
constraints, but nevertheless require that the user sets them up. It doesn't 
come out of the box in a regular distribution. Same applies to other C++ 
libraries, Python pip packages, etc. That's why typically projects should set 
up a sandboxed environment with pinned versions of dependencies to ensure they 
can always be built and linted at any point in time.

Take also for example Clang compiler, I can see in the release notes that they 
have removed 2 user-facing compiler flags:
https://clang.llvm.org/docs/ReleaseNotes.html#removed-compiler-flags

This means this compiler can no longer be used to compile code that has a 
checked-in CMakeLists.txt (or similar) that uses those compiler flags. How much 
of a problem that is? Should those projects really prevent Clang from cleaning 
technical debt and be user-friendly for the general public?

I do acknowledge that the proposed deprecation is much bigger since it will 
affect essentially all projects. I'm thinking perhaps we can simply extend the 
notice period so everyone has time to update, together with printing some 
warning?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147876/new/

https://reviews.llvm.org/D147876

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


  1   2   >