[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-13 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

@aaron.ballman, @rsmith, @mizvekov, @shafik,  has the mankind any chance to get 
this reviewed and merged?

Btw, FYI, I've investigated the Chromium compilation crash that caused the 
rollback in 8ba442bc2136 
 and have 
succeeded in obtaining a smaller reproducer:

  void fn() {
auto L = [i = 5](auto) -> decltype(auto) { return i; };
L(2);
  }

After 5a391d38ac6c 
, 
`DeclRefExpr` in lambda `return` statement referring to `i` becomes 
instantiation dependent because decl context of `i` declaration occurs to be 
the templated lambda `operator()` and not the lambda implicit (non-templated) 
class (which seems to be wrong). Then, after da986511fb9da1a 
, that 
dependence flag started to propagate through `DecltypeType`, and `L(2)` call 
result type becomes "dependent", which, of course, should not occur.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D143736: [PowerPC] Specify the dynamic loader prefix in ppc-float-abi-warning

2023-02-13 Thread Qiu Chaofan 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 rGcb90bb986611: [PowerPC] Specify the dynamic loader prefix in 
ppc-float-abi-warning (authored by tuliom, committed by qiucf).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143736

Files:
  clang/test/Driver/ppc-float-abi-warning.cpp


Index: clang/test/Driver/ppc-float-abi-warning.cpp
===
--- clang/test/Driver/ppc-float-abi-warning.cpp
+++ clang/test/Driver/ppc-float-abi-warning.cpp
@@ -17,10 +17,12 @@
 // RUN:  -mabi=ieeelongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \
 // RUN:  FileCheck %s --check-prefix=NOWARN
 // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  --dyld-prefix=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \
 // RUN:  -mabi=%if ppc_linux_default_ieeelongdouble %{ieeelongdouble%} \
 // RUN:  %else %{ibmlongdouble%} -stdlib=libc++ 2>&1 | \
 // RUN:  FileCheck %s --check-prefix=NOWARN
 // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  --dyld-prefix=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \
 // RUN:  -mabi=%if ppc_linux_default_ieeelongdouble %{ibmlongdouble%} \
 // RUN:  %else %{ieeelongdouble%} -stdlib=libc++ 2>&1 | FileCheck %s
 


Index: clang/test/Driver/ppc-float-abi-warning.cpp
===
--- clang/test/Driver/ppc-float-abi-warning.cpp
+++ clang/test/Driver/ppc-float-abi-warning.cpp
@@ -17,10 +17,12 @@
 // RUN:  -mabi=ieeelongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \
 // RUN:  FileCheck %s --check-prefix=NOWARN
 // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  --dyld-prefix=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \
 // RUN:  -mabi=%if ppc_linux_default_ieeelongdouble %{ieeelongdouble%} \
 // RUN:  %else %{ibmlongdouble%} -stdlib=libc++ 2>&1 | \
 // RUN:  FileCheck %s --check-prefix=NOWARN
 // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  --dyld-prefix=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \
 // RUN:  -mabi=%if ppc_linux_default_ieeelongdouble %{ibmlongdouble%} \
 // RUN:  %else %{ieeelongdouble%} -stdlib=libc++ 2>&1 | FileCheck %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cb90bb9 - [PowerPC] Specify the dynamic loader prefix in ppc-float-abi-warning

2023-02-13 Thread Qiu Chaofan via cfe-commits

Author: Tulio Magno Quites Machado Filho
Date: 2023-02-14T15:03:58+08:00
New Revision: cb90bb986611bab58dbe05cefb0903e0a07f3cca

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

LOG: [PowerPC] Specify the dynamic loader prefix in ppc-float-abi-warning

Ensure the tests do not fail during cross compilation by specifying
the dynamic loader prefix for a GNU installation that is expected to
support IEEE 128-bit long double.

Reviewed By: qiucf

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

Added: 


Modified: 
clang/test/Driver/ppc-float-abi-warning.cpp

Removed: 




diff  --git a/clang/test/Driver/ppc-float-abi-warning.cpp 
b/clang/test/Driver/ppc-float-abi-warning.cpp
index e3baa9f4c059d..87d6d87a3b31e 100644
--- a/clang/test/Driver/ppc-float-abi-warning.cpp
+++ b/clang/test/Driver/ppc-float-abi-warning.cpp
@@ -17,10 +17,12 @@
 // RUN:  -mabi=ieeelongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \
 // RUN:  FileCheck %s --check-prefix=NOWARN
 // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  --dyld-prefix=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \
 // RUN:  -mabi=%if ppc_linux_default_ieeelongdouble %{ieeelongdouble%} \
 // RUN:  %else %{ibmlongdouble%} -stdlib=libc++ 2>&1 | \
 // RUN:  FileCheck %s --check-prefix=NOWARN
 // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  --dyld-prefix=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \
 // RUN:  -mabi=%if ppc_linux_default_ieeelongdouble %{ibmlongdouble%} \
 // RUN:  %else %{ieeelongdouble%} -stdlib=libc++ 2>&1 | FileCheck %s
 



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


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

2023-02-13 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 497206.
VincentWu marked 19 inline comments as done.
VincentWu added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmp-invalid.s
  llvm/test/MC/RISCV/rv32zcmp-valid.s
  llvm/test/MC/RISCV/rv64zcb-invalid.s
  llvm/test/MC/RISCV/rv64zcmp-invalid.s
  llvm/test/MC/RISCV/rv64zcmp-valid.s

Index: llvm/test/MC/RISCV/rv64zcmp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmp-valid.s
@@ -0,0 +1,149 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=experimental-zcmp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=experimental-zcmp < %s \
+# RUN: | llvm-objdump --mattr=-c,experimental-zcmp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.mvsa01 s1, s0
+# CHECK-ASM: encoding: [0xa2,0xac]
+cm.mvsa01 s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.mva01s s1, s0
+# CHECK-ASM: encoding: [0xe2,0xac]
+cm.mva01s s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbe]
+cm.popret {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbe]
+cm.popret {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbe]
+cm.popret {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbe]
+cm.popret {ra,s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbe]
+cm.popret {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbe]
+cm.popret {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbe]
+cm.popret {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbe]
+cm.popret {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbe]
+cm.popret {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbc]
+cm.popretz {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbc]
+cm.popretz {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbc]
+cm.popretz {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbc]
+cm.popretz {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbc]
+cm.popretz {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbc]
+cm.popretz {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbc]
+cm.popretz {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbc]
+cm.popretz {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbc]
+cm.popretz {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xba]
+cm.pop {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xba]
+cm.pop {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0}, 16
+# CHECK-ASM: encoding: [0x52,0xba]
+cm.pop {ra, s0}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xba]
+cm.pop {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xba]
+cm.pop {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xba]
+cm.pop {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xba]
+cm.pop {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xba]
+cm.pop {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.push {ra}, -16
+# CHECK-ASM: encoding: [0x42,0xb8]
+cm.push {ra}, -16
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0}, -32
+# CHECK-ASM: encoding: [0x56,0xb8]
+cm.push {ra, s0}, -32
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0-s1}, 

[PATCH] D143418: [libclang] Add API to set preferred temp dir path

2023-02-13 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy added a comment.

> `uint32_t Size; // = sizeof(struct CIndexOptions), used for option versioning`

`uint32_t` was introduced in C99. Can/should it be used in //Index.h//? Only 
built-in `[unsigned] (int|long)` types are currently used in this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143418

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


[clang] 9c4f0d8 - [docs] Add document for clang-scan-deps -format=p1689

2023-02-13 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-02-14T14:00:12+08:00
New Revision: 9c4f0d83f64ea64d662bb0c670bb5ca5d21a63fe

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

LOG: [docs] Add document for clang-scan-deps -format=p1689

The patches for `clang-scan-deps` have been landed. And we need to
document the behavior then.

Added: 


Modified: 
clang/docs/StandardCPlusPlusModules.rst

Removed: 




diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index c8dbaa89bbfe1..d4db37ea6e2e2 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -856,6 +856,249 @@ So the final answer for why we don't reuse the interface 
of Clang modules for he
 there are some 
diff erences between header units and Clang modules and that ignoring those
 
diff erences now would likely become a problem in the future.
 
+Discover Dependencies
+=
+
+Prior to modules, all the translation units can be compiled parallelly.
+But it is not true for the module units. The presense of module units requires
+us to compile the translation units in a (topological) order.
+
+The clang-scan-deps scanner implemented
+`P1689 paper 
`_
+to describe the order. Only named modules are supported now.
+
+We need a compilation database to use clang-scan-deps. See
+`JSON Compilation Database Format Specification 
`_
+for example. Note that the ``output`` entry is necessary for clang-scan-deps
+to scan P1689 format. Here is an example:
+
+.. code-block:: c++
+
+  //--- M.cppm
+  export module M;
+  export import :interface_part;
+  import :impl_part;
+  export int Hello();
+
+  //--- interface_part.cppm
+  export module M:interface_part;
+  export void World();
+
+  //--- Impl.cpp
+  module;
+  #include 
+  module M;
+  void Hello() {
+  std::cout << "Hello ";
+  }
+
+  //--- impl_part.cppm
+  module;
+  #include 
+  #include 
+  module M:impl_part;
+  import :interface_part;
+
+  std::string W = "World.";
+  void World() {
+  std::cout << W << std::endl;
+  }
+
+  //--- User.cpp
+  import M;
+  import third_party_module;
+  int main() {
+Hello();
+World();
+return 0;
+  }
+
+And here is the compilation database:
+
+.. code-block:: text
+
+  [
+  {
+  "directory": ".",
+  "command": "/clang++ -std=c++20 M.cppm -c 
-o M.o",
+  "file": "M.cppm",
+  "output": "M.o"
+  },
+  {
+  "directory": ".",
+  "command": "/clang++ -std=c++20 Impl.cpp -c 
-o Impl.o",
+  "file": "Impl.cpp",
+  "output": "Impl.o"
+  },
+  {
+  "directory": ".",
+  "command": "/clang++ -std=c++20 
impl_part.cppm -c -o impl_part.o",
+  "file": "impl_part.cppm",
+  "output": "impl_part.o"
+  },
+  {
+  "directory": ".",
+  "command": "/clang++ -std=c++20 
interface_part.cppm -c -o interface_part.o",
+  "file": "interface_part.cppm",
+  "output": "interface_part.o"
+  },
+  {
+  "directory": ".",
+  "command": "/clang++ -std=c++20 User.cpp -c 
-o User.o",
+  "file": "User.cpp",
+  "output": "User.o"
+  }
+  ]
+
+And we can get the dependency information in P1689 format by:
+
+.. code-block:: console
+
+  $ clang-scan-deps -format=p1689 -compilation-database P1689.json
+
+And we will get:
+
+.. code-block:: text
+
+  {
+"revision": 0,
+"rules": [
+  {
+"primary-output": "Impl.o",
+"requires": [
+  {
+"logical-name": "M",
+"source-path": "M.cppm"
+  }
+]
+  },
+  {
+"primary-output": "M.o",
+"provides": [
+  {
+"is-interface": true,
+"logical-name": "M",
+"source-path": "M.cppm"
+  }
+],
+"requires": [
+  {
+"logical-name": "M:interface_part",
+"source-path": "interface_part.cppm"
+  },
+  {
+"logical-name": "M:impl_part",
+"source-path": "impl_part.cppm"
+  }
+]
+  },
+  {
+"primary-output": "User.o",
+"requires": [
+  {
+"logical-name": "M",
+"source-path": "M.cppm"
+  },
+  {
+"logical-name": "third_party_module"
+  }
+]
+  },
+  {
+"primary-output": "impl_part.o",
+"provides": [
+  {
+"is-interface": false,
+"logical-name": "M:impl_part",
+"source-path": "impl_part.cppm"
+  }
+],
+"requires": [
+  {
+"logical-name": "M:interface_part",
+"source-path": "interface_part.cppm"
+  }
+]
+  },
+  {
+

[PATCH] D143971: [clang-tidy] Flag code with both string constructor arguments implicitly casted

2023-02-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp:40
+
+  std::string swapped('x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are 
probably swapped; expecting string(count, character) 
[bugprone-string-constructor]

`swapped[1,2,5,7]`, `wswapped` were all supported by the original logic - i.e., 
the ones with a literal char as the first arg.

The other `swapped*` cases are newly supported with my changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143971

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


[PATCH] D143971: [clang-tidy] Flag code with both string constructor arguments implicitly casted

2023-02-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 497189.
ccotter added a comment.

- Add more cases to swapped params


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143971

Files:
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
@@ -5,12 +5,13 @@
 class allocator {};
 template 
 class char_traits {};
-template , typename A = std::allocator >
+template , typename A = std::allocator>
 struct basic_string {
   basic_string();
-  basic_string(const C*, unsigned int size);
-  basic_string(const C *, const A  = A());
-  basic_string(unsigned int size, C c);
+  basic_string(const basic_string&, unsigned int, unsigned int, const A & = A());
+  basic_string(const C*, unsigned int);
+  basic_string(const C*, const A& = A());
+  basic_string(unsigned int, C);
 };
 typedef basic_string string;
 typedef basic_string wstring;
@@ -18,7 +19,7 @@
 template >
 struct basic_string_view {
   basic_string_view();
-  basic_string_view(const C *, unsigned int size);
+  basic_string_view(const C *, unsigned int);
   basic_string_view(const C *);
 };
 typedef basic_string_view string_view;
@@ -28,20 +29,58 @@
 const char* kText = "";
 const char kText2[] = "";
 extern const char kText3[];
+char getChar();
+const char* getCharPtr();
 
 void Test() {
-  std::string str('x', 4);
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [bugprone-string-constructor]
-  // CHECK-FIXES: std::string str(4, 'x');
-  std::wstring wstr(L'x', 4);
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: string constructor parameters are probably swapped
-  // CHECK-FIXES: std::wstring wstr(4, L'x');
+  short sh;
+  int i;
+  char ch;
+
+  std::string swapped('x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped(4, 'x');
+  std::wstring wswapped(L'x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: string constructor arguments are probably swapped
+  // CHECK-FIXES: std::wstring wswapped(4, L'x');
+  std::string swapped2('x', i);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped2(i, 'x');
+  std::string swapped3(ch, 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped3(4, ch);
+  std::string swapped4(ch, i);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped4(i, ch);
+  std::string swapped5('x', (int)'x');
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped5((int)'x', 'x');
+  std::string swapped6(getChar(), 10);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped6(10, getChar());
+  std::string swapped7((('x')), ( i ));
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped7(( i ), (('x')));
+  std::string swapped8((ch), (i));
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped8((i), (ch));
+  std::string swapped9((getChar()), (i));
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped9((i), (getChar()));
   std::string s0(0, 'x');
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
   std::string s1(-4, 'x');
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
   std::string s2(0x100, 

[PATCH] D143974: [clangd] Inactive regions support via dedicated protocol

2023-02-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Corresponding client-side support is implemented for vscode in the latest 
version of https://github.com/clangd/vscode-clangd/pull/193.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143974

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


[PATCH] D143974: [clangd] Inactive regions support via dedicated protocol

2023-02-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added reviewers: sammccall, kadircet, hokein.
Herald added a subscriber: arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This implements the server side of the approach discussed at
https://github.com/clangd/vscode-clangd/pull/193#issuecomment-1044315732


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143974

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -89,7 +89,8 @@
   for (auto File : AdditionalFiles)
 TU.AdditionalFiles.insert({File.first, std::string(File.second)});
   auto AST = TU.build();
-  auto Actual = getSemanticHighlightings(AST);
+  auto Actual =
+  getSemanticHighlightings(AST, /*IncludeInactiveRegionTokens=*/true);
   for (auto  : Actual)
 Token.Modifiers &= ModifierMask;
 
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -344,7 +344,8 @@
 
   void buildSemanticHighlighting(std::optional LineRange) {
 log("Building semantic highlighting");
-auto Highlights = getSemanticHighlightings(*AST);
+auto Highlights =
+getSemanticHighlightings(*AST, /*IncludeInactiveRegionTokens=*/true);
 for (const auto HL : Highlights)
   if (!LineRange || LineRange->contains(HL.R))
 vlog(" {0} {1} {2}", HL.R, HL.Kind, HL.Modifiers);
Index: clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
@@ -47,14 +47,16 @@
 // Now we hit the TUDecl case where commonAncestor() returns null
 // intendedly. We only annotate tokens in the main file, so use the default
 // traversal scope (which is the top level decls of the main file).
-HighlightingTokens = getSemanticHighlightings(*Inputs.AST);
+HighlightingTokens = getSemanticHighlightings(
+*Inputs.AST, /*IncludeInactiveRegionTokens=*/true);
   } else {
 // Store the existing scopes.
 const auto  = Inputs.AST->getASTContext().getTraversalScope();
 // Narrow the traversal scope to the selected node.
 Inputs.AST->getASTContext().setTraversalScope(
 {const_cast(CommonDecl)});
-HighlightingTokens = getSemanticHighlightings(*Inputs.AST);
+HighlightingTokens = getSemanticHighlightings(
+*Inputs.AST, /*IncludeInactiveRegionTokens=*/true);
 // Restore the traversal scope.
 Inputs.AST->getASTContext().setTraversalScope(BackupScopes);
   }
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -105,7 +105,8 @@
 
 // Returns all HighlightingTokens from an AST. Only generates highlights for the
 // main AST.
-std::vector getSemanticHighlightings(ParsedAST );
+std::vector
+getSemanticHighlightings(ParsedAST , bool IncludeInactiveRegionTokens);
 
 std::vector toSemanticTokens(llvm::ArrayRef,
 llvm::StringRef Code);
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -357,9 +357,10 @@
 /// Consumes source locations and maps them to text ranges for highlightings.
 class HighlightingsBuilder {
 public:
-  HighlightingsBuilder(const ParsedAST )
+  HighlightingsBuilder(const ParsedAST , bool IncludeInactiveRegionTokens)
   : TB(AST.getTokens()), SourceMgr(AST.getSourceManager()),
-LangOpts(AST.getLangOpts()) {}
+LangOpts(AST.getLangOpts()),
+IncludeInactiveRegionTokens(IncludeInactiveRegionTokens) {}
 
   HighlightingToken (SourceLocation Loc, HighlightingKind Kind) {
 auto Range = getRangeForSourceLocation(Loc);
@@ 

[PATCH] D143849: [Clang][OpenCL] Allow pointers in structs as kernel arguments from 2.0

2023-02-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/test/SemaOpenCL/invalid-kernel-parameters.cl:90
 
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
 typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' 
declared here}}

Ayal wrote:
> yaxunl wrote:
> > we should not limit the tests to CL1.2. We should test them with 2.0 to 
> > make sure there is no diagnostics.
> > 
> > To differentiate between 1.2 and 2.0 you can use -verify=ocl12 and 
> > -verify=ocl20.
> > 
> > same as below
> Using -verify=ocl12 and -verify=ocl20 should probably be done separately as 
> an NFC patch as it involves many changes IIUC.
> 
> The expect's were placed under #ifdef instead (and only them), following e.g. 
> existing lines 8-12.
you can use -verify=expected,ocl12 for OCL1.2 and -verify for OCL2.0 then the 
common diagnostics are kept as 'expected-*' and unchanged. you only need to 
change the ocl1.2 specific diagnostics to 'ocl12-*'.

For example, 
https://github.com/llvm/llvm-project/blob/main/clang/test/SemaOpenCL/atomic-ops.cl


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

https://reviews.llvm.org/D143849

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


[PATCH] D143971: [clang-tidy] Flag code with both string constructor arguments implicitly casted

2023-02-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp:58
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments 
might be incorrect;
+  std::string s7(kText[1], 10);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments 
might be incorrect;

This is specifically a bug I wrote recently where I meant to write `[1]`. 
This doesn't fall under the "arguments swapped" case since indeed I merely 
forgot a '&'. At most, the tool can flag this potentially buggy code and 
suggest casts if the author determines the code is correct as is. However, the 
tool does not actually provide replacements as such code is more likely to be 
incorrect and require the author to determine the fix and apply it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143971

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


[PATCH] D143971: Flag code with both string constructor arguments implicitly casted

2023-02-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter created this revision.
Herald added a subscriber: carlosgalvezp.
Herald added a reviewer: njames93.
Herald added a project: All.
ccotter requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Calls to the fill constructor where both arguments are
implicitly cast is confusing since the implicit cast may not be
apparent to the reader. In many cases, this is a programmer error. In
cases where it's not an error, the code should use explicit casts to
clearly specify intent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143971

Files:
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
@@ -5,12 +5,13 @@
 class allocator {};
 template 
 class char_traits {};
-template , typename A = std::allocator >
+template , typename A = std::allocator>
 struct basic_string {
   basic_string();
-  basic_string(const C*, unsigned int size);
-  basic_string(const C *, const A  = A());
-  basic_string(unsigned int size, C c);
+  basic_string(const basic_string&, unsigned int, unsigned int, const A & = A());
+  basic_string(const C*, unsigned int);
+  basic_string(const C*, const A& = A());
+  basic_string(unsigned int, C);
 };
 typedef basic_string string;
 typedef basic_string wstring;
@@ -18,7 +19,7 @@
 template >
 struct basic_string_view {
   basic_string_view();
-  basic_string_view(const C *, unsigned int size);
+  basic_string_view(const C *, unsigned int);
   basic_string_view(const C *);
 };
 typedef basic_string_view string_view;
@@ -31,10 +32,10 @@
 
 void Test() {
   std::string str('x', 4);
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
   // CHECK-FIXES: std::string str(4, 'x');
   std::wstring wstr(L'x', 4);
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: string constructor parameters are probably swapped
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: string constructor arguments are probably swapped
   // CHECK-FIXES: std::wstring wstr(4, L'x');
   std::string s0(0, 'x');
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
@@ -43,6 +44,22 @@
   std::string s2(0x100, 'x');
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
 
+  short sh;
+  int i;
+  char ch;
+  std::string s3(ch, 10);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments might be incorrect; calling as string(count, character) due to implicit casting of both arguments; use explicit casts if string(count, character) is the intended constructor [bugprone-string-constructor]
+  std::string s4(ch, sh);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments might be incorrect;
+  std::string s5(ch, i);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments might be incorrect;
+  std::string s6(ch, (int)ch);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments might be incorrect;
+  std::string s7(kText[1], 10);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments might be incorrect;
+  std::string s8(kText[1], i);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments might be incorrect;
+
   std::string q0("test", 0);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
   std::string q1(kText, -4);
@@ -91,12 +108,15 @@
 }
 
 void Valid() {
+  int i;
   std::string empty();
   std::string str(4, 'x');
   std::wstring wstr(4, L'x');
   std::string s1("test", 4);
   std::string s2("test", 3);
   std::string s3("test");
+  std::string s4((int)kText[1], i);
+  std::string s5(kText[1], (char)i);
 
   std::string_view emptyv();
   std::string_view sv1("test", 4);
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
@@ -5,7 +5,7 @@
 
 Finds string constructors that are suspicious and probably errors.
 
-A common mistake is to swap parameters to the 'fill' string-constructor.
+A common mistake is to swap arguments to 

[PATCH] D143657: [Clang][RISCV] Guard vector float16 type correctly with semantic analysis

2023-02-13 Thread Yueh-Ting (eop) Chen 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 rG235e90c1d760: [Clang][RISCV] Guard vector float16 type 
correctly with semantic analysis (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143657

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/test/Sema/riscv-vector-float16-check.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -368,14 +368,13 @@
   }
 }
   }
-  OS << "#if defined(__riscv_zvfh)\n";
+
   for (int Log2LMUL : Log2LMULs) {
 auto T = TypeCache.computeType(BasicType::Float16, Log2LMUL,
PrototypeDescriptor::Vector);
 if (T)
   printType(*T);
   }
-  OS << "#endif\n";
 
   OS << "#if (__riscv_v_elen_fp >= 32)\n";
   for (int Log2LMUL : Log2LMULs) {
Index: clang/test/Sema/riscv-vector-float16-check.c
===
--- /dev/null
+++ clang/test/Sema/riscv-vector-float16-check.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+#include 
+
+vfloat16m1_t foo() { /* expected-error {{RISC-V type 'vfloat16m1_t' (aka '__rvv_float16m1_t') requires the 'zvfh' extension}} */
+} /* expected-warning {{non-void function does not return a value}}*/
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -171,7 +171,6 @@
   const TargetInfo  = Context.getTargetInfo();
   bool HasVectorFloat32 = TI.hasFeature("zve32f");
   bool HasVectorFloat64 = TI.hasFeature("zve64d");
-  bool HasZvfh = TI.hasFeature("experimental-zvfh");
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
 
@@ -223,9 +222,6 @@
 continue;
 
   // Check requirement.
-  if (BaseType == BasicType::Float16 && !HasZvfh)
-continue;
-
   if (BaseType == BasicType::Float32 && !HasVectorFloat32)
 continue;
 
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -2039,6 +2039,12 @@
 targetDiag(D->getLocation(), diag::note_defined_here, FD) << D;
 }
 
+if (Ty->isRVVType(/* Bitwidth */ 16, /* IsFloat */ true) &&
+!Context.getTargetInfo().hasFeature("experimental-zvfh")) {
+  Diag(Loc, diag::err_riscv_type_requires_extension, FD)
+  << Ty << "zvfh";
+}
+
 // Don't allow SVE types in functions without a SVE target.
 if (Ty->isSVESizelessBuiltinType() && FD && FD->hasBody()) {
   llvm::StringMap CallerFeatureMap;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11738,6 +11738,9 @@
   "builtin requires%select{| at least one of the following extensions to be enabled}0: %1">;
 def err_riscv_builtin_invalid_lmul : Error<
   "LMUL argument must be in the range [0,3] or [5,7]">;
+def err_riscv_type_requires_extension : Error<
+  "RISC-V type %0 requires the '%1' extension"
+>;
 
 def err_std_source_location_impl_not_found : Error<
   "'std::source_location::__impl' was not found; it must be defined before '__builtin_source_location' is called">;
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -2275,6 +2275,8 @@
 
   bool isRVVType() const;
 
+  bool isRVVType(unsigned Bitwidth, bool IsFloat) const;
+
   /// Return the implicit lifetime for this type, which must not be dependent.
   Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const;
 
@@ -7153,6 +7155,17 @@
 false; // end of boolean or operation.
 }
 
+inline bool Type::isRVVType(unsigned Bitwidth, bool IsFloat) const {
+  bool Ret = false;
+#define RVV_TYPE(Name, Id, SingletonId)
+#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned,   \
+IsFP)  \
+  if (ElBits == Bitwidth && IsFloat == IsFP)   \
+Ret |= isSpecificBuiltinType(BuiltinType::Id);
+#include 

[clang] 235e90c - [Clang][RISCV] Guard vector float16 type correctly with semantic analysis

2023-02-13 Thread via cfe-commits

Author: eopXD
Date: 2023-02-13T18:07:00-08:00
New Revision: 235e90c1d760ea38f2af6bf4de2cc9355b89d24c

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

LOG: [Clang][RISCV] Guard vector float16 type correctly with semantic analysis

Before this commit, vector float 16 types (e.g. `vfloat16m1_t`) of RVV
is only defined when extension `zvfh` is defined. However this
generate inaccurate diagnostics like:

```
error: unknown type name 'vfloat16m1_t'
```

This commit improves the compiler by guarding type check correctly
under semantic analysis.

Reviewed By: craig.topper

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

Added: 
clang/test/Sema/riscv-vector-float16-check.c

Modified: 
clang/include/clang/AST/Type.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaRISCVVectorLookup.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 180251d7f6bd..34c85c1930c8 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2275,6 +2275,8 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
 
   bool isRVVType() const;
 
+  bool isRVVType(unsigned Bitwidth, bool IsFloat) const;
+
   /// Return the implicit lifetime for this type, which must not be dependent.
   Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const;
 
@@ -7153,6 +7155,17 @@ inline bool Type::isRVVType() const {
 false; // end of boolean or operation.
 }
 
+inline bool Type::isRVVType(unsigned Bitwidth, bool IsFloat) const {
+  bool Ret = false;
+#define RVV_TYPE(Name, Id, SingletonId)
+#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned,   
\
+IsFP)  
\
+  if (ElBits == Bitwidth && IsFloat == IsFP)   
\
+Ret |= isSpecificBuiltinType(BuiltinType::Id);
+#include "clang/Basic/RISCVVTypes.def"
+  return Ret;
+}
+
 inline bool Type::isTemplateTypeParmType() const {
   return isa(CanonicalType);
 }

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b658ad71e63a..af714de6b607 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11738,6 +11738,9 @@ def err_riscv_builtin_requires_extension : Error<
   "builtin requires%select{| at least one of the following extensions to be 
enabled}0: %1">;
 def err_riscv_builtin_invalid_lmul : Error<
   "LMUL argument must be in the range [0,3] or [5,7]">;
+def err_riscv_type_requires_extension : Error<
+  "RISC-V type %0 requires the '%1' extension"
+>;
 
 def err_std_source_location_impl_not_found : Error<
   "'std::source_location::__impl' was not found; it must be defined before 
'__builtin_source_location' is called">;

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index f983c477ac18..fd412765447b 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -2039,6 +2039,12 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation 
Loc, ValueDecl *D) {
 targetDiag(D->getLocation(), diag::note_defined_here, FD) << D;
 }
 
+if (Ty->isRVVType(/* Bitwidth */ 16, /* IsFloat */ true) &&
+!Context.getTargetInfo().hasFeature("experimental-zvfh")) {
+  Diag(Loc, diag::err_riscv_type_requires_extension, FD)
+  << Ty << "zvfh";
+}
+
 // Don't allow SVE types in functions without a SVE target.
 if (Ty->isSVESizelessBuiltinType() && FD && FD->hasBody()) {
   llvm::StringMap CallerFeatureMap;

diff  --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp 
b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
index fedc314f2965..8b82740da14d 100644
--- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -171,7 +171,6 @@ void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
   const TargetInfo  = Context.getTargetInfo();
   bool HasVectorFloat32 = TI.hasFeature("zve32f");
   bool HasVectorFloat64 = TI.hasFeature("zve64d");
-  bool HasZvfh = TI.hasFeature("experimental-zvfh");
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
 
@@ -223,9 +222,6 @@ void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
 continue;
 
   // Check requirement.
-  if (BaseType == BasicType::Float16 && !HasZvfh)
-continue;
-
   if (BaseType == BasicType::Float32 && !HasVectorFloat32)
 continue;
 

diff  --git a/clang/test/Sema/riscv-vector-float16-check.c 
b/clang/test/Sema/riscv-vector-float16-check.c
new file mode 100644
index ..48959254d2ad
--- /dev/null
+++ 

[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-13 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 accepted this revision.
jrtc27 added a comment.
This revision is now accepted and ready to land.

Personally happy with the concept then, seems consistent and overall helpful, 
just some nits




Comment at: llvm/lib/Target/RISCV/RISCVFeatures.td:83-86
+   "'zifencei' (ifence)">;
+def HasStdExtZifencei : Predicate<"Subtarget->hasStdExtZifencei()">,
+   AssemblerPredicate<(all_of 
FeatureStdExtZifencei),
+   "'Zifencei' (ifence)">;

s/ifence/fence.i/ (or Instruction Fence if you want words) for both these



Comment at: llvm/test/CodeGen/RISCV/attributes.ll:103-104
+; RUN: llc -mtriple=riscv64 -mattr=+zicsr %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZICSR %s
+; RUN: llc -mtriple=riscv64 -mattr=+zifencei %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZIFENCEI %s
+
 





Comment at: llvm/test/CodeGen/RISCV/attributes.ll:153-154
+; RV32ZICSR: .attribute 5, "rv32i2p0_zicsr2p0"
+; RV32ZIFENCEI: .attribute 5, "rv32i2p0_zifencei2p0"
+
 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143953

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


[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-13 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

In D143953#4124649 , @jrtc27 wrote:

> In D143953#4124636 , @reames wrote:
>
>> @jrtc27 Not sure if this changes your take, but I realized the variant being 
>> introduced is maybe much less interesting than I'd first thought.  We 
>> generally make no effort to make sure an extension was defined in the spec 
>> version corresponding to our base revision.  Given that, we have a bunch of 
>> cases where we allow I2.0 + some random extension.  Given that, this one 
>> stops looking all that interesting.  It doesn't actually set much precedent 
>> - because we already did that, a long time ago.
>>
>> If you agree with that framing, I'll rework the description.
>
> Hm, do we allow M + Zmmul? If so then I guess I can get behind that view.



  $ ~/llvm-dev/build/bin/clang -target riscv64 -march=rv64g_zmmul 
vector_add_i32.c -S
  $ cat vector_add_i32.s 
.text
.attribute  4, 16
.attribute  5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_zmmul1p0"

vector_add_i32.c is a random C file; contents are uninteresting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143953

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


[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-13 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D143953#4124636 , @reames wrote:

> @jrtc27 Not sure if this changes your take, but I realized the variant being 
> introduced is maybe much less interesting than I'd first thought.  We 
> generally make no effort to make sure an extension was defined in the spec 
> version corresponding to our base revision.  Given that, we have a bunch of 
> cases where we allow I2.0 + some random extension.  Given that, this one 
> stops looking all that interesting.  It doesn't actually set much precedent - 
> because we already did that, a long time ago.
>
> If you agree with that framing, I'll rework the description.

Hm, do we allow M + Zmmul? If so then I guess I can get behind that view.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143953

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


[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-13 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

@jrtc27 Not sure if this changes your take, but I realized the variant being 
introduced is maybe much less interesting than I'd first thought.  We generally 
make no effort to make sure an extension was defined in the spec version 
corresponding to our base revision.  Given that, we have a bunch of cases where 
we allow I2.0 + some random extension.  Given that, this one stops looking all 
that interesting.  It doesn't actually set much precedent - because we already 
did that, a long time ago.

If you agree with that framing, I'll rework the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143953

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


[PATCH] D143877: [NFC] [clang] Forward forwarding reference

2023-02-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 497146.
ccotter added a comment.

- Add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143877

Files:
  clang/include/clang/AST/IgnoreExpr.h
  clang/unittests/AST/ASTExprTest.cpp
  clang/unittests/AST/CMakeLists.txt


Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -7,6 +7,7 @@
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
+  ASTExprTest.cpp
   ASTImporterFixtures.cpp
   ASTImporterTest.cpp
   ASTImporterObjCTest.cpp
Index: clang/unittests/AST/ASTExprTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/ASTExprTest.cpp
@@ -0,0 +1,58 @@
+//===- unittests/AST/ASTExprTest.cpp --- AST Expr tests 
---===//
+//
+// 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 contains tests for AST Expr related methods.
+//
+//===--===//
+
+#include "ASTPrint.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/IgnoreExpr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+TEST(ASTExpr, IgnoreExprCallbackForwarded) {
+  constexpr char Code[] = "";
+  auto AST = tooling::buildASTFromCodeWithArgs(Code, /*Args=*/{"-std=c++20"});
+  ASTContext  = AST->getASTContext();
+
+  auto createIntLiteral = [&](uint32_t Value) -> IntegerLiteral * {
+const int numBits = 32;
+return IntegerLiteral::Create(Ctx, llvm::APInt(numBits, Value),
+  Ctx.UnsignedIntTy, {});
+  };
+
+  struct IgnoreParens {
+Expr *operator()(Expr *E) & { return nullptr; }
+Expr *operator()(Expr *E) && {
+  if (auto *PE = dyn_cast(E)) {
+return PE->getSubExpr();
+  }
+  return E;
+}
+  };
+
+  {
+auto *IntExpr = createIntLiteral(10);
+ParenExpr *PE =
+new (Ctx) ParenExpr(SourceLocation{}, SourceLocation{}, IntExpr);
+EXPECT_EQ(IntExpr, IgnoreExprNodes(PE, IgnoreParens{}));
+  }
+
+  {
+IgnoreParens CB{};
+auto *IntExpr = createIntLiteral(10);
+ParenExpr *PE =
+new (Ctx) ParenExpr(SourceLocation{}, SourceLocation{}, IntExpr);
+EXPECT_EQ(nullptr, IgnoreExprNodes(PE, CB));
+  }
+}
Index: clang/include/clang/AST/IgnoreExpr.h
===
--- clang/include/clang/AST/IgnoreExpr.h
+++ clang/include/clang/AST/IgnoreExpr.h
@@ -23,7 +23,8 @@
 inline Expr *IgnoreExprNodesImpl(Expr *E) { return E; }
 template 
 Expr *IgnoreExprNodesImpl(Expr *E, FnTy &, FnTys &&... Fns) {
-  return IgnoreExprNodesImpl(Fn(E), std::forward(Fns)...);
+  return IgnoreExprNodesImpl(std::forward(Fn)(E),
+ std::forward(Fns)...);
 }
 } // namespace detail
 


Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -7,6 +7,7 @@
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
+  ASTExprTest.cpp
   ASTImporterFixtures.cpp
   ASTImporterTest.cpp
   ASTImporterObjCTest.cpp
Index: clang/unittests/AST/ASTExprTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/ASTExprTest.cpp
@@ -0,0 +1,58 @@
+//===- unittests/AST/ASTExprTest.cpp --- AST Expr tests ---===//
+//
+// 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 contains tests for AST Expr related methods.
+//
+//===--===//
+
+#include "ASTPrint.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/IgnoreExpr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+TEST(ASTExpr, IgnoreExprCallbackForwarded) {
+  constexpr char Code[] = "";
+  auto AST = tooling::buildASTFromCodeWithArgs(Code, /*Args=*/{"-std=c++20"});
+  ASTContext  = AST->getASTContext();
+
+  auto createIntLiteral = [&](uint32_t Value) -> IntegerLiteral * {
+const int numBits = 32;
+return IntegerLiteral::Create(Ctx, 

[PATCH] D140123: [TLS] Clamp the alignment of TLS global variables if required by the target

2023-02-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

There are subsections for individual flags.  Maybe we could mess with the 
markup to make that a bit more clear...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140123

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


[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-13 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

I'm fine with this approach but I think they should be filtered out of the ELF 
attributes, maybe also preprocessor macros? That is, treating them as a 
redundant no-op in the driver rather than like a true extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143953

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


[PATCH] D143921: [debug-info][codegen] Prevent creation of self-referential SP node

2023-02-13 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

In D143921#4123218 , @fdeazeve wrote:

> Any testing suggestions here? I can use what we have on GH (cpp -> codegen 
> test), but I'm not sure if there's a finer grained test we could use.

I was thinking of a very small IR test similar to 
`llvm/test/Verifier/disubprogram-name-match-only.ll`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143921

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


[PATCH] D143960: [Fuchsia] Set /winsysroot in windows runtimes linker flags

2023-02-13 Thread Haowei Wu via Phabricator via cfe-commits
haowei created this revision.
haowei added a reviewer: phosek.
Herald added a subscriber: abrachet.
Herald added a project: All.
haowei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch sets '/winsysroot' flag when building Windows runtimes so we don't 
have to explicitly set Windows library search paths.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143960

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -88,14 +88,13 @@
   ${LLVM_WINSYSROOT})
 string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
 set(WINDOWS_LINK_FLAGS
-/vfsoverlay:${LLVM_VFSOVERLAY}
-# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
-# so we have to manually set the libpath. We use clang-cl driver if we 
can
-# and remove these libpath flags.
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+  # TODO: lld-link has a bug that it cannot infer the machine type
+  # correctly when /winsysroot is set while Windows libraries search paths
+  # are not explicitly defined.
+  # Explicitly set the machine type for now.
+  /machine:X64
+  /vfsoverlay:${LLVM_VFSOVERLAY}
+  /winsysroot:${LLVM_WINSYSROOT})
 string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
   endif()
 


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -88,14 +88,13 @@
   ${LLVM_WINSYSROOT})
 string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
 set(WINDOWS_LINK_FLAGS
-/vfsoverlay:${LLVM_VFSOVERLAY}
-# TODO: On Windows, linker is invoked by cmake instead of the clang-cl driver,
-# so we have to manually set the libpath. We use clang-cl driver if we can
-# and remove these libpath flags.
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+  # TODO: lld-link has a bug that it cannot infer the machine type
+  # correctly when /winsysroot is set while Windows libraries search paths
+  # are not explicitly defined.
+  # Explicitly set the machine type for now.
+  /machine:X64
+  /vfsoverlay:${LLVM_VFSOVERLAY}
+  /winsysroot:${LLVM_WINSYSROOT})
 string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
   endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140123: [TLS] Clamp the alignment of TLS global variables if required by the target

2023-02-13 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp added a comment.

In D140123#4124512 , @efriedma wrote:

>> no separate section for module flags
>
> https://llvm.org/docs/LangRef.html#module-flags-metadata ?

That seems to be the description of the metadata for module flags, not the 
documentation of the flags themselves.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140123

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


[PATCH] D143794: [Fuchsia] Add FUCHSIA_ENABLE_LLDB option.

2023-02-13 Thread Daniel Thornburgh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7bc9dc26bc9b: [Fuchsia] Add FUCHSIA_ENABLE_LLDB option. 
(authored by mysterymath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143794

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -4,7 +4,7 @@
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(LLVM_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly" CACHE 
STRING "")
+set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -321,7 +321,7 @@
   scan-build-py
   CACHE STRING "")
 
-set(LLVM_DISTRIBUTION_COMPONENTS
+set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld
   clang-apply-replacements
@@ -336,5 +336,13 @@
   find-all-symbols
   builtins
   runtimes
-  ${LLVM_TOOLCHAIN_TOOLS}
-  CACHE STRING "")
+  ${LLVM_TOOLCHAIN_TOOLS})
+
+set(FUCHSIA_ENABLE_LLDB OFF CACHE BOOL "Enable LLDB")
+if(FUCHSIA_ENABLE_LLDB)
+  list(APPEND _FUCHSIA_ENABLE_PROJECTS "lldb")
+  list(APPEND _FUCHSIA_DISTRIBUTION_COMPONENTS "lldb")
+endif()
+
+set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "")
+set(LLVM_DISTRIBUTION_COMPONENTS ${_FUCHSIA_DISTRIBUTION_COMPONENTS} CACHE 
STRING "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -4,7 +4,7 @@
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(LLVM_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly" CACHE STRING "")
+set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -321,7 +321,7 @@
   scan-build-py
   CACHE STRING "")
 
-set(LLVM_DISTRIBUTION_COMPONENTS
+set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld
   clang-apply-replacements
@@ -336,5 +336,13 @@
   find-all-symbols
   builtins
   runtimes
-  ${LLVM_TOOLCHAIN_TOOLS}
-  CACHE STRING "")
+  ${LLVM_TOOLCHAIN_TOOLS})
+
+set(FUCHSIA_ENABLE_LLDB OFF CACHE BOOL "Enable LLDB")
+if(FUCHSIA_ENABLE_LLDB)
+  list(APPEND _FUCHSIA_ENABLE_PROJECTS "lldb")
+  list(APPEND _FUCHSIA_DISTRIBUTION_COMPONENTS "lldb")
+endif()
+
+set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "")
+set(LLVM_DISTRIBUTION_COMPONENTS ${_FUCHSIA_DISTRIBUTION_COMPONENTS} CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7bc9dc2 - [Fuchsia] Add FUCHSIA_ENABLE_LLDB option.

2023-02-13 Thread Daniel Thornburgh via cfe-commits

Author: Daniel Thornburgh
Date: 2023-02-13T15:49:45-08:00
New Revision: 7bc9dc26bc9beb159547f7160d852543bc52

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

LOG: [Fuchsia] Add FUCHSIA_ENABLE_LLDB option.

This CMake option builds/installs LLDB as part of the Fuchsia toolchain.
Once this is better supported, the effects of this will be inlined into
the toolchain cache file.

Reviewed By: phosek

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4d2be0b47d1f1..5a9681a7cbae0 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -4,7 +4,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(LLVM_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly" CACHE 
STRING "")
+set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -321,7 +321,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   scan-build-py
   CACHE STRING "")
 
-set(LLVM_DISTRIBUTION_COMPONENTS
+set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld
   clang-apply-replacements
@@ -336,5 +336,13 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   find-all-symbols
   builtins
   runtimes
-  ${LLVM_TOOLCHAIN_TOOLS}
-  CACHE STRING "")
+  ${LLVM_TOOLCHAIN_TOOLS})
+
+set(FUCHSIA_ENABLE_LLDB OFF CACHE BOOL "Enable LLDB")
+if(FUCHSIA_ENABLE_LLDB)
+  list(APPEND _FUCHSIA_ENABLE_PROJECTS "lldb")
+  list(APPEND _FUCHSIA_DISTRIBUTION_COMPONENTS "lldb")
+endif()
+
+set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "")
+set(LLVM_DISTRIBUTION_COMPONENTS ${_FUCHSIA_DISTRIBUTION_COMPONENTS} CACHE 
STRING "")



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


[PATCH] D140123: [TLS] Clamp the alignment of TLS global variables if required by the target

2023-02-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> no separate section for module flags

https://llvm.org/docs/LangRef.html#module-flags-metadata ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140123

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


[PATCH] D143877: [NFC] [clang] Forward forwarding reference

2023-02-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

Realistically, I'm not sure if this change is all that valuable aside from 
abiding by the CppCoreGuidelines from the readability and consistency 
standpoint. The only impact this change would have that I can think of is 
allowing an object with an `&&` (or other combination) qualified `operator()` 
that would be picked up by this change, which doesn't seem likely of a use case 
for this function. I'll try to add a small test that covers this and leave it 
to the maintainers whether this is a worthy change :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143877

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


[PATCH] D140123: [TLS] Clamp the alignment of TLS global variables if required by the target

2023-02-13 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp added a comment.

In D140123#4123625 , @efriedma wrote:

> In D140123#4113536 , @efriedma 
> wrote:
>
>> Missing LangRef change?
>
> Ping?

Added a LangRef entry with 776b7499ea813c06b 
. There 
seems to be no separate section for module flags, so I added it to the entry on 
global variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140123

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


[PATCH] D143849: [Clang][OpenCL] Allow pointers in structs as kernel arguments from 2.0

2023-02-13 Thread Ayal Zaks via Phabricator via cfe-commits
Ayal added inline comments.



Comment at: clang/test/SemaOpenCL/invalid-kernel-parameters.cl:90
 
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
 typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' 
declared here}}

yaxunl wrote:
> we should not limit the tests to CL1.2. We should test them with 2.0 to make 
> sure there is no diagnostics.
> 
> To differentiate between 1.2 and 2.0 you can use -verify=ocl12 and 
> -verify=ocl20.
> 
> same as below
Using -verify=ocl12 and -verify=ocl20 should probably be done separately as an 
NFC patch as it involves many changes IIUC.

The expect's were placed under #ifdef instead (and only them), following e.g. 
existing lines 8-12.


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

https://reviews.llvm.org/D143849

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


[PATCH] D143849: [Clang][OpenCL] Allow pointers in structs as kernel arguments from 2.0

2023-02-13 Thread Ayal Zaks via Phabricator via cfe-commits
Ayal updated this revision to Diff 497128.
Ayal added a comment.

Updated version merges the `if`'s and checks tests for both 1.2 and 2.0.


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

https://reviews.llvm.org/D143849

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/invalid-kernel-parameters.cl


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -87,15 +87,20 @@
 
 
 
-typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' 
declared here}}
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
+// expected-note@+4{{within field of type 'FooImage2D' declared here}}
+// expected-note@+8{{field of illegal type '__read_only image2d_t' declared 
here}}
+// expected-error@+10{{struct kernel parameters may not contain pointers}}
+#endif
+typedef struct FooImage2D
 {
   // TODO: Clean up needed - we don't really need to check for image, event, 
etc
   // as a note here any longer.
   // They are diagnosed as an error for all struct fields (OpenCL v1.2 
s6.9b,r).
-  image2d_t imageField; // expected-note{{field of illegal type '__read_only 
image2d_t' declared here}} expected-error{{the '__read_only image2d_t' type 
cannot be used to declare a structure or union field}}
+  image2d_t imageField; // expected-error{{the '__read_only image2d_t' type 
cannot be used to declare a structure or union field}}
 } FooImage2D;
 
-kernel void image_in_struct_arg(FooImage2D arg) { } // expected-error{{struct 
kernel parameters may not contain pointers}}
+kernel void image_in_struct_arg(FooImage2D arg) { }
 
 typedef struct Foo // expected-note{{within field of type 'Foo' declared here}}
 {
@@ -104,6 +109,18 @@
 
 kernel void pointer_in_struct_arg(Foo arg) { } // expected-error{{struct 
kernel parameters may not contain pointers}}
 
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
+// expected-note@+4{{within field of type 'FooGlobal' declared here}}
+// expected-note@+5{{field of illegal pointer type '__global int *' declared 
here}}
+// expected-error@+7{{struct kernel parameters may not contain pointers}}
+#endif
+typedef struct FooGlobal 
+{
+  global int* ptrField;
+} FooGlobal;
+
+kernel void global_pointer_in_struct_arg(FooGlobal arg) { }
+
 typedef union FooUnion // expected-note{{within field of type 'FooUnion' 
declared here}}
 {
   int* ptrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9489,13 +9489,18 @@
   // OpenCL v1.2 s6.9.p:
   // Arguments to kernel functions that are declared to be a struct or 
union
   // do not allow OpenCL objects to be passed as elements of the struct or
-  // union.
-  if (ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam ||
-  ParamType == InvalidAddrSpacePtrKernelParam) {
+  // union. This restriction was lifted in OpenCL v2.0 with the 
introduction
+  // of SVM.
+  if (ParamType == InvalidAddrSpacePtrKernelParam ||
+  ((ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam) &&
+   S.getLangOpts().getOpenCLCompatibleVersion() <= 120)) {
 S.Diag(Param->getLocation(),
diag::err_record_with_pointers_kernel_param)
   << PT->isUnionType()
   << PT;
+  } else if (ParamType == PtrKernelParam || ParamType == 
PtrPtrKernelParam) {
+// and OpenCL version is at-least 2.0, so these types are allowed. 
+continue;
   } else {
 S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
   }


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -87,15 +87,20 @@
 
 
 
-typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' declared here}}
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
+// expected-note@+4{{within field of type 'FooImage2D' declared here}}
+// expected-note@+8{{field of illegal type '__read_only image2d_t' declared here}}
+// expected-error@+10{{struct kernel parameters may not contain pointers}}
+#endif
+typedef struct FooImage2D
 {
   // TODO: Clean up needed - we don't really need to check for image, event, etc
   // as a note here any longer.
   // They are diagnosed as an error for all struct fields (OpenCL v1.2 s6.9b,r).
-  image2d_t imageField; // expected-note{{field of illegal type '__read_only image2d_t' declared here}} expected-error{{the '__read_only image2d_t' type cannot be used to declare a structure or union field}}
+  image2d_t imageField; // 

[PATCH] D143533: [clang] Allow gnu::aligned attribute to work with templated type alias declarations

2023-02-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:2154
+  if (uint64_t Result = SubstTypeVisitor(Ctx, SubType->getReplacementType())
+.TryEval(Attr->getAlignmentExpr())) {
+TI.Align = Result;

I don't think this approach is going to work out well. There are many cases 
this gets wrong, fixing them would require reinventing template substitution 
here, and generally we shouldn't be doing this substitution as part of 
alignment computation at all -- we should have `TreeTransform` produce the 
right alignment value during template instantiation and just pull it back out 
of the `Type` here. We can't really use the same approach as we do for 
`TypedefDecl`s, though, because we don't instantiate a `TypeAliasDecl` for each 
use of a `TypeAliasTemplateDecl`, so there's nowhere to hang an instantiated 
attribute. But the handling for `TypedefType`s is also fairly painful, so I 
think we should be considering an approach that makes both of them more 
elegant. Here's what I suggest:

- We add a new sugar-only `Type` subclass that represents an alignment 
attribute. Maybe we can model this as an `AttributedType` for the 
`AlignedAttr`, or maybe we create a new kind of type node.
- We translate `AlignedAttr`s on typedef and type alias declarations into this 
new kind of `Type` wrapping the declared type.
- We make `getTypeInfoImpl` special-case that type sugar node instead of 
special-casing `TypedefType` sugar.
- We make sure that `TreeTransform` properly instantiates the new node, in 
particular performing substitution within the argument.



Comment at: clang/lib/AST/ASTContext.cpp:2577-2583
+  case Type::SubstTemplateTypeParm: {
+const auto *SubType = cast(T);
+auto TI = getTypeInfo(SubType->getReplacementType().getTypePtr());
+if (MaybeGetAlignForTemplateAlias(TI, SubType))
+  TI.AlignRequirement = AlignRequirementKind::RequiredByTypedef;
+return TI;
+  }

Looking for a `SubstTemplateTypeParm` will mean that you don't handle cases 
like:
```
template using AlignedChar [[gnu::aligned(N)]] = char;
```
Instead, it would be better to add the special treatment to 
`TemplateSpecializationType`s for which `isTypeAlias` is `true`... but see my 
other comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143533

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


[PATCH] D143501: [clang][DebugInfo] lldb: Use preferred name's type when emitting DW_AT_names

2023-02-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> I think /maybe/ we had some design principle that DWARF features wouldn't be 
> solely controlled by debugger tuning, the tuning only indicates defaults but 
> tehy can be controlled by flags? Not sure if I'm remembering that quite 
> right, though - maybe @probinson remembers more of that?

I guess maybe not - at least there's a handful of debugger tuning checks in 
similar code around here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143501

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


[PATCH] D143877: [NFC] [clang] Forward forwarding reference

2023-02-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

any chance this is testable, maybe in a unit test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143877

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


[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-13 Thread Philip Reames via Phabricator via cfe-commits
reames created this revision.
reames added reviewers: asb, frasercrmck, kito-cheng, jrtc27, craig.topper.
Herald added subscribers: luke, VincentWu, vkmr, jdoerfert, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, 
shiva0217, niosHD, sabuasal, bollu, simoncook, johnrusso, rbar, hiraditya, 
kristof.beyls, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added projects: clang, LLVM.

This change adds the definition of the two extensions, but does not either a) 
make any instruction conditional on them or b) enabled the extensions by 
default.  (The *instructions* do remain enabled by default per ISA version 2.0 
which is our current default.)

This is meant to be a building block towards something like 
https://reviews.llvm.org/D141666, and in the meantime, address one of the most 
surprising of the current user experience warts.  The current behavior of 
rejecting the extensions at the command line despite emitting code which 
appears to use them is surprising to anyone not deeply versed in the details of 
this situation.

Between versions 2.0 and 2.1 of the base I specification, a backwards 
incompatible change was made to remove selected instructions and CSRs from the 
base ISA. These instructions were grouped into a set of new extensions (these), 
but were no longer required by the base ISA. This change is described in 
“Preface to Document Version 20190608-Base-Ratified” from the specification 
document.

As LLVM currently implements only version 2.0 of the base specification, 
accepting these extensions at the command line introduces a configuration which 
doesn't actually match any spec version.  It's a pretty harmless variant since 
the 2.0 extension definitions, to my knowledge, exactly match the text from the 
2.0 I text before they were moved into standalone extensions in 2.1 of I.  (The 
version numbering in that sentence is a tad confusing to say the least.  
Hopefully I got it right.)

If we decide we don't want to accept this variant, the other obvious near term 
option would be to detect and error with a more helpful error message.

Worth noting is that we're setting precedent here.  There's at least one other 
case I know of which is analogous (counters), and others may come up in the 
future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143953

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -193,3 +193,9 @@
 
 .attribute arch, "rv32iztso0p1"
 # CHECK: attribute  5, "rv32i2p0_ztso0p1"
+
+.attribute arch, "rv32izicsr2p0"
+# CHECK: attribute  5, "rv32i2p0_zicsr2p0"
+
+.attribute arch, "rv32izifencei2p0"
+# CHECK: attribute  5, "rv32i2p0_zifencei2p0"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -45,6 +45,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCB %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCD %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcf %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCF %s
+; RUN: llc -mtriple=riscv32 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV32ZICSR %s
+; RUN: llc -mtriple=riscv32 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV32ZIFENCEI %s
 
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s
@@ -97,6 +99,9 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zca %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCB %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCD %s
+; RUN: llc -mtriple=riscv64 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV64ZICSR %s
+; RUN: llc -mtriple=riscv64 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV64ZIFENCEI %s
+
 
 ; CHECK: .attribute 4, 16
 
@@ -144,6 +149,9 @@
 ; RV32ZCB: .attribute 5, "rv32i2p0_zca1p0_zcb1p0"
 ; RV32ZCD: .attribute 5, "rv32i2p0_zcd1p0"
 ; RV32ZCF: .attribute 5, "rv32i2p0_zcf1p0"
+; RV32ZICSR: .attribute 5, "rv32i2p0_zicsr2p0"
+; RV32ZIFENCEI: .attribute 5, "rv32i2p0_zifencei2p0"
+
 
 ; RV64M: .attribute 5, 

[PATCH] D143906: [include-cleaner] Better support ambiguous std symbols

2023-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp:174
const PragmaIncludes *PI) {
+  if (auto Headers = specialStandardSymbols(S); !Headers.empty())
+return Headers;

kadircet wrote:
> rather than doing this here and bailing out early, i think we should just 
> augment the `Headers` below, after `locateSymbol` and `findHeaders` is run.
> 
> that way we'll make sure rest of the logic applies in the future without 
> special casing (e.g. we've some fixmes for treating implementation locations 
> for stdlib symbols as providers, in such a scenario this early exits would 
> create non-uniformity).
> it also implies we'll need to think about hints to attach here, which seems 
> consistent with rest of the logic again (as we still assign hints to headers 
> derived from stdlib recognizer).
> 
> so what about an alternative with a signature like: 
> `llvm::SmallVector> headersForSpecialSymbols(S, SM, PI);` then 
> we can just initialize Headers with a call to it?
> i think we should just augment the Headers below, after locateSymbol and 
> findHeaders is run. 

I'm not sure about it. Looks like this is subtle, it creates discrepancies for 
standard symbols, these special std symbols will have the underlying header as 
alternative while other normal std-recognizer symbols not. I think it would be 
better to be consistent for all std symbols.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143906

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


[PATCH] D143906: [include-cleaner] Better support ambiguous std symbols

2023-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 497110.
hokein marked 3 inline comments as done.
hokein added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143906

Files:
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -278,25 +278,31 @@
 
 class HeadersForSymbolTest : public FindHeadersTest {
 protected:
-  llvm::SmallVector headersForFoo() {
+  llvm::SmallVector headersFor(llvm::StringRef Name) {
 struct Visitor : public RecursiveASTVisitor {
   const NamedDecl *Out = nullptr;
+  llvm::StringRef Name;
+  Visitor(llvm::StringRef Name) : Name(Name) {}
   bool VisitNamedDecl(const NamedDecl *ND) {
-if (ND->getName() == "foo") {
+if (auto *TD = ND->getDescribedTemplate())
+  ND = TD;
+
+if (ND->getName() == Name) {
   EXPECT_TRUE(Out == nullptr || Out == ND->getCanonicalDecl())
-  << "Found multiple matches for foo.";
+  << "Found multiple matches for " << Name << ".";
   Out = cast(ND->getCanonicalDecl());
 }
 return true;
   }
 };
-Visitor V;
+Visitor V(Name);
 V.TraverseDecl(AST->context().getTranslationUnitDecl());
 if (!V.Out)
-  ADD_FAILURE() << "Couldn't find any decls named foo.";
+  ADD_FAILURE() << "Couldn't find any decls named " << Name << ".";
 assert(V.Out);
 return headersForSymbol(*V.Out, AST->sourceManager(), );
   }
+  llvm::SmallVector headersForFoo() { return headersFor("foo"); }
 };
 
 TEST_F(HeadersForSymbolTest, Deduplicates) {
@@ -430,5 +436,55 @@
   EXPECT_THAT(headersForFoo(), ElementsAre(Header(StringRef("\"public.h\"")),
physicalHeader("foo.h")));
 }
+
+TEST_F(HeadersForSymbolTest, AmbiguousStdSymbols) {
+  struct {
+llvm::StringRef Code;
+llvm::StringRef Name;
+
+llvm::StringRef ExpectedHeader;
+  } TestCases[] = {
+  {
+  R"cpp(
+namespace std {
+ template 
+ constexpr OutputIt move(InputIt first, InputIt last, OutputIt dest);
+})cpp",
+  "move",
+  "",
+  },
+  {
+  R"cpp(
+namespace std {
+  template constexpr T move(T&& t) noexcept;
+})cpp",
+  "move",
+  "",
+  },
+  {
+  R"cpp(
+namespace std {
+  template
+  ForwardIt remove(ForwardIt first, ForwardIt last, const T& value);
+})cpp",
+  "remove",
+  "",
+  },
+  {
+  "namespace std { int remove(const char*); }",
+  "remove",
+  "",
+  },
+  };
+
+  for (const auto  : TestCases) {
+Inputs.Code = T.Code;
+buildAST();
+EXPECT_THAT(headersFor(T.Name),
+UnorderedElementsAre(
+Header(*tooling::stdlib::Header::named(T.ExpectedHeader;
+  }
+}
+
 } // namespace
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
===
--- clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -82,16 +82,63 @@
   llvm_unreachable("unhandled Symbol kind!");
 }
 
+Hints isPublicHeader(const FileEntry *FE, const PragmaIncludes *PI) {
+  return (PI->isPrivate(FE) || !PI->isSelfContained(FE)) ? Hints::None
+ : Hints::PublicHeader;
+}
+llvm::SmallVector>
+hintedHeadersForStdHeaders(llvm::ArrayRef Headers,
+   const SourceManager , const PragmaIncludes *PI) {
+  llvm::SmallVector> Results;
+  for (const auto  : Headers) {
+Results.emplace_back(H, Hints::PublicHeader);
+for (const auto *Export : PI->getExporters(H, SM.getFileManager()))
+  Results.emplace_back(Header(Export), isPublicHeader(Export, PI));
+  }
+  // StandardLibrary returns headers in preference order, so only mark the
+  // first.
+  if (!Results.empty())
+Results.front().Hint |= Hints::PreferredHeader;
+  return Results;
+}
+
+// Special-case the ambiguous standard library symbols (e.g. std::move) which
+// are not supported by the tooling stdlib lib.
+llvm::SmallVector>
+headersForSpecialSymbol(const Symbol , const SourceManager ,
+const PragmaIncludes *PI) {
+  if (S.kind() != Symbol::Declaration || !S.declaration().isInStdNamespace())
+return {};
+
+  const auto *FD = S.declaration().getAsFunction();
+  if (!FD)
+return {};
+
+  

[PATCH] D143233: [Clang][CodeGen] Fix this argument type for certain destructors

2023-02-13 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143233

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


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

2023-02-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:326
+unsigned Val;
+bool IsRV64;
+  };

Is this IsRV64 field used?



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:331
+unsigned Val;
+bool IsRV64;
+  };

Is this IsRV64 field used?



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1028
+  // be called after checking isFRMArg.
+  RISCVFPRndMode::RoundingMode getRoundingMode() const {
+// isFRMArg has validated the operand, meaning this cast is safe.

`getRoundingMode` shouldn't be in this patch



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:2120
+StringRef EndName = getLexer().getTok().getIdentifier();
+// FixMe: the register mapping and checks of EABI is wrong
+if (matchRegisterNameHelper(/*IsEABI*/ false, RegEnd, EndName))

FixMe -> FIXME



Comment at: llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp:451
+  const void *Decoder) {
+  // Sign-extend the number in the bottom N bits of Imm
+  if (Imm <= 3)

This comment looks copy/pasted from somewhere else?



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp:224
+else if (SlistEncode > 5 && SlistEncode <= 14)
+  OS << "-s" + std::to_string(SlistEncode - 5);
+  }

Does this work? 

```
OS << "-s" << (SlistEncode - 5);
```



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:492
+  RA_S0_S11,
+  RA_S0_S10, // This is for error checking.
+};

Should use this define instead writing 16 in several places? Or maybe rename 
this so it's obviously invalid?



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp:200
+  if (Spimm < Base || Spimm > Base + 48)
+llvm_unreachable("Incorrect spimm");
+  if (Opcode == RISCV::CM_PUSH) {

Combine the `if` into an `assert`?



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp:97
+private:
+  FeatureBitset computeAvailableFeatures(const FeatureBitset ) const;
+  void

What are these functions?



Comment at: llvm/lib/Target/RISCV/RISCVFeatures.td:335
+def HasStdExtZcmp : Predicate<"Subtarget->hasStdExtZcmp() && 
!Subtarget->hasStdExtC()">,
+   AssemblerPredicate<(all_of FeatureExtZcmp, (not 
FeatureStdExtC)),
+   "'Zcmp' (sequenced instuctions for code-size 
reduction.)">;

Line `AssemblerPredicate` up with the `"Subtarget` on the previous line.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td:70
+  return false;
+return  isShiftedUInt<5, 4>(Imm);
+  }];

Extra space before `isShiftedUInt`



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td:85
 
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVZcArith_rr funct6,bits<2> funct2, bits<2> opcode, string 
opcodestr>

These lines were deleted when the Zcb patch was merged.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td:260
   (C_ZEXT_H GPRC:$rs1, GPRC:$rs1)>;
-} // Predicates = [HasStdExtZcb, HasStdExtZbb]
+} // Predicates = [, HasStdExtZbb]
 

What happened here?



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.td:177
 
+// Saved Registers from s0 to s7, for C.MVA01S07 instruction in Zc extension
+def SR07 : RegisterClass<"RISCV", [XLenVT], 32, (add

Zc -> Zcmp?



Comment at: llvm/lib/Target/RISCV/RISCVSchedRocket.td:21
   let UnsupportedFeatures = [HasStdExtZbkb, HasStdExtZbkc, HasStdExtZbkx,
- HasStdExtZknd, HasStdExtZkne, HasStdExtZknh,
- HasStdExtZksed, HasStdExtZksh, HasStdExtZkr,
- HasVInstructions, HasVInstructionsI64];
+ HasStdExtZcb, HasStdExtZknd, HasStdExtZkne,
+ HasStdExtZknh, HasStdExtZksed, HasStdExtZksh,

While this is probably correct, since it says Zcb and not Zcmp, it doesn't 
belong in this patch.



Comment at: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td:18
   let CompleteModel = 0;
   let UnsupportedFeatures = [HasStdExtZbkb, HasStdExtZbkc, HasStdExtZbkx,
+ HasStdExtZcb, HasStdExtZknd, HasStdExtZkne,

Same



Comment at: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp:83
   initializeRISCVInsertVSETVLIPass(*PR);
-  initializeRISCVDAGToDAGISelPass(*PR);
 }





Comment at: llvm/test/MC/RISCV/attribute-arch.s:170
 
-.attribute arch, "rv32izihintntl0p2"
-# CHECK: attribute  5, 

[PATCH] D143233: [Clang][CodeGen] Fix this argument type for certain destructors

2023-02-13 Thread Jacob Young via Phabricator via cfe-commits
jacobly updated this revision to Diff 497097.
jacobly added a comment.

Fix bad diff update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143233

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  clang/test/CodeGenCXX/microsoft-abi-structors.cpp
  clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -53,6 +53,7 @@
 B::~B() {
   // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1B@@UAE@XZ"
   // Store initial this:
+  // CHECK:   %[[THIS:.*]] = alloca %struct.B*
   // CHECK:   %[[THIS_ADDR:.*]] = alloca %struct.B*
   // CHECK:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
   // Reload and adjust the this parameter:
@@ -90,8 +91,7 @@
   // CHECK2: %[[THIS:.*]] = load %struct.B*, %struct.B** {{.*}}
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[B_i8:.*]] = getelementptr i8, i8* %[[THIS_i8]], i32 8
-  // CHECK2: %[[B:.*]] = bitcast i8* %[[B_i8]] to %struct.B*
-  // CHECK2: call x86_thiscallcc void @"??1B@@UAE@XZ"(%struct.B* {{[^,]*}} %[[B]])
+  // CHECK2: call x86_thiscallcc void @"??1B@@UAE@XZ"(i8*{{[^,]*}} %[[B_i8]])
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[THIS_i8]], i32 8
   // CHECK2: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.VBase*
@@ -99,6 +99,7 @@
   // CHECK2: ret
 
   // CHECK2-LABEL: define linkonce_odr dso_local x86_thiscallcc noundef i8* @"??_GB@@UAEPAXI@Z"
+  // CHECK2:   store %struct.B* %{{.*}}, %struct.B** %[[THIS:.*]], align 4
   // CHECK2:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR:.*]], align 4
   // CHECK2:   %[[THIS:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
   // CHECK2:   %[[THIS_PARAM_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
@@ -195,8 +196,7 @@
 // CHECK: %[[VBENTRY:.*]] = getelementptr inbounds i32, i32* %[[VBTABLE]], i32 1
 // CHECK: %[[VBOFFSET32:.*]] = load i32, i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
-// CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.B*
+// CHECK: %[[VBASE:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
 //
 // CHECK: %[[OBJ_i8:.*]] = bitcast %struct.B* %[[OBJ]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 0
@@ -206,12 +206,12 @@
 // CHECK: %[[VBOFFSET32:.*]] = load i32, i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (%struct.B*, i32)***
-// CHECK: %[[VFTABLE:.*]] = load i8* (%struct.B*, i32)**, i8* (%struct.B*, i32)*** %[[VFPTR]]
-// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (%struct.B*, i32)*, i8* (%struct.B*, i32)** %[[VFTABLE]], i64 0
-// CHECK: %[[VFUN_VALUE:.*]] = load i8* (%struct.B*, i32)*, i8* (%struct.B*, i32)** %[[VFUN]]
+// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (i8*, i32)***
+// CHECK: %[[VFTABLE:.*]] = load i8* (i8*, i32)**, i8* (i8*, i32)*** %[[VFPTR]]
+// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (i8*, i32)*, i8* (i8*, i32)** %[[VFTABLE]], i64 0
+// CHECK: %[[VFUN_VALUE:.*]] = load i8* (i8*, i32)*, i8* (i8*, i32)** %[[VFUN]]
 //
-// CHECK: call x86_thiscallcc noundef i8* %[[VFUN_VALUE]](%struct.B* {{[^,]*}} %[[VBASE]], i32 noundef 1)
+// CHECK: call x86_thiscallcc noundef i8* %[[VFUN_VALUE]](i8* {{[^,]*}} %[[VBASE]], i32 noundef 1)
 // CHECK: ret void
 }
 
@@ -295,8 +295,9 @@
 } d;
 
 D::~D() {
-  // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1D@diamond@@UAE@XZ"(%"struct.diamond::D"*{{.*}})
+  // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1D@diamond@@UAE@XZ"(i8*{{.*}})
   // Store initial this:
+  // CHECK: %[[THIS:.*]] = alloca %"struct.diamond::D"*
   // CHECK: %[[THIS_ADDR:.*]] = alloca %"struct.diamond::D"*
   // CHECK: store %"struct.diamond::D"* %{{.*}}, %"struct.diamond::D"** %[[THIS_ADDR]], align 4
   //
@@ -310,16 +311,13 @@
   // CHECK: %[[C_i8:.*]] = getelementptr inbounds i8, i8* %[[D_i8]], i32 4
   // CHECK: %[[C:.*]] = bitcast i8* %[[C_i8]] to %"struct.diamond::C"*
   // CHECK: %[[C_i8:.*]] = bitcast %"struct.diamond::C"* %[[C]] to i8*
-  // CHECK: %[[ARG_i8:.*]] = 

[PATCH] D143806: [Clang][Test] Add llvm-lto, llvm-lto2 and llvm-profdata to the tool substitutions list

2023-02-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Seems a bit unfortunate that clang tests are using these tools, but fair enough 
- they clearly are, so suitable to include them here, I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143806

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


[PATCH] D143803: [clang][alias|ifunc]: Add a diagnostic for mangled names

2023-02-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D143803#412 , @0xdc03 wrote:

> Note that as it stands currently, this patch cannot be committed because the 
> test `clang/test/SemaCXX/externc-ifunc-resolver.cpp` fails to run. The 
> contents of the test are as follows:
>
>   // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
>   
>   extern "C" {
>   __attribute__((used)) static void *resolve_foo() { return 0; }
>   namespace NS {
>   __attribute__((used)) static void *resolve_foo() { return 0; }
>   } // namespace NS
>   
>   // FIXME: This diagnostic is pretty confusing, the issue is that the 
> existence
>   // of the two functions suppresses the 'alias' creation, and thus the ifunc
>   // resolution via the alias as well. In the future we should probably find
>   // some way to improve this diagnostic (likely by diagnosing when we decide
>   // this case suppresses alias creation).
>   __attribute__((ifunc("resolve_foo"))) void foo(); // expected-error{{ifunc 
> must point to a defined function}}
>   }
>
> The error that I get is as follows:
>
>   Command Output (stderr):
>   --
>   + : 'RUN: at line 1'
>   + /mnt/entschuldigung/LLVM/llvm-main/build-release/bin/clang -cc1 
> -internal-isystem 
> /mnt/entschuldigung/LLVM/llvm-main/build-release/lib/clang/17/include 
> -nostdsysteminc -emit-llvm-only -triple x86_64-linux-gnu -verify 
> /mnt/entschuldigung/LLVM/llvm-main/clang/test/SemaCXX/externc-ifunc-resolver.cpp
>   error: 'note' diagnostics seen but not expected:
> File 
> /mnt/entschuldigung/LLVM/llvm-main/clang/test/SemaCXX/externc-ifunc-resolver.cpp
>  Line 14: 'resolve_foo' exists as a mangled name, did you mean to use 
> '_ZL11resolve_foov'?
> File 
> /mnt/entschuldigung/LLVM/llvm-main/clang/test/SemaCXX/externc-ifunc-resolver.cpp
>  Line 14: 'resolve_foo' exists as a mangled name, did you mean to use 
> '_ZN2NSL11resolve_fooEv'?
>   2 errors generated.
>   
>   --
>
> which confuses me because an `extern "C"` block is not supposed to mangle any 
> names, right? Appreciate any inputs on this.

Looks like maybe a Clang feature, that since they're "static"/internal linkage, 
Clang decides it can still mangle them: https://godbolt.org/z/6oMfjced1 - GCC 
doesn't do this, and fails if you try to overload them, whereas clang doesn't.

That does surprise me - if only for GCC/Clang compatibility, regardless of what 
the spec says, exactly...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143803

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


[libclc] f11ab83 - libclc: remove sqrt/rsqrt from clspv SOURCES

2023-02-13 Thread Kévin Petit via cfe-commits

Author: Kévin Petit
Date: 2023-02-13T21:27:40Z
New Revision: f11ab8353f972647f276b07c24d1308859fbde0d

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

LOG: libclc: remove sqrt/rsqrt from clspv SOURCES

https://reviews.llvm.org/D134040

Patch by: Aaron Greig 

Added: 


Modified: 
libclc/clspv/lib/SOURCES

Removed: 




diff  --git a/libclc/clspv/lib/SOURCES b/libclc/clspv/lib/SOURCES
index 0466345cee027..cae33c38472be 100644
--- a/libclc/clspv/lib/SOURCES
+++ b/libclc/clspv/lib/SOURCES
@@ -18,7 +18,6 @@ math/nextafter.cl
 ../../generic/lib/math/clc_remainder.cl
 ../../generic/lib/math/clc_remquo.cl
 ../../generic/lib/math/clc_rootn.cl
-../../generic/lib/math/clc_sqrt.cl
 ../../generic/lib/math/clc_tan.cl
 ../../generic/lib/math/erf.cl
 ../../generic/lib/math/erfc.cl
@@ -41,8 +40,6 @@ math/nextafter.cl
 ../../generic/lib/math/remainder.cl
 ../../generic/lib/math/remquo.cl
 ../../generic/lib/math/rootn.cl
-../../generic/lib/math/rsqrt.cl
-../../generic/lib/math/sqrt.cl
 ../../generic/lib/math/tables.cl
 ../../generic/lib/math/tanh.cl
 ../../generic/lib/math/tgamma.cl



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


[PATCH] D143870: [clang-format] Remove all include duplicates not only those in the same block

2023-02-13 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe added a comment.

@HazardyKnusperkeks thank you for the review, I would add another option, but I 
don't know a good name. I would propose a

`boolean` `IncludeDeduplicateInAllBlocks` which defaults to zero.

First an `Include`, to keep include-sorting related options together in the 
documentation (sorted by name not by category)
`DeduplicateInAllBlocks` self explaining name.

But `IncludeDeduplication` with the enum states `IDD_SameBlock`(default) and 
IDD_ALL would also an option.
The latter has the advantage, that an expansion of this option would not 
require the adjustment of tests.

What's your preference?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143870

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


[PATCH] D143657: [Clang][RISCV] Guard vector float16 type correctly with semantic analysis

2023-02-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143657

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


[PATCH] D143691: Fix clang-formats IncludeCategory to match the documentation

2023-02-13 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe added a comment.

I've added some elaborations and justifications for the criticized changes.




Comment at: clang/lib/Format/Format.cpp:1379
   LLVMStyle.IncludeStyle.IncludeCategories = {
-  {"^\"(llvm|llvm-c|clang|clang-c)/", 2, 0, false},
-  {"^(<|\"(gtest|gmock|isl|json)/)", 3, 0, false},
-  {".*", 1, 0, false}};
+  {"^\"(llvm|llvm-c|clang|clang-c)/", 2, 2, false},
+  {"^(<|\"(gtest|gmock|isl|json)/)", 3, 3, false},

HazardyKnusperkeks wrote:
> I don't follow why this is necessary. And I don't feel comfortable with it.
This **was** required, but is not required necessarily, my last update of the 
patch made this change most likely obsolete.

But the actual reason is, that `SortPriority` is described in the documentation 
as "optional value which is defaulted to `Priority`, if absent", but it is 
neither a (std::)optional value nor it was defaulted to Priority if absent.
It was indirectly updated from **0** to `Priority` in the algorithm.

Since I moved the buggy, re-initialization of `SortPriority` to the first 
initialization:
clang/lib/Tooling/Inclusions/IncludeStyle.cpp:L20 this change must also be 
covered by the tests: All zero initializations must now be default to 
`Priority` to not change the test behavior, which is what you want.

Either by creating a Constructor without `SortPriority`, which defaults to 
Priority,
creating a factory function, or by doing this for all tests manually.


Imagine the tests would also test the interpretation of the JSON input. Then 
the tests would not require an adjustment to be semantically equal.

But since I added Priority to the sorting after **this** change, this is kind 
of irrelevant.



Comment at: clang/lib/Tooling/Inclusions/IncludeStyle.cpp:18
 IO , IncludeStyle::IncludeCategory ) {
-  IO.mapOptional("Regex", Category.Regex);
-  IO.mapOptional("Priority", Category.Priority);
-  IO.mapOptional("SortPriority", Category.SortPriority);
+  IO.mapRequired("Regex", Category.Regex);
+  IO.mapRequired("Priority", Category.Priority);

HazardyKnusperkeks wrote:
> A big no! You will break existing configurations.
Can you elaborate?
Do you mean the change from `mapOptional` to `mapRequired`?
From what I thought, this change only affects clarity (improvement), not the 
semantic:
 - the parent JSON list/array entry is already optional.
 - therefore any of them is required, but none is useful alone.
   - an empty regex, just matches nothing `=>` regex required
   - an empty Priority should default (documentation) to INT_MAX, but actually 
did not (0). 
 - Also, from the documentations view, omitting one of them was never intended.

The only effect this change will have for old configurations, is, that it 
breaks "wrong" configurations. It's like abusing undefined behav.: You can't be 
sure it works after a compiler update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143691

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


[PATCH] D143921: [debug-info][codegen] Prevent creation of self-referential SP node

2023-02-13 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/lib/IR/Verifier.cpp:1404
+CheckDI(!N.getRawDeclaration(),
+"subprogram declaration must not have a declaration field");
   }

Can you a new test for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143921

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


[PATCH] D143233: [Clang][CodeGen] Fix this argument type for certain destructors

2023-02-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

If the parameter attributes are relevant, should we change the CHECK lines in 
the tests to check for them?  At least for some of the tests.  Once we fix 
these tests to enable opaque pointer types, you won't actually be checking for 
anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143233

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


[PATCH] D143919: [Clang] Copy strictfp attribute from pattern to instantiation

2023-02-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D143919#4123712 , @sepavloff wrote:

> In D143919#4123616 , @efriedma 
> wrote:
>
>> We have code somewhere to generically copy attributes from function 
>> templates to instantiations, right?  Why do we need to explicitly copy 
>> StrictFPAttr in particular, separate from that?
>
> Could you please point me out to this code? I didn't find it.

It's the call to `InstantiateAttrs` in `InitFunctionInstantiation`.  
`InstantiateAttrs` hard-codes a list of attributes to clone, which seems like a 
bad design, but it's easy enough to imitate in your code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143919

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


[PATCH] D143870: [clang-format] Remove all include duplicates not only those in the same block

2023-02-13 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks requested changes to this revision.
HazardyKnusperkeks added a comment.
This revision now requires changes to proceed.

I can see that this is maybe useful, but that have to be behind a new option, 
which is turned off by default. And a big no to changing the existing tests, 
you may add new stuff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143870

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


[PATCH] D143691: Fix clang-formats IncludeCategory to match the documentation

2023-02-13 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks requested changes to this revision.
HazardyKnusperkeks added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Format/Format.cpp:1379
   LLVMStyle.IncludeStyle.IncludeCategories = {
-  {"^\"(llvm|llvm-c|clang|clang-c)/", 2, 0, false},
-  {"^(<|\"(gtest|gmock|isl|json)/)", 3, 0, false},
-  {".*", 1, 0, false}};
+  {"^\"(llvm|llvm-c|clang|clang-c)/", 2, 2, false},
+  {"^(<|\"(gtest|gmock|isl|json)/)", 3, 3, false},

I don't follow why this is necessary. And I don't feel comfortable with it.



Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:219-221
 if (CategoryRegexs[i].match(IncludeName)) {
-  Ret = Style.IncludeCategories[i].Priority;
-  break;
+  return Style.IncludeCategories[i].Priority;
 }

Drop the braces (now).



Comment at: clang/lib/Tooling/Inclusions/IncludeStyle.cpp:18
 IO , IncludeStyle::IncludeCategory ) {
-  IO.mapOptional("Regex", Category.Regex);
-  IO.mapOptional("Priority", Category.Priority);
-  IO.mapOptional("SortPriority", Category.SortPriority);
+  IO.mapRequired("Regex", Category.Regex);
+  IO.mapRequired("Priority", Category.Priority);

A big no! You will break existing configurations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143691

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


[PATCH] D143794: [Fuchsia] Add FUCHSIA_ENABLE_LLDB option.

2023-02-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143794

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


[PATCH] D143128: [-Wunsafe-buffer-usage][WIP] Fix-Its transforming `[any]` to `(DRE.data() + any)`

2023-02-13 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 497057.
ziqingluo-90 added a comment.

Rebased.


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

https://reviews.llvm.org/D143128

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
  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
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+int f(unsigned long, void *);
+
+[[clang::unsafe_buffer_usage]]
+int unsafe_f(unsigned long, void *);
+
+void address_to_integer(int x) {
+  int * p = new int[10];
+  unsigned long n = (unsigned long) [5];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:42}:"(p.data() + 5)"
+  unsigned long m = (unsigned long) [x];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:42}:"(p.data() + x)"
+}
+
+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}:"(p.data() + 5)"
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:33}:"(p.data() + x)"
+}
+
+void ignore_unsafe_calls(int x) {
+  // Cannot fix `[x]` for now as it is an argument of an unsafe
+  // call. So no fix for variable `p`.
+  int * p = new int[10];
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
+  unsafe_f((unsigned long) [5],
+	   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
+	   [x]);
+
+  int * q = new int[10];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::span q"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:13-[[@LINE-2]]:13}:"{"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:24-[[@LINE-3]]:24}:", 10}"
+  unsafe_f((unsigned long) [5],
+	   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:28-[[@LINE-1]]:33}:"(q.data() + 5)"
+	   (void*)0);
+}
+
+void odd_subscript_form() {
+  int * p = new int[10];
+  unsigned long n = (unsigned long) &5[p];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:42}:"(p.data() + 5)"
+}
+
+// To test multiple function declarations, each of which carries
+// different incomplete informations:
+[[clang::unsafe_buffer_usage]]
+void unsafe_g(void*);
+
+void unsafe_g(void*);
+
+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*);
+
+[[clang::unsafe_buffer_usage]]
+void unsafe_h(void*);
+
+void unsafe_h(void* p) { ((char*)p)[10]; }
+
+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
@@ -117,6 +117,15 @@
   bool Matches;
 };
 
+// Because we're dealing with raw pointers, let's define what we mean by that.
+static auto hasPointerType() {
+return hasType(hasCanonicalType(pointerType()));
+}
+
+static auto hasArrayType() {
+return hasType(hasCanonicalType(arrayType()));
+}
+
 AST_MATCHER_P(Stmt, forEveryDescendant, internal::Matcher, innerMatcher) {
   const DynTypedMatcher  = static_cast(innerMatcher);
   
@@ -149,6 +158,29 @@
 ));
 // clang-format off
 }
+
+// Returns a matcher that matches any expression `e` such that `InnerMatcher`
+// matches `e` and `e` is in an Unspecified Pointer Context (UPC).
+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
+  // ...
+  auto CallArgMatcher =
+  callExpr(hasAnyArgument(allOf(
+   hasPointerType() /* array also decays to pointer type*/,
+   InnerMatcher)),
+   unless(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage);
+  auto CastOperandMatcher =
+  explicitCastExpr(hasCastKind(CastKind::CK_PointerToIntegral),
+   castSubExpr(allOf(hasPointerType(), InnerMatcher)));
+
+ return stmt(anyOf(CallArgMatcher, CastOperandMatcher));
+  // FIXME: any more cases? (UPC excludes the RHS of an assignment.  For now we
+  // don't have to check that.)
+}
 } // namespace clang::ast_matchers
 
 namespace {
@@ -163,15 +195,6 @@
 class Strategy;
 } // namespace
 
-// Because we're dealing with raw pointers, let's define what we mean by that.
-static auto hasPointerType() {
-return 

[PATCH] D143781: [Clang][LLVM] Enable __arithmetic_fence and fprotect-parens on AArch64

2023-02-13 Thread Alexander Shaposhnikov 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 rG8f5d81585aa9: [Clang][LLVM] Enable __arithmetic_fence and 
fprotect-parens on AArch64 (authored by alexander-shaposhnikov).

Changed prior to commit:
  https://reviews.llvm.org/D143781?vs=496606=497055#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143781

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/AArch64.h
  clang/test/AST/arithmetic-fence-builtin.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  llvm/test/CodeGen/AArch64/arithmetic_fence.ll

Index: llvm/test/CodeGen/AArch64/arithmetic_fence.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/arithmetic_fence.ll
@@ -0,0 +1,129 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=-neon -fp-contract=fast | FileCheck %s --check-prefix=Aarch64
+; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=+neon -fp-contract=fast | FileCheck %s --check-prefix=Aarch64-Neon
+
+define float @f1(float %a, float %b, float %c) {
+; Aarch64-LABEL: f1:
+; Aarch64:   // %bb.0:
+; Aarch64-NEXT:fmadd s0, s1, s0, s2
+; Aarch64-NEXT:ret
+;
+; Aarch64-Neon-LABEL: f1:
+; Aarch64-Neon:   // %bb.0:
+; Aarch64-Neon-NEXT:fmadd s0, s1, s0, s2
+; Aarch64-Neon-NEXT:ret
+  %mul = fmul fast float %b, %a
+  %add = fadd fast float %mul, %c
+  ret float %add
+}
+
+define float @f2(float %a, float %b, float %c) {
+; Aarch64-LABEL: f2:
+; Aarch64:   // %bb.0:
+; Aarch64-NEXT:fmul s0, s1, s0
+; Aarch64-NEXT://ARITH_FENCE
+; Aarch64-NEXT:fadd s0, s0, s2
+; Aarch64-NEXT:ret
+;
+; Aarch64-Neon-LABEL: f2:
+; Aarch64-Neon:   // %bb.0:
+; Aarch64-Neon-NEXT:fmul s0, s1, s0
+; Aarch64-Neon-NEXT://ARITH_FENCE
+; Aarch64-Neon-NEXT:fadd s0, s0, s2
+; Aarch64-Neon-NEXT:ret
+  %mul = fmul fast float %b, %a
+  %tmp = call float @llvm.arithmetic.fence.f32(float %mul)
+  %add = fadd fast float %tmp, %c
+  ret float %add
+}
+
+define double @f3(double %a) {
+; Aarch64-LABEL: f3:
+; Aarch64:   // %bb.0:
+; Aarch64-NEXT:fmov d1, #4.
+; Aarch64-NEXT:fmul d0, d0, d1
+; Aarch64-NEXT:ret
+;
+; Aarch64-Neon-LABEL: f3:
+; Aarch64-Neon:   // %bb.0:
+; Aarch64-Neon-NEXT:fmov d1, #4.
+; Aarch64-Neon-NEXT:fmul d0, d0, d1
+; Aarch64-Neon-NEXT:ret
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f4(double %a) {
+; Aarch64-LABEL: f4:
+; Aarch64:   // %bb.0:
+; Aarch64-NEXT:fadd d0, d0, d0
+; Aarch64-NEXT:fmov d1, d0
+; Aarch64-NEXT://ARITH_FENCE
+; Aarch64-NEXT:fadd d0, d1, d0
+; Aarch64-NEXT:ret
+;
+; Aarch64-Neon-LABEL: f4:
+; Aarch64-Neon:   // %bb.0:
+; Aarch64-Neon-NEXT:fadd d0, d0, d0
+; Aarch64-Neon-NEXT:fmov d1, d0
+; Aarch64-Neon-NEXT://ARITH_FENCE
+; Aarch64-Neon-NEXT:fadd d0, d1, d0
+; Aarch64-Neon-NEXT:ret
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f5(<2 x float> %a) {
+; Aarch64-LABEL: f5:
+; Aarch64:   // %bb.0:
+; Aarch64-NEXT:fmov s2, #4.
+; Aarch64-NEXT:fmul s0, s0, s2
+; Aarch64-NEXT:fmul s1, s1, s2
+; Aarch64-NEXT:ret
+;
+; Aarch64-Neon-LABEL: f5:
+; Aarch64-Neon:   // %bb.0:
+; Aarch64-Neon-NEXT:fmov v1.2s, #4.
+; Aarch64-Neon-NEXT:fmul v0.2s, v0.2s, v1.2s
+; Aarch64-Neon-NEXT:ret
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f6(<2 x float> %a) {
+; Aarch64-LABEL: f6:
+; Aarch64:   // %bb.0:
+; Aarch64-NEXT:fadd s0, s0, s0
+; Aarch64-NEXT:fadd s1, s1, s1
+; Aarch64-NEXT:fmov s2, s1
+; Aarch64-NEXT:fmov s3, s0
+; Aarch64-NEXT://ARITH_FENCE
+; Aarch64-NEXT://ARITH_FENCE
+; Aarch64-NEXT:fadd s0, s3, s0
+; Aarch64-NEXT:fadd s1, s2, s1
+; Aarch64-NEXT:ret
+;
+; Aarch64-Neon-LABEL: f6:
+; Aarch64-Neon:   // %bb.0:
+; Aarch64-Neon-NEXT:fadd v0.2s, v0.2s, v0.2s
+; Aarch64-Neon-NEXT:fmov d1, d0
+; Aarch64-Neon-NEXT://ARITH_FENCE
+; Aarch64-Neon-NEXT:fadd v0.2s, v1.2s, v0.2s
+; Aarch64-Neon-NEXT:ret
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+declare float @llvm.arithmetic.fence.f32(float)
+declare double @llvm.arithmetic.fence.f64(double)
+declare <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float>)
Index: 

[clang] 8f5d815 - [Clang][LLVM] Enable __arithmetic_fence and fprotect-parens on AArch64

2023-02-13 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2023-02-13T19:26:11Z
New Revision: 8f5d81585aa9261342d5304e460925916ea1f851

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

LOG: [Clang][LLVM] Enable __arithmetic_fence and fprotect-parens on AArch64

Enable __arithmetic_fence and fprotect-parens on AArch64.

Test plan: ninja check-clang check-clang-tools check-llvm

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

Added: 
llvm/test/CodeGen/AArch64/arithmetic_fence.ll

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Basic/Targets/AArch64.h
clang/test/AST/arithmetic-fence-builtin.c
clang/test/CodeGen/arithmetic-fence-builtin.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 06f0bdcc796d6..0dcd9b9f04b1d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -181,13 +181,16 @@ DWARF Support in Clang
 Arm and AArch64 Support in Clang
 
 
-* The hard-float ABI is now available in Armv8.1-M configurations that
+- The hard-float ABI is now available in Armv8.1-M configurations that
   have integer MVE instructions (and therefore have FP registers) but
   no scalar or vector floating point computation. Previously, trying
   to select the hard-float ABI on such a target (via
   ``-mfloat-abi=hard`` or a triple ending in ``hf``) would silently
   use the soft-float ABI instead.
 
+- Clang builtin ``__arithmetic_fence`` and the command line option 
``-fprotect-parens``
+  are now enabled for AArch64.
+
 Floating Point Support in Clang
 ---
 - Add ``__builtin_elementwise_log`` builtin for floating point types only.

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 7f88f3516780f..23cabc5885104 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -155,6 +155,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
   bool supportsTargetAttributeTune() const override { return true; }
 
+  bool checkArithmeticFenceSupported() const override { return true; }
+
   bool hasBFloat16Type() const override;
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;

diff  --git a/clang/test/AST/arithmetic-fence-builtin.c 
b/clang/test/AST/arithmetic-fence-builtin.c
index 4b3c8bed5..acdefade0748a 100644
--- a/clang/test/AST/arithmetic-fence-builtin.c
+++ b/clang/test/AST/arithmetic-fence-builtin.c
@@ -2,30 +2,54 @@
 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu %s \
 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
 //
+// RUN: %clang_cc1 -ast-dump -triple aarch64-unknown-linux-gnu %s \
+// RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
+//
 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu -DFAST -mreassociate %s 
\
 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
 //
+// RUN: %clang_cc1 -ast-dump -triple aarch64-unknown-linux-gnu -DFAST 
-mreassociate %s \
+// RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
+//
 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu -DFAST -mreassociate %s 
\
 // RUN: -fprotect-parens \
 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK2
 //
+// RUN: %clang_cc1 -ast-dump -triple aarch64-unknown-linux-gnu -DFAST 
-mreassociate %s \
+// RUN: -fprotect-parens \
+// RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK2
+//
 // Tests with serialization:
 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu -emit-pch -o %t %s
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -include-pch %t -ast-dump-all 
/dev/null \
 // RUN: | FileCheck %s --strict-whitespace
 //
+// RUN: %clang_cc1 -ast-dump -triple aarch64-unknown-linux-gnu -emit-pch -o %t 
%s
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -include-pch %t 
-ast-dump-all /dev/null \
+// RUN: | FileCheck %s --strict-whitespace
+//
 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu -DFAST -mreassociate %s 
\
 // RUN: -emit-pch -o %t
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -include-pch %t -ast-dump-all 
/dev/null \
 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
 //
+// RUN: %clang_cc1 -ast-dump -triple aarch64-unknown-linux-gnu -DFAST 
-mreassociate %s \
+// RUN: -emit-pch -o %t
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -include-pch %t 
-ast-dump-all /dev/null \
+// RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
+//
 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu -DFAST -mreassociate %s 
\
 // RUN: -fprotect-parens \
 // RUN: -emit-pch -o %t
 // RUN: %clang_cc1 -triple 

[PATCH] D143233: [Clang][CodeGen] Fix this argument type for certain destructors

2023-02-13 Thread Jacob Young via Phabricator via cfe-commits
jacobly updated this revision to Diff 497052.
jacobly added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143233

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  clang/test/CodeGenCXX/microsoft-abi-structors.cpp
  clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -53,6 +53,7 @@
 B::~B() {
   // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1B@@UAE@XZ"
   // Store initial this:
+  // CHECK:   %[[THIS:.*]] = alloca %struct.B*
   // CHECK:   %[[THIS_ADDR:.*]] = alloca %struct.B*
   // CHECK:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
   // Reload and adjust the this parameter:
@@ -90,8 +91,7 @@
   // CHECK2: %[[THIS:.*]] = load %struct.B*, %struct.B** {{.*}}
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[B_i8:.*]] = getelementptr i8, i8* %[[THIS_i8]], i32 8
-  // CHECK2: %[[B:.*]] = bitcast i8* %[[B_i8]] to %struct.B*
-  // CHECK2: call x86_thiscallcc void @"??1B@@UAE@XZ"(%struct.B* {{[^,]*}} %[[B]])
+  // CHECK2: call x86_thiscallcc void @"??1B@@UAE@XZ"(i8*{{[^,]*}} %[[B_i8]])
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[THIS_i8]], i32 8
   // CHECK2: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.VBase*
@@ -99,6 +99,7 @@
   // CHECK2: ret
 
   // CHECK2-LABEL: define linkonce_odr dso_local x86_thiscallcc noundef i8* @"??_GB@@UAEPAXI@Z"
+  // CHECK2:   store %struct.B* %{{.*}}, %struct.B** %[[THIS:.*]], align 4
   // CHECK2:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR:.*]], align 4
   // CHECK2:   %[[THIS:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
   // CHECK2:   %[[THIS_PARAM_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
@@ -196,7 +197,6 @@
 // CHECK: %[[VBOFFSET32:.*]] = load i32, i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.B*
 //
 // CHECK: %[[OBJ_i8:.*]] = bitcast %struct.B* %[[OBJ]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 0
@@ -206,12 +206,12 @@
 // CHECK: %[[VBOFFSET32:.*]] = load i32, i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (%struct.B*, i32)***
-// CHECK: %[[VFTABLE:.*]] = load i8* (%struct.B*, i32)**, i8* (%struct.B*, i32)*** %[[VFPTR]]
-// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (%struct.B*, i32)*, i8* (%struct.B*, i32)** %[[VFTABLE]], i64 0
-// CHECK: %[[VFUN_VALUE:.*]] = load i8* (%struct.B*, i32)*, i8* (%struct.B*, i32)** %[[VFUN]]
+// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (i8*, i32)***
+// CHECK: %[[VFTABLE:.*]] = load i8* (i8*, i32)**, i8* (i8*, i32)*** %[[VFPTR]]
+// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (i8*, i32)*, i8* (i8*, i32)** %[[VFTABLE]], i64 0
+// CHECK: %[[VFUN_VALUE:.*]] = load i8* (i8*, i32)*, i8* (i8*, i32)** %[[VFUN]]
 //
-// CHECK: call x86_thiscallcc noundef i8* %[[VFUN_VALUE]](%struct.B* {{[^,]*}} %[[VBASE]], i32 noundef 1)
+// CHECK: call x86_thiscallcc noundef i8* %[[VFUN_VALUE]](i8* {{[^,]*}} %[[VBASE]], i32 noundef 1)
 // CHECK: ret void
 }
 
@@ -295,8 +295,9 @@
 } d;
 
 D::~D() {
-  // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1D@diamond@@UAE@XZ"(%"struct.diamond::D"*{{.*}})
+  // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1D@diamond@@UAE@XZ"(i8*{{.*}})
   // Store initial this:
+  // CHECK: %[[THIS:.*]] = alloca %"struct.diamond::D"*
   // CHECK: %[[THIS_ADDR:.*]] = alloca %"struct.diamond::D"*
   // CHECK: store %"struct.diamond::D"* %{{.*}}, %"struct.diamond::D"** %[[THIS_ADDR]], align 4
   //
@@ -310,16 +311,13 @@
   // CHECK: %[[C_i8:.*]] = getelementptr inbounds i8, i8* %[[D_i8]], i32 4
   // CHECK: %[[C:.*]] = bitcast i8* %[[C_i8]] to %"struct.diamond::C"*
   // CHECK: %[[C_i8:.*]] = bitcast %"struct.diamond::C"* %[[C]] to i8*
-  // CHECK: %[[ARG_i8:.*]] = getelementptr i8, i8* %{{.*}}, i32 16
-  // FIXME: We might consider changing the dtor this parameter type to i8*.
-  // CHECK: %[[ARG:.*]] = bitcast i8* %[[ARG_i8]] to 

[PATCH] D143680: [WIP][-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

2023-02-13 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 497051.
ziqingluo-90 added a comment.

Rebased


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

https://reviews.llvm.org/D143680

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
@@ -131,6 +131,38 @@
   tmp = (int) s[5];
 }
 
+void null_init() {
+#define NULL 0
+  int tmp;
+  int * my_null = 0;
+  int * p = 0;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::span p"
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{^3}}
+  int * g = NULL; // cannot handle fix-its involving macros for now
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * f = nullptr;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::span f"
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{^3}}
+
+  // In case of value dependencies, we give up
+  int * q = my_null;
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::span q"
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:13-[[@LINE-2]]:13}:"{"
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:", <# placeholder #>}"
+  int * r = my_null + 0;
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::span r"
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:13-[[@LINE-2]]:13}:"{"
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-3]]:24-[[@LINE-3]]:24}:", <# placeholder #>}"
+
+  tmp = p[5]; // `p[5]` will cause crash after `p` being transformed to be a `std::span`
+  tmp = q[5]; // Similar for the rests.
+  tmp = r[5];
+  tmp = g[5];
+  tmp = f[5];
+#undef NULL
+}
+
+
 void unsupported_multi_decl(int * x) {
   int * p = x, * q = new int[10];
   // CHECK-NOT: fix-it:"{{.*}}":[[@LINE-1]]
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -862,14 +862,30 @@
 template 
 static SourceLocation getEndCharLoc(const NodeTy *Node, const SourceManager ,
 const LangOptions ) {
-  return Lexer::getLocForEndOfToken(Node->getEndLoc(), 1, SM, LangOpts);
+  unsigned TkLen = Lexer::MeasureTokenLength(Node->getEndLoc(), SM, LangOpts);
+  SourceLocation Loc = Node->getEndLoc().getLocWithOffset(TkLen - 1);
+
+  // We expect `Loc` to be valid. The location is obtained by moving forward
+  // from the beginning of the token 'len(token)-1' characters. The file ID of
+  // the locations within a token must be consistent.
+  assert(Loc.isValid() && "Expected the source location of the last"
+  "character of an AST Node is alwasy valid");
+  return Loc;
 }
 
 // Return the source location just past the last character of the AST `Node`.
 template 
 static SourceLocation getPastLoc(const NodeTy *Node, const SourceManager ,
  const LangOptions ) {
-  return Lexer::getLocForEndOfToken(Node->getEndLoc(), 0, SM, LangOpts);
+  SourceLocation Loc =
+  Lexer::getLocForEndOfToken(Node->getEndLoc(), 0, SM, LangOpts);
+
+  // We expect `Loc` to be valid as it is either associated to a file ID or
+  //   it must be the end of a macro expansion. (see
+  //   `Lexer::getLocForEndOfToken`)
+  assert(Loc.isValid() && "Expected the source location just past the last "
+  "character of an AST Node is alwasy valid");
+  return Loc;
 }
 
 // Return text representation of an `Expr`.
@@ -923,9 +939,25 @@
 static FixItList
 populateInitializerFixItWithSpan(const Expr *Init, const ASTContext ,
  const StringRef UserFillPlaceHolder) {
-  FixItList FixIts{};
   const SourceManager  = Ctx.getSourceManager();
   const LangOptions  = Ctx.getLangOpts();
+
+  // If `Init` has a constant value that is (or equivalent to) a
+  // NULL pointer, we use the default constructor to initialize the span
+  // object, i.e., a `std:span` variable declaration with no initializer.
+  // So the fix-it is just to remove the initializer.
+  if (Init->isNullPointerConstant(
+  std::remove_const_t(Ctx),
+  // FIXME: Why does this function not ask for `const ASTContext
+  // &`? It should. Maybe worth an NFC patch later.
+  Expr::NullPointerConstantValueDependence::
+  NPC_ValueDependentIsNotNull)) {
+SourceRange SR(Init->getBeginLoc(), getEndCharLoc(Init, SM, LangOpts));
+
+return {FixItHint::CreateRemoval(SR)};
+  }
+
+  FixItList FixIts{};
   std::string ExtentText = UserFillPlaceHolder.data();
   StringRef One = "1";
 
@@ -998,8 +1030,9 @@
 FixItList InitFixIts =
 populateInitializerFixItWithSpan(Init, Ctx, 

[PATCH] D143919: [Clang] Copy strictfp attribute from pattern to instantiation

2023-02-13 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D143919#4123616 , @efriedma wrote:

> We have code somewhere to generically copy attributes from function templates 
> to instantiations, right?  Why do we need to explicitly copy StrictFPAttr in 
> particular, separate from that?

Could you please point me out to this code? I didn't find it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143919

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


[PATCH] D143233: [Clang][CodeGen] Fix this argument type for certain destructors

2023-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: efriedma.
aaron.ballman added a comment.

Please be sure to add release notes to clang/docs/ReleaseNotes.rst

Things look reasonable to me, but it'd be nice if someone with more Windows ABI 
experience could take a look as well.




Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:243
+  GlobalDecl LookupGD = GD;
+  if (const CXXDestructorDecl *DD = dyn_cast(MD)) {
+// Complete dtors take a pointer to the complete object,




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143233

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


[PATCH] D143917: [clang-tidy] Clarify bugprone-branch-clone diagnostic message

2023-02-13 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp accepted this revision.
carlosgalvezp added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the fix! Personally I don't think such a small change is worth 
mentioning in the Release Notes, but maybe other reviewers think differently, 
let's give them a couple of days.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143917

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


[PATCH] D143794: [Fuchsia] Add FUCHSIA_ENABLE_LLDB option.

2023-02-13 Thread Daniel Thornburgh via Phabricator via cfe-commits
mysterymath updated this revision to Diff 497048.
mysterymath added a comment.

_FUCHSIA_DISTRIBUTION_COMPONENTS should not be a CACHE variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143794

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -4,7 +4,7 @@
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(LLVM_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly" CACHE 
STRING "")
+set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -321,7 +321,7 @@
   scan-build-py
   CACHE STRING "")
 
-set(LLVM_DISTRIBUTION_COMPONENTS
+set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld
   clang-apply-replacements
@@ -336,5 +336,13 @@
   find-all-symbols
   builtins
   runtimes
-  ${LLVM_TOOLCHAIN_TOOLS}
-  CACHE STRING "")
+  ${LLVM_TOOLCHAIN_TOOLS})
+
+set(FUCHSIA_ENABLE_LLDB OFF CACHE BOOL "Enable LLDB")
+if(FUCHSIA_ENABLE_LLDB)
+  list(APPEND _FUCHSIA_ENABLE_PROJECTS "lldb")
+  list(APPEND _FUCHSIA_DISTRIBUTION_COMPONENTS "lldb")
+endif()
+
+set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "")
+set(LLVM_DISTRIBUTION_COMPONENTS ${_FUCHSIA_DISTRIBUTION_COMPONENTS} CACHE 
STRING "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -4,7 +4,7 @@
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(LLVM_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly" CACHE STRING "")
+set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -321,7 +321,7 @@
   scan-build-py
   CACHE STRING "")
 
-set(LLVM_DISTRIBUTION_COMPONENTS
+set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld
   clang-apply-replacements
@@ -336,5 +336,13 @@
   find-all-symbols
   builtins
   runtimes
-  ${LLVM_TOOLCHAIN_TOOLS}
-  CACHE STRING "")
+  ${LLVM_TOOLCHAIN_TOOLS})
+
+set(FUCHSIA_ENABLE_LLDB OFF CACHE BOOL "Enable LLDB")
+if(FUCHSIA_ENABLE_LLDB)
+  list(APPEND _FUCHSIA_ENABLE_PROJECTS "lldb")
+  list(APPEND _FUCHSIA_DISTRIBUTION_COMPONENTS "lldb")
+endif()
+
+set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "")
+set(LLVM_DISTRIBUTION_COMPONENTS ${_FUCHSIA_DISTRIBUTION_COMPONENTS} CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142316: [clang] Add test for CWG2396

2023-02-13 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 rG51a07fc24cb9: [clang] Add test for CWG2396 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142316

Files:
  clang/test/CXX/drs/dr12xx.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
@@ -7553,7 +7553,7 @@
 https://wg21.link/cwg1291;>1291
 CD6
 Looking up a conversion-type-id
-Unknown
+N/A
   
   
 https://wg21.link/cwg1292;>1292
@@ -14183,7 +14183,7 @@
 https://wg21.link/cwg2396;>2396
 CD6
 Lookup of names in complex conversion-type-ids
-Unknown
+No
   
   
 https://wg21.link/cwg2397;>2397
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -181,3 +181,19 @@
 B b;
 
 }
+
+namespace dr2396 { // dr2396: no
+  struct A {
+struct B;
+operator B B::*();
+  };
+  struct B;
+
+  // FIXME: per P1787 "Calling a conversion function" example, all of the
+  // examples below are well-formed, with B resolving to A::B, but currently
+  // it's been resolved to dr2396::B. 
+
+  // void f(A a) { a.operator B B::*(); }
+  // void g(A a) { a.operator decltype(B()) B::*(); }
+  // void g2(A a) { a.operator B decltype(B())::*(); }
+}
Index: clang/test/CXX/drs/dr12xx.cpp
===
--- clang/test/CXX/drs/dr12xx.cpp
+++ clang/test/CXX/drs/dr12xx.cpp
@@ -68,6 +68,8 @@
 #endif
 }
 
+// dr1291: na
+
 namespace dr1295 { // dr1295: 4
   struct X {
 unsigned bitfield : 4;


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -7553,7 +7553,7 @@
 https://wg21.link/cwg1291;>1291
 CD6
 Looking up a conversion-type-id
-Unknown
+N/A
   
   
 https://wg21.link/cwg1292;>1292
@@ -14183,7 +14183,7 @@
 https://wg21.link/cwg2396;>2396
 CD6
 Lookup of names in complex conversion-type-ids
-Unknown
+No
   
   
 https://wg21.link/cwg2397;>2397
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -181,3 +181,19 @@
 B b;
 
 }
+
+namespace dr2396 { // dr2396: no
+  struct A {
+struct B;
+operator B B::*();
+  };
+  struct B;
+
+  // FIXME: per P1787 "Calling a conversion function" example, all of the
+  // examples below are well-formed, with B resolving to A::B, but currently
+  // it's been resolved to dr2396::B. 
+
+  // void f(A a) { a.operator B B::*(); }
+  // void g(A a) { a.operator decltype(B()) B::*(); }
+  // void g2(A a) { a.operator B decltype(B())::*(); }
+}
Index: clang/test/CXX/drs/dr12xx.cpp
===
--- clang/test/CXX/drs/dr12xx.cpp
+++ clang/test/CXX/drs/dr12xx.cpp
@@ -68,6 +68,8 @@
 #endif
 }
 
+// dr1291: na
+
 namespace dr1295 { // dr1295: 4
   struct X {
 unsigned bitfield : 4;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 51a07fc - [clang] Add test for CWG2396

2023-02-13 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-02-13T21:53:00+03:00
New Revision: 51a07fc24cb909011e0b16793800aab4b93031ed

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

LOG: [clang] Add test for CWG2396

Also mark [[ https://wg21.link/cwg1291 | CWG1291 ]] as "na".

[[ https://wg21.link/p1787 | P1787 ]]: CWG1291 and CWG2396 are resolved by 
explicitly specifying how to look up names in a conversion-type-id.
Wording: see changes to [basic.lookup.unqual]/5 and [basic.lookup.qual]/2.

"Calling a conversion function" example in [[ https://wg21.link/p1787 | P1787 
]] is also relevant.

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

Added: 


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

Removed: 




diff  --git a/clang/test/CXX/drs/dr12xx.cpp b/clang/test/CXX/drs/dr12xx.cpp
index dcc131104e7bd..9f09ff1f698e5 100644
--- a/clang/test/CXX/drs/dr12xx.cpp
+++ b/clang/test/CXX/drs/dr12xx.cpp
@@ -68,6 +68,8 @@ namespace dr1265 { // dr1265: 5
 #endif
 }
 
+// dr1291: na
+
 namespace dr1295 { // dr1295: 4
   struct X {
 unsigned bitfield : 4;

diff  --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp
index 59e1f27491d26..a60aa8e5609c6 100644
--- a/clang/test/CXX/drs/dr23xx.cpp
+++ b/clang/test/CXX/drs/dr23xx.cpp
@@ -181,3 +181,19 @@ struct B { const A a; };
 B b;
 
 }
+
+namespace dr2396 { // dr2396: no
+  struct A {
+struct B;
+operator B B::*();
+  };
+  struct B;
+
+  // FIXME: per P1787 "Calling a conversion function" example, all of the
+  // examples below are well-formed, with B resolving to A::B, but currently
+  // it's been resolved to dr2396::B. 
+
+  // void f(A a) { a.operator B B::*(); }
+  // void g(A a) { a.operator decltype(B()) B::*(); }
+  // void g2(A a) { a.operator B decltype(B())::*(); }
+}

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 8123c476abb8c..fdf8e6b4baeb1 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -7553,7 +7553,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg1291;>1291
 CD6
 Looking up a conversion-type-id
-Unknown
+N/A
   
   
 https://wg21.link/cwg1292;>1292
@@ -14183,7 +14183,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg2396;>2396
 CD6
 Lookup of names in complex conversion-type-ids
-Unknown
+No
   
   
 https://wg21.link/cwg2397;>2397



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


[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-02-13 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 497045.
TIFitis added a comment.

Fixing build errors. Added mlir/lib/Target/LLVMIR/Dialect/Utils.cpp, made it 
part of the MLIRTargetLLVMIRExport lib.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142914

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/include/mlir/Target/LLVMIR/Dialect/Utils.h
  mlir/lib/Target/LLVMIR/CMakeLists.txt
  mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/Utils.cpp

Index: mlir/lib/Target/LLVMIR/Dialect/Utils.cpp
===
--- /dev/null
+++ mlir/lib/Target/LLVMIR/Dialect/Utils.cpp
@@ -0,0 +1,41 @@
+//===- Utils.cpp - General Utils for translating MLIR dialect to LLVM IR---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines general utilities for MLIR Dialect translations to LLVM IR.
+//
+//===--===//
+
+#include "mlir/Target/LLVMIR/Dialect/Utils.h"
+
+llvm::Constant *
+mlir::LLVM::createSourceLocStrFromLocation(Location loc,
+   llvm::OpenMPIRBuilder ,
+   StringRef name, uint32_t ) {
+  if (auto fileLoc = loc.dyn_cast()) {
+StringRef fileName = fileLoc.getFilename();
+unsigned lineNo = fileLoc.getLine();
+unsigned colNo = fileLoc.getColumn();
+return builder.getOrCreateSrcLocStr(name, fileName, lineNo, colNo, strLen);
+  }
+  std::string locStr;
+  llvm::raw_string_ostream locOS(locStr);
+  locOS << loc;
+  return builder.getOrCreateSrcLocStr(locOS.str(), strLen);
+}
+
+llvm::Constant *
+mlir::LLVM::createMappingInformation(Location loc,
+ llvm::OpenMPIRBuilder ) {
+  uint32_t strLen;
+  if (auto nameLoc = loc.dyn_cast()) {
+StringRef name = nameLoc.getName();
+return createSourceLocStrFromLocation(nameLoc.getChildLoc(), builder, name,
+  strLen);
+  }
+  return createSourceLocStrFromLocation(loc, builder, "unknown", strLen);
+}
Index: mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -15,10 +15,12 @@
 #include "mlir/IR/IRMapping.h"
 #include "mlir/IR/Operation.h"
 #include "mlir/Support/LLVM.h"
+#include "mlir/Target/LLVMIR/Dialect/Utils.h"
 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
 
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/TypeSwitch.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/IRBuilder.h"
@@ -1325,6 +1327,191 @@
   return success();
 }
 
+/// Process MapOperands for Target Data directives.
+static LogicalResult processMapOperand(
+llvm::IRBuilderBase , LLVM::ModuleTranslation ,
+const SmallVector , const ArrayAttr ,
+SmallVector ,
+SmallVectorImpl ,
+struct llvm::OpenMPIRBuilder::MapperAllocas ) {
+  auto numMapOperands = mapOperands.size();
+  llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
+  llvm::PointerType *i8PtrTy = builder.getInt8PtrTy();
+  llvm::ArrayType *arrI8PtrTy = llvm::ArrayType::get(i8PtrTy, numMapOperands);
+  llvm::IntegerType *i64Ty = builder.getInt64Ty();
+  llvm::ArrayType *arrI64Ty = llvm::ArrayType::get(i64Ty, numMapOperands);
+
+  unsigned index = 0;
+  for (const auto  : mapOperands) {
+const auto  = mapTypes[index];
+
+llvm::Value *mapOpValue = moduleTranslation.lookupValue(mapOp);
+llvm::Value *mapOpPtrBase;
+llvm::Value *mapOpPtr;
+llvm::Value *mapOpSize;
+
+if (mapOp.getType().isa()) {
+  mapOpPtrBase = mapOpValue;
+  mapOpPtr = mapOpValue;
+  mapOpSize = ompBuilder->getSizeInBytes(mapOpValue);
+} else {
+  return failure();
+}
+
+// Store base pointer extracted from operand into the i-th position of
+// argBase.
+llvm::Value *ptrBaseGEP = builder.CreateInBoundsGEP(
+arrI8PtrTy, mapperAllocas.ArgsBase,
+{builder.getInt32(0), builder.getInt32(index)});
+llvm::Value *ptrBaseCast = builder.CreateBitCast(
+ptrBaseGEP, 

[PATCH] D140123: [TLS] Clamp the alignment of TLS global variables if required by the target

2023-02-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D140123#4113536 , @efriedma wrote:

> Missing LangRef change?

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140123

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


[PATCH] D143919: [Clang] Copy strictfp attribute from pattern to instantiation

2023-02-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

We have code somewhere to generically copy attributes from function templates 
to instantiations, right?  Why do we need to explicitly copy StrictFPAttr in 
particular, separate from that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143919

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


[PATCH] D142316: [clang] Add test for CWG2396

2023-02-13 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142316

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


[PATCH] D143781: [Clang][LLVM] Enable __arithmetic_fence and fprotect-parens on AArch64

2023-02-13 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

sure, will do! thanks for the review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143781

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


[PATCH] D143418: [libclang] Add API to set preferred temp dir path

2023-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D143418#4123468 , @vedgy wrote:

> In D143418#4122821 , @aaron.ballman 
> wrote:
>
>>> How about including existing options, which //should// be set in 
>>> constructor, in the initial struct version and deprecating the 
>>> corresponding setters?
>>
>> I think that makes a lot of sense.
>
> How to deprecate the setters? Add `DEPRECATED` in the documentations as is 
> already done in two places in //Index.h//?

I think that is reasonable. (Maybe someday in the future we should use 
attributes to give users better diagnostics, but not as part of this patch.)

>>>   `const char *preferredTempDirPath;`
>>
>> In terms of documenting the structure, should we document this member as 
>> only impacting preamble files currently, should we rename this to be 
>> preamble-path specific, or should we try to use this preferred path in all 
>> the places we need the temp directory?
>>
>> (I lean towards renaming to preamble-path specific -- then users don't have 
>> the problem of upgrading to a newer CIndex potentially changing the behavior 
>> of where non-preamble files are stored, and we don't have to do the work 
>> up-front to audit other temp file uses.)
>
> Looks like an imperfect general implementation is unacceptable. So I'll 
> rename this data member to `PreambleStoragePath`.

I like that direction, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143418

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


[PATCH] D143725: [llvm-objdump][ARM] support --symbolize-operands for ARM/ELF

2023-02-13 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added inline comments.



Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:1169-1171
+  // On PowerPC and ARM/Thumb, if the address of a branch is the same as
+  // the target, it means that it's a function call. Do not mark the label
+  // for this case.

Is this always true for linked binary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143725

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


[PATCH] D143260: [clangd] Add semantic token for labels

2023-02-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Another potential consideration here is the GNU "labels as values 
" language extension, 
which clang seems to support, and which allows referencing a `LabelDecl` from a 
context other than a goto-statement (and thus less obvious from the lexical 
context only).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143260

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


[PATCH] D143891: [Clang] Adjust triviality computation in QualType::isTrivialType to C++20 cases.

2023-02-13 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/lib/AST/Type.cpp:2495
+  // FIXME: We should merge this definition of triviality into
+  // CXXRecordDecl::isTrivial. Currently it computes the wrong thing.
+  return ClassDecl->hasTrivialDefaultConstructor() &&

shafik wrote:
> Will you follow-up this change by updating `CXXRecordDecl::isTrivial` as well 
> or is that a more difficult issue?
I want to, but I need to check the call sites to make sure it won't change ABI 
or something. And I wanted a fix that I can safely backport :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143891

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


[PATCH] D143260: [clangd] Add semantic token for labels

2023-02-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

FWIW, I agree that switch labels and goto labels are conceptually quite 
different: the thing before a switch label is an expression, and if it's an 
identifier it references an already-declared entity with its own kind (e.g. 
enumerator), whereas a goto label basically declares a new entity of a special 
kind (which can then be referenced from `goto` statements); having a distint 
color for that kind would make sense to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143260

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


[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-13 Thread Mark Danial via Phabricator via cfe-commits
madanial updated this revision to Diff 497024.
madanial added a comment.

Addressing the review comments relating to the test case. Thanks for the catch!


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

https://reviews.llvm.org/D140795

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/underscoring.f90
  flang/test/Fir/external-mangling.fir

Index: flang/test/Fir/external-mangling.fir
===
--- flang/test/Fir/external-mangling.fir
+++ flang/test/Fir/external-mangling.fir
@@ -1,6 +1,9 @@
-// RUN: fir-opt --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR
+// RUN: fir-opt --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: fir-opt --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-NOUNDER
 
 func.func @_QPfoo() {
   %c0 = arith.constant 0 : index
@@ -21,24 +24,43 @@
 func.func private @_QPbar(!fir.ref)
 func.func private @_QPbar2(!fir.ref)
 
-// CHECK: func @foo_
-// CHECK: %{{.*}} = fir.address_of(@a_) : !fir.ref>
-// CHECK: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
-// CHECK: fir.call @bar_
-// CHECK: fir.call @bar2_
-// CHECK: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: func private @bar_(!fir.ref)
-
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
-// LLVMIR: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
-// LLVMIR: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
-
-// LLVMIR: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
-// LLVMIR: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
-// LLVMIR: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
-// LLVMIR: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+// CHECK-UNDER: func @foo_
+// CHECK-UNDER: %{{.*}} = fir.address_of(@a_) : !fir.ref>
+// CHECK-UNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-UNDER: fir.call @bar_
+// CHECK-UNDER: fir.call @bar2_
+// CHECK-UNDER: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: func private @bar_(!fir.ref)
+
+// CHECK-NOUNDER: func @foo(
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@a) : !fir.ref>
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-NOUNDER: fir.call @bar(
+// CHECK-NOUNDER: fir.call @bar2(
+// CHECK-NOUNDER: fir.global common @a(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: func private @bar(!fir.ref)
+
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-UNDER: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-UNDER: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-UNDER: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
+// LLVMIR-UNDER: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @a : !llvm.ptr>
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-NOUNDER: llvm.call @bar(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-NOUNDER: llvm.call @bar2(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-NOUNDER: llvm.mlir.global common @a(dense<0> : vector<4xi8>) {{.*}} : 

[PATCH] D143418: [libclang] Add API to set preferred temp dir path

2023-02-13 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy added a comment.

In D143418#4122821 , @aaron.ballman 
wrote:

>> How about including existing options, which //should// be set in 
>> constructor, in the initial struct version and deprecating the corresponding 
>> setters?
>
> I think that makes a lot of sense.

How to deprecate the setters? Add `DEPRECATED` in the documentations as is 
already done in two places in //Index.h//?

>>   `const char *preferredTempDirPath;`
>
> In terms of documenting the structure, should we document this member as only 
> impacting preamble files currently, should we rename this to be preamble-path 
> specific, or should we try to use this preferred path in all the places we 
> need the temp directory?
>
> (I lean towards renaming to preamble-path specific -- then users don't have 
> the problem of upgrading to a newer CIndex potentially changing the behavior 
> of where non-preamble files are stored, and we don't have to do the work 
> up-front to audit other temp file uses.)

Looks like an imperfect general implementation is unacceptable. So I'll rename 
this data member to `PreambleStoragePath`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143418

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


[clang] 756395f - [clang] fix DR status in cxx_status.html

2023-02-13 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-02-13T09:30:57-08:00
New Revision: 756395f61b90e30c9087b5efa8b4809ab03aff6e

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

LOG: [clang] fix DR status in cxx_status.html

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 729135deced82..f93a788aa0d7a 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1203,12 +1203,11 @@ C++20 implementation status
 Partial
   

-https://wg21.link/P2615R1;>P2615R1
+https://wg21.link/P2615R1;>P2615R1 (DR)
 No
   

-https://wg21.link/P2788R0;>P2788R0
-
+https://wg21.link/P2788R0;>P2788R0 (DR)
 No
   
 
@@ -1530,13 +1529,13 @@ C++2b implementation status
   Clang 16
 
 
-  Permitting static constexpr variables in constexpr functions 
(DR)
+  Permitting static constexpr variables in constexpr functions
   https://wg21.link/P2647R1;>P2647R1
   Clang 16
 
 
-  consteval needs to propagate up (DR)
-  https://wg21.link/P2564R3;>P2564R3
+  consteval needs to propagate up
+  https://wg21.link/P2564R3;>P2564R3 (DR)
   No
 
 
@@ -1546,9 +1545,9 @@ C++2b implementation status
 
 
 
-  Static and explicit object member functions with the same 
parameter-type-lists
-  https://wg21.link/P2797R0;>P2797R0
-  No
+  Referencing The Unicode Standard
+  https://wg21.link/P2736R2;>P2736R2
+  Yes
 
 
 



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


[PATCH] D141698: doc: Rewrite opening paragraph of CFI Design Doc

2023-02-13 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce added a comment.

I tend to keep it as it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141698

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


[PATCH] D141808: [Driver] Add --vfsoverlay flag

2023-02-13 Thread Alex Brachet 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 rGdf5beebc98bb: [Driver] Add --vfsoverlay flag (authored by 
abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D141808?vs=489839=497022#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141808

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/msvc-link.c
  clang/test/Driver/vfsoverlay.c


Index: clang/test/Driver/vfsoverlay.c
===
--- clang/test/Driver/vfsoverlay.c
+++ clang/test/Driver/vfsoverlay.c
@@ -1,5 +1,8 @@
 // RUN: %clang -ivfsoverlay foo.h -### %s 2>&1 | FileCheck %s
 // CHECK: "-ivfsoverlay" "foo.h"
 
+// RUN: %clang --vfsoverlay foo.h -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK2
+// CHECK2: "--vfsoverlay" "foo.h"
+
 // RUN: not %clang -ivfsoverlay foo.h %s 2>&1 | FileCheck 
-check-prefix=CHECK-MISSING %s
 // CHECK-MISSING: virtual filesystem overlay file 'foo.h' not found
Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -30,3 +30,9 @@
 // NOREPRO: "-out:msvc-link.exe"
 // NOREPRO: "-nologo"
 // NOREPRO-NOT: "-Brepro"
+
+// RUN: %clang_cl -fuse-ld=lld --vfsoverlay %s -### -- %s 2>&1 | FileCheck 
--check-prefix=VFSOVERLAY %s
+// VFSOVERLAY: -cc1"
+// VFSOVERLAY: "--vfsoverlay"
+// VFSOVERLAY: lld-link"
+// VFSOVERLAY: "/vfsoverlay:
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3167,7 +3167,7 @@
 Opts.AddSystemHeaderPrefix(
 A->getValue(), A->getOption().matches(OPT_system_header_prefix));
 
-  for (const auto *A : Args.filtered(OPT_ivfsoverlay))
+  for (const auto *A : Args.filtered(OPT_ivfsoverlay, OPT_vfsoverlay))
 Opts.AddVFSOverlayFile(A->getValue());
 
   return Diags.getNumErrors() == NumErrorsBefore;
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -312,6 +312,11 @@
   if (Linker.equals_insensitive("lld"))
 Linker = "lld-link";
 
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7038,6 +7038,13 @@
 A->claim();
   }
 
+  // Forward --vfsoverlay to -cc1.
+  for (const Arg *A : Args.filtered(options::OPT_vfsoverlay)) {
+CmdArgs.push_back("--vfsoverlay");
+CmdArgs.push_back(A->getValue());
+A->claim();
+  }
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3400,6 +3400,9 @@
   Flags<[CC1Option]>;
 def ivfsoverlay : JoinedOrSeparate<["-"], "ivfsoverlay">, 
Group, Flags<[CC1Option]>,
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system">;
+def vfsoverlay : JoinedOrSeparate<["-", "--"], "vfsoverlay">, 
Flags<[CC1Option, CoreOption]>,
+  HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
+   "Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,


Index: clang/test/Driver/vfsoverlay.c
===
--- clang/test/Driver/vfsoverlay.c
+++ clang/test/Driver/vfsoverlay.c
@@ -1,5 +1,8 @@
 // RUN: %clang -ivfsoverlay foo.h -### %s 2>&1 | FileCheck %s
 // CHECK: "-ivfsoverlay" "foo.h"
 
+// RUN: %clang --vfsoverlay foo.h -### %s 2>&1 | FileCheck %s --check-prefix=CHECK2
+// CHECK2: "--vfsoverlay" "foo.h"
+
 // RUN: not %clang -ivfsoverlay foo.h %s 2>&1 

[clang] df5beeb - [Driver] Add --vfsoverlay flag

2023-02-13 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-13T17:25:45Z
New Revision: df5beebc98bbe76312e3a416d5fbc563c037923c

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

LOG: [Driver] Add --vfsoverlay flag

This flag implies `-ivfsoverlay`, and additionally passes the same
argument to the linker if it supports it. At present the only linker
which does is lld-link, so this functionality has only been added to
the MSVC toolchain. Additionally this option has been made a
CoreOption so that clang-cl can use it without `-Xclang`

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/msvc-link.c
clang/test/Driver/vfsoverlay.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 96904518a51d7..9b7f30454534b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3400,6 +3400,9 @@ def iwithsysroot : JoinedOrSeparate<["-"], 
"iwithsysroot">, Group
   Flags<[CC1Option]>;
 def ivfsoverlay : JoinedOrSeparate<["-"], "ivfsoverlay">, 
Group, Flags<[CC1Option]>,
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system">;
+def vfsoverlay : JoinedOrSeparate<["-", "--"], "vfsoverlay">, 
Flags<[CC1Option, CoreOption]>,
+  HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
+   "Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c97856a47686a..7b91fdf933286 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7038,6 +7038,13 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 A->claim();
   }
 
+  // Forward --vfsoverlay to -cc1.
+  for (const Arg *A : Args.filtered(options::OPT_vfsoverlay)) {
+CmdArgs.push_back("--vfsoverlay");
+CmdArgs.push_back(A->getValue());
+A->claim();
+  }
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 223a4e8a1560f..13a7a2f47cf49 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -312,6 +312,11 @@ void visualstudio::Linker::ConstructJob(Compilation , 
const JobAction ,
   if (Linker.equals_insensitive("lld"))
 Linker = "lld-link";
 
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 86717cc6ebfbf..84b2345266036 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3167,7 +3167,7 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions 
, ArgList ,
 Opts.AddSystemHeaderPrefix(
 A->getValue(), A->getOption().matches(OPT_system_header_prefix));
 
-  for (const auto *A : Args.filtered(OPT_ivfsoverlay))
+  for (const auto *A : Args.filtered(OPT_ivfsoverlay, OPT_vfsoverlay))
 Opts.AddVFSOverlayFile(A->getValue());
 
   return Diags.getNumErrors() == NumErrorsBefore;

diff  --git a/clang/test/Driver/msvc-link.c b/clang/test/Driver/msvc-link.c
index 1ee17fc63c321..52efaf5ece266 100644
--- a/clang/test/Driver/msvc-link.c
+++ b/clang/test/Driver/msvc-link.c
@@ -30,3 +30,9 @@
 // NOREPRO: "-out:msvc-link.exe"
 // NOREPRO: "-nologo"
 // NOREPRO-NOT: "-Brepro"
+
+// RUN: %clang_cl -fuse-ld=lld --vfsoverlay %s -### -- %s 2>&1 | FileCheck 
--check-prefix=VFSOVERLAY %s
+// VFSOVERLAY: -cc1"
+// VFSOVERLAY: "--vfsoverlay"
+// VFSOVERLAY: lld-link"
+// VFSOVERLAY: "/vfsoverlay:

diff  --git a/clang/test/Driver/vfsoverlay.c b/clang/test/Driver/vfsoverlay.c
index 6ae494544f9fd..694cf623c4476 100644
--- a/clang/test/Driver/vfsoverlay.c
+++ b/clang/test/Driver/vfsoverlay.c
@@ -1,5 +1,8 @@
 // RUN: %clang -ivfsoverlay foo.h -### %s 2>&1 | FileCheck %s
 // CHECK: "-ivfsoverlay" "foo.h"
 
+// 

[PATCH] D141775: [Clang] Export CanPassInRegisters as a type trait

2023-02-13 Thread Roy Jacobson 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 rGb6259eca16f6: [Clang] Export CanPassInRegisters as a type 
trait (authored by royjacobson).

Changed prior to commit:
  https://reviews.llvm.org/D141775?vs=491102=497016#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141775

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3055,6 +3055,36 @@
 
 } // namespace is_trivially_relocatable
 
+namespace can_pass_in_regs {
+
+struct A { };
+
+struct B {
+  ~B();
+};
+
+struct C; // expected-note {{forward declaration}}
+
+union D {
+  int x;
+};
+
+static_assert(__can_pass_in_regs(A), "");
+static_assert(__can_pass_in_regs(A), "");
+static_assert(!__can_pass_in_regs(B), "");
+static_assert(__can_pass_in_regs(D), "");
+
+void test_errors() {
+  (void)__can_pass_in_regs(const A); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(A&); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(A&&); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(const A&); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(C); // expected-error {{incomplete type}}
+  (void)__can_pass_in_regs(int); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(int&); // expected-error {{not an unqualified class type}}
+}
+}
+
 struct S {};
 template  using remove_const_t = __remove_const(T);
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4885,6 +4885,7 @@
   case UTT_IsLiteral:
   // By analogy, is_trivially_relocatable imposes the same constraints.
   case UTT_IsTriviallyRelocatable:
+  case UTT_CanPassInRegs:
   // Per the GCC type traits documentation, T shall be a complete type, cv void,
   // or an array of unknown bound. But GCC actually imposes the same constraints
   // as above.
@@ -5373,6 +5374,11 @@
 return T.isTriviallyRelocatableType(C);
   case UTT_IsReferenceable:
 return T.isReferenceable();
+  case UTT_CanPassInRegs:
+if (CXXRecordDecl *RD = T->getAsCXXRecordDecl(); RD && !T.hasQualifiers())
+  return RD->canPassInRegisters();
+Self.Diag(KeyLoc, diag::err_builtin_pass_in_regs_non_class) << T;
+return false;
   }
 }
 
Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -523,6 +523,7 @@
 TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX)
 TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
+TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 
 // Embarcadero Expression Traits
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11794,4 +11794,8 @@
   "change type of '%0' to '%select{std::span|std::array|std::span::iterator}1' to preserve bounds information">;
 def err_loongarch_builtin_requires_la32 : Error<
   "this builtin requires target: loongarch32">;
+
+def err_builtin_pass_in_regs_non_class : Error<
+  "argument %0 is not an unqualified class type">;
+
 } // end of sema component.
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1401,6 +1401,10 @@
 * ``__array_extent(type, dim)`` (Embarcadero):
   The ``dim``'th array bound in the type ``type``, or ``0`` if
   ``dim >= __array_rank(type)``.
+* ``__can_pass_in_regs`` (C++)
+  Returns whether a class can be passed in registers under the current
+  ABI. This type can only be applied to unqualified class types.
+  This is not a portable type trait.
 * ``__has_nothrow_assign`` (GNU, Microsoft, Embarcadero):
   Deprecated, use ``__is_nothrow_assignable`` instead.
 * ``__has_nothrow_move_assign`` (GNU, Microsoft):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b6259ec - [Clang] Export CanPassInRegisters as a type trait

2023-02-13 Thread Roy Jacobson via cfe-commits

Author: Roy Jacobson
Date: 2023-02-13T19:16:23+02:00
New Revision: b6259eca16f6c923d87a1ca1d424931e37d6871a

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

LOG: [Clang] Export CanPassInRegisters as a type trait

While working on D140664, I thought it would be nice to be able to write tests
for parameter passing ABI. Currently we test this by dumping the AST and
matching the results which makes it hard to write new tests.
Adding this builtin will allow writing better ABI tests which
can help improve our coverage in this area.

While less useful, maybe some users would also find it useful for asserting
against pessimisations for their classes.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/TokenKinds.def
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/type-traits.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84d5b0ed98108..20c8bb5de0443 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1401,6 +1401,10 @@ The following type trait primitives are supported by 
Clang. Those traits marked
 * ``__array_extent(type, dim)`` (Embarcadero):
   The ``dim``'th array bound in the type ``type``, or ``0`` if
   ``dim >= __array_rank(type)``.
+* ``__can_pass_in_regs`` (C++)
+  Returns whether a class can be passed in registers under the current
+  ABI. This type can only be applied to unqualified class types.
+  This is not a portable type trait.
 * ``__has_nothrow_assign`` (GNU, Microsoft, Embarcadero):
   Deprecated, use ``__is_nothrow_assignable`` instead.
 * ``__has_nothrow_move_assign`` (GNU, Microsoft):

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9b9ec23a2f21f..b658ad71e63a1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11794,4 +11794,8 @@ def note_unsafe_buffer_variable_fixit : Note<
   "change type of '%0' to '%select{std::span|std::array|std::span::iterator}1' 
to preserve bounds information">;
 def err_loongarch_builtin_requires_la32 : Error<
   "this builtin requires target: loongarch32">;
+
+def err_builtin_pass_in_regs_non_class : Error<
+  "argument %0 is not an unqualified class type">;
+
 } // end of sema component.

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 96feae991ccbc..6d35f1bb31fcd 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -523,6 +523,7 @@ TYPE_TRAIT_1(__is_unbounded_array, IsUnboundedArray, KEYCXX)
 TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX)
 TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
+TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 
 // Embarcadero Expression Traits

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index ef012770747ca..eb9a3e65763f2 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4885,6 +4885,7 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema , 
TypeTrait UTT,
   case UTT_IsLiteral:
   // By analogy, is_trivially_relocatable imposes the same constraints.
   case UTT_IsTriviallyRelocatable:
+  case UTT_CanPassInRegs:
   // Per the GCC type traits documentation, T shall be a complete type, cv 
void,
   // or an array of unknown bound. But GCC actually imposes the same 
constraints
   // as above.
@@ -5373,6 +5374,11 @@ static bool EvaluateUnaryTypeTrait(Sema , TypeTrait 
UTT,
 return T.isTriviallyRelocatableType(C);
   case UTT_IsReferenceable:
 return T.isReferenceable();
+  case UTT_CanPassInRegs:
+if (CXXRecordDecl *RD = T->getAsCXXRecordDecl(); RD && !T.hasQualifiers())
+  return RD->canPassInRegisters();
+Self.Diag(KeyLoc, diag::err_builtin_pass_in_regs_non_class) << T;
+return false;
   }
 }
 

diff  --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index 76a67252c9410..7d425acb56813 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -3055,6 +3055,36 @@ 
static_assert(__is_trivially_relocatable(TrivialAbiNontrivialMoveCtor[]), "");
 
 } // namespace is_trivially_relocatable
 
+namespace can_pass_in_regs {
+
+struct A { };
+
+struct B {
+  ~B();
+};
+
+struct C; // expected-note {{forward declaration}}
+
+union D {
+  int x;
+};
+

[PATCH] D143891: [Clang] Adjust triviality computation in QualType::isTrivialType to C++20 cases.

2023-02-13 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

In D143891#4122731 , @aaron.ballman 
wrote:

> In D143891#4122668 , @royjacobson 
> wrote:
>
>> In D143891#4122660 , 
>> @aaron.ballman wrote:
>>
>>> This is an ABI breaking change, isn't it? (The type trait now returns 
>>> something different than it did before, which could change instantiations 
>>> or object layout.)
>>
>> Technically it is, but it only affects code that relies on constrained 
>> default constructors, which we're only going to support in Clang 16. So if 
>> we backport this to 16 it's not very problematic.
>
> Hmmm, if it's true that this only changes the behavior of a type with a 
> constrained default constructor, then I think it's fine despite being an ABI 
> break (we never claimed full support for concepts, so anyone relying on a 
> particular behavior was mistaken to do that). I can't quite convince myself 
> this doesn't impact other cases though -- the logic for computing triviality 
> is nontrivial itself (pun intended), so I'm really only concerned that 
> `__is_trivial` and friends return a different value for a non-constrained 
> type. However, I also can't come up with a test case whose behavior changes 
> either.

I think this makes sense.




Comment at: clang/lib/AST/Type.cpp:2495
+  // FIXME: We should merge this definition of triviality into
+  // CXXRecordDecl::isTrivial. Currently it computes the wrong thing.
+  return ClassDecl->hasTrivialDefaultConstructor() &&

Will you follow-up this change by updating `CXXRecordDecl::isTrivial` as well 
or is that a more difficult issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143891

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


[PATCH] D142836: [Tooling/Inclusion] Add symbol mappings for `std::experimental::filesystem`

2023-02-13 Thread Younan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4021ed3d79d: [Tooling/Inclusion] Add symbol mappings for 
`std::experimental::filesystem` (authored by zyounan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142836

Files:
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc
  clang/unittests/Tooling/StandardLibraryTest.cpp

Index: clang/unittests/Tooling/StandardLibraryTest.cpp
===
--- clang/unittests/Tooling/StandardLibraryTest.cpp
+++ clang/unittests/Tooling/StandardLibraryTest.cpp
@@ -79,6 +79,23 @@
   EXPECT_FALSE(stdlib::Header::named("", stdlib::Lang::CXX));
 }
 
+TEST(StdlibTest, Experimental) {
+  EXPECT_FALSE(
+  stdlib::Header::named("", stdlib::Lang::C));
+  EXPECT_TRUE(
+  stdlib::Header::named("", stdlib::Lang::CXX));
+
+  auto Symbol = stdlib::Symbol::named("std::experimental::filesystem::",
+  "system_complete");
+  EXPECT_TRUE(Symbol);
+  EXPECT_EQ(Symbol->scope(), "std::experimental::filesystem::");
+  EXPECT_EQ(Symbol->name(), "system_complete");
+  EXPECT_EQ(Symbol->header(),
+stdlib::Header::named(""));
+  EXPECT_EQ(Symbol->qualifiedName(),
+"std::experimental::filesystem::system_complete");
+}
+
 TEST(StdlibTest, CCompat) {
   EXPECT_THAT(
   stdlib::Symbol::named("", "int16_t", stdlib::Lang::CXX)->headers(),
Index: clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc
===
--- /dev/null
+++ clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc
@@ -0,0 +1,54 @@
+// These are derived from N4100[fs.filesystem.synopsis], final
+// draft for experimental filesystem.
+// clang-format off
+SYMBOL(absolute, std::experimental::filesystem::, )
+SYMBOL(canonical, std::experimental::filesystem::, )
+SYMBOL(copy, std::experimental::filesystem::, )
+SYMBOL(copy_file, std::experimental::filesystem::, )
+SYMBOL(copy_options, std::experimental::filesystem::, )
+SYMBOL(copy_symlink, std::experimental::filesystem::, )
+SYMBOL(create_directories, std::experimental::filesystem::, )
+SYMBOL(create_directory, std::experimental::filesystem::, )
+SYMBOL(create_directory_symlink, std::experimental::filesystem::, )
+SYMBOL(create_hard_link, std::experimental::filesystem::, )
+SYMBOL(create_symlink, std::experimental::filesystem::, )
+SYMBOL(current_path, std::experimental::filesystem::, )
+SYMBOL(directory_entry, std::experimental::filesystem::, )
+SYMBOL(directory_iterator, std::experimental::filesystem::, )
+SYMBOL(directory_options, std::experimental::filesystem::, )
+SYMBOL(equivalent, std::experimental::filesystem::, )
+SYMBOL(exists, std::experimental::filesystem::, )
+SYMBOL(file_size, std::experimental::filesystem::, )
+SYMBOL(file_status, std::experimental::filesystem::, )
+SYMBOL(file_time_type, std::experimental::filesystem::, )
+SYMBOL(file_type, std::experimental::filesystem::, )
+SYMBOL(filesystem_error, std::experimental::filesystem::, )
+SYMBOL(hard_link_count, std::experimental::filesystem::, )
+SYMBOL(is_block_file, std::experimental::filesystem::, )
+SYMBOL(is_character_file, std::experimental::filesystem::, )
+SYMBOL(is_directory, std::experimental::filesystem::, )
+SYMBOL(is_empty, std::experimental::filesystem::, )
+SYMBOL(is_fifo, std::experimental::filesystem::, )
+SYMBOL(is_other, std::experimental::filesystem::, )
+SYMBOL(is_regular_file, std::experimental::filesystem::, )
+SYMBOL(is_socket, std::experimental::filesystem::, )
+SYMBOL(is_symlink, std::experimental::filesystem::, )
+SYMBOL(last_write_time, std::experimental::filesystem::, )
+SYMBOL(path, std::experimental::filesystem::, )
+SYMBOL(permissions, std::experimental::filesystem::, )
+SYMBOL(perms, std::experimental::filesystem::, )
+SYMBOL(read_symlink, std::experimental::filesystem::, )
+SYMBOL(recursive_directory_iterator, std::experimental::filesystem::, )
+SYMBOL(remove, std::experimental::filesystem::, )
+SYMBOL(remove_all, std::experimental::filesystem::, )
+SYMBOL(rename, std::experimental::filesystem::, )
+SYMBOL(resize_file, std::experimental::filesystem::, )
+SYMBOL(space, std::experimental::filesystem::, )
+SYMBOL(space_info, std::experimental::filesystem::, )
+SYMBOL(status, std::experimental::filesystem::, )
+SYMBOL(status_known, std::experimental::filesystem::, )
+SYMBOL(symlink_status, std::experimental::filesystem::, )
+SYMBOL(system_complete, std::experimental::filesystem::, )
+SYMBOL(temp_directory_path, std::experimental::filesystem::, )
+SYMBOL(u8path, std::experimental::filesystem::, )
+// clang-format on
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ 

[clang] d4021ed - [Tooling/Inclusion] Add symbol mappings for `std::experimental::filesystem`

2023-02-13 Thread Younan Zhang via cfe-commits

Author: Younan Zhang
Date: 2023-02-14T01:07:39+08:00
New Revision: d4021ed3d79d8823317d894b55f4e6a30cfc3614

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

LOG: [Tooling/Inclusion] Add symbol mappings for `std::experimental::filesystem`

Clangd maintains a symbol map from standard library, in order to prevent
unexpected header/symbol leaks from internal files. (e.g. files under
`bits/` for libstdc++) This symbol map was generated by a python script
that parses pages of offline cppreference archive. The script didn't
handle the case for `std::experimental::`, where most symbols are from
TS. It works well as symbols are directly laid out in the corresponding
header under `experimental` directory for most of time.

However, libstdc++'s implementation split symbols of TS FS into a few
header files located in `experimental/bits`. This would make the code
completion provide internal headers when we simply select the symbols.

There are slightly differences between TS FS and C++17 FS. Some
functions like `system_complete` was replaced by `absolute` and
relative-related operations were introduced later by another proposal.
Even so, all mainstream implementation are based on N4100, the final
filesystem TS draft that was published in 2014 and from which symbols
we've added are exported.

This fixes https://github.com/clangd/clangd/issues/1481

Reviewed By: kadircet

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

Added: 
clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc

Modified: 
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
clang/unittests/Tooling/StandardLibraryTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp 
b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index 2f8537951a0f3..416b53117d16b 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -61,8 +61,9 @@ static int countSymbols(Lang Language) {
 #include "CSymbolMap.inc"
 break;
   case Lang::CXX:
-#include "StdSymbolMap.inc"
 #include "StdSpecialSymbolMap.inc"
+#include "StdSymbolMap.inc"
+#include "StdTsSymbolMap.inc"
 break;
   }
 #undef SYMBOL
@@ -130,8 +131,9 @@ static int initialize(Lang Language) {
 #include "CSymbolMap.inc"
 break;
   case Lang::CXX:
-#include "StdSymbolMap.inc"
 #include "StdSpecialSymbolMap.inc"
+#include "StdSymbolMap.inc"
+#include "StdTsSymbolMap.inc"
 break;
   }
 #undef SYMBOL

diff  --git a/clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc
new file mode 100644
index 0..7fd17ed49c72c
--- /dev/null
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc
@@ -0,0 +1,54 @@
+// These are derived from N4100[fs.filesystem.synopsis], final
+// draft for experimental filesystem.
+// clang-format off
+SYMBOL(absolute, std::experimental::filesystem::, )
+SYMBOL(canonical, std::experimental::filesystem::, )
+SYMBOL(copy, std::experimental::filesystem::, )
+SYMBOL(copy_file, std::experimental::filesystem::, )
+SYMBOL(copy_options, std::experimental::filesystem::, 
)
+SYMBOL(copy_symlink, std::experimental::filesystem::, 
)
+SYMBOL(create_directories, std::experimental::filesystem::, 
)
+SYMBOL(create_directory, std::experimental::filesystem::, 
)
+SYMBOL(create_directory_symlink, std::experimental::filesystem::, 
)
+SYMBOL(create_hard_link, std::experimental::filesystem::, 
)
+SYMBOL(create_symlink, std::experimental::filesystem::, 
)
+SYMBOL(current_path, std::experimental::filesystem::, 
)
+SYMBOL(directory_entry, std::experimental::filesystem::, 
)
+SYMBOL(directory_iterator, std::experimental::filesystem::, 
)
+SYMBOL(directory_options, std::experimental::filesystem::, 
)
+SYMBOL(equivalent, std::experimental::filesystem::, )
+SYMBOL(exists, std::experimental::filesystem::, )
+SYMBOL(file_size, std::experimental::filesystem::, )
+SYMBOL(file_status, std::experimental::filesystem::, )
+SYMBOL(file_time_type, std::experimental::filesystem::, 
)
+SYMBOL(file_type, std::experimental::filesystem::, )
+SYMBOL(filesystem_error, std::experimental::filesystem::, 
)
+SYMBOL(hard_link_count, std::experimental::filesystem::, 
)
+SYMBOL(is_block_file, std::experimental::filesystem::, 
)
+SYMBOL(is_character_file, std::experimental::filesystem::, 
)
+SYMBOL(is_directory, std::experimental::filesystem::, 
)
+SYMBOL(is_empty, std::experimental::filesystem::, )
+SYMBOL(is_fifo, std::experimental::filesystem::, )
+SYMBOL(is_other, std::experimental::filesystem::, )
+SYMBOL(is_regular_file, std::experimental::filesystem::, 
)
+SYMBOL(is_socket, std::experimental::filesystem::, )
+SYMBOL(is_symlink, std::experimental::filesystem::, )
+SYMBOL(last_write_time, 

[PATCH] D143768: [Clang] Add options to disable direct linking of arch tools

2023-02-13 Thread Aaron Siddhartha Mondal via Phabricator via cfe-commits
aaronmondal added a subscriber: aaron.ballman.
aaronmondal added a comment.

Ok so I went over 
https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#testing-for-the-presence-of-a-header-__has_include
 (thanks, @aaron.ballman ) and through the commit history for the amdgpu-arch 
tool.

As I understand, in cases such as standard library headers, these 
`__has_include`s are useful (and are encouraged), (I assume especially for 
header-only libraries). But I'm not convinced that it's the right way to do 
things in the HSA case.

1. If we don't detect this during configuration, we will fail during the build, 
not during configuration. this means that if the hsa CMake package is found but 
the headers are not actually present, we will fail late, potentially *very* 
late in the build.
2. It also seems like the `__has_include`s have continuously been a source of 
confusion, and maybe I'm confused as well, but I think even the current 
implementation after 
https://reviews.llvm.org/rGbfe4514add5b7ab7e1f06248983a7162d734cffb has a bug 
(if DYNAMIC_HSA is not set and hsa is not found, we don't raise a "missing 
hsa.h" error).

@jhuber6 I didn't understand what you mean with linking it into libc. But if 
the performance regression is "ignorable" I'd be in favor of just always using 
`dlopen`.

I also agree with @tianshilei1992 that if this should remain we should 
definitely have configuration for this.

IMO it would be very desirable for every out-of-llvm-tree dependency to be 
checked during configuration. If someone without access to a compile server 
runs an LLVM build that seemingly passes configuration and then fails after 90 
minutes because they had leftover cmake configs their package manager failed to 
clean up it unnecessarily inconveniences the user and we can prevent it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143768

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


[PATCH] D141215: [clang-repl][WIP] Implement pretty printing

2023-02-13 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 497011.
junaire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/Value.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Interpreter/pretty-print.cpp
  clang/tools/clang-repl/CMakeLists.txt
  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
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -18,6 +19,8 @@
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h" // llvm_shutdown
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
@@ -66,6 +69,29 @@
   return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
+static void DeclareMagicFunctions(clang::Interpreter ) {
+  llvm::ArrayRef MagicFunctions = {
+  "void __InterpreterCreateValue(void*, void*, bool);",
+  "void __InterpreterCreateValue(void*, void*, char);",
+  "void __InterpreterCreateValue(void*, void*, signed char);",
+  "void __InterpreterCreateValue(void*, void*, short);",
+  "void __InterpreterCreateValue(void*, void*, int);",
+  "void __InterpreterCreateValue(void*, void*, long);",
+  "void __InterpreterCreateValue(void*, void*, long long);",
+  "void __InterpreterCreateValue(void*, void*, unsigned char);",
+  "void __InterpreterCreateValue(void*, void*, unsigned short);",
+  "void __InterpreterCreateValue(void*, void*, unsigned int);",
+  "void __InterpreterCreateValue(void*, void*, unsigned long);",
+  "void __InterpreterCreateValue(void*, void*, unsigned long long);",
+  "void __InterpreterCreateValue(void*, void*, float);",
+  "void __InterpreterCreateValue(void*, void*, double);",
+  "void __InterpreterCreateValue(void*, void*, void*);"};
+
+  for (llvm::StringRef Function : MagicFunctions) {
+llvm::cantFail(Interp.ParseAndExecute(Function));
+  }
+}
+
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
   ExitOnErr.setBanner("clang-repl: ");
@@ -110,6 +136,7 @@
 
   bool HasError = false;
 
+  DeclareMagicFunctions(*Interp);
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -12,6 +12,7 @@
   )
 
 clang_target_link_libraries(clang-repl PRIVATE
+  clangAST
   clangBasic
   clangFrontend
   clangInterpreter
Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+int x = 42;
+x
+// CHECK: (int) 42
+x - 2
+// CHECK-NEXT: (int) 40
+%quit
+
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -154,10 +154,20 @@
   return true;
 }
 
-bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed) {
+bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed,
+  bool IsTopExpr) {
   if (TryConsumeToken(tok::semi))
 return false;
 
+  // If this is in the incremental C++ mode, then it means we need to pretty
+  // print this expression. Thus, let's pretend we have this semi and continue
+  // parsing.
+  if (PP.isIncrementalProcessingEnabled() && IsTopExpr &&
+  DiagID == diag::err_expected_semi_after_expr) {
+setPrettyPrintMode();
+return false;
+  }
+
   if (Tok.is(tok::code_completion)) {
 handleUnexpectedCodeCompletionToken();
 return false;
Index: clang/lib/Parse/ParseStmt.cpp

[PATCH] D141666: [RISCV] Proper support of extensions Zicsr and Zifencei

2023-02-13 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

JFYI, I have a change out which just documents current status while we wait for 
a resolution.  https://reviews.llvm.org/D143924


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141666

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


[PATCH] D143439: [RISCV] Add vendor-defined XTheadBb (basic bit-manipulation) extension

2023-02-13 Thread Philipp Tomsich via Phabricator via cfe-commits
philipp.tomsich marked 4 inline comments as done.
philipp.tomsich added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:315
+  if (Subtarget.hasVendorXTHeadBb()) {
+setOperationAction({ISD::CTLZ}, XLenVT, Legal);
+

inclyc wrote:
> It looks like this line of code will cause compilation warning.
> 
> ```
> [1677/1717] Building CXX object 
> lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVISelLowering.cpp.o
> /tmp/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp:315:24: 
> warning: braces around scalar initializer [-Wbraced-scalar-init]
> setOperationAction({ISD::CTLZ}, XLenVT, Legal);
>^~~
> 1 warning generated.
> [1717/1717] Creating library symlink lib/libclang-cpp.so
> [1542/1716] Building CXX object 
> lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVISelLowering.cpp.o
> /tmp/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp:315:24: 
> warning: braces around scalar initializer [-Wbraced-scalar-init]
> setOperationAction({ISD::CTLZ}, XLenVT, Legal);
>^~~
> 1 warning generated.
> [1716/1716] Linking C executable bin/mlir-capi-execution-engine-test
> ```
Thanks. I'll push a NFC commit to fix this, as soon as my testrun completes.
Interesting that I don't see this warning on my build ... will dig to make sure 
that we are not missing anything in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143439

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


[PATCH] D143439: [RISCV] Add vendor-defined XTheadBb (basic bit-manipulation) extension

2023-02-13 Thread Yingchi Long via Phabricator via cfe-commits
inclyc added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:320
+if (Subtarget.is64Bit())
+  setOperationAction({ISD::CTLZ, ISD::CTLZ_ZERO_UNDEF}, MVT::i32, Custom);
+  }

inclyc wrote:
> And this one
Ah, this is my fault :(. There should be only 1 warning on line 315


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143439

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


[PATCH] D143439: [RISCV] Add vendor-defined XTheadBb (basic bit-manipulation) extension

2023-02-13 Thread Yingchi Long via Phabricator via cfe-commits
inclyc added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:315
+  if (Subtarget.hasVendorXTHeadBb()) {
+setOperationAction({ISD::CTLZ}, XLenVT, Legal);
+

It looks like this line of code will cause compilation warning.

```
[1677/1717] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVISelLowering.cpp.o
/tmp/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp:315:24: warning: 
braces around scalar initializer [-Wbraced-scalar-init]
setOperationAction({ISD::CTLZ}, XLenVT, Legal);
   ^~~
1 warning generated.
[1717/1717] Creating library symlink lib/libclang-cpp.so
[1542/1716] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVISelLowering.cpp.o
/tmp/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp:315:24: warning: 
braces around scalar initializer [-Wbraced-scalar-init]
setOperationAction({ISD::CTLZ}, XLenVT, Legal);
   ^~~
1 warning generated.
[1716/1716] Linking C executable bin/mlir-capi-execution-engine-test
```



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:320
+if (Subtarget.is64Bit())
+  setOperationAction({ISD::CTLZ, ISD::CTLZ_ZERO_UNDEF}, MVT::i32, Custom);
+  }

And this one


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143439

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


[PATCH] D143921: [debug-info][codegen] Prevent creation of self-referential SP node

2023-02-13 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

Any testing suggestions here? I can use what we have on GH (cpp -> codegen 
test), but I'm not sure if there's a finer grained test we could use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143921

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


[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-02-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 2 inline comments as done.
pmatos added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:7269
+  }
+  Attrs[NewAttrKind] = true;
+

aaron.ballman wrote:
> aaron.ballman wrote:
> > This seems like it's not used.
> Still wondering about this
That's correct - removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-02-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 497004.
pmatos added a comment.

Remove unnecessary code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Format/FormatToken.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/wasm-funcref.c
  clang/test/Parser/wasm-funcref.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388587)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388586)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x7FFFEA>();
+  correct<0x7FFFE9>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650L>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/Sema/wasm-refs.c
===
--- clang/test/Sema/wasm-refs.c
+++ clang/test/Sema/wasm-refs.c
@@ -46,6 +46,8 @@
 __externref_t ***illegal_return_2(); // expected-error {{pointer to WebAssembly reference type is not allowed}}
 
 void varargs(int, ...);
+typedef void (*__funcref funcref_t)();
+typedef void (*__funcref __funcref funcref_fail_t)(); // expected-warning {{attribute '__funcref' is already applied}}
 
 __externref_t func(__externref_t ref) {
// expected-error {{cannot take address of WebAssembly reference}}
@@ -67,5 +69,7 @@
   _Alignof(__externref_t ***);   // expected-error {{pointer to WebAssembly reference type is not allowed}};
   varargs(1, ref);   // expected-error {{cannot pass expression of type '__externref_t' to variadic function}}
 
+  funcref_t func = __builtin_wasm_ref_null_func(0); // expected-error {{too many arguments to function call, expected 0, have 1}}
+
   return ref;
 }
Index: clang/test/Parser/wasm-funcref.c
===
--- /dev/null
+++ clang/test/Parser/wasm-funcref.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple powerpc-linux-gnu -fsyntax-only -verify %s
+
+// Test that we trigger an error at parse time if using keyword funcref
+// while not using a wasm triple.
+typedef void (*__funcref funcref_t)(); // expected-error {{invalid use of '__funcref' keyword outside the WebAssembly triple}}
+typedef int (*__funcref fn_funcref_t)(int);// expected-error {{invalid use of '__funcref' keyword outside the WebAssembly triple}}
+typedef int (*fn_t)(int);
+
+static fn_funcref_t nullFuncref = 0;
Index: clang/test/CodeGen/WebAssembly/wasm-funcref.c
===
--- /dev/null
+++ clang/test/CodeGen/WebAssembly/wasm-funcref.c
@@ -0,0 +1,99 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple wasm32 -target-feature +reference-types -o - -emit-llvm %s | FileCheck %s
+
+typedef void (*__funcref funcref_t)();
+typedef int (*__funcref fn_funcref_t)(int);
+typedef int (*fn_t)(int);
+
+// Null funcref builtin call
+// CHECK-LABEL: @get_null(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call ptr addrspace(20) @llvm.wasm.ref.null.func()
+// CHECK-NEXT:ret ptr addrspace(20) [[TMP0]]
+//
+funcref_t get_null() {
+  return 

[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-02-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 497002.
pmatos marked 2 inline comments as done.
pmatos added a comment.

Further refinement of the patch with more diagnostics tested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Format/FormatToken.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/wasm-funcref.c
  clang/test/Parser/wasm-funcref.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388587)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388586)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x7FFFEA>();
+  correct<0x7FFFE9>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650L>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/Sema/wasm-refs.c
===
--- clang/test/Sema/wasm-refs.c
+++ clang/test/Sema/wasm-refs.c
@@ -46,6 +46,8 @@
 __externref_t ***illegal_return_2(); // expected-error {{pointer to WebAssembly reference type is not allowed}}
 
 void varargs(int, ...);
+typedef void (*__funcref funcref_t)();
+typedef void (*__funcref __funcref funcref_fail_t)(); // expected-warning {{attribute '__funcref' is already applied}}
 
 __externref_t func(__externref_t ref) {
// expected-error {{cannot take address of WebAssembly reference}}
@@ -67,5 +69,7 @@
   _Alignof(__externref_t ***);   // expected-error {{pointer to WebAssembly reference type is not allowed}};
   varargs(1, ref);   // expected-error {{cannot pass expression of type '__externref_t' to variadic function}}
 
+  funcref_t func = __builtin_wasm_ref_null_func(0); // expected-error {{too many arguments to function call, expected 0, have 1}}
+
   return ref;
 }
Index: clang/test/Parser/wasm-funcref.c
===
--- /dev/null
+++ clang/test/Parser/wasm-funcref.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple powerpc-linux-gnu -fsyntax-only -verify %s
+
+// Test that we trigger an error at parse time if using keyword funcref
+// while not using a wasm triple.
+typedef void (*__funcref funcref_t)(); // expected-error {{invalid use of '__funcref' keyword outside the WebAssembly triple}}
+typedef int (*__funcref fn_funcref_t)(int);// expected-error {{invalid use of '__funcref' keyword outside the WebAssembly triple}}
+typedef int (*fn_t)(int);
+
+static fn_funcref_t nullFuncref = 0;
Index: clang/test/CodeGen/WebAssembly/wasm-funcref.c
===
--- /dev/null
+++ clang/test/CodeGen/WebAssembly/wasm-funcref.c
@@ -0,0 +1,99 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple wasm32 -target-feature +reference-types -o - -emit-llvm %s | FileCheck %s
+
+typedef void (*__funcref funcref_t)();
+typedef int (*__funcref fn_funcref_t)(int);
+typedef int (*fn_t)(int);
+
+// Null funcref builtin call
+// CHECK-LABEL: @get_null(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call ptr addrspace(20) @llvm.wasm.ref.null.func()
+// CHECK-NEXT:ret ptr 

[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-02-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 4 inline comments as done.
pmatos added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:6696
+bool Sema::BuiltinWasmRefNullFunc(CallExpr *TheCall) {
+  if (TheCall->getNumArgs() != 0)
+return true;

erichkeane wrote:
> Does this diagnose?  Should we be emitting an error here?
I think it makes sense. Will add a test as well for the diagnostic.



Comment at: clang/lib/Sema/SemaChecking.cpp:6557-6561
+  // Therefore we need to change the types of the DeclRefExpr (stored in FDecl)
+  // and regenerate a straight up CallExpr on the modified FDecl.
+  // returning
+  // CallExpr
+  // `- FunctionDecl

aaron.ballman wrote:
> Why would we need to do this?? And what do we do when there is no 
> `FunctionDecl` to get back to (because it's a call expression through a 
> function pointer, for example)?
I have added a test to check this situation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D143921: [debug-info][codegen] Prevent creation of self-referential SP node

2023-02-13 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve created this revision.
Herald added subscribers: jdoerfert, hiraditya.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

The function `CGDebugInfo::EmitFunctionDecl` is supposed to create a
declaration -- never a _definition_ -- of a subprogram. This is made
evident by the fact that the SPFlags never have the "Declaration" bit
set by that function.

However, when `EmitFunctionDecl` calls `DIBuilder::createFunction`, it
still tries to fill the "Declaration" argument by passing it the result
of `getFunctionDeclaration(D)`. This will query an internal cache of
previously created declarations and, for most code paths, we return
nullptr; all is good.

However, as reported in [0], there are pathological cases in which we
attempt to recreate a declaration, so the cache query succeeds,
resulting in a subprogram declaration whose declaration field points to
another declaration. Through a series of RAUWs, the declaration field
ends up pointing to the SP itself. Self-referential MDNodes can't be
`unique`, which causes the verifier to fail (declarations must be
`unique`).

We can argue that the caller should check the cache first, but this is
not a correctness issue (declarations are `unique` anyway). The bug is
that `CGDebugInfo::EmitFunctionDecl` should always pass `nullptr` to the
declaration argument of `DIBuilder::createFunction`, expressing the fact
that declarations don't point to other declarations. AFAICT this is not
something for which any reasonable meaning exists.

This seems a lot like a copy-paste mistake that has survived for ~10
years, since other places in this file have the exact same call almost
token-by-token.

I've tested this by compiling LLVMSupport with and without the patch, O2 

and O0, and comparing the dwarfdump of the lib. The dumps are identical
modulo the attributes decl_file/producer/comp_dir.

[0]: https://github.com/llvm/llvm-project/issues/59241


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143921

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  llvm/docs/LangRef.rst
  llvm/lib/IR/Verifier.cpp


Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1400,6 +1400,8 @@
   } else {
 // Subprogram declarations (part of the type hierarchy).
 CheckDI(!Unit, "subprogram declarations must not have a compile unit", );
+CheckDI(!N.getRawDeclaration(),
+"subprogram declaration must not have a declaration field");
   }
 
   if (auto *RawThrownTypes = N.getRawThrownTypes()) {
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -5772,11 +5772,12 @@
 
 .. _DISubprogramDeclaration:
 
-When ``isDefinition: false``, subprograms describe a declaration in the type
-tree as opposed to a definition of a function.  If the scope is a composite
-type with an ODR ``identifier:`` and that does not set ``flags: DIFwdDecl``,
-then the subprogram declaration is uniqued based only on its ``linkageName:``
-and ``scope:``.
+When ``spFlags: DISPFlagDefinition`` is not present, subprograms describe a
+declaration in the type tree as opposed to a definition of a function. In this
+case, the ``declaration`` field must be empty. If the scope is a composite type
+with an ODR ``identifier:`` and that does not set ``flags: DIFwdDecl``, then
+the subprogram declaration is uniqued based only on its ``linkageName:`` and
+``scope:``.
 
 .. code-block:: text
 
@@ -5785,9 +5786,9 @@
 }
 
 !0 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
-file: !2, line: 7, type: !3, isLocal: true,
-isDefinition: true, scopeLine: 8,
-containingType: !4,
+file: !2, line: 7, type: !3,
+spFlags: DISPFlagDefinition | 
DISPFlagLocalToUnit,
+scopeLine: 8, containingType: !4,
 virtuality: DW_VIRTUALITY_pure_virtual,
 virtualIndex: 10, flags: DIFlagPrototyped,
 isOptimized: true, unit: !5, templateParams: 
!6,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4217,7 +4217,7 @@
   llvm::DISubprogram *SP =
   DBuilder.createFunction(FDContext, Name, LinkageName, Unit, LineNo, STy,
   ScopeLine, Flags, SPFlags, TParamsArray.get(),
-  getFunctionDeclaration(D), nullptr, Annotations);
+   

[PATCH] D143920: [clang][dataflow] Change `transfer` API to take a reference.

2023-02-13 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: xazax.hun, gribozavr2.
Herald added subscribers: martong, rnkovacs.
Herald added a reviewer: NoQ.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

The provided `CFGElement` is never null, so a reference is a more precise type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143920

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h
  
clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h
  clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
  clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
  clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -112,7 +112,7 @@
 
   static NonConvergingLattice initialElement() { return {0}; }
 
-  void transfer(const CFGElement *, NonConvergingLattice , Environment &) {
+  void transfer(const CFGElement &, NonConvergingLattice , Environment &) {
 ++E.State;
   }
 };
@@ -194,8 +194,8 @@
 
   static FunctionCallLattice initialElement() { return {}; }
 
-  void transfer(const CFGElement *Elt, FunctionCallLattice , Environment &) {
-auto CS = Elt->getAs();
+  void transfer(const CFGElement , FunctionCallLattice , Environment &) {
+auto CS = Elt.getAs();
 if (!CS)
   return;
 const auto *S = CS->getStmt();
@@ -350,8 +350,8 @@
 
   static NoopLattice initialElement() { return {}; }
 
-  void transfer(const CFGElement *Elt, NoopLattice &, Environment ) {
-auto CS = Elt->getAs();
+  void transfer(const CFGElement , NoopLattice &, Environment ) {
+auto CS = Elt.getAs();
 if (!CS)
   return;
 const auto *S = CS->getStmt();
@@ -508,8 +508,8 @@
 
   static NoopLattice initialElement() { return {}; }
 
-  void transfer(const CFGElement *Elt, NoopLattice &, Environment ) {
-auto CS = Elt->getAs();
+  void transfer(const CFGElement , NoopLattice &, Environment ) {
+auto CS = Elt.getAs();
 if (!CS)
   return;
 const Stmt *S = CS->getStmt();
@@ -1202,8 +1202,8 @@
 
   static NoopLattice initialElement() { return {}; }
 
-  void transfer(const CFGElement *Elt, NoopLattice &, Environment ) {
-auto CS = Elt->getAs();
+  void transfer(const CFGElement , NoopLattice &, Environment ) {
+auto CS = Elt.getAs();
 if (!CS)
   return;
 const Stmt *S = CS->getStmt();
Index: clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp
@@ -44,7 +44,7 @@
   explicit TestPropagationAnalysis(ASTContext )
   : DataflowAnalysis(Context) {}
   static TestLattice initialElement() { return TestLattice::bottom(); }
-  void transfer(const CFGElement *, TestLattice &, Environment &) {}
+  void transfer(const CFGElement &, TestLattice &, Environment &) {}
   void transferBranch(bool Branch, const Stmt *S, TestLattice ,
   Environment ) {
 L.Branch = Branch;
Index: clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
@@ -124,9 +124,9 @@
 return ConstantPropagationLattice::bottom();
   }
 
-  void transfer(const CFGElement *E, ConstantPropagationLattice ,
+  void transfer(const CFGElement , ConstantPropagationLattice ,
 Environment ) {
-auto CS = E->getAs();
+auto CS = E.getAs();
 if (!CS)
   return;
 auto S = CS->getStmt();
Index: clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
@@ -330,9 +330,9 @@
 
   static NoopLattice initialElement() { 

[PATCH] D143851: [clang-tidy] Tweak 'rule of 3/5' checks to allow defaulting a destructor outside the class.

2023-02-13 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 496998.
royjacobson added a comment.

Address CR comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143851

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/special-member-functions.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-cxx-03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-relaxed.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions.cpp
@@ -3,7 +3,7 @@
 class DefinesDestructor {
   ~DefinesDestructor();
 };
-// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
 
 class DefinesDefaultedDestructor {
   ~DefinesDefaultedDestructor() = default;
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-relaxed.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-relaxed.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-relaxed.cpp
@@ -1,14 +1,26 @@
 // RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t -- -config="{CheckOptions: [{key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions, value: true}, {key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor, value: true}]}" --
 
+// Don't warn on destructors without definitions, they might be defaulted in another TU.
+class DeclaresDestructor {
+  ~DeclaresDestructor();
+};
+
 class DefinesDestructor {
   ~DefinesDestructor();
 };
-// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a non-default destructor but does not define a copy constructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
+DefinesDestructor::~DefinesDestructor() {}
+// CHECK-MESSAGES: [[@LINE-4]]:7: warning: class 'DefinesDestructor' defines a non-default destructor but does not define a copy constructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
 
 class DefinesDefaultedDestructor {
   ~DefinesDefaultedDestructor() = default;
 };
 
+class DefinesDefaultedDestructorOutside {
+  ~DefinesDefaultedDestructorOutside();
+};
+
+DefinesDefaultedDestructorOutside::~DefinesDefaultedDestructorOutside() = default;
+
 class DefinesCopyConstructor {
   DefinesCopyConstructor(const DefinesCopyConstructor &);
 };
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-cxx-03.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-cxx-03.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-cxx-03.cpp
@@ -3,7 +3,7 @@
 class DefinesDestructor {
   ~DefinesDestructor();
 };
-// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a non-default destructor but does not define a copy constructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a destructor but does not define a copy constructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
 
 class DefinesCopyConstructor {
   DefinesCopyConstructor(const DefinesCopyConstructor &);
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/special-member-functions.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/special-member-functions.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/special-member-functions.rst
@@ -25,15 +25,25 @@
 
 .. option:: AllowSoleDefaultDtor
 
-   When set to `true` (default is `false`), this check doesn't flag classes with a sole, explicitly
-   defaulted destructor. An example for such a class is:
+   

[PATCH] D143763: [Clang] Add clangMinimumVersion to multilib.yaml

2023-02-13 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

No objections to MaskRay's suggestion to merge with an earlier patch. I've made 
some suggestions to make the error messages be a bit more specific about what 
is wrong.




Comment at: clang/lib/Driver/Multilib.cpp:185
+if (M.ClangMinimumVersion.empty())
+  return "missing required key 'clangMinimumVersion'";
+

Perhaps
"missing required key 'clangMinimumVersion' expect MAJOR.MINOR.PATCHLEVEL" to 
give an idea what the key is expecting?



Comment at: clang/lib/Driver/Multilib.cpp:195
+if (MinVerStrings.size() != 3)
+  return "not a valid version string \"" + M.ClangMinimumVersion + "\"";
+

Can we add why the version string isn't valid? For example "expected format 
MAJOR.MINOR.PATCHLEVEL got " + M.CLangMinimumVersion ...





Comment at: clang/lib/Driver/Multilib.cpp:200
+  if (S.getAsInteger(10, V))
+return "not a valid version string \"" + M.ClangMinimumVersion + "\"";
+  ClangMinimumVersion.push_back(V);

Similarly, can we say what we were expecting. For example all components must 
be decimal integers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143763

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


  1   2   >