[PATCH] D140954: [7/7][Clang][RISCV][NFC] Remove attribute `IsPrototypeDefaultTU`

2023-01-23 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b28229412dc: [7/7][Clang][RISCV][NFC] Remove attribute 
`IsPrototypeDefaultTU` (authored by eopXD).
Herald added a subscriber: luke.

Changed prior to commit:
  https://reviews.llvm.org/D140954?vs=489283&id=491620#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140954

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -66,7 +66,6 @@
   bool HasMasked :1;
   bool HasVL :1;
   bool HasMaskedOffOperand :1;
-  bool IsPrototypeDefaultTU : 1;
   bool HasTailPolicy : 1;
   bool HasMaskPolicy : 1;
   uint8_t UnMaskedPolicyScheme : 2;
@@ -518,7 +517,6 @@
 std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL");
 bool HasTailPolicy = R->getValueAsBit("HasTailPolicy");
 bool HasMaskPolicy = R->getValueAsBit("HasMaskPolicy");
-bool IsPrototypeDefaultTU = R->getValueAsBit("IsPrototypeDefaultTU");
 bool SupportOverloading = R->getValueAsBit("SupportOverloading");
 bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
@@ -549,13 +547,13 @@
 parsePrototypes(OverloadedSuffixProto);
 
 // Compute Builtin types
-auto Prototype = RVVIntrinsic::computeBuiltinTypes(
-BasicPrototype, /*IsMasked=*/false,
-/*HasMaskedOffOperand=*/false, HasVL, NF, IsPrototypeDefaultTU,
-UnMaskedPolicyScheme, Policy());
+auto Prototype =
+RVVIntrinsic::computeBuiltinTypes(BasicPrototype, /*IsMasked=*/false,
+  /*HasMaskedOffOperand=*/false, HasVL,
+  NF, UnMaskedPolicyScheme, Policy());
 auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-IsPrototypeDefaultTU, MaskedPolicyScheme, Policy());
+MaskedPolicyScheme, Policy());
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -577,22 +575,22 @@
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-Policy(), IsPrototypeDefaultTU));
+Policy()));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
 RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF,
-IsPrototypeDefaultTU, UnMaskedPolicyScheme, P);
+UnMaskedPolicyScheme, P);
 std::optional PolicyTypes =
 TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName,
 /*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-ManualCodegen, *PolicyTypes, IntrinsicTypes,
-RequiredFeatures, NF, P, IsPrototypeDefaultTU));
+ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures,
+NF, P));
   }
 if (!HasMasked)
   continue;
@@ -602,24 +600,23 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
-SupportOverloading, HasBuiltinAlias, ManualCodegen,
-*MaskTypes, IntrinsicTypes, RequiredFeatures, NF,
-Policy(), IsPrototypeDefaultTU));
+SupportOverloading, HasBuiltinAlias, ManualCodegen, *MaskTypes,
+IntrinsicTypes, RequiredFeatures, NF, Policy()));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
   SmallVector PolicyPrototype =
   RVVIntrinsic::computeBuiltinTypes(
   BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
-  NF, IsPrototypeDefaultTU, MaskedPolicyScheme, P);
+  NF, MaskedPolicyScheme, P);
   std::optional PolicyTypes =
  

[clang] 6b28229 - [7/7][Clang][RISCV][NFC] Remove attribute `IsPrototypeDefaultTU`

2023-01-23 Thread via cfe-commits

Author: eopXD
Date: 2023-01-23T23:57:04-08:00
New Revision: 6b28229412dc9760b3fab33763f3347761876227

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

LOG: [7/7][Clang][RISCV][NFC] Remove attribute `IsPrototypeDefaultTU`

This is the 7th commit of a patch-set that aims to remove the
IsPrototypeDefaultTU special case for the rvv-intrinsics.

This is the final commit of the patch-set. Now that no intrinsics is
using the attribute, we are safe to remove it.

Please refer to the cover letter in the 1st commit (D140895) for an
overview.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Sema/SemaRISCVVectorLookup.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 6c6515b2f245c..b72eee6ccd18e 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -201,10 +201,6 @@ class RVVBuiltin : 
RVVOp0Builtin<"m", prototype, "c"> {
 }
 
 let UnMaskedPolicyScheme = HasPolicyOperand,
-HasMaskedOffOperand = false,
-IsPrototypeDefaultTU = false in {
+HasMaskedOffOperand = false in {
   multiclass RVVSlideUpBuiltinSet {
 defm "" : RVVOutBuiltinSet;
@@ -469,7 +464,6 @@ let UnMaskedPolicyScheme = HasPolicyOperand,
 }
 
 let UnMaskedPolicyScheme = HasPassthruOperand,
-IsPrototypeDefaultTU = false,
 ManualCodegen = [{
   if (IsMasked) {
 std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
@@ -1877,8 +1871,7 @@ defm vwmulsu : RVVOutOp0Op1BuiltinSet<"vwmulsu", "csi",
 }
 
 // 12.13. Vector Single-Width Integer Multiply-Add Instructions
-let UnMaskedPolicyScheme = HasPolicyOperand,
-IsPrototypeDefaultTU = false in {
+let UnMaskedPolicyScheme = HasPolicyOperand in {
 defm vmacc  : RVVIntTerBuiltinSet;
 defm vnmsac : RVVIntTerBuiltinSet;
 defm vmadd  : RVVIntTerBuiltinSet;
@@ -1989,8 +1982,7 @@ let Log2LMUL = [-2, -1, 0, 1, 2] in {
 }
 
 // 14.6. Vector Single-Width Floating-Point Fused Multiply-Add Instructions
-let UnMaskedPolicyScheme = HasPolicyOperand,
-IsPrototypeDefaultTU = false in {
+let UnMaskedPolicyScheme = HasPolicyOperand in {
 defm vfmacc  : RVVFloatingTerBuiltinSet;
 defm vfnmacc : RVVFloatingTerBuiltinSet;
 defm vfmsac  : RVVFloatingTerBuiltinSet;
@@ -2107,7 +2099,6 @@ let Log2LMUL = [-3, -2, -1, 0, 1, 2] in {
 // 15.1. Vector Single-Width Integer Reduction Instructions
 let UnMaskedPolicyScheme = HasPassthruOperand,
 MaskedPolicyScheme = HasPassthruOperand,
-IsPrototypeDefaultTU = false,
 HasMaskPolicy = false in {
 defm vredsum : RVVIntReductionBuiltinSet;
 defm vredmaxu : RVVUnsignedReductionBuiltin;
@@ -2190,7 +2181,7 @@ let HasMasked = false, MaskedPolicyScheme = NonePolicy in 
{
 defm vmv_x : RVVOp0BuiltinSet<"vmv_x_s", "csil",
[["s", "ve", "ev"],
 ["s", "UvUe", "UeUv"]]>;
-  let OverloadedName = "vmv_s", IsPrototypeDefaultTU = false,
+  let OverloadedName = "vmv_s",
   UnMaskedPolicyScheme = HasPassthruOperand,
   SupportOverloading = false in
 defm vmv_s : RVVOutBuiltinSet<"vmv_s_x", "csil",
@@ -2203,7 +2194,7 @@ let HasMasked = false, MaskedPolicyScheme = NonePolicy in 
{
   let HasVL = false, OverloadedName = "vfmv_f" in
 defm vfmv_f : RVVOp0BuiltinSet<"vfmv_f_s", "xfd",
  [["s", "ve", "ev"]]>;
-  let OverloadedName = "vfmv_s", IsPrototypeDefaultTU = false,
+  let OverloadedName = "vfmv_s",
   UnMaskedPolicyScheme = HasPassthruOperand,
   SupportOverloading = false in
 defm vfmv_s : RVVOutBuiltinSet<"vfmv_s_f", "xfd",
@@ -2244,8 +2235,7 @@ defm vrgatherei16 : RVVOutBuiltinSet<"vrgatherei16_vv", 
"csil",
 }
 
 // 17.5. Vector Compress Instruction
-let IsPrototypeDefaultTU = false,
-HasMasked = false,
+let HasMasked = false,
 UnMaskedPolicyScheme = HasPassthruOperand,
 MaskedPolicyScheme = NonePolicy,
 ManualCodegen = [{

diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index 68c8c48999e46..85323c02cdc72 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -402,7 +402,7 @@ class RVVIntrinsic {
const RVVTypes &Types,
const std::vector &IntrinsicTypes,
const std::vector &RequiredFeatures,
-   unsigned NF, Policy PolicyAttrs, bool IsPrototypeDefaultTU);
+   unsigned NF, Policy PolicyAttrs);

[PATCH] D140874: [clang][Interp] Support pointer types in compound assignment operations

2023-01-23 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 491619.
tbaeder marked an inline comment as done.

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

https://reviews.llvm.org/D140874

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -514,6 +514,199 @@
 return (a -= a);
   }
   static_assert(subAll(213) == 0, "");
+
+  constexpr bool BoolOr(bool b1, bool b2) {
+bool a;
+a = b1;
+a |= b2;
+return a;
+  }
+  static_assert(BoolOr(true, true), "");
+  static_assert(BoolOr(true, false), "");
+  static_assert(BoolOr(false, true), "");
+  static_assert(!BoolOr(false, false), "");
+
+  constexpr int IntOr(unsigned a, unsigned b) {
+unsigned r;
+r = a;
+r |= b;
+return r;
+  }
+  static_assert(IntOr(10, 1) == 11, "");
+  static_assert(IntOr(1337, -1) == -1, "");
+  static_assert(IntOr(0, 12) == 12, "");
+
+  constexpr bool BoolAnd(bool b1, bool b2) {
+bool a;
+a = b1;
+a &= b2;
+return a;
+  }
+  static_assert(BoolAnd(true, true), "");
+  static_assert(!BoolAnd(true, false), "");
+  static_assert(!BoolAnd(false, true), "");
+  static_assert(!BoolAnd(false, false), "");
+
+  constexpr int IntAnd(unsigned a, unsigned b) {
+unsigned r;
+r = a;
+r &= b;
+return r;
+  }
+  static_assert(IntAnd(10, 1) == 0, "");
+  static_assert(IntAnd(1337, -1) == 1337, "");
+  static_assert(IntAnd(0, 12) == 0, "");
+
+  constexpr bool BoolXor(bool b1, bool b2) {
+bool a;
+a = b1;
+a ^= b2;
+return a;
+  }
+  static_assert(!BoolXor(true, true), "");
+  static_assert(BoolXor(true, false), "");
+  static_assert(BoolXor(false, true), "");
+  static_assert(!BoolXor(false, false), "");
+
+  constexpr int IntXor(unsigned a, unsigned b) {
+unsigned r;
+r = a;
+r ^= b;
+return r;
+  }
+  static_assert(IntXor(10, 1) == 11, "");
+  static_assert(IntXor(10, 10) == 0, "");
+  static_assert(IntXor(12, true) == 13, "");
+
+  constexpr bool BoolRem(bool b1, bool b2) {
+bool a;
+a = b1;
+a %= b2;
+return a;
+  }
+  static_assert(!BoolRem(true, true), "");
+  static_assert(!BoolRem(false, true), "");
+
+  constexpr int IntRem(int a, int b) {
+int r;
+r = a;
+r %= b; // expected-note {{division by zero}} \
+// ref-note {{division by zero}} \
+// expected-note {{outside the range of representable values}} \
+// ref-note {{outside the range of representable values}}
+return r;
+  }
+  static_assert(IntRem(2, 2) == 0, "");
+  static_assert(IntRem(2, 1) == 0, "");
+  static_assert(IntRem(9, 7) == 2, "");
+  static_assert(IntRem(5, 0) == 0, ""); // expected-error {{not an integral constant expression}} \
+// expected-note {{in call to 'IntRem(5, 0)'}} \
+// ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'IntRem(5, 0)'}}
+
+  static_assert(IntRem(INT_MIN, -1) == 0, ""); // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'IntRem}} \
+   // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'IntRem}}
+
+
+
+  constexpr bool BoolDiv(bool b1, bool b2) {
+bool a;
+a = b1;
+a /= b2;
+return a;
+  }
+  static_assert(BoolDiv(true, true), "");
+  static_assert(!BoolDiv(false, true), "");
+
+  constexpr int IntDiv(int a, int b) {
+int r;
+r = a;
+r /= b; // expected-note {{division by zero}} \
+// ref-note {{division by zero}} \
+// expected-note {{outside the range of representable values}} \
+// ref-note {{outside the range of representable values}}
+return r;
+  }
+  static_assert(IntDiv(2, 2) == 1, "");
+  static_assert(IntDiv(12, 20) == 0, "");
+  static_assert(IntDiv(2, 1) == 2, "");
+  static_assert(IntDiv(9, 7) == 1, "");
+  static_assert(IntDiv(5, 0) == 0, ""); // expected-error {{not an integral constant expression}} \
+// expected-note {{in call to 'IntDiv(5, 0)'}} \
+// ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'IntDiv(5, 0)'}}
+
+  static_assert(IntDiv(INT_MIN, -1) == 0, ""); // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'IntDiv}} \
+   // ref-error {{not an integral constant expression}} \
+

[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-23 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D138546#4075681 , @cpsauer wrote:

> Sounds like you're not concerned, then, that the 
> JSONCompilationDatabasePlugin will get invoked and the results then passed to 
> a SystemIncludeExtractor-enabled mangler?
> (I'd seen some fallback calls into the plugin registry in 
> GlobalCompilationDatabase, hence the original change, but, lacking broader 
> context, I was having trouble tracing the expected control flow.)

I did initially overlook the mentioned fallback codepath 
,
 thanks for catching that. However, it looks like it's only taken if we've 
already explicitly checked for `compile_commands.json` and didn't find one, so 
`JsonCompilationDatabasePlugin` won't find anything either (i.e. the fallback 
is for potential other plugins).

As for consumers of the plugin registry outside of clangd, we can assume they 
won't use `SystemIncludeExtractor` which is currently a clangd-internal 
component. (There has been an idea floated about upstreaming 
`SystemIncludeExtractor` from clangd to libTooling, but it remains to be 
determined how that would look at the API level, and we can make adjustments as 
necessary if/when that happens.)

Anyways, +1 from me on the TargetAndMode related changes.


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

https://reviews.llvm.org/D138546

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


[PATCH] D140947: [6/7][Clang][RISCV] Remove default tail-undisturbed for vmv_s_x and vfmv_s_f intrinsics

2023-01-23 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14261c1991fe: [6/7][Clang][RISCV] Remove default 
tail-undisturbed for vmv_s_x and vfmv_s_f… (authored by eopXD).
Herald added a subscriber: luke.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140947

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
@@ -547,15 +547,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf8(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv1i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf8_t test_vmv_s_x_i8mf8(vint8mf8_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8mf4_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv2i8( [[SRC:%.*]])
@@ -565,15 +556,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf4(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv2i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf4_t test_vmv_s_x_i8mf4(vint8mf4_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8mf2_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv4i8( [[SRC:%.*]])
@@ -583,15 +565,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf2(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv4i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf2_t test_vmv_s_x_i8mf2(vint8mf2_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m1_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv8i8( [[SRC:%.*]])
@@ -601,15 +574,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m1(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv8i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m1_t test_vmv_s_x_i8m1(vint8m1_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m2_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv16i8( [[SRC:%.*]])
@@ -619,15 +583,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m2(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv16i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m2_t test_vmv_s_x_i8m2(vint8m2_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m4_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv32i8( [[SRC:%.*]])
@@ -637,15 +592,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m4(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv32i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m4_t test_vmv_s_x_i8m4(vint8m4_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m8_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv64i8( [[SRC:%.*]])
@@ -655,15 +601,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m8(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv64i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m8_t test_vmv_s_x_i8m8(vint8m8_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i16mf4_i16(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[

[clang] 14261c1 - [6/7][Clang][RISCV] Remove default tail-undisturbed for vmv_s_x and vfmv_s_f intrinsics

2023-01-23 Thread via cfe-commits

Author: eopXD
Date: 2023-01-23T23:53:27-08:00
New Revision: 14261c1991fe49e3a4ffcc58cdc5c5b91dc81ba9

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

LOG: [6/7][Clang][RISCV] Remove default tail-undisturbed for vmv_s_x and 
vfmv_s_f intrinsics

The destination parameter is removed for non-policy unmasked intrinsics.

The default policy for non-policy (implicit) vmv_s_x and vfmv_s_f
intrinsics will be tail agnostic and mask undisturbed.

Upon change of prototype, vmv_s_x and vfmv_s_f is no longer able to
have an overloading version for its non-policy and tail agnostic
intrinsics.

This is the 6th commit of a patch-set that aims to remove the
IsPrototypeDefaultTU special case for the rvv-intrinsics.

Please refer to the cover letter in the 1st commit (D140895) for an
overview.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmv.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmv.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmv.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 630f32411b69a..6c6515b2f245c 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -2190,12 +2190,12 @@ let HasMasked = false, MaskedPolicyScheme = NonePolicy 
in {
 defm vmv_x : RVVOp0BuiltinSet<"vmv_x_s", "csil",
[["s", "ve", "ev"],
 ["s", "UvUe", "UeUv"]]>;
-  let OverloadedName = "vmv_s", IsPrototypeDefaultTU = true,
+  let OverloadedName = "vmv_s", IsPrototypeDefaultTU = false,
   UnMaskedPolicyScheme = HasPassthruOperand,
   SupportOverloading = false in
 defm vmv_s : RVVOutBuiltinSet<"vmv_s_x", "csil",
-   [["x", "v", "vve"],
-["x", "Uv", "UvUvUe"]]>;
+   [["x", "v", "ve"],
+["x", "Uv", "UvUe"]]>;
 }
 
 // 17.2. Floating-Point Scalar Move Instructions
@@ -2203,12 +2203,12 @@ let HasMasked = false, MaskedPolicyScheme = NonePolicy 
in {
   let HasVL = false, OverloadedName = "vfmv_f" in
 defm vfmv_f : RVVOp0BuiltinSet<"vfmv_f_s", "xfd",
  [["s", "ve", "ev"]]>;
-  let OverloadedName = "vfmv_s", IsPrototypeDefaultTU = true,
+  let OverloadedName = "vfmv_s", IsPrototypeDefaultTU = false,
   UnMaskedPolicyScheme = HasPassthruOperand,
   SupportOverloading = false in
 defm vfmv_s : RVVOutBuiltinSet<"vfmv_s_f", "xfd",
- [["f", "v", "vve"],
-  ["x", "Uv", "UvUvUe"]]>;
+ [["f", "v", "ve"],
+  ["x", "Uv", "UvUe"]]>;
 }
 
 // 17.3. Vector Slide Instructions

diff  --git 
a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmv.c
 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmv.c
index b60de7ad5451f..b405a2526dade 100644
--- 
a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmv.c
+++ 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmv.c
@@ -153,11 +153,11 @@ _Float16 test_vfmv_f_s_f16mf4_f16(vfloat16mf4_t src) {
 
 // CHECK-RV64-LABEL: @test_vfmv_s_f_f16mf4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfmv.s.f.nxv1f16.i64( [[DEST:%.*]], half 
[[SRC:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfmv.s.f.nxv1f16.i64( poison, half [[SRC:%.*]], 
i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf4_t test_vfmv_s_f_f16mf4(vfloat16mf4_t dest, _Float16 src, size_t 
vl) {
-  return vfmv_s_f_f16mf4(dest, src, vl);
+vfloat16mf4_t test_vfmv_s_f_f16mf4(_Float16 src, size_t vl) {
+  return vfmv_s_f_f16mf4(src, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vfmv_f_s_f16mf2_f16(
@@ -171,11 +171,11 @@ _Float16 test_vfmv_f_s_f16mf2_f16(vfloat16mf2_t src) {
 
 // CHECK-RV64-LABEL: @test_vfmv_s_f_f16mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfmv.s.f.nxv2f16.i64( [[DEST:%.*]], half 
[[SRC:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfmv.s.f.nxv2f16.i64( poison, half [[SRC:%.*]], 
i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16

[PATCH] D140941: [4/7][Clang][RISCV] Remove default tail-undisturbed for multiply-add intrinsics

2023-01-23 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb106cb4a0060: [4/7][Clang][RISCV] Remove default 
tail-undisturbed for multiply-add intrinsics (authored by eopXD).
Herald added a subscriber: luke.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140941

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccsu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccus.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccsu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccus.c

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


[PATCH] D140942: [5/7][Clang][RISCV] Remove default tail-undisturbed for vcompress intrinsics

2023-01-23 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG380129657fe3: [5/7][Clang][RISCV] Remove default 
tail-undisturbed for vcompress intrinsics (authored by eopXD).
Herald added a subscriber: luke.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140942

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
@@ -9,532 +9,532 @@
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16mf4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv1f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf4_t test_vcompress_vm_f16mf4(vfloat16mf4_t dest, vfloat16mf4_t src, vbool64_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16mf4_t test_vcompress_vm_f16mf4(vfloat16mf4_t src, vbool64_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv2f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf2_t test_vcompress_vm_f16mf2(vfloat16mf2_t dest, vfloat16mf2_t src, vbool32_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16mf2_t test_vcompress_vm_f16mf2(vfloat16mf2_t src, vbool32_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv4f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m1_t test_vcompress_vm_f16m1(vfloat16m1_t dest, vfloat16m1_t src, vbool16_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16m1_t test_vcompress_vm_f16m1(vfloat16m1_t src, vbool16_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv8f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m2_t test_vcompress_vm_f16m2(vfloat16m2_t dest, vfloat16m2_t src, vbool8_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16m2_t test_vcompress_vm_f16m2(vfloat16m2_t src, vbool8_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv16f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m4_t test_vcompress_vm_f16m4(vfloat16m4_t dest, vfloat16m4_t src, vbool4_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16m4_t test_vcompress_vm_f16m4(vfloat16m4_t src, vbool4_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m8(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv32f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv32f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m8_t test_vcompress_vm_f16m8(vfloat16m8_t dest, vfloat16m8_t src, vbool2_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16m8_t test_vcompress_vm_f16m8(vfloat16m8_t src, vbool2_t mask, size_t vl) {
+  re

[clang] 3801296 - [5/7][Clang][RISCV] Remove default tail-undisturbed for vcompress intrinsics

2023-01-23 Thread via cfe-commits

Author: eopXD
Date: 2023-01-23T23:50:43-08:00
New Revision: 380129657fe3d594e966a8d7ff510ed6afb3e177

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

LOG: [5/7][Clang][RISCV] Remove default tail-undisturbed for vcompress 
intrinsics

The destination parameter is removed for non-policy unmasked intrinsics.

The default policy for non-policy (implicit) vcompress intrinsics will
be tail agnostic and mask undisturbed.

This is the 5th commit of a patch-set that aims to remove the
IsPrototypeDefaultTU special case for the rvv-intrinsics.

Please refer to the cover letter in the 1st commit (D140895) for an
overview.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 4e36f213677a3..630f32411b69a 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -2244,7 +2244,7 @@ defm vrgatherei16 : RVVOutBuiltinSet<"vrgatherei16_vv", 
"csil",
 }
 
 // 17.5. Vector Compress Instruction
-let IsPrototypeDefaultTU = true,
+let IsPrototypeDefaultTU = false,
 HasMasked = false,
 UnMaskedPolicyScheme = HasPassthruOperand,
 MaskedPolicyScheme = NonePolicy,
@@ -2256,10 +2256,10 @@ let IsPrototypeDefaultTU = true,
 }] in {
   // signed and floating type
   defm vcompress : RVVOutBuiltinSet<"vcompress", "csilxfd",
-[["vm", "v", "vvvm"]]>;
+[["vm", "v", "vvm"]]>;
   // unsigned type
   defm vcompress : RVVOutBuiltinSet<"vcompress", "csil",
-[["vm", "Uv", "UvUvUvm"]]>;
+[["vm", "Uv", "UvUvm"]]>;
 }
 
 // Miscellaneous

diff  --git 
a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c
 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c
index f44a36897889a..8c53b7e94687f 100644
--- 
a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c
+++ 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c
@@ -9,532 +9,532 @@
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16mf4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv1f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf4_t test_vcompress_vm_f16mf4(vfloat16mf4_t dest, vfloat16mf4_t src, 
vbool64_t mask, size_t vl) {
-  return vcompress_vm_f16mf4(dest, src, mask, vl);
+vfloat16mf4_t test_vcompress_vm_f16mf4(vfloat16mf4_t src, vbool64_t mask, 
size_t vl) {
+  return vcompress_vm_f16mf4(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv2f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf2_t test_vcompress_vm_f16mf2(vfloat16mf2_t dest, vfloat16mf2_t src, 
vbool32_t mask, size_t vl) {
-  return vcompress_vm_f16mf2(dest, src, mask, vl);
+vfloat16mf2_t test_vcompress_vm_f16mf2(vfloat16mf2_t src, vbool32_t mask, 
size_t vl) {
+  return vcompress_vm_f16mf2(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv4f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m1_t test_vcompress_vm_f16m1(vfloat16m1_t dest, vfloat16m1_t src, 
vbool16_t mask, size_t vl) {
-  return vcompress_vm_f16m1(dest, src, mask, vl);
+vfloat16m1_t test_vcompress_vm_f16m1(vfloat16m1_t src, vbool16_t mask, size_t 
vl) {
+  return vcompress_vm_f16m1(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK

[PATCH] D140936: [2/7][Clang][RISCV] Remove default tail-undisturbed for vslideup intrinsics

2023-01-23 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92717c2ca8c5: [2/7][Clang][RISCV] Remove default 
tail-undisturbed for vslideup intrinsics (authored by eopXD).
Herald added a subscriber: luke.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140936

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vslideup.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c
@@ -9,7 +9,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16mf4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16mf4_t test_vslideup_vx_f16mf4(vfloat16mf4_t dest, vfloat16mf4_t src, size_t offset, size_t vl) {
@@ -18,7 +18,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16mf2_t test_vslideup_vx_f16mf2(vfloat16mf2_t dest, vfloat16mf2_t src, size_t offset, size_t vl) {
@@ -27,7 +27,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m1_t test_vslideup_vx_f16m1(vfloat16m1_t dest, vfloat16m1_t src, size_t offset, size_t vl) {
@@ -36,7 +36,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m2_t test_vslideup_vx_f16m2(vfloat16m2_t dest, vfloat16m2_t src, size_t offset, size_t vl) {
@@ -45,7 +45,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m4_t test_vslideup_vx_f16m4(vfloat16m4_t dest, vfloat16m4_t src, size_t offset, size_t vl) {
@@ -54,7 +54,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m8(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv32f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv32f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m8_t test_vslideup_vx_f16m8(vfloat16m8_t dest, vfloat16m8_t src, size_t offset, size_t vl) {
@@ -63,7 +63,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f32mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv1f32.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv1f32.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat32mf2_t test_vslideup_vx_f32mf2(vfloat32mf2_t dest, vfloat32mf2_t src, size_t offset, size_t vl) {
@@ -72,7 +72,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f32m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv2f32.i64( [[DEST:%.*]]

[clang] 92717c2 - [2/7][Clang][RISCV] Remove default tail-undisturbed for vslideup intrinsics

2023-01-23 Thread via cfe-commits

Author: eopXD
Date: 2023-01-23T23:34:57-08:00
New Revision: 92717c2ca8c53e51e99fd0a4adea8b56008bab53

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

LOG: [2/7][Clang][RISCV] Remove default tail-undisturbed for vslideup intrinsics

The destination parameter is still needed as elements of
0 <  i < max(vstart, OFFSET) in vd remains unchanged.

The default policy for non-policy (implicit) vslideup intrinsics
will be tail agnostic and mask undisturbed.

This is the 2nd commit of a patch-set that aims to remove the
IsPrototypeDefaultTU special case for the rvv-intrinsics.

Please refer to the cover letter in the 1st commit (D140895) for an overview.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vslideup.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 3bd463324db6b..623cace677c02 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -457,10 +457,21 @@ class RVVMaskOp0Builtin : 
RVVOp0Builtin<"m", prototype, "c"> {
   let HasMaskedOffOperand = false;
 }
 
+let UnMaskedPolicyScheme = HasPolicyOperand,
+HasMaskedOffOperand = false,
+IsPrototypeDefaultTU = false in {
+  multiclass RVVSlideUpBuiltinSet {
+defm "" : RVVOutBuiltinSet;
+defm "" : RVVOutBuiltinSet;
+  }
+}
+
 let UnMaskedPolicyScheme = HasPolicyOperand,
 HasMaskedOffOperand = false,
 IsPrototypeDefaultTU = true in {
-  multiclass RVVSlideBuiltinSet {
+  multiclass RVVSlideDownBuiltinSet {
 defm "" : RVVOutBuiltinSet;
 defm "" : RVVOutBuiltinSet 
@llvm.riscv.vslideup.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16mf4_t test_vslideup_vx_f16mf4(vfloat16mf4_t dest, vfloat16mf4_t src, 
size_t offset, size_t vl) {
@@ -18,7 +18,7 @@ vfloat16mf4_t test_vslideup_vx_f16mf4(vfloat16mf4_t dest, 
vfloat16mf4_t src, siz
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16mf2_t test_vslideup_vx_f16mf2(vfloat16mf2_t dest, vfloat16mf2_t src, 
size_t offset, size_t vl) {
@@ -27,7 +27,7 @@ vfloat16mf2_t test_vslideup_vx_f16mf2(vfloat16mf2_t dest, 
vfloat16mf2_t src, siz
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m1_t test_vslideup_vx_f16m1(vfloat16m1_t dest, vfloat16m1_t src, 
size_t offset, size_t vl) {
@@ -36,7 +36,7 @@ vfloat16m1_t test_vslideup_vx_f16m1(vfloat16m1_t dest, 
vfloat16m1_t src, size_t
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m2_t test_vslideup_vx_f16m2(vfloat16m2_t dest, vfloat16m2_t src, 
size_t offset, size_t vl) {
@@ -45,7 +45,7 @@ vfloat16m2_t test_vslideup_vx_f16m2(vfloat16m2_t dest, 
vfloat16m2_t src, size_t
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vslideup.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m4_t test_vslideup_vx_f16m4(vfloat16m4_t dest, vfloat16m4_t src, 
size_t offset, size_t v

[PATCH] D141754: [5/15][Clang][RISCV][NFC] Remove extra attribute Policy::IntrinsicWithoutMU by reusing HasTailPolicy and HasMaskPolicy

2023-01-23 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/D141754/new/

https://reviews.llvm.org/D141754

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


[PATCH] D140895: [1/7][Clang][RISCV] Remove default tail-undisturbed for vector reduction intrinsics

2023-01-23 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG224d29e6f543: [1/7][Clang][RISCV] Remove default 
tail-undisturbed for vector reduction… (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140895

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredand.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmaxu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredminu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredxor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwredsumu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredand.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmaxu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredminu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredxor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwredsumu.c

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


[PATCH] D140895: [1/7][Clang][RISCV] Remove default tail-undisturbed for vector reduction intrinsics

2023-01-23 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 491609.
eopXD added a comment.
Herald added a subscriber: luke.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140895

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredand.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmaxu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredminu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredxor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwredsumu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredand.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmaxu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredminu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredxor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwredsumu.c

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


[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-01-23 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 491608.
pmatos added a comment.

Finish fixing tests after dianostic message changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/builtins-table.c
  clang/test/CodeGen/WebAssembly/table.c
  clang/test/Sema/builtins-wasm.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/test/SemaCXX/wasm-refs.cpp
  llvm/include/llvm/CodeGen/WasmAddressSpaces.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
@@ -62,8 +62,9 @@
   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
 PtrToIntInst *PTI = dyn_cast(&*I);
 IntToPtrInst *ITP = dyn_cast(&*I);
-if (!(PTI && WebAssembly::isRefType(PTI->getPointerOperand()->getType())) &&
-!(ITP && WebAssembly::isRefType(ITP->getDestTy(
+if (!(PTI &&
+  PTI->getPointerOperand()->getType()->isWebAssemblyReferenceType()) &&
+!(ITP && ITP->getDestTy()->isWebAssemblyReferenceType()))
   continue;
 
 UndefValue *U = UndefValue::get(I->getType());
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1202,7 +1202,7 @@
   // Lastly, if this is a call to a funcref we need to add an instruction
   // table.set to the chain and transform the call.
   if (CLI.CB &&
-  WebAssembly::isFuncrefType(CLI.CB->getCalledOperand()->getType())) {
+  CLI.CB->getCalledOperand()->getType()->isWebAssemblyFuncrefType()) {
 // In the absence of function references proposal where a funcref call is
 // lowered to call_ref, using reference types we generate a table.set to set
 // the funcref to a special table used solely for this purpose, followed by
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
@@ -45,43 +45,6 @@
   Multivalue = 0x,
 };
 
-enum WasmAddressSpace : unsigned {
-  // Default address space, for pointers to linear memory (stack, heap, data).
-  WASM_ADDRESS_SPACE_DEFAULT = 0,
-  // A non-integral address space for pointers to named objects outside of
-  // linear memory: WebAssembly globals or WebAssembly locals.  Loads and stores
-  // to these pointers are lowered to global.get / global.set or local.get /
-  // local.set, as appropriate.
-  WASM_ADDRESS_SPACE_VAR = 1,
-  // A non-integral address space for externref values
-  WASM_ADDRESS_SPACE_EXTERNREF = 10,
-  // A non-integral address space for funcref values
-  WASM_ADDRESS_SPACE_FUNCREF = 20,
-};
-
-inline bool isDefaultAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_DEFAULT;
-}
-inline bool isWasmVarAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_VAR;
-}
-inline bool isValidAddressSpace(unsigned AS) {
-  return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);
-}
-inline bool isFuncrefType(const Type *Ty) {
-  return isa(Ty) &&
- Ty->getPointerAddressSpace() ==
- WasmAddressSpace::WASM_ADDRESS_SPACE_FUNCREF;
-}
-inline bool isExternrefType(const Type *Ty) {
-  return isa(Ty) &&
- Ty->getPointerAddressSpace() ==
- WasmAddressSpace::WASM_ADDRESS_SPACE_EXTERNREF;
-}
-i

[PATCH] D140250: Define NULL in its own header

2023-01-23 Thread Ian Anderson via Phabricator via cfe-commits
iana added inline comments.



Comment at: 
llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll:37
 !7 = !DIFile(filename: "clang/12.0.0/include/__stddef_max_align_t.h", 
directory: "/")
-!8 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 
256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
-!9 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
-!10 = !{i32 7, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{!"clang version 12.0.0"}
-!14 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, 
file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !20)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null, !17}
-!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: 
!18, line: 235, baseType: !19)
-!18 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", 
directory: "")
-!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
-!20 = !{!21}
-!21 = !DILocalVariable(arg: 1, scope: !14, file: !1, line: 20, type: !17)
-!22 = distinct !DIAssignID()
-!23 = !DILocation(line: 0, scope: !14)
-!28 = distinct !DIAssignID()
-!29 = !DILocation(line: 20, column: 27, scope: !14)
+!8 = !DIFile(filename: "clang/12.0.0/include/__stddef_null.h", directory: "/")
+!9 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 
256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")

Adding this line is the only reason I changed this file. I'm not familiar at 
all with how these tests work, so I don't really know if it's necessary. The 
test passes with and without these changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140250

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


[PATCH] D140250: Define NULL in its own header

2023-01-23 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 491607.
iana added a comment.

Fix the debuginfo-generic-assignment-tracking-sroa test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140250

Files:
  clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/Basic/Module.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__stddef_null.h
  clang/lib/Headers/module.modulemap
  clang/lib/Headers/stddef.h
  clang/lib/Lex/ModuleMap.cpp
  compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
  llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -88,6 +88,7 @@
 "__clang_hip_runtime_wrapper.h",
 "__clang_hip_stdlib.h",
 "__stddef_max_align_t.h",
+"__stddef_null.h",
 "__wmmintrin_aes.h",
 "__wmmintrin_pclmul.h",
 "adxintrin.h",
Index: llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
===
--- llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
+++ llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
@@ -10,46 +10,47 @@
 ; CHECK: @llvm.dbg.assign(metadata ptr %0,{{.+}}, metadata !DIExpression(),{{.+}}, metadata ptr undef, {{.+}})
 ;; There should be no new fragment and the value component should remain as %0.
 
-define dso_local void @_Z3funDn(ptr %0) #0 !dbg !14 {
+define dso_local void @_Z3funDn(ptr %0) #0 !dbg !15 {
 entry:
-  %.addr = alloca i8*, align 8, !DIAssignID !22
-  call void @llvm.dbg.assign(metadata i1 undef, metadata !21, metadata !DIExpression(), metadata !22, metadata ptr %.addr, metadata !DIExpression()), !dbg !23
-  store ptr %0, ptr %.addr, align 8, !DIAssignID !28
-  call void @llvm.dbg.assign(metadata ptr %0, metadata !21, metadata !DIExpression(), metadata !28, metadata ptr %.addr, metadata !DIExpression()), !dbg !23
-  ret void, !dbg !29
+  %.addr = alloca i8*, align 8, !DIAssignID !23
+  call void @llvm.dbg.assign(metadata i1 undef, metadata !22, metadata !DIExpression(), metadata !23, metadata ptr %.addr, metadata !DIExpression()), !dbg !24
+  store ptr %0, ptr %.addr, align 8, !DIAssignID !29
+  call void @llvm.dbg.assign(metadata ptr %0, metadata !22, metadata !DIExpression(), metadata !29, metadata ptr %.addr, metadata !DIExpression()), !dbg !24
+  ret void, !dbg !30
 }
 
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #1
 
 !llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!10, !11, !12, !1000}
-!llvm.ident = !{!13}
+!llvm.module.flags = !{!11, !12, !13, !1000}
+!llvm.ident = !{!14}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, imports: !3, splitDebugInlining: false, nameTableKind: None)
 !1 = !DIFile(filename: "test.cpp", directory: "/")
 !2 = !{}
 !3 = !{!4}
-!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !6, file: !9, line: 56)
+!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !6, file: !10, line: 56)
 !5 = !DINamespace(name: "std", scope: null)
-!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "max_align_t", file: !7, line: 24, baseType: !8)
+!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "max_align_t", file: !7, line: 24, baseType: !9)
 !7 = !DIFile(filename: "clang/12.0.0/include/__stddef_max_align_t.h", directory: "/")
-!8 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
-!9 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
-!10 = !{i32 7, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{!"clang version 12.0.0"}
-!14 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null, !17}
-!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: !18, line: 235, baseType: !19)
-!18 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", directory: "")
-!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
-!20 = !{!21}
-!21 = !DILocalVariable(arg: 1, scope:

[PATCH] D142338: [Clang][NFC] Remove a redundancy check in Sema::adjustMemberFunctionCC

2023-01-23 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 rG40003af98456: [Clang][NFC] Remove a redundancy check in 
Sema::adjustMemberFunctionCC (authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142338

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7963,7 +7963,7 @@
 CallingConv DefaultCC =
 Context.getDefaultCallingConvention(IsVariadic, IsStatic);
 
-if (CurCC != DefaultCC || DefaultCC == ToCC)
+if (CurCC != DefaultCC)
   return;
 
 if (hasExplicitCallingConv(T))


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7963,7 +7963,7 @@
 CallingConv DefaultCC =
 Context.getDefaultCallingConvention(IsVariadic, IsStatic);
 
-if (CurCC != DefaultCC || DefaultCC == ToCC)
+if (CurCC != DefaultCC)
   return;
 
 if (hasExplicitCallingConv(T))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 40003af - [Clang][NFC] Remove a redundancy check in Sema::adjustMemberFunctionCC

2023-01-23 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-01-24T11:56:06+05:30
New Revision: 40003af98456607f9b6bd1910424c5243eeb5d01

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

LOG: [Clang][NFC] Remove a redundancy check in Sema::adjustMemberFunctionCC

If the current calling convection CurCC is not equal to Target calling
convection ToCC and current calling convention (CurCC) is equal to the
default calling convention (DefaultCC), that means DefaultCC can not be
equal to ToCC so the right part of the expression DefaultCC == ToCC is
not needed.

revelant code -
  if (CurCC == ToCC)
return;
  if (CurCC != DefaultCC || DefaultCC == ToCC)
return;

Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N41.

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

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 16986f6f0d0e5..89d819a77dcbb 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7963,7 +7963,7 @@ void Sema::adjustMemberFunctionCC(QualType &T, bool 
IsStatic, bool IsCtorOrDtor,
 CallingConv DefaultCC =
 Context.getDefaultCallingConvention(IsVariadic, IsStatic);
 
-if (CurCC != DefaultCC || DefaultCC == ToCC)
+if (CurCC != DefaultCC)
   return;
 
 if (hasExplicitCallingConv(T))



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


[PATCH] D142358: Opting out of Clang 16 ABI Changes for AIX and z/OS

2023-01-23 Thread Hubert Tong 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 rG0f5099cd9422: Opting out of Clang 16 ABI Changes for AIX and 
z/OS (authored by nicolerabjohn, committed by hubert.reinterpretcast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142358

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/SemaCXX/class-layout.cpp

Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -7,8 +7,17 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)
+
 #define SA(n, p) int a##n[(p) ? 1 : -1]
 
 struct A {
@@ -611,6 +620,8 @@
 #pragma pack(pop)
 }
 
+#endif // !defined(__MVS__) && !defined(__AIX__)
+
 namespace non_pod {
 struct t1 {
 protected:
@@ -670,11 +681,15 @@
 struct t2 {
   t1 v1;
 } __attribute__((packed));
+#if (defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15) || !defined(__MVS__)
 _Static_assert(_Alignof(t2) == 1, "");
+#else
+_Static_assert(_Alignof(t2) == 4, "");
+#endif
 struct t3 : t1 {
   char c;
 };
-#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15
+#if (defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15) || defined(__MVS__)
 _Static_assert(sizeof(t3) == 8, "");
 #else
 _Static_assert(sizeof(t3) == 12, "");
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,7 +1968,8 @@
  FieldClass->hasAttr() ||
  Context.getLangOpts().getClangABICompat() <=
  LangOptions::ClangABI::Ver15 ||
- Target.isPS() || Target.isOSDarwin())) ||
+ Target.isPS() || Target.isOSDarwin() ||
+ Target.isOSAIX())) ||
  D->hasAttr();
 
   // When used as part of a typedef, or together with a 'packed' attribute, the
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -838,13 +838,14 @@
 
 - GCC doesn't pack non-POD members in packed structs unless the packed
   attribute is also specified on the member. Clang historically did perform
-  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  such packing. Clang now matches the gcc behavior
+  (except on Darwin, PS4 and AIX).
   You can switch back to the old ABI behavior with the flag:
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such

[clang] 0f5099c - Opting out of Clang 16 ABI Changes for AIX and z/OS

2023-01-23 Thread Hubert Tong via cfe-commits

Author: Nicole Rabjohn
Date: 2023-01-24T01:14:05-05:00
New Revision: 0f5099cd94226479fe30b4fc2d6a9743ebe2b12b

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

LOG: Opting out of Clang 16 ABI Changes for AIX and z/OS

There is already a GCC compatibility gap on AIX, & GCC compatibility is
not a concern on z/OS. GCC compatibility is not sufficient motivation
for breaking ABI on AIX and z/OS. This opts out of changes introduced in
https://reviews.llvm.org/D119051. For AIX only, also opt out of D117616
(which z/OS had picked up at the time ABI stabilization occurred).

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/test/SemaCXX/class-layout.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f7a68a64df325..7d356e53547bf 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -838,13 +838,14 @@ ABI Changes in Clang
 
 - GCC doesn't pack non-POD members in packed structs unless the packed
   attribute is also specified on the member. Clang historically did perform
-  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  such packing. Clang now matches the gcc behavior
+  (except on Darwin, PS4 and AIX).
   You can switch back to the old ABI behavior with the flag:
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such types as non-POD (for the purposes of Itanium ABI). Clang now
-  matches the gcc behavior (except on Darwin and PS4). You can switch back to
-  the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
+  matches the gcc behavior (except on Darwin, PS4, AIX and z/OS). You can 
switch
+  back to the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
 
 OpenMP Support in Clang
 ---

diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index da27f73ea94e2..2f546398338c4 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,7 +1968,8 @@ void ItaniumRecordLayoutBuilder::LayoutField(const 
FieldDecl *D,
  FieldClass->hasAttr() ||
  Context.getLangOpts().getClangABICompat() <=
  LangOptions::ClangABI::Ver15 ||
- Target.isPS() || Target.isOSDarwin())) ||
+ Target.isPS() || Target.isOSDarwin() ||
+ Target.isOSAIX())) ||
  D->hasAttr();
 
   // When used as part of a typedef, or together with a 'packed' attribute, the

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index a1b1f917931b2..fd372cb12df2b 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@ class AIXTargetInfo : public OSTargetInfo {
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@ class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public 
OSTargetInfo {
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,

diff  --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 3d710dc5a5200..3ccd0ad25d7e7 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -7,8 +7,17 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_

[PATCH] D140250: Define NULL in its own header

2023-01-23 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 491604.
iana added a comment.

Rebase, update diagnostic to include the full module name instead of just the 
top level.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140250

Files:
  clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/Basic/Module.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__stddef_null.h
  clang/lib/Headers/module.modulemap
  clang/lib/Headers/stddef.h
  clang/lib/Lex/ModuleMap.cpp
  compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
  llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -88,6 +88,7 @@
 "__clang_hip_runtime_wrapper.h",
 "__clang_hip_stdlib.h",
 "__stddef_max_align_t.h",
+"__stddef_null.h",
 "__wmmintrin_aes.h",
 "__wmmintrin_pclmul.h",
 "adxintrin.h",
Index: llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
===
--- llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
+++ llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
@@ -34,22 +34,23 @@
 !5 = !DINamespace(name: "std", scope: null)
 !6 = !DIDerivedType(tag: DW_TAG_typedef, name: "max_align_t", file: !7, line: 24, baseType: !8)
 !7 = !DIFile(filename: "clang/12.0.0/include/__stddef_max_align_t.h", directory: "/")
-!8 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
-!9 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
-!10 = !{i32 7, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{!"clang version 12.0.0"}
-!14 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null, !17}
-!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: !18, line: 235, baseType: !19)
-!18 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", directory: "")
-!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
-!20 = !{!21}
-!21 = !DILocalVariable(arg: 1, scope: !14, file: !1, line: 20, type: !17)
-!22 = distinct !DIAssignID()
-!23 = !DILocation(line: 0, scope: !14)
-!28 = distinct !DIAssignID()
-!29 = !DILocation(line: 20, column: 27, scope: !14)
-!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
+!8 = !DIFile(filename: "clang/12.0.0/include/__stddef_null.h", directory: "/")
+!9 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
+!10 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
+!11 = !{i32 7, !"Dwarf Version", i32 4}
+!12 = !{i32 2, !"Debug Info Version", i32 3}
+!13 = !{i32 1, !"wchar_size", i32 4}
+!14 = !{!"clang version 12.0.0"}
+!15 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20)
+!16 = !DISubroutineType(types: !16)
+!17 = !{null, !17}
+!18 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: !18, line: 235, baseType: !19)
+!19 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", directory: "")
+!20 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
+!21 = !{!21}
+!22 = !DILocalVariable(arg: 1, scope: !14, file: !1, line: 20, type: !17)
+!23 = distinct !DIAssignID()
+!24 = !DILocation(line: 0, scope: !14)
+!29 = distinct !DIAssignID()
+!30 = !DILocation(line: 20, column: 27, scope: !14)
+!1001 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
Index: compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
===
--- compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
+++ compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
@@ -20,6 +20,7 @@
 #include 
 #include 
 // IWYU pragma: no_include <__stddef_max_align_t.h>
+// IWYU pragma: no_include <__stddef_null.h>
 
 namespace gwp_asan {
 // This class is the primary implementation of the allocator portion of GWP-
Index: clang/lib/Lex/ModuleMap.cpp

[PATCH] D142430: [Clang] Treat `std::forward_like` as builtin

2023-01-23 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: rsmith, aaron.ballman.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added a reviewer: NoQ.
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This diff extends D123345  by adding support 
for std::forward_like.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142430

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/builtin-std-move.cpp
  clang/test/SemaCXX/attr-lifetimebound.cpp
  clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
  clang/test/SemaCXX/builtin-std-move.cpp

Index: clang/test/SemaCXX/builtin-std-move.cpp
===
--- clang/test/SemaCXX/builtin-std-move.cpp
+++ clang/test/SemaCXX/builtin-std-move.cpp
@@ -43,6 +43,33 @@
 return static_cast(x);
   }
 
+  template  struct is_const { static constexpr bool value = false; };
+  template  struct is_const { static constexpr bool value = true; };
+
+  template  struct conditional { using type = T; };
+  template  struct conditional { using type = F; };
+
+  template 
+  using CopyConst = typename conditional<
+  is_const>::value,
+  const T, T>::type;
+
+  template 
+  using OverrideRef = typename conditional<
+  is_lvalue_reference::value,
+  typename remove_reference::type &,
+  typename remove_reference::type &&>::type;
+
+  template 
+  using ForwardLikeRetType = OverrideRef>;
+
+  template 
+  CONSTEXPR auto forward_like(T &&t) -> ForwardLikeRetType {
+using TT = typename remove_reference::type;
+static_assert(TT::moveable, "instantiated as_const"); // expected-error {{no member named 'moveable' in 'B'}}
+return static_cast>(t);
+  }
+
   template CONSTEXPR const T &as_const(T &x) {
 static_assert(T::moveable, "instantiated as_const"); // expected-error {{no member named 'moveable' in 'B'}}
 return x;
@@ -92,14 +119,15 @@
 B &&(*pMove)(B&) = std::move; // #1 expected-note {{instantiation of}}
 B &&(*pMoveIfNoexcept)(B&) = &std::move_if_noexcept; // #2 expected-note {{instantiation of}}
 B &&(*pForward)(B&) = &std::forward; // #3 expected-note {{instantiation of}}
-const B &(*pAsConst)(B&) = &std::as_const; // #4 expected-note {{instantiation of}}
-B *(*pAddressof)(B&) = &std::addressof; // #5 expected-note {{instantiation of}}
-B *(*pUnderUnderAddressof)(B&) = &std::__addressof; // #6 expected-note {{instantiation of}}
+B &&(*pForwardLike)(B&) = &std::forward_like; // #4 expected-note {{instantiation of}}
+const B &(*pAsConst)(B&) = &std::as_const; // #5 expected-note {{instantiation of}}
+B *(*pAddressof)(B&) = &std::addressof; // #6 expected-note {{instantiation of}}
+B *(*pUnderUnderAddressof)(B&) = &std::__addressof; // #7 expected-note {{instantiation of}}
 int (*pUnrelatedMove)(B, B) = std::move;
 
 struct C {};
-C &&(&rMove)(C&) = std::move; // #7 expected-note {{instantiation of}}
-C &&(&rForward)(C&) = std::forward; // #8 expected-note {{instantiation of}}
+C &&(&rMove)(C&) = std::move; // #8 expected-note {{instantiation of}}
+C &&(&rForward)(C&) = std::forward; // #9 expected-note {{instantiation of}}
 int (&rUnrelatedMove)(B, B) = std::move;
 
 #if __cplusplus <= 201703L
@@ -111,6 +139,7 @@
 // expected-warning@#6 {{non-addressable}}
 // expected-warning@#7 {{non-addressable}}
 // expected-warning@#8 {{non-addressable}}
+// expected-warning@#9 {{non-addressable}}
 #else
 // expected-error@#1 {{non-addressable}}
 // expected-error@#2 {{non-addressable}}
@@ -120,6 +149,7 @@
 // expected-error@#6 {{non-addressable}}
 // expected-error@#7 {{non-addressable}}
 // expected-error@#8 {{non-addressable}}
+// expected-error@#9 {{non-addressable}}
 #endif
 
 void attribute_const() {
@@ -127,6 +157,7 @@
   std::move(n); // expected-warning {{ignoring return value}}
   std::move_if_noexcept(n); // expected-warning {{ignoring return value}}
   std::forward(n); // expected-warning {{ignoring return value}}
+  std::forward_like(n); // expected-warning {{ignoring return value}}
   std::addressof(n); // expected-warning {{ignoring return value}}
   std::__addressof(n); // expected-warning {{ignoring return value}}
   std::as_const(n); // expected-warning {{ignoring return value}}
Index: clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
===
--- clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
+++ clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++20 -verify %s -DBUILTIN=builtin
 //

[PATCH] D138275: [clang][Interp] Avoid leaking init maps of local primitive arrays

2023-01-23 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

It's interrupted whenever one of the `emitXXX()` functions returns `false`, or 
when one of the function in `Interp.h` returns `false`, e.g. when trying to 
read from a null pointer.


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

https://reviews.llvm.org/D138275

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


[PATCH] D140845: [clang][Interp] Fix left-/right-shifting more than sizeof(unsigned)

2023-01-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/AST/Interp/shifts.cpp:149
+  constexpr signed int R = 62;
+  constexpr decltype(L) M = L << R;
 };

Can we add a test for left shift as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140845

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


[PATCH] D138275: [clang][Interp] Avoid leaking init maps of local primitive arrays

2023-01-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

This looks good to me but I am wondering how "interpretation is interrupted" 
can happen.


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

https://reviews.llvm.org/D138275

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Since this is a change only for AIX and z/OS, and considering that this is a 
patch to prevent ABI changes compared to the current ABI baselines for those 
platforms, I will land this ahead of the LLVM 16 branching.


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

https://reviews.llvm.org/D142358

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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-23 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

owenpan wrote:
> rymiel wrote:
> > rymiel wrote:
> > > owenpan wrote:
> > > > We should pass `true` to `peekNextToken()` on Line 3597 here, but 
> > > > removing this entire case would have no effect on the existing unit 
> > > > test (Line 23693 in FormatTest.cpp). @HazardyKnusperkeks any idea?
> > > The peeking is there because of https://reviews.llvm.org/D134325, it has 
> > > no format tests, only an annotator test
> > Also, I don't think that function is involved in concept declarations since 
> > https://reviews.llvm.org/D140339
> So which tests were meant to check the `kw_bool` case here?
Well, originally the one you mentioned on line 23693, but since the code paths 
have been changed, I think it's really only the one added in 
https://reviews.llvm.org/D134325


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

Thanks @nicolerabjohn; this LGTM!




Comment at: clang/test/SemaCXX/class-layout.cpp:685
+#if (defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15) || !defined(__MVS__)
 _Static_assert(_Alignof(t2) == 1, "");
+#else

Just a note: As mentioned above, for some releases of Open XL on z/OS, the 
`-fclang-abi-compat` level that gives this result is less than 15 (but, then 
again, the behaviour expected by this line persisted in vanilla Clang 15). What 
is more important is the default behaviour (confirmed below) anyway.


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

https://reviews.llvm.org/D142358

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


[PATCH] D118493: Set rpath on openmp executables

2023-01-23 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Enabled-by-default `-fopenmp-implicit-rpath` is odd. For other shared objects 
(e.g. `libclang_rt.*.so`) we don't do this.
For libraries in a well-known system directory, we just rely on the default 
`/etc/ld.so.conf*`.
For libraries in other directories or when `--sysroot=` is specified, the user 
is responsible to set up it correctly.
An opt-out behavior causes follow-up workarounds like D142174 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Nicole Rabjohn via Phabricator via cfe-commits
nicolerabjohn marked an inline comment as done.
nicolerabjohn added inline comments.



Comment at: clang/test/SemaCXX/class-layout.cpp:688
 };
 #if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15
 _Static_assert(sizeof(t3) == 8, "");

hubert.reinterpretcast wrote:
> hubert.reinterpretcast wrote:
> > hubert.reinterpretcast wrote:
> > > Because z/OS has some of the Clang 16 changes but not all, I think we 
> > > can't rely on claiming that it uses the Clang 15 ABI for the purposes of 
> > > the testing (and need to make a change here to say that it does follow 
> > > the "Clang 15 ABI" for this aspect).
> > Sorry, my last suggestion for this line should be reverted. z/OS works just 
> > like Linux for this right now: no special code needed here.
> > Sorry, my last suggestion for this line should be reverted. z/OS works just 
> > like Linux for this right now: no special code needed here.
> 
> I was actually confused about being confused before (and now I am just very 
> confused). This is the test corresponding to the changes to 
> `areDefaultedSMFStillPOD`. z/OS does not work just like Linux for this part. 
> Under `__MVS__`, we really should always be returning `8` for the size of 
> `t3`. I am not sure how we ended up with `12` as I was told offline.
> 
I discussed offline with Hubert, and we went through the test cases. My updated 
diff has applied Hubert's original suggestion for this line, as well as a 
similar change for line 684 to update the assertions for the z/OS case. This 
test case now passes all the AIX & z/OS run lines. 


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

https://reviews.llvm.org/D142358

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Nicole Rabjohn via Phabricator via cfe-commits
nicolerabjohn updated this revision to Diff 491595.
nicolerabjohn added a comment.

Update to assertions for z/OS case.


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

https://reviews.llvm.org/D142358

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/SemaCXX/class-layout.cpp

Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -7,8 +7,17 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)
+
 #define SA(n, p) int a##n[(p) ? 1 : -1]
 
 struct A {
@@ -611,6 +620,8 @@
 #pragma pack(pop)
 }
 
+#endif // !defined(__MVS__) && !defined(__AIX__)
+
 namespace non_pod {
 struct t1 {
 protected:
@@ -670,11 +681,15 @@
 struct t2 {
   t1 v1;
 } __attribute__((packed));
+#if (defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15) || !defined(__MVS__)
 _Static_assert(_Alignof(t2) == 1, "");
+#else
+_Static_assert(_Alignof(t2) == 4, "");
+#endif
 struct t3 : t1 {
   char c;
 };
-#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15
+#if (defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15) || defined(__MVS__)
 _Static_assert(sizeof(t3) == 8, "");
 #else
 _Static_assert(sizeof(t3) == 12, "");
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,7 +1968,8 @@
  FieldClass->hasAttr() ||
  Context.getLangOpts().getClangABICompat() <=
  LangOptions::ClangABI::Ver15 ||
- Target.isPS() || Target.isOSDarwin())) ||
+ Target.isPS() || Target.isOSDarwin() ||
+ Target.isOSAIX())) ||
  D->hasAttr();
 
   // When used as part of a typedef, or together with a 'packed' attribute, the
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -814,13 +814,14 @@
 
 - GCC doesn't pack non-POD members in packed structs unless the packed
   attribute is also specified on the member. Clang historically did perform
-  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  such packing. Clang now matches the gcc behavior
+  (except on Darwin, PS4 and AIX).
   You can switch back to the old ABI behavior with the flag:
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such types as non-POD (for the purposes of Itanium ABI). Clang now
-  matches the gcc behavior (except on Darwin and PS4). You can switch back to
-  the old ABI behavior with the flag: ``-fclang-abi-compa

[PATCH] D142014: [clangd] fix wrong CalleeArgInfo in the hover

2023-01-23 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry marked an inline comment as done.
v1nh1shungry added a comment.

Thanks for the review! @tom-anders




Comment at: clang-tools-extra/clangd/Hover.cpp:1035
 } else if (const auto *MTE =
CastNode->ASTNode.get()) {
 } else { // Unknown implicit node, assume type conversion.

v1nh1shungry wrote:
> tom-anders wrote:
> > v1nh1shungry wrote:
> > > tom-anders wrote:
> > > > This branch is now empty, do we still need it? 
> > > I keep this branch because the original implementation doesn't want to 
> > > mark `Converted` in this branch. Yeah I can modify the following `else` 
> > > to `else if (const ...; !MTE)` (or something cleaner), but I think the 
> > > two are the same ugly :(
> > Ah I see, what about just adding `PassType.Converted = false` here (even 
> > though it has no effect, but just to make this more clear)? 
> Then how about just adding some comments? I don't have a strong opinion here 
> though.
Done. Sorry for the confusion here! Hope it is clear now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142014

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


[PATCH] D142014: [clangd] fix wrong CalleeArgInfo in the hover

2023-01-23 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry updated this revision to Diff 491594.
v1nh1shungry added a comment.

land review's suggestions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142014

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -934,6 +934,23 @@
  HI.CalleeArgInfo->Type = "const int &";
  HI.CallPassType = HoverInfo::PassType{PassMode::ConstRef, false};
}},
+  {
+  R"cpp(
+int add(int lhs, int rhs);
+int main() {
+  add(1 [[^+]] 2, 3);
+}
+)cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Kind = index::SymbolKind::Unknown;
+HI.Type = "int";
+HI.Value = "3";
+HI.CalleeArgInfo.emplace();
+HI.CalleeArgInfo->Name = "lhs";
+HI.CalleeArgInfo->Type = "int";
+HI.CallPassType = HoverInfo::PassType{PassMode::Value, false};
+  }},
   {// Extra info for method call.
R"cpp(
   class C {
@@ -1673,8 +1690,8 @@
   }},
   {
   R"cpp(// Function definition via using declaration
-namespace ns { 
-  void foo(); 
+namespace ns {
+  void foo();
 }
 int main() {
   using ns::foo;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -952,6 +952,15 @@
   }
 }
 
+HoverInfo::PassType::PassMode getPassMode(QualType ParmType) {
+  if (ParmType->isReferenceType()) {
+if (ParmType->getPointeeType().isConstQualified())
+  return HoverInfo::PassType::ConstRef;
+return HoverInfo::PassType::Ref;
+  }
+  return HoverInfo::PassType::Value;
+}
+
 // If N is passed as argument to a function, fill HI.CalleeArgInfo with
 // information about that argument.
 void maybeAddCalleeArgInfo(const SelectionTree::Node *N, HoverInfo &HI,
@@ -972,14 +981,18 @@
   if (!FD || FD->isOverloadedOperator() || FD->isVariadic())
 return;
 
+  HoverInfo::PassType PassType;
+
   // Find argument index for N.
   for (unsigned I = 0; I < CE->getNumArgs() && I < FD->getNumParams(); ++I) {
 if (CE->getArg(I) != OuterNode.ASTNode.get())
   continue;
 
 // Extract matching argument from function declaration.
-if (const ParmVarDecl *PVD = FD->getParamDecl(I))
+if (const ParmVarDecl *PVD = FD->getParamDecl(I)) {
   HI.CalleeArgInfo.emplace(toHoverInfoParam(PVD, PP));
+  PassType.PassBy = getPassMode(PVD->getType());
+}
 break;
   }
   if (!HI.CalleeArgInfo)
@@ -988,16 +1001,6 @@
   // If we found a matching argument, also figure out if it's a
   // [const-]reference. For this we need to walk up the AST from the arg itself
   // to CallExpr and check all implicit casts, constructor calls, etc.
-  HoverInfo::PassType PassType;
-  if (const auto *E = N->ASTNode.get()) {
-if (E->getType().isConstQualified())
-  PassType.PassBy = HoverInfo::PassType::ConstRef;
-
-// No implicit node, literal passed by value
-if (isLiteral(E) && N->Parent == OuterNode.Parent)
-  PassType.PassBy = HoverInfo::PassType::Value;
-  }
-
   for (auto *CastNode = N->Parent;
CastNode != OuterNode.Parent && !PassType.Converted;
CastNode = CastNode->Parent) {
@@ -1006,22 +1009,13 @@
   case CK_NoOp:
   case CK_DerivedToBase:
   case CK_UncheckedDerivedToBase:
-// If it was a reference before, it's still a reference.
-if (PassType.PassBy != HoverInfo::PassType::Value)
-  PassType.PassBy = ImplicitCast->getType().isConstQualified()
-? HoverInfo::PassType::ConstRef
-: HoverInfo::PassType::Ref;
-break;
   case CK_LValueToRValue:
   case CK_ArrayToPointerDecay:
   case CK_FunctionToPointerDecay:
   case CK_NullToPointer:
   case CK_NullToMemberPointer:
-// No longer a reference, but we do not show this as type conversion.
-PassType.PassBy = HoverInfo::PassType::Value;
 break;
   default:
-PassType.PassBy = HoverInfo::PassType::Value;
 PassType.Converted = true;
 break;
   }
@@ -1029,16 +1023,24 @@
CastNode->ASTNode.get()) {
   // We want to be smart about copy constructors. They should not show up as
   // type conversion, but instead as passing by value.
-  if (CtorCall->getConstructor()->isCopyConstructor())
+  const CXXConstructorDecl *CD = CtorCall->getConstructor();
+  if (CD->isCopyConstructor()) {

[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-23 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer updated this revision to Diff 491593.
cpsauer added a comment.

Rebased


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

https://reviews.llvm.org/D138546

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -49,7 +49,7 @@
   Cmd.CommandLine = {"clang++", "--", "foo.cc", "bar.cc"};
   Mangler(Cmd, "foo.cc");
   EXPECT_THAT(Cmd.CommandLine,
-  ElementsAre(testPath("fake/clang++"),
+  ElementsAre(testPath("fake/clang++"), "--driver-mode=g++",
   "-resource-dir=" + testPath("fake/resources"),
   "-isysroot", testPath("fake/sysroot"), "--",
   "foo.cc"));
@@ -198,7 +198,8 @@
   }
   // Edits are applied in given order and before other mangling and they always
   // go before filename.
-  EXPECT_THAT(Cmd.CommandLine, ElementsAre(_, "--hello", "--", "FOO.CC"));
+  EXPECT_THAT(Cmd.CommandLine,
+  ElementsAre(_, "--driver-mode=g++", "--hello", "--", "FOO.CC"));
 }
 
 static std::string strip(llvm::StringRef Arg, llvm::StringRef Argv) {
Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -16,6 +16,8 @@
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"-target arm-linux-gnueabi"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--target=arm-linux-gnueabi"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> %t.dir/bin/my_driver.sh
@@ -32,7 +34,7 @@
 
 # Generate a compile_commands.json that will query the mock driver we've
 # created. Which should add a.h and b.h into include search path.
-# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot -target arm-linux-gnueabi --target=arm-linux-gnueabi", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
 # On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
@@ -70,7 +72,7 @@
 {"jsonrpc":"2.0","method":"exit"}
 
 # Generate a different compile_commands.json which does not point to the mock driver
-# RUN: echo '[{"directory": "%/t.dir", "command": "gcc the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "gcc the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot -target arm-linux-gnueabi --target=arm-linux-gnueabi", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # Generate a clangd config file which points to the mock driver instead
 # RUN: echo 'CompileFlags:' > %t.dir/.clangd
Index: clang-tools-extra/clangd/SystemIncludeExtractor.cpp
===
--- clang-tools-extra/clangd/SystemIncludeExtractor.cpp
+++ clang-tools-extra/clangd/SystemIncludeExtractor.cpp
@@ -185,13 +185,18 @@
   const llvm::StringRef FlagsToPreserve[] = {
   "-nostdinc", "--no-standard-includes", "-nostdinc++", "-nobuiltininc"};
   // Preserves these flags and their values, either as separate args or with an
-  // equalsbetween them
+  // equals between them
   const llvm::StringRef ArgsToPreserve[] = {"--sysroot", "-isysroot"};
 
   for (size_t I = 0, E = CommandLine.size(); I < E; ++I) {
 llvm::StringRef Arg = CommandLine[I];
 if (llvm::is_contained(FlagsToPreserve, Arg)) {
   Args.push_back(Arg);
+} else if (Arg.startswith("--target=")) {
+  Args.push_back(Arg);
+} else if (I + 1 < E && Arg.equals("-target")) {
+  Args.push_back(CommandLine[I]);
+  Args.push_back(CommandLine[++I]);
 } else {

[PATCH] D142377: Dead links on https://clang.llvm.org/extra/clang-tidy/ #60023

2023-01-23 Thread pratik sharma via Phabricator via cfe-commits
s-pratik added a comment.

Great ! 
Please Use Name : Pratik Sharma
Email : sharmapratik...@gmail.com


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142377

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


[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-23 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer updated this revision to Diff 491592.

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

https://reviews.llvm.org/D138546

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -49,7 +49,7 @@
   Cmd.CommandLine = {"clang++", "--", "foo.cc", "bar.cc"};
   Mangler(Cmd, "foo.cc");
   EXPECT_THAT(Cmd.CommandLine,
-  ElementsAre(testPath("fake/clang++"),
+  ElementsAre(testPath("fake/clang++"), "--driver-mode=g++",
   "-resource-dir=" + testPath("fake/resources"),
   "-isysroot", testPath("fake/sysroot"), "--",
   "foo.cc"));
@@ -198,7 +198,8 @@
   }
   // Edits are applied in given order and before other mangling and they always
   // go before filename.
-  EXPECT_THAT(Cmd.CommandLine, ElementsAre(_, "--hello", "--", "FOO.CC"));
+  EXPECT_THAT(Cmd.CommandLine,
+  ElementsAre(_, "--driver-mode=g++", "--hello", "--", "FOO.CC"));
 }
 
 static std::string strip(llvm::StringRef Arg, llvm::StringRef Argv) {
Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -16,6 +16,8 @@
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"-target arm-linux-gnueabi"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--target=arm-linux-gnueabi"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> %t.dir/bin/my_driver.sh
@@ -32,7 +34,7 @@
 
 # Generate a compile_commands.json that will query the mock driver we've
 # created. Which should add a.h and b.h into include search path.
-# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot -target arm-linux-gnueabi --target=arm-linux-gnueabi", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
 # On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
@@ -70,7 +72,7 @@
 {"jsonrpc":"2.0","method":"exit"}
 
 # Generate a different compile_commands.json which does not point to the mock driver
-# RUN: echo '[{"directory": "%/t.dir", "command": "gcc the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "gcc the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot -target arm-linux-gnueabi --target=arm-linux-gnueabi", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # Generate a clangd config file which points to the mock driver instead
 # RUN: echo 'CompileFlags:' > %t.dir/.clangd
Index: clang-tools-extra/clangd/SystemIncludeExtractor.cpp
===
--- clang-tools-extra/clangd/SystemIncludeExtractor.cpp
+++ clang-tools-extra/clangd/SystemIncludeExtractor.cpp
@@ -184,13 +184,18 @@
   const llvm::StringRef FlagsToPreserve[] = {
   "-nostdinc", "--no-standard-includes", "-nostdinc++", "-nobuiltininc"};
   // Preserves these flags and their values, either as separate args or with an
-  // equalsbetween them
+  // equals between them
   const llvm::StringRef ArgsToPreserve[] = {"--sysroot", "-isysroot"};
 
   for (size_t I = 0, E = CommandLine.size(); I < E; ++I) {
 llvm::StringRef Arg = CommandLine[I];
 if (llvm::is_contained(FlagsToPreserve, Arg)) {
   Args.push_back(Arg);
+} else if (Arg.startswith("--target=")) {
+  Args.push_back(Arg);
+} else if (I + 1 < E && Arg.equals("-target")) {
+  Args.push_back(CommandLine[I]);
+  Args.push_back(CommandLine[++I]);
 } else {
   const auto *Found =
   

[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-23 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer added a comment.

Yay. Thanks, Nathan, for guiding, replying, and just generally being so kind, 
great, and thorough.

I'll back out the plugin part of the changes changes momentarily, then.
Just to confirm: Sounds like you're not concerned, then, that the 
JSONCompilationDatabasePlugin will get invoked and the results then passed to a 
SystemIncludeExtractor-enabled mangler?
(I'd seen some fallback calls into the plugin registry in 
GlobalCompilationDatabase, hence the original change, but, lacking broader 
context, I was having trouble tracing the expected control flow.)


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

https://reviews.llvm.org/D138546

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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-23 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

rymiel wrote:
> rymiel wrote:
> > owenpan wrote:
> > > We should pass `true` to `peekNextToken()` on Line 3597 here, but 
> > > removing this entire case would have no effect on the existing unit test 
> > > (Line 23693 in FormatTest.cpp). @HazardyKnusperkeks any idea?
> > The peeking is there because of https://reviews.llvm.org/D134325, it has no 
> > format tests, only an annotator test
> Also, I don't think that function is involved in concept declarations since 
> https://reviews.llvm.org/D140339
So which tests were meant to check the `kw_bool` case here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[clang] f2b58eb - Revert "[Fuchsia] Build windows runtimes using cross compilation on Linux"

2023-01-23 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-01-23T18:43:23-08:00
New Revision: f2b58eb4ad840f33caf970d6cf2906486647086b

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

LOG: Revert "[Fuchsia] Build windows runtimes using cross compilation on Linux"

This reverts commit 20bb7658f53b0b8db165ff4d404ede3f9b34862d.
It breaks Fuchsia stage2 builders.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 73fa55668957..9694a0f59856 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -69,44 +69,12 @@ if(APPLE)
   set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" 
CACHE STRING "")
 endif()
 
-if(WIN32 OR LLVM_WINSYSROOT)
-  if((NOT WIN32) AND (NOT LLVM_VFSOVERLAY))
-message(FATAL_ERROR "LLVM_VFSOVERLAY should be defined.")
-  endif()
+if(WIN32)
   set(target "x86_64-pc-windows-msvc")
 
-  if (LLVM_WINSYSROOT)
-set(WINDOWS_COMPILER_FLAGS
-  -Xclang
-  -ivfsoverlay
-  -Xclang
-  ${LLVM_VFSOVERLAY}
-  # TODO: /winsysroot should be set by HandleLLVMOptions.cmake 
automatically
-  # but it current has a bug that prevents it from working under cross
-  # compilation. Set this flag manually for now.
-  /winsysroot
-  ${LLVM_WINSYSROOT})
-string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
-set(WINDOWS_LINK_FLAGS
-/vfsoverlay:${LLVM_VFSOVERLAY}
-# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
-# so we have to manually set the libpath. We use clang-cl driver if we 
can
-# and remove these libpath flags.
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
-string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
-  endif()
-
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-  set(BUILTINS_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
-  set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
-  set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
-  set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
-  set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 
   list(APPEND RUNTIME_TARGETS "${target}")
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
@@ -116,11 +84,6 @@ if(WIN32 OR LLVM_WINSYSROOT)
   set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE 
STRING "")
-  set(RUNTIMES_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
-  set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
-  set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
-  set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
-  set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
 foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)

diff  --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake 
b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 05bfd70fe54c..d760eee07958 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -93,7 +93,7 @@ function(llvm_ExternalProject_Add name source_dir)
   if(_cmake_system_name STREQUAL Darwin)
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo)
   elseif(is_msvc_target)
-list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib llvm-rc llvm-mt)
+list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib)
   else()
 # TODO: These tools don't fully support Mach-O format yet.
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-objcopy llvm-strip llvm-readelf)
@@ -212,12 +212,6 @@ function(llvm_ExternalProject_Add name source_dir)
 if(llvm-readelf IN_LIST TOOLCHAIN_TOOLS)
   list(APPEND compiler_args 
-DCMAKE_READELF=${LLVM_RUNTIME_OUT

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-01-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D139837#4067208 , @ayzhao wrote:

> Thanks for your effort on this!
>
> FYI I landed parenthesized aggregate initialization in D141546 
> , so CTAD for that feature should no longer 
> be blocked.

Thanks for letting me know. Considering the existing reviews, I'll create a 
separate patch for the parenthesized expression-list support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-23 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

rymiel wrote:
> owenpan wrote:
> > We should pass `true` to `peekNextToken()` on Line 3597 here, but removing 
> > this entire case would have no effect on the existing unit test (Line 23693 
> > in FormatTest.cpp). @HazardyKnusperkeks any idea?
> The peeking is there because of https://reviews.llvm.org/D134325, it has no 
> format tests, only an annotator test
Also, I don't think that function is involved in concept declarations since 
https://reviews.llvm.org/D140339


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-23 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

owenpan wrote:
> We should pass `true` to `peekNextToken()` on Line 3597 here, but removing 
> this entire case would have no effect on the existing unit test (Line 23693 
> in FormatTest.cpp). @HazardyKnusperkeks any idea?
The peeking is there because of https://reviews.llvm.org/D134325, it has no 
format tests, only an annotator test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-23 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 491581.
ziqingluo-90 added a comment.

Refactored the fix-it generation code to stop using the pretty-printer.


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

https://reviews.llvm.org/D139737

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

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
@@ -0,0 +1,96 @@
+// RUN: cp %s %t.cpp
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fixit %t.cpp
+// RUN: grep -v CHECK %t.cpp | FileCheck %s
+typedef int * Int_ptr_t;
+typedef int Int_t;
+
+void local_array_subscript_simple() {
+  int tmp;
+// CHECK: std::span p {new int[10], 10};
+// CHECK: std::span q {new int[10], 10};
+// CHECK: tmp = p[5];
+// CHECK: tmp = q[5];
+  int *p = new int[10];
+  const int *q = new int[10];
+  tmp = p[5];
+  tmp = q[5];
+
+// CHECK: std::span x {new int[10], 10};
+// CHECK: std::span y {new int, 1};
+// CHECK: std::span z {new int[10], 10};
+// CHECK: std::span w {new Int_t[10], 10};
+
+  Int_ptr_t x = new int[10];
+  Int_ptr_t y = new int;
+  Int_t * z = new int[10];
+  Int_t * w = new Int_t[10];
+
+  // CHECK: tmp = x[5];
+  tmp = x[5];
+  // CHECK: tmp = y[5];
+  tmp = y[5]; // y[5] will crash after being span
+  // CHECK: tmp = z[5];
+  tmp = z[5];
+  // CHECK: tmp = w[5];
+  tmp = w[5];
+}
+
+void local_array_subscript_auto() {
+  int tmp;
+// CHECK: std::span p {new int[10], 10};
+// CHECK: tmp = p[5];
+  auto p = new int[10];
+  tmp = p[5];
+}
+
+void local_array_subscript_variable_extent() {
+  int n = 10;
+  int tmp;
+
+  // CHECK: std::span p {new int[n], n};
+  // CHECK: std::span q {new int[n++], <# placeholder #>};
+  // CHECK: tmp = p[5];
+  // CHECK: tmp = q[5];
+  int *p = new int[n];
+  // If the extent expression does not have a constant value, we cannot fill the extent for users...
+  int *q = new int[n++];
+  tmp = p[5];
+  tmp = q[5];
+}
+
+
+void local_ptr_to_array() {
+  int tmp;
+  int n = 10;
+  int a[10];
+  int b[n];  // If the extent expression does not have a constant value, we cannot fill the extent for users...
+  // CHECK: std::span p {a, 10};
+  // CHECK: std::span q {b, <# placeholder #>};
+  // CHECK: tmp = p[5];
+  // CHECK: tmp = q[5];
+  int *p = a;
+  int *q = b;
+  tmp = p[5];
+  tmp = q[5];
+}
+
+void local_ptr_addrof_init() {
+  int var;
+// CHECK: std::span q {&var, 1};
+// CHECK: var = q[5];
+  int * q = &var;
+  // This expression involves unsafe buffer accesses, which will crash
+  // at runtime after applying the fix-it,
+  var = q[5];
+}
+
+void decl_without_init() {
+  int tmp;
+  // CHECK: std::span p;
+  int * p;
+  // CHECK: std::span q;
+  Int_ptr_t q;
+
+  tmp = p[5];
+  tmp = q[5];
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -9,6 +9,7 @@
 #include "clang/Analysis/Analyses/UnsafeBufferUsage.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
@@ -115,6 +116,21 @@
   MatchDescendantVisitor Visitor(&DTM, Finder, Builder, ASTMatchFinder::BK_All);  
   return Visitor.findMatch(DynTypedNode::create(Node));
 }
+
+AST_MATCHER_P(CastExpr, castSubExpr, internal::Matcher, innerMatcher) {
+  return innerMatcher.matches(*Node.getSubExpr(), Finder, Builder);
+}
+
+// Returns a matcher that matches any expression 'e' such that `innerMatcher`
+// matches 'e' and 'e' is in an Unspecified Lvalue Context.
+static auto isInUnspecifiedLvalueContext(internal::Matcher innerMatcher) {
+  auto isLvalueToRvalueCast = [](internal::Matcher M) {
+return implicitCastExpr(hasCastKind(CastKind::CK_LValueToRValue),
+castSubExpr(M));
+  };
+  //FIXME: add assignmentTo context...
+  return isLvalueToRvalueCast(innerMatcher);
+}
 } // namespace clang::ast_matchers
 
 namespace {
@@ -282,7 +298,7 @@
 /// Array subscript expressions on raw pointers as if they're arrays. Unsafe as
 /// it doesn't have any bounds checks for the array.
 class ArraySubscriptGadget : public WarningGadget {
-  static constexpr const char *const ArraySubscrTag = "arraySubscr";
+  static constexpr const char *const ArraySubscrTag = "ArraySubscript";
   const ArraySubscriptExpr *ASE;
 
 public:
@@ -366,6 +382,51 @@
   // FIXME: pointer adding zero should be fine
   //FIXME: this gadge will need a fix-it
 };
+
+class Strategy;
+
+// Represents expressions of the form `DRE[*]` in the Unspecified Lvalue
+// Context (see `isInUn

[PATCH] D142423: [clang-tidy] Fix segfault in bugprone-standalone-empty

2023-01-23 Thread Denis Nikitin via Phabricator via cfe-commits
denik created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
denik requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

The check incorrectly identified empty() method call in the template
class definition as a stand-alone function call.
This led to a crash because the checker did not expect empty() function
calls without arguments.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142423

Files:
  clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/bugprone/standalone-empty.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/standalone-empty.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/standalone-empty.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/standalone-empty.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/standalone-empty.cpp
@@ -80,6 +80,10 @@
 void empty(T &&);
 } // namespace test
 
+namespace test_no_args {
+bool empty();
+} // namespace test_no_args
+
 namespace base {
 template 
 struct base_vector {
@@ -306,6 +310,9 @@
 
 test::empty(v);
 // no-warning
+
+test_no_args::empty();
+// no-warning
   }
 
   {
@@ -876,3 +883,24 @@
 // no-warning
   }
 }
+
+namespace user_lib {
+template 
+struct vector {
+  bool empty();
+  bool test_empty_inside_impl() {
+empty();
+// no-warning
+return empty();
+// no-warning
+  }
+};
+} // namespace user_lib
+
+bool test_template_empty_outside_impl() {
+  user_lib::vector v;
+  v.empty();
+  // CHECK-MESSAGES: :[[#@LINE-1]]:3: warning: ignoring the result of 'empty()' [bugprone-standalone-empty]
+  return v.empty();
+  // no-warning
+}
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/standalone-empty.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/standalone-empty.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/standalone-empty.rst
@@ -3,8 +3,8 @@
 bugprone-standalone-empty
 =
 
-Warns when `empty()` is used on a range and the result is ignored. Suggests 
-`clear()` if it is an existing member function.
+Warns when ``empty()`` is used on a range and the result is ignored. Suggests
+``clear()`` if it is an existing member function.
 
 The ``empty()`` method on several common ranges returns a Boolean indicating
 whether or not the range is empty, but is often mistakenly interpreted as
@@ -29,3 +29,8 @@
   std::vector v;
   ...
   v.clear();
+
+Limitations:
+- Doesn't warn if ``empty()`` is defined and used with the ignore result in the
+  class template definition (for example in the library implementation). These
+  error cases can be caught with ``[[nodiscard]]`` attribute.
Index: clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
@@ -29,10 +29,12 @@
 using ast_matchers::BoundNodes;
 using ast_matchers::callee;
 using ast_matchers::callExpr;
+using ast_matchers::classTemplateDecl;
 using ast_matchers::cxxMemberCallExpr;
 using ast_matchers::cxxMethodDecl;
 using ast_matchers::expr;
 using ast_matchers::functionDecl;
+using ast_matchers::hasAncestor;
 using ast_matchers::hasName;
 using ast_matchers::hasParent;
 using ast_matchers::ignoringImplicit;
@@ -70,10 +72,13 @@
 }
 
 void StandaloneEmptyCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
+  // Ignore empty calls in a template definition which fall under callExpr
+  // non-member matcher even if they are methods.
   const auto NonMemberMatcher = expr(ignoringImplicit(ignoringParenImpCasts(
   callExpr(
   hasParent(stmt(optionally(hasParent(stmtExpr().bind("stexpr"
 .bind("parent")),
+  unless(hasAncestor(classTemplateDecl())),
   callee(functionDecl(hasName("empty"), unless(returns(voidType())
   .bind("empty";
   const auto MemberMatcher =
@@ -154,6 +159,8 @@
   return;
 if (ParentReturnStmt)
   return;
+if (NonMemberCall->getNumArgs() != 1)
+  return;
 
 SourceLocation NonMemberLoc = NonMemberCall->getExprLoc();
 SourceLocation NonMemberEndLoc = NonMemberCall->getEndLoc();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142416: [clang][deps] NFC: Remove dead code

2023-01-23 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:180
-  // incompatible modules (e.g. with differences in search paths).
-  CI.getHeaderSearchOpts().ModulesStrictContextHash = true;
-

benlangmuir wrote:
> I see we're enabling strict hashing in the scaner itself: 
> `ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;`, which 
> makes me think this code was never used to influence the scanner's implicit 
> build.  If that's true, was this code *already* dead before my change in 
> D129884?  It's not clear to me what it was doing.
The line you found enables strict context hashing for the `CompilerInstance` 
that performs the scanning build. That's still important so that we don't 
squash multiple module configurations into one minimized PCM.

The line this patch removes used to control generation of the module context 
hash we report to the client. This used to be done by taking the original TU 
command line, tweaking it, and calling `CompilerInvocation::getModuleHash()`. 
Since we now hash the whole command line that's generated from said 
`CompilerInvocation`, controlling the behavior of `getModuleHash()` by enabling 
strict context hash is no longer necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142416

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


[PATCH] D142421: [Sanitizers] fix -fno-sanitize-link-runtime for darwin

2023-01-23 Thread Usama Hameed via Phabricator via cfe-commits
usama54321 created this revision.
Herald added a project: All.
usama54321 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

rdar://99200922


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142421

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

Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -25,6 +25,14 @@
 //
 // CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
+// RUN: %clang -fsanitize=address -fno-sanitize-link-runtime -### %s 2>&1 \
+// RUN: --target=arm64e-apple-macosx -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-DARWIN %s
+//
+// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN-NOT: libclang_rt.asan
+
 // RUN: %clang -fsanitize=address -### %s 2>&1 \
 // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
@@ -288,6 +296,14 @@
 //
 // CHECK-TSAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.tsan
 
+// RUN: %clang -fsanitize=thread -fno-sanitize-link-runtime -### %s 2>&1 \
+// RUN: --target=arm64e-apple-ios -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-TSAN-NO-LINK-RUNTIME-DARWIN %s
+//
+// CHECK-TSAN-NO-LINK-RUNTIME-DARWIN-NOT: libclang_rt.tsan
+
 // RUN: %clangxx -### %s 2>&1 \
 // RUN: --target=x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
 // RUN: -fsanitize=memory \
@@ -353,6 +369,22 @@
 //
 // CHECK-UBSAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.undefined
 
+// RUN: %clang -fsanitize=undefined -fno-sanitize-link-runtime -### %s 2>&1 \
+// RUN: --target=x86_64-apple-darwin -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-UBSAN-NO-LINK-RUNTIME-DARWIN %s
+//
+// CHECK-UBSAN-NO-LINK-RUNTIME-DARWIN-NOT: libclang_rt.ubsan
+
+// RUN: %clang -fsanitize=fuzzer -fno-sanitize-link-runtime -### %s 2>&1 \
+// RUN: --target=arm64e-apple-watchos -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-FUZZER-NO-LINK-RUNTIME-DARWIN %s
+//
+// CHECK-FUZZER-NO-LINK-RUNTIME-DARWIN-NOT: libclang_rt.fuzzer
+
 // RUN: %clang -fsanitize=undefined -### %s 2>&1 \
 // RUN: --target=i386-unknown-linux -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1431,27 +1431,29 @@
 return;
   }
 
-  if (Sanitize.needsAsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
-  if (Sanitize.needsLsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
-  if (Sanitize.needsUbsanRt()) {
-assert(Sanitize.needsSharedRt() && "Static sanitizer runtimes not supported");
-AddLinkSanitizerLibArgs(Args, CmdArgs,
-Sanitize.requiresMinimalRuntime() ? "ubsan_minimal"
-  : "ubsan");
-  }
-  if (Sanitize.needsTsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
-  if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {
-AddLinkSanitizerLibArgs(Args, CmdArgs, "fuzzer", /*shared=*/false);
-
-// Libfuzzer is written in C++ and requires libcxx.
-AddCXXStdlibLibArgs(Args, CmdArgs);
-  }
-  if (Sanitize.needsStatsRt()) {
-AddLinkRuntimeLib(Args, CmdArgs, "stats_client", RLO_AlwaysLink);
-AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
+  if (Sanitize.linkRuntimes()) {
+if (Sanitize.needsAsanRt())
+  AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+if (Sanitize.needsLsanRt())
+  AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
+if (Sanitize.needsUbsanRt()) {
+  assert(Sanitize.needsSharedRt() && "Static sanitizer runtimes not supported");
+  AddLinkSanitizerLibArgs(Args, CmdArgs,
+  Sanitize.requiresMinimalRuntime() ? "ubsan_minimal"
+: "ubsan");
+}
+if (Sanitize.needsTsanRt())
+  AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
+if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {
+  AddLinkSanitizerLibArgs(Args, CmdArgs, "fuzzer", /*shared=*/false);
+
+// Libfuzzer is written in C++ and requires libcxx.
+AddCXXStdlibLibArgs(Args, CmdArgs);
+}
+if (Sanitize.needsStatsRt()) {
+  AddLinkRuntimeLib(Args, Cm

[PATCH] D140598: [Clang] Add sanity check in Sema::getDestructorName to prevent nullptr dereference

2023-01-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 491554.
shafik marked 2 inline comments as done.
shafik added a comment.

- Switched to isValid() over isSet()
- Added release note


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

https://reviews.llvm.org/D140598

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/GH59446.cpp


Index: clang/test/SemaCXX/GH59446.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/GH59446.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+namespace GH59446 { // expected-note {{to match this '{'}}
+namespace N {
+template  struct X ; // expected-note 2 {{template is declared 
here}}
+ // expected-note@-1 {{'N::X' declared 
here}}
+// expected-note@-2 {{non-type declaration 
found by destructor name lookup}}
+  }
+  void f(X *x) { // expected-error {{no template named 'X'; did you mean 
'N::X'}}
+x->N::X::~X(); // expected-error 2 {{implicit instantiation of 
undefined template 'GH59446::N::X'}}
+// expected-error@-1 {{identifier 'X' after '~' in 
destructor name does not name a type}}
+} // expected-error {{expected '}'}}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -391,7 +391,7 @@
 //
 // also looks for type-name in the scope. Unfortunately, we can't
 // reasonably apply this fallback for dependent nested-name-specifiers.
-if (SS.getScopeRep()->getPrefix()) {
+if (SS.isValid() && SS.getScopeRep()->getPrefix()) {
   if (ParsedType T = LookupInScope()) {
 Diag(SS.getEndLoc(), diag::ext_qualified_dtor_named_in_lexical_scope)
 << FixItHint::CreateRemoval(SS.getRange());
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -356,6 +356,9 @@
   `Issue 51227 `_.
 - Fix the bug of inserting the ``ZeroInitializationFixit`` before the template
   argument list of ``VarTemplateSpecializationDecl``.
+- Fix crash on invalid code when looking up a destructor in a templated class
+  inside a namespace. This fixes
+  `Issue 59446 `_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/SemaCXX/GH59446.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/GH59446.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+namespace GH59446 { // expected-note {{to match this '{'}}
+namespace N {
+template  struct X ; // expected-note 2 {{template is declared here}}
+ // expected-note@-1 {{'N::X' declared here}}
+ // expected-note@-2 {{non-type declaration found by destructor name lookup}}
+  }
+  void f(X *x) { // expected-error {{no template named 'X'; did you mean 'N::X'}}
+x->N::X::~X(); // expected-error 2 {{implicit instantiation of undefined template 'GH59446::N::X'}}
+// expected-error@-1 {{identifier 'X' after '~' in destructor name does not name a type}}
+} // expected-error {{expected '}'}}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -391,7 +391,7 @@
 //
 // also looks for type-name in the scope. Unfortunately, we can't
 // reasonably apply this fallback for dependent nested-name-specifiers.
-if (SS.getScopeRep()->getPrefix()) {
+if (SS.isValid() && SS.getScopeRep()->getPrefix()) {
   if (ParsedType T = LookupInScope()) {
 Diag(SS.getEndLoc(), diag::ext_qualified_dtor_named_in_lexical_scope)
 << FixItHint::CreateRemoval(SS.getRange());
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -356,6 +356,9 @@
   `Issue 51227 `_.
 - Fix the bug of inserting the ``ZeroInitializationFixit`` before the template
   argument list of ``VarTemplateSpecializationDecl``.
+- Fix crash on invalid code when looking up a destructor in a templated class
+  inside a namespace. This fixes
+  `Issue 59446 `_.
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141765: [FPEnv] Fix complex operations in strictfp mode

2023-01-23 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Seems right to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141765

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


[PATCH] D142416: [clang][deps] NFC: Remove dead code

2023-01-23 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

Removing `ImplicitModulePCMPath` LGTM; not sure about the other change.




Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:180
-  // incompatible modules (e.g. with differences in search paths).
-  CI.getHeaderSearchOpts().ModulesStrictContextHash = true;
-

I see we're enabling strict hashing in the scaner itself: 
`ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;`, which 
makes me think this code was never used to influence the scanner's implicit 
build.  If that's true, was this code *already* dead before my change in 
D129884?  It's not clear to me what it was doing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142416

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


[PATCH] D142403: [build] Fix stand-alone builds of clang.

2023-01-23 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D142403#4075215 , @tstellar wrote:

> LGTM.  I tested and this fixes the build.

@tstellar , I wonder how your build (and mine too, in fact) didn't complain 
about the typo... luckily the bots cover this functionality! Anyway, I have 
re-landed it as 
https://reviews.llvm.org/rGaa19429b19b6a8d44a671a93bf9c00570bad53ac.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142403

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


[PATCH] D141738: Add initial support for cross compile Windows runtimes under Linux when building Fuchsia clang toolchain

2023-01-23 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:95
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"

haowei wrote:
> thakis wrote:
> > You can tell cmake to invoke lld-link, which has a /winsysroot: flag.
> What would be a good way to make CMake invoke lld-link (or through clang-cl) 
> instead of using `cmake vs_link` in this situation?
> We thought about using
> 
> ```
> set(CMAKE_${LANG}_SIMULATE_ID "MSVC")
> set(CMAKE_${LANG}_COMPILER_FRONTEND_VARIANT "GNU")
> ```
> 
> but I don't feel great about changing variables that are not suppose to 
> change. 
Wouldn't CMake use `lld-link` if you set `CMAKE_LINKER=lld-link`. We already do 
this in 
https://github.com/llvm/llvm-project/blob/0e09bb8b143c80426c497a924ee4fa57a26af6b5/llvm/cmake/modules/LLVMExternalProjectUtils.cmake#L179
 which is used by the bootstrapping build so you should be able to use 
`/winsysroot:` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141738

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


[PATCH] D142416: [clang][deps] NFC: Remove dead code

2023-01-23 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: benlangmuir.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch removes some dead code in the dependency scanner.

The `ModuleDeps::ImplicitModulePCMPath` member stopped being used in D131934 
.

The strict context hash was replaced in D129884 
 by hash of the canonical command line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142416

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp


Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -171,14 +171,6 @@
 
   Optimize(CI);
 
-  // The original invocation probably didn't have strict context hash enabled.
-  // We will use the context hash of this invocation to distinguish between
-  // multiple incompatible versions of the same module and will use it when
-  // reporting dependencies to the clients. Let's make sure we're using
-  // **strict** context hash in order to prevent accidental sharing of
-  // incompatible modules (e.g. with differences in search paths).
-  CI.getHeaderSearchOpts().ModulesStrictContextHash = true;
-
   return CI;
 }
 
@@ -414,7 +406,6 @@
 
   MD.ID.ModuleName = M->getFullModuleName();
   MD.ImportedByMainFile = DirectModularDeps.contains(M);
-  MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
   MD.IsSystem = M->IsSystem;
 
   ModuleMap &ModMapInfo =
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -87,9 +87,6 @@
   /// additionally appear in \c FileDeps as a dependency.
   std::string ClangModuleMapFile;
 
-  /// The path to where an implicit build would put the PCM for this module.
-  std::string ImplicitModulePCMPath;
-
   /// A collection of absolute paths to files that this module directly depends
   /// on, not including transitive dependencies.
   llvm::StringSet<> FileDeps;


Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -171,14 +171,6 @@
 
   Optimize(CI);
 
-  // The original invocation probably didn't have strict context hash enabled.
-  // We will use the context hash of this invocation to distinguish between
-  // multiple incompatible versions of the same module and will use it when
-  // reporting dependencies to the clients. Let's make sure we're using
-  // **strict** context hash in order to prevent accidental sharing of
-  // incompatible modules (e.g. with differences in search paths).
-  CI.getHeaderSearchOpts().ModulesStrictContextHash = true;
-
   return CI;
 }
 
@@ -414,7 +406,6 @@
 
   MD.ID.ModuleName = M->getFullModuleName();
   MD.ImportedByMainFile = DirectModularDeps.contains(M);
-  MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
   MD.IsSystem = M->IsSystem;
 
   ModuleMap &ModMapInfo =
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -87,9 +87,6 @@
   /// additionally appear in \c FileDeps as a dependency.
   std::string ClangModuleMapFile;
 
-  /// The path to where an implicit build would put the PCM for this module.
-  std::string ImplicitModulePCMPath;
-
   /// A collection of absolute paths to files that this module directly depends
   /// on, not including transitive dependencies.
   llvm::StringSet<> FileDeps;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142393: [OpenMP] Add 'amdgpu-flat-work-group-size' to OpenMP kernels

2023-01-23 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:791
 
-  // Get the device name and canonicalize it
+  // Get the ndevice name and canonicalize it
   const StringRef GpuArch = getGPUArch(DriverArgs);

^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142393

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


[PATCH] D142403: [build] Fix stand-alone builds of clang.

2023-01-23 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D142403#4075215 , @tstellar wrote:

> LGTM.  I tested and this fixes the build.

Thank you @tstellar, I landed it. I am going offline for until tomorrow morning 
- feel free to revert it if the world of bots collapses :)

@mgorny - is this fixing also your builds?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142403

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


[clang] 0ba42be - [Clang][NFC] Fix documentation and remove unused tool

2023-01-23 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-23T17:57:21-06:00
New Revision: 0ba42be63e1f26370565cd6b824a9de4ff53a801

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

LOG: [Clang][NFC] Fix documentation and remove unused tool

Summary:
I removed some documentation but not its Sphinx index, this fixes that.
Also I realized that we had a tool in the header still around so that's
gone too.

Added: 


Modified: 
clang/docs/index.rst
clang/docs/tools/clang-formatted-files.txt
clang/lib/Driver/ToolChains/Clang.h

Removed: 




diff  --git a/clang/docs/index.rst b/clang/docs/index.rst
index 4befe61ee5ca5..e572f706c01f5 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -87,9 +87,7 @@ Using Clang Tools
ClangFormatStyleOptions
ClangFormattedStatus
ClangLinkerWrapper
-   ClangNvlinkWrapper
ClangOffloadBundler
-   ClangOffloadWrapper
ClangOffloadPackager
ClangRepl
 

diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 6730aacf43cd4..42798e5183a82 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -608,8 +608,6 @@ clang/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
 clang/tools/clang-fuzzer/handle-llvm/handle_llvm.h
 clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
 clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
-clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
-clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
 clang/tools/clang-pseudo/ClangPseudo.cpp
 clang/tools/clang-refactor/ClangRefactor.cpp
 clang/tools/clang-refactor/TestSupport.cpp

diff  --git a/clang/lib/Driver/ToolChains/Clang.h 
b/clang/lib/Driver/ToolChains/Clang.h
index d7550665539cc..a7625dba66469 100644
--- a/clang/lib/Driver/ToolChains/Clang.h
+++ b/clang/lib/Driver/ToolChains/Clang.h
@@ -159,19 +159,6 @@ class LLVM_LIBRARY_VISIBILITY OffloadBundler final : 
public Tool {
const char *LinkingOutput) const override;
 };
 
-/// Offload wrapper tool.
-class LLVM_LIBRARY_VISIBILITY OffloadWrapper final : public Tool {
-public:
-  OffloadWrapper(const ToolChain &TC)
-  : Tool("offload wrapper", "clang-offload-wrapper", TC) {}
-
-  bool hasIntegratedCPP() const override { return false; }
-  void ConstructJob(Compilation &C, const JobAction &JA,
-const InputInfo &Output, const InputInfoList &Inputs,
-const llvm::opt::ArgList &TCArgs,
-const char *LinkingOutput) const override;
-};
-
 /// Offload binary tool.
 class LLVM_LIBRARY_VISIBILITY OffloadPackager final : public Tool {
 public:



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


[PATCH] D142403: [build] Fix stand-alone builds of clang.

2023-01-23 Thread Francesco Petrogalli 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 rG5d02e38f56df: [build] Fix stand-alone builds of clang. 
(authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142403

Files:
  llvm/cmake/modules/LLVMConfig.cmake.in


Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -140,9 +140,9 @@
   @llvm_config_include_buildtree_only_exports@
 endif()
 
-# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
-# on LLVM's tablegen-generated headers can always depend on this target whether
-# building in-tree with LLVM or not.
+# By creating the following targets here, subprojects that depend on
+# LLVM's tablegen-generated headers can always depend on this target
+# whether building in-tree with LLVM or not.
 if(NOT TARGET intrinsics_gen)
   add_custom_target(intrinsics_gen)
 endif()
@@ -152,6 +152,9 @@
 if(NOT TARGET acc_gen)
   add_custom_target(acc_gen)
 endif()
+if(NOT TARGET RISCVTargetParserTablegen)
+  add_custom_target(RISCVTargetParserTableGen)
+endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)


Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -140,9 +140,9 @@
   @llvm_config_include_buildtree_only_exports@
 endif()
 
-# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
-# on LLVM's tablegen-generated headers can always depend on this target whether
-# building in-tree with LLVM or not.
+# By creating the following targets here, subprojects that depend on
+# LLVM's tablegen-generated headers can always depend on this target
+# whether building in-tree with LLVM or not.
 if(NOT TARGET intrinsics_gen)
   add_custom_target(intrinsics_gen)
 endif()
@@ -152,6 +152,9 @@
 if(NOT TARGET acc_gen)
   add_custom_target(acc_gen)
 endif()
+if(NOT TARGET RISCVTargetParserTablegen)
+  add_custom_target(RISCVTargetParserTableGen)
+endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142403: [build] Fix stand-alone builds of clang.

2023-01-23 Thread Tom Stellard via Phabricator via cfe-commits
tstellar accepted this revision.
tstellar added a comment.
This revision is now accepted and ready to land.

LGTM.  I tested and this fixes the build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142403

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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-23 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3592-3601
 case tok::kw_bool:
   // bool is only allowed if it is directly followed by a paren for a cast:
   // concept C = bool(...);
   // and bool is the only type, all other types as cast must be inside a
   // cast to bool an thus are handled by the other cases.
   if (Tokens->peekNextToken()->isNot(tok::l_paren))
 return;

We should pass `true` to `peekNextToken()` on Line 3597 here, but removing this 
entire case would have no effect on the existing unit test (Line 23693 in 
FormatTest.cpp). @HazardyKnusperkeks any idea?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142412

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


[PATCH] D141968: [NFC] Consolidate llvm::CodeGenOpt::Level handling

2023-01-23 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added inline comments.



Comment at: flang/lib/Frontend/FrontendActions.cpp:590
+  std::optional OptLevelOrNone =
+  CodeGenOpt::getLevel(CGOpts.OptimizationLevel);
+  assert(OptLevelOrNone && "Invalid optimization level!");

aaronpuchert wrote:
> Does this need `llvm::`?
> 
> ```
> ../llvm-project/flang/lib/Frontend/FrontendActions.cpp:590:7: error: use of 
> undeclared identifier 'CodeGenOpt'; did you mean 'llvm::CodeGenOpt'?
>   CodeGenOpt::getLevel(CGOpts.OptimizationLevel);
>   ^~
>   llvm::CodeGenOpt
> ../llvm-project/llvm/include/llvm/Support/CodeGen.h:53:13: note: 
> 'llvm::CodeGenOpt' declared here
>   namespace CodeGenOpt {
> ^
> ```
> See https://lab.llvm.org/buildbot/#/builders/191/builds/13832.
Yes, I just commited a1baa7a5c57ea3065f8f354d2fc758b3328040fd to fix this; I 
thought I was building `flang` locally but didn't verify it and clearly was not

Thank you and sorry for the noise!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141968

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


[PATCH] D141968: [NFC] Consolidate llvm::CodeGenOpt::Level handling

2023-01-23 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: flang/lib/Frontend/FrontendActions.cpp:590
+  std::optional OptLevelOrNone =
+  CodeGenOpt::getLevel(CGOpts.OptimizationLevel);
+  assert(OptLevelOrNone && "Invalid optimization level!");

Does this need `llvm::`?

```
../llvm-project/flang/lib/Frontend/FrontendActions.cpp:590:7: error: use of 
undeclared identifier 'CodeGenOpt'; did you mean 'llvm::CodeGenOpt'?
  CodeGenOpt::getLevel(CGOpts.OptimizationLevel);
  ^~
  llvm::CodeGenOpt
../llvm-project/llvm/include/llvm/Support/CodeGen.h:53:13: note: 
'llvm::CodeGenOpt' declared here
  namespace CodeGenOpt {
^
```
See https://lab.llvm.org/buildbot/#/builders/191/builds/13832.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141968

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


[PATCH] D142412: [clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

2023-01-23 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

To prevent potential bugs in situations where we want to peek the next 
//non-comment// token.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142412

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3444,6 +3444,13 @@
"\n"
"private:\n"
"  int c;\n"
+   "};\n"
+   "class B {\n"
+   "public:\n"
+   "  std::unique_ptr b() { return nullptr; 
}\n"
+   "\n"
+   "private:\n"
+   "  int c;\n"
"};");
 }
 
@@ -9637,6 +9644,19 @@
"  return a;\n"
"}",
Style);
+  verifyFormat("byte *\n"
+   "f(a)\n"
+   "byte /* K&R C */ a[];\n"
+   "{\n"
+   "  return a;\n"
+   "}\n"
+   "byte *\n"
+   "g(p)\n"
+   "byte /* K&R C */ *p;\n"
+   "{\n"
+   "  return p;\n"
+   "}",
+   Style);
   verifyFormat("bool f(int a, int) override;\n"
"Bar g(int a, Bar) final;\n"
"Bar h(a, Bar) final;",
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1906,7 +1906,9 @@
   // declaration.
   if (!IsTopLevel || !Style.isCpp() || !Previous || eof())
 break;
-  if (isC78ParameterDecl(FormatTok, Tokens->peekNextToken(), Previous)) {
+  if (isC78ParameterDecl(FormatTok,
+ Tokens->peekNextToken(/*SkipComment=*/true),
+ Previous)) {
 addUnwrappedLine();
 return;
   }
@@ -2376,7 +2378,7 @@
   if (FormatTok->is(tok::l_square))
 return false;
   if (FormatTok->is(tok::r_square)) {
-const FormatToken *Next = Tokens->peekNextToken();
+const FormatToken *Next = Tokens->peekNextToken(/*SkipComment=*/true);
 if (Next->is(tok::greater))
   return false;
   }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3444,6 +3444,13 @@
"\n"
"private:\n"
"  int c;\n"
+   "};\n"
+   "class B {\n"
+   "public:\n"
+   "  std::unique_ptr b() { return nullptr; }\n"
+   "\n"
+   "private:\n"
+   "  int c;\n"
"};");
 }
 
@@ -9637,6 +9644,19 @@
"  return a;\n"
"}",
Style);
+  verifyFormat("byte *\n"
+   "f(a)\n"
+   "byte /* K&R C */ a[];\n"
+   "{\n"
+   "  return a;\n"
+   "}\n"
+   "byte *\n"
+   "g(p)\n"
+   "byte /* K&R C */ *p;\n"
+   "{\n"
+   "  return p;\n"
+   "}",
+   Style);
   verifyFormat("bool f(int a, int) override;\n"
"Bar g(int a, Bar) final;\n"
"Bar h(a, Bar) final;",
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1906,7 +1906,9 @@
   // declaration.
   if (!IsTopLevel || !Style.isCpp() || !Previous || eof())
 break;
-  if (isC78ParameterDecl(FormatTok, Tokens->peekNextToken(), Previous)) {
+  if (isC78ParameterDecl(FormatTok,
+ Tokens->peekNextToken(/*SkipComment=*/true),
+ Previous)) {
 addUnwrappedLine();
 return;
   }
@@ -2376,7 +2378,7 @@
   if (FormatTok->is(tok::l_square))
 return false;
   if (FormatTok->is(tok::r_square)) {
-const FormatToken *Next = Tokens->peekNextToken();
+const FormatToken *Next = Tokens->peekNextToken(/*SkipComment=*/true);
 if (Next->is(tok::greater))
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142392: [clang][deps] Add module files for input dependencies earlier

2023-01-23 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 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/D142392/new/

https://reviews.llvm.org/D142392

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


[PATCH] D141968: [NFC] Consolidate llvm::CodeGenOpt::Level handling

2023-01-23 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

I also ended up changing the underlying type to `int` to resolve 
https://lab.llvm.org/buildbot/#/builders/61/builds/38754 , and I removed the 
`getID` function (with the implicit conversions it would never get used anyway).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141968

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


[PATCH] D142196: [clang][Lex] Add back PPCallbacks::FileNotFound

2023-01-23 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld marked an inline comment as done.
Hahnfeld added a comment.

In D142196#4074249 , @jansvoboda11 
wrote:

> Also I think we should mention this API in our docs, right where the removed 
> original used to be.

Which API docs are you referring to? I'm only aware of the `pp-trace` docs 
(updated in https://reviews.llvm.org/D125258 for the removal), but I didn't add 
`FileNotFound` to `pp-trace` because it's more of a hook than a "traceable 
event" - should I add it nevertheless?




Comment at: clang/include/clang/Lex/PPCallbacks.h:87
+  /// Callback invoked whenever an inclusion directive results in a
+  /// file-not-found error.
+  ///

jansvoboda11 wrote:
> The wording is a bit misleading due to:
> ```
>   if (SuppressIncludeNotFoundError)
> return std::nullopt;
> ```
> after invoking this callback. Reading the comment, I assume the diagnostic 
> has already been issued. Can we tweak this to clarify things?
Please let me know if this sounds better.


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

https://reviews.llvm.org/D142196

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


[PATCH] D142196: [clang][Lex] Add back PPCallbacks::FileNotFound

2023-01-23 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 491522.
Hahnfeld added a comment.

Update comment.


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

https://reviews.llvm.org/D142196

Files:
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Lex/PPDirectives.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp

Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -444,6 +444,50 @@
   ASSERT_EQ("\"tri\?\?-graph.h\"", GetSourceString(Range));
 }
 
+TEST_F(PPCallbacksTest, FileNotFoundSkipped) {
+  const char *SourceText = "#include \"skipped.h\"\n";
+
+  std::unique_ptr SourceBuf =
+  llvm::MemoryBuffer::getMemBuffer(SourceText);
+  SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
+
+  HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+  Diags, LangOpts, Target.get());
+  TrivialModuleLoader ModLoader;
+
+  DiagnosticConsumer *DiagConsumer = new DiagnosticConsumer;
+  DiagnosticsEngine FileNotFoundDiags(DiagID, DiagOpts.get(), DiagConsumer);
+  Preprocessor PP(std::make_shared(), FileNotFoundDiags,
+  LangOpts, SourceMgr, HeaderInfo, ModLoader,
+  /*IILookup=*/nullptr,
+  /*OwnsHeaderSearch=*/false);
+  PP.Initialize(*Target);
+
+  class FileNotFoundCallbacks : public PPCallbacks {
+  public:
+unsigned int NumCalls = 0;
+bool FileNotFound(StringRef FileName) override {
+  NumCalls++;
+  return FileName == "skipped.h";
+}
+  };
+
+  auto *Callbacks = new FileNotFoundCallbacks;
+  PP.addPPCallbacks(std::unique_ptr(Callbacks));
+
+  // Lex source text.
+  PP.EnterMainSourceFile();
+  while (true) {
+Token Tok;
+PP.Lex(Tok);
+if (Tok.is(tok::eof))
+  break;
+  }
+
+  ASSERT_EQ(1u, Callbacks->NumCalls);
+  ASSERT_EQ(0u, DiagConsumer->getNumErrors());
+}
+
 TEST_F(PPCallbacksTest, OpenCLExtensionPragmaEnabled) {
   const char* Source =
 "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n";
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2000,6 +2000,10 @@
   if (File)
 return File;
 
+  // Give the clients a chance to silently skip this include.
+  if (Callbacks && Callbacks->FileNotFound(Filename))
+return std::nullopt;
+
   if (SuppressIncludeNotFoundError)
 return std::nullopt;
 
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -83,6 +83,16 @@
const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) {}
 
+  /// Callback invoked whenever the preprocessor cannot find a file for an
+  /// inclusion directive.
+  ///
+  /// \param FileName The name of the file being included, as written in the
+  /// source code.
+  ///
+  /// \returns true to indicate that the preprocessor should skip this file
+  /// and not issue any diagnostic.
+  virtual bool FileNotFound(StringRef FileName) { return false; }
+
   /// Callback invoked whenever an inclusion directive of
   /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless
   /// of whether the inclusion will actually result in an inclusion.
@@ -451,6 +461,14 @@
 Second->FileSkipped(SkippedFile, FilenameTok, FileType);
   }
 
+  bool FileNotFound(StringRef FileName) override {
+bool Skip = First->FileNotFound(FileName);
+// Make sure to invoke the second callback, no matter if the first already
+// returned true to skip the file.
+Skip |= Second->FileNotFound(FileName);
+return Skip;
+  }
+
   void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
   StringRef FileName, bool IsAngled,
   CharSourceRange FilenameRange,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141738: Add initial support for cross compile Windows runtimes under Linux when building Fuchsia clang toolchain

2023-01-23 Thread Haowei Wu via Phabricator via cfe-commits
haowei added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:95
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"

thakis wrote:
> You can tell cmake to invoke lld-link, which has a /winsysroot: flag.
What would be a good way to make CMake invoke lld-link (or through clang-cl) 
instead of using `cmake vs_link` in this situation?
We thought about using

```
set(CMAKE_${LANG}_SIMULATE_ID "MSVC")
set(CMAKE_${LANG}_COMPILER_FRONTEND_VARIANT "GNU")
```

but I don't feel great about changing variables that are not suppose to change. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141738

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


[PATCH] D141968: [NFC] Consolidate llvm::CodeGenOpt::Level handling

2023-01-23 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added inline comments.



Comment at: llvm/include/llvm/Support/CodeGen.h:67
+  inline std::optional getLevel(IDType ID) {
+if (ID < 0 || ID > 3)
+  return std::nullopt;

mstorsjo wrote:
> scott.linder wrote:
> > barannikov88 wrote:
> > > As I can see, clients do not check for nullopt. Either add checks or 
> > > replace this check with an assertion and drop std::optional (in this case 
> > > `parseLevel` should be updated accordingly).
> > > 
> > > 
> > Good catch! I was working off of the old behavior of `llvm::Optional` and 
> > assuming the new `std::optional` was guaranteed to `assert` on dereference 
> > as well. I think the right interface is to expose the `optional`, so for 
> > the callsites which currently do the equivalent of asserting I will just 
> > carry over an explicit assert to the new version.
> > 
> > I posted to 
> > https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716/26
> >  to discuss the issue more generally, as at least some of the patches which 
> > moved code from `llvm::Optional` to `std::optional` accidentally dropped 
> > assertions.
> This causes massive amounts of warnings when built with GCC:
> ```
> ../include/llvm/Support/CodeGen.h:67:12: warning: comparison is always false 
> due to limited range of data type [-Wtype-limits]
>67 | if (ID < 0 || ID > 3)
>   | ~~~^~~
> ```
Fixed in 2dc33713de7ceae3e28a13be1d72c862ec0efb2c

Thank you for reporting, sorry for the noise!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141968

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


[PATCH] D142410: [AArch64] ARMv8.5-A implies both FEAT_SB and FEAT_SSBS

2023-01-23 Thread Philipp Tomsich via Phabricator via cfe-commits
philipp.tomsich created this revision.
philipp.tomsich added a reviewer: dmgreen.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
philipp.tomsich requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

ARMv8.5-A implies SB and SSBS.  This requires some adjustments to the
testcases where ARMv8.5 cores (which must implement these) have tests
that don't expect SB or (usually) SBSS to be set.

Depends on D142396 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142410

Files:
  clang/test/CodeGen/aarch64-targetattr.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h
  llvm/lib/Target/AArch64/AArch64.td
  llvm/unittests/TargetParser/TargetParserTest.cpp

Index: llvm/unittests/TargetParser/TargetParserTest.cpp
===
--- llvm/unittests/TargetParser/TargetParserTest.cpp
+++ llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1094,7 +1094,7 @@
 AArch64::AEK_FP16 | AArch64::AEK_FP16FML | AArch64::AEK_SVE |
 AArch64::AEK_SVE2 | AArch64::AEK_SVE2BITPERM |
 AArch64::AEK_PAUTH | AArch64::AEK_FLAGM | AArch64::AEK_SB |
-AArch64::AEK_I8MM | AArch64::AEK_BF16,
+AArch64::AEK_I8MM | AArch64::AEK_BF16 | AArch64::AEK_SSBS,
 "9-A"),
 ARMCPUTestParams("cortex-a715", "armv9-a", "neon-fp-armv8",
  AArch64::AEK_CRC | AArch64::AEK_FP | AArch64::AEK_BF16 |
@@ -1107,7 +1107,8 @@
  AArch64::AEK_SB | AArch64::AEK_I8MM |
  AArch64::AEK_PERFMON | AArch64::AEK_PREDRES |
  AArch64::AEK_PROFILE | AArch64::AEK_FP16FML |
- AArch64::AEK_FP16 | AArch64::AEK_FLAGM,
+ AArch64::AEK_FP16 | AArch64::AEK_FLAGM |
+ AArch64::AEK_SSBS,
  "9-A"),
 ARMCPUTestParams(
 "neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
@@ -1128,7 +1129,7 @@
 AArch64::AEK_FP16 | AArch64::AEK_BF16 | AArch64::AEK_SVE2 |
 AArch64::AEK_PROFILE | AArch64::AEK_FP16FML |
 AArch64::AEK_I8MM | AArch64::AEK_SVE2BITPERM |
-AArch64::AEK_RAND,
+AArch64::AEK_RAND | AArch64::AEK_SB | AArch64::AEK_SSBS,
 "9-A"),
 ARMCPUTestParams("cortex-r82", "armv8-r", "crypto-neon-fp-armv8",
  AArch64::AEK_CRC | AArch64::AEK_RDM |
@@ -1228,7 +1229,8 @@
  AArch64::AEK_LSE | AArch64::AEK_RAS |
  AArch64::AEK_RDM | AArch64::AEK_RCPC |
  AArch64::AEK_DOTPROD | AArch64::AEK_FP16 |
- AArch64::AEK_FP16FML | AArch64::AEK_SHA3,
+ AArch64::AEK_FP16FML | AArch64::AEK_SHA3 |
+ AArch64::AEK_SB | AArch64::AEK_SSBS,
  "8.5-A"),
 ARMCPUTestParams("apple-a15", "armv8.5-a", "crypto-neon-fp-armv8",
  AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
@@ -1237,7 +1239,8 @@
  AArch64::AEK_RDM | AArch64::AEK_RCPC |
  AArch64::AEK_DOTPROD | AArch64::AEK_FP16 |
  AArch64::AEK_FP16FML | AArch64::AEK_SHA3 |
- AArch64::AEK_BF16 | AArch64::AEK_I8MM,
+ AArch64::AEK_BF16 | AArch64::AEK_I8MM |
+ AArch64::AEK_SB | AArch64::AEK_SSBS,
  "8.5-A"),
 ARMCPUTestParams("apple-a16", "armv8.5-a", "crypto-neon-fp-armv8",
  AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
@@ -1246,7 +1249,8 @@
  AArch64::AEK_RDM | AArch64::AEK_RCPC |
  AArch64::AEK_DOTPROD | AArch64::AEK_FP16 |
  AArch64::AEK_FP16FML | AArch64::AEK_SHA3 |
- AArch64::AEK_BF16 | AArch64::AEK_I8MM,
+ AArch64::AEK_BF16 | AArch64::AEK_I8MM |
+ AArch64::AEK_SB | AArch64::AEK_SSBS,
  "8.5-A"),
 ARMCPUTestParams("apple-m1", "armv8.5-a", "crypto-neon-fp-armv8",
  AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
@@ -1254,7 +1258,8 @@
  AArch64::AEK_LSE | AArch64::AEK_RAS |
  AArch64::AEK_RDM | AArch64::AEK_RCPC |
  AArch64::AEK_DOTPROD | AArch64::AEK_FP16 |
- AArch64::AEK_FP16FML | AArch64::AEK_SHA3,
+ AArch64::AEK_FP16FML | AArch64::AEK_SHA3 |
+ AArch64::AEK_SB | AArch64:

[PATCH] D141968: [NFC] Consolidate llvm::CodeGenOpt::Level handling

2023-01-23 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: llvm/include/llvm/Support/CodeGen.h:67
+  inline std::optional getLevel(IDType ID) {
+if (ID < 0 || ID > 3)
+  return std::nullopt;

scott.linder wrote:
> barannikov88 wrote:
> > As I can see, clients do not check for nullopt. Either add checks or 
> > replace this check with an assertion and drop std::optional (in this case 
> > `parseLevel` should be updated accordingly).
> > 
> > 
> Good catch! I was working off of the old behavior of `llvm::Optional` and 
> assuming the new `std::optional` was guaranteed to `assert` on dereference as 
> well. I think the right interface is to expose the `optional`, so for the 
> callsites which currently do the equivalent of asserting I will just carry 
> over an explicit assert to the new version.
> 
> I posted to 
> https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716/26
>  to discuss the issue more generally, as at least some of the patches which 
> moved code from `llvm::Optional` to `std::optional` accidentally dropped 
> assertions.
This causes massive amounts of warnings when built with GCC:
```
../include/llvm/Support/CodeGen.h:67:12: warning: comparison is always false 
due to limited range of data type [-Wtype-limits]
   67 | if (ID < 0 || ID > 3)
  | ~~~^~~
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141968

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


[PATCH] D141968: [NFC] Consolidate llvm::CodeGenOpt::Level handling

2023-01-23 Thread Scott Linder 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 rG25c0ea2a5370: [NFC] Consolidate llvm::CodeGenOpt::Level 
handling (authored by scott.linder).

Changed prior to commit:
  https://reviews.llvm.org/D141968?vs=490321&id=491515#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141968

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  flang/lib/Frontend/FrontendActions.cpp
  llvm/include/llvm/Support/CodeGen.h
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/lto/lto.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp

Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
@@ -138,20 +138,6 @@
   return createModuleFromMemoryBuffer(MB, Context);
 }
 
-CodeGenOpt::Level getCGOptLevel(unsigned OptLevel) {
-  switch (OptLevel) {
-  case 0:
-return CodeGenOpt::None;
-  case 1:
-return CodeGenOpt::Less;
-  case 2:
-return CodeGenOpt::Default;
-  case 3:
-return CodeGenOpt::Aggressive;
-  }
-  llvm_unreachable("Invalid optimization level");
-}
-
 OptimizationLevel getOptLevel(unsigned OptLevel) {
   switch (OptLevel) {
   case 0:
@@ -169,7 +155,10 @@
 Expected>
 createTargetMachine(Module &M, std::string CPU, unsigned OptLevel) {
   Triple TT(M.getTargetTriple());
-  CodeGenOpt::Level CGOptLevel = getCGOptLevel(OptLevel);
+  std::optional CGOptLevelOrNone =
+  CodeGenOpt::getLevel(OptLevel);
+  assert(CGOptLevelOrNone && "Invalid optimization level");
+  CodeGenOpt::Level CGOptLevel = *CGOptLevelOrNone;
 
   std::string Msg;
   const Target *T = TargetRegistry::lookupTarget(M.getTargetTriple(), Msg);
Index: llvm/tools/lto/lto.cpp
===
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -528,20 +528,10 @@
 if (OptLevel < '0' || OptLevel > '3')
   report_fatal_error("Optimization level must be between 0 and 3");
 CodeGen->setOptLevel(OptLevel - '0');
-switch (OptLevel) {
-case '0':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::None);
-  break;
-case '1':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Less);
-  break;
-case '2':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Default);
-  break;
-case '3':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Aggressive);
-  break;
-}
+std::optional CGOptLevelOrNone =
+CodeGenOpt::getLevel(OptLevel - '0');
+assert(CGOptLevelOrNone);
+CodeGen->setCodeGenOptLevel(*CGOptLevelOrNone);
   }
   return wrap(CodeGen);
 }
Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -306,20 +306,9 @@
   Conf.Freestanding = EnableFreestanding;
   for (auto &PluginFN : PassPlugins)
 Conf.PassPlugins.push_back(PluginFN);
-  switch (CGOptLevel) {
-  case '0':
-Conf.CGOptLevel = CodeGenOpt::None;
-break;
-  case '1':
-Conf.CGOptLevel = CodeGenOpt::Less;
-break;
-  case '2':
-Conf.CGOptLevel = CodeGenOpt::Default;
-break;
-  case '3':
-Conf.CGOptLevel = CodeGenOpt::Aggressive;
-break;
-  default:
+  if (auto Level = CodeGenOpt::parseLevel(CGOptLevel)) {
+Conf.CGOptLevel = *Level;
+  } else {
 llvm::errs() << "invalid cg optimization level: " << CGOptLevel << '\n';
 return 1;
   }
Index: llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
===
--- llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
+++ llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
@@ -42,7 +42,7 @@
 OptLevel("O",
  cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
   "(default = '-O2')"),
- cl::Prefix, cl::init(' '));
+ cl::Prefix, cl::init('2'));
 
 static cl::opt
 TargetTriple("mtriple", cl::desc("Override target triple for module"));
@@ -144,16 +144,12 @@
   std::string CPUStr = codegen::getCPUStr(),
   FeaturesStr = codegen::getFeaturesStr();
 
-  CodeGenOpt::Level OLvl = CodeGenOpt::Default;
-  switch (OptLevel) {
-  default:
+  CodeGenOpt::Level OLvl;
+  if (auto Level = CodeGenOpt::parseLevel(OptLevel)) {
+OLvl = *Level;
+  } else {
 errs() << argv[0] << ": invalid optimization level.\n";
 return 1;
-  case ' ': break;
-  case '0': OLvl = 

[clang] 25c0ea2 - [NFC] Consolidate llvm::CodeGenOpt::Level handling

2023-01-23 Thread Scott Linder via cfe-commits

Author: Scott Linder
Date: 2023-01-23T22:50:49Z
New Revision: 25c0ea2a5370813f46686918a84e0de27e107d08

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

LOG: [NFC] Consolidate llvm::CodeGenOpt::Level handling

Add free functions llvm::CodeGenOpt::{getLevel,getID,parseLevel} to
provide common implementations for functionality that has been
duplicated in many places across the codebase.

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
flang/lib/Frontend/FrontendActions.cpp
llvm/include/llvm/Support/CodeGen.h
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llc/llc.cpp
llvm/tools/lli/lli.cpp
llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
llvm/tools/llvm-lto2/llvm-lto2.cpp
llvm/tools/lto/lto.cpp
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index ecc727d6dd281..10d6bff25e6d6 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -300,21 +300,6 @@ static TargetLibraryInfoImpl *createTLII(llvm::Triple 
&TargetTriple,
   return TLII;
 }
 
-static CodeGenOpt::Level getCGOptLevel(const CodeGenOptions &CodeGenOpts) {
-  switch (CodeGenOpts.OptimizationLevel) {
-  default:
-llvm_unreachable("Invalid optimization level!");
-  case 0:
-return CodeGenOpt::None;
-  case 1:
-return CodeGenOpt::Less;
-  case 2:
-return CodeGenOpt::Default; // O2/Os/Oz
-  case 3:
-return CodeGenOpt::Aggressive;
-  }
-}
-
 static std::optional
 getCodeModel(const CodeGenOptions &CodeGenOpts) {
   unsigned CodeModel = llvm::StringSwitch(CodeGenOpts.CodeModel)
@@ -579,7 +564,10 @@ void EmitAssemblyHelper::CreateTargetMachine(bool 
MustCreateTM) {
   std::string FeaturesStr =
   llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ",");
   llvm::Reloc::Model RM = CodeGenOpts.RelocationModel;
-  CodeGenOpt::Level OptLevel = getCGOptLevel(CodeGenOpts);
+  std::optional OptLevelOrNone =
+  CodeGenOpt::getLevel(CodeGenOpts.OptimizationLevel);
+  assert(OptLevelOrNone && "Invalid optimization level!");
+  CodeGenOpt::Level OptLevel = *OptLevelOrNone;
 
   llvm::TargetOptions Options;
   if (!initTargetOptions(Diags, Options, CodeGenOpts, TargetOpts, LangOpts,
@@ -1161,7 +1149,10 @@ static void runThinLTOBackend(
   Conf.CodeModel = getCodeModel(CGOpts);
   Conf.MAttrs = TOpts.Features;
   Conf.RelocModel = CGOpts.RelocationModel;
-  Conf.CGOptLevel = getCGOptLevel(CGOpts);
+  std::optional OptLevelOrNone =
+  CodeGenOpt::getLevel(CGOpts.OptimizationLevel);
+  assert(OptLevelOrNone && "Invalid optimization level!");
+  Conf.CGOptLevel = *OptLevelOrNone;
   Conf.OptLevel = CGOpts.OptimizationLevel;
   initTargetOptions(Diags, Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts);
   Conf.SampleProfile = std::move(SampleProfile);

diff  --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp 
b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
index 5c9066c148d61..06df39dcdc479 100644
--- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -54,14 +54,11 @@ getOptLevel(const std::vector &ExtraArgs) {
   CodeGenOpt::Level OLvl = CodeGenOpt::Default;
   for (auto &A : ExtraArgs) {
 if (A[0] == '-' && A[1] == 'O') {
-  switch(A[2]) {
-case '0': OLvl = CodeGenOpt::None; break;
-case '1': OLvl = CodeGenOpt::Less; break;
-case '2': OLvl = CodeGenOpt::Default; break;
-case '3': OLvl = CodeGenOpt::Aggressive; break;
-default:
-  errs() << "error: opt level must be between 0 and 3.\n";
-  std::exit(1);
+  if (auto Level = CodeGenOpt::parseLevel(A[2])) {
+OLvl = *Level;
+  } else {
+errs() << "error: opt level must be between 0 and 3.\n";
+std::exit(1);
   }
 }
   }

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 5cae73ef543eb..57603ccef01f9 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -491,20 +491,6 @@ std::vector 
getTargetFeatures(ArrayRef InputFiles) {
   return UnifiedFeatures;
 }
 
-CodeGenOpt::Level getCGOptLevel(unsigned OptLevel) {
-  switch (OptLevel) {
-  case 0:
-return CodeGenOpt::None;
-  case 1:
-return CodeGenOpt::Less;
-  case 2:
-return CodeGenOpt::Default;
-  case 3:
-return CodeGenOpt::Aggressive;
-  }
-  llvm_unr

[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/SemaCXX/class-layout.cpp:688
 };
 #if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15
 _Static_assert(sizeof(t3) == 8, "");

hubert.reinterpretcast wrote:
> hubert.reinterpretcast wrote:
> > Because z/OS has some of the Clang 16 changes but not all, I think we can't 
> > rely on claiming that it uses the Clang 15 ABI for the purposes of the 
> > testing (and need to make a change here to say that it does follow the 
> > "Clang 15 ABI" for this aspect).
> Sorry, my last suggestion for this line should be reverted. z/OS works just 
> like Linux for this right now: no special code needed here.
> Sorry, my last suggestion for this line should be reverted. z/OS works just 
> like Linux for this right now: no special code needed here.

I was actually confused about being confused before (and now I am just very 
confused). This is the test corresponding to the changes to 
`areDefaultedSMFStillPOD`. z/OS does not work just like Linux for this part. 
Under `__MVS__`, we really should always be returning `8` for the size of `t3`. 
I am not sure how we ended up with `12` as I was told offline.



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

https://reviews.llvm.org/D142358

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


[PATCH] D142296: [clang-format] Fix bugs in parsing C++20 module import statements

2023-01-23 Thread Owen Pan 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 rG02fd0020e577: [clang-format] Fix bugs in parsing C++20 
module import statements (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142296

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12810,6 +12810,7 @@
   // But 'import' might also be a regular C++ namespace.
   verifyFormat("import::SomeFunction(aaa,\n"
" a);");
+  verifyFormat("import::Bar foo(val ? 2 : 1);");
 }
 
 //===--===//
@@ -24628,6 +24629,7 @@
   verifyFormat("import foo.bar;", Style);
   verifyFormat("import foo:bar;", Style);
   verifyFormat("import :bar;", Style);
+  verifyFormat("import /* module partition */ :bar;", Style);
   verifyFormat("import ;", Style);
   verifyFormat("import \"header\";", Style);
 
@@ -24654,6 +24656,8 @@
   verifyFormat("import", Style);
   verifyFormat("module", Style);
   verifyFormat("export", Style);
+
+  verifyFormat("import /* not keyword */ = val ? 2 : 1;");
 }
 
 TEST_F(FormatTest, CoroutineForCoawait) {
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -153,7 +153,7 @@
   void parseCaseLabel();
   void parseSwitch();
   void parseNamespace();
-  void parseModuleImport();
+  bool parseModuleImport();
   void parseNew();
   void parseAccessSpecifier();
   bool parseEnum();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -41,7 +41,7 @@
 
   // Returns the token that would be returned by the next call to
   // getNextToken().
-  virtual FormatToken *peekNextToken() = 0;
+  virtual FormatToken *peekNextToken(bool SkipComment = false) = 0;
 
   // Returns whether we are at the end of the file.
   // This can be different from whether getNextToken() returned an eof token
@@ -169,10 +169,10 @@
 return PreviousTokenSource->getPreviousToken();
   }
 
-  FormatToken *peekNextToken() override {
+  FormatToken *peekNextToken(bool SkipComment) override {
 if (eof())
   return &FakeEOF;
-return PreviousTokenSource->peekNextToken();
+return PreviousTokenSource->peekNextToken(SkipComment);
   }
 
   bool isEOF() override { return PreviousTokenSource->isEOF(); }
@@ -288,8 +288,11 @@
 return Position > 0 ? Tokens[Position - 1] : nullptr;
   }
 
-  FormatToken *peekNextToken() override {
+  FormatToken *peekNextToken(bool SkipComment) override {
 int Next = Position + 1;
+if (SkipComment)
+  while (Tokens[Next]->is(tok::comment))
+++Next;
 LLVM_DEBUG({
   llvm::dbgs() << "Peeking ";
   dbgToken(Next);
@@ -1435,7 +1438,15 @@
   return Tok->Previous && Tok->Previous->isOneOf(tok::l_paren, tok::comma);
 }
 
-void UnwrappedLineParser::parseModuleImport() {
+bool UnwrappedLineParser::parseModuleImport() {
+  assert(FormatTok->is(Keywords.kw_import) && "'import' expected");
+
+  if (auto Token = Tokens->peekNextToken(/*SkipComment=*/true);
+  !Token->Tok.getIdentifierInfo() &&
+  !Token->isOneOf(tok::colon, tok::less, tok::string_literal)) {
+return false;
+  }
+
   nextToken();
   while (!eof()) {
 if (FormatTok->is(tok::colon)) {
@@ -1462,6 +1473,7 @@
   }
 
   addUnwrappedLine();
+  return true;
 }
 
 // readTokenWithJavaScriptASI reads the next token and terminates the current
@@ -1682,14 +1694,12 @@
 }
 if (Style.isCpp()) {
   nextToken();
-  if (FormatTok->is(Keywords.kw_import)) {
-parseModuleImport();
-return;
-  }
   if (FormatTok->is(tok::kw_namespace)) {
 parseNamespace();
 return;
   }
+  if (FormatTok->is(Keywords.kw_import) && parseModuleImport())
+return;
 }
 break;
   case tok::kw_inline:
@@ -1726,10 +1736,8 @@
 addUnwrappedLine();
 return;
   }
-  if (Style.isCpp()) {
-parseModuleImport();
+  if (Style.isCpp() && parseModuleImport())
 return;
-  }
 }
 if (Style.isCpp() &&
 FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 02fd002 - [clang-format] Fix bugs in parsing C++20 module import statements

2023-01-23 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-01-23T14:35:15-08:00
New Revision: 02fd0020e5771b2850f892712b8fa51d3b98e270

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

LOG: [clang-format] Fix bugs in parsing C++20 module import statements

Also fixes #60145.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index effb0ecb368bb..6d5b92c61c78b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -41,7 +41,7 @@ class FormatTokenSource {
 
   // Returns the token that would be returned by the next call to
   // getNextToken().
-  virtual FormatToken *peekNextToken() = 0;
+  virtual FormatToken *peekNextToken(bool SkipComment = false) = 0;
 
   // Returns whether we are at the end of the file.
   // This can be 
diff erent from whether getNextToken() returned an eof token
@@ -169,10 +169,10 @@ class ScopedMacroState : public FormatTokenSource {
 return PreviousTokenSource->getPreviousToken();
   }
 
-  FormatToken *peekNextToken() override {
+  FormatToken *peekNextToken(bool SkipComment) override {
 if (eof())
   return &FakeEOF;
-return PreviousTokenSource->peekNextToken();
+return PreviousTokenSource->peekNextToken(SkipComment);
   }
 
   bool isEOF() override { return PreviousTokenSource->isEOF(); }
@@ -288,8 +288,11 @@ class IndexedTokenSource : public FormatTokenSource {
 return Position > 0 ? Tokens[Position - 1] : nullptr;
   }
 
-  FormatToken *peekNextToken() override {
+  FormatToken *peekNextToken(bool SkipComment) override {
 int Next = Position + 1;
+if (SkipComment)
+  while (Tokens[Next]->is(tok::comment))
+++Next;
 LLVM_DEBUG({
   llvm::dbgs() << "Peeking ";
   dbgToken(Next);
@@ -1435,7 +1438,15 @@ static bool isC78ParameterDecl(const FormatToken *Tok, 
const FormatToken *Next,
   return Tok->Previous && Tok->Previous->isOneOf(tok::l_paren, tok::comma);
 }
 
-void UnwrappedLineParser::parseModuleImport() {
+bool UnwrappedLineParser::parseModuleImport() {
+  assert(FormatTok->is(Keywords.kw_import) && "'import' expected");
+
+  if (auto Token = Tokens->peekNextToken(/*SkipComment=*/true);
+  !Token->Tok.getIdentifierInfo() &&
+  !Token->isOneOf(tok::colon, tok::less, tok::string_literal)) {
+return false;
+  }
+
   nextToken();
   while (!eof()) {
 if (FormatTok->is(tok::colon)) {
@@ -1462,6 +1473,7 @@ void UnwrappedLineParser::parseModuleImport() {
   }
 
   addUnwrappedLine();
+  return true;
 }
 
 // readTokenWithJavaScriptASI reads the next token and terminates the current
@@ -1682,14 +1694,12 @@ void UnwrappedLineParser::parseStructuralElement(
 }
 if (Style.isCpp()) {
   nextToken();
-  if (FormatTok->is(Keywords.kw_import)) {
-parseModuleImport();
-return;
-  }
   if (FormatTok->is(tok::kw_namespace)) {
 parseNamespace();
 return;
   }
+  if (FormatTok->is(Keywords.kw_import) && parseModuleImport())
+return;
 }
 break;
   case tok::kw_inline:
@@ -1726,10 +1736,8 @@ void UnwrappedLineParser::parseStructuralElement(
 addUnwrappedLine();
 return;
   }
-  if (Style.isCpp()) {
-parseModuleImport();
+  if (Style.isCpp() && parseModuleImport())
 return;
-  }
 }
 if (Style.isCpp() &&
 FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals,

diff  --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
index 97c5baf152fef..f043e567eb733 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -153,7 +153,7 @@ class UnwrappedLineParser {
   void parseCaseLabel();
   void parseSwitch();
   void parseNamespace();
-  void parseModuleImport();
+  bool parseModuleImport();
   void parseNew();
   void parseAccessSpecifier();
   bool parseEnum();

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index aa7ae12b6502c..b7d0a398dd432 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12810,6 +12810,7 @@ TEST_F(FormatTest, HandlesIncludeDirectives) {
   // But 'import' might also be a regular C++ namespace.
   verifyFormat("import::SomeFunction(aaa,\n"
" a);");
+  verifyFormat("import::Bar foo(val ? 2 : 1);");
 }
 
 
//===--===//
@@ -24628,6 +24

[PATCH] D142401: [Clang] Fix a crash when recursively callig a default member initializer.

2023-01-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I could not find any tests that test for this warning.




Comment at: clang/lib/Sema/SemaExpr.cpp:5914
+  runWithSufficientStackSpace(CallLoc, [&] {
+MarkDeclarationsReferencedInExpr(Init, /*SkipLocalVariables*/ true);
+  });




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142401

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


[clang] 35912ad - [clang] Fix unused variable warning in isBuiltinSupported

2023-01-23 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-01-23T23:16:45+01:00
New Revision: 35912ad39d8a0f244f36d24526ec70b8b028a6e0

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

LOG: [clang] Fix unused variable warning in isBuiltinSupported

Warnings introduced by cf1756146d386667a80501fb8161505d12950804

Added: 


Modified: 
clang/lib/Basic/Builtins.cpp

Removed: 




diff  --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp
index df0fcf23b35f..74081a7c2ec6 100644
--- a/clang/lib/Basic/Builtins.cpp
+++ b/clang/lib/Basic/Builtins.cpp
@@ -75,46 +75,49 @@ bool Builtin::Context::isBuiltinFunc(llvm::StringRef 
FuncName) {
 /// Is this builtin supported according to the given language options?
 static bool builtinIsSupported(const Builtin::Info &BuiltinInfo,
const LangOptions &LangOpts) {
-  if (bool BuiltinsUnsupported =
-  LangOpts.NoBuiltin && strchr(BuiltinInfo.Attributes, 'f') != nullptr)
+  /* Builtins Unsupported */
+  if (LangOpts.NoBuiltin && strchr(BuiltinInfo.Attributes, 'f') != nullptr)
 return false;
-  if (bool CorBuiltinsUnsupported =
-  !LangOpts.Coroutines && (BuiltinInfo.Langs & COR_LANG))
+  /* CorBuiltins Unsupported */
+  if (!LangOpts.Coroutines && (BuiltinInfo.Langs & COR_LANG))
 return false;
-  if (bool MathBuiltinsUnsupported =
-  LangOpts.NoMathBuiltin && BuiltinInfo.Header.ID == 
HeaderDesc::MATH_H)
+  /* MathBuiltins Unsupported */
+  if (LangOpts.NoMathBuiltin && BuiltinInfo.Header.ID == HeaderDesc::MATH_H)
 return false;
-  if (bool GnuModeUnsupported =
-  !LangOpts.GNUMode && (BuiltinInfo.Langs & GNU_LANG))
+  /* GnuMode Unsupported */
+  if (!LangOpts.GNUMode && (BuiltinInfo.Langs & GNU_LANG))
 return false;
-  if (bool MSModeUnsupported =
-  !LangOpts.MicrosoftExt && (BuiltinInfo.Langs & MS_LANG))
+  /* MSMode Unsupported */
+  if (!LangOpts.MicrosoftExt && (BuiltinInfo.Langs & MS_LANG))
 return false;
-  if (bool ObjCUnsupported = !LangOpts.ObjC && BuiltinInfo.Langs == OBJC_LANG)
+  /* ObjC Unsupported */
+  if (!LangOpts.ObjC && BuiltinInfo.Langs == OBJC_LANG)
 return false;
-  if (bool OclCUnsupported =
-  !LangOpts.OpenCL && (BuiltinInfo.Langs & ALL_OCL_LANGUAGES))
+  /* OpenCLC Unsupported */
+  if (!LangOpts.OpenCL && (BuiltinInfo.Langs & ALL_OCL_LANGUAGES))
 return false;
-  if (bool OclGASUnsupported =
-  !LangOpts.OpenCLGenericAddressSpace && (BuiltinInfo.Langs & OCL_GAS))
+  /* OopenCL GAS Unsupported */
+  if (!LangOpts.OpenCLGenericAddressSpace && (BuiltinInfo.Langs & OCL_GAS))
 return false;
-  if (bool OclPipeUnsupported =
-  !LangOpts.OpenCLPipes && (BuiltinInfo.Langs & OCL_PIPE))
+  /* OpenCL Pipe Unsupported */
+  if (!LangOpts.OpenCLPipes && (BuiltinInfo.Langs & OCL_PIPE))
 return false;
 
   // Device side enqueue is not supported until OpenCL 2.0. In 2.0 and higher
   // support is indicated with language option for blocks.
-  if (bool OclDSEUnsupported =
-  (LangOpts.getOpenCLCompatibleVersion() < 200 || !LangOpts.Blocks) &&
-  (BuiltinInfo.Langs & OCL_DSE))
+
+  /* OpenCL DSE Unsupported */
+  if ((LangOpts.getOpenCLCompatibleVersion() < 200 || !LangOpts.Blocks) &&
+  (BuiltinInfo.Langs & OCL_DSE))
 return false;
-  if (bool OpenMPUnsupported =
-  !LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG)
+  /* OpenMP Unsupported */
+  if (!LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG)
 return false;
-  if (bool CUDAUnsupported = !LangOpts.CUDA && BuiltinInfo.Langs == CUDA_LANG)
+  /* CUDA Unsupported */
+  if (!LangOpts.CUDA && BuiltinInfo.Langs == CUDA_LANG)
 return false;
-  if (bool CPlusPlusUnsupported =
-  !LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG)
+  /* CPlusPlus Unsupported */
+  if (!LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG)
 return false;
   return true;
 }



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


[PATCH] D141738: Add initial support for cross compile Windows runtimes under Linux when building Fuchsia clang toolchain

2023-01-23 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:95
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"

You can tell cmake to invoke lld-link, which has a /winsysroot: flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141738

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


[PATCH] D141738: Add initial support for cross compile Windows runtimes under Linux when building Fuchsia clang toolchain

2023-01-23 Thread Haowei Wu 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 rG20bb7658f53b: [Fuchsia] Build windows runtimes using cross 
compilation on Linux (authored by haowei).

Changed prior to commit:
  https://reviews.llvm.org/D141738?vs=490994&id=491508#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141738

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake


Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -93,7 +93,7 @@
   if(_cmake_system_name STREQUAL Darwin)
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo)
   elseif(is_msvc_target)
-list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib)
+list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib llvm-rc llvm-mt)
   else()
 # TODO: These tools don't fully support Mach-O format yet.
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-objcopy llvm-strip llvm-readelf)
@@ -213,6 +213,12 @@
 if(llvm-readelf IN_LIST TOOLCHAIN_TOOLS)
   list(APPEND compiler_args 
-DCMAKE_READELF=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-readelf${CMAKE_EXECUTABLE_SUFFIX})
 endif()
+if(llvm-mt IN_LIST TOOLCHAIN_TOOLS AND is_msvc_target)
+  list(APPEND compiler_args 
-DCMAKE_MT=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-mt${CMAKE_EXECUTABLE_SUFFIX})
+endif()
+if(llvm-rc IN_LIST TOOLCHAIN_TOOLS AND is_msvc_target)
+  list(APPEND compiler_args 
-DCMAKE_RC_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-rc${CMAKE_EXECUTABLE_SUFFIX})
+endif()
 list(APPEND ARG_DEPENDS ${TOOLCHAIN_TOOLS})
   endif()
 
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -69,12 +69,44 @@
   set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" 
CACHE STRING "")
 endif()
 
-if(WIN32)
+if(WIN32 OR LLVM_WINSYSROOT)
+  if((NOT WIN32) AND (NOT LLVM_VFSOVERLAY))
+message(FATAL_ERROR "LLVM_VFSOVERLAY should be defined.")
+  endif()
   set(target "x86_64-pc-windows-msvc")
 
+  if (LLVM_WINSYSROOT)
+set(WINDOWS_COMPILER_FLAGS
+  -Xclang
+  -ivfsoverlay
+  -Xclang
+  ${LLVM_VFSOVERLAY}
+  # TODO: /winsysroot should be set by HandleLLVMOptions.cmake 
automatically
+  # but it current has a bug that prevents it from working under cross
+  # compilation. Set this flag manually for now.
+  /winsysroot
+  ${LLVM_WINSYSROOT})
+string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
+set(WINDOWS_LINK_FLAGS
+/vfsoverlay:${LLVM_VFSOVERLAY}
+# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
+# so we have to manually set the libpath. We use clang-cl driver if we 
can
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
+  endif()
+
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
+  set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 
   list(APPEND RUNTIME_TARGETS "${target}")
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
@@ -84,6 +116,11 @@
   set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
+  set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_MODULE_LINK

[clang] 20bb765 - [Fuchsia] Build windows runtimes using cross compilation on Linux

2023-01-23 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-01-23T14:09:31-08:00
New Revision: 20bb7658f53b0b8db165ff4d404ede3f9b34862d

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

LOG: [Fuchsia] Build windows runtimes using cross compilation on Linux

This patch provides initial support of building Clang runtimes for
Windows when using Fuchsia Clang toolchains under Linux.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 9694a0f59856..73fa55668957 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -69,12 +69,44 @@ if(APPLE)
   set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" 
CACHE STRING "")
 endif()
 
-if(WIN32)
+if(WIN32 OR LLVM_WINSYSROOT)
+  if((NOT WIN32) AND (NOT LLVM_VFSOVERLAY))
+message(FATAL_ERROR "LLVM_VFSOVERLAY should be defined.")
+  endif()
   set(target "x86_64-pc-windows-msvc")
 
+  if (LLVM_WINSYSROOT)
+set(WINDOWS_COMPILER_FLAGS
+  -Xclang
+  -ivfsoverlay
+  -Xclang
+  ${LLVM_VFSOVERLAY}
+  # TODO: /winsysroot should be set by HandleLLVMOptions.cmake 
automatically
+  # but it current has a bug that prevents it from working under cross
+  # compilation. Set this flag manually for now.
+  /winsysroot
+  ${LLVM_WINSYSROOT})
+string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
+set(WINDOWS_LINK_FLAGS
+/vfsoverlay:${LLVM_VFSOVERLAY}
+# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
+# so we have to manually set the libpath. We use clang-cl driver if we 
can
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
+  endif()
+
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
+  set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 
   list(APPEND RUNTIME_TARGETS "${target}")
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
@@ -84,6 +116,11 @@ if(WIN32)
   set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
+  set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
 foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)

diff  --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake 
b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index bf61d6dbc497..ff6cb11f7d1b 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -93,7 +93,7 @@ function(llvm_ExternalProject_Add name source_dir)
   if(_cmake_system_name STREQUAL Darwin)
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo)
   elseif(is_msvc_target)
-list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib)
+list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib llvm-rc llvm-mt)
   else()
 # TODO: These tools don't fully support Mach-O format yet.
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-objcopy llvm-strip llvm-readelf)
@@ -213,6 +213,12 @@ function(llvm_ExternalProject_Add name source_dir)
 if(llvm-readelf IN_LIST TOOLCHAIN_TOOLS)
   list(

[PATCH] D140434: readability-const-return-type: don't diagnose a template function returning T, even if sometimes instantiated with e.g. T = const int.

2023-01-23 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a11b23c0238: readability-const-return-type: don't 
diagnose a template function returning T… (authored by suertreus, committed by 
ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140434

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -340,3 +340,18 @@
 __typeof__(const int) n21() {
   return 21;
 }
+
+template 
+struct n25 {
+  T foo() const { return 2; }
+};
+template struct n25;
+
+template 
+struct p41 {
+  const T foo() const { return 2; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const
+  // CHECK-MESSAGES: [[@LINE-2]]:3: warning: return type 'const
+  // CHECK-FIXES: T foo() const { return 2; }
+};
+template struct p41;
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -110,9 +110,10 @@
 void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
   // Find all function definitions for which the return types are `const`
   // qualified, ignoring decltype types.
-  auto NonLocalConstType = qualType(
-  unless(isLocalConstQualified()),
-  anyOf(decltypeType(), autoType(), isTypeOfType(), isTypeOfExprType()));
+  auto NonLocalConstType =
+  qualType(unless(isLocalConstQualified()),
+   anyOf(decltypeType(), autoType(), isTypeOfType(),
+ isTypeOfExprType(), substTemplateTypeParmType()));
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),


Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -340,3 +340,18 @@
 __typeof__(const int) n21() {
   return 21;
 }
+
+template 
+struct n25 {
+  T foo() const { return 2; }
+};
+template struct n25;
+
+template 
+struct p41 {
+  const T foo() const { return 2; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const
+  // CHECK-MESSAGES: [[@LINE-2]]:3: warning: return type 'const
+  // CHECK-FIXES: T foo() const { return 2; }
+};
+template struct p41;
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -110,9 +110,10 @@
 void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
   // Find all function definitions for which the return types are `const`
   // qualified, ignoring decltype types.
-  auto NonLocalConstType = qualType(
-  unless(isLocalConstQualified()),
-  anyOf(decltypeType(), autoType(), isTypeOfType(), isTypeOfExprType()));
+  auto NonLocalConstType =
+  qualType(unless(isLocalConstQualified()),
+   anyOf(decltypeType(), autoType(), isTypeOfType(),
+ isTypeOfExprType(), substTemplateTypeParmType()));
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 9a11b23 - readability-const-return-type: don't diagnose a template function returning T, even if sometimes instantiated with e.g. T = const int.

2023-01-23 Thread Yitzhak Mandelbaum via cfe-commits

Author: Andy Getzendanner
Date: 2023-01-23T22:08:12Z
New Revision: 9a11b23c0238ebfa0210ce89dee97f68ae3dfbd4

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

LOG: readability-const-return-type: don't diagnose a template function 
returning T, even if sometimes instantiated with e.g. T = const int.

It's not really a readability problem since there's no `const` to read at the 
declaration site, and returning std::remove_const_t instead usually only 
hurts readability.

Reviewed By: ymandel

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
index b63c25265d92..e92350632b55 100644
--- a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -110,9 +110,10 @@ void 
ConstReturnTypeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
   // Find all function definitions for which the return types are `const`
   // qualified, ignoring decltype types.
-  auto NonLocalConstType = qualType(
-  unless(isLocalConstQualified()),
-  anyOf(decltypeType(), autoType(), isTypeOfType(), isTypeOfExprType()));
+  auto NonLocalConstType =
+  qualType(unless(isLocalConstQualified()),
+   anyOf(decltypeType(), autoType(), isTypeOfType(),
+ isTypeOfExprType(), substTemplateTypeParmType()));
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
index 144dc00fcfea..5577060c402a 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -340,3 +340,18 @@ __typeof__(n17i) n20() {
 __typeof__(const int) n21() {
   return 21;
 }
+
+template 
+struct n25 {
+  T foo() const { return 2; }
+};
+template struct n25;
+
+template 
+struct p41 {
+  const T foo() const { return 2; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const
+  // CHECK-MESSAGES: [[@LINE-2]]:3: warning: return type 'const
+  // CHECK-FIXES: T foo() const { return 2; }
+};
+template struct p41;



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


[PATCH] D142024: [clang] Optimize clang::Builtin::Info density

2023-01-23 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

This got fixed in d1f313e73a1b33d662dbab54be76720b9c875645 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142024

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


[PATCH] D142403: [build] Force building LLVMTargetParser before other non-LLVM components.

2023-01-23 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 491506.
fpetrogalli added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

Address code review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142403

Files:
  llvm/cmake/modules/LLVMConfig.cmake.in


Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -140,9 +140,9 @@
   @llvm_config_include_buildtree_only_exports@
 endif()
 
-# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
-# on LLVM's tablegen-generated headers can always depend on this target whether
-# building in-tree with LLVM or not.
+# By creating the following targets here, subprojects that depend on
+# LLVM's tablegen-generated headers can always depend on this target
+# whether building in-tree with LLVM or not.
 if(NOT TARGET intrinsics_gen)
   add_custom_target(intrinsics_gen)
 endif()
@@ -152,6 +152,9 @@
 if(NOT TARGET acc_gen)
   add_custom_target(acc_gen)
 endif()
+if(NOT TARGET RISCVTargetParserTablegen)
+  add_custom_target(RISCVTargetParserTableGen)
+endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)


Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -140,9 +140,9 @@
   @llvm_config_include_buildtree_only_exports@
 endif()
 
-# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
-# on LLVM's tablegen-generated headers can always depend on this target whether
-# building in-tree with LLVM or not.
+# By creating the following targets here, subprojects that depend on
+# LLVM's tablegen-generated headers can always depend on this target
+# whether building in-tree with LLVM or not.
 if(NOT TARGET intrinsics_gen)
   add_custom_target(intrinsics_gen)
 endif()
@@ -152,6 +152,9 @@
 if(NOT TARGET acc_gen)
   add_custom_target(acc_gen)
 endif()
+if(NOT TARGET RISCVTargetParserTablegen)
+  add_custom_target(RISCVTargetParserTableGen)
+endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Nicole Rabjohn via Phabricator via cfe-commits
nicolerabjohn updated this revision to Diff 491505.
nicolerabjohn added a comment.

Reverting previous directive change.


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

https://reviews.llvm.org/D142358

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/SemaCXX/class-layout.cpp


Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -7,8 +7,17 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
+// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)
+
 #define SA(n, p) int a##n[(p) ? 1 : -1]
 
 struct A {
@@ -611,6 +620,8 @@
 #pragma pack(pop)
 }
 
+#endif // !defined(__MVS__) && !defined(__AIX__)
+
 namespace non_pod {
 struct t1 {
 protected:
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,7 +1968,8 @@
  FieldClass->hasAttr() ||
  Context.getLangOpts().getClangABICompat() <=
  LangOptions::ClangABI::Ver15 ||
- Target.isPS() || Target.isOSDarwin())) ||
+ Target.isPS() || Target.isOSDarwin() ||
+ Target.isOSAIX())) || 
  D->hasAttr();
 
   // When used as part of a typedef, or together with a 'packed' attribute, the
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -814,13 +814,14 @@
 
 - GCC doesn't pack non-POD members in packed structs unless the packed
   attribute is also specified on the member. Clang historically did perform
-  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  such packing. Clang now matches the gcc behavior
+  (except on Darwin, PS4 and AIX).
   You can switch back to the old ABI behavior with the flag:
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such types as non-POD (for the purposes of Itanium ABI). Clang now
-  matches the gcc behavior (except on Darwin and PS4). You can switch back to
-  the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
+  matches the gcc behavior (except on Darwin, PS4, AIX and z/OS). You can 
switch
+  back to the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
 
 OpenMP Support in Clang
 ---


Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -7,8 +7,17 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsy

[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/SemaCXX/class-layout.cpp:18
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)

dblaikie wrote:
> What's the reason this part is #ifdef'd out? Does it contain code that's 
> unsupported on these platforms?
The correct values need to be evaluated for those parts. This test was never 
run with those platforms as targets. We're trying to get the newer tests 
enabled first.


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

https://reviews.llvm.org/D142358

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/SemaCXX/class-layout.cpp:688
 };
 #if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15
 _Static_assert(sizeof(t3) == 8, "");

hubert.reinterpretcast wrote:
> Because z/OS has some of the Clang 16 changes but not all, I think we can't 
> rely on claiming that it uses the Clang 15 ABI for the purposes of the 
> testing (and need to make a change here to say that it does follow the "Clang 
> 15 ABI" for this aspect).
Sorry, my last suggestion for this line should be reverted. z/OS works just 
like Linux for this right now: no special code needed here.


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

https://reviews.llvm.org/D142358

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


[PATCH] D142403: [build] Force building LLVMTargetParser before other non-LLVM components.

2023-01-23 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D142403#4074905 , @fpetrogalli 
wrote:

> In D142403#4074885 , @tstellar 
> wrote:
>
>> This is still the wrong change IMO.  I don't know, maybe I'm not being 
>> clear, but I don't 'think you ever actually tried my suggestion in D141581 
>>  which was to leave  the 
>> RISCVTargetParserTableGen Depends as is and add the pseudo targets in 
>> llvm/cmake/modules/LLVMConfig.cmake.in.
>
> We'll get there! I think I missed the "leave the `RISCVTargetParserTableGen` 
> in the `DEPENDS`, sorry about that.

No problem!  Thanks for sticking with it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142403

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


[PATCH] D142403: [build] Force building LLVMTargetParser before other non-LLVM components.

2023-01-23 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D142403#4074885 , @tstellar wrote:

> This is still the wrong change IMO.  I don't know, maybe I'm not being clear, 
> but I don't 'think you ever actually tried my suggestion in D141581 
>  which was to leave  the 
> RISCVTargetParserTableGen Depends as is and add the pseudo targets in 
> llvm/cmake/modules/LLVMConfig.cmake.in.

We'll get there! I think I missed the "leave the `RISCVTargetParserTableGen` in 
the `DEPENDS`, sorry about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142403

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/test/SemaCXX/class-layout.cpp:18
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)

What's the reason this part is #ifdef'd out? Does it contain code that's 
unsupported on these platforms?


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

https://reviews.llvm.org/D142358

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


[PATCH] D142403: [build] Force building LLVMTargetParser before other non-LLVM components.

2023-01-23 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

This is still the wrong change IMO.  I don't know, maybe I'm not being clear, 
but I don't 'think you ever actually tried my suggestion in D141581 
 which was to leave  the 
RISCVTargetParserTableGen Depends as is and add the pseudo targets in 
llvm/cmake/modules/LLVMConfig.cmake.in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142403

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


[PATCH] D142403: [build] Force building LLVMTargetParser before other non-LLVM components.

2023-01-23 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli created this revision.
fpetrogalli added reviewers: mgorny, tstellar.
Herald added subscribers: luismarques, s.egerton, kadircet, PkmX, simoncook, 
arichardson.
Herald added a project: All.
fpetrogalli requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay, ilya-biryukov.
Herald added a project: clang.

By the time we start building clangDriver and clangBasic, we need to
make sure that the header file include `#include
"llvm/TargetParser/RISCVTargetParserDef.inc"` used by
`llvm/include/llvm/Targetparser/RISCVTargetParser.h` is created before
the .h file itself is used in the aforementioned clang components.

We opted for this solution because:

1. Adding TargetParser to the LLVM_LINK_COMPONENTS list of clangDriver

and clangBasic can incur in parallel builds, where the clang libraries
are built before LLVMTargetParser is ready. This generates errors like
`fatal error: llvm/TargetParser/RISCVTargetParserDef.inc: No such file
or directory`.

2. Using the original RISCVTargetParserTablegen as DEPENDS of

clangDriver and clangBasic breaks stand-alone builds [1] of clang
(because cmake configuration does not know about the cmake-tree of
llvm, in which RISCVTargetParserTablegen is created).

[1] https://llvm.org/docs/GettingStarted.html#stand-alone-builds

This commit is a rework of https://reviews.llvm.org/D141581, which was
reverted in https://reviews.llvm.org/rG20ffb9aaf982.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142403

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Driver/CMakeLists.txt


Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -93,7 +93,7 @@
 
   DEPENDS
   ClangDriverOptions
-  RISCVTargetParserTableGen
+  LLVMTargetParser
 
   LINK_LIBS
   clangBasic
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -110,7 +110,7 @@
 
   DEPENDS
   omp_gen
-  RISCVTargetParserTableGen
+  LLVMTargetParser
   )
 
 target_link_libraries(clangBasic


Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -93,7 +93,7 @@
 
   DEPENDS
   ClangDriverOptions
-  RISCVTargetParserTableGen
+  LLVMTargetParser
 
   LINK_LIBS
   clangBasic
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -110,7 +110,7 @@
 
   DEPENDS
   omp_gen
-  RISCVTargetParserTableGen
+  LLVMTargetParser
   )
 
 target_link_libraries(clangBasic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142393: [OpenMP] Add 'amdgpu-flat-work-group-size' to OpenMP kernels

2023-01-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9552
 F->addFnAttr("uniform-work-group-size", "true");
+  if (IsOpenMPkernel)
+F->addFnAttr("amdgpu-flat-work-group-size",

jhuber6 wrote:
> arsenm wrote:
> > jhuber6 wrote:
> > > arsenm wrote:
> > > > Probably shouldn’t check the language, just it’s a kernel. Also 
> > > > shouldn’t emit this if it’s the default 1024. I’ve been trying to cut 
> > > > down on the superfluous attribute spam
> > > There's a section for HIP above that does the same. We could probably 
> > > consolidate here for all "AMDGPU" kernels and get rid of the redundant 
> > > attribute. Maybe in a separate patch?
> > All the isCUDA || HIP || OpenMP checks scattered around are driving me 
> > crazy. A bunch of the out of tree divergent patches are just adding to 
> > them. We should just purge everything checking languages to the actual 
> > features and stop putting language names in things 
> OpenCL is the odd one out as far as I know, HIP and OpenMP are mostly 
> equivalent as far as attributes go.
OpenCL uses 256 as default max block size. This is to avoid performance 
regressions for existing apps. HIP uses 1024 by default.



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:61
+DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ,
+   "1024")));
+

we should keep the default value in Options.td instead of having multiple 
copies at different places. save as below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142393

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


[PATCH] D141463: [clang-tidy] Improve rename_check.py

2023-01-23 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked an inline comment as done.
ccotter added a comment.

Thanks for reviewing and merging my recent changes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141463

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


[PATCH] D142358: Opting out of Clang 15 ABI Changes for AIX and z/OS

2023-01-23 Thread Nicole Rabjohn via Phabricator via cfe-commits
nicolerabjohn updated this revision to Diff 491501.
nicolerabjohn added a comment.

Addressing review comments - spacing, updates to run lines, updates to a 
directive.


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

https://reviews.llvm.org/D142358

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/SemaCXX/class-layout.cpp

Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -7,8 +7,17 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+
 // expected-no-diagnostics
 
+#if !defined(__MVS__) && !defined(_AIX)
+
 #define SA(n, p) int a##n[(p) ? 1 : -1]
 
 struct A {
@@ -611,6 +620,8 @@
 #pragma pack(pop)
 }
 
+#endif // !defined(__MVS__) && !defined(__AIX__)
+
 namespace non_pod {
 struct t1 {
 protected:
@@ -674,7 +685,7 @@
 struct t3 : t1 {
   char c;
 };
-#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15
+#if (defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15) || defined(__MVS__)
 _Static_assert(sizeof(t3) == 8, "");
 #else
 _Static_assert(sizeof(t3) == 12, "");
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -773,6 +773,10 @@
   }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 // z/OS target
@@ -831,6 +835,10 @@
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
   }
+
+  bool areDefaultedSMFStillPOD(const LangOptions &) const override {
+return false;
+  }
 };
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,7 +1968,8 @@
  FieldClass->hasAttr() ||
  Context.getLangOpts().getClangABICompat() <=
  LangOptions::ClangABI::Ver15 ||
- Target.isPS() || Target.isOSDarwin())) ||
+ Target.isPS() || Target.isOSDarwin() ||
+ Target.isOSAIX())) || 
  D->hasAttr();
 
   // When used as part of a typedef, or together with a 'packed' attribute, the
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -814,13 +814,14 @@
 
 - GCC doesn't pack non-POD members in packed structs unless the packed
   attribute is also specified on the member. Clang historically did perform
-  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  such packing. Clang now matches the gcc behavior
+  (except on Darwin, PS4 and AIX).
   You can switch back to the old ABI behavior with the flag:
   ``-fclang-abi-compat=15.0``.
 - GCC allows POD types to have defaulted special members. Clang historically
   classified such types as non-POD (for the purposes of Itanium ABI). Clang now
-  matches the gcc behavior (except on Darwin and PS4). You can switch back to
-  the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
+  matches the gcc behavior (except on Darwin, PS4, AIX and z/OS). You can switch
+  back to the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
 
 OpenMP 

[PATCH] D141717: [Clang] Only emit textual LLVM-IR in device only mode

2023-01-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Can we keep the original behaviour for the older driver for HIP? Only enable 
the change for the new driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141717

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


[PATCH] D141581: [build] Fix stand-alone builds of clang.

2023-01-23 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

Reverted in https://reviews.llvm.org/rG20ffb9aaf982


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141581: [build] Fix stand-alone builds of clang.

2023-01-23 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

@fpetrogalli The solution is to add   RISCVTargetParserTableGen to the Depnds 
list of clang/lib/Driver and clang/lib/Basic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[clang] 20ffb9a - Revert "[build] Fix stand-alone builds of clang."

2023-01-23 Thread Francesco Petrogalli via cfe-commits

Author: Francesco Petrogalli
Date: 2023-01-23T22:31:34+01:00
New Revision: 20ffb9aaf982f341c1ea34808e002daa5be0df76

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

LOG: Revert "[build] Fix stand-alone builds of clang."

It breaks some builds [1] with the following error:

```
ccache /usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.build/tools/clang/lib/Basic
 
-I/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/Basic
 -I/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/include 
-I/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.build/tools/clang/include
 -I/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.build/include 
-I/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.src/llvm/include 
-fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -O3 -DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG 
-std=c++17 -MD -MT 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/RISCV.cpp.o -MF 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/RISCV.cpp.o.d -o 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/RISCV.cpp.o -c 
/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/Basic/Targets/RISCV.cpp
In file included from 
/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/Basic/Targets/RISCV.cpp:19:
/home/omp-vega20-0/bbot/openmp-offload-amdgpu-runtime/llvm.src/llvm/include/llvm/TargetParser/RISCVTargetParser.h:29:10:
 fatal error: llvm/TargetParser/RISCVTargetParserDef.inc: No such file or 
directory
   29 | #include "llvm/TargetParser/RISCVTargetParserDef.inc"
  |  ^~~~
compilation terminated.
2.225 [3029/31/825] Building CXX object 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Version.cpp.o
2.524 [3029/30/826] Building RISCVTargetParserDef.inc...
```

[1] https://lab.llvm.org/buildbot/#/builders/193/builds/25362

This reverts commit 52bcdac3b8425e20023151bb726b56fd6f62ec17.

Added: 


Modified: 
clang/lib/Basic/CMakeLists.txt
clang/lib/Driver/CMakeLists.txt
llvm/cmake/modules/LLVMConfig.cmake.in

Removed: 




diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 936709da9716a..32af83ee23f31 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -110,6 +110,7 @@ add_clang_library(clangBasic
 
   DEPENDS
   omp_gen
+  RISCVTargetParserTableGen
   )
 
 target_link_libraries(clangBasic

diff  --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 0b6ce9145c651..ba56a9323400c 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -93,6 +93,7 @@ add_clang_library(clangDriver
 
   DEPENDS
   ClangDriverOptions
+  RISCVTargetParserTableGen
 
   LINK_LIBS
   clangBasic

diff  --git a/llvm/cmake/modules/LLVMConfig.cmake.in 
b/llvm/cmake/modules/LLVMConfig.cmake.in
index bae2a07c0fb16..f1362fa032c2b 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -140,9 +140,9 @@ if(NOT TARGET LLVMSupport)
   @llvm_config_include_buildtree_only_exports@
 endif()
 
-# By creating the following targets here, subprojects that depend on
-# LLVM's tablegen-generated headers can always depend on this target
-# whether building in-tree with LLVM or not.
+# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
+# on LLVM's tablegen-generated headers can always depend on this target whether
+# building in-tree with LLVM or not.
 if(NOT TARGET intrinsics_gen)
   add_custom_target(intrinsics_gen)
 endif()
@@ -152,9 +152,6 @@ endif()
 if(NOT TARGET acc_gen)
   add_custom_target(acc_gen)
 endif()
-if(NOT TARGET RISCVTargetParserTableGen)
-  add_custom_target(RISCVTargetParserTableGen)
-endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)



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


[PATCH] D142396: [AArch64] Add the Ampere1A core

2023-01-23 Thread Philipp Tomsich via Phabricator via cfe-commits
philipp.tomsich updated this revision to Diff 491499.
philipp.tomsich added a comment.

v2 changes:

- fixes a whitespace issue
- fixes a rebase artifact on Ampere1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142396

Files:
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64MacroFusion.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/TargetParser/Host.cpp
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/TargetParser/Host.cpp
  llvm/unittests/TargetParser/TargetParserTest.cpp

Index: llvm/unittests/TargetParser/TargetParserTest.cpp
===
--- llvm/unittests/TargetParser/TargetParserTest.cpp
+++ llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1341,6 +1341,15 @@
  AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM|
  AArch64::AEK_SSBS | AArch64::AEK_SB   | AArch64::AEK_RAND,
  "8.6-A"),
+ARMCPUTestParams("ampere1a", "armv8.6-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC  | AArch64::AEK_FP   | AArch64::AEK_FP16   |
+ AArch64::AEK_SIMD | AArch64::AEK_RAS  | AArch64::AEK_LSE |
+ AArch64::AEK_RDM  | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+ AArch64::AEK_SM4  | AArch64::AEK_SHA3 | AArch64::AEK_BF16|
+ AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM|
+ AArch64::AEK_SSBS | AArch64::AEK_SB   | AArch64::AEK_RAND|
+ AArch64::AEK_MTE,
+ "8.6-A"),
 ARMCPUTestParams(
 "neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",
 AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
@@ -1403,7 +1412,7 @@
  "8.2-A")));
 
 // Note: number of CPUs includes aliases.
-static constexpr unsigned NumAArch64CPUArchs = 61;
+static constexpr unsigned NumAArch64CPUArchs = 62;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/unittests/TargetParser/Host.cpp
===
--- llvm/unittests/TargetParser/Host.cpp
+++ llvm/unittests/TargetParser/Host.cpp
@@ -117,6 +117,9 @@
   EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
   "CPU part: 0xac3"),
 "ampere1");
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
+  "CPU part: 0xac4"),
+"ampere1a");
 
   // MSM8992/4 weirdness
   StringRef MSM8992ProcCpuInfo = R"(
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -13,6 +13,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1a --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/AArch64/armv8.3a-rcpc.s
===
--- llvm/test/MC/AArch64/armv8.3a-rcpc.s
+++ llvm/test/MC/AArch64/armv8.3a-rcpc.s
@@ -7,6 +7,7 @@
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-n1 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-n2 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=ampere1 < %s 2>&1 | FileCheck %s
+// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=ampere1a < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.2a -mattr=+rcpc < %s 2>&1 | FileCheck %s
 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8.2a < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-REQ %s < %t
Index: llvm/test/MC/AArch64/armv8.2a-dotprod.s
===
--- llvm/test/MC/AArch64/armv8.2a-dotprod.s
+++ llvm/test/MC/AArch64/armv8.2a-dot

  1   2   3   4   >