[PATCH] D157332: [clang] Make init for empty no_unique_address fields a no-op write

2023-08-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I see what you're getting at here... but I don't think this works quite right.  
If the empty class has a non-trivial constructor, we have to pass the correct 
"this" address to that constructor.  Usually a constructor for an empty class 
won't do anything with that address, but it could theoretically do something 
with it.

In order to preserve the address in the cases we need it, we need a different 
invariant: the handling for each aggregate expression in EmitAggExpr needs to 
ensure it doesn't store anything to an empty class.  Which is unfortunately 
more fragile than I'd like, but I can't think of a better approach.  This check 
needs to happen further down the call stack.  Maybe put it in 
CodeGenFunction::EmitCall.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157332

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


[PATCH] D157362: [RISCV] Add Zicfilp extension.

2023-08-07 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 created this revision.
fakepaper56 added reviewers: craig.topper, reames, frasercrmck, rogfer01, asb.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, jdoerfert, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, 
arichardson.
Herald added a project: All.
fakepaper56 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wangpc, eopXD, MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157362

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
@@ -299,3 +299,6 @@
 
 .attribute arch, "rv32i_xcvbi"
 # CHECK: attribute  5, "rv32i2p1_xcvbi1p0"
+
+.attribute arch, "rv32i_zicfilp0p2"
+# CHECK: attribute  5, "rv32i2p1_zicfilp0p2"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -86,6 +86,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFMIN %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFWMA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zacas %s -o - | FileCheck --check-prefix=RV32ZACAS %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV32ZICFILP %s
 
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s
@@ -174,6 +175,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFMIN %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFWMA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zacas %s -o - | FileCheck --check-prefix=RV64ZACAS %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV64ZICFILP %s
 
 ; CHECK: .attribute 4, 16
 
@@ -262,6 +264,7 @@
 ; RV32ZVFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvl32b1p0"
 ; RV32ZVFBFWMA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvfbfwma0p8_zvl32b1p0"
 ; RV32ZACAS: .attribute 5, "rv32i2p1_a2p1_zacas1p0"
+; RV32ZICFILP: .attribute 5, "rv32i2p1_zicfilp0p2"
 
 ; RV64M: .attribute 5, "rv64i2p1_m2p0"
 ; RV64ZMMUL: .attribute 5, "rv64i2p1_zmmul1p0"
@@ -349,6 +352,7 @@
 ; RV64ZVFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvl32b1p0"
 ; RV64ZVFBFWMA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvfbfwma0p8_zvl32b1p0"
 ; RV64ZACAS: .attribute 5, "rv64i2p1_a2p1_zacas1p0"
+; RV64ZICFILP: .attribute 5, "rv64i2p1_zicfilp0p2"
 
 define i32 @addi(i32 %a) {
   %1 = add i32 %a, 1
Index: llvm/lib/Target/RISCV/RISCVFeatures.td
===
--- llvm/lib/Target/RISCV/RISCVFeatures.td
+++ llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -647,6 +647,13 @@
"other extensions: Zvks and Zvkg.",
[FeatureStdExtZvks, FeatureStdExtZvkg]>;
 
+def FeatureStdExtZicfilp
+: SubtargetFeature<"experimental-zicfilp", "HasStdExtZicfilp", "true",
+   "'Zicfilp' (Landing pad)">;
+def HasStdExtZicfilp : Predicate<"Subtarget->hasStdExtZicfilp()">,
+ AssemblerPredicate<(all_of FeatureStdExtZicfilp),
+ "'Zicfilp' (Landing pad)">;
+
 def FeatureStdExtZicond
 : SubtargetFeature<"experimental-zicond", "HasStdExtZicond", "true",
"'Zicond' (Integer Conditional Operations)">;
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -167,6 +167,7 @@
 {"zfa", RISCVExtensionVersion{0, 2}},
 {"zfbfmin", RISCVExtensionVersion{0, 8}},
 
+{"zicfilp", RISCVExtensionVersion{0, 2}},
 {"zicond", RISCVExtensionVersion{1, 0}},
 
 {"zihintntl", RISCVExtensionVersion{0, 2}},
Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ 

[PATCH] D157119: cmake: add missing dependencies on ClangDriverOptions tablegen

2023-08-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.



>   How to reproduce locally: 
> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild

Does not reproduce on my workstation too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157119

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


[PATCH] D157353: [RISCV] Remove pre-defined macro test for b extension. NFC.

2023-08-07 Thread Jim Lin 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 rG767ca3a70d6d: [RISCV] Remove pre-defined macro test for b 
extension. NFC. (authored by Jim).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157353

Files:
  clang/test/Preprocessor/riscv-target-features.c


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -16,8 +16,6 @@
 // CHECK-NOT: __riscv_fsqrt {{.*$}}
 // CHECK-NOT: __riscv_c {{.*$}}
 // CHECK-NOT: __riscv_compressed {{.*$}}
-// CHECK-NOT: __riscv_b {{.*$}}
-// CHECK-NOT: __riscv_bitmanip {{.*$}}
 // CHECK-NOT: __riscv_zihintntl {{.*$}}
 // CHECK-NOT: __riscv_zba {{.*$}}
 // CHECK-NOT: __riscv_zbb {{.*$}}
@@ -165,7 +163,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izba -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBA-EXT %s
-// CHECK-ZBA-NOT: __riscv_b
 // CHECK-ZBA-EXT: __riscv_zba 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -180,7 +177,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbb -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
-// CHECK-ZBB-NOT: __riscv_b
 // CHECK-ZBB-EXT: __riscv_zbb 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -195,7 +191,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbc -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
-// CHECK-ZBC-NOT: __riscv_b
 // CHECK-ZBC-EXT: __riscv_zbc 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -210,7 +205,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbs -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBS-EXT %s
-// CHECK-ZBS-NOT: __riscv_b
 // CHECK-ZBS-EXT: __riscv_zbs 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -16,8 +16,6 @@
 // CHECK-NOT: __riscv_fsqrt {{.*$}}
 // CHECK-NOT: __riscv_c {{.*$}}
 // CHECK-NOT: __riscv_compressed {{.*$}}
-// CHECK-NOT: __riscv_b {{.*$}}
-// CHECK-NOT: __riscv_bitmanip {{.*$}}
 // CHECK-NOT: __riscv_zihintntl {{.*$}}
 // CHECK-NOT: __riscv_zba {{.*$}}
 // CHECK-NOT: __riscv_zbb {{.*$}}
@@ -165,7 +163,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izba -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBA-EXT %s
-// CHECK-ZBA-NOT: __riscv_b
 // CHECK-ZBA-EXT: __riscv_zba 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -180,7 +177,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbb -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
-// CHECK-ZBB-NOT: __riscv_b
 // CHECK-ZBB-EXT: __riscv_zbb 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -195,7 +191,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbc -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
-// CHECK-ZBC-NOT: __riscv_b
 // CHECK-ZBC-EXT: __riscv_zbc 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -210,7 +205,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbs -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBS-EXT %s
-// CHECK-ZBS-NOT: __riscv_b
 // CHECK-ZBS-EXT: __riscv_zbs 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 767ca3a - [RISCV] Remove pre-defined macro test for b extension. NFC.

2023-08-07 Thread Jim Lin via cfe-commits

Author: Jim Lin
Date: 2023-08-08T13:01:34+08:00
New Revision: 767ca3a70d6d60bd52ff0829335942aa6dafcc28

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

LOG: [RISCV] Remove pre-defined macro test for b extension. NFC.

B extension has been removed.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 2361ec70a5609c..dcf62e76149ccd 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -16,8 +16,6 @@
 // CHECK-NOT: __riscv_fsqrt {{.*$}}
 // CHECK-NOT: __riscv_c {{.*$}}
 // CHECK-NOT: __riscv_compressed {{.*$}}
-// CHECK-NOT: __riscv_b {{.*$}}
-// CHECK-NOT: __riscv_bitmanip {{.*$}}
 // CHECK-NOT: __riscv_zihintntl {{.*$}}
 // CHECK-NOT: __riscv_zba {{.*$}}
 // CHECK-NOT: __riscv_zbb {{.*$}}
@@ -165,7 +163,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izba -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBA-EXT %s
-// CHECK-ZBA-NOT: __riscv_b
 // CHECK-ZBA-EXT: __riscv_zba 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -180,7 +177,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbb -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
-// CHECK-ZBB-NOT: __riscv_b
 // CHECK-ZBB-EXT: __riscv_zbb 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -195,7 +191,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbc -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
-// CHECK-ZBC-NOT: __riscv_b
 // CHECK-ZBC-EXT: __riscv_zbc 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -210,7 +205,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbs -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBS-EXT %s
-// CHECK-ZBS-NOT: __riscv_b
 // CHECK-ZBS-EXT: __riscv_zbs 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \



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


[PATCH] D157119: cmake: add missing dependencies on ClangDriverOptions tablegen

2023-08-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D157119#4565993 , @jroelofs wrote:

> In D157119#4564546 , @vitalybuka 
> wrote:
>
>> I suspect one of your recent changes broke 
>> https://lab.llvm.org/buildbot/#/builders/168/builds/14944
>> Can you please take a look?
>
> Happy to take a look, but there are 28 commits in the blame list for that 
> build... what makes you suspect it's the one change that only *adds* build 
> dependencies?  ISTM the `clangd` binary should be bit-identical before/after 
> this change, right?

Just 3 mention clangd

> I can't reproduce the failure locally.

Have you tried instruction in the error report:

  How to reproduce locally: 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild



> Do we have a way to re-trigger that job for specific commits & bisect the 
> blame list?

Another easy ways are:

1. trigger from buildbot, but I don't know you need special permision for that
2. revert, see if it helps, and reland if it's not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157119

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


[PATCH] D157076: [clang][ExtractAPI] Add support for C++ class templates and concepts

2023-08-07 Thread Erick Velez via Phabricator via cfe-commits
evelez7 updated this revision to Diff 548042.
evelez7 added a comment.

Add brackets for SerializerBase visit methods


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157076

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/class_template.cpp
  clang/test/ExtractAPI/class_template_partial_spec.cpp
  clang/test/ExtractAPI/class_template_spec.cpp
  clang/test/ExtractAPI/concept.cpp

Index: clang/test/ExtractAPI/concept.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/concept.cpp
@@ -0,0 +1,133 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -std=c++20 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template concept Foo = true;
+
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "keyword",
+  "spelling": "typename"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "genericParameter",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": "> "
+},
+{
+  "kind": "keyword",
+  "spelling": "concept"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@CT@Foo"
+  },
+  "kind": {
+"displayName": "Concept",
+"identifier": "c++.concept"
+  },
+  "location": {
+"position": {
+  "character": 30,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ],
+  "swiftGenerics": {
+"parameters": [
+  {
+"depth": 0,
+"index": 0,
+"name": "T"
+  }
+]
+  }
+}
+  ]
+}
Index: clang/test/ExtractAPI/class_template_spec.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/class_template_spec.cpp
@@ -0,0 +1,206 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template class Foo {};
+
+template<> class Foo {};
+
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+  

[PATCH] D157353: [RISCV] Remove pre-defined macro test for b extension. NFC.

2023-08-07 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/D157353/new/

https://reviews.llvm.org/D157353

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


[PATCH] D157353: [RISCV] Remove pre-defined macro test for b extension. NFC.

2023-08-07 Thread Jim Lin via Phabricator via cfe-commits
Jim created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, benna, psnobl, jocewei, PkmX, 
the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
Jim requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD.
Herald added a project: clang.

B extension has been removed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157353

Files:
  clang/test/Preprocessor/riscv-target-features.c


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -16,8 +16,6 @@
 // CHECK-NOT: __riscv_fsqrt {{.*$}}
 // CHECK-NOT: __riscv_c {{.*$}}
 // CHECK-NOT: __riscv_compressed {{.*$}}
-// CHECK-NOT: __riscv_b {{.*$}}
-// CHECK-NOT: __riscv_bitmanip {{.*$}}
 // CHECK-NOT: __riscv_zihintntl {{.*$}}
 // CHECK-NOT: __riscv_zba {{.*$}}
 // CHECK-NOT: __riscv_zbb {{.*$}}
@@ -165,7 +163,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izba -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBA-EXT %s
-// CHECK-ZBA-NOT: __riscv_b
 // CHECK-ZBA-EXT: __riscv_zba 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -180,7 +177,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbb -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
-// CHECK-ZBB-NOT: __riscv_b
 // CHECK-ZBB-EXT: __riscv_zbb 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -195,7 +191,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbc -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
-// CHECK-ZBC-NOT: __riscv_b
 // CHECK-ZBC-EXT: __riscv_zbc 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -210,7 +205,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbs -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBS-EXT %s
-// CHECK-ZBS-NOT: __riscv_b
 // CHECK-ZBS-EXT: __riscv_zbs 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -16,8 +16,6 @@
 // CHECK-NOT: __riscv_fsqrt {{.*$}}
 // CHECK-NOT: __riscv_c {{.*$}}
 // CHECK-NOT: __riscv_compressed {{.*$}}
-// CHECK-NOT: __riscv_b {{.*$}}
-// CHECK-NOT: __riscv_bitmanip {{.*$}}
 // CHECK-NOT: __riscv_zihintntl {{.*$}}
 // CHECK-NOT: __riscv_zba {{.*$}}
 // CHECK-NOT: __riscv_zbb {{.*$}}
@@ -165,7 +163,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izba -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBA-EXT %s
-// CHECK-ZBA-NOT: __riscv_b
 // CHECK-ZBA-EXT: __riscv_zba 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -180,7 +177,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbb -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
-// CHECK-ZBB-NOT: __riscv_b
 // CHECK-ZBB-EXT: __riscv_zbb 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -195,7 +191,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbc -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
-// CHECK-ZBC-NOT: __riscv_b
 // CHECK-ZBC-EXT: __riscv_zbc 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
@@ -210,7 +205,6 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu \
 // RUN: -march=rv64izbs -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZBS-EXT %s
-// CHECK-ZBS-NOT: __riscv_b
 // CHECK-ZBS-EXT: __riscv_zbs 100{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-08-07 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142609#4566418 , @aaron.ballman 
wrote:

> Concerns have been raised in 
> https://github.com/llvm/llvm-project/issues/64356 that this is an undesirable 
> change in diagnostic behavior. The diagnostic is supposed to fire when 
> misusing a logical operand that most likely should have been a bitwise 
> operand. There's a feeling that `true && expr` is plausibly done 
> intentionally more often than `true & expr`.
>
> I think we should revert the changes from this patch and in the Clang 17.x 
> branch so that we can reevaluate the approach taken in this patch. CC 
> @porglezomp @cjdb

This got reverted and cherry-pick request is made - 
https://github.com/llvm/llvm-project/issues/64515.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

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


[PATCH] D157275: [Driver] Select newest GCC installation on Solaris

2023-08-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2193
 // Skip other prefixes once a GCC installation is found.
-if (Version > VersionZero)
+// Solaris GCC installations live in separate Prefixes per Version
+// (/usr/gcc/) that arrive in directory order, so check all

Adding a Solaris special case here seems strange.

Do you know what the typical `Prefixes` values are on Solaris? Is it possible 
to remove some elements as a special case for Solaris instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157275

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


[PATCH] D157352: Revert "[Clang] Fix -Wconstant-logical-operand when LHS is a constant"

2023-08-07 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa84525233776: Revert [Clang] Fix 
-Wconstant-logical-operand when LHS is a constant (authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157352

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/C/drs/dr4xx.c
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
  clang/test/Parser/cxx2a-concept-declaration.cpp
  clang/test/Sema/exprs.c
  clang/test/SemaCXX/expressions.cpp
  clang/test/SemaCXX/warn-unsequenced.cpp
  clang/test/SemaTemplate/dependent-expr.cpp

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -43,9 +43,7 @@
 
 namespace PR7724 {
   template int myMethod()
-  { return 2 && sizeof(OT); } // expected-warning {{use of logical '&&' with constant operand}} \
-  // expected-note {{use '&' for a bitwise operation}} \
-  // expected-note {{remove constant to silence this warning}}
+  { return 2 && sizeof(OT); }
 }
 
 namespace test4 {
Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -76,37 +76,15 @@
 
   (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-
-  (0 && (a = 0)) + a; // cxx11-warning {{use of logical '&&' with constant operand}}
-  // cxx11-note@-1 {{use '&' for a bitwise operation}}
-  // cxx11-note@-2 {{remove constant to silence this warning}}
-  // cxx17-warning@-3 {{use of logical '&&' with constant operand}}
-  // cxx17-note@-4 {{use '&' for a bitwise operation}}
-  // cxx17-note@-5 {{remove constant to silence this warning}}
-
+  (0 && (a = 0)) + a; // ok
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  // cxx11-warning@-2 {{use of logical '&&' with constant operand}}
-  // cxx11-note@-3 {{use '&' for a bitwise operation}}
-  // cxx11-note@-4 {{remove constant to silence this warning}}
-  // cxx17-warning@-5 {{use of logical '&&' with constant operand}}
-  // cxx17-note@-6 {{use '&' for a bitwise operation}}
-  // cxx17-note@-7 {{remove constant to silence this warning}}
-
 
   (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  // cxx11-warning@-2 {{use of logical '||' with constant operand}}
-  // cxx11-note@-3 {{use '|' for a bitwise operation}}
-  // cxx17-warning@-4 {{use of logical '||' with constant operand}}
-  // cxx17-note@-5 {{use '|' for a bitwise operation}}
-  (1 || (a = 0)) + a; // cxx11-warning {{use of logical '||' with constant operand}}
-  // cxx11-note@-1 {{use '|' for a bitwise operation}}
-  // cxx17-warning@-2 {{use of logical '||' with constant operand}}
-  // cxx17-note@-3 {{use '|' for a bitwise operation}}
-
+  (1 || (a = 0)) + a; // ok
 
   (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,9 +44,6 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
-  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
-   // expected-note {{use '&' for a bitwise operation}} \
-   // expected-note {{remove constant to silence this warning}}
 
   return 

[clang] a845252 - Revert "[Clang] Fix -Wconstant-logical-operand when LHS is a constant"

2023-08-07 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-08-08T08:00:02+05:30
New Revision: a84525233776a716e2c6291993f0b33fd1c76f7c

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

LOG: Revert "[Clang] Fix -Wconstant-logical-operand when LHS is a constant"

This reverts commit dfdfd306cfaf54fbc43e2d5eb36489dac3eb9976.

An issue is reported for wrong warning, this has to be reconsidered.

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/test/C/drs/dr4xx.c
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
clang/test/Parser/cxx2a-concept-declaration.cpp
clang/test/Sema/exprs.c
clang/test/SemaCXX/expressions.cpp
clang/test/SemaCXX/warn-unsequenced.cpp
clang/test/SemaTemplate/dependent-expr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 44bd3c4cf3a665..4cd58ba071283a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12728,8 +12728,6 @@ class Sema final {
   QualType CheckBitwiseOperands( // C99 6.5.[10...12]
   ExprResult , ExprResult , SourceLocation Loc,
   BinaryOperatorKind Opc);
-  void diagnoseLogicalInsteadOfBitwise(Expr *Op1, Expr *Op2, SourceLocation 
Loc,
-   BinaryOperatorKind Opc);
   QualType CheckLogicalOperands( // C99 6.5.[13,14]
 ExprResult , ExprResult , SourceLocation Loc,
 BinaryOperatorKind Opc);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b37e8598249944..c1c6a34e8bc84f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13880,56 +13880,6 @@ inline QualType Sema::CheckBitwiseOperands(ExprResult 
, ExprResult ,
   return InvalidOperands(Loc, LHS, RHS);
 }
 
-// Diagnose cases where the user write a logical and/or but probably meant a
-// bitwise one.  We do this when one of the operands is a non-bool integer and
-// the other is a constant.
-void Sema::diagnoseLogicalInsteadOfBitwise(Expr *Op1, Expr *Op2,
-   SourceLocation Loc,
-   BinaryOperatorKind Opc) {
-  if (Op1->getType()->isIntegerType() && !Op1->getType()->isBooleanType() &&
-  Op2->getType()->isIntegerType() && !Op2->isValueDependent() &&
-  // Don't warn in macros or template instantiations.
-  !Loc.isMacroID() && !inTemplateInstantiation() &&
-  !Op2->getExprLoc().isMacroID() && !Op1->getExprLoc().isMacroID()) {
-bool IsOp1InMacro = Op1->getExprLoc().isMacroID();
-bool IsOp2InMacro = Op2->getExprLoc().isMacroID();
-
-// Exclude the specific expression from triggering the warning.
-if (!(IsOp1InMacro && IsOp2InMacro &&
-  Op1->getSourceRange() == Op2->getSourceRange())) {
-  // If the RHS can be constant folded, and if it constant folds to
-  // something that isn't 0 or 1 (which indicate a potential logical
-  // operation that happened to fold to true/false) then warn. Parens on 
the
-  // RHS are ignored. If the RHS can be constant folded, and if it constant
-  // folds to something that isn't 0 or 1 (which indicate a potential
-  // logical operation that happened to fold to true/false) then warn.
-  // Parens on the RHS are ignored.
-  Expr::EvalResult EVResult;
-  if (Op2->EvaluateAsInt(EVResult, Context)) {
-llvm::APSInt Result = EVResult.Val.getInt();
-if ((getLangOpts().Bool && !Op2->getType()->isBooleanType() &&
- !Op2->getExprLoc().isMacroID()) ||
-(Result != 0 && Result != 1)) {
-  Diag(Loc, diag::warn_logical_instead_of_bitwise)
-  << Op2->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
-  // Suggest replacing the logical operator with the bitwise version
-  Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
-  << (Opc == BO_LAnd ? "&" : "|")
-  << FixItHint::CreateReplacement(
- SourceRange(Loc, getLocForEndOfToken(Loc)),
- Opc == BO_LAnd ? "&" : "|");
-  if (Opc == BO_LAnd)
-// Suggest replacing "Foo() && kNonZero" with "Foo()"
-Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
-<< FixItHint::CreateRemoval(
-   SourceRange(getLocForEndOfToken(Op1->getEndLoc()),
-   Op2->getEndLoc()));
-}
-  }
-}
-  }
-}
-
 // C99 6.5.[13,14]
 inline QualType Sema::CheckLogicalOperands(ExprResult , ExprResult ,
SourceLocation Loc,
@@ -13948,6 +13898,9 @@ inline QualType Sema::CheckLogicalOperands(ExprResult 
, 

[PATCH] D157352: Revert "[Clang] Fix -Wconstant-logical-operand when LHS is a constant"

2023-08-07 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit dfdfd306cfaf54fbc43e2d5eb36489dac3eb9976 
.

An issue is reported for wrong warning, this has to be reconsidered.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157352

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/C/drs/dr4xx.c
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
  clang/test/Parser/cxx2a-concept-declaration.cpp
  clang/test/Sema/exprs.c
  clang/test/SemaCXX/expressions.cpp
  clang/test/SemaCXX/warn-unsequenced.cpp
  clang/test/SemaTemplate/dependent-expr.cpp

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -43,9 +43,7 @@
 
 namespace PR7724 {
   template int myMethod()
-  { return 2 && sizeof(OT); } // expected-warning {{use of logical '&&' with constant operand}} \
-  // expected-note {{use '&' for a bitwise operation}} \
-  // expected-note {{remove constant to silence this warning}}
+  { return 2 && sizeof(OT); }
 }
 
 namespace test4 {
Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -76,37 +76,15 @@
 
   (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-
-  (0 && (a = 0)) + a; // cxx11-warning {{use of logical '&&' with constant operand}}
-  // cxx11-note@-1 {{use '&' for a bitwise operation}}
-  // cxx11-note@-2 {{remove constant to silence this warning}}
-  // cxx17-warning@-3 {{use of logical '&&' with constant operand}}
-  // cxx17-note@-4 {{use '&' for a bitwise operation}}
-  // cxx17-note@-5 {{remove constant to silence this warning}}
-
+  (0 && (a = 0)) + a; // ok
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  // cxx11-warning@-2 {{use of logical '&&' with constant operand}}
-  // cxx11-note@-3 {{use '&' for a bitwise operation}}
-  // cxx11-note@-4 {{remove constant to silence this warning}}
-  // cxx17-warning@-5 {{use of logical '&&' with constant operand}}
-  // cxx17-note@-6 {{use '&' for a bitwise operation}}
-  // cxx17-note@-7 {{remove constant to silence this warning}}
-
 
   (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  // cxx11-warning@-2 {{use of logical '||' with constant operand}}
-  // cxx11-note@-3 {{use '|' for a bitwise operation}}
-  // cxx17-warning@-4 {{use of logical '||' with constant operand}}
-  // cxx17-note@-5 {{use '|' for a bitwise operation}}
-  (1 || (a = 0)) + a; // cxx11-warning {{use of logical '||' with constant operand}}
-  // cxx11-note@-1 {{use '|' for a bitwise operation}}
-  // cxx17-warning@-2 {{use of logical '||' with constant operand}}
-  // cxx17-note@-3 {{use '|' for a bitwise operation}}
-
+  (1 || (a = 0)) + a; // ok
 
   (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,9 +44,6 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
-  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
-   // expected-note {{use '&' for a bitwise operation}} \
-   // expected-note {{remove constant to silence this warning}}
 
   return x && sizeof(int) == 4;  // 

[PATCH] D157238: [clang][ASTImporter] Add import of 'DependentSizedExtVectorType'

2023-08-07 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb92fb8726fc: [clang][ASTImporter] Add import of 
DependentSizedExtVectorType (authored by dingfei 
fd...@feysh.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157238

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1044,6 +1044,17 @@
  has(fieldDecl(hasType(dependentSizedArrayType(;
 }
 
+TEST_P(ImportExpr, DependentSizedExtVectorType) {
+  MatchVerifier Verifier;
+  testImport("template"
+ "class declToImport {"
+ "  typedef T __attribute__((ext_vector_type(Size))) type;"
+ "};",
+ Lang_CXX03, "", Lang_CXX03, Verifier,
+ classTemplateDecl(has(cxxRecordDecl(
+ has(typedefDecl(hasType(dependentSizedExtVectorType(;
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportUsingPackDecl) {
   Decl *FromTU = getTuDecl(
   "struct A { int operator()() { return 1; } };"
Index: clang/unittests/AST/ASTImporterFixtures.h
===
--- clang/unittests/AST/ASTImporterFixtures.h
+++ clang/unittests/AST/ASTImporterFixtures.h
@@ -260,6 +260,8 @@
  FromAST->getFileManager(), false);
 
 auto FoundNodes = match(SearchMatcher, FromCtx);
+if (FoundNodes.empty())
+  return testing::AssertionFailure() << "No node was found!";
 if (FoundNodes.size() != 1)
   return testing::AssertionFailure()
  << "Multiple potential nodes were found!";
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -381,7 +381,8 @@
 ExpectedType VisitIncompleteArrayType(const IncompleteArrayType *T);
 ExpectedType VisitVariableArrayType(const VariableArrayType *T);
 ExpectedType VisitDependentSizedArrayType(const DependentSizedArrayType 
*T);
-// FIXME: DependentSizedExtVectorType
+ExpectedType
+VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T);
 ExpectedType VisitVectorType(const VectorType *T);
 ExpectedType VisitExtVectorType(const ExtVectorType *T);
 ExpectedType VisitFunctionNoProtoType(const FunctionNoProtoType *T);
@@ -1264,6 +1265,18 @@
   T->getIndexTypeCVRQualifiers(), ToBracketsRange);
 }
 
+ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
+const DependentSizedExtVectorType *T) {
+  Error Err = Error::success();
+  QualType ToElementType = importChecked(Err, T->getElementType());
+  Expr *ToSizeExpr = importChecked(Err, T->getSizeExpr());
+  SourceLocation ToAttrLoc = importChecked(Err, T->getAttributeLoc());
+  if (Err)
+return std::move(Err);
+  return Importer.getToContext().getDependentSizedExtVectorType(
+  ToElementType, ToSizeExpr, ToAttrLoc);
+}
+
 ExpectedType ASTNodeImporter::VisitVectorType(const VectorType *T) {
   ExpectedType ToElementTypeOrErr = import(T->getElementType());
   if (!ToElementTypeOrErr)


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1044,6 +1044,17 @@
  has(fieldDecl(hasType(dependentSizedArrayType(;
 }
 
+TEST_P(ImportExpr, DependentSizedExtVectorType) {
+  MatchVerifier Verifier;
+  testImport("template"
+ "class declToImport {"
+ "  typedef T __attribute__((ext_vector_type(Size))) type;"
+ "};",
+ Lang_CXX03, "", Lang_CXX03, Verifier,
+ classTemplateDecl(has(cxxRecordDecl(
+ has(typedefDecl(hasType(dependentSizedExtVectorType(;
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportUsingPackDecl) {
   Decl *FromTU = getTuDecl(
   "struct A { int operator()() { return 1; } };"
Index: clang/unittests/AST/ASTImporterFixtures.h
===
--- clang/unittests/AST/ASTImporterFixtures.h
+++ clang/unittests/AST/ASTImporterFixtures.h
@@ -260,6 +260,8 @@
  FromAST->getFileManager(), false);
 
 auto FoundNodes = match(SearchMatcher, FromCtx);
+if (FoundNodes.empty())
+  return testing::AssertionFailure() << "No node was found!";
 if (FoundNodes.size() != 1)
   return testing::AssertionFailure()
  << "Multiple potential nodes were found!";
Index: clang/lib/AST/ASTImporter.cpp
===
--- 

[PATCH] D157249: [clang][ASTImporter] Add import of 'ConvertVectorExpr'

2023-08-07 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf21f9fc0373: [clang][ASTImporter] Add import of 
ConvertVectorExpr (authored by dingfei fd...@feysh.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157249

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1306,6 +1306,29 @@
 ToChooseExpr->isConditionDependent());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportConvertVectorExpr) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  "typedef double v4double __attribute__((__vector_size__(32)));"
+  "typedef float  v4float  __attribute__((__vector_size__(16)));"
+  "v4float vf;"
+  "void declToImport() { (void)__builtin_convertvector(vf, v4double); }",
+  Lang_CXX03, "", Lang_CXX03);
+
+  auto ToResults =
+  match(convertVectorExpr().bind("convert"), To->getASTContext());
+  auto FromResults =
+  match(convertVectorExpr().bind("convert"), From->getASTContext());
+
+  const ConvertVectorExpr *FromConvertVectorExpr =
+  selectFirst("convert", FromResults);
+  ASSERT_TRUE(FromConvertVectorExpr);
+
+  const ConvertVectorExpr *ToConvertVectorExpr =
+  selectFirst("convert", ToResults);
+  ASSERT_TRUE(ToConvertVectorExpr);
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportGenericSelectionExpr) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -616,6 +616,7 @@
 ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
+ExpectedStmt VisitConvertVectorExpr(ConvertVectorExpr *E);
 ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E);
@@ -7051,6 +7052,21 @@
  ToRParenLoc, CondIsTrue);
 }
 
+ExpectedStmt ASTNodeImporter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
+  Error Err = Error::success();
+  auto *ToSrcExpr = importChecked(Err, E->getSrcExpr());
+  auto ToRParenLoc = importChecked(Err, E->getRParenLoc());
+  auto ToBuiltinLoc = importChecked(Err, E->getBuiltinLoc());
+  auto ToType = importChecked(Err, E->getType());
+  auto *ToTSI = importChecked(Err, E->getTypeSourceInfo());
+  if (Err)
+return std::move(Err);
+
+  return new (Importer.getToContext())
+  ConvertVectorExpr(ToSrcExpr, ToTSI, ToType, E->getValueKind(),
+E->getObjectKind(), ToBuiltinLoc, ToRParenLoc);
+}
+
 ExpectedStmt ASTNodeImporter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
   Error Err = Error::success();
   auto ToRParenLoc = importChecked(Err, E->getRParenLoc());


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1306,6 +1306,29 @@
 ToChooseExpr->isConditionDependent());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportConvertVectorExpr) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  "typedef double v4double __attribute__((__vector_size__(32)));"
+  "typedef float  v4float  __attribute__((__vector_size__(16)));"
+  "v4float vf;"
+  "void declToImport() { (void)__builtin_convertvector(vf, v4double); }",
+  Lang_CXX03, "", Lang_CXX03);
+
+  auto ToResults =
+  match(convertVectorExpr().bind("convert"), To->getASTContext());
+  auto FromResults =
+  match(convertVectorExpr().bind("convert"), From->getASTContext());
+
+  const ConvertVectorExpr *FromConvertVectorExpr =
+  selectFirst("convert", FromResults);
+  ASSERT_TRUE(FromConvertVectorExpr);
+
+  const ConvertVectorExpr *ToConvertVectorExpr =
+  selectFirst("convert", ToResults);
+  ASSERT_TRUE(ToConvertVectorExpr);
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportGenericSelectionExpr) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -616,6 +616,7 @@
 ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
+ExpectedStmt VisitConvertVectorExpr(ConvertVectorExpr *E);
 ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E);
 ExpectedStmt 

[clang] df21f9f - [clang][ASTImporter] Add import of 'ConvertVectorExpr'

2023-08-07 Thread via cfe-commits

Author: dingfei
Date: 2023-08-08T10:23:56+08:00
New Revision: df21f9fc037329ae05ff4640d9172364bb9ef6ed

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

LOG: [clang][ASTImporter] Add import of 'ConvertVectorExpr'

Add import of ConvertVectorExpr.

Reviewed By: balazske

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index c64b92c5c830e4..6da39ca2778bd1 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -616,6 +616,7 @@ namespace clang {
 ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
+ExpectedStmt VisitConvertVectorExpr(ConvertVectorExpr *E);
 ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E);
@@ -7051,6 +7052,21 @@ ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr 
*E) {
  ToRParenLoc, CondIsTrue);
 }
 
+ExpectedStmt ASTNodeImporter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
+  Error Err = Error::success();
+  auto *ToSrcExpr = importChecked(Err, E->getSrcExpr());
+  auto ToRParenLoc = importChecked(Err, E->getRParenLoc());
+  auto ToBuiltinLoc = importChecked(Err, E->getBuiltinLoc());
+  auto ToType = importChecked(Err, E->getType());
+  auto *ToTSI = importChecked(Err, E->getTypeSourceInfo());
+  if (Err)
+return std::move(Err);
+
+  return new (Importer.getToContext())
+  ConvertVectorExpr(ToSrcExpr, ToTSI, ToType, E->getValueKind(),
+E->getObjectKind(), ToBuiltinLoc, ToRParenLoc);
+}
+
 ExpectedStmt ASTNodeImporter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
   Error Err = Error::success();
   auto ToRParenLoc = importChecked(Err, E->getRParenLoc());

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 667e94521da131..9094ff4f25e7be 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -1306,6 +1306,29 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportChooseExpr) {
 ToChooseExpr->isConditionDependent());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportConvertVectorExpr) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  "typedef double v4double __attribute__((__vector_size__(32)));"
+  "typedef float  v4float  __attribute__((__vector_size__(16)));"
+  "v4float vf;"
+  "void declToImport() { (void)__builtin_convertvector(vf, v4double); }",
+  Lang_CXX03, "", Lang_CXX03);
+
+  auto ToResults =
+  match(convertVectorExpr().bind("convert"), To->getASTContext());
+  auto FromResults =
+  match(convertVectorExpr().bind("convert"), From->getASTContext());
+
+  const ConvertVectorExpr *FromConvertVectorExpr =
+  selectFirst("convert", FromResults);
+  ASSERT_TRUE(FromConvertVectorExpr);
+
+  const ConvertVectorExpr *ToConvertVectorExpr =
+  selectFirst("convert", ToResults);
+  ASSERT_TRUE(ToConvertVectorExpr);
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportGenericSelectionExpr) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(



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


[clang] db92fb8 - [clang][ASTImporter] Add import of 'DependentSizedExtVectorType'

2023-08-07 Thread via cfe-commits

Author: dingfei
Date: 2023-08-08T10:22:00+08:00
New Revision: db92fb8726fc09e6d76346a02169685025fd59ca

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

LOG: [clang][ASTImporter] Add import of 'DependentSizedExtVectorType'

Add import of 'DependentSizedExtVectorType'.

Reviewed By: balazske

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterFixtures.h
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f122c09629e1c2..c64b92c5c830e4 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -381,7 +381,8 @@ namespace clang {
 ExpectedType VisitIncompleteArrayType(const IncompleteArrayType *T);
 ExpectedType VisitVariableArrayType(const VariableArrayType *T);
 ExpectedType VisitDependentSizedArrayType(const DependentSizedArrayType 
*T);
-// FIXME: DependentSizedExtVectorType
+ExpectedType
+VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T);
 ExpectedType VisitVectorType(const VectorType *T);
 ExpectedType VisitExtVectorType(const ExtVectorType *T);
 ExpectedType VisitFunctionNoProtoType(const FunctionNoProtoType *T);
@@ -1264,6 +1265,18 @@ ExpectedType 
ASTNodeImporter::VisitDependentSizedArrayType(
   T->getIndexTypeCVRQualifiers(), ToBracketsRange);
 }
 
+ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
+const DependentSizedExtVectorType *T) {
+  Error Err = Error::success();
+  QualType ToElementType = importChecked(Err, T->getElementType());
+  Expr *ToSizeExpr = importChecked(Err, T->getSizeExpr());
+  SourceLocation ToAttrLoc = importChecked(Err, T->getAttributeLoc());
+  if (Err)
+return std::move(Err);
+  return Importer.getToContext().getDependentSizedExtVectorType(
+  ToElementType, ToSizeExpr, ToAttrLoc);
+}
+
 ExpectedType ASTNodeImporter::VisitVectorType(const VectorType *T) {
   ExpectedType ToElementTypeOrErr = import(T->getElementType());
   if (!ToElementTypeOrErr)

diff  --git a/clang/unittests/AST/ASTImporterFixtures.h 
b/clang/unittests/AST/ASTImporterFixtures.h
index ed561f4b5eaf2e..87e62cbda422ab 100644
--- a/clang/unittests/AST/ASTImporterFixtures.h
+++ b/clang/unittests/AST/ASTImporterFixtures.h
@@ -260,6 +260,8 @@ class TestImportBase
  FromAST->getFileManager(), false);
 
 auto FoundNodes = match(SearchMatcher, FromCtx);
+if (FoundNodes.empty())
+  return testing::AssertionFailure() << "No node was found!";
 if (FoundNodes.size() != 1)
   return testing::AssertionFailure()
  << "Multiple potential nodes were found!";

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 4c53d4b7eee9d8..667e94521da131 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -1044,6 +1044,17 @@ TEST_P(ImportExpr, DependentSizedArrayType) {
  has(fieldDecl(hasType(dependentSizedArrayType(;
 }
 
+TEST_P(ImportExpr, DependentSizedExtVectorType) {
+  MatchVerifier Verifier;
+  testImport("template"
+ "class declToImport {"
+ "  typedef T __attribute__((ext_vector_type(Size))) type;"
+ "};",
+ Lang_CXX03, "", Lang_CXX03, Verifier,
+ classTemplateDecl(has(cxxRecordDecl(
+ has(typedefDecl(hasType(dependentSizedExtVectorType(;
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportUsingPackDecl) {
   Decl *FromTU = getTuDecl(
   "struct A { int operator()() { return 1; } };"



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


[PATCH] D157296: [AST][Coroutine] Fix CoyieldExpr missing end loc

2023-08-07 Thread Ding Fei via Phabricator via cfe-commits
danix800 added a comment.

1. Use invalid loc: `SourceLocation()`

  ExprWithCleanups 0x55d1067162c8  'void'
  `-CoyieldExpr 0x55d106716280  'void'
|-CXXMemberCallExpr 0x55d106715ed8  
'std::suspend_always':'std::suspend_always'
| |-MemberExpr 0x55d106715ea8  '' 
.yield_value 0x55d10670b220
| | `-DeclRefExpr 0x55d106715e88  'std::coroutine_traits::promise_type':'Chat::promise_type' lvalue Var 0x55d106714218 '__promise' 
'std::coroutine_traits::promise_type':'Chat::promise_type'
| `-ImplicitCastExpr 0x55d106715f00  'int' 
|   `-DeclRefExpr 0x55d1067118e8  'int' lvalue ParmVar 
0x55d1067116c0 'sss' 'int'
|-MaterializeTemporaryExpr 0x55d106715f58  
'std::suspend_always':'std::suspend_always' lvalue
| `-CXXMemberCallExpr 0x55d106715ed8  
'std::suspend_always':'std::suspend_always'
|   |-MemberExpr 0x55d106715ea8  '' 
.yield_value 0x55d10670b220
|   | `-DeclRefExpr 0x55d106715e88  'std::coroutine_traits::promise_type':'Chat::promise_type' lvalue Var 0x55d106714218 '__promise' 
'std::coroutine_traits::promise_type':'Chat::promise_type'
|   `-ImplicitCastExpr 0x55d106715f00  'int' 
| `-DeclRefExpr 0x55d1067118e8  'int' lvalue ParmVar 
0x55d1067116c0 'sss' 'int'
|-ExprWithCleanups 0x55d106715fd8 > 'bool'
| `-CXXMemberCallExpr 0x55d106715fb8 > 'bool'
|   `-MemberExpr 0x55d106715f88  '' 
.await_ready 0x55d106708858
| `-OpaqueValueExpr 0x55d106715f70  
'std::suspend_always':'std::suspend_always' lvalue
|   `-MaterializeTemporaryExpr 0x55d106715f58  
'std::suspend_always':'std::suspend_always' lvalue
| `-CXXMemberCallExpr 0x55d106715ed8  
'std::suspend_always':'std::suspend_always'
|   |-MemberExpr 0x55d106715ea8  '' .yield_value 0x55d10670b220
|   | `-DeclRefExpr 0x55d106715e88  
'std::coroutine_traits::promise_type':'Chat::promise_type' lvalue 
Var 0x55d106714218 '__promise' 'std::coroutine_traits::promise_type':'Chat::promise_type'
|   `-ImplicitCastExpr 0x55d106715f00  'int' 

| `-DeclRefExpr 0x55d1067118e8  'int' lvalue ParmVar 
0x55d1067116c0 'sss' 'int'
|-CXXMemberCallExpr 0x55d106716160  'void'
| |-MemberExpr 0x55d106716130  '' 
.await_suspend 0x55d106708ad8
| | `-OpaqueValueExpr 0x55d106715f70  
'std::suspend_always':'std::suspend_always' lvalue
| |   `-MaterializeTemporaryExpr 0x55d106715f58  
'std::suspend_always':'std::suspend_always' lvalue
| | `-CXXMemberCallExpr 0x55d106715ed8  
'std::suspend_always':'std::suspend_always'
| |   |-MemberExpr 0x55d106715ea8  '' .yield_value 0x55d10670b220
| |   | `-DeclRefExpr 0x55d106715e88  
'std::coroutine_traits::promise_type':'Chat::promise_type' lvalue 
Var 0x55d106714218 '__promise' 'std::coroutine_traits::promise_type':'Chat::promise_type'
| |   `-ImplicitCastExpr 0x55d106715f00  'int' 
| | `-DeclRefExpr 0x55d1067118e8  'int' lvalue ParmVar 
0x55d1067116c0 'sss' 'int'
| `-ImplicitCastExpr 0x55d106716218  
'coroutine_handle<>':'std::coroutine_handle' 
|   `-CXXConstructExpr 0x55d1067161e8  
'coroutine_handle<>':'std::coroutine_handle' 'void 
(coroutine_handle) noexcept'
| `-CallExpr 0x55d1067160d0  
'coroutine_handle':'std::coroutine_handle'
|   |-ImplicitCastExpr 0x55d1067160b8  
'coroutine_handle (*)(void *) noexcept' 
|   | `-DeclRefExpr 0x55d106716098  
'coroutine_handle (void *) noexcept' lvalue CXXMethod 
0x55d10670dd98 'from_address' 'coroutine_handle (void *) noexcept'
|   `-CallExpr 0x55d106716078  'void *'
| `-ImplicitCastExpr 0x55d106716060  'void *(*)() noexcept' 

|   `-DeclRefExpr 0x55d106716040  'void *() noexcept' lvalue 
Function 0x55d106714c88 '__builtin_coro_frame' 'void *() noexcept'
`-CXXMemberCallExpr 0x55d106716260 > 'void'
  `-MemberExpr 0x55d106716230  '' 
.await_resume 0x55d106708bf8
`-OpaqueValueExpr 0x55d106715f70  
'std::suspend_always':'std::suspend_always' lvalue
  `-MaterializeTemporaryExpr 0x55d106715f58  
'std::suspend_always':'std::suspend_always' lvalue
`-CXXMemberCallExpr 0x55d106715ed8  
'std::suspend_always':'std::suspend_always'
  |-MemberExpr 0x55d106715ea8  '' .yield_value 0x55d10670b220
  | `-DeclRefExpr 0x55d106715e88  
'std::coroutine_traits::promise_type':'Chat::promise_type' lvalue 
Var 0x55d106714218 '__promise' 'std::coroutine_traits::promise_type':'Chat::promise_type'
  `-ImplicitCastExpr 0x55d106715f00  'int' 
`-DeclRefExpr 0x55d1067118e8  'int' lvalue ParmVar 
0x55d1067116c0 'sss' 'int'

Note that `CXXMemberCallExpr 0x55d106716260 >` relies on 
`RParenLoc` directly. Coroutine is implemented as member call so I think 
`RParen` is intended and should exist and be correct.

2. Use last arg's end loc if exists:  `auto EndLoc = Args.empty() ? Loc : 
Args.back()->getEndLoc();`

  ExprWithCleanups 0x55dcfa09f2c8  'void'
  `-CoyieldExpr 0x55dcfa09f280  'void'

[PATCH] D152793: [RISCV] Add MC layer support for Zicfiss.

2023-08-07 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 updated this revision to Diff 548027.
fakepaper56 added a comment.

Bump to 0.2 and address part of comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

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.h
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/zicfiss-invalid.s
  llvm/test/MC/RISCV/zicfiss-valid.s

Index: llvm/test/MC/RISCV/zicfiss-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfiss-valid.s
@@ -0,0 +1,110 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: ssload x1
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x1
+
+# CHECK-ASM-AND-OBJ: ssload x1
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload ra
+
+# CHECK-ASM-AND-OBJ: ssload x5
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x5
+
+# CHECK-ASM-AND-OBJ: ssload x5
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload t0
+
+# CHECK-ASM-AND-OBJ: sspopchk x1
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x1
+
+# CHECK-ASM-AND-OBJ: sspopchk x1
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk ra
+
+# CHECK-ASM-AND-OBJ: sspopchk x5
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x5
+
+# CHECK-ASM-AND-OBJ: sspopchk x5
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk t0
+
+# CHECK-ASM-AND-OBJ: sspinc 4
+# CHECK-ASM: encoding: [0x73,0x40,0xd2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspinc 4
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x1
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush ra
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x5
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush t0
+
+# CHECK-ASM-AND-OBJ: ssprr ra
+# CHECK-ASM: encoding: [0xf3,0x40,0x00,0x86]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssprr ra
+
+# CHECK-ASM-AND-OBJ: ssamoswap t0, zero, (a0)
+# CHECK-ASM: encoding: [0xf3,0x42,0x05,0x82]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssamoswap t0, x0, (a0)
+
+# CHECK-ASM-AND-OBJ: c.sspush x1
+# CHECK-ASM: encoding: [0x81,0x60]
+# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions), 'Zicfiss' (Shadow stack)
+c.sspush x1
+

[PATCH] D155850: [Clang][CodeGen][RFC] Add codegen support for C++ Parallel Algorithm Offload

2023-08-07 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 548022.
AlexVlx added a comment.

Extend handling of unsupported builtins to include dealing with the `target` 
attribute.


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

https://reviews.llvm.org/D155850

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenStdPar/unannotated-functions-get-emitted.cpp
  clang/test/CodeGenStdPar/unsupported-builtins.cpp

Index: clang/test/CodeGenStdPar/unsupported-builtins.cpp
===
--- /dev/null
+++ clang/test/CodeGenStdPar/unsupported-builtins.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   --stdpar -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s
+
+#define __global__ __attribute__((global))
+
+__global__ void foo() { return __builtin_ia32_pause(); }
+
+// CHECK: declare void @__builtin_ia32_pause__stdpar_unsupported()
Index: clang/test/CodeGenStdPar/unannotated-functions-get-emitted.cpp
===
--- /dev/null
+++ clang/test/CodeGenStdPar/unannotated-functions-get-emitted.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck --check-prefix=NO-STDPAR-DEV %s
+
+// RUN: %clang_cc1 --stdpar -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck --check-prefix=STDPAR-DEV %s
+
+#define __device__ __attribute__((device))
+
+// NO-STDPAR-DEV-NOT: define {{.*}} void @_Z3fooPff({{.*}})
+// STDPAR-DEV: define {{.*}} void @_Z3fooPff({{.*}})
+void foo(float *a, float b) {
+  *a = b;
+}
+
+// NO-STDPAR-DEV: define {{.*}} void @_Z3barPff({{.*}})
+// STDPAR-DEV: define {{.*}} void @_Z3barPff({{.*}})
+__device__ void bar(float *a, float b) {
+  *a = b;
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3550,7 +3550,10 @@
   !Global->hasAttr() &&
   !Global->hasAttr() &&
   !Global->getType()->isCUDADeviceBuiltinSurfaceType() &&
-  !Global->getType()->isCUDADeviceBuiltinTextureType())
+  !Global->getType()->isCUDADeviceBuiltinTextureType() &&
+  !(LangOpts.HIPStdPar &&
+isa(Global) &&
+!Global->hasAttr()))
 return;
 } else {
   // We need to emit host-side 'shadows' for all global
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2594,10 +2594,15 @@
   std::string MissingFeature;
   llvm::StringMap CallerFeatureMap;
   CGM.getContext().getFunctionFeatureMap(CallerFeatureMap, FD);
+  // When compiling in StdPar mode we have to be conservative in rejecting
+  // target specific features in the FE, and defer the possible error to the
+  // AcceleratorCodeSelection pass, wherein iff an unsupported target builtin is
+  // referenced by an accelerator executable function, we emit an error.
+  bool IsStdPar = getLangOpts().HIPStdPar && getLangOpts().CUDAIsDevice
   if (BuiltinID) {
 StringRef FeatureList(CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID));
 if (!Builtin::evaluateRequiredTargetFeatures(
-FeatureList, CallerFeatureMap)) {
+FeatureList, CallerFeatureMap) && !IsStdPar) {
   CGM.getDiags().Report(Loc, diag::err_builtin_needs_feature)
   << TargetDecl->getDeclName()
   << FeatureList;
@@ -2630,7 +2635,7 @@
 return false;
   }
   return true;
-}))
+}) && !IsStdPar)
   CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
   << FD->getDeclName() << TargetDecl->getDeclName() << MissingFeature;
   } else if (!FD->isMultiVersion() && FD->hasAttr()) {
@@ -2639,7 +2644,8 @@
 
 for (const auto  : CalleeFeatureMap) {
   if (F.getValue() && (!CallerFeatureMap.lookup(F.getKey()) ||
-   !CallerFeatureMap.find(F.getKey())->getValue()))
+   !CallerFeatureMap.find(F.getKey())->getValue()) &&
+  !IsStdPar)
 CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
 << FD->getDeclName() << TargetDecl->getDeclName() << F.getKey();
 }
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2238,6 +2238,19 @@
   return nullptr;
 }
 
+static RValue EmitStdParUnsupportedBuiltin(CodeGenFunction *CGF,
+   const FunctionDecl *FD) {
+  auto Name = FD->getNameAsString() + "__stdpar_unsupported";
+  auto FnTy = CGF->CGM.getTypes().GetFunctionType(FD);
+  

[PATCH] D153114: [clangd] [C++20] [Modules] Support C++20 modules for clangd

2023-08-07 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

Got it. Being patience is not bad and it is good enough to know that we are 
moving forward : )


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

https://reviews.llvm.org/D153114

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


[PATCH] D157350: [clang][ExtractAPI] Add support for C++ variable templates

2023-08-07 Thread Erick Velez via Phabricator via cfe-commits
evelez7 created this revision.
evelez7 added a reviewer: dang.
Herald added a reviewer: ributzka.
Herald added a project: All.
evelez7 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Serialize global C++ variable templates and specializations.

Depends on D157076 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157350

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/global_var_template.cpp
  clang/test/ExtractAPI/global_var_template_partial_spec.cpp
  clang/test/ExtractAPI/global_var_template_spec.cpp

Index: clang/test/ExtractAPI/global_var_template_spec.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/global_var_template_spec.cpp
@@ -0,0 +1,207 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template T Foo = T(3.14);
+
+template<> int Foo;
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "keyword",
+  "spelling": "typename"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "genericParameter",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": "> "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:t0.0",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@Foo"
+  },
+  "kind": {
+"displayName": "Global Variable Template",
+"identifier": "c++.var"
+  },
+  "location": {
+"position": {
+  "character": 24,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ],
+  "swiftGenerics": {
+"parameters": [
+  {
+"depth": 0,
+"index": 0,
+"name": "T"
+  }
+]
+  }
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<> "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+   

[PATCH] D156771: [clang][hexagon] Handle library path arguments earlier

2023-08-07 Thread Brian Cain via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5bc4b34a3aa9: [clang][hexagon] Handle library path arguments 
earlier (authored by androm3da).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156771

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/test/Driver/hexagon-toolchain-linux.c


Index: clang/test/Driver/hexagon-toolchain-linux.c
===
--- clang/test/Driver/hexagon-toolchain-linux.c
+++ clang/test/Driver/hexagon-toolchain-linux.c
@@ -120,8 +120,12 @@
 // CHECK009-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
 // CHECK009-SAME: {{^}} "-internal-externc-isystem" 
"[[INSTALLED_DIR]]/../target/hexagon/include"
 
-// RUN: %clang -fdriver-only -Werror -v -L/tmp \
-// RUN:--target=hexagon-unknown-linux-musl %s 2>&1 \
+// RUN: %clang -Werror -L/tmp \
+// RUN:--target=hexagon-unknown-linux-musl %s -### 2>&1 \
 // RUN:| FileCheck -check-prefix=CHECK010 %s
 // CHECK010:   InstalledDir: [[INSTALLED_DIR:.+]]
+// CHECK010-NOT:  "-lstandalone"
+// CHECK010-NOT:  crt0_standalone.o
+// CHECK010:   crt1.o
 // CHECK010:   "-L/tmp"
+// CHECK010-NOT:  "-lstandalone"
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -383,6 +383,11 @@
   if (HTC.ShouldLinkCXXStdlib(Args))
 HTC.AddCXXStdlibLibArgs(Args, CmdArgs);
 }
+const ToolChain::path_list  = HTC.getFilePaths();
+for (const auto  : LibPaths)
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+Args.ClaimAllArgs(options::OPT_L);
+return;
   }
 
   
//


Index: clang/test/Driver/hexagon-toolchain-linux.c
===
--- clang/test/Driver/hexagon-toolchain-linux.c
+++ clang/test/Driver/hexagon-toolchain-linux.c
@@ -120,8 +120,12 @@
 // CHECK009-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
 // CHECK009-SAME: {{^}} "-internal-externc-isystem" "[[INSTALLED_DIR]]/../target/hexagon/include"
 
-// RUN: %clang -fdriver-only -Werror -v -L/tmp \
-// RUN:--target=hexagon-unknown-linux-musl %s 2>&1 \
+// RUN: %clang -Werror -L/tmp \
+// RUN:--target=hexagon-unknown-linux-musl %s -### 2>&1 \
 // RUN:| FileCheck -check-prefix=CHECK010 %s
 // CHECK010:   InstalledDir: [[INSTALLED_DIR:.+]]
+// CHECK010-NOT:  "-lstandalone"
+// CHECK010-NOT:  crt0_standalone.o
+// CHECK010:   crt1.o
 // CHECK010:   "-L/tmp"
+// CHECK010-NOT:  "-lstandalone"
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -383,6 +383,11 @@
   if (HTC.ShouldLinkCXXStdlib(Args))
 HTC.AddCXXStdlibLibArgs(Args, CmdArgs);
 }
+const ToolChain::path_list  = HTC.getFilePaths();
+for (const auto  : LibPaths)
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+Args.ClaimAllArgs(options::OPT_L);
+return;
   }
 
   //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5bc4b34 - [clang][hexagon] Handle library path arguments earlier

2023-08-07 Thread Brian Cain via cfe-commits

Author: Brian Cain
Date: 2023-08-07T18:18:59-07:00
New Revision: 5bc4b34a3aa9c6ea10663a252ac46d20862b38d5

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

LOG: [clang][hexagon] Handle library path arguments earlier

The removal of the early return in 96832a6bf7e0e7f1e8d634d38c44a1b32d512923
was an error: it would include the 'standalone' library that's not used
by linux.

Instead we reproduce the library path handling in the linux/musl block.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-toolchain-linux.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index dab7382532520a..aed4ab1955b4f3 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -383,6 +383,11 @@ constructHexagonLinkArgs(Compilation , const JobAction 
,
   if (HTC.ShouldLinkCXXStdlib(Args))
 HTC.AddCXXStdlibLibArgs(Args, CmdArgs);
 }
+const ToolChain::path_list  = HTC.getFilePaths();
+for (const auto  : LibPaths)
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+Args.ClaimAllArgs(options::OPT_L);
+return;
   }
 
   
//

diff  --git a/clang/test/Driver/hexagon-toolchain-linux.c 
b/clang/test/Driver/hexagon-toolchain-linux.c
index 61a5581b009c23..423306affdce3a 100644
--- a/clang/test/Driver/hexagon-toolchain-linux.c
+++ b/clang/test/Driver/hexagon-toolchain-linux.c
@@ -120,8 +120,12 @@
 // CHECK009-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
 // CHECK009-SAME: {{^}} "-internal-externc-isystem" 
"[[INSTALLED_DIR]]/../target/hexagon/include"
 
-// RUN: %clang -fdriver-only -Werror -v -L/tmp \
-// RUN:--target=hexagon-unknown-linux-musl %s 2>&1 \
+// RUN: %clang -Werror -L/tmp \
+// RUN:--target=hexagon-unknown-linux-musl %s -### 2>&1 \
 // RUN:| FileCheck -check-prefix=CHECK010 %s
 // CHECK010:   InstalledDir: [[INSTALLED_DIR:.+]]
+// CHECK010-NOT:  "-lstandalone"
+// CHECK010-NOT:  crt0_standalone.o
+// CHECK010:   crt1.o
 // CHECK010:   "-L/tmp"
+// CHECK010-NOT:  "-lstandalone"



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


[PATCH] D156116: [Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC behaviour

2023-08-07 Thread Lu Weining via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7a8a7d49776: [Clang][LoongArch] Fix ABI handling of empty 
structs in C++ to match GCC… (authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156116

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c

Index: clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
===
--- clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -3,7 +3,6 @@
 // RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - -x c++ | \
 // RUN:   FileCheck --check-prefix=CHECK-CXX %s
 
-// FIXME: This isn't currently respected.
 // Fields containing empty structs or unions are ignored when flattening
 // structs to examine whether the structs can be passed via FARs, even in C++.
 // But there is an exception that non-zero-length array of empty structures are
@@ -16,7 +15,7 @@
 struct s1 { struct empty e; float f; };
 
 // CHECK-C: define{{.*}} float @test_s1(float {{.*}})
-// CHECK-CXX: define{{.*}} i64 @_Z7test_s12s1(i64 {{.*}})
+// CHECK-CXX: define{{.*}} float @_Z7test_s12s1(float {{.*}})
 struct s1 test_s1(struct s1 a) {
   return a;
 }
@@ -24,7 +23,7 @@
 struct s2 { struct empty e; int32_t i; float f; };
 
 // CHECK-C: define{{.*}} { i32, float } @test_s2(i32 {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s22s2([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { i32, float } @_Z7test_s22s2(i32 {{.*}}, float {{.*}})
 struct s2 test_s2(struct s2 a) {
   return a;
 }
@@ -32,7 +31,7 @@
 struct s3 { struct empty e; float f; float g; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s3(float {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s32s3([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { float, float } @_Z7test_s32s3(float {{.*}}, float {{.*}})
 struct s3 test_s3(struct s3 a) {
   return a;
 }
@@ -40,7 +39,7 @@
 struct s4 { struct empty e; float __complex__ c; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s4(float {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s42s4([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { float, float } @_Z7test_s42s4(float {{.*}}, float {{.*}})
 struct s4 test_s4(struct s4 a) {
   return a;
 }
@@ -77,7 +76,14 @@
 struct s8 { struct empty_arr0 e; float f; };
 
 // CHECK-C: define{{.*}} float @test_s8(float {{.*}})
-// CHECK-CXX: define{{.*}} i64 @_Z7test_s82s8(i64 {{.*}})
+// CHECK-CXX: define{{.*}} float @_Z7test_s82s8(float {{.*}})
 struct s8 test_s8(struct s8 a) {
   return a;
 }
+
+// CHECK-C: define{{.*}} void @test_s9()
+// CHECK-CXX: define{{.*}} i64 @_Z7test_s92s9(i64 {{.*}})
+struct s9 { struct empty e; };
+struct s9 test_s9(struct s9 a) {
+  return a;
+}
Index: clang/lib/CodeGen/Targets/LoongArch.cpp
===
--- clang/lib/CodeGen/Targets/LoongArch.cpp
+++ clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -148,6 +148,13 @@
   if (const ConstantArrayType *ATy = getContext().getAsConstantArrayType(Ty)) {
 uint64_t ArraySize = ATy->getSize().getZExtValue();
 QualType EltTy = ATy->getElementType();
+// Non-zero-length arrays of empty records make the struct ineligible to be
+// passed via FARs in C++.
+if (const auto *RTy = EltTy->getAs()) {
+  if (ArraySize != 0 && isa(RTy->getDecl()) &&
+  isEmptyRecord(getContext(), EltTy, true, true))
+return false;
+}
 CharUnits EltSize = getContext().getTypeSizeInChars(EltTy);
 for (uint64_t i = 0; i < ArraySize; ++i) {
   if (!detectFARsEligibleStructHelper(EltTy, CurOff, Field1Ty, Field1Off,
@@ -163,7 +170,7 @@
 // copy constructor are not eligible for the FP calling convention.
 if (getRecordArgABI(Ty, CGT.getCXXABI()))
   return false;
-if (isEmptyRecord(getContext(), Ty, true))
+if (isEmptyRecord(getContext(), Ty, true, true))
   return true;
 const RecordDecl *RD = RTy->getDecl();
 // Unions aren't eligible unless they're empty (which is caught above).
@@ -222,6 +229,8 @@
   if (!detectFARsEligibleStructHelper(Ty, CharUnits::Zero(), Field1Ty,
   Field1Off, Field2Ty, Field2Off))
 return false;
+  if (!Field1Ty)
+return false;
   // Not really a candidate if we have a single int but no float.
   if (Field1Ty && !Field2Ty && !Field1Ty->isFloatingPointTy())
 return false;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -192,6 +192,9 @@
 LoongArch Support
 ^
 
+- An ABI mismatch between GCC and Clang related to 

[clang] e7a8a7d - [Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC behaviour

2023-08-07 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2023-08-08T09:07:11+08:00
New Revision: e7a8a7d4977627ebc43e9ed43462aebad4a66e8d

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

LOG: [Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC 
behaviour

GCC doesn't ignore non-zero-length array of empty structures in C++
while clang does. What this patch did is to match GCC's behaviour
although this rule is not documented in psABI.

Similar to D142327 for RISCV.

Reviewed By: xry111, xen0n

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/Targets/LoongArch.cpp
clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 949e3fe7d2c8d7..44f6ad807daf8f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -192,6 +192,9 @@ Windows Support
 LoongArch Support
 ^
 
+- An ABI mismatch between GCC and Clang related to the handling of empty 
structs
+  in C++ parameter passing under ``lp64d`` ABI was fixed.
+
 RISC-V Support
 ^^
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the

diff  --git a/clang/lib/CodeGen/Targets/LoongArch.cpp 
b/clang/lib/CodeGen/Targets/LoongArch.cpp
index 6391a8aeaa67cd..7483bf6d6d1e8e 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -148,6 +148,13 @@ bool LoongArchABIInfo::detectFARsEligibleStructHelper(
   if (const ConstantArrayType *ATy = getContext().getAsConstantArrayType(Ty)) {
 uint64_t ArraySize = ATy->getSize().getZExtValue();
 QualType EltTy = ATy->getElementType();
+// Non-zero-length arrays of empty records make the struct ineligible to be
+// passed via FARs in C++.
+if (const auto *RTy = EltTy->getAs()) {
+  if (ArraySize != 0 && isa(RTy->getDecl()) &&
+  isEmptyRecord(getContext(), EltTy, true, true))
+return false;
+}
 CharUnits EltSize = getContext().getTypeSizeInChars(EltTy);
 for (uint64_t i = 0; i < ArraySize; ++i) {
   if (!detectFARsEligibleStructHelper(EltTy, CurOff, Field1Ty, Field1Off,
@@ -163,7 +170,7 @@ bool LoongArchABIInfo::detectFARsEligibleStructHelper(
 // copy constructor are not eligible for the FP calling convention.
 if (getRecordArgABI(Ty, CGT.getCXXABI()))
   return false;
-if (isEmptyRecord(getContext(), Ty, true))
+if (isEmptyRecord(getContext(), Ty, true, true))
   return true;
 const RecordDecl *RD = RTy->getDecl();
 // Unions aren't eligible unless they're empty (which is caught above).
@@ -222,6 +229,8 @@ bool LoongArchABIInfo::detectFARsEligibleStruct(
   if (!detectFARsEligibleStructHelper(Ty, CharUnits::Zero(), Field1Ty,
   Field1Off, Field2Ty, Field2Off))
 return false;
+  if (!Field1Ty)
+return false;
   // Not really a candidate if we have a single int but no float.
   if (Field1Ty && !Field2Ty && !Field1Ty->isFloatingPointTy())
 return false;

diff  --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c 
b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
index 3a65b90e48e0e0..fb90bf556c19b2 100644
--- a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -3,7 +3,6 @@
 // RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d 
-target-abi lp64d -emit-llvm %s -o - -x c++ | \
 // RUN:   FileCheck --check-prefix=CHECK-CXX %s
 
-// FIXME: This isn't currently respected.
 // Fields containing empty structs or unions are ignored when flattening
 // structs to examine whether the structs can be passed via FARs, even in C++.
 // But there is an exception that non-zero-length array of empty structures are
@@ -16,7 +15,7 @@ struct empty { struct { struct { } e; }; };
 struct s1 { struct empty e; float f; };
 
 // CHECK-C: define{{.*}} float @test_s1(float {{.*}})
-// CHECK-CXX: define{{.*}} i64 @_Z7test_s12s1(i64 {{.*}})
+// CHECK-CXX: define{{.*}} float @_Z7test_s12s1(float {{.*}})
 struct s1 test_s1(struct s1 a) {
   return a;
 }
@@ -24,7 +23,7 @@ struct s1 test_s1(struct s1 a) {
 struct s2 { struct empty e; int32_t i; float f; };
 
 // CHECK-C: define{{.*}} { i32, float } @test_s2(i32 {{.*}}, float {{.*}})
-// CHECK-CXX: define{{.*}} [2 x i64] @_Z7test_s22s2([2 x i64] {{.*}})
+// CHECK-CXX: define{{.*}} { i32, float } @_Z7test_s22s2(i32 {{.*}}, float 
{{.*}})
 struct s2 test_s2(struct s2 a) {
   return a;
 }
@@ -32,7 +31,7 @@ struct s2 test_s2(struct s2 a) {
 struct s3 { struct empty e; float f; float g; };
 
 // CHECK-C: define{{.*}} { float, float } @test_s3(float {{.*}}, float {{.*}})
-// 

[PATCH] D157270: [Clang][AArch64] Add diagnostic for calls from non-ZA to shared-ZA functions.

2023-08-07 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added inline comments.



Comment at: clang/test/Sema/aarch64-sme-func-attrs.c:181
 
+void non_za_definition(void) {
+  sme_arm_new_za(); // OK

sdesmalen wrote:
> rsandifo-arm wrote:
> > sdesmalen wrote:
> > > rsandifo-arm wrote:
> > > > Would be good to have some tests for indirect function calls too (via 
> > > > function pointers), to make sure that the diagnostic still works when 
> > > > no decl is available.
> > > > 
> > > > I suppose this applies to D157269 too.
> > > I'm not sure that's necessary because D127762 already added tests to 
> > > ensure the attributes propagate on pointer types, which then sets the 
> > > ExtProtoInfo for those values. This patch merely checks the SME attribute 
> > > fields from ExtProtoInfo. i.e. there is already nothing depending on a 
> > > declaration being available.
> > But `Sema::checkCall` does have some tests that depend on the decl rather 
> > than the type.  So the purpose of the test wouldn't be “does the attribute 
> > stick when applied to indirect function types?” (which I agree is already 
> > covered), but “does the new code correctly process the attribute on the 
> > target of a function pointer type?”
> The declaration is only relevant for the call-site, not the callee.
> 
>   if (ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateZASharedMask) {
> 
> The above line checks __arm_shared_za attribute of the callee (could be a 
> decl, or a function pointer, but in either case is a prototyped function with 
> the propagated attributes)
> 
>   if (auto *CallerFD = dyn_cast(CurContext)) {
> 
> The above line checks if the call-site context is a FunctionDecl (or 
> definition for that matter). If the call is not part of a declaration (e.g. 
> it's part of some global initialiser), we know it cannot have any live ZA 
> state (which I now realise is missing a test-case).
> 
> So I think that a test like this:
> 
>   __arm_new_za void foo(void (*f)() __arm_shared_za) { f(); }
> 
> is not testing anything that isn't already tested. But perhaps I'm still 
> misunderstanding your point. If so, could you give an example of a test you 
> have in mind?
That's the kind of test I had in mind.

checkCall does have some conditions that are based on the callee decl rather 
than the callee type.  That is, it does distinguish between direct calls and 
indirect calls.  It would have been easy for the code to be in a block that was 
guarded with FDecl.  Or it could be accidentally rearranged like that in 
future, especially if the function grows to have several more tests.

And yeah, I agree that the code as-written works, and so it doesn't fall into 
the trap that is being tested for.  But that's true of most tests that get 
written for new features. :)

So a test for both the direct and indirect cases seemed worthwhile.  If we were 
just going to have one, then I think testing the indirect case is more valuable 
than testing the direct case, since it's the type rather than the decl that 
matters.

I won't press the point further though.  Feel free to skip the comment if you'd 
rather keep the tests as they are.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157270

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


[PATCH] D157326: [clang-tidy] Fix handling of out-of-line functions in readability-static-accessed-through-instance

2023-08-07 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp:23
 static unsigned getNameSpecifierNestingLevel(const QualType ) {
   if (const ElaboratedType *ElType = QType->getAs()) {
 if (const NestedNameSpecifier *NestedSpecifiers = ElType->getQualifier()) {

Should be `const auto *`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157326

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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Yabin Cui via Phabricator via cfe-commits
yabinc added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

enh wrote:
> enh wrote:
> > enh wrote:
> > > ZijunZhao wrote:
> > > > enh wrote:
> > > > > is this ever _not_ set for clang?
> > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
> > > > I think it is set?
> > > i get an error from
> > > ```
> > > /tmp$ cat x.c
> > > #if defined(__GNUC__)
> > > #error foo
> > > #endif
> > > ```
> > > regardless of whether i compile with -std=c11 or -std=gnu11.
> > > neither -ansi nor -pedantic seem to stop it either.
> > it does look like it _should_ be possible to not have it set though? 
> > llvm/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp has:
> > ```
> >   if (LangOpts.GNUCVersion != 0) {
> > // Major, minor, patch, are given two decimal places each, so 4.2.1 
> > becomes
> > // 40201.
> > unsigned GNUCMajor = LangOpts.GNUCVersion / 100 / 100;
> > unsigned GNUCMinor = LangOpts.GNUCVersion / 100 % 100;
> > unsigned GNUCPatch = LangOpts.GNUCVersion % 100;
> > Builder.defineMacro("__GNUC__", Twine(GNUCMajor));
> > Builder.defineMacro("__GNUC_MINOR__", Twine(GNUCMinor));
> > Builder.defineMacro("__GNUC_PATCHLEVEL__", Twine(GNUCPatch));
> > Builder.defineMacro("__GXX_ABI_VERSION", "1002");
> > 
> > if (LangOpts.CPlusPlus) {
> >   Builder.defineMacro("__GNUG__", Twine(GNUCMajor));
> >   Builder.defineMacro("__GXX_WEAK__");
> > }
> >   }
> > ```
> /me wonders whether the right test here is actually `#if 
> __has_feature(__builtin_add_overflow)` (etc)...
> 
> but at this point, you definitely need an llvm person :-)
From 
https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins,
 we can check them with
 __has_builtin(__builtin_add_overflow) && __has_builtin(__builtin_sub_overflow) 
&& __has_builtin(__builtin_mul_overflow).
I saw some code also checks if __GNUC__ >= 5:

// The __GNUC__ checks can not be removed until we depend on GCC >= 10.1
// which is the first version that returns true for 
__has_builtin(__builtin_add_overflow)
#if __GNUC__ >= 5 || __has_builtin(__builtin_add_overflow)

I guess we don't need to support real gcc using this header here. So maybe only 
checking __has_builtin is enough?

By the way, if __builtin_add_overflow may not appear on some targets, do we 
need to modify tests to specify triple like "-triple "x86_64-unknown-unknown"" 
in 
https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/builtins-overflow.c#L5
 ?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

enh wrote:
> enh wrote:
> > enh wrote:
> > > ZijunZhao wrote:
> > > > enh wrote:
> > > > > is this ever _not_ set for clang?
> > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
> > > > I think it is set?
> > > i get an error from
> > > ```
> > > /tmp$ cat x.c
> > > #if defined(__GNUC__)
> > > #error foo
> > > #endif
> > > ```
> > > regardless of whether i compile with -std=c11 or -std=gnu11.
> > > neither -ansi nor -pedantic seem to stop it either.
> > it does look like it _should_ be possible to not have it set though? 
> > llvm/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp has:
> > ```
> >   if (LangOpts.GNUCVersion != 0) {
> > // Major, minor, patch, are given two decimal places each, so 4.2.1 
> > becomes
> > // 40201.
> > unsigned GNUCMajor = LangOpts.GNUCVersion / 100 / 100;
> > unsigned GNUCMinor = LangOpts.GNUCVersion / 100 % 100;
> > unsigned GNUCPatch = LangOpts.GNUCVersion % 100;
> > Builder.defineMacro("__GNUC__", Twine(GNUCMajor));
> > Builder.defineMacro("__GNUC_MINOR__", Twine(GNUCMinor));
> > Builder.defineMacro("__GNUC_PATCHLEVEL__", Twine(GNUCPatch));
> > Builder.defineMacro("__GXX_ABI_VERSION", "1002");
> > 
> > if (LangOpts.CPlusPlus) {
> >   Builder.defineMacro("__GNUG__", Twine(GNUCMajor));
> >   Builder.defineMacro("__GXX_WEAK__");
> > }
> >   }
> > ```
> /me wonders whether the right test here is actually `#if 
> __has_feature(__builtin_add_overflow)` (etc)...
> 
> but at this point, you definitely need an llvm person :-)
#ifndef __has_builtin // Optional of course.
  #define __has_builtin(x) 0  // Compatibility with non-clang compilers.
#endif

...
#if __has_builtin(__builtin_trap)
  __builtin_trap();
#else
  abort();
#endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157135: [OpenMP][Docs] Update OpenMP supported features table

2023-08-07 Thread David Pagan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6204724df56: [OpenMP][Docs] Update OpenMP supported 
features table (authored by ddpagan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157135

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -309,7 +309,7 @@
 
+--+--+--+---+
 | loop | 'reproducible'/'unconstrained' modifiers in 
'order' clause   | :part:`partial`  | D127855   
|
 
+--+--+--+---+
-| memory management| alignment for allocate directive and clause   
   | :part:`worked on`| 
  |
+| memory management| alignment for allocate directive and clause   
   | :good:`done` | D115683 
  |
 
+--+--+--+---+
 | memory management| new memory management routines
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -309,7 +309,7 @@
 +--+--+--+---+
 | loop | 'reproducible'/'unconstrained' modifiers in 'order' clause   | :part:`partial`  | D127855   |
 +--+--+--+---+
-| memory management| alignment for allocate directive and clause  | :part:`worked on`|   |
+| memory management| alignment for allocate directive and clause  | :good:`done` | D115683   |
 +--+--+--+---+
 | memory management| new memory management routines   | :none:`unclaimed`|   |
 +--+--+--+---+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f620472 - [OpenMP][Docs] Update OpenMP supported features table

2023-08-07 Thread Dave Pagan via cfe-commits

Author: Dave Pagan
Date: 2023-08-07T19:16:13-04:00
New Revision: f6204724df56188e82c6363aa13e1806cf6c5176

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

LOG: [OpenMP][Docs] Update OpenMP supported features table

Updated status of alignment clause for allocate directive in
OpenMP features table, section OpenMP 5.1 Implementation Details.

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index bfae0a7e43f775..a0ddfb605e658a 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -309,7 +309,7 @@ implementation.
 
+--+--+--+---+
 | loop | 'reproducible'/'unconstrained' modifiers in 
'order' clause   | :part:`partial`  | D127855   
|
 
+--+--+--+---+
-| memory management| alignment for allocate directive and clause   
   | :part:`worked on`| 
  |
+| memory management| alignment for allocate directive and clause   
   | :good:`done` | D115683 
  |
 
+--+--+--+---+
 | memory management| new memory management routines
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+



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


[PATCH] D156523: [clang][DeclPrinter] Fix AST print to suppress output of implicit (non-written) constructor initializers

2023-08-07 Thread Timo Stripf 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 rG291eb2589fdc: [clang][DeclPrinter] Fix AST print to suppress 
output of implicit (non-written)… (authored by strimo378).

Changed prior to commit:
  https://reviews.llvm.org/D156523?vs=545102=547988#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156523

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/test/AST/ast-print-method-decl.cpp


Index: clang/test/AST/ast-print-method-decl.cpp
===
--- clang/test/AST/ast-print-method-decl.cpp
+++ clang/test/AST/ast-print-method-decl.cpp
@@ -100,3 +100,26 @@
 
   // CHECK-NEXT: };
 };
+
+
+//  Check that implict (non-written) constructor initializers are not 
output
+
+struct ImplicitCtorInit1 {
+  int a;
+};
+
+// CHECK: struct ImplicitCtorInit2 : ImplicitCtorInit1 {
+struct ImplicitCtorInit2 : ImplicitCtorInit1 {
+
+  // CHECK-NEXT: ImplicitCtorInit2(int *) {
+  ImplicitCtorInit2(int *) {
+  // CHECK-NEXT: }
+  }
+
+  // CHECK-NEXT: ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
+  ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
+  // CHECK-NEXT: }
+  }
+
+  // CHECK-NEXT: };
+};
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -309,6 +309,8 @@
   for (const auto *BMInitializer : CDecl->inits()) {
 if (BMInitializer->isInClassMemberInitializer())
   continue;
+if (!BMInitializer->isWritten())
+  continue;
 
 if (!HasInitializerList) {
   Proto += " : ";


Index: clang/test/AST/ast-print-method-decl.cpp
===
--- clang/test/AST/ast-print-method-decl.cpp
+++ clang/test/AST/ast-print-method-decl.cpp
@@ -100,3 +100,26 @@
 
   // CHECK-NEXT: };
 };
+
+
+//  Check that implict (non-written) constructor initializers are not output
+
+struct ImplicitCtorInit1 {
+  int a;
+};
+
+// CHECK: struct ImplicitCtorInit2 : ImplicitCtorInit1 {
+struct ImplicitCtorInit2 : ImplicitCtorInit1 {
+
+  // CHECK-NEXT: ImplicitCtorInit2(int *) {
+  ImplicitCtorInit2(int *) {
+  // CHECK-NEXT: }
+  }
+
+  // CHECK-NEXT: ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
+  ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
+  // CHECK-NEXT: }
+  }
+
+  // CHECK-NEXT: };
+};
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -309,6 +309,8 @@
   for (const auto *BMInitializer : CDecl->inits()) {
 if (BMInitializer->isInClassMemberInitializer())
   continue;
+if (!BMInitializer->isWritten())
+  continue;
 
 if (!HasInitializerList) {
   Proto += " : ";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 291eb25 - [clang][DeclPrinter] Fix AST print to suppress output of implicit (non-written) constructor initializers

2023-08-07 Thread Timo Stripf via cfe-commits

Author: Timo Stripf
Date: 2023-08-07T23:13:50Z
New Revision: 291eb2589fdc78827af6c2c858bc5e9456e3dc20

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

LOG: [clang][DeclPrinter] Fix AST print to suppress output of implicit 
(non-written) constructor initializers

DeclPrinter::PrintConstructorInitializers did output non-written constructor 
initiaizers. In particular, implicit constructor initializers of base classes 
were output.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/AST/DeclPrinter.cpp
clang/test/AST/ast-print-method-decl.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 0608b48f3a880e..034fc874bd882b 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -309,6 +309,8 @@ void 
DeclPrinter::PrintConstructorInitializers(CXXConstructorDecl *CDecl,
   for (const auto *BMInitializer : CDecl->inits()) {
 if (BMInitializer->isInClassMemberInitializer())
   continue;
+if (!BMInitializer->isWritten())
+  continue;
 
 if (!HasInitializerList) {
   Proto += " : ";

diff  --git a/clang/test/AST/ast-print-method-decl.cpp 
b/clang/test/AST/ast-print-method-decl.cpp
index 928687b4b35894..37ddefcb611e18 100644
--- a/clang/test/AST/ast-print-method-decl.cpp
+++ b/clang/test/AST/ast-print-method-decl.cpp
@@ -100,3 +100,26 @@ struct DefMethodsWithoutBody {
 
   // CHECK-NEXT: };
 };
+
+
+//  Check that implict (non-written) constructor initializers are not 
output
+
+struct ImplicitCtorInit1 {
+  int a;
+};
+
+// CHECK: struct ImplicitCtorInit2 : ImplicitCtorInit1 {
+struct ImplicitCtorInit2 : ImplicitCtorInit1 {
+
+  // CHECK-NEXT: ImplicitCtorInit2(int *) {
+  ImplicitCtorInit2(int *) {
+  // CHECK-NEXT: }
+  }
+
+  // CHECK-NEXT: ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
+  ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
+  // CHECK-NEXT: }
+  }
+
+  // CHECK-NEXT: };
+};



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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Elliott Hughes via Phabricator via cfe-commits
enh added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

enh wrote:
> enh wrote:
> > ZijunZhao wrote:
> > > enh wrote:
> > > > is this ever _not_ set for clang?
> > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
> > > I think it is set?
> > i get an error from
> > ```
> > /tmp$ cat x.c
> > #if defined(__GNUC__)
> > #error foo
> > #endif
> > ```
> > regardless of whether i compile with -std=c11 or -std=gnu11.
> > neither -ansi nor -pedantic seem to stop it either.
> it does look like it _should_ be possible to not have it set though? 
> llvm/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp has:
> ```
>   if (LangOpts.GNUCVersion != 0) {
> // Major, minor, patch, are given two decimal places each, so 4.2.1 
> becomes
> // 40201.
> unsigned GNUCMajor = LangOpts.GNUCVersion / 100 / 100;
> unsigned GNUCMinor = LangOpts.GNUCVersion / 100 % 100;
> unsigned GNUCPatch = LangOpts.GNUCVersion % 100;
> Builder.defineMacro("__GNUC__", Twine(GNUCMajor));
> Builder.defineMacro("__GNUC_MINOR__", Twine(GNUCMinor));
> Builder.defineMacro("__GNUC_PATCHLEVEL__", Twine(GNUCPatch));
> Builder.defineMacro("__GXX_ABI_VERSION", "1002");
> 
> if (LangOpts.CPlusPlus) {
>   Builder.defineMacro("__GNUG__", Twine(GNUCMajor));
>   Builder.defineMacro("__GXX_WEAK__");
> }
>   }
> ```
/me wonders whether the right test here is actually `#if 
__has_feature(__builtin_add_overflow)` (etc)...

but at this point, you definitely need an llvm person :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Elliott Hughes via Phabricator via cfe-commits
enh added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

enh wrote:
> ZijunZhao wrote:
> > enh wrote:
> > > is this ever _not_ set for clang?
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
> > I think it is set?
> i get an error from
> ```
> /tmp$ cat x.c
> #if defined(__GNUC__)
> #error foo
> #endif
> ```
> regardless of whether i compile with -std=c11 or -std=gnu11.
> neither -ansi nor -pedantic seem to stop it either.
it does look like it _should_ be possible to not have it set though? 
llvm/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp has:
```
  if (LangOpts.GNUCVersion != 0) {
// Major, minor, patch, are given two decimal places each, so 4.2.1 becomes
// 40201.
unsigned GNUCMajor = LangOpts.GNUCVersion / 100 / 100;
unsigned GNUCMinor = LangOpts.GNUCVersion / 100 % 100;
unsigned GNUCPatch = LangOpts.GNUCVersion % 100;
Builder.defineMacro("__GNUC__", Twine(GNUCMajor));
Builder.defineMacro("__GNUC_MINOR__", Twine(GNUCMinor));
Builder.defineMacro("__GNUC_PATCHLEVEL__", Twine(GNUCPatch));
Builder.defineMacro("__GXX_ABI_VERSION", "1002");

if (LangOpts.CPlusPlus) {
  Builder.defineMacro("__GNUG__", Twine(GNUCMajor));
  Builder.defineMacro("__GXX_WEAK__");
}
  }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Elliott Hughes via Phabricator via cfe-commits
enh added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

ZijunZhao wrote:
> enh wrote:
> > is this ever _not_ set for clang?
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
> I think it is set?
i get an error from
```
/tmp$ cat x.c
#if defined(__GNUC__)
#error foo
#endif
```
regardless of whether i compile with -std=c11 or -std=gnu11.
neither -ansi nor -pedantic seem to stop it either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Zijun Zhao via Phabricator via cfe-commits
ZijunZhao added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

enh wrote:
> is this ever _not_ set for clang?
https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
I think it is set?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Elliott Hughes via Phabricator via cfe-commits
enh added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

is this ever _not_ set for clang?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Zijun Zhao via Phabricator via cfe-commits
ZijunZhao updated this revision to Diff 547986.
ZijunZhao marked an inline comment as done.
ZijunZhao added a comment.

1. Fix some format nits
2. Change `CHECK-NEXT` to `CHECK`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/stdckdint.h
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Headers/stdckdint.cpp
  clang/test/Modules/Inputs/System/usr/include/module.map

Index: clang/test/Modules/Inputs/System/usr/include/module.map
===
--- clang/test/Modules/Inputs/System/usr/include/module.map
+++ clang/test/Modules/Inputs/System/usr/include/module.map
@@ -14,6 +14,11 @@
 header "stdbool.h"
   }
 
+  // In both directories (compiler support version wins, does not forward)
+  module stdckdint {
+header "stdckdint.h"
+  }
+
   // In both directories (compiler support version wins, forwards)
   module stdint {
 header "stdint.h"
Index: clang/test/Headers/stdckdint.cpp
===
--- /dev/null
+++ clang/test/Headers/stdckdint.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -emit-llvm -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: define dso_local noundef zeroext i1 @_Z12test_ckd_addv() #0 {
+// CHECK:  entry:
+// CHECK:%0 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 -1073741826, i32 -1073741826)
+// CHECK:%1 = extractvalue { i32, i1 } %0, 1
+// CHECK:%2 = extractvalue { i32, i1 } %0, 0
+// CHECK:store i32 %2, ptr %result, align 4
+// CHECK:ret i1 %1
+// CHECK:}
+// CHECK:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+// CHECK:declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1
+bool test_ckd_add() {
+  int result;
+  return ckd_add(, -1073741826, -1073741826);
+}
+
+// CHECK-LABEL: define dso_local noundef zeroext i1 @_Z12test_ckd_subv() #0 {
+// CHECK:  entry:
+// CHECK:%0 = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 -1073741826, i32 1073741826)
+// CHECK:%1 = extractvalue { i32, i1 } %0, 1
+// CHECK:store i32 %2, ptr %result, align 4
+// CHECK:ret i1 %1
+// CHECK:}
+// CHECK:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+// CHECK:declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) #1
+bool test_ckd_sub() {
+  int result;
+  return ckd_sub(, -1073741826, 1073741826);
+}
+
+// CHECK-LABEL: define dso_local noundef zeroext i1 @_Z12test_ckd_mulv() #0 {
+// CHECK:  entry:
+// CHECK:%0 = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 -1073741826, i32 2)
+// CHECK:%1 = extractvalue { i32, i1 } %0, 1
+// CHECK:store i32 %2, ptr %result, align 4
+// CHECK:ret i1 %1
+// CHECK:}
+// CHECK:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+// CHECK:declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) #1
+bool test_ckd_mul() {
+  int result;
+  return ckd_mul(, -1073741826, 2);
+}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -207,7 +207,7 @@
 .Cases("assert.h", "complex.h", "ctype.h", "errno.h", "fenv.h", true)
 .Cases("float.h", "inttypes.h", "iso646.h", "limits.h", "locale.h", true)
 .Cases("math.h", "setjmp.h", "signal.h", "stdalign.h", "stdarg.h", true)
-.Cases("stdatomic.h", "stdbool.h", "stddef.h", "stdint.h", "stdio.h", true)
+.Cases("stdatomic.h", "stdbool.h", "stdckdint.h", "stddef.h", "stdint.h", "stdio.h", true)
 .Cases("stdlib.h", "stdnoreturn.h", "string.h", "tgmath.h", "threads.h", true)
 .Cases("time.h", "uchar.h", "wchar.h", "wctype.h", true)
 
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -384,6 +384,7 @@
.Case("stdarg.h", true)
.Case("stdatomic.h", true)
.Case("stdbool.h", true)
+   .Case("stdckdint.h", true)
.Case("stddef.h", true)
.Case("stdint.h", true)
.Case("tgmath.h", true)
Index: clang/lib/Headers/stdckdint.h
===
--- /dev/null
+++ clang/lib/Headers/stdckdint.h
@@ -0,0 +1,21 @@
+/*=== stdckdint.h - Standard header for checking integer===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+
+#ifndef __STDCKDINT_H
+#define 

[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-07 Thread David Pagan via Phabricator via cfe-commits
ddpagan updated this revision to Diff 547982.
ddpagan added a comment.

As requested, added reference to OpenMP 5.2 specification that discusses 
handling of if clauses with combined/composite directives. Also, improved 
comment relating to what was being done and why.


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

https://reviews.llvm.org/D157197

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp

Index: clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
@@ -695,7 +695,6 @@
 // CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
 // CHECK1-NEXT:store i32 0, ptr [[DOTOMP_COMB_LB]], align 4
@@ -729,16 +728,12 @@
 // CHECK1-NEXT:[[TMP8:%.*]] = zext i32 [[TMP7]] to i64
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
 // CHECK1-NEXT:[[TMP10:%.*]] = zext i32 [[TMP9]] to i64
-// CHECK1-NEXT:call void @__kmpc_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:[[TMP11:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store i32 0, ptr [[DOTBOUND_ZERO_ADDR]], align 4
-// CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83.omp_outlined.omp_outlined(ptr [[TMP11]], ptr [[DOTBOUND_ZERO_ADDR]], i64 [[TMP8]], i64 [[TMP10]]) #[[ATTR2]]
-// CHECK1-NEXT:call void @__kmpc_end_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
+// CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB3]], i32 2, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83.omp_outlined.omp_outlined, i64 [[TMP8]], i64 [[TMP10]])
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_INC:%.*]]
 // CHECK1:   omp.inner.for.inc:
-// CHECK1-NEXT:[[TMP12:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
-// CHECK1-NEXT:[[TMP13:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
-// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP12]], [[TMP13]]
+// CHECK1-NEXT:[[TMP11:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
+// CHECK1-NEXT:[[TMP12:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
+// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP11]], [[TMP12]]
 // CHECK1-NEXT:store i32 [[ADD]], ptr [[DOTOMP_IV]], align 4
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_COND]]
 // CHECK1:   omp.inner.for.end:
@@ -847,7 +842,6 @@
 // CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
 // CHECK1-NEXT:store i64 [[DOTCAPTURE_EXPR_]], ptr [[DOTCAPTURE_EXPR__ADDR]], align 8
@@ -882,25 +876,12 @@
 // CHECK1-NEXT:[[TMP8:%.*]] = zext i32 [[TMP7]] to i64
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
 // CHECK1-NEXT:[[TMP10:%.*]] = zext i32 [[TMP9]] to i64
-// CHECK1-NEXT:[[TMP11:%.*]] = load i8, ptr [[DOTCAPTURE_EXPR__ADDR]], align 1
-// CHECK1-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP11]] to i1
-// CHECK1-NEXT:br i1 [[TOBOOL]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_ELSE:%.*]]
-// CHECK1:   omp_if.then:
 // CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB3]], i32 2, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l90.omp_outlined.omp_outlined, i64 [[TMP8]], i64 [[TMP10]])
-// CHECK1-NEXT:br label [[OMP_IF_END:%.*]]
-// CHECK1:   omp_if.else:
-// CHECK1-NEXT:call void @__kmpc_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:[[TMP12:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store i32 0, ptr [[DOTBOUND_ZERO_ADDR]], align 4
-// CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l90.omp_outlined.omp_outlined(ptr [[TMP12]], ptr [[DOTBOUND_ZERO_ADDR]], i64 [[TMP8]], i64 [[TMP10]]) #[[ATTR2]]
-// CHECK1-NEXT:call void @__kmpc_end_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:br label [[OMP_IF_END]]
-// CHECK1:   omp_if.end:
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_INC:%.*]]
 // CHECK1:   omp.inner.for.inc:
-// CHECK1-NEXT:[[TMP13:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
-// CHECK1-NEXT:[[TMP14:%.*]] = load i32, ptr 

[PATCH] D156743: clang/OpenCL: Add inline implementations of sqrt in builtin header

2023-08-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Headers/opencl-c-base.h:832
+
+inline float __ovld __cnfn sqrt(float __x) {
+  return __builtin_elementwise_sqrt(__x);

Anastasia wrote:
> arsenm wrote:
> > svenvh wrote:
> > > Anastasia wrote:
> > > > Is this a generic implementation enough? Would some targets not need to 
> > > > do something different for this built-in?
> > > > 
> > > > Ideally this header is to be kept light so I am a bit worried about 
> > > > adding definitions of the functions here. Otherwise we will end up in 
> > > > the same situation as we one day were with opencl-c.h. So could these 
> > > > be left there instead? It might be good to check with @svenvh if 
> > > > TableGen header has already a way to do this function forwarding or can 
> > > > be extended to do such a thing. Then it would be implementable in the 
> > > > both header mechanisms. I don't know if Sven has some other ideas or 
> > > > opinions...
> > > We did already discuss this a bit on the GitHub issue: 
> > > https://github.com/llvm/llvm-project/issues/64264
> > As I mentioned on the ticket, it's only this one case so I'm not worried 
> > about adding a lot more to the base header. I think we can start by 
> > assuming llvm.sqrt always works correctly, I don't want to add more 
> > complexity to handle this case without a specific reason
> > As I mentioned on the ticket, it's only this one case so I'm not worried 
> > about adding a lot more to the base header.
> 
> This is how things normally start. Someone else might want to continue this 
> approach because it is already there.
> 
> >I think we can start by assuming llvm.sqrt always works correctly, I don't 
> >want to add more complexity to handle this case without a specific reason
> 
> Do you mean it would apply to all implementations? What I am missing here is 
> why it is required to be in the headers? Is this because it needs to be 
> inlined or is it because the compiler must see `__builtin_elementwise_sqrt` 
> with the surrounding code where it is called from?
Yes, I would expect any llvm consumer to correctly lower llvm.sqrt, and such an 
implementation would be correctly rounded and pass conformance with 
-cl-fp32-correctly-rounded-divide-sqrt

The goal is to get !fpmath attached to an llvm.sqrt call. The way this 
currently happens is based on the language, it gets emitted from the various 
__builtin_sqrt* calls


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

https://reviews.llvm.org/D156743

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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

For the record, the documentation for stdckdint.h is here: 
https://open-std.org/JTC1/SC22/WG14/www/docs/n3096.pdf#page=330


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[clang] 3e66a17 - Reland [clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body

2023-08-07 Thread Timo Stripf via cfe-commits

Author: Timo Stripf
Date: 2023-08-07T22:14:15Z
New Revision: 3e66a174dfd2144672cb7e23afb33df109abadd1

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

LOG: Reland [clang][DeclPrinter] Fix missing semicolon in AST print for methods 
that are definitions without having a body

DeclPrinter used FunctionDecl::isThisDeclarationADefinition to decide if the 
decl requires a semicolon at the end. However, there are several methods 
without body (that require a semicolon) that are definitions.

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

Initial commit had a failing test case on targets not supporting 
`__attribute__((alias))`. Added `-triple i386-linux-gnu` to the specific test 
case.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/AST/DeclPrinter.cpp
clang/test/AST/ast-print-method-decl.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index bf4d26c723d2e6..0608b48f3a880e 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -463,12 +463,12 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool 
Indent) {
 else if (isa(*D) && cast(*D)->hasBody())
   Terminator = nullptr;
 else if (auto FD = dyn_cast(*D)) {
-  if (FD->isThisDeclarationADefinition())
+  if (FD->doesThisDeclarationHaveABody() && !FD->isDefaulted())
 Terminator = nullptr;
   else
 Terminator = ";";
 } else if (auto TD = dyn_cast(*D)) {
-  if (TD->getTemplatedDecl()->isThisDeclarationADefinition())
+  if (TD->getTemplatedDecl()->doesThisDeclarationHaveABody())
 Terminator = nullptr;
   else
 Terminator = ";";

diff  --git a/clang/test/AST/ast-print-method-decl.cpp 
b/clang/test/AST/ast-print-method-decl.cpp
index 505e07dde1a868..928687b4b35894 100644
--- a/clang/test/AST/ast-print-method-decl.cpp
+++ b/clang/test/AST/ast-print-method-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ast-print %s -o - -std=c++20 | FileCheck %s
+// RUN: %clang_cc1 -ast-print -triple i386-linux-gnu %s -o - -std=c++20 | 
FileCheck %s
 
 // CHECK: struct DelegatingCtor1 {
 struct DelegatingCtor1 {
@@ -85,3 +85,18 @@ struct CurlyCtorInit {
 
   // CHECK-NEXT: };
 };
+
+
+// CHECK: struct DefMethodsWithoutBody {
+struct DefMethodsWithoutBody {
+  // CHECK-NEXT: DefMethodsWithoutBody() = delete;
+  DefMethodsWithoutBody() = delete;
+
+  // CHECK-NEXT: DefMethodsWithoutBody() = default;
+  ~DefMethodsWithoutBody() = default;
+
+  // CHECK-NEXT: void m1() __attribute__((alias("X")));
+  void m1() __attribute__((alias("X")));
+
+  // CHECK-NEXT: };
+};



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


[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:1
+/*=== stdckdint.h - Standard header for checking integer
+ *-===

nit: format.



Comment at: clang/test/Headers/stdckdint.cpp:1
+// RUN: %clang_cc1 -emit-llvm  -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | 
FileCheck --check-prefix=CHECK-NEXT %s
+

1. nit: `-emit-llvm  -fgnuc-version=4.2.` has two spaces.
2. please chose a prefix other than `CHECK-NEXT`. as it has special meaning. 
https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-next-directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D156014: [Clang][NVPTX] Permit use of the alias attribute for NVPTX targets

2023-08-07 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D156014#4567446 , @jhuber6 wrote:

> In D156014#4567363 , @steven_wu 
> wrote:
>
>> This breaks macOS bot: 
>> https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/36900/testReport/junit/Clang/SemaCUDA/alias_cu/
>
> I should've fixed that already. Is it still broken?

9e99a4f0db0e21b68e9aab9ad6f32f34d42eb460 
 ? That is 
not yet built but looks promising. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156014

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


[PATCH] D157076: [clang][ExtractAPI] Add support for C++ class templates and concepts

2023-08-07 Thread Erick Velez via Phabricator via cfe-commits
evelez7 updated this revision to Diff 547971.
evelez7 added a comment.

Refactor template arg name deduction to get as string for 
FragmentKind::typeIdentifier


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157076

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/class_template.cpp
  clang/test/ExtractAPI/class_template_partial_spec.cpp
  clang/test/ExtractAPI/class_template_spec.cpp
  clang/test/ExtractAPI/concept.cpp

Index: clang/test/ExtractAPI/concept.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/concept.cpp
@@ -0,0 +1,133 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -std=c++20 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template concept Foo = true;
+
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "keyword",
+  "spelling": "typename"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "genericParameter",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": "> "
+},
+{
+  "kind": "keyword",
+  "spelling": "concept"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@CT@Foo"
+  },
+  "kind": {
+"displayName": "Concept",
+"identifier": "c++.concept"
+  },
+  "location": {
+"position": {
+  "character": 30,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ],
+  "swiftGenerics": {
+"parameters": [
+  {
+"depth": 0,
+"index": 0,
+"name": "T"
+  }
+]
+  }
+}
+  ]
+}
Index: clang/test/ExtractAPI/class_template_spec.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/class_template_spec.cpp
@@ -0,0 +1,206 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template class Foo {};
+
+template<> class Foo {};
+
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 

[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Yabin Cui via Phabricator via cfe-commits
yabinc accepted this revision.
yabinc added a comment.
This revision is now accepted and ready to land.

LGTM, but please wait for a couple of days in case others wish to review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D156466: [clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

2023-08-07 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6267d3b98c1: [clang][CGExprConstant] handle implicit 
widening/narrowing Int-to-Int casts (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156466

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/global-init.c


Index: clang/test/CodeGen/global-init.c
===
--- clang/test/CodeGen/global-init.c
+++ clang/test/CodeGen/global-init.c
@@ -49,6 +49,11 @@
 // CHECK: @yuv_types ={{.*}} global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", 
[6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
 
+unsigned long long x = -1000;
+// CHECK: @x ={{.*}} global i64 -1000
+unsigned long long uint_max = 4294967295u;
+// CHECK: @uint_max ={{.*}} global i64 4294967295
+
 
 // NOTE: tentative definitions are processed at the end of the translation 
unit.
 
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1139,6 +1139,24 @@
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
+case CK_IntegralCast: {
+  QualType FromType = subExpr->getType();
+  // See also HandleIntToIntCast in ExprConstant.cpp
+  if (FromType->isIntegerType())
+if (llvm::Constant *C = Visit(subExpr, FromType))
+  if (auto *CI = dyn_cast(C)) {
+unsigned SrcWidth = CGM.getContext().getIntWidth(FromType);
+unsigned DstWidth = CGM.getContext().getIntWidth(destType);
+if (DstWidth == SrcWidth)
+  return CI;
+llvm::APInt A = FromType->isSignedIntegerType()
+? CI->getValue().sextOrTrunc(DstWidth)
+: CI->getValue().zextOrTrunc(DstWidth);
+return llvm::ConstantInt::get(CGM.getLLVMContext(), A);
+  }
+  return nullptr;
+}
+
 case CK_Dependent: llvm_unreachable("saw dependent cast!");
 
 case CK_BuiltinFnToFnPtr:
@@ -1191,7 +1209,6 @@
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:
 case CK_IntegralToBoolean:


Index: clang/test/CodeGen/global-init.c
===
--- clang/test/CodeGen/global-init.c
+++ clang/test/CodeGen/global-init.c
@@ -49,6 +49,11 @@
 // CHECK: @yuv_types ={{.*}} global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", [6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
 
+unsigned long long x = -1000;
+// CHECK: @x ={{.*}} global i64 -1000
+unsigned long long uint_max = 4294967295u;
+// CHECK: @uint_max ={{.*}} global i64 4294967295
+
 
 // NOTE: tentative definitions are processed at the end of the translation unit.
 
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1139,6 +1139,24 @@
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
+case CK_IntegralCast: {
+  QualType FromType = subExpr->getType();
+  // See also HandleIntToIntCast in ExprConstant.cpp
+  if (FromType->isIntegerType())
+if (llvm::Constant *C = Visit(subExpr, FromType))
+  if (auto *CI = dyn_cast(C)) {
+unsigned SrcWidth = CGM.getContext().getIntWidth(FromType);
+unsigned DstWidth = CGM.getContext().getIntWidth(destType);
+if (DstWidth == SrcWidth)
+  return CI;
+llvm::APInt A = FromType->isSignedIntegerType()
+? CI->getValue().sextOrTrunc(DstWidth)
+: CI->getValue().zextOrTrunc(DstWidth);
+return llvm::ConstantInt::get(CGM.getLLVMContext(), A);
+  }
+  return nullptr;
+}
+
 case CK_Dependent: llvm_unreachable("saw dependent cast!");
 
 case CK_BuiltinFnToFnPtr:
@@ -1191,7 +1209,6 @@
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:
 case CK_IntegralToBoolean:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156014: [Clang][NVPTX] Permit use of the alias attribute for NVPTX targets

2023-08-07 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D156014#4567363 , @steven_wu wrote:

> This breaks macOS bot: 
> https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/36900/testReport/junit/Clang/SemaCUDA/alias_cu/

I should've fixed that already. Is it still broken?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156014

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


[clang] f6267d3 - [clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

2023-08-07 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2023-08-07T14:57:25-07:00
New Revision: f6267d3b98c11b50bf24946f21c6646d2d3f6fa8

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

LOG: [clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

Consider the following statements:
long x = 1;
short y = 1;

With the following AST:
|-VarDecl 0x55d289973730  col:6 x 'long' cinit
| `-ImplicitCastExpr 0x55d289973800  'long' 
|   `-IntegerLiteral 0x55d2899737e0  'int' 1
`-VarDecl 0x55d289973830  col:7 y 'short' cinit
  `-ImplicitCastExpr 0x55d2899738b8  'short' 
`-IntegerLiteral 0x55d289973898  'int' 1

Sign or Zero extend or truncate based on the source signedness and
destination width.

Reviewed By: efriedma

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp
clang/test/CodeGen/global-init.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index e482b57eb144d7..b0f52066daeeca 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1139,6 +1139,24 @@ class ConstExprEmitter :
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
+case CK_IntegralCast: {
+  QualType FromType = subExpr->getType();
+  // See also HandleIntToIntCast in ExprConstant.cpp
+  if (FromType->isIntegerType())
+if (llvm::Constant *C = Visit(subExpr, FromType))
+  if (auto *CI = dyn_cast(C)) {
+unsigned SrcWidth = CGM.getContext().getIntWidth(FromType);
+unsigned DstWidth = CGM.getContext().getIntWidth(destType);
+if (DstWidth == SrcWidth)
+  return CI;
+llvm::APInt A = FromType->isSignedIntegerType()
+? CI->getValue().sextOrTrunc(DstWidth)
+: CI->getValue().zextOrTrunc(DstWidth);
+return llvm::ConstantInt::get(CGM.getLLVMContext(), A);
+  }
+  return nullptr;
+}
+
 case CK_Dependent: llvm_unreachable("saw dependent cast!");
 
 case CK_BuiltinFnToFnPtr:
@@ -1191,7 +1209,6 @@ class ConstExprEmitter :
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:
 case CK_IntegralToBoolean:

diff  --git a/clang/test/CodeGen/global-init.c 
b/clang/test/CodeGen/global-init.c
index a69f0288561104..fbf3c973ad9755 100644
--- a/clang/test/CodeGen/global-init.c
+++ b/clang/test/CodeGen/global-init.c
@@ -49,6 +49,11 @@ struct K {
 // CHECK: @yuv_types ={{.*}} global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", 
[6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
 
+unsigned long long x = -1000;
+// CHECK: @x ={{.*}} global i64 -1000
+unsigned long long uint_max = 4294967295u;
+// CHECK: @uint_max ={{.*}} global i64 4294967295
+
 
 // NOTE: tentative definitions are processed at the end of the translation 
unit.
 



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


[PATCH] D157334: [clang] Define _MSC_EXTENSIONS on -gnu if -fms-extensions is set

2023-08-07 Thread Aiden Grossman via Phabricator via cfe-commits
aidengrossman added reviewers: aaron.ballman, hans, mstorsjo, rnk, glandium.
aidengrossman added a comment.

This should fix the issues seen in https://reviews.llvm.org/D150646 regarding 
`-fms-extensions` being set on MinGW and the builtins being defined but no 
`_MSC_EXTENSIONS` macro being set which caused a redefinition of the 
`__cpuidex` function. I'm not sure if this is 100% correct, but at least 
something needs to be done when `-fms-extensions` is passed and the target 
triple includes `-gnu`. Also not sure what happened with the patch formatting 
in Phabricator. The git diff is much cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157334

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


[PATCH] D156378: [clang][CGExprConstant] handle unary negation on integrals

2023-08-07 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG769333aeeb45: [clang][CGExprConstant] handle unary negation 
on integrals (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156378

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1363,6 +1363,13 @@
 return Visit(E->getSubExpr(), T);
   }
 
+  llvm::Constant *VisitUnaryMinus(UnaryOperator *U, QualType T) {
+if (llvm::Constant *C = Visit(U->getSubExpr(), T))
+  if (auto *CI = dyn_cast(C))
+return llvm::ConstantInt::get(CGM.getLLVMContext(), -CI->getValue());
+return nullptr;
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1363,6 +1363,13 @@
 return Visit(E->getSubExpr(), T);
   }
 
+  llvm::Constant *VisitUnaryMinus(UnaryOperator *U, QualType T) {
+if (llvm::Constant *C = Visit(U->getSubExpr(), T))
+  if (auto *CI = dyn_cast(C))
+return llvm::ConstantInt::get(CGM.getLLVMContext(), -CI->getValue());
+return nullptr;
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 769333a - [clang][CGExprConstant] handle unary negation on integrals

2023-08-07 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2023-08-07T14:51:01-07:00
New Revision: 769333aeeb4508a39ce61cde5d70d880f9abfc35

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

LOG: [clang][CGExprConstant] handle unary negation on integrals

Consider the statement:
int x = -1;
And the following AST:
`-VarDecl 0x55c4823a7670  col:5 x 'int' cinit
  `-UnaryOperator 0x55c4823a7740  'int' prefix '-'
`-IntegerLiteral 0x55c4823a7720  'int' 1

Return the evaluation of the subexpression negated.

Reviewed By: efriedma

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index 9ad07f7d2220a7..e482b57eb144d7 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1363,6 +1363,13 @@ class ConstExprEmitter :
 return Visit(E->getSubExpr(), T);
   }
 
+  llvm::Constant *VisitUnaryMinus(UnaryOperator *U, QualType T) {
+if (llvm::Constant *C = Visit(U->getSubExpr(), T))
+  if (auto *CI = dyn_cast(C))
+return llvm::ConstantInt::get(CGM.getLLVMContext(), -CI->getValue());
+return nullptr;
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);



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


[PATCH] D157334: [clang] Define _MSC_EXTENSIONS on -gnu if -fms-extensions is set

2023-08-07 Thread Aiden Grossman via Phabricator via cfe-commits
aidengrossman created this revision.
Herald added subscribers: pengfei, mstorsjo.
Herald added a project: All.
aidengrossman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch makes sure _MSC_EXTENSIONS is defined if -fms-extensions is set by 
hosting the logic for setting the -fms-extensions related macros out of some 
conditional checks related to the target triple. Otherwise we would end up in 
situations where Windows builtins added by -fms-extensions would be defined but 
_MSC_EXTENSIONS wouldn't be defined like on MinGW with the triple 
x86_64-windows-gnu.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157334

Files:
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/test/Preprocessor/predefined-win-macros.c


Index: clang/test/Preprocessor/predefined-win-macros.c
===
--- clang/test/Preprocessor/predefined-win-macros.c
+++ clang/test/Preprocessor/predefined-win-macros.c
@@ -120,9 +120,14 @@
 // CHECK-AMD64-MINGW: #define _WIN32 1
 // CHECK-AMD64-MINGW: #define _WIN64 1

+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - -fms-extensions \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW-MSE
+
+// CHECK-AMD64-MINGW-MSE: #define _MSC_EXTENSIONS 1
+
 // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW

 // CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
 // CHECK-ARM64-MINGW: #define WIN32 1
 // CHECK-ARM64-MINGW: #define WIN64 1
Index: clang/lib/Basic/Targets/OSTargets.cpp
===
--- clang/lib/Basic/Targets/OSTargets.cpp
+++ clang/lib/Basic/Targets/OSTargets.cpp
@@ -226,25 +226,15 @@
 }
   }

-  if (Opts.MicrosoftExt) {
-Builder.defineMacro("_MSC_EXTENSIONS");
-
-if (Opts.CPlusPlus11) {
-  Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
-  Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
-  Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
-}
-  }
-
   if (!Opts.MSVolatile)
 Builder.defineMacro("_ISO_VOLATILE");

   if (Opts.Kernel)
 Builder.defineMacro("_KERNEL_MODE");

   Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
   Builder.defineMacro("__STDC_NO_THREADS__");

   // Starting with VS 2022 17.1, MSVC predefines the below macro to inform
   // users of the execution character set defined at compile time.
   // The value given is the Windows Code Page Identifier:
@@ -264,7 +254,17 @@
   else if (Triple.isKnownWindowsMSVCEnvironment() ||
(Triple.isWindowsItaniumEnvironment() && Opts.MSVCCompat))
 addVisualCDefines(Opts, Builder);
+
+  if (Opts.MicrosoftExt) {
+Builder.defineMacro("_MSC_EXTENSIONS");
+
+if (Opts.CPlusPlus11) {
+  Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
+  Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
+  Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
+}
+  }
 }

 } // namespace targets
 } // namespace clang


Index: clang/test/Preprocessor/predefined-win-macros.c
===
--- clang/test/Preprocessor/predefined-win-macros.c
+++ clang/test/Preprocessor/predefined-win-macros.c
@@ -120,9 +120,14 @@
 // CHECK-AMD64-MINGW: #define _WIN32 1
 // CHECK-AMD64-MINGW: #define _WIN64 1

+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - -fms-extensions \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW-MSE
+
+// CHECK-AMD64-MINGW-MSE: #define _MSC_EXTENSIONS 1
+
 // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW

 // CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
 // CHECK-ARM64-MINGW: #define WIN32 1
 // CHECK-ARM64-MINGW: #define WIN64 1
Index: clang/lib/Basic/Targets/OSTargets.cpp
===
--- clang/lib/Basic/Targets/OSTargets.cpp
+++ clang/lib/Basic/Targets/OSTargets.cpp
@@ -226,25 +226,15 @@
 }
   }

-  if (Opts.MicrosoftExt) {
-Builder.defineMacro("_MSC_EXTENSIONS");
-
-if (Opts.CPlusPlus11) {
-  Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
-  Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
-  Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
-}
-  }
-
   if (!Opts.MSVolatile)
 Builder.defineMacro("_ISO_VOLATILE");

   if (Opts.Kernel)
 Builder.defineMacro("_KERNEL_MODE");

   Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
   Builder.defineMacro("__STDC_NO_THREADS__");

   // Starting with VS 2022 17.1, MSVC predefines the below macro to inform
   // users of the execution character set defined at compile time.
   // The value given is the Windows Code Page Identifier:
@@ -264,7 +254,17 @@
   else if (Triple.isKnownWindowsMSVCEnvironment() ||

[PATCH] D156014: [Clang][NVPTX] Permit use of the alias attribute for NVPTX targets

2023-08-07 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

This breaks macOS bot: 
https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/36900/testReport/junit/Clang/SemaCUDA/alias_cu/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156014

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


[PATCH] D157332: [clang] Make init for empty no_unique_address fields a no-op write

2023-08-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: aaron.ballman, efriedma.
Herald added subscribers: steven.zhang, pengfei.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang.

An empty struct is handled as a struct with a dummy i8, on all targets.

Most targets treat an empty struct return value as essentially
void - but some don't. (Currently, at least x86_64-windows-* and
powerpc64le-* don't treat it as void.)

When intializing a struct with such a no_unique_address member,
make sure we don't write the dummy i8 into the struct where there's
no space allocated for it.

Previously it would clobber the actual valid data of the struct.

The existing clang tests in CodeGenCXX/tail-padding.cpp contain
cases of fields that have no_unique_address on non-empty struct
members; the check for isEmptyRecord() is needed to retain the
previous behaviour in that test.

Fixes https://github.com/llvm/llvm-project/issues/64253, and
possibly https://github.com/llvm/llvm-project/issues/64077
and https://github.com/llvm/llvm-project/issues/64427 as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157332

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/ctor-empty-nounique.cpp


Index: clang/test/CodeGenCXX/ctor-empty-nounique.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ctor-empty-nounique.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -o - %s | FileCheck %s
+
+// An empty struct is handled as a struct with a dummy i8, on all targets.
+// Most targets treat an empty struct return value as essentially void - but
+// some don't. (Currently, at least x86_64-windows-* and powerpc64le-* don't
+// treat it as void.)
+//
+// When intializing a struct with such a no_unique_address member, make sure we
+// don't write the dummy i8 into the struct where there's no space allocated 
for
+// it.
+//
+// This can only be tested with targets that don't treat empty struct returns 
as
+// void.
+
+struct S {};
+S f();
+struct Z {
+  int x;
+  [[no_unique_address]] S y;
+  Z();
+};
+Z::Z() : x(111), y(f()) {}
+
+// CHECK: define {{.*}} @_ZN1ZC2Ev
+
+// CHECK: %coerce = alloca %struct.S, align 1
+
+// CHECK: %call = call i8 @_Z1fv()
+// CHECK-NEXT: %coerce.dive = getelementptr inbounds %struct.S, ptr %coerce, 
i32 0, i32 0
+// CHECK-NEXT: store i8 %call, ptr %coerce.dive, align 1
+// CHECK-NEXT: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -10,6 +10,7 @@
 //
 
//===--===//
 
+#include "ABIInfoImpl.h"
 #include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGDebugInfo.h"
@@ -701,6 +702,9 @@
 getOverlapForFieldInit(Field), AggValueSlot::IsNotZeroed,
 // Checks are made by the code that calls constructor.
 AggValueSlot::IsSanitizerChecked);
+if (Field->hasAttr() &&
+isEmptyRecord(getContext(), FieldType, true))
+  Slot = AggValueSlot::ignored();
 EmitAggExpr(Init, Slot);
 break;
   }


Index: clang/test/CodeGenCXX/ctor-empty-nounique.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ctor-empty-nounique.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -o - %s | FileCheck %s
+
+// An empty struct is handled as a struct with a dummy i8, on all targets.
+// Most targets treat an empty struct return value as essentially void - but
+// some don't. (Currently, at least x86_64-windows-* and powerpc64le-* don't
+// treat it as void.)
+//
+// When intializing a struct with such a no_unique_address member, make sure we
+// don't write the dummy i8 into the struct where there's no space allocated for
+// it.
+//
+// This can only be tested with targets that don't treat empty struct returns as
+// void.
+
+struct S {};
+S f();
+struct Z {
+  int x;
+  [[no_unique_address]] S y;
+  Z();
+};
+Z::Z() : x(111), y(f()) {}
+
+// CHECK: define {{.*}} @_ZN1ZC2Ev
+
+// CHECK: %coerce = alloca %struct.S, align 1
+
+// CHECK: %call = call i8 @_Z1fv()
+// CHECK-NEXT: %coerce.dive = getelementptr inbounds %struct.S, ptr %coerce, i32 0, i32 0
+// CHECK-NEXT: store i8 %call, ptr %coerce.dive, align 1
+// CHECK-NEXT: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "ABIInfoImpl.h"
 #include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGDebugInfo.h"
@@ -701,6 +702,9 @@
 getOverlapForFieldInit(Field), AggValueSlot::IsNotZeroed,
 // Checks are made by the code that calls 

[PATCH] D157324: [clang] Move the Clang CI jobs off of the libc++ builders

2023-08-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 547950.
ldionne added a comment.

Try to fix build on queue=linux builders


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157324

Files:
  clang/utils/ci/buildkite-pipeline.yml


Index: clang/utils/ci/buildkite-pipeline.yml
===
--- clang/utils/ci/buildkite-pipeline.yml
+++ clang/utils/ci/buildkite-pipeline.yml
@@ -22,8 +22,7 @@
   - "clang/utils/ci/run-buildbot check-format"
 
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
@@ -35,12 +34,8 @@
   - label: "Building clang"
 commands:
   - "clang/utils/ci/run-buildbot build-clang"
-env:
-CC: "clang-${LLVM_HEAD_VERSION}"
-CXX: "clang++-${LLVM_HEAD_VERSION}"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
@@ -49,7 +44,7 @@
 
   - wait
 
-  - label: "C++03"
+  - label: "Running libc++ test suite in C++03"
 commands:
   - "clang/utils/ci/run-buildbot generic-cxx03"
 artifact_paths:
@@ -59,15 +54,14 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" 
# TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
   limit: 2
 timeout_in_minutes: 120
 
-  - label: "C++26"
+  - label: "Running libc++ test suite in C++26"
 commands:
   - "clang/utils/ci/run-buildbot generic-cxx26"
 artifact_paths:
@@ -77,15 +71,14 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" 
# TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
   limit: 2
 timeout_in_minutes: 120
 
-  - label: "Modules"
+  - label: "Running libc++ test suite with Clang Modules"
 commands:
   - "clang/utils/ci/run-buildbot generic-modules"
 artifact_paths:
@@ -95,8 +88,7 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" 
# TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost


Index: clang/utils/ci/buildkite-pipeline.yml
===
--- clang/utils/ci/buildkite-pipeline.yml
+++ clang/utils/ci/buildkite-pipeline.yml
@@ -22,8 +22,7 @@
   - "clang/utils/ci/run-buildbot check-format"
 
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
@@ -35,12 +34,8 @@
   - label: "Building clang"
 commands:
   - "clang/utils/ci/run-buildbot build-clang"
-env:
-CC: "clang-${LLVM_HEAD_VERSION}"
-CXX: "clang++-${LLVM_HEAD_VERSION}"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
@@ -49,7 +44,7 @@
 
   - wait
 
-  - label: "C++03"
+  - label: "Running libc++ test suite in C++03"
 commands:
   - "clang/utils/ci/run-buildbot generic-cxx03"
 artifact_paths:
@@ -59,15 +54,14 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" # TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
   limit: 2
 timeout_in_minutes: 120
 
-  - label: "C++26"
+  - label: "Running libc++ test suite in C++26"
 commands:
   - "clang/utils/ci/run-buildbot generic-cxx26"
 artifact_paths:
@@ -77,15 +71,14 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" # TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
   limit: 2
 timeout_in_minutes: 120
 
-  - label: "Modules"
+  - label: "Running libc++ test suite with Clang Modules"
 commands:
   - "clang/utils/ci/run-buildbot generic-modules"
 artifact_paths:
@@ -95,8 +88,7 @@
 

[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Zijun Zhao via Phabricator via cfe-commits
ZijunZhao updated this revision to Diff 547949.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/stdckdint.h
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Headers/stdckdint.cpp
  clang/test/Modules/Inputs/System/usr/include/module.map

Index: clang/test/Modules/Inputs/System/usr/include/module.map
===
--- clang/test/Modules/Inputs/System/usr/include/module.map
+++ clang/test/Modules/Inputs/System/usr/include/module.map
@@ -14,6 +14,11 @@
 header "stdbool.h"
   }
 
+  // In both directories (compiler support version wins, does not forward)
+  module stdckdint {
+header "stdckdint.h"
+  }
+
   // In both directories (compiler support version wins, forwards)
   module stdint {
 header "stdint.h"
Index: clang/test/Headers/stdckdint.cpp
===
--- /dev/null
+++ clang/test/Headers/stdckdint.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -emit-llvm  -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | FileCheck --check-prefix=CHECK-NEXT %s
+
+
+#include 
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add() #0 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:%0 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 -1073741826, i32 -1073741826)
+// CHECK-NEXT:%1 = extractvalue { i32, i1 } %0, 1 
+// CHECK-NEXT:store i32 %2, ptr %result, align 4 
+// CHECK-NEXT:ret i1 %1 
+// CHECK-NEXT:} 
+// CHECK-NEXT:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 
+// CHECK-NEXT:declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1 
+bool test_ckd_add() {
+  int result;
+  return ckd_add(, -1073741826, -1073741826);
+}
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_sub() #0 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:%0 = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 -1073741826, i32 1073741826)
+// CHECK-NEXT:%1 = extractvalue { i32, i1 } %0, 1 
+// CHECK-NEXT:store i32 %2, ptr %result, align 4 
+// CHECK-NEXT:ret i1 %1 
+// CHECK-NEXT:} 
+// CHECK-NEXT:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 
+// CHECK-NEXT:declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) #1 
+bool test_ckd_sub() {
+  int result;
+  return ckd_sub(, -1073741826, 1073741826);
+}
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_mul() #0 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:%0 = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 -1073741826, i32 2)
+// CHECK-NEXT:%1 = extractvalue { i32, i1 } %0, 1 
+// CHECK-NEXT:store i32 %2, ptr %result, align 4
+// CHECK-NEXT:ret i1 %1 
+// CHECK-NEXT:} 
+// CHECK-NEXT:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 
+// CHECK-NEXT:declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) #1 
+bool test_ckd_mul() {
+  int result;
+  return ckd_mul(, -1073741826, 2);
+}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -207,7 +207,7 @@
 .Cases("assert.h", "complex.h", "ctype.h", "errno.h", "fenv.h", true)
 .Cases("float.h", "inttypes.h", "iso646.h", "limits.h", "locale.h", true)
 .Cases("math.h", "setjmp.h", "signal.h", "stdalign.h", "stdarg.h", true)
-.Cases("stdatomic.h", "stdbool.h", "stddef.h", "stdint.h", "stdio.h", true)
+.Cases("stdatomic.h", "stdbool.h", "stdckdint.h", "stddef.h", "stdint.h", "stdio.h", true)
 .Cases("stdlib.h", "stdnoreturn.h", "string.h", "tgmath.h", "threads.h", true)
 .Cases("time.h", "uchar.h", "wchar.h", "wctype.h", true)
 
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -384,6 +384,7 @@
.Case("stdarg.h", true)
.Case("stdatomic.h", true)
.Case("stdbool.h", true)
+   .Case("stdckdint.h", true)
.Case("stddef.h", true)
.Case("stdint.h", true)
.Case("tgmath.h", true)
Index: clang/lib/Headers/stdckdint.h
===
--- /dev/null
+++ clang/lib/Headers/stdckdint.h
@@ -0,0 +1,22 @@
+/*=== stdckdint.h - Standard header for checking integer
+ *-===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+
+#ifndef __STDCKDINT_H
+#define __STDCKDINT_H
+
+#if defined(__GNUC__)

[PATCH] D157331: [clang] Implement C23

2023-08-07 Thread Zijun Zhao via Phabricator via cfe-commits
ZijunZhao created this revision.
Herald added a project: All.
ZijunZhao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

https://github.com/llvm/llvm-project/issues/62248


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157331

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/stdckdint.h
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Headers/stdckdint.cpp
  clang/test/Modules/Inputs/System/usr/include/module.map

Index: clang/test/Modules/Inputs/System/usr/include/module.map
===
--- clang/test/Modules/Inputs/System/usr/include/module.map
+++ clang/test/Modules/Inputs/System/usr/include/module.map
@@ -14,6 +14,11 @@
 header "stdbool.h"
   }
 
+  // In both directories (compiler support version wins, does not forward)
+  module stdckdint {
+header "stdckdint.h"
+  }
+
   // In both directories (compiler support version wins, forwards)
   module stdint {
 header "stdint.h"
Index: clang/test/Headers/stdckdint.cpp
===
--- /dev/null
+++ clang/test/Headers/stdckdint.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -emit-llvm  -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | FileCheck --check-prefix=CHECK-NEXT %s
+
+
+#include 
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add() #0 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:%0 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 -1073741826, i32 -1073741826)
+// CHECK-NEXT:%1 = extractvalue { i32, i1 } %0, 1 
+// CHECK-NEXT:store i32 %2, ptr %result, align 4 
+// CHECK-NEXT:ret i1 %1 
+// CHECK-NEXT:} 
+// CHECK-NEXT:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 
+// CHECK-NEXT:declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1 
+bool test_ckd_add() {
+  int result;
+  return ckd_add(, -1073741826, -1073741826);
+}
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_sub() #0 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:%0 = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 -1073741826, i32 1073741826)
+// CHECK-NEXT:%1 = extractvalue { i32, i1 } %0, 1 
+// CHECK-NEXT:store i32 %2, ptr %result, align 4 
+// CHECK-NEXT:ret i1 %1 
+// CHECK-NEXT:} 
+// CHECK-NEXT:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 
+// CHECK-NEXT:declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) #1 
+bool test_ckd_sub() {
+  int result;
+  return ckd_sub(, -1073741826, 1073741826);
+}
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_mul() #0 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:%0 = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 -1073741826, i32 2)
+// CHECK-NEXT:%1 = extractvalue { i32, i1 } %0, 1 
+// CHECK-NEXT:store i32 %2, ptr %result, align 4
+// CHECK-NEXT:ret i1 %1 
+// CHECK-NEXT:} 
+// CHECK-NEXT:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 
+// CHECK-NEXT:declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) #1 
+bool test_ckd_mul() {
+  int result;
+  return ckd_mul(, -1073741826, 2);
+}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -207,7 +207,7 @@
 .Cases("assert.h", "complex.h", "ctype.h", "errno.h", "fenv.h", true)
 .Cases("float.h", "inttypes.h", "iso646.h", "limits.h", "locale.h", true)
 .Cases("math.h", "setjmp.h", "signal.h", "stdalign.h", "stdarg.h", true)
-.Cases("stdatomic.h", "stdbool.h", "stddef.h", "stdint.h", "stdio.h", true)
+.Cases("stdatomic.h", "stdbool.h", "stdckdint.h", "stddef.h", "stdint.h", "stdio.h", true)
 .Cases("stdlib.h", "stdnoreturn.h", "string.h", "tgmath.h", "threads.h", true)
 .Cases("time.h", "uchar.h", "wchar.h", "wctype.h", true)
 
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -384,6 +384,7 @@
.Case("stdarg.h", true)
.Case("stdatomic.h", true)
.Case("stdbool.h", true)
+   .Case("stdckdint.h", true)
.Case("stddef.h", true)
.Case("stdint.h", true)
.Case("tgmath.h", true)
Index: clang/lib/Headers/stdckdint.h
===
--- /dev/null
+++ clang/lib/Headers/stdckdint.h
@@ -0,0 +1,22 @@
+/*=== stdckdint.h - Standard header for checking integer
+ *-===
+ *
+ * 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
+ *
+ 

[PATCH] D157246: [clang-tidy] Update tests to include C++23 and C++26

2023-08-07 Thread Adrian Vogelsgesang 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 rGfda777849b00: [clang-tidy] Update tests to include C++23 and 
C++26 (authored by avogelsgesang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157246

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++20 %s readability-container-contains %t
+// RUN: %check_clang_tidy -std=c++20-or-later %s readability-container-contains %t
 
 // Some *very* simplified versions of `map` etc.
 namespace std {
Index: clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp
@@ -45,7 +45,7 @@
   BadArgument& operator=(BadArgument&);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument'
   BadArgument& operator=(const BadArgument&&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadAr
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument'
 };
 
 struct BadModifier {
@@ -76,7 +76,7 @@
 public:
   BadReturnStatement& operator=(BadReturnStatement&& rhs) {
 n = std::move(rhs.n);
-return rhs;
+return *
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this'
   }
 
Index: clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
@@ -1,9 +1,9 @@
 // RUN: %check_clang_tidy %s misc-const-correctness %t -- \
 // RUN:   -config="{CheckOptions: {\
-// RUN:   misc-const-correctness.TransformValues: true, \
-// RUN:   misc-const-correctness.WarnPointersAsValues: false, \
-// RUN:   misc-const-correctness.TransformPointersAsValues: false} \
-// RUN:   }" -- -fno-delayed-template-parsing
+// RUN: misc-const-correctness.TransformValues: true, \
+// RUN: misc-const-correctness.WarnPointersAsValues: false, \
+// RUN: misc-const-correctness.TransformPointersAsValues: false \
+// RUN:   }}" -- -fno-delayed-template-parsing
 
 // --- Provide test samples for primitive builtins -
 // - every 'p_*' variable is a 'potential_const_*' variable
@@ -181,14 +181,7 @@
   return _local1;
 }
 
-double _const_ref_return() {
-  double p_local0 = 0.0;
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const'
-  // CHECK-FIXES: double const p_local0
-  double np_local0 = 42.42;
-  return np_local0;
-}
-
+// Also see const-correctness-values.cpp-before-cxx23.cpp for `non_const_ref_return` and `return_non_const_pointer_ref`
 const double _ref_return() {
   double p_local0 = 0.0;
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const'
@@ -199,11 +192,6 @@
   return p_local1;
 }
 
-double *_non_const_pointer_ref() {
-  double *np_local0 = nullptr;
-  return np_local0;
-}
-
 void overloaded_arguments(const int );
 void overloaded_arguments(int );
 void overloaded_arguments(const int *in);
Index: clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
@@ -0,0 +1,20 @@
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17,c++20 %s misc-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: {\
+// RUN: misc-const-correctness.TransformValues: true, \
+// RUN: misc-const-correctness.WarnPointersAsValues: false, \
+// RUN: misc-const-correctness.TransformPointersAsValues: false \
+// RUN:   }}" -- -fno-delayed-template-parsing
+
+
+double _const_ref_return() {
+  double p_local0 = 

[clang-tools-extra] fda7778 - [clang-tidy] Update tests to include C++23 and C++26

2023-08-07 Thread Adrian Vogelsgesang via cfe-commits

Author: Adrian Vogelsgesang
Date: 2023-08-07T21:25:22Z
New Revision: fda777849b0088ba83e28683c53c5c8321ef2558

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

LOG: [clang-tidy] Update tests to include C++23 and C++26

This commit changes the `c++xx-or-later` definitions to also include
C++23 and the upcoming C++26.
`readability/container-contains.cpp` to also test newer C++ versions.

Also, this commit adjusts a couple of test cases slightly:
* `container-contains.cpp` now also tests newer C++ versions.
  Restricting it to C++20 was an oversight of mine when originally
  writing this check.
* `unconventional-assign-operator.cpp`: The `return rhs` raised
  a "non-const lvalue reference to type 'BadReturnStatement' cannot
  bind to a temporary" error in C++23. The issue is circumenvented
  by writing `return *`.
* `const-correctness-values.cpp` was also running into the same error
  in C++23. The troublesome test cases were moved to a separate file.

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp

Modified: 
clang-tools-extra/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp

Removed: 




diff  --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py 
b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
index a78996a0fce3b0..53ffca0bad8d06 100755
--- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -265,15 +265,17 @@ def run(self):
 
 def expand_std(std):
 if std == "c++98-or-later":
-return ["c++98", "c++11", "c++14", "c++17", "c++20"]
+return ["c++98", "c++11", "c++14", "c++17", "c++20", "c++23", "c++2c"]
 if std == "c++11-or-later":
-return ["c++11", "c++14", "c++17", "c++20"]
+return ["c++11", "c++14", "c++17", "c++20", "c++23", "c++2c"]
 if std == "c++14-or-later":
-return ["c++14", "c++17", "c++20"]
+return ["c++14", "c++17", "c++20", "c++23", "c++2c"]
 if std == "c++17-or-later":
-return ["c++17", "c++20"]
+return ["c++17", "c++20", "c++23", "c++2c"]
 if std == "c++20-or-later":
-return ["c++20"]
+return ["c++20", "c++23", "c++2c"]
+if std == "c++23-or-later":
+return ["c++23", "c++2c"]
 return [std]
 
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
new file mode 100644
index 00..3547ec080911eb
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
@@ -0,0 +1,20 @@
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17,c++20 %s 
misc-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: {\
+// RUN: misc-const-correctness.TransformValues: true, \
+// RUN: misc-const-correctness.WarnPointersAsValues: false, \
+// RUN: misc-const-correctness.TransformPointersAsValues: false \
+// RUN:   }}" -- -fno-delayed-template-parsing
+
+
+double _const_ref_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 
'double' can be declared 'const'
+  // CHECK-FIXES: double const p_local0
+  double np_local0 = 42.42;
+  return np_local0;
+}
+
+double *_non_const_pointer_ref() {
+  double *np_local0 = nullptr;
+  return np_local0;
+}

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
index 88f40462003e88..186e3cf5a179b2 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
@@ -1,9 +1,9 @@
 // RUN: %check_clang_tidy %s misc-const-correctness %t -- \
 // RUN:   -config="{CheckOptions: {\
-// RUN:   misc-const-correctness.TransformValues: true, \
-// RUN:   misc-const-correctness.WarnPointersAsValues: false, \
-// RUN:   misc-const-correctness.TransformPointersAsValues: false} \
-// RUN:   }" -- -fno-delayed-template-parsing
+// RUN: misc-const-correctness.TransformValues: true, \
+// RUN: misc-const-correctness.WarnPointersAsValues: false, \
+// RUN: misc-const-correctness.TransformPointersAsValues: false \
+// RUN:   }}" -- -fno-delayed-template-parsing
 
 // --- Provide test samples for primitive builtins -
 // 

[PATCH] D139730: [OpenMP][DeviceRTL][AMDGPU] Support code object version 5

2023-08-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:17143-17145
+  llvm::LoadInst *LD;
+  Constant *Offset, *Offset1;
+  Value *DP, *DP1;

Move down to define and initialize



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:17163-17165
+BasicBlock *NewABI = CGF.createBasicBlock("amdgcn.abi.cov5", TheFunction);
+BasicBlock *OldABI = CGF.createBasicBlock("amdgcn.abi.cov4", nullptr);
+BasicBlock *End = CGF.createBasicBlock("amdgcn.abi.end", nullptr);

You could write all of this in terms of selects and avoid introducing all these 
blocks



Comment at: clang/lib/CodeGen/Targets/AMDGPU.cpp:358
+CodeGen::CodeGenModule ) const {
+  if (!CGM.getTriple().isAMDGCN())
+return;

Don't need this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139730

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


[PATCH] D157270: [Clang][AArch64] Add diagnostic for calls from non-ZA to shared-ZA functions.

2023-08-07 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/test/Sema/aarch64-sme-func-attrs.c:181
 
+void non_za_definition(void) {
+  sme_arm_new_za(); // OK

rsandifo-arm wrote:
> sdesmalen wrote:
> > rsandifo-arm wrote:
> > > Would be good to have some tests for indirect function calls too (via 
> > > function pointers), to make sure that the diagnostic still works when no 
> > > decl is available.
> > > 
> > > I suppose this applies to D157269 too.
> > I'm not sure that's necessary because D127762 already added tests to ensure 
> > the attributes propagate on pointer types, which then sets the ExtProtoInfo 
> > for those values. This patch merely checks the SME attribute fields from 
> > ExtProtoInfo. i.e. there is already nothing depending on a declaration 
> > being available.
> But `Sema::checkCall` does have some tests that depend on the decl rather 
> than the type.  So the purpose of the test wouldn't be “does the attribute 
> stick when applied to indirect function types?” (which I agree is already 
> covered), but “does the new code correctly process the attribute on the 
> target of a function pointer type?”
The declaration is only relevant for the call-site, not the callee.

  if (ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateZASharedMask) {

The above line checks __arm_shared_za attribute of the callee (could be a decl, 
or a function pointer, but in either case is a prototyped function with the 
propagated attributes)

  if (auto *CallerFD = dyn_cast(CurContext)) {

The above line checks if the call-site context is a FunctionDecl (or definition 
for that matter). If the call is not part of a declaration (e.g. it's part of 
some global initialiser), we know it cannot have any live ZA state (which I now 
realise is missing a test-case).

So I think that a test like this:

  __arm_new_za void foo(void (*f)() __arm_shared_za) { f(); }

is not testing anything that isn't already tested. But perhaps I'm still 
misunderstanding your point. If so, could you give an example of a test you 
have in mind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157270

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


[PATCH] D157270: [Clang][AArch64] Add diagnostic for calls from non-ZA to shared-ZA functions.

2023-08-07 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 547936.
sdesmalen marked an inline comment as done.
sdesmalen added a comment.

- Replaced `|=` into normal assignment `=`
- Added test for global initializer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157270

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/aarch64-sme-func-attrs.c


Index: clang/test/Sema/aarch64-sme-func-attrs.c
===
--- clang/test/Sema/aarch64-sme-func-attrs.c
+++ clang/test/Sema/aarch64-sme-func-attrs.c
@@ -178,7 +178,26 @@
 void redecl_nopreserve_za(void) __arm_shared_za;
 void redecl_nopreserve_za(void) __arm_shared_za __arm_preserves_za {}
 
+void non_za_definition(void) {
+  sme_arm_new_za(); // OK
+  // expected-error@+2 {{call to a shared ZA function requires the caller to 
have ZA state}}
+  // expected-cpp-error@+1 {{call to a shared ZA function requires the caller 
to have ZA state}}
+  sme_arm_shared_za();
+}
+
+void shared_za_definition(void) __arm_shared_za {
+  sme_arm_shared_za(); // OK
+}
+
+__arm_new_za void new_za_definition(void) {
+  sme_arm_shared_za(); // OK
+}
+
 #ifdef __cplusplus
+int shared_za_initializer(void) __arm_shared_za;
+// expected-cpp-error@+1 {{call to a shared ZA function requires the caller to 
have ZA state}}
+int global = shared_za_initializer();
+
 struct S {
   virtual void shared_za_memberfn(void) __arm_shared_za;
 };
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -6765,6 +6765,22 @@
 Diag(Loc, diag::err_sme_call_in_non_sme_target);
   }
 }
+
+// If the callee uses AArch64 SME ZA state but the caller doesn't define
+// any, then this is an error.
+if (ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateZASharedMask) {
+  bool CallerHasZAState = false;
+  if (auto *CallerFD = dyn_cast(CurContext)) {
+if (CallerFD->hasAttr())
+  CallerHasZAState = true;
+else if (const auto *FPT = 
CallerFD->getType()->getAs())
+  CallerHasZAState = FPT->getExtProtoInfo().AArch64SMEAttributes &
+ FunctionType::SME_PStateZASharedMask;
+  }
+
+  if (!CallerHasZAState)
+Diag(Loc, diag::err_sme_za_call_no_za_state);
+}
   }
 
   if (FDecl && FDecl->hasAttr()) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3629,6 +3629,8 @@
   "function declared %0 was previously declared %1, which has different SME 
function attributes">;
 def err_sme_call_in_non_sme_target : Error<
   "call to a streaming function requires 'sme'">;
+def err_sme_za_call_no_za_state : Error<
+  "call to a shared ZA function requires the caller to have ZA state">;
 def err_sme_definition_using_sm_in_non_sme_target : Error<
   "function executed in streaming-SVE mode requires 'sme'">;
 def err_sme_definition_using_za_in_non_sme_target : Error<


Index: clang/test/Sema/aarch64-sme-func-attrs.c
===
--- clang/test/Sema/aarch64-sme-func-attrs.c
+++ clang/test/Sema/aarch64-sme-func-attrs.c
@@ -178,7 +178,26 @@
 void redecl_nopreserve_za(void) __arm_shared_za;
 void redecl_nopreserve_za(void) __arm_shared_za __arm_preserves_za {}
 
+void non_za_definition(void) {
+  sme_arm_new_za(); // OK
+  // expected-error@+2 {{call to a shared ZA function requires the caller to have ZA state}}
+  // expected-cpp-error@+1 {{call to a shared ZA function requires the caller to have ZA state}}
+  sme_arm_shared_za();
+}
+
+void shared_za_definition(void) __arm_shared_za {
+  sme_arm_shared_za(); // OK
+}
+
+__arm_new_za void new_za_definition(void) {
+  sme_arm_shared_za(); // OK
+}
+
 #ifdef __cplusplus
+int shared_za_initializer(void) __arm_shared_za;
+// expected-cpp-error@+1 {{call to a shared ZA function requires the caller to have ZA state}}
+int global = shared_za_initializer();
+
 struct S {
   virtual void shared_za_memberfn(void) __arm_shared_za;
 };
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -6765,6 +6765,22 @@
 Diag(Loc, diag::err_sme_call_in_non_sme_target);
   }
 }
+
+// If the callee uses AArch64 SME ZA state but the caller doesn't define
+// any, then this is an error.
+if (ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateZASharedMask) {
+  bool CallerHasZAState = false;
+  if (auto *CallerFD = dyn_cast(CurContext)) {
+if (CallerFD->hasAttr())
+  CallerHasZAState = 

[PATCH] D157326: [clang-tidy] Fix handling of out-of-line functions in readability-static-accessed-through-instance

2023-08-07 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
PiotrZSL added reviewers: njames93, carlosgalvezp.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Use isStatic instead of isStaticStorageClass to properly
handle a out-of-line definitions.

Fixes: #51861


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157326

Files:
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
@@ -363,3 +363,20 @@
 }
 
 } // namespace llvm_issue_61736
+
+namespace PR51861 {
+  class Foo {
+public:
+  static Foo& getInstance();
+  static int getBar();
+  };
+
+  inline int Foo::getBar() { return 42; }
+
+  void test() {
+auto& params = Foo::getInstance();
+params.getBar();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: static member accessed through 
instance [readability-static-accessed-through-instance]
+// CHECK-FIXES: {{^}}PR51861::Foo::getBar();{{$}}
+  }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -192,6 +192,10 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-static-accessed-through-instance
+  ` check to
+  identify calls to static member functions with out-of-class inline 
definitions.
+
 Removed checks
 ^^
 
Index: 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -15,6 +15,10 @@
 
 namespace clang::tidy::readability {
 
+namespace {
+AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
+} // namespace
+
 static unsigned getNameSpecifierNestingLevel(const QualType ) {
   if (const ElaboratedType *ElType = QType->getAs()) {
 if (const NestedNameSpecifier *NestedSpecifiers = ElType->getQualifier()) {
@@ -38,7 +42,7 @@
 
 void StaticAccessedThroughInstanceCheck::registerMatchers(MatchFinder *Finder) 
{
   Finder->addMatcher(
-  memberExpr(hasDeclaration(anyOf(cxxMethodDecl(isStaticStorageClass()),
+  memberExpr(hasDeclaration(anyOf(cxxMethodDecl(isStatic()),
   varDecl(hasStaticStorageDuration()),
   enumConstantDecl(
   .bind("memberExpression"),


Index: clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
@@ -363,3 +363,20 @@
 }
 
 } // namespace llvm_issue_61736
+
+namespace PR51861 {
+  class Foo {
+public:
+  static Foo& getInstance();
+  static int getBar();
+  };
+
+  inline int Foo::getBar() { return 42; }
+
+  void test() {
+auto& params = Foo::getInstance();
+params.getBar();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: static member accessed through instance [readability-static-accessed-through-instance]
+// CHECK-FIXES: {{^}}PR51861::Foo::getBar();{{$}}
+  }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -192,6 +192,10 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-static-accessed-through-instance
+  ` check to
+  identify calls to static member functions with out-of-class inline definitions.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -15,6 +15,10 @@
 
 namespace clang::tidy::readability {
 
+namespace {

[PATCH] D157269: [Clang][AArch64] Diagnostics for SME attributes when target doesn't have 'sme'

2023-08-07 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a subscriber: paulwalker-arm.
sdesmalen added a comment.

Thanks for the review of the Clang side @aaron.ballman and @rsandifo-arm.

@paulwalker-arm would you be happy to have a look at the LLVM side of this 
patch?




Comment at: clang/test/Sema/aarch64-sme-func-attrs-without-target-feature.cpp:29
+
+void streaming_compatible_def2() {
+  non_streaming_decl(); // OK

rsandifo-arm wrote:
> Looks like this was intended to be `__arm_streaming_compatible`.
Thanks, I missed that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157269

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


[PATCH] D157269: [Clang][AArch64] Diagnostics for SME attributes when target doesn't have 'sme'

2023-08-07 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 547933.
sdesmalen marked 2 inline comments as done.
sdesmalen added a comment.

Removed double error message for missing 'sme' for both ZA and Streaming


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157269

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/aarch64-sme-func-attrs-without-target-feature.cpp
  llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  
llvm/test/CodeGen/AArch64/sme-call-streaming-compatible-to-normal-fn-wihout-sme-attr.ll

Index: llvm/test/CodeGen/AArch64/sme-call-streaming-compatible-to-normal-fn-wihout-sme-attr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sme-call-streaming-compatible-to-normal-fn-wihout-sme-attr.ll
@@ -0,0 +1,41 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc < %s | FileCheck %s
+
+; This that the following code can be compiled without +sme, because if the
+; call is not entered in streaming-SVE mode at runtime, the codepath leading
+; to the smstop/smstart pair will not be executed either.
+
+target triple = "aarch64"
+
+define void @streaming_compatible() #0 {
+; CHECK-LABEL: streaming_compatible:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:stp d15, d14, [sp, #-80]! // 16-byte Folded Spill
+; CHECK-NEXT:stp d13, d12, [sp, #16] // 16-byte Folded Spill
+; CHECK-NEXT:stp d11, d10, [sp, #32] // 16-byte Folded Spill
+; CHECK-NEXT:stp d9, d8, [sp, #48] // 16-byte Folded Spill
+; CHECK-NEXT:stp x30, x19, [sp, #64] // 16-byte Folded Spill
+; CHECK-NEXT:bl __arm_sme_state
+; CHECK-NEXT:and x19, x0, #0x1
+; CHECK-NEXT:tbz x19, #0, .LBB0_2
+; CHECK-NEXT:  // %bb.1:
+; CHECK-NEXT:msr SVCRSM, #0
+; CHECK-NEXT:  .LBB0_2:
+; CHECK-NEXT:bl non_streaming
+; CHECK-NEXT:tbz x19, #0, .LBB0_4
+; CHECK-NEXT:  // %bb.3:
+; CHECK-NEXT:msr SVCRSM, #1
+; CHECK-NEXT:  .LBB0_4:
+; CHECK-NEXT:ldp x30, x19, [sp, #64] // 16-byte Folded Reload
+; CHECK-NEXT:ldp d9, d8, [sp, #48] // 16-byte Folded Reload
+; CHECK-NEXT:ldp d11, d10, [sp, #32] // 16-byte Folded Reload
+; CHECK-NEXT:ldp d13, d12, [sp, #16] // 16-byte Folded Reload
+; CHECK-NEXT:ldp d15, d14, [sp], #80 // 16-byte Folded Reload
+; CHECK-NEXT:ret
+  call void @non_streaming()
+  ret void
+}
+
+declare void @non_streaming()
+
+attributes #0 = { nounwind "aarch64_pstate_sm_compatible" }
Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
===
--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -442,8 +442,6 @@
 
   assert((!StreamingSVEMode || I->hasSME()) &&
  "Expected SME to be available");
-  assert((!StreamingCompatibleSVEMode || I->hasSVEorSME()) &&
- "Expected SVE or SME to be available");
 
   return I.get();
 }
Index: llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
@@ -154,6 +154,12 @@
   let Inst{11-9} = pstatefield;
   let Inst{8} = imm;
   let Inst{7-5} = 0b011; // op2
+
+  // We shouldn't require 'sme' to compile streaming-compatible functions which
+  // call non-streaming functions as the SME smstart/smstop will only be
+  // executed at runtime if streaming-mode is enabled, which also means SME must
+  // be enabled.
+  let Predicates = [];
 }
 
 def : InstAlias<"smstart",(MSRpstatesvcrImm1 0b011, 0b1)>;
@@ -226,12 +232,6 @@
 def : Pat<(AArch64_smstop (i32 svcr_op:$pstate), (i64 0), (i64 1)),   // after call
   (MSRpstatesvcrImm1 svcr_op:$pstate, 0b0)>;
 
-// The generic case which gets expanded to a pseudo node.
-def : Pat<(AArch64_smstart (i32 svcr_op:$pstate), (i64 GPR64:$rtpstate), (i64 timm0_1:$expected_pstate)),
-  (MSRpstatePseudo svcr_op:$pstate, 0b1, GPR64:$rtpstate, timm0_1:$expected_pstate)>;
-def : Pat<(AArch64_smstop (i32 svcr_op:$pstate), (i64 GPR64:$rtpstate), (i64 timm0_1:$expected_pstate)),
-  (MSRpstatePseudo svcr_op:$pstate, 0b0, GPR64:$rtpstate, timm0_1:$expected_pstate)>;
-
 // Read and write TPIDR2_EL0
 def : Pat<(int_aarch64_sme_set_tpidr2 i64:$val),
   (MSR 0xde85, GPR64:$val)>;
@@ -243,6 +243,12 @@
   (OBSCURE_COPY GPR64:$idx)>;
 } // End let Predicates = [HasSME]
 
+// The generic case which gets expanded to a pseudo node (doesn't require SME or SVE)
+def : Pat<(AArch64_smstart (i32 svcr_op:$pstate), (i64 GPR64:$rtpstate), (i64 timm0_1:$expected_pstate)),
+  (MSRpstatePseudo svcr_op:$pstate, 0b1, GPR64:$rtpstate, timm0_1:$expected_pstate)>;
+def : Pat<(AArch64_smstop (i32 

[PATCH] D157246: [clang-tidy] Update tests to include C++23 and C++26

2023-08-07 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang updated this revision to Diff 547931.
avogelsgesang added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157246

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++20 %s readability-container-contains %t
+// RUN: %check_clang_tidy -std=c++20-or-later %s readability-container-contains %t
 
 // Some *very* simplified versions of `map` etc.
 namespace std {
Index: clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp
@@ -45,7 +45,7 @@
   BadArgument& operator=(BadArgument&);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument'
   BadArgument& operator=(const BadArgument&&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadAr
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument'
 };
 
 struct BadModifier {
@@ -76,7 +76,7 @@
 public:
   BadReturnStatement& operator=(BadReturnStatement&& rhs) {
 n = std::move(rhs.n);
-return rhs;
+return *
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this'
   }
 
Index: clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
@@ -1,9 +1,9 @@
 // RUN: %check_clang_tidy %s misc-const-correctness %t -- \
 // RUN:   -config="{CheckOptions: {\
-// RUN:   misc-const-correctness.TransformValues: true, \
-// RUN:   misc-const-correctness.WarnPointersAsValues: false, \
-// RUN:   misc-const-correctness.TransformPointersAsValues: false} \
-// RUN:   }" -- -fno-delayed-template-parsing
+// RUN: misc-const-correctness.TransformValues: true, \
+// RUN: misc-const-correctness.WarnPointersAsValues: false, \
+// RUN: misc-const-correctness.TransformPointersAsValues: false \
+// RUN:   }}" -- -fno-delayed-template-parsing
 
 // --- Provide test samples for primitive builtins -
 // - every 'p_*' variable is a 'potential_const_*' variable
@@ -181,14 +181,7 @@
   return _local1;
 }
 
-double _const_ref_return() {
-  double p_local0 = 0.0;
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const'
-  // CHECK-FIXES: double const p_local0
-  double np_local0 = 42.42;
-  return np_local0;
-}
-
+// Also see const-correctness-values.cpp-before-cxx23.cpp for `non_const_ref_return` and `return_non_const_pointer_ref`
 const double _ref_return() {
   double p_local0 = 0.0;
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const'
@@ -199,11 +192,6 @@
   return p_local1;
 }
 
-double *_non_const_pointer_ref() {
-  double *np_local0 = nullptr;
-  return np_local0;
-}
-
 void overloaded_arguments(const int );
 void overloaded_arguments(int );
 void overloaded_arguments(const int *in);
Index: clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp
@@ -0,0 +1,20 @@
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17,c++20 %s misc-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: {\
+// RUN: misc-const-correctness.TransformValues: true, \
+// RUN: misc-const-correctness.WarnPointersAsValues: false, \
+// RUN: misc-const-correctness.TransformPointersAsValues: false \
+// RUN:   }}" -- -fno-delayed-template-parsing
+
+
+double _const_ref_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const'
+  // CHECK-FIXES: double const 

[PATCH] D157324: [clang] Move the Clang CI jobs off of the libc++ builders

2023-08-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a subscriber: goncharov.
ldionne added a comment.

@goncharov Now that we have a `buildkite-pipeline.yml` for Clang, would it make 
sense to stop running the "builtin" jobs like 
https://buildkite.com/llvm-project/premerge-checks/builds/169498#0189d1af-3c81-4ab5-a87a-ac8db177ccf0
 and instead run these tests inside the Clang CI pipeline by defining them 
inside `buildkite-pipeline.yml`? This would centralize where all the jobs for 
Clang CI are defined.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157324

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


[PATCH] D157324: [clang] Move the Clang CI jobs off of the libc++ builders

2023-08-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The libc++ builders do not have the capacity to serve both libc++ and
Clang CI needs. We initially used the libc++ builders when adding
pre-commit CI for Clang as an experiment, however this setup has been
problematic for libc++ for a long time. It makes libc++ CI turnaround
way too slow, which has been a frequent source of frustration.

We didn't want to make this change before the release to avoid rocking
the boat too much in such an important time, however now that the
release has been cut, we need to make this change. This will shift
the traffic for Clang pre-commit CI from the libc++ builders to the
builders that have been used for Clang pre-commit CI defined outside
of Clang's BuildKite pipeline.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157324

Files:
  clang/utils/ci/buildkite-pipeline.yml


Index: clang/utils/ci/buildkite-pipeline.yml
===
--- clang/utils/ci/buildkite-pipeline.yml
+++ clang/utils/ci/buildkite-pipeline.yml
@@ -22,8 +22,7 @@
   - "clang/utils/ci/run-buildbot check-format"
 
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
@@ -39,8 +38,7 @@
 CC: "clang-${LLVM_HEAD_VERSION}"
 CXX: "clang++-${LLVM_HEAD_VERSION}"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
@@ -49,7 +47,7 @@
 
   - wait
 
-  - label: "C++03"
+  - label: "Running libc++ test suite in C++03"
 commands:
   - "clang/utils/ci/run-buildbot generic-cxx03"
 artifact_paths:
@@ -59,15 +57,14 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" 
# TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
   limit: 2
 timeout_in_minutes: 120
 
-  - label: "C++26"
+  - label: "Running libc++ test suite in C++26"
 commands:
   - "clang/utils/ci/run-buildbot generic-cxx26"
 artifact_paths:
@@ -77,15 +74,14 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" 
# TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
   limit: 2
 timeout_in_minutes: 120
 
-  - label: "Modules"
+  - label: "Running libc++ test suite with Clang Modules"
 commands:
   - "clang/utils/ci/run-buildbot generic-modules"
 artifact_paths:
@@ -95,8 +91,7 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" 
# TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost


Index: clang/utils/ci/buildkite-pipeline.yml
===
--- clang/utils/ci/buildkite-pipeline.yml
+++ clang/utils/ci/buildkite-pipeline.yml
@@ -22,8 +22,7 @@
   - "clang/utils/ci/run-buildbot check-format"
 
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
@@ -39,8 +38,7 @@
 CC: "clang-${LLVM_HEAD_VERSION}"
 CXX: "clang++-${LLVM_HEAD_VERSION}"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
@@ -49,7 +47,7 @@
 
   - wait
 
-  - label: "C++03"
+  - label: "Running libc++ test suite in C++03"
 commands:
   - "clang/utils/ci/run-buildbot generic-cxx03"
 artifact_paths:
@@ -59,15 +57,14 @@
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" # TODO: Should we build that from scratch?
 CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
-  queue: "libcxx-builders"
-  os: "linux"
+  queue: "linux"
 retry:
   automatic:
 - exit_status: -1  # Agent was lost
   limit: 2
 timeout_in_minutes: 120
 
-  - label: "C++26"
+  - label: "Running libc++ test suite in C++26"
 commands:
   - "clang/utils/ci/run-buildbot generic-cxx26"
 artifact_paths:
@@ -77,15 +74,14 @@
 LLVM_SYMBOLIZER_PATH: 

[PATCH] D157321: [InstrProf] Fix macOS profile tests after D156569

2023-08-07 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157321

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


[PATCH] D155895: Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`.

2023-08-07 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted in 0342bbf223fa12701a0570a23f9eac433b8b341c for now, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155895

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


[clang] 0342bbf - Revert "Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`."

2023-08-07 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2023-08-07T15:48:23-04:00
New Revision: 0342bbf223fa12701a0570a23f9eac433b8b341c

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

LOG: Revert "Anonymous unions should be transparent wrt 
`[[clang::trivial_abi]]`."

This reverts commit bddaa35177861545fc329123e55b6a3b34549507.
Reverting as requested at https://reviews.llvm.org/D155895#4566945
(for breaking tests on Windows).

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/attr-trivial-abi.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d926cfcd4d8665..3ef68ca8af6685 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -230,12 +230,6 @@ class LangOptions : public LangOptionsBase {
 ///   - consider classes with defaulted special member functions non-pod.
 Ver15,
 
-/// Attempt to be ABI-compatible with code generated by Clang 17.0.x.
-/// This causes clang to:
-///   - Treat `[[clang::trivial_abi]]` as ill-formed and ignore it if any
-/// field is an anonymous union and/or struct.
-Ver17,
-
 /// Conform to the underlying platform's C and C++ ABIs as closely
 /// as we can.
 Latest

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 699b315269deb3..be53ce3e472659 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3474,8 +3474,6 @@ void CompilerInvocation::GenerateLangArgs(const 
LangOptions ,
 GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "14.0");
   else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver15)
 GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "15.0");
-  else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver17)
-GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "17.0");
 
   if (Opts.getSignReturnAddressScope() ==
   LangOptions::SignReturnAddressScopeKind::All)
@@ -3961,8 +3959,6 @@ bool CompilerInvocation::ParseLangArgs(LangOptions , 
ArgList ,
 Opts.setClangABICompat(LangOptions::ClangABI::Ver14);
   else if (Major <= 15)
 Opts.setClangABICompat(LangOptions::ClangABI::Ver15);
-  else if (Major <= 17)
-Opts.setClangABICompat(LangOptions::ClangABI::Ver17);
 } else if (Ver != "latest") {
   Diags.Report(diag::err_drv_invalid_value)
   << A->getAsString(Args) << A->getValue();

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 6c29efc03a4b78..2c2c9dc8147437 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -45,7 +45,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/SaveAndRestore.h"
 #include 
@@ -10414,35 +10413,21 @@ void 
Sema::checkIllFormedTrivialABIStruct(CXXRecordDecl ) {
 }
   }
 
-  llvm::SmallVector FieldsToCheck{RD.fields()};
-  while (!FieldsToCheck.empty()) {
-const FieldDecl *FD = FieldsToCheck.pop_back_val();
-
-// Ill-formed if the field is an ObjectiveC pointer.
+  for (const auto *FD : RD.fields()) {
+// Ill-formed if the field is an ObjectiveC pointer or of a type that is
+// non-trivial for the purpose of calls.
 QualType FT = FD->getType();
 if (FT.getObjCLifetime() == Qualifiers::OCL_Weak) {
   PrintDiagAndRemoveAttr(4);
   return;
 }
 
-if (const auto *RT = FT->getBaseElementTypeUnsafe()->getAs()) {
-  // Check the fields of anonymous structs (and/or or unions) instead of
-  // checking the type of the anonynous struct itself.
-  if (getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver17 &&
-  RT->getDecl()->isAnonymousStructOrUnion()) {
-FieldsToCheck.append(RT->getDecl()->field_begin(),
- RT->getDecl()->field_end());
-continue;
-  }
-
-  // Ill-formed if the field is of a type that is non-trivial for the
-  // purpose of calls.
+if (const auto *RT = FT->getBaseElementTypeUnsafe()->getAs())
   if (!RT->isDependentType() &&
   !cast(RT->getDecl())->canPassInRegisters()) {
 PrintDiagAndRemoveAttr(5);
 return;
   }
-}
   }
 }
 

diff  --git a/clang/test/SemaCXX/attr-trivial-abi.cpp 
b/clang/test/SemaCXX/attr-trivial-abi.cpp
index accac42c25cf5f..c215f90eb124ce 100644
--- a/clang/test/SemaCXX/attr-trivial-abi.cpp
+++ b/clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s 

[clang] 9e99a4f - [NVPTX] Fix missed test after adding alias support for NVPTX

2023-08-07 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-08-07T14:35:02-05:00
New Revision: 9e99a4f0db0e21b68e9aab9ad6f32f34d42eb460

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

LOG: [NVPTX] Fix missed test after adding alias support for NVPTX

Summary:
This test was accidentally not updated.

Added: 


Modified: 
clang/test/SemaCUDA/alias.cu

Removed: 




diff  --git a/clang/test/SemaCUDA/alias.cu b/clang/test/SemaCUDA/alias.cu
index 39251ed10ecda0..a0350e69d7ec14 100644
--- a/clang/test/SemaCUDA/alias.cu
+++ b/clang/test/SemaCUDA/alias.cu
@@ -1,11 +1,6 @@
-// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device 
-verify -DEXPECT_ERR %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device 
-target-sdk-version=9.0 -verify %s
 
-// The alias attribute is not allowed in CUDA device code.
-void bar();
+// The alias attribute is not allowed in CUDA device code before 10.0.
+extern "C" void bar();
 __attribute__((alias("bar"))) void foo();
-#ifdef EXPECT_ERR
-// expected-error@-2 {{CUDA does not support aliases}}
-#else
-// expected-no-diagnostics
-#endif
+// expected-error@-1 {{CUDA older than 10.0 does not support .alias}}



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


[clang-tools-extra] 1af159e - [clang-tidy][NFC] Update tests to CheckOptions using new syntax

2023-08-07 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-07T19:32:27Z
New Revision: 1af159e98c23a293c103e1f548866488126ed6f6

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

LOG: [clang-tidy][NFC] Update tests to CheckOptions using new syntax

This patch is just updating all test files to use the new syntax.
Fix for changes introduced after D130209 were created.

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/empty-catch.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/sizeof-expression-warn-on-sizeof-pointer-to-aggregate.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access-ignore-smart.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions.c

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-do-while.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-pointer-as-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-unaligned.cpp
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-wrong-config.cpp
clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/unused-parameters-virtual.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize/use-override-templates.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-absl.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-fmt.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp
clang-tools-extra/test/clang-tidy/checkers/performance/enum-size.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/magic-numbers-userliteral.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/operators-representation-to-alternative.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/operators-representation-to-traditional.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr-function.cpp

clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy

clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
clang-tools-extra/test/clang-tidy/infrastructure/dump-config-invalid.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/empty-catch.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/empty-catch.cpp
index 687f9c920fb39e..8ab38229b6dbf8 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/empty-catch.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/empty-catch.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy -std=c++98-or-later %s bugprone-empty-catch %t -- \
-// RUN: -config="{CheckOptions: [{key: 
bugprone-empty-catch.AllowEmptyCatchForExceptions, value: 
'::SafeException;WarnException'}, \
-// RUN:{key: bugprone-empty-catch.IgnoreCatchWithKeywords, value: 
'@IGNORE;@TODO'}]}" -- -fexceptions
+// RUN: -config="{CheckOptions: 
{bugprone-empty-catch.AllowEmptyCatchForExceptions: 
'::SafeException;WarnException', \
+// RUN:bugprone-empty-catch.IgnoreCatchWithKeywords: 
'@IGNORE;@TODO'}}" -- -fexceptions
 
 struct Exception {};
 struct SafeException {};

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/non-zero-enum-to-bool-conversion.cpp
index 00f2e71229895e..e0728680d4c6ad 100644
--- 

[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-08-07 Thread Sunil K via Phabricator via cfe-commits
koops updated this revision to Diff 547905.
koops added a comment.

In clang/test/OpenMP/loop_bind_enclosed.cpp  Generalizing the CHECK pattern for 
aarch64-linux, s390x-linux and ppc64le-linux.


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

https://reviews.llvm.org/D144634

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/generic_loop_ast_print.cpp
  clang/test/OpenMP/generic_loop_codegen.cpp
  clang/test/OpenMP/loop_bind_codegen.cpp
  clang/test/OpenMP/loop_bind_enclosed.cpp
  clang/test/OpenMP/loop_bind_messages.cpp
  clang/test/OpenMP/nested_loop_codegen.cpp
  clang/test/PCH/pragma-loop.cpp

Index: clang/test/PCH/pragma-loop.cpp
===
--- clang/test/PCH/pragma-loop.cpp
+++ clang/test/PCH/pragma-loop.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -emit-pch -o %t.a %s
-// RUN: %clang_cc1 -include-pch %t.a %s -ast-print -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -emit-pch -o %t.a %s
+// RUN: %clang_cc1 -fopenmp -include-pch %t.a %s -ast-print -o - | FileCheck %s
 
 // CHECK: #pragma clang loop vectorize_width(4)
 // CHECK: #pragma clang loop interleave_count(8)
@@ -18,6 +18,9 @@
 // CHECK: #pragma nounroll{{$}}
 // CHECK: #pragma clang loop vectorize_width(V)
 // CHECK: #pragma clang loop interleave_count(I)
+// CHECK: #pragma omp simd
+// CHECK: #pragma omp for
+// CHECK: #pragma omp distribute
 
 #ifndef HEADER
 #define HEADER
@@ -94,9 +97,33 @@
   List[i] = i;
 }
   }
+
+  inline void run8(int *List, int Length) {
+int i = 0;
+#pragma omp loop bind(thread)
+for (int i = 0; i < Length; i++) {
+  List[i] = i;
+}
+  }
+
+  inline void run9(int *List, int Length) {
+int i = 0;
+#pragma omp loop bind(parallel)
+for (int i = 0; i < Length; i++) {
+  List[i] = i;
+}
+  }
+
+  inline void run10(int *List, int Length) {
+int i = 0;
+#pragma omp loop bind(teams)
+for (int i = 0; i < Length; i++) {
+  List[i] = i;
+}
+  }
+
 };
 #else
-
 void test() {
   int List[100];
 
@@ -109,6 +136,9 @@
   pt.run5(List, 100);
   pt.run6(List, 100);
   pt.run7<2, 4>(List, 100);
+  pt.run8(List, 100);
+  pt.run9(List, 100);
+  pt.run10(List, 100);
 }
 
 #endif
Index: clang/test/OpenMP/nested_loop_codegen.cpp
===
--- clang/test/OpenMP/nested_loop_codegen.cpp
+++ clang/test/OpenMP/nested_loop_codegen.cpp
@@ -58,6 +58,12 @@
 // CHECK1-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[I_ADDR:%.*]] = alloca ptr, align 8
+// CHECK1-NEXT:[[TMP:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_IV:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_LB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_UB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[K:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
@@ -66,35 +72,27 @@
 // CHECK1-NEXT:store i32 0, ptr [[TMP0]], align 4
 // CHECK1-NEXT:br label [[FOR_COND:%.*]]
 // CHECK1:   for.cond:
-// CHECK1-NEXT:[[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
-// CHECK1-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP1]], 10
-// CHECK1-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END7:%.*]]
 // CHECK1:   for.body:
-// CHECK1-NEXT:store i32 0, ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_COND1:%.*]]
-// CHECK1:   for.cond1:
-// CHECK1-NEXT:[[TMP2:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[CMP2:%.*]] = icmp slt i32 [[TMP2]], 5
-// CHECK1-NEXT:br i1 [[CMP2]], label [[FOR_BODY3:%.*]], label [[FOR_END:%.*]]
-// CHECK1:   for.body3:
-// CHECK1-NEXT:[[TMP3:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[INC:%.*]] = add nsw i32 [[TMP3]], 1
-// CHECK1-NEXT:store i32 [[INC]], ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_INC:%.*]]
-// CHECK1:   for.inc:
-// CHECK1-NEXT:[[TMP4:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[INC4:%.*]] = add nsw i32 [[TMP4]], 1
-// CHECK1-NEXT:store i32 [[INC4]], ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_COND1]], !llvm.loop [[LOOP3:![0-9]+]]
-// CHECK1:   for.end:
-// CHECK1-NEXT:br label [[FOR_INC5:%.*]]
-// CHECK1:   for.inc5:
-// CHECK1-NEXT:[[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
-// CHECK1-NEXT:[[INC6:%.*]] = add nsw i32 [[TMP5]], 1
-// 

[PATCH] D155895: Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`.

2023-08-07 Thread Łukasz Anforowicz via Phabricator via cfe-commits
lukasza added a comment.

In D155895#4566903 , @thakis wrote:

> Looks like this breaks tests on windows: 
> http://45.33.8.238/win/82239/step_7.txt

Thanks for the report!  It seems that `#if defined(_WIN64) && 
!defined(__MINGW32__)` from `clang/test/SemaCXX/attr-trivial-abi.cpp` needs to 
be applied to fix the failing expectations of the new tests:

  error: 'error' diagnostics seen but not expected: 
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 182: 
static assertion failed due to requirement 
'__is_trivially_relocatable(anonymousUnionsAndStructs::Trivial)': 
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 200: 
static assertion failed due to requirement 
'__is_trivially_relocatable(anonymousUnionsAndStructs::BasicStruct)': 
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 225: 
static assertion failed due to requirement 
'__is_trivially_relocatable(anonymousUnionsAndStructs::StructWithAnonymousUnion)':
 
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 239: 
static assertion failed due to requirement 
'__is_trivially_relocatable(anonymousUnionsAndStructs::StructWithAnonymousStruct)':
 
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 266: 
static assertion failed due to requirement 
'__is_trivially_relocatable(anonymousUnionsAndStructs::TrivialAbiAttributeAppliedToAnonymousUnion)':
 
  error: 'warning' diagnostics seen but not expected: 
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 194: 
'trivial_abi' cannot be applied to 'BasicStruct'
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 212: 
'trivial_abi' cannot be applied to 'StructWithAnonymousUnion'
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 233: 
'trivial_abi' cannot be applied to 'StructWithAnonymousStruct'
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 251: 
'trivial_abi' cannot be applied to 'TrivialAbiAttributeAppliedToAnonymousUnion'
  error: 'note' diagnostics seen but not expected: 
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 194: 
'trivial_abi' is disallowed on 'BasicStruct' because it has a field of a 
non-trivial class type
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 212: 
'trivial_abi' is disallowed on 'StructWithAnonymousUnion' because it has a 
field of a non-trivial class type
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 233: 
'trivial_abi' is disallowed on 'StructWithAnonymousStruct' because it has a 
field of a non-trivial class type
File C:\src\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp Line 251: 
'trivial_abi' is disallowed on 'TrivialAbiAttributeAppliedToAnonymousUnion' 
because it has a field of a non-trivial class type

Alternatively, maybe the test classes can be made trivially copyable.

> Please take a look and revert for now if it takes a while to fix.

I need to take a few days off this week, so I think it will indeed be safest to 
revert for now.  I don't have write access to the repo though - I hope that 
@gribozavr2 can help with the revert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155895

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


[PATCH] D157164: [clang-tidy] Add fix-it support to `llvmlibc-inline-function-decl`

2023-08-07 Thread Roland McGrath via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d4162ff28b4: [clang-tidy] Add fix-it support to 
`llvmlibc-inline-function-decl` (authored by mcgrathr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157164

Files:
  clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
@@ -17,11 +17,13 @@
 
 constexpr long long addll(long long a, long long b) {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addll' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: LIBC_INLINE constexpr long long addll(long long a, long long b) {
   return a + b;
 }
 
 inline unsigned long addul(unsigned long a, unsigned long b) {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addul' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: LIBC_INLINE inline unsigned long addul(unsigned long a, unsigned long b) {
   return a + b;
 }
 
@@ -30,11 +32,13 @@
 public:
   MyClass() : A(123) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'MyClass' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+  // CHECK-FIXES:   LIBC_INLINE MyClass() : A(123) {}
 
   LIBC_INLINE MyClass(int V) : A(V) {}
 
   constexpr operator int() const { return A; }
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator int' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+  // CHECK-FIXES:   LIBC_INLINE constexpr operator int() const { return A; }
 
   LIBC_INLINE bool operator==(const MyClass ) {
 return RHS.A == A;
@@ -42,6 +46,7 @@
 
   static int getVal(const MyClass ) {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'getVal' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+  // CHECK-FIXES:   LIBC_INLINE static int getVal(const MyClass ) {
 return V.A;
   }
 
@@ -51,6 +56,7 @@
 
   constexpr static int addInt(MyClass , int A) {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'addInt' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+  // CHECK-FIXES:   LIBC_INLINE constexpr static int addInt(MyClass , int A) {
 return V.A += A;
   }
 
@@ -78,6 +84,7 @@
 
 inline void badSimpleFunction() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badSimpleFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: LIBC_INLINE inline void badSimpleFunction() {}
 
 void LIBC_INLINE badSimpleFunctionWrongLocation() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badSimpleFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
@@ -93,6 +100,7 @@
 
 template  inline void badTemplateFunction() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badTemplateFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: template  LIBC_INLINE inline void badTemplateFunction() {}
 
 template  void LIBC_INLINE badTemplateFunctionWrongLocation() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badTemplateFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
@@ -108,9 +116,11 @@
 
 template  inline void badVariadicFunction() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: template  LIBC_INLINE inline void badVariadicFunction() {}
 
 template  void LIBC_INLINE badVariadicFunctionWrongLocation() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: template  LIBC_INLINE void LIBC_INLINE badVariadicFunctionWrongLocation() {}
 
 struct 

[clang-tools-extra] 9d4162f - [clang-tidy] Add fix-it support to `llvmlibc-inline-function-decl`

2023-08-07 Thread Roland McGrath via cfe-commits

Author: Roland McGrath
Date: 2023-08-07T12:15:59-07:00
New Revision: 9d4162ff28b479c93d55df67bf38507bdc50a2d1

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

LOG: [clang-tidy] Add fix-it support to `llvmlibc-inline-function-decl`

This is very simplistic and could be more thorough by replacing
an existing `LIBC_INLINE` in the wrong location or a redunant
`inline` when inserting the right macro use.  But as is this
suffices to automatically apply fixes for most or all of the
instances in the libc tree today and get working results (despite
some superfluous `inline` keywords left behind).

Reviewed By: abrachet

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp 
b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
index f901cd115a8ff7..c119e393d3ab69 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
@@ -88,7 +88,7 @@ void InlineFunctionDeclCheck::check(const 
MatchFinder::MatchResult ) {
 
   diag(SrcBegin, "%0 must be tagged with the LIBC_INLINE macro; the macro "
  "should be placed at the beginning of the declaration")
-  << FuncDecl;
+  << FuncDecl << FixItHint::CreateInsertion(Loc, "LIBC_INLINE ");
 }
 
 } // namespace clang::tidy::llvm_libc

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp 
b/clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
index ab4410ad4fb478..0028c575b1d687 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
@@ -17,11 +17,13 @@ LIBC_INLINE constexpr long addl(long a, long b) {
 
 constexpr long long addll(long long a, long long b) {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addll' must be tagged with the 
LIBC_INLINE macro; the macro should be placed at the beginning of the 
declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: LIBC_INLINE constexpr long long addll(long long a, long long 
b) {
   return a + b;
 }
 
 inline unsigned long addul(unsigned long a, unsigned long b) {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addul' must be tagged with the 
LIBC_INLINE macro; the macro should be placed at the beginning of the 
declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: LIBC_INLINE inline unsigned long addul(unsigned long a, 
unsigned long b) {
   return a + b;
 }
 
@@ -30,11 +32,13 @@ class  MyClass {
 public:
   MyClass() : A(123) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'MyClass' must be tagged with 
the LIBC_INLINE macro; the macro should be placed at the beginning of the 
declaration [llvmlibc-inline-function-decl]
+  // CHECK-FIXES:   LIBC_INLINE MyClass() : A(123) {}
 
   LIBC_INLINE MyClass(int V) : A(V) {}
 
   constexpr operator int() const { return A; }
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator int' must be tagged 
with the LIBC_INLINE macro; the macro should be placed at the beginning of the 
declaration [llvmlibc-inline-function-decl]
+  // CHECK-FIXES:   LIBC_INLINE constexpr operator int() const { return A; }
 
   LIBC_INLINE bool operator==(const MyClass ) {
 return RHS.A == A;
@@ -42,6 +46,7 @@ class  MyClass {
 
   static int getVal(const MyClass ) {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'getVal' must be tagged with the 
LIBC_INLINE macro; the macro should be placed at the beginning of the 
declaration [llvmlibc-inline-function-decl]
+  // CHECK-FIXES:   LIBC_INLINE static int getVal(const MyClass ) {
 return V.A;
   }
 
@@ -51,6 +56,7 @@ class  MyClass {
 
   constexpr static int addInt(MyClass , int A) {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'addInt' must be tagged with the 
LIBC_INLINE macro; the macro should be placed at the beginning of the 
declaration [llvmlibc-inline-function-decl]
+  // CHECK-FIXES:   LIBC_INLINE constexpr static int addInt(MyClass , int A) 
{
 return V.A += A;
   }
 
@@ -78,6 +84,7 @@ LIBC_INLINE void goodSimpleFunction() {}
 
 inline void badSimpleFunction() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badSimpleFunction' must be tagged 
with the LIBC_INLINE macro; the macro should be placed at the beginning of the 
declaration [llvmlibc-inline-function-decl]
+// CHECK-FIXES: LIBC_INLINE inline void badSimpleFunction() {}
 
 void LIBC_INLINE badSimpleFunctionWrongLocation() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 

[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-08-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D151683#4566907 , @eaeltsin wrote:

> Hi,
>
> Is it a known issue, that clang doesn't compile `void foo(char *argv[] 
> [[maybe_unused]]) {}` ? The error is `error: 'maybe_unused' attribute cannot 
> be applied to types`.
>
> https://godbolt.org/z/r9E81cWxh - clang fails, but gcc doesn't.
>
> It looks like there is a lot of oss code of the form `void foo(char *argv[] 
> ATTRIBUTE_UNUSED)`, where `ATTRIBUTE_UNUSED` was configured to 
> `__attribute__((unused))` before this change (thus compiled ok) and to 
> `[[maybe_unused]]` after this change (thus started to break).

https://eel.is/c++draft/dcl.array#3.sentence-2 -- an attribute in that position 
appertains to the array type and `maybe_unused` cannot be applied to types in 
that way, so I believe Clang's behavior is correct. So I think the C++ 
attribute behavior is expected, but the change between `__attribute__` and 
`[[]]` may be catching folks off-guard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

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


[PATCH] D154300: [CUDA][HIP] Fix template argument deduction

2023-08-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 547901.
yaxunl marked an inline comment as done.
yaxunl added a comment.

revised by comments


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

https://reviews.llvm.org/D154300

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/template-arg-deduction.cu

Index: clang/test/SemaCUDA/template-arg-deduction.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/template-arg-deduction.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+void foo();
+__device__ void foo();
+
+template
+void host_temp(F f);
+
+template
+__device__ void device_temp(F f);
+
+void host_caller() {
+  host_temp(foo);
+}
+
+__global__ void kernel_caller() {
+  device_temp(foo);
+}
+
+__device__ void device_caller() {
+  device_temp(foo);
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -12750,6 +12750,13 @@
   DeclAccessPair DAP;
   SmallVector AmbiguousDecls;
 
+  // Return positive for better, negative for worse, 0 for equal preference.
+  auto CheckCUDAPreference = [&](FunctionDecl *FD1, FunctionDecl *FD2) {
+FunctionDecl *Caller = getCurFunctionDecl(/*AllowLambda=*/true);
+return static_cast(IdentifyCUDAPreference(Caller, FD1)) -
+   static_cast(IdentifyCUDAPreference(Caller, FD2));
+  };
+
   auto CheckMoreConstrained = [&](FunctionDecl *FD1,
   FunctionDecl *FD2) -> std::optional {
 if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
@@ -12780,9 +12787,31 @@
 if (!checkAddressOfFunctionIsAvailable(FD))
   continue;
 
+// If we found a better result, update Result.
+auto FoundBetter = [&]() {
+  IsResultAmbiguous = false;
+  DAP = I.getPair();
+  Result = FD;
+};
+
 // We have more than one result - see if it is more constrained than the
 // previous one.
 if (Result) {
+  // Check CUDA preference first. If the candidates have differennt CUDA
+  // preference, choose the one with higher CUDA preference. Otherwise,
+  // choose the one with more constraints.
+  if (getLangOpts().CUDA) {
+int PreferenceByCUDA = CheckCUDAPreference(FD, Result);
+// FD has different preference than Result.
+if (PreferenceByCUDA != 0) {
+  // FD is more preferable than Result.
+  if (PreferenceByCUDA > 0)
+FoundBetter();
+  continue;
+}
+  }
+  // FD has the same CUDA prefernece than Result. Continue check
+  // constraints.
   std::optional MoreConstrainedThanPrevious =
   CheckMoreConstrained(FD, Result);
   if (!MoreConstrainedThanPrevious) {
@@ -12794,9 +12823,7 @@
 continue;
   // FD is more constrained - replace Result with it.
 }
-IsResultAmbiguous = false;
-DAP = I.getPair();
-Result = FD;
+FoundBetter();
   }
 
   if (IsResultAmbiguous)
@@ -12806,9 +12833,15 @@
 SmallVector ResultAC;
 // We skipped over some ambiguous declarations which might be ambiguous with
 // the selected result.
-for (FunctionDecl *Skipped : AmbiguousDecls)
+for (FunctionDecl *Skipped : AmbiguousDecls) {
+  // If skipped candidate has different CUDA preference than the result,
+  // there is no ambiguity. Otherwise check whether they have different
+  // constraints.
+  if (getLangOpts().CUDA && CheckCUDAPreference(Skipped, Result) != 0)
+continue;
   if (!CheckMoreConstrained(Skipped, Result))
 return nullptr;
+}
 Pair = DAP;
   }
   return Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156014: [Clang][NVPTX] Permit use of the alias attribute for NVPTX targets

2023-08-07 Thread Joseph Huber 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 rG0ba9aec38faa: [Clang][NVPTX] Permit use of the alias 
attribute for NVPTX targets (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156014

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCUDA/alias.cu


Index: clang/test/CodeGenCUDA/alias.cu
===
--- clang/test/CodeGenCUDA/alias.cu
+++ clang/test/CodeGenCUDA/alias.cu
@@ -4,17 +4,26 @@
 
 // RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
 // RUN:   -o - %s | FileCheck %s
-// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn -emit-llvm \
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm 
-target-sdk-version=10.1 \
+// RUN:   -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
 // RUN:   -o - %s | FileCheck %s
 
 #include "Inputs/cuda.h"
 
-// Check that we don't generate an alias from "foo" to the mangled name for
-// ns::foo() -- nvptx doesn't support aliases.
-
-namespace ns {
 extern "C" {
-// CHECK-NOT: @foo = internal alias
-__device__ __attribute__((used)) static int foo() { return 0; }
-}
+__device__ int foo() { return 1; }
 }
+
+[[gnu::alias("foo")]] __device__ int alias();
+
+// CHECK: @_Z5aliasv = alias i32 (), ptr @foo
+//
+//  CHECK: define dso_local i32 @foo() #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT: entry:
+//  CHECK:   ret i32 1
+// CHECK-NEXT: }
+
+// RUN: not %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm 
-target-sdk-version=9.0 \
+// RUN:   -o - %s 2>&1 | FileCheck %s --check-prefix=NO_SUPPORT
+// NO_SUPPORT: CUDA older than 10.0 does not support .alias
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -23,6 +23,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/Cuda.h"
 #include "clang/Basic/DarwinSDKInfo.h"
 #include "clang/Basic/HLSLRuntime.h"
 #include "clang/Basic/LangOptions.h"
@@ -1992,8 +1993,12 @@
 S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_darwin);
 return;
   }
+
   if (S.Context.getTargetInfo().getTriple().isNVPTX()) {
-S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_nvptx);
+CudaVersion Version =
+ToCudaVersion(S.Context.getTargetInfo().getSDKVersion());
+if (Version != CudaVersion::UNKNOWN && Version < CudaVersion::CUDA_100)
+  S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_nvptx);
   }
 
   // Aliases should be on declarations, not definitions.
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8658,8 +8658,8 @@
 def err_variadic_device_fn : Error<
   "CUDA device code does not support variadic functions">;
 def err_va_arg_in_device : Error<
-  "CUDA device code does not support va_arg">;
-def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">;
+"CUDA device code does not support va_arg">;
+def err_alias_not_supported_on_nvptx : Error<"CUDA older than 10.0 does not 
support .alias">;
 def err_cuda_unattributed_constexpr_cannot_overload_device : Error<
   "constexpr function %0 without __host__ or __device__ attributes cannot "
   "overload __device__ function with same signature.  Add a __host__ "


Index: clang/test/CodeGenCUDA/alias.cu
===
--- clang/test/CodeGenCUDA/alias.cu
+++ clang/test/CodeGenCUDA/alias.cu
@@ -4,17 +4,26 @@
 
 // RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
 // RUN:   -o - %s | FileCheck %s
-// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn -emit-llvm \
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm -target-sdk-version=10.1 \
+// RUN:   -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
 // RUN:   -o - %s | FileCheck %s
 
 #include "Inputs/cuda.h"
 
-// Check that we don't generate an alias from "foo" to the mangled name for
-// ns::foo() -- nvptx doesn't support aliases.
-
-namespace ns {
 extern "C" {
-// CHECK-NOT: @foo = internal alias
-__device__ __attribute__((used)) static int foo() { return 0; }
-}
+__device__ int foo() { return 1; }
 }
+
+[[gnu::alias("foo")]] __device__ int alias();
+
+// CHECK: @_Z5aliasv = alias i32 (), ptr @foo
+//
+//  CHECK: define dso_local i32 @foo() #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT: entry:
+//  CHECK:   ret i32 1
+// CHECK-NEXT: }
+
+// 

[clang] 0ba9aec - [Clang][NVPTX] Permit use of the alias attribute for NVPTX targets

2023-08-07 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-08-07T14:08:04-05:00
New Revision: 0ba9aec38faa8f567741fdb4eac1149c3fe94ceb

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

LOG: [Clang][NVPTX] Permit use of the alias attribute for NVPTX targets

The patch in D155211 added basic support for the `.alias` keyword in
PTX. This means we should be able to permit use of this in clang.

Reviewed By: tra

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGenCUDA/alias.cu

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4979f9f86d236d..ae9ccdc8ab701e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8658,8 +8658,8 @@ def warn_kern_is_inline : Warning<
 def err_variadic_device_fn : Error<
   "CUDA device code does not support variadic functions">;
 def err_va_arg_in_device : Error<
-  "CUDA device code does not support va_arg">;
-def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">;
+"CUDA device code does not support va_arg">;
+def err_alias_not_supported_on_nvptx : Error<"CUDA older than 10.0 does not 
support .alias">;
 def err_cuda_unattributed_constexpr_cannot_overload_device : Error<
   "constexpr function %0 without __host__ or __device__ attributes cannot "
   "overload __device__ function with same signature.  Add a __host__ "

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 429fa12ff2e293..f71e663bca315f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -23,6 +23,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/Cuda.h"
 #include "clang/Basic/DarwinSDKInfo.h"
 #include "clang/Basic/HLSLRuntime.h"
 #include "clang/Basic/LangOptions.h"
@@ -1992,8 +1993,12 @@ static void handleAliasAttr(Sema , Decl *D, const 
ParsedAttr ) {
 S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_darwin);
 return;
   }
+
   if (S.Context.getTargetInfo().getTriple().isNVPTX()) {
-S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_nvptx);
+CudaVersion Version =
+ToCudaVersion(S.Context.getTargetInfo().getSDKVersion());
+if (Version != CudaVersion::UNKNOWN && Version < CudaVersion::CUDA_100)
+  S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_nvptx);
   }
 
   // Aliases should be on declarations, not definitions.

diff  --git a/clang/test/CodeGenCUDA/alias.cu b/clang/test/CodeGenCUDA/alias.cu
index 56e595ed36390e..bc27d2f162a5a8 100644
--- a/clang/test/CodeGenCUDA/alias.cu
+++ b/clang/test/CodeGenCUDA/alias.cu
@@ -4,17 +4,26 @@
 
 // RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
 // RUN:   -o - %s | FileCheck %s
-// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn -emit-llvm \
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm 
-target-sdk-version=10.1 \
+// RUN:   -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
 // RUN:   -o - %s | FileCheck %s
 
 #include "Inputs/cuda.h"
 
-// Check that we don't generate an alias from "foo" to the mangled name for
-// ns::foo() -- nvptx doesn't support aliases.
-
-namespace ns {
 extern "C" {
-// CHECK-NOT: @foo = internal alias
-__device__ __attribute__((used)) static int foo() { return 0; }
-}
+__device__ int foo() { return 1; }
 }
+
+[[gnu::alias("foo")]] __device__ int alias();
+
+// CHECK: @_Z5aliasv = alias i32 (), ptr @foo
+//
+//  CHECK: define dso_local i32 @foo() #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT: entry:
+//  CHECK:   ret i32 1
+// CHECK-NEXT: }
+
+// RUN: not %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm 
-target-sdk-version=9.0 \
+// RUN:   -o - %s 2>&1 | FileCheck %s --check-prefix=NO_SUPPORT
+// NO_SUPPORT: CUDA older than 10.0 does not support .alias



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


[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-08-07 Thread Evgeny Eltsin via Phabricator via cfe-commits
eaeltsin added a comment.

Hi,

Is it a known issue, that clang doesn't compile `void foo(char *argv[] 
[[maybe_unused]]) {}` ?

https://godbolt.org/z/r9E81cWxh - clang fails, but gcc doesn't.

It looks like there is a lot of oss code of the form `void foo(char *argv[] 
ATTRIBUTE_UNUSED)`, where `ATTRIBUTE_UNUSED` was configured to 
`__attribute__((unused))` before this change (thus compiled ok) and to 
`[[maybe_unused]]` after this change (thus started to break).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

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


[PATCH] D154300: [CUDA][HIP] Fix template argument deduction

2023-08-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:12758-12764
+std::optional MorePreferableByCUDA =
+CheckCUDAPreference(FD, Result);
+// If FD has different CUDA preference than Result.
+if (MorePreferableByCUDA) {
+  // FD is less preferable than Result.
+  if (!*MorePreferableByCUDA)
+continue;

tra wrote:
> Maybe `CheckCUDAPreference` should return -1/0/1 or an enum. std::optional 
> does not seem to be very readable here.
> 
> E.g. `if(MorePreferableByCUDA)` sounds like it's going to be satisfied when 
> FD is a better choice than Result, but it's not the case.
> I think this would be easier to follow:
> ```
> if (CheckCUDAPreference(FD, Result) <= 0) // or `!= CP_BETTER`
>  continue;
> ```
> 
will use an integer for that.


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

https://reviews.llvm.org/D154300

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


[PATCH] D155895: Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`.

2023-08-07 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on windows: http://45.33.8.238/win/82239/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155895

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


[PATCH] D140828: [C++] Implement "Deducing this" (P0847R7)

2023-08-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/include/clang/AST/Expr.h:1279
+  explicit DeclRefExpr(EmptyShell Empty) : Expr(DeclRefExprClass, Empty) {
+DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = false;
+  }

aaron.ballman wrote:
> We usually only create the empty shell when we're doing something like AST 
> deserialization, and we expect that to perform the initialization of each 
> field manually. I think you can remove this bit?
I moved it to the serialization code, but this fields is never serialized (It 
stop being useful once the dependency is computed). 
Maybe DeclRefExprBits is not the best place but at the same time this way it 
doesn't take too much space



Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:1365-1366
   Method1->isStatic() == Method2->isStatic() &&
+  Method1->isImplicitObjectMemberFunction() ==
+  Method2->isImplicitObjectMemberFunction() &&
   Method1->isConst() == Method2->isConst() &&

aaron.ballman wrote:
> Is this correct for structural equivalence, or are these supposed to be 
> structurally equivalent?
> ```
> void func(const this auto& R);
> // and
> void func() const &;
> ```
> I think these aren't equivalent, but I wanted to be sure.
Yup, they have completely different type



Comment at: clang/lib/AST/DeclCXX.cpp:841
   const auto *ParamTy =
-  Method->getParamDecl(0)->getType()->getAs();
+  Method->getNonObjectParameter(0)->getType()->getAs();
   if (!ParamTy || ParamTy->getPointeeType().isConstQualified())

aaron.ballman wrote:
> Under what circumstances should existing calls to `getParamDecl()` be 
> converted to using `getNonObjectParameter()` instead? Similar for 
> `getNumParams()`.
everytime you want to ignore (or handle differently) the explicit object 
parameter. I'll do another survey at some point, to be sure i didn't miss a spot



Comment at: clang/lib/AST/DeclCXX.cpp:2531-2534
+  RefQualifierKind RK = FPT->getRefQualifier();
+  if (RK == RefQualifierKind::RQ_RValue)
+return C.getRValueReferenceType(Type);
+  return C.getLValueReferenceType(Type);

aaron.ballman wrote:
> What about other kinds of qualifiers like `const` and `volatile`?
`::getThisObjectType` does that for us



Comment at: clang/lib/AST/ExprClassification.cpp:468
 
-  if (isa(D) && cast(D)->isInstance())
-return Cl::CL_MemberFunction;
+  if (auto *M = dyn_cast(D)) {
+if (M->isImplicitObjectMemberFunction())

aaron.ballman wrote:
> Just to double-check -- an explicit object member function is a prvalue?
This is my reading of https://eel.is/c++draft/expr.prim#id.qual-5 




Comment at: clang/lib/AST/ExprClassification.cpp:559-565
+  if (const auto *Method = dyn_cast(Member)) {
+if (Method->isStatic())
+  return Cl::CL_LValue;
+if (Method->isImplicitObjectMemberFunction())
+  return Cl::CL_MemberFunction;
+return Cl::CL_PRValue;
+  }

aaron.ballman wrote:
> 
Can you confirm? I know it's redundant, but it matches the comment and i don't 
think removing it is an improvement


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140828

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


[PATCH] D157164: [clang-tidy] Add fix-it support to `llvmlibc-inline-function-decl`

2023-08-07 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Release notes are missing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157164

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


[PATCH] D156556: [AggressiveInstCombine][NFC] Fix typo

2023-08-07 Thread Maksim Kita 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 rG5dde755188e3: [AggressiveInstCombine][NFC] Fix typo 
(authored by kitaisreal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156556

Files:
  llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp


Index: llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
===
--- llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -934,13 +934,8 @@
   size_t ConstantStrSize = ConstantStr.size();
 
   // Trivial cases are optimized during inst combine
-  if (ConstantStrSize == 0) {
+  if (ConstantStrSize == 0 || ConstantStrSize > 2)
 return false;
-  }
-
-  if (ConstantStrSize > 2) {
-return false;
-  }
 
   // Check if strcmp result is only used in a comparison with zero
   if (!isOnlyUsedInZeroComparison(CI))
@@ -960,7 +955,7 @@
   // For strcmp(P, "xy") do the following transformation:
   //
   // (before)
-  // dst = strcmp(P, "x")
+  // dst = strcmp(P, "xy")
   //
   // (after)
   // v0 = P[0] - 'x'
@@ -1000,19 +995,19 @@
 static_cast(ConstantStr[CharacterIndexToCheck]));
 Value *CharacterSub =
 B.CreateNSWSub(StrCharacterValue, ConstantStrCharacterValue);
-Value *IsCharacterSubZero =
+Value *CharacterSubIsZero =
 B.CreateICmpEQ(CharacterSub, ConstantInt::get(RetType, 0));
-BasicBlock *IsCharacterSubZeroBB =
+BasicBlock *CharacterSubIsZeroBB =
 BasicBlock::Create(B.getContext(), "strcmp_expand_sub_is_zero",
InitialBB->getParent(), JoinBlock);
-B.CreateCondBr(IsCharacterSubZero, IsCharacterSubZeroBB, JoinBlock);
+B.CreateCondBr(CharacterSubIsZero, CharacterSubIsZeroBB, JoinBlock);
 
 ResultPHI->addIncoming(CharacterSub, B.GetInsertBlock());
 DTUpdates.emplace_back(DominatorTree::Insert, B.GetInsertBlock(),
-   IsCharacterSubZeroBB);
+   CharacterSubIsZeroBB);
 
-B.SetInsertPoint(IsCharacterSubZeroBB);
-DTUpdates.emplace_back(DominatorTree::Insert, IsCharacterSubZeroBB,
+B.SetInsertPoint(CharacterSubIsZeroBB);
+DTUpdates.emplace_back(DominatorTree::Insert, CharacterSubIsZeroBB,
JoinBlock);
   }
 


Index: llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
===
--- llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -934,13 +934,8 @@
   size_t ConstantStrSize = ConstantStr.size();
 
   // Trivial cases are optimized during inst combine
-  if (ConstantStrSize == 0) {
+  if (ConstantStrSize == 0 || ConstantStrSize > 2)
 return false;
-  }
-
-  if (ConstantStrSize > 2) {
-return false;
-  }
 
   // Check if strcmp result is only used in a comparison with zero
   if (!isOnlyUsedInZeroComparison(CI))
@@ -960,7 +955,7 @@
   // For strcmp(P, "xy") do the following transformation:
   //
   // (before)
-  // dst = strcmp(P, "x")
+  // dst = strcmp(P, "xy")
   //
   // (after)
   // v0 = P[0] - 'x'
@@ -1000,19 +995,19 @@
 static_cast(ConstantStr[CharacterIndexToCheck]));
 Value *CharacterSub =
 B.CreateNSWSub(StrCharacterValue, ConstantStrCharacterValue);
-Value *IsCharacterSubZero =
+Value *CharacterSubIsZero =
 B.CreateICmpEQ(CharacterSub, ConstantInt::get(RetType, 0));
-BasicBlock *IsCharacterSubZeroBB =
+BasicBlock *CharacterSubIsZeroBB =
 BasicBlock::Create(B.getContext(), "strcmp_expand_sub_is_zero",
InitialBB->getParent(), JoinBlock);
-B.CreateCondBr(IsCharacterSubZero, IsCharacterSubZeroBB, JoinBlock);
+B.CreateCondBr(CharacterSubIsZero, CharacterSubIsZeroBB, JoinBlock);
 
 ResultPHI->addIncoming(CharacterSub, B.GetInsertBlock());
 DTUpdates.emplace_back(DominatorTree::Insert, B.GetInsertBlock(),
-   IsCharacterSubZeroBB);
+   CharacterSubIsZeroBB);
 
-B.SetInsertPoint(IsCharacterSubZeroBB);
-DTUpdates.emplace_back(DominatorTree::Insert, IsCharacterSubZeroBB,
+B.SetInsertPoint(CharacterSubIsZeroBB);
+DTUpdates.emplace_back(DominatorTree::Insert, CharacterSubIsZeroBB,
JoinBlock);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157227: [Clang] Don't add `undef` for `operator new` under -fno-exceptions.

2023-08-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D157227#4564817 , @nikic wrote:

> Removing noundef makes no sense to me, because the return value is noundef 
> even under fno-exceptions. If we remove something, it should be the nonnull 
> attribute, because that's what's actually being violated.
>
> @ldionne Can you give us an ETA on D150610  
> please? Do we need to introduce a workaround for this libcxx bug in clang, or 
> do you plan to fix this in the near future?

I'll try to do this for LLVM 18, sorry that's just a complicated change. I 
would recommend not working around this in Clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157227

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


[PATCH] D156821: [CodeGen] [ubsan] Respect integer overflow handling in abs builtin

2023-08-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

This looks good to me, but I'm not sure I'm a fully qualified reviewer here.


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

https://reviews.llvm.org/D156821

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


[PATCH] D141918: WIP: [Clang] Emit 'unwindabort' when applicable.

2023-08-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Thanks for the rebase!

We're eager to try this for Meta's Android apps, where size is a priority and 
better `noexcept` codegen would be really helpful. I ran into a crash with 
coroutines though, which blocks me from fully evaluating the size difference 
made by these changes. The reduced test case is in P8313 
, and you can repro the crash by running:

  $ clang -std=c++20 -O2 -c crash.cpp
  cannot use musttail with unwindabort
musttail call unwindabort fastcc void %10(ptr %call57)
  in function _Z5startv.resume
  fatal error: error in backend: Broken function found, compilation aborted!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141918

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


[PATCH] D157296: [AST][Coroutine] Fix CoyieldExpr missing end loc

2023-08-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:322
+  auto EndLoc = Args.empty() ? Loc : Args.back()->getEndLoc();
+  return S.BuildCallExpr(nullptr, Result.get(), Loc, Args, EndLoc, nullptr);
 }

hokein wrote:
> Thanks for the fast fix.
> 
> Reading the source code here, I'm not sure this is a correct fix (and put the 
> heuristic here). I assume the `Loc` points the the `co_yield` token here, 
> passing the `Loc` to the `LParenLoc` and `RParenLoc` parameters seems wrong 
> to me, there is no `(` and `)` written in the source code here (because the 
> member call expression is an implicit generated node in the clang AST), we 
> should pass an invalid source location (`SourceLocation()`).
> 
> The `CallExpr::getEndLoc()` has implemented similar 
> [heuristic](https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/Expr.cpp#L1662-L1664)
>  to handle the case where the RParenLoc is invalid.
>  passing the Loc to the LParenLoc and RParenLoc parameters seems wrong to me

FWIW, I thought so as well, but I thought we have the same behavior for 
`CoreturnExpr` and `CoawaitExpr`. These statements are not really call 
expressions as far as the AST is concerned, so it's a bit hard to say whether 
there is a right or wrong answer for where the l- and r-paren locations are for 
the call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157296

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


[PATCH] D157296: [AST][Coroutine] Fix CoyieldExpr missing end loc

2023-08-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:322
+  auto EndLoc = Args.empty() ? Loc : Args.back()->getEndLoc();
+  return S.BuildCallExpr(nullptr, Result.get(), Loc, Args, EndLoc, nullptr);
 }

Thanks for the fast fix.

Reading the source code here, I'm not sure this is a correct fix (and put the 
heuristic here). I assume the `Loc` points the the `co_yield` token here, 
passing the `Loc` to the `LParenLoc` and `RParenLoc` parameters seems wrong to 
me, there is no `(` and `)` written in the source code here (because the member 
call expression is an implicit generated node in the clang AST), we should pass 
an invalid source location (`SourceLocation()`).

The `CallExpr::getEndLoc()` has implemented similar 
[heuristic](https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/Expr.cpp#L1662-L1664)
 to handle the case where the RParenLoc is invalid.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157296

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


[PATCH] D157157: [clang] Add clang support for Machine Function Splitting on AArch64

2023-08-07 Thread Daniel Hoekwater via Phabricator via cfe-commits
dhoekwater updated this revision to Diff 547884.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157157

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,8 +1,10 @@
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | 
FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=CHECK-NOOPT %s
+// RUN: %clang -### -target aarch64-unknown-linux 
-fprofile-use=default.profdata -fsplit-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=CHECK-AARCH64 %s
 // RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 
2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 
 // CHECK-OPT:   "-fsplit-machine-functions"
 // CHECK-NOOPT-NOT: "-fsplit-machine-functions"
+// CHECK-AARCH64:   "-fsplit-machine-functions"
 // CHECK-TRIPLE:error: unsupported option '-fsplit-machine-functions' for 
target
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5849,8 +5849,8 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
-// This codegen pass is only available on x86-elf targets.
-if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+// This codegen pass is only available on x86 and Arm ELF targets.
+if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF()) {
   if (A->getOption().matches(options::OPT_fsplit_machine_functions))
 A->render(Args, CmdArgs);
 } else {


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,8 +1,10 @@
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// RUN: %clang -### -target aarch64-unknown-linux -fprofile-use=default.profdata -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-AARCH64 %s
 // RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 
 // CHECK-OPT:   "-fsplit-machine-functions"
 // CHECK-NOOPT-NOT: "-fsplit-machine-functions"
+// CHECK-AARCH64:   "-fsplit-machine-functions"
 // CHECK-TRIPLE:error: unsupported option '-fsplit-machine-functions' for target
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5849,8 +5849,8 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
-// This codegen pass is only available on x86-elf targets.
-if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+// This codegen pass is only available on x86 and Arm ELF targets.
+if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF()) {
   if (A->getOption().matches(options::OPT_fsplit_machine_functions))
 A->render(Args, CmdArgs);
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157296: [AST][Coroutine] Fix CoyieldExpr missing end loc

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157296

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


[PATCH] D154559: [clang] Fix constant evaluation about static member function

2023-08-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

Clang was correct here until fairly recently; P2280 
 
(https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2280r4.html) changed 
the language rules. It was applied as a DR, so we should make that change 
retroactively rather than only in C++23 mode. See 
https://github.com/llvm/llvm-project/issues/63139, which tracks implementation 
of that language change.

I don't think we should be applying an ad-hoc patch like this which doesn't 
follow either the old or the new language rule, and should instead implement 
the new rule from P2280 .


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

https://reviews.llvm.org/D154559

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


[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-07 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok added inline comments.



Comment at: clang/test/Sema/format-pointer.c:39
+  printf("%p", np);
+  scanf("%p", );  // expected-warning {{format specifies type 'void **' but 
the argument has type 'nullptr_t *'}}
+  scanf("%p", );  // pedantic-warning {{format specifies type 'void **' 
but the argument has type 'nullptr_t **'}}

Should this be a pedantic warning?

If this reads a non-null pointer, the bit pattern of `np` will be messed up but 
`np` will still read as a nullptr.
If it reads a null pointer, it should be fine.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156054

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


  1   2   3   >