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

2023-01-11 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: clang-tools-extra/clang-tidy/rename_check.py:97
 def getListOfFiles(clang_tidy_path):
-  files = glob.glob(os.path.join(clang_tidy_path, '*'))
-  for dirname in files:
-if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname, '*'))
+  files = glob.glob(os.path.join(clang_tidy_path, '**'), recursive=True)
   files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',

carlosgalvezp wrote:
> Why is this change needed? I'd expect only line 99 to be needed to fix moving 
> the test.
Ah, it's not needed, but I thought it was a bit cleaner to have both the globs 
take the same approach and be recursive, avoiding the for-loop over the 
subdirectories.


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] D141463: [clang-tidy] Improve rename_check.py

2023-01-11 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/rename_check.py:97
 def getListOfFiles(clang_tidy_path):
-  files = glob.glob(os.path.join(clang_tidy_path, '*'))
-  for dirname in files:
-if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname, '*'))
+  files = glob.glob(os.path.join(clang_tidy_path, '**'), recursive=True)
   files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',

ccotter wrote:
> carlosgalvezp wrote:
> > Why is this change needed? I'd expect only line 99 to be needed to fix 
> > moving the test.
> Ah, it's not needed, but I thought it was a bit cleaner to have both the 
> globs take the same approach and be recursive, avoiding the for-loop over the 
> subdirectories.
Ah yes I see it now, yes it's good to keep the consistency, thanks!


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] D140686: [WIP][Clang][RISCV] Update operand order for vmerge and vcompress

2023-01-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488093.
eopXD added a comment.

Rebase on top of landing of D141198 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140686

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vmerge.c

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


[PATCH] D141411: [AArch64] Make -march and target("arch=..") attributes imply dependent features

2023-01-11 Thread Dave Green 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 rG0c0127bb9f00: [AArch64] Make -march and target(arch=..) 
attributes imply dependent features (authored by dmgreen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D141411?vs=487874&id=488101#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141411

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-targetattr-arch.c
  clang/test/CodeGen/aarch64-targetattr.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.def

Index: llvm/include/llvm/TargetParser/AArch64TargetParser.def
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.def
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.def
@@ -69,28 +69,31 @@
  (AArch64::AEK_CRC | AArch64::AEK_FP |
   AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
   AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
-  AArch64::AEK_SVE2))
+  AArch64::AEK_SVE | AArch64::AEK_SVE2))
 AARCH64_ARCH("armv9.1-a", ARMV9_1A, "+v9.1a",
  (AArch64::AEK_CRC | AArch64::AEK_FP |
   AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
   AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
-  AArch64::AEK_BF16 | AArch64::AEK_I8MM | AArch64::AEK_SVE2))
+  AArch64::AEK_BF16 | AArch64::AEK_I8MM | AArch64::AEK_SVE |
+  AArch64::AEK_SVE2))
 AARCH64_ARCH("armv9.2-a", ARMV9_2A, "+v9.2a",
  (AArch64::AEK_CRC | AArch64::AEK_FP |
   AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
   AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
-  AArch64::AEK_BF16 | AArch64::AEK_I8MM | AArch64::AEK_SVE2))
+  AArch64::AEK_BF16 | AArch64::AEK_I8MM | AArch64::AEK_SVE |
+  AArch64::AEK_SVE2))
 AARCH64_ARCH("armv9.3-a", ARMV9_3A, "+v9.3a",
  (AArch64::AEK_CRC | AArch64::AEK_FP |
   AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
   AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
-  AArch64::AEK_BF16 | AArch64::AEK_I8MM | AArch64::AEK_SVE2))
+  AArch64::AEK_BF16 | AArch64::AEK_I8MM | AArch64::AEK_SVE |
+  AArch64::AEK_SVE2))
 AARCH64_ARCH("armv9.4-a", ARMV9_4A, "+v9.4a",
  (AArch64::AEK_CRC | AArch64::AEK_FP |
   AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
   AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
-  AArch64::AEK_BF16 | AArch64::AEK_I8MM | AArch64::AEK_SVE2 |
-  AArch64::AEK_RASv2))
+  AArch64::AEK_BF16 | AArch64::AEK_I8MM | AArch64::AEK_SVE |
+  AArch64::AEK_SVE2 | AArch64::AEK_RASv2))
 // For v8-R, we do not enable crypto and align with GCC that enables a more
 // minimal set of optional architecture extensions.
 AARCH64_ARCH("armv8-r", ARMV8R, "+v8r",
Index: clang/test/CodeGen/aarch64-targetattr.c
===
--- clang/test/CodeGen/aarch64-targetattr.c
+++ clang/test/CodeGen/aarch64-targetattr.c
@@ -89,10 +89,10 @@
 __attribute__((target("no-simd")))
 void nosimd() {}
 
-// CHECK: attributes #0 = { {{.*}} "target-features"="+v8.1a,+v8.2a,+v8a" }
-// CHECK: attributes #1 = { {{.*}} "target-features"="+fp-armv8,+fullfp16,+neon,+sve,+v8.1a,+v8.2a,+v8a" }
-// CHECK: attributes #2 = { {{.*}} "target-features"="+fp-armv8,+fullfp16,+neon,+sve,+sve2,+v8.1a,+v8.2a,+v8a" }
-// CHECK: attributes #3 = { {{.*}} "target-features"="+fp-armv8,+fullfp16,+neon,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a" }
+// CHECK: attributes #0 = { {{.*}} "target-features"="+crc,+fp-armv8,+lse,+neon,+ras,+rdm,+v8.1a,+v8.2a,+v8a" }
+// CHECK: attributes #1 = { {{.*}} "target-features"="+crc,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sve,+v8.1a,+v8.2a,+v8a" }
+// CHECK: attributes #2 = { {{.*}} "target-features"="+crc,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sve,+sve2,+v8.1a,+v8.2a,+v8a" }
+// CHECK: attributes #3 = { {{.*}} "target-features"="+aes,+bf16,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a" }
 // CHECK: attributes #4 = { {{.*}} "target-cpu"="cortex-a710" "target-features"="+bf16,+crc,+dotprod,+flagm,+fp-armv8,+fp16fml,+i8mm,+lse,+mte,+neon,+pauth,+ras,+rcpc,+rdm,+sb,+sve,+sve2,+sve2-bitperm" }
 // CHECK: attributes #5 = { {{.*}} "tune-cpu"="cortex-a710" }
 // CHECK: attributes #6 = { {{.*}} "target-cpu"="generic" }
@@ -104,6 +104,6 @@
 // CHECK: attributes #12 = { {{.*}} "target-features"="+fp-armv8,+full

[clang] 0c0127b - [AArch64] Make -march and target(arch=..) attributes imply dependent features

2023-01-11 Thread David Green via cfe-commits

Author: David Green
Date: 2023-01-11T08:48:23Z
New Revision: 0c0127bb9f0098752a9769748511e170ed240695

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

LOG: [AArch64] Make -march and target(arch=..) attributes imply dependent 
features

Specifying an architecture revision should also add feature strings for
any dependent default extensions. Otherwise the new checks for
target-dependent features for acle intrinsics from D134353 and D132034
can fail.

This patch does that in setFeatureEnabled, similar to the addition of
dependent architecture revisions. +sve also needs to be added to armv9
architectures in the target parser, as it is implied by +sve2.

Fixes #59911

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

Added: 
clang/test/CodeGen/aarch64-targetattr-arch.c

Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/test/CodeGen/aarch64-targetattr.c
llvm/include/llvm/TargetParser/AArch64TargetParser.def

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 5db313813a76a..a4b27bb64ab8d 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -736,17 +736,33 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) 
const {
 void AArch64TargetInfo::setFeatureEnabled(llvm::StringMap &Features,
   StringRef Name, bool Enabled) const {
   Features[Name] = Enabled;
+
+  // If the feature is an architecture feature (like v8.2a), add all previous
+  // architecture versions and any dependant target features.
   llvm::AArch64::ArchKind AK = llvm::AArch64::getSubArchArchKind(Name);
-  // Add all previous architecture versions.
+  if (AK == llvm::AArch64::ArchKind::INVALID)
+return;
   // In case of v9.x the v8.x counterparts are added too.
   if ("9" == getArchVersionString(AK))
 for (llvm::AArch64::ArchKind I = llvm::AArch64::convertV9toV8(AK);
  I != llvm::AArch64::ArchKind::INVALID; --I)
   Features[llvm::AArch64::getSubArch(I)] = Enabled;
 
-  for (llvm::AArch64::ArchKind I = --AK; I != llvm::AArch64::ArchKind::INVALID;
-   --I)
+  llvm::AArch64::ArchKind I = AK;
+  for (--I; I != llvm::AArch64::ArchKind::INVALID; --I)
 Features[llvm::AArch64::getSubArch(I)] = Enabled;
+
+  // Set any features implied by the architecture
+  uint64_t Extensions = llvm::AArch64::getDefaultExtensions("generic", AK);
+  std::vector CPUFeats;
+  if (llvm::AArch64::getExtensionFeatures(Extensions, CPUFeats)) {
+for (auto F : CPUFeats) {
+  assert(F[0] == '+' && "Expected + in target feature!");
+  if (F == "+crypto")
+continue;
+  Features[F.drop_front(1)] = true;
+}
+  }
 }
 
 bool AArch64TargetInfo::handleTargetFeatures(std::vector 
&Features,

diff  --git a/clang/test/CodeGen/aarch64-targetattr-arch.c 
b/clang/test/CodeGen/aarch64-targetattr-arch.c
new file mode 100644
index 0..059036dfcc6fc
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-targetattr-arch.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-eabi -target-feature +v8a -verify -DHAS8 -S 
%s -o -
+// RUN: %clang_cc1 -triple aarch64-eabi -target-feature +v8.1a -verify -DHAS81 
-S %s -o -
+// RUN: %clang_cc1 -triple aarch64-eabi -target-feature +v9a -verify -DHAS9 -S 
%s -o -
+
+#ifdef HAS9
+// expected-no-diagnostics
+#endif
+
+#include 
+#include 
+
+__attribute__((target("arch=armv8.1-a")))
+int test_crc_attr()
+{
+  return __crc32cd(1, 1);
+}
+
+__attribute__((target("arch=armv9-a")))
+svint8_t test_svadd_attr(svbool_t pg, svint8_t op1, svint8_t op2)
+{
+  return svadd_s8_z(pg, op1, op2);
+}
+
+svint8_t test_errors(svbool_t pg, svint8_t op1, svint8_t op2)
+{
+#ifdef HAS8
+// expected-error@+2{{always_inline function '__crc32cd' requires target 
feature 'crc'}}
+#endif
+  __crc32cd(1, 1);
+#if defined(HAS8) || defined(HAS81)
+// expected-error@+2{{'svadd_s8_z' needs target feature sve}}
+#endif
+  return svadd_s8_z(pg, op1, op2);
+}

diff  --git a/clang/test/CodeGen/aarch64-targetattr.c 
b/clang/test/CodeGen/aarch64-targetattr.c
index 88af5cc5bc8da..8730ecfbd1343 100644
--- a/clang/test/CodeGen/aarch64-targetattr.c
+++ b/clang/test/CodeGen/aarch64-targetattr.c
@@ -89,10 +89,10 @@ void noneon() {}
 __attribute__((target("no-simd")))
 void nosimd() {}
 
-// CHECK: attributes #0 = { {{.*}} "target-features"="+v8.1a,+v8.2a,+v8a" }
-// CHECK: attributes #1 = { {{.*}} 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve,+v8.1a,+v8.2a,+v8a" }
-// CHECK: attributes #2 = { {{.*}} 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve,+sve2,+v8.1a,+v8.2a,+v8a" }
-// CHECK: attributes #3 = { {{.*}} 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 }
+// CHECK: attributes #0 = { {{.*}} 
"t

[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to enable/disable ExternalNameConversionPass

2023-01-11 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

You should have a look at 
https://mlir.llvm.org/docs/PassManagement/#instance-specific-pass-options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140795

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


[PATCH] D141467: [clang][Driver][CUDA] Get rid of unused LibPath

2023-01-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: tra.
Herald added subscribers: mattd, yaxunl.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

LibPath discovered during InstallationDetection wasn't used anywhere.
Moreover it actually resulted in discarding installations that don't have any
`/lib` directory.

This is causing troubles for our pipelines downstream, that want to perform
syntax-only analysis on the sources.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141467

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h


Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -31,7 +31,6 @@
   CudaVersion Version = CudaVersion::UNKNOWN;
   std::string InstallPath;
   std::string BinPath;
-  std::string LibPath;
   std::string LibDevicePath;
   std::string IncludePath;
   llvm::StringMap LibDeviceMap;
@@ -69,8 +68,6 @@
   StringRef getBinPath() const { return BinPath; }
   /// Get the detected Cuda Include path.
   StringRef getIncludePath() const { return IncludePath; }
-  /// Get the detected Cuda library path.
-  StringRef getLibPath() const { return LibPath; }
   /// Get the detected Cuda device library path.
   StringRef getLibDevicePath() const { return LibDevicePath; }
   /// Get libdevice file for given architecture
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -194,19 +194,6 @@
 if (CheckLibDevice && !FS.exists(LibDevicePath))
   continue;
 
-// On Linux, we have both lib and lib64 directories, and we need to choose
-// based on our triple.  On MacOS, we have only a lib directory.
-//
-// It's sufficient for our purposes to be flexible: If both lib and lib64
-// exist, we choose whichever one matches our triple.  Otherwise, if only
-// lib exists, we use it.
-if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
-  LibPath = InstallPath + "/lib64";
-else if (FS.exists(InstallPath + "/lib"))
-  LibPath = InstallPath + "/lib";
-else
-  continue;
-
 Version = CudaVersion::UNKNOWN;
 if (auto CudaHFile = FS.getBufferForFile(InstallPath + "/include/cuda.h"))
   Version = parseCudaHFile((*CudaHFile)->getBuffer());


Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -31,7 +31,6 @@
   CudaVersion Version = CudaVersion::UNKNOWN;
   std::string InstallPath;
   std::string BinPath;
-  std::string LibPath;
   std::string LibDevicePath;
   std::string IncludePath;
   llvm::StringMap LibDeviceMap;
@@ -69,8 +68,6 @@
   StringRef getBinPath() const { return BinPath; }
   /// Get the detected Cuda Include path.
   StringRef getIncludePath() const { return IncludePath; }
-  /// Get the detected Cuda library path.
-  StringRef getLibPath() const { return LibPath; }
   /// Get the detected Cuda device library path.
   StringRef getLibDevicePath() const { return LibDevicePath; }
   /// Get libdevice file for given architecture
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -194,19 +194,6 @@
 if (CheckLibDevice && !FS.exists(LibDevicePath))
   continue;
 
-// On Linux, we have both lib and lib64 directories, and we need to choose
-// based on our triple.  On MacOS, we have only a lib directory.
-//
-// It's sufficient for our purposes to be flexible: If both lib and lib64
-// exist, we choose whichever one matches our triple.  Otherwise, if only
-// lib exists, we use it.
-if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
-  LibPath = InstallPath + "/lib64";
-else if (FS.exists(InstallPath + "/lib"))
-  LibPath = InstallPath + "/lib";
-else
-  continue;
-
 Version = CudaVersion::UNKNOWN;
 if (auto CudaHFile = FS.getBufferForFile(InstallPath + "/include/cuda.h"))
   Version = parseCudaHFile((*CudaHFile)->getBuffer());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cf7a830 - [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

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

Author: Francesco Petrogalli
Date: 2023-01-11T10:00:04+01:00
New Revision: cf7a8305a2b4ddfd299c748136cb9a2960ef7089

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

LOG: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

This patch removes the file 
`llvm/include/llvm/TargetParser/RISCVTargetParser.def` and replaces it with a 
tablegen-generated `.inc` file out of `llvm/lib/Target/RISCV/RISCV.td`.

The module system has been updated to make sure we can build clang/llvm with 
`-DLLVM_ENABLE_MODULES=On`

Reviewed By: craig.topper

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

Added: 
llvm/include/llvm/TargetParser/CMakeLists.txt
llvm/include/llvm/TargetParser/RISCVTargetParser.h
llvm/lib/TargetParser/RISCVTargetParser.cpp
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp

Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
llvm/include/llvm/CMakeLists.txt
llvm/include/llvm/TargetParser/TargetParser.h
llvm/include/llvm/module.extern.modulemap
llvm/include/llvm/module.install.modulemap
llvm/include/llvm/module.modulemap
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/TargetParser/CMakeLists.txt
llvm/lib/TargetParser/TargetParser.cpp
llvm/utils/TableGen/CMakeLists.txt
llvm/utils/TableGen/TableGen.cpp
llvm/utils/TableGen/TableGenBackends.h

Removed: 
llvm/include/llvm/TargetParser/RISCVTargetParser.def



diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 7713398c83b20..a9adafddb7e54 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -15,8 +15,8 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 #include 
 
 using namespace clang;

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 4724e5c5a37ec..5c11064d81d59 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -17,8 +17,8 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/RISCVISAInfo.h"
-#include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;

diff  --git a/llvm/include/llvm/CMakeLists.txt 
b/llvm/include/llvm/CMakeLists.txt
index b46319f24fc8e..d1dc0a99463ba 100644
--- a/llvm/include/llvm/CMakeLists.txt
+++ b/llvm/include/llvm/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_subdirectory(IR)
 add_subdirectory(Support)
 add_subdirectory(Frontend)
+add_subdirectory(TargetParser)
 
 # If we're doing an out-of-tree build, copy a module map for generated
 # header files into the build area.

diff  --git a/llvm/include/llvm/TargetParser/CMakeLists.txt 
b/llvm/include/llvm/TargetParser/CMakeLists.txt
new file mode 100644
index 0..d102dcf4dde7e
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/CMakeLists.txt
@@ -0,0 +1,4 @@
+set(LLVM_TARGET_DEFINITIONS ${CMAKE_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
+tablegen(LLVM RISCVTargetParserDef.inc -gen-riscv-target-def -I 
${CMAKE_SOURCE_DIR}/lib/Target/RISCV/)
+add_public_tablegen_target(RISCVTargetParserTableGen)
+

diff  --git a/llvm/include/llvm/TargetParser/RISCVTargetParser.def 
b/llvm/include/llvm/TargetParser/RISCVTargetParser.def
deleted file mode 100644
index 6d65ac1c398e7..0
--- a/llvm/include/llvm/TargetParser/RISCVTargetParser.def
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef PROC
-#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)
-#endif
-
-PROC(INVALID, {"invalid"}, FK_INVALID, {""})
-PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""})
-PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""})
-PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""})
-PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""})
-PROC(SIFIVE_E20, {"sifive-e20"}, FK_NONE, {"rv32imc"})
-PROC(SIFIVE_E21, {"sifive-e21"}, FK_NONE, {"rv32imac"})
-PROC(SIFIVE_E24, {"sifive-e24"}, FK_NONE, {"rv32imafc"})
-PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
-PROC(SIFIVE_E34, {"sifive-e34"}, FK_NONE, {"rv32imafc"})
-PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
-PROC(SIFIVE_S21, {"sifive-s21"}, FK_64BIT, {"rv64imac"})
-PROC(SIFIVE_S51, {"sifive-s51"}, FK_64BIT, {"rv64imac"})
-PROC(SIFIVE_S54, {"sifive-s54"}, FK_64BIT, {"rv64gc"})
-PROC(SIFIVE_S76, {"sifive-s76"}, FK_64BIT, {"rv64gc"})
-PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
-PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64g

[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2023-01-11 Thread Francesco Petrogalli via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf7a8305a2b4: [TargetParser] Generate the defs for RISCV 
CPUs using llvm-tblgen. (authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/include/llvm/CMakeLists.txt
  llvm/include/llvm/TargetParser/CMakeLists.txt
  llvm/include/llvm/TargetParser/RISCVTargetParser.def
  llvm/include/llvm/TargetParser/RISCVTargetParser.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/include/llvm/module.extern.modulemap
  llvm/include/llvm/module.install.modulemap
  llvm/include/llvm/module.modulemap
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/RISCVTargetParser.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
  llvm/utils/TableGen/TableGen.cpp
  llvm/utils/TableGen/TableGenBackends.h

Index: llvm/utils/TableGen/TableGenBackends.h
===
--- llvm/utils/TableGen/TableGenBackends.h
+++ llvm/utils/TableGen/TableGenBackends.h
@@ -94,6 +94,7 @@
 void EmitDirectivesDecl(RecordKeeper &RK, raw_ostream &OS);
 void EmitDirectivesImpl(RecordKeeper &RK, raw_ostream &OS);
 void EmitDXILOperation(RecordKeeper &RK, raw_ostream &OS);
+void EmitRISCVTargetDef(const RecordKeeper &RK, raw_ostream &OS);
 
 } // End llvm namespace
 
Index: llvm/utils/TableGen/TableGen.cpp
===
--- llvm/utils/TableGen/TableGen.cpp
+++ llvm/utils/TableGen/TableGen.cpp
@@ -58,6 +58,7 @@
   GenDirectivesEnumDecl,
   GenDirectivesEnumImpl,
   GenDXILOperation,
+  GenRISCVTargetDef,
 };
 
 namespace llvm {
@@ -141,8 +142,9 @@
 clEnumValN(GenDirectivesEnumImpl, "gen-directive-impl",
"Generate directive related implementation code"),
 clEnumValN(GenDXILOperation, "gen-dxil-operation",
-   "Generate DXIL operation information")));
-
+   "Generate DXIL operation information"),
+clEnumValN(GenRISCVTargetDef, "gen-riscv-target-def",
+   "Generate the list of CPU for RISCV")));
 cl::OptionCategory PrintEnumsCat("Options for -print-enums");
 cl::opt Class("class", cl::desc("Print Enum list for this class"),
cl::value_desc("class name"),
@@ -278,6 +280,9 @@
   case GenDXILOperation:
 EmitDXILOperation(Records, OS);
 break;
+  case GenRISCVTargetDef:
+EmitRISCVTargetDef(Records, OS);
+break;
   }
 
   return false;
Index: llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
===
--- /dev/null
+++ llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
@@ -0,0 +1,62 @@
+//===- RISCVTargetDefEmitter.cpp - Generate lists of RISCV CPUs ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This tablegen backend emits the include file needed by the target
+// parser to parse the RISC-V CPUs.
+//
+//===--===//
+
+#include "TableGenBackends.h"
+#include "llvm/TableGen/Record.h"
+
+using namespace llvm;
+
+static std::string getEnumFeatures(const Record &Rec) {
+  std::vector Features = Rec.getValueAsListOfDefs("Features");
+  if (find_if(Features, [](const Record *R) {
+return R->getName() == "Feature64Bit";
+  }) != Features.end())
+return "FK_64BIT";
+
+  return "FK_NONE";
+}
+
+void llvm::EmitRISCVTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
+  using MapTy = std::pair>;
+  using RecordMap = std::map, std::less<>>;
+  const RecordMap &Map = RK.getDefs();
+
+  OS << "#ifndef PROC\n"
+ << "#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)\n"
+ << "#endif\n\n";
+
+  OS << "PROC(INVALID, {\"invalid\"}, FK_INVALID, {\"\"})\n";
+  // Iterate on all definition records.
+  for (const MapTy &Def : Map) {
+const Record &Rec = *(Def.second);
+if (Rec.isSubClassOf("RISCVProcessorModel"))
+  OS << "PROC(" << Rec.getName() << ", "
+ << "{\"" << Rec.getValueAsString("Name") << "\"},"
+ << getEnumFeatures(Rec) << ", "
+ << "{\"" << Rec.getValueAsString("DefaultMarch") << "\"})\n";
+  }
+  OS << "\n#undef PROC\n";
+  OS << "\n";
+  OS << "#ifndef TUNE_PROC\n"
+ << "#define TUNE_PROC(ENUM, NAME)\n"
+ << "#endif\n\n";
+  OS << "TUNE_PROC(GENERIC, \"generic\")\n";
+  for (const MapTy &Def : Map) {
+const Record &Rec = *(De

[clang] 8bd65e5 - Revert "[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen."

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

Author: Francesco Petrogalli
Date: 2023-01-11T10:22:56+01:00
New Revision: 8bd65e535fb33bc48805bafed8217b16a853e158

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

LOG: Revert "[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen."

This reverts commit cf7a8305a2b4ddfd299c748136cb9a2960ef7089.

Added: 
llvm/include/llvm/TargetParser/RISCVTargetParser.def

Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
llvm/include/llvm/CMakeLists.txt
llvm/include/llvm/TargetParser/TargetParser.h
llvm/include/llvm/module.extern.modulemap
llvm/include/llvm/module.install.modulemap
llvm/include/llvm/module.modulemap
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/TargetParser/CMakeLists.txt
llvm/lib/TargetParser/TargetParser.cpp
llvm/utils/TableGen/CMakeLists.txt
llvm/utils/TableGen/TableGen.cpp
llvm/utils/TableGen/TableGenBackends.h

Removed: 
llvm/include/llvm/TargetParser/CMakeLists.txt
llvm/include/llvm/TargetParser/RISCVTargetParser.h
llvm/lib/TargetParser/RISCVTargetParser.cpp
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp



diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index a9adafddb7e54..7713398c83b20 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -15,8 +15,8 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/RISCVTargetParser.h"
 #include 
 
 using namespace clang;

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 5c11064d81d59..4724e5c5a37ec 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -17,8 +17,8 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/RISCVISAInfo.h"
+#include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/RISCVTargetParser.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;

diff  --git a/llvm/include/llvm/CMakeLists.txt 
b/llvm/include/llvm/CMakeLists.txt
index d1dc0a99463ba..b46319f24fc8e 100644
--- a/llvm/include/llvm/CMakeLists.txt
+++ b/llvm/include/llvm/CMakeLists.txt
@@ -1,7 +1,6 @@
 add_subdirectory(IR)
 add_subdirectory(Support)
 add_subdirectory(Frontend)
-add_subdirectory(TargetParser)
 
 # If we're doing an out-of-tree build, copy a module map for generated
 # header files into the build area.

diff  --git a/llvm/include/llvm/TargetParser/CMakeLists.txt 
b/llvm/include/llvm/TargetParser/CMakeLists.txt
deleted file mode 100644
index d102dcf4dde7e..0
--- a/llvm/include/llvm/TargetParser/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-set(LLVM_TARGET_DEFINITIONS ${CMAKE_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
-tablegen(LLVM RISCVTargetParserDef.inc -gen-riscv-target-def -I 
${CMAKE_SOURCE_DIR}/lib/Target/RISCV/)
-add_public_tablegen_target(RISCVTargetParserTableGen)
-

diff  --git a/llvm/include/llvm/TargetParser/RISCVTargetParser.def 
b/llvm/include/llvm/TargetParser/RISCVTargetParser.def
new file mode 100644
index 0..6d65ac1c398e7
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/RISCVTargetParser.def
@@ -0,0 +1,35 @@
+#ifndef PROC
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)
+#endif
+
+PROC(INVALID, {"invalid"}, FK_INVALID, {""})
+PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""})
+PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""})
+PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""})
+PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""})
+PROC(SIFIVE_E20, {"sifive-e20"}, FK_NONE, {"rv32imc"})
+PROC(SIFIVE_E21, {"sifive-e21"}, FK_NONE, {"rv32imac"})
+PROC(SIFIVE_E24, {"sifive-e24"}, FK_NONE, {"rv32imafc"})
+PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
+PROC(SIFIVE_E34, {"sifive-e34"}, FK_NONE, {"rv32imafc"})
+PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
+PROC(SIFIVE_S21, {"sifive-s21"}, FK_64BIT, {"rv64imac"})
+PROC(SIFIVE_S51, {"sifive-s51"}, FK_64BIT, {"rv64imac"})
+PROC(SIFIVE_S54, {"sifive-s54"}, FK_64BIT, {"rv64gc"})
+PROC(SIFIVE_S76, {"sifive-s76"}, FK_64BIT, {"rv64gc"})
+PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
+PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
+PROC(SYNTACORE_SCR1_BASE, {"syntacore-scr1-base"}, FK_NONE, {"rv32ic"})
+PROC(SYNTACORE_SCR1_MAX, {"syntacore-scr1-max"}, FK_NONE, {"rv32imc"})
+
+#undef PROC
+
+#ifndef TUNE_PROC
+#define TUNE_PROC(ENUM, NAME)
+#endif
+
+TUNE_PROC(GENERIC, "generic")
+TUNE_PROC(ROCKET, "rocket")
+TUNE_PROC(S

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

2023-01-11 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

@aaron.ballman Hi Aaron, since you requested an RFC for this. I wonder if you 
have any comments for this or the other related patches: D122215 
, D139010 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D141375: [SYCL][OpenMP] Fix compilation errors for unsupported __bf16 intrinsics

2023-01-11 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

In D141375#4041360 , @bader wrote:

> LGTM.
> I expect this to be a common issue for all single-source offloading 
> programming models (i.e. CUDA and HIP in addition to SYCL and OpenMP 
> offload). Probably we can generalize the code patterns used in this patch for 
> all of them.

Looks like CUDA added support for the type  - https://reviews.llvm.org/D136311, 
https://reviews.llvm.org/rG678d8946ba2ba790c4c52e96e2134ee136e30057.

>> In addition to that, there are other built-in data types not supported 
>> either by host or device, which are handled similar way. Right?

Yes. Code added here is similar to code added for other unsupported types like 
__float128


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

https://reviews.llvm.org/D141375

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

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

After submitting this, I had to revert it 

 because of failures like 
https://lab.llvm.org/buildbot/#/builders/225/builds/12367/steps/5/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D141056: [SVE][CGBuiltins] Remove need for instcombine from ACLE tests.

2023-01-11 Thread David Sherwood via Phabricator via cfe-commits
david-arm added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9092
+  if (BytesPerElt > 1) {
+Value *Scale = ConstantInt::get(Int64Ty, Log2_32(BytesPerElt));
+Ops[2] = Builder.CreateShl(Ops[2], Scale);

Given this seems a frequent idiom is it worth putting this into a helper 
routine? i.e. something like

  Ops[2] = getScaledOffset(Ops[2], BytesPerElt);

where

  Value *getScaledOffset(SDValue Offset, unsigned Bytes) {
Value *Scale = ConstantInt::get(Int64Ty, Log2_32(Bytes));
return Builder.CreateShl(Offset, Scale);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141056

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


[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for fixing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

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


[clang] 1bb8021 - [AArch64] Add REQUIRES: aarch64-registered-target to aarch64-targetattr-arch.c. NFC

2023-01-11 Thread David Green via cfe-commits

Author: David Green
Date: 2023-01-11T10:10:01Z
New Revision: 1bb80214b63007784d7eab93835ebc4ac5da7b69

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

LOG: [AArch64] Add REQUIRES: aarch64-registered-target to 
aarch64-targetattr-arch.c. NFC

Added: 


Modified: 
clang/test/CodeGen/aarch64-targetattr-arch.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-targetattr-arch.c 
b/clang/test/CodeGen/aarch64-targetattr-arch.c
index 059036dfcc6f..c7fa8e878550 100644
--- a/clang/test/CodeGen/aarch64-targetattr-arch.c
+++ b/clang/test/CodeGen/aarch64-targetattr-arch.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple aarch64-eabi -target-feature +v8a -verify -DHAS8 -S 
%s -o -
 // RUN: %clang_cc1 -triple aarch64-eabi -target-feature +v8.1a -verify -DHAS81 
-S %s -o -
 // RUN: %clang_cc1 -triple aarch64-eabi -target-feature +v9a -verify -DHAS9 -S 
%s -o -
+// REQUIRES: aarch64-registered-target
 
 #ifdef HAS9
 // expected-no-diagnostics



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


[PATCH] D141472: [clang][Interp] Add function pointers

2023-01-11 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, tahonermann, erichkeane, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This adds a `FunctionPointer` class as well as a new `FnPtr` primtype.

It also adds a `CallPtr` opcode that pops a `FunctionPointer` from the stack 
and calls its function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141472

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/FunctionPointer.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpStack.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.cpp
  clang/lib/AST/Interp/PrimType.h
  clang/test/AST/Interp/functions.cpp

Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -99,3 +99,58 @@
   huh(); // expected-error {{use of undeclared identifier}} \
  // ref-error {{use of undeclared identifier}}
 }
+
+namespace FunctionPointers {
+  constexpr int add(int a, int b) {
+return a + b;
+  }
+
+  struct S { int a; };
+  constexpr S getS() {
+return S{12};
+  }
+
+  constexpr int applyBinOp(int a, int b, int (*op)(int, int)) {
+return op(a, b);
+  }
+  static_assert(applyBinOp(1, 2, add) == 3, "");
+
+  constexpr int ignoreReturnValue() {
+int (*foo)(int, int) = add;
+
+foo(1, 2);
+return 1;
+  }
+  static_assert(ignoreReturnValue() == 1, "");
+
+  constexpr int createS(S (*gimme)()) {
+gimme(); // Ignored return value
+return gimme().a;
+  }
+  static_assert(createS(getS) == 12, "");
+
+namespace FunctionReturnType {
+  typedef int (*ptr)(int*);
+  typedef ptr (*pm)();
+
+  constexpr int fun1(int* y) {
+  return *y + 10;
+  }
+  constexpr ptr fun() {
+  return &fun1;
+  }
+  static_assert(fun() == nullptr, ""); // expected-error {{static assertion failed}} \
+   // ref-error {{static assertion failed}}
+
+  constexpr int foo() {
+int (*f)(int *) = fun();
+int m = 0;
+
+m = f(&m);
+
+return m;
+  }
+  static_assert(foo() == 10);
+}
+
+}
Index: clang/lib/AST/Interp/PrimType.h
===
--- clang/lib/AST/Interp/PrimType.h
+++ clang/lib/AST/Interp/PrimType.h
@@ -24,6 +24,7 @@
 namespace interp {
 
 class Pointer;
+class FunctionPointer;
 
 /// Enumeration of the primitive types of the VM.
 enum PrimType : unsigned {
@@ -38,6 +39,7 @@
   PT_Bool,
   PT_Float,
   PT_Ptr,
+  PT_FnPtr,
 };
 
 /// Mapping from primitive types to their representation.
@@ -53,6 +55,7 @@
 template <> struct PrimConv { using T = Floating; };
 template <> struct PrimConv { using T = Boolean; };
 template <> struct PrimConv { using T = Pointer; };
+template <> struct PrimConv { using T = FunctionPointer; };
 
 /// Returns the size of a primitive type in bytes.
 size_t primSize(PrimType Type);
@@ -90,6 +93,7 @@
   TYPE_SWITCH_CASE(PT_Float, B)\
   TYPE_SWITCH_CASE(PT_Bool, B) \
   TYPE_SWITCH_CASE(PT_Ptr, B)  \
+  TYPE_SWITCH_CASE(PT_FnPtr, B)\
 }  \
   } while (0)
 #define COMPOSITE_TYPE_SWITCH(Expr, B, D)  \
Index: clang/lib/AST/Interp/PrimType.cpp
===
--- clang/lib/AST/Interp/PrimType.cpp
+++ clang/lib/AST/Interp/PrimType.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "PrimType.h"
+#include "FunctionPointer.h"
 #include "Pointer.h"
 
 using namespace clang;
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -27,6 +27,7 @@
 def Uint64 : Type;
 def Float : Type;
 def Ptr : Type;
+def FnPtr : Type;
 
 //===--===//
 // Types transferred to the interpreter.
@@ -77,7 +78,7 @@
 }
 
 def PtrTypeClass : TypeClass {
-  let Types = [Ptr];
+  let Types = [Ptr, FnPtr];
 }
 
 def BoolTypeClass : TypeClass {
@@ -187,6 +188,12 @@
   let ChangesPC = 1;
 }
 
+def CallPtr : Opcode {
+  let Args = [];
+  let Types = [];
+  let ChangesPC = 1;
+}
+
 //===--===//
 // Frame management
 //===--===//
@@ -228,6 +235,7 @@
 // [] -> [Pointer]
 def Null : Opcode {
   let Types = [P

[clang] ac1ffd3 - [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

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

Author: Francesco Petrogalli
Date: 2023-01-11T11:18:44+01:00
New Revision: ac1ffd3caca12c254e0b8c847aa8ce8e51b6cfbf

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

LOG: [TargetParser]  Generate the defs for RISCV CPUs using llvm-tblgen.

Rework the change to prevent build failures. NFCI.

The failing code was submitted as
cf7a8305a2b4ddfd299c748136cb9a2960ef7089 and reverted via
8bd65e535fb33bc48805bafed8217b16a853e158.

The rework in this new commit prevents failures like the following:

FAILED: tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/RISCV.cpp.o
/usr/bin/c++  [bunch of non interesting stuff]  -c 
/llvm-project/clang/lib/Basic/Targets/RISCV.cpp
In file included from 
/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:19:
/llvm-project/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"
 |  ^~~~

These failures happen because the library LLVMTargetParser depends on
RISCVTargetParserTableGen, which is a tablegen target that generates
the list of CPUs in
llvm/TargetParser/RISCVTargetParserDef.inc. This *.inc file is
included by the public header file
llvm/TargetParser/RISCVTargetParser.h.

The header file llvm/TargetParser/RISCVTargetParser.h is also used in
components (clangDriver and clangBasic) that link into
LLVMTargetParser, but on some configurations such components might end
up being built before TargetParser is ready.

The fix is to make sure that clangDriver and clangBasic depend on the
tablegen target RISCVTargetParserTableGen, which generates the .inc
file whether or not LLVMTargetParser is ready.

WRT the original patch at https://reviews.llvm.org/D137517, this
commit is just adding RISCVTargetParserTableGen in the DEPENDS list of
clangDriver and clangBasic.

Added: 
llvm/include/llvm/TargetParser/CMakeLists.txt
llvm/include/llvm/TargetParser/RISCVTargetParser.h
llvm/lib/TargetParser/RISCVTargetParser.cpp
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp

Modified: 
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
llvm/include/llvm/CMakeLists.txt
llvm/include/llvm/TargetParser/TargetParser.h
llvm/include/llvm/module.extern.modulemap
llvm/include/llvm/module.install.modulemap
llvm/include/llvm/module.modulemap
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/TargetParser/CMakeLists.txt
llvm/lib/TargetParser/TargetParser.cpp
llvm/utils/TableGen/CMakeLists.txt
llvm/utils/TableGen/TableGen.cpp
llvm/utils/TableGen/TableGenBackends.h

Removed: 
llvm/include/llvm/TargetParser/RISCVTargetParser.def



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/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 7713398c83b20..a9adafddb7e54 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -15,8 +15,8 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 #include 
 
 using namespace clang;

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/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 4724e5c5a37ec..5c11064d81d59 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -17,8 +17,8 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/RISCVISAInfo.h"
-#include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;

diff  --git a/llvm/include/llvm/CMakeLists.txt 
b/llvm/include/llvm/CMakeLists.txt
index b46319f24fc8e..d1dc0a99463ba 100644
--- a/llvm/include/llvm/

[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

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

In D137517#4042758 , @fpetrogalli 
wrote:

> After submitting this, I had to revert it 
> 
>  because of failures like 
> https://lab.llvm.org/buildbot/#/builders/225/builds/12367/steps/5/logs/stdio

I have resubmitted with what I hope is the right fix (I could not reproduce any 
of the failures I was seeing in buildbot, on my machine the build is fine).

The new commit is at 
https://github.com/llvm/llvm-project/commit/ac1ffd3caca12c254e0b8c847aa8ce8e51b6cfbf
 - in the commit message I have explained what I have changed WRT this original 
patch. I have added  the
tablegen target `RISCVTargetParserTableGen` in the `DEPENDS` list of 
`clangDriver` and `clangBasic`. This makes sure that the `.*inc` file with 
theist o the CPU is available even if `LLVMTargetParser` has not been built yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D141411: [AArch64] Make -march and target("arch=..") attributes imply dependent features

2023-01-11 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Can we check this logic, especially around adding both AEK_SVE and AEK_SVE2 in 
the `AARCH64_ARCH` descriptions, this means that `-march=armv9-a+nosve2` still 
can generate sve instructions. I'm not entirely sure of the intended behaviour 
there, especially as sve2 should maybe imply sve by other means (iirc, there's 
a place higher up in AArch64TargetParser.def with the implied features?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141411

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


[clang] 8b301b4 - [clang][Interp][NFC] Print Pointee address of Pointer

2023-01-11 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-11T12:01:32+01:00
New Revision: 8b301b4f6b3d7068fd81f88ac001916c2f138c33

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

LOG: [clang][Interp][NFC] Print Pointee address of Pointer

Added: 


Modified: 
clang/lib/AST/Interp/Pointer.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h
index 09738fbfb137b..38341ae2322d9 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -298,7 +298,7 @@ class Pointer {
 
   /// Prints the pointer.
   void print(llvm::raw_ostream &OS) const {
-OS << "{" << Base << ", " << Offset << ", ";
+OS << Pointee << " {" << Base << ", " << Offset << ", ";
 if (Pointee)
   OS << Pointee->getSize();
 else



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


[PATCH] D141477: [include-mapping] Fix the instructions for running stdlib recognizer. Mention python command explicitly. Remove angle brackets.

2023-01-11 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141477

Files:
  clang/tools/include-mapping/gen_std.py


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -24,13 +24,13 @@

https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup
   2. Download cppreference offline HTML files (e.g. html_book_20181028.zip) at
https://en.cppreference.com/w/Cppreference:Archives
-  3. Unzip the zip file from step 2 to directory , you should
- get a "reference" directory in 
+  3. Unzip the zip file from step 2 (e.g., to a "cppreference" directory). You 
should
+ get a "cppreference/reference" directory.
   4. Run the command:
// Generate C++ symbols
-   gen_std.py -cppreference  -language=cpp > 
StdSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=cpp > 
StdSymbolMap.inc
// Generate C symbols
-   gen_std.py -cppreference  -language=c > 
CSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=c > 
CSymbolMap.inc
 """
 
 


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -24,13 +24,13 @@
https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup
   2. Download cppreference offline HTML files (e.g. html_book_20181028.zip) at
https://en.cppreference.com/w/Cppreference:Archives
-  3. Unzip the zip file from step 2 to directory , you should
- get a "reference" directory in 
+  3. Unzip the zip file from step 2 (e.g., to a "cppreference" directory). You should
+ get a "cppreference/reference" directory.
   4. Run the command:
// Generate C++ symbols
-   gen_std.py -cppreference  -language=cpp > StdSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=cpp > StdSymbolMap.inc
// Generate C symbols
-   gen_std.py -cppreference  -language=c > CSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=c > CSymbolMap.inc
 """
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141478: [include-cleaner] Improve header spelling in the presence of links

2023-01-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: kadircet, hokein.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

HeaderSearch uses FileEntry::getName() to determine the best spelling of a
header. FileEntry::getName() is now the name of the *last* retrieved ref.
This means that when FileManager::getFile() hits an existing inode through a new
path, it changes the spelling of that header.

In the absence of explicit logic to track the preferred name(s) of header files,
we should avoid gratuitously calling getFile() with paths different than how
the header was originally included, such as the result of realpath().

The originally-specified path should be fine here:

- if the same filemanager is being used for record/analysis, we'll hit the 
filename cache
- if a different filemanager is being used e.g. preamble scenario, we should 
get the same result unless either the working directory has changed (which it 
shouldn't, else many other things will fail) or the file has gone/changed inode 
(in which case the old method doesn't work either)

Needless to say this is fragile, but talking to @kadircet offline, it's good
enough for our purposes for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141478

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/Record.cpp


Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -204,7 +204,7 @@
 Top.SeenAtLine == HashLine) {
   if (IncludedHeader)
 Out->IWYUExportBy[IncludedHeader->getUniqueID()].push_back(
-Top.FullPath);
+Top.Path);
   // main-file #include with export pragma should never be removed.
   if (Top.SeenAtFile == SM.getMainFileID())
 Out->ShouldKeep.insert(HashLine);
@@ -251,14 +251,13 @@
SM.getFileOffset(Range.getBegin()));
 // Record export pragma.
 if (Pragma->startswith("export")) {
-  ExportStack.push_back(
-  {CommentLine, CommentFID,
-   save(SM.getFileEntryForID(CommentFID)->tryGetRealPathName()),
-   false});
+  ExportStack.push_back({CommentLine, CommentFID,
+ save(SM.getFileEntryForID(CommentFID)->getName()),
+ false});
 } else if (Pragma->startswith("begin_exports")) {
-  ExportStack.push_back(
-  {CommentLine, CommentFID,
-   save(SM.getFileEntryForID(CommentFID)->tryGetRealPathName()), 
true});
+  ExportStack.push_back({CommentLine, CommentFID,
+ save(SM.getFileEntryForID(CommentFID)->getName()),
+ true});
 } else if (Pragma->startswith("end_exports")) {
   // FIXME: be robust on unmatching cases. We should only pop the stack if
   // the begin_exports and end_exports is in the same file.
@@ -297,8 +296,8 @@
 int SeenAtLine = 0; // 1-based line number.
 // The file where we saw the pragma.
 FileID SeenAtFile;
-// FullPath of the file SeenAtFile.
-StringRef FullPath;
+// Name (per FileEntry::getName()) of the file SeenAtFile.
+StringRef Path;
 // true if it is a block begin/end_exports pragma; false if it is a
 // single-line export pragma.
 bool Block = false;
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
@@ -90,12 +90,15 @@
   IWYUPublic;
 
   /// A reverse map from the underlying header to its exporter headers.
-  //
-  //  There's no way to get a FileEntry from a UniqueID, especially when it
-  //  hasn't been opened before. So store the full path and convert it to a
-  //  FileEntry by opening the file again through a FileManager.
+  ///
+  /// There's no way to get a FileEntry from a UniqueID, especially when it
+  /// hasn't been opened before. So store the path and convert it to a
+  /// FileEntry by opening the file again through a FileManager.
+  ///
+  /// We don't use RealPathName, as opening the file through a different name
+  /// changes its preferred name. Clearly this is fragile!
   llvm::DenseMap>
+ llvm::SmallVector>
   IWYUExportBy;
 
   /// Contains all non self-contained files detected during the parsing.


Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -

[clang] 9e0474f - Perform access checking to private members in simple requirement.

2023-01-11 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2023-01-11T12:13:16+01:00
New Revision: 9e0474fbb9c56725a1dfd1658837f07db73f4d8d

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

LOG: Perform access checking to private members in simple requirement.

> Dependent access checks.

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

We previously ignored dependent access checks to private members.
These are visible only to the `RequiresExprBodyExpr` (through 
`PerformDependentDiagnositcs`) and not to the individual requirements.

---

> Non-dependent access checks.
Fixes: https://github.com/llvm/llvm-project/issues/53334
Access to members in a non-dependent context would always yield an
invalid expression. When it appears in a requires-expression, then this
is a hard error as this would always result in a substitution failure.

https://eel.is/c++draft/expr.prim.req#general-note-1
> Note 1: If a requires-expression contains invalid types or expressions in its 
> requirements, and it does not appear within the declaration of a templated 
> entity, then the program is ill-formed. — end note]
> If the substitution of template arguments into a requirement would always 
> result in a substitution failure, the program is ill-formed; no diagnostic 
> required.

The main issue here is the delaying of the diagnostics.
Use a `ParsingDeclRAIIObject` creates a separate diagnostic pool for 
diagnositcs associated to the `RequiresExprBodyDecl`.
This is important because dependent diagnostics should not be leaked/delayed to 
higher scopes (Eg. inside a template function or in a trailing requires). These 
dependent diagnostics must be attached to the `DeclContext` of the parameters 
of `RequiresExpr` (which is the `RequiresExprBodyDecl` in this case).
Non dependent diagnostics, on the other hand, should not delayed and surfaced 
as hard errors.

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

Added: 
clang/test/SemaCXX/invalid-requirement-requires-expr.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ExprConcepts.h
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/SemaAccess.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 927c85249b729..b55b2d6752972 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -735,7 +735,8 @@ C++20 Feature Support
 - Do not hide templated base members introduced via using-decl in derived class
   (useful specially for constrained members). Fixes `GH50886 
`_.
 - Implemented CWG2635 as a Defect Report, which prohibits structured bindings 
from being constrained.
-
+- Correctly handle access-checks in requires expression. Fixes `GH53364 
`_,
+  `GH53334 `_.
 C++2b Feature Support
 ^
 

diff  --git a/clang/include/clang/AST/ExprConcepts.h 
b/clang/include/clang/AST/ExprConcepts.h
index a358a2a41619e..f02c140c14c19 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++ b/clang/include/clang/AST/ExprConcepts.h
@@ -528,6 +528,12 @@ class RequiresExpr final : public Expr,
 return RequiresExprBits.IsSatisfied;
   }
 
+  void setSatisfied(bool IsSatisfied) {
+assert(!isValueDependent() &&
+   "setSatisfied called on a dependent RequiresExpr");
+RequiresExprBits.IsSatisfied = IsSatisfied;
+  }
+
   SourceLocation getRequiresKWLoc() const {
 return RequiresExprBits.RequiresKWLoc;
   }

diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index 5017f31a1ecb2..7f09120574a7a 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3509,6 +3509,10 @@ ExprResult Parser::ParseRequiresExpression() {
   Actions, Sema::ExpressionEvaluationContext::Unevaluated);
 
   ParseScope BodyScope(this, Scope::DeclScope);
+  // Create a separate diagnostic pool for RequiresExprBodyDecl.
+  // Dependent diagnostics are attached to this Decl and non-depenedent
+  // diagnostics are surfaced after this parse.
+  ParsingDeclRAIIObject ParsingBodyDecl(*this, 
ParsingDeclRAIIObject::NoParent);
   RequiresExprBodyDecl *Body = Actions.ActOnStartRequiresExpr(
   RequiresKWLoc, LocalParameterDecls, getCurScope());
 
@@ -3746,6 +3750,7 @@ ExprResult Parser::ParseRequiresExpression() {
   }
   Braces.consumeClose();
   Actions.ActOnFinishRequiresExpr();
+  ParsingBodyDecl.complete(Body);
   return Actions.ActOnRequiresExpr(RequiresKWLoc, Body, LocalParameterDecls,
Requ

[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-11 Thread Utkarsh Saxena 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 rG9e0474fbb9c5: Perform access checking to private members in 
simple requirement. (authored by usaxena95).

Changed prior to commit:
  https://reviews.llvm.org/D140547?vs=487866&id=488136#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ExprConcepts.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaAccess.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
  clang/test/SemaCXX/invalid-requirement-requires-expr.cpp

Index: clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -I%S -std=c++2a -verify
+
+// RequiresExpr contains invalid requirement. (Eg. Highly recurisive template).
+template
+struct A { static constexpr bool far(); };
+class B {
+bool data_member;
+friend struct A<1>;
+};
+
+template<>
+constexpr bool A<0>::far() { return true; }
+
+template
+constexpr bool A::far() {
+return requires(B b) {
+  b.data_member;
+  requires A::far(); //expected-note 3{{in instantiation}} // expected-note 6{{while}} expected-note {{contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all}}
+  // expected-error@-1{{recursive template instantiation exceeded maximum depth}}
+};
+}
+static_assert(A<1>::far());
+static_assert(!A<10001>::far()); // expected-note {{in instantiation of member function}}
Index: clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
@@ -104,3 +104,138 @@
 constexpr bool b = requires (X &x) { static_cast(nullptr); };
 // expected-error@-1{{constraint variable 'x' cannot be used in an evaluated context}}
 // expected-note@-2{{'x' declared here}}
+
+namespace access_checks {
+namespace in_requires_expression {
+template
+struct A {
+static constexpr bool foo();
+static constexpr bool bar();
+static constexpr bool baz();
+static constexpr bool faz();
+};
+
+class C{};
+
+class B {
+void p() {}
+bool data_member = true;
+static const bool static_member = true;
+friend struct A<0>;
+};
+
+template
+constexpr bool A::foo() {
+return requires(B b) { b.p(); };
+}
+static_assert(!A<1>::foo());
+static_assert(A<0>::foo());
+
+template
+constexpr bool A::bar() {
+return requires() { B::static_member; };
+}
+static_assert(!A<1>::bar());
+static_assert(A<0>::bar());
+
+template
+constexpr bool A::baz() {
+return requires(B b) { b.data_member; };
+}
+static_assert(!A<1>::baz());
+static_assert(A<0>::baz());
+
+template
+constexpr bool A::faz() {
+return requires(B a, B b) { 
+  a.p();
+  b.data_member;
+  B::static_member;
+};
+}
+static_assert(!A<1>::faz());
+static_assert(A<0>::faz());
+} // namespace in_requires_expression
+
+namespace in_concepts {
+// Dependent access does not cause hard errors.
+template class A;
+
+template <> class A<0> {
+  static void f() {}
+};
+template
+concept C1 = requires() { A::f(); };
+static_assert(!C1<0>);
+
+template <> class A<1> {
+public: 
+  static void f() {}
+};
+static_assert(C1<1>);
+
+// Non-dependent access to private member is a hard error.
+class B{
+   static void f() {} // expected-note 2{{implicitly declared private here}}
+};
+template
+concept C2 = requires() { B::f(); }; // expected-error {{'f' is a private member}}
+
+constexpr bool non_template_func() {
+  return requires() {
+  B::f(); // expected-error {{'f' is a private member}}
+  };
+}
+template
+constexpr bool template_func() {
+  return requires() {
+  A::f();
+  };
+}
+static_assert(!template_func<0>());
+static_assert(template_func<1>());
+} // namespace in_concepts
+
+namespace in_trailing_requires {
+template  struct B;
+class A {
+   static void f();
+   friend struct B;
+};
+ 
+template  struct B {
+  static constexpr int index() requires requires{ A::f(); } {
+return 1;
+  }
+  static constexpr int index() {
+return 2;
+  }
+};
+
+static_assert(B::index() == 1);
+static_assert(B::index() == 2);
+
+namespace missing_member_function {
+template  struct Use;
+class X { 
+  int a;
+  static int B;
+  friend struct Use;
+};
+template  struct Use {
+  constexpr static int foo() requires requires(X x) { x.a; } {
+return 1;
+  }
+  constexpr static int bar() requires requires { X::B; } {
+return 1;
+  }
+};
+
+void test() {
+  // FIXME: Propagate diagnostic.
+ 

[PATCH] D141472: [clang][Interp] Add function pointers

2023-01-11 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 488135.

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

https://reviews.llvm.org/D141472

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpStack.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.cpp
  clang/lib/AST/Interp/PrimType.h
  clang/test/AST/Interp/functions.cpp

Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -99,3 +99,58 @@
   huh(); // expected-error {{use of undeclared identifier}} \
  // ref-error {{use of undeclared identifier}}
 }
+
+namespace FunctionPointers {
+  constexpr int add(int a, int b) {
+return a + b;
+  }
+
+  struct S { int a; };
+  constexpr S getS() {
+return S{12};
+  }
+
+  constexpr int applyBinOp(int a, int b, int (*op)(int, int)) {
+return op(a, b);
+  }
+  static_assert(applyBinOp(1, 2, add) == 3, "");
+
+  constexpr int ignoreReturnValue() {
+int (*foo)(int, int) = add;
+
+foo(1, 2);
+return 1;
+  }
+  static_assert(ignoreReturnValue() == 1, "");
+
+  constexpr int createS(S (*gimme)()) {
+gimme(); // Ignored return value
+return gimme().a;
+  }
+  static_assert(createS(getS) == 12, "");
+
+namespace FunctionReturnType {
+  typedef int (*ptr)(int*);
+  typedef ptr (*pm)();
+
+  constexpr int fun1(int* y) {
+  return *y + 10;
+  }
+  constexpr ptr fun() {
+  return &fun1;
+  }
+  static_assert(fun() == nullptr, ""); // expected-error {{static assertion failed}} \
+   // ref-error {{static assertion failed}}
+
+  constexpr int foo() {
+int (*f)(int *) = fun();
+int m = 0;
+
+m = f(&m);
+
+return m;
+  }
+  static_assert(foo() == 10);
+}
+
+}
Index: clang/lib/AST/Interp/PrimType.h
===
--- clang/lib/AST/Interp/PrimType.h
+++ clang/lib/AST/Interp/PrimType.h
@@ -24,6 +24,7 @@
 namespace interp {
 
 class Pointer;
+class FunctionPointer;
 
 /// Enumeration of the primitive types of the VM.
 enum PrimType : unsigned {
@@ -38,6 +39,7 @@
   PT_Bool,
   PT_Float,
   PT_Ptr,
+  PT_FnPtr,
 };
 
 /// Mapping from primitive types to their representation.
@@ -53,6 +55,7 @@
 template <> struct PrimConv { using T = Floating; };
 template <> struct PrimConv { using T = Boolean; };
 template <> struct PrimConv { using T = Pointer; };
+template <> struct PrimConv { using T = FunctionPointer; };
 
 /// Returns the size of a primitive type in bytes.
 size_t primSize(PrimType Type);
@@ -90,6 +93,7 @@
   TYPE_SWITCH_CASE(PT_Float, B)\
   TYPE_SWITCH_CASE(PT_Bool, B) \
   TYPE_SWITCH_CASE(PT_Ptr, B)  \
+  TYPE_SWITCH_CASE(PT_FnPtr, B)\
 }  \
   } while (0)
 #define COMPOSITE_TYPE_SWITCH(Expr, B, D)  \
Index: clang/lib/AST/Interp/PrimType.cpp
===
--- clang/lib/AST/Interp/PrimType.cpp
+++ clang/lib/AST/Interp/PrimType.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "PrimType.h"
+#include "FunctionPointer.h"
 #include "Pointer.h"
 
 using namespace clang;
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -27,6 +27,7 @@
 def Uint64 : Type;
 def Float : Type;
 def Ptr : Type;
+def FnPtr : Type;
 
 //===--===//
 // Types transferred to the interpreter.
@@ -77,7 +78,7 @@
 }
 
 def PtrTypeClass : TypeClass {
-  let Types = [Ptr];
+  let Types = [Ptr, FnPtr];
 }
 
 def BoolTypeClass : TypeClass {
@@ -187,6 +188,12 @@
   let ChangesPC = 1;
 }
 
+def CallPtr : Opcode {
+  let Args = [];
+  let Types = [];
+  let ChangesPC = 1;
+}
+
 //===--===//
 // Frame management
 //===--===//
@@ -228,6 +235,7 @@
 // [] -> [Pointer]
 def Null : Opcode {
   let Types = [PtrTypeClass];
+  let HasGroup = 1;
 }
 
 //===--===//
@@ -447,6 +455,14 @@
   let HasGroup = 0;
 }
 
+//===--===//
+// Function pointers.
+//===--===//
+def GetFnPtr : Opcode {
+  let Ar

[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

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

add `LLVM_READONLY` to `getSourceRange()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/test/FixIt/fixit-const-var-init.cpp


Index: clang/test/FixIt/fixit-const-var-init.cpp
===
--- /dev/null
+++ clang/test/FixIt/fixit-const-var-init.cpp
@@ -0,0 +1,28 @@
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++14 %s 
2>&1 | FileCheck %s
+
+const int a; // expected-error {{default initialization of an object of const 
type}}
+// CHECK: fix-it:"{{.*}}":{3:12-3:12}:" = 0"
+
+template  const int b; // expected-error {{default 
initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{6:36-6:36}:" = 0"
+
+template  const int b; // expected-error {{default 
initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{9:39-9:39}:" = 0"
+
+template <> const int b; // expected-error {{default 
initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{12:36-12:36}:" = 0"
+
+constexpr float c; // expected-error {{must be initialized by a constant 
expression}}
+// CHECK: fix-it:"{{.*}}":{15:18-15:18}:" = 0.0"
+
+template  constexpr float d; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{18:42-18:42}:" = 0.0"
+
+template  constexpr float d; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{21:45-21:45}:" = 0.0"
+
+template <> constexpr float d; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{24:42-24:42}:" = 0.0"
+
+void (* const func)(int, int); // expected-error {{default initialization of 
an object of const type}}
+// CHECK: fix-it:"{{.*}}":{27:30-27:30}:" = nullptr"
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2924,6 +2924,14 @@
 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
   }
 
+  SourceRange getSourceRange() const override LLVM_READONLY {
+if (isExplicitSpecialization()) {
+  if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
+return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+}
+return VarDecl::getSourceRange();
+  }
+
   void Profile(llvm::FoldingSetNodeID &ID) const {
 Profile(ID, TemplateArgs->asArray(), getASTContext());
   }
@@ -3081,6 +3089,14 @@
 return First->InstantiatedFromMember.setInt(true);
   }
 
+  SourceRange getSourceRange() const override LLVM_READONLY {
+if (isExplicitSpecialization()) {
+  if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
+return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+}
+return VarDecl::getSourceRange();
+  }
+
   void Profile(llvm::FoldingSetNodeID &ID) const {
 Profile(ID, getTemplateArgs().asArray(), getTemplateParameters(),
 getASTContext());


Index: clang/test/FixIt/fixit-const-var-init.cpp
===
--- /dev/null
+++ clang/test/FixIt/fixit-const-var-init.cpp
@@ -0,0 +1,28 @@
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++14 %s 2>&1 | FileCheck %s
+
+const int a; // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{3:12-3:12}:" = 0"
+
+template  const int b; // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{6:36-6:36}:" = 0"
+
+template  const int b; // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{9:39-9:39}:" = 0"
+
+template <> const int b; // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{12:36-12:36}:" = 0"
+
+constexpr float c; // expected-error {{must be initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{15:18-15:18}:" = 0.0"
+
+template  constexpr float d; // expected-error {{must be initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{18:42-18:42}:" = 0.0"
+
+template  constexpr float d; // expected-error {{must be initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{21:45-21:45}:" = 0.0"
+
+template <> constexpr float d; // expected-error {{must be initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{24:42-24:42}:" = 0.0"
+
+void (* const func)(int, int); // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{27:30-27:30}:" = nullptr"
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/cla

[clang] 1b1d8ac - [clang-format][doc] Fix doc format for IntegerLiteralSeparator

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

Author: Owen Pan
Date: 2023-01-11T03:23:34-08:00
New Revision: 1b1d8acdfa1e8fc5bc64ffd982bb689e308d6c20

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

LOG: [clang-format][doc] Fix doc format for IntegerLiteralSeparator

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 23f5786723f6d..fd2a9438a3327 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3169,24 +3169,42 @@ the configuration (without a prefix: ``Auto``).
   Nested configuration flags:
 
   Separator format of integer literals of 
diff erent bases.
-  If <0: Remove separators.
-  If  0: Leave the literal as is.
-  If >0: Insert separators between digits starting from the rightmost digit.
 
-  * ``int8_t Binary`` .. code-block:: c++
+  If negative, remove separators. If  ``0``, leave the literal as is. If
+  positive, insert separators between digits starting from the rightmost
+  digit.
+
+  For example, the config below will leave separators in binary literals
+  alone, insert separators in decimal literals to separate the digits into
+  groups of 3, and remove separators in hexadecimal literals.
+
+  .. code-block:: c++
+
+IntegerLiteralSeparator:
+  Binary: 0
+  Decimal: 3
+  Hex: -1
+
+  * ``int8_t Binary`` Format separators in binary literals.
+
+.. code-block:: c++
 
-1: 0b10001101
 0: 0b10011'11'0110'1
 3: 0b100'111'101'101
 4: 0b1001'1110'1101
 
-  * ``int8_t Decimal`` .. code-block:: c++
+  * ``int8_t Decimal`` Format separators in decimal literals.
+
+.. code-block:: c++
 
-1: 18446744073709550592ull
 0: 184467'440737'0'95505'92ull
 3: 18'446'744'073'709'550'592ull
 
-  * ``int8_t Hex`` .. code-block:: c++
+  * ``int8_t Hex`` Format separators in hexadecimal literals.
+
+.. code-block:: c++
 
-1: 0xDEADBEEFDEADBEEFuz
 0: 0xDEAD'BEEF'DE'AD'BEE'Fuz

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 3a7a183d139f0..5d5a044158dfb 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2455,10 +2455,22 @@ struct FormatStyle {
   TrailingCommaStyle InsertTrailingCommas;
 
   /// Separator format of integer literals of 
diff erent bases.
-  /// If <0: Remove separators.
-  /// If  0: Leave the literal as is.
-  /// If >0: Insert separators between digits starting from the rightmost 
digit.
+  ///
+  /// If negative, remove separators. If  ``0``, leave the literal as is. If
+  /// positive, insert separators between digits starting from the rightmost
+  /// digit.
+  ///
+  /// For example, the config below will leave separators in binary literals
+  /// alone, insert separators in decimal literals to separate the digits into
+  /// groups of 3, and remove separators in hexadecimal literals.
+  /// \code
+  ///   IntegerLiteralSeparator:
+  /// Binary: 0
+  /// Decimal: 3
+  /// Hex: -1
+  /// \endcode
   struct IntegerLiteralSeparatorStyle {
+/// Format separators in binary literals.
 /// \code
 ///-1: 0b10001101
 /// 0: 0b10011'11'0110'1
@@ -2466,12 +2478,14 @@ struct FormatStyle {
 /// 4: 0b1001'1110'1101
 /// \endcode
 int8_t Binary;
+/// Format separators in decimal literals.
 /// \code
 ///-1: 18446744073709550592ull
 /// 0: 184467'440737'0'95505'92ull
 /// 3: 18'446'744'073'709'550'592ull
 /// \endcode
 int8_t Decimal;
+/// Format separators in hexadecimal literals.
 /// \code
 ///-1: 0xDEADBEEFDEADBEEFuz
 /// 0: 0xDEAD'BEEF'DE'AD'BEE'Fuz



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


[PATCH] D141472: [clang][Interp] Add function pointers

2023-01-11 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 488139.

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

https://reviews.llvm.org/D141472

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/FunctionPointer.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpStack.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.cpp
  clang/lib/AST/Interp/PrimType.h
  clang/test/AST/Interp/functions.cpp

Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -99,3 +99,58 @@
   huh(); // expected-error {{use of undeclared identifier}} \
  // ref-error {{use of undeclared identifier}}
 }
+
+namespace FunctionPointers {
+  constexpr int add(int a, int b) {
+return a + b;
+  }
+
+  struct S { int a; };
+  constexpr S getS() {
+return S{12};
+  }
+
+  constexpr int applyBinOp(int a, int b, int (*op)(int, int)) {
+return op(a, b);
+  }
+  static_assert(applyBinOp(1, 2, add) == 3, "");
+
+  constexpr int ignoreReturnValue() {
+int (*foo)(int, int) = add;
+
+foo(1, 2);
+return 1;
+  }
+  static_assert(ignoreReturnValue() == 1, "");
+
+  constexpr int createS(S (*gimme)()) {
+gimme(); // Ignored return value
+return gimme().a;
+  }
+  static_assert(createS(getS) == 12, "");
+
+namespace FunctionReturnType {
+  typedef int (*ptr)(int*);
+  typedef ptr (*pm)();
+
+  constexpr int fun1(int* y) {
+  return *y + 10;
+  }
+  constexpr ptr fun() {
+  return &fun1;
+  }
+  static_assert(fun() == nullptr, ""); // expected-error {{static assertion failed}} \
+   // ref-error {{static assertion failed}}
+
+  constexpr int foo() {
+int (*f)(int *) = fun();
+int m = 0;
+
+m = f(&m);
+
+return m;
+  }
+  static_assert(foo() == 10);
+}
+
+}
Index: clang/lib/AST/Interp/PrimType.h
===
--- clang/lib/AST/Interp/PrimType.h
+++ clang/lib/AST/Interp/PrimType.h
@@ -24,6 +24,7 @@
 namespace interp {
 
 class Pointer;
+class FunctionPointer;
 
 /// Enumeration of the primitive types of the VM.
 enum PrimType : unsigned {
@@ -38,6 +39,7 @@
   PT_Bool,
   PT_Float,
   PT_Ptr,
+  PT_FnPtr,
 };
 
 /// Mapping from primitive types to their representation.
@@ -53,6 +55,7 @@
 template <> struct PrimConv { using T = Floating; };
 template <> struct PrimConv { using T = Boolean; };
 template <> struct PrimConv { using T = Pointer; };
+template <> struct PrimConv { using T = FunctionPointer; };
 
 /// Returns the size of a primitive type in bytes.
 size_t primSize(PrimType Type);
@@ -90,6 +93,7 @@
   TYPE_SWITCH_CASE(PT_Float, B)\
   TYPE_SWITCH_CASE(PT_Bool, B) \
   TYPE_SWITCH_CASE(PT_Ptr, B)  \
+  TYPE_SWITCH_CASE(PT_FnPtr, B)\
 }  \
   } while (0)
 #define COMPOSITE_TYPE_SWITCH(Expr, B, D)  \
Index: clang/lib/AST/Interp/PrimType.cpp
===
--- clang/lib/AST/Interp/PrimType.cpp
+++ clang/lib/AST/Interp/PrimType.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "PrimType.h"
+#include "FunctionPointer.h"
 #include "Pointer.h"
 
 using namespace clang;
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -27,6 +27,7 @@
 def Uint64 : Type;
 def Float : Type;
 def Ptr : Type;
+def FnPtr : Type;
 
 //===--===//
 // Types transferred to the interpreter.
@@ -77,7 +78,7 @@
 }
 
 def PtrTypeClass : TypeClass {
-  let Types = [Ptr];
+  let Types = [Ptr, FnPtr];
 }
 
 def BoolTypeClass : TypeClass {
@@ -187,6 +188,12 @@
   let ChangesPC = 1;
 }
 
+def CallPtr : Opcode {
+  let Args = [];
+  let Types = [];
+  let ChangesPC = 1;
+}
+
 //===--===//
 // Frame management
 //===--===//
@@ -228,6 +235,7 @@
 // [] -> [Pointer]
 def Null : Opcode {
   let Types = [PtrTypeClass];
+  let HasGroup = 1;
 }
 
 //===--===//
@@ -447,6 +455,14 @@
   let HasGroup = 0;
 }
 
+//===--===//
+// Function pointers.
+//===-

[clang] 75c0d43 - [docs] Add newline in clang release notes.

2023-01-11 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2023-01-11T12:28:59+01:00
New Revision: 75c0d43e857dd6e61e9c354284347144b428f44a

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

LOG: [docs] Add newline in clang release notes.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b55b2d675297..235684c1f9b8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -737,6 +737,7 @@ C++20 Feature Support
 - Implemented CWG2635 as a Defect Report, which prohibits structured bindings 
from being constrained.
 - Correctly handle access-checks in requires expression. Fixes `GH53364 
`_,
   `GH53334 `_.
+
 C++2b Feature Support
 ^
 



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


[PATCH] D140956: [clang-format] Add an option for breaking after C++11 attributes

2023-01-11 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

> Was it actually a regression or did this patch also fix a bug? It seems that 
> the continuation indent before the & in your example is inconsistent with 
> other similar function declarations.

Nice catch! I fully agree with you!
Thank you for looking into this, sorry for the false alarm!

I'll go ahead and revert my revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140956

___
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-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488140.
eopXD edited the summary of this revision.
eopXD added a comment.

Rebase on top of landing of D141198 .


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


[clang] 922c889 - Revert "Revert "[clang-format] Add an option for breaking after C++11 attributes""

2023-01-11 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2023-01-11T11:30:30Z
New Revision: 922c8891d9916fa094147c5c793291f97a83c84c

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

LOG: Revert "Revert "[clang-format] Add an option for breaking after C++11 
attributes""

This reverts commit 879bfe6a979295f834b76df66b19a203b93eed0f.

owenpan@ pointed out on https://reviews.llvm.org/D140956 that this
actually makes the formatting more consistent, so it's not a regression.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/TokenAnnotator.h
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index fd2a9438a3327..05eca35aa9714 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1762,6 +1762,41 @@ the configuration (without a prefix: ``Auto``).
}
 
 
+**BreakAfterAttributes** (``AttributeBreakingStyle``) 
:versionbadge:`clang-format 16`
+  Break after a group of C++11 attributes before a function
+  declaration/definition name.
+
+  Possible values:
+
+  * ``ABS_Always`` (in configuration: ``Always``)
+Always break after attributes.
+
+.. code-block:: c++
+
+  [[nodiscard]]
+  inline int f();
+  [[gnu::const]] [[nodiscard]]
+  int g();
+
+  * ``ABS_Leave`` (in configuration: ``Leave``)
+Leave the line breaking after attributes as is.
+
+.. code-block:: c++
+
+  [[nodiscard]] inline int f();
+  [[gnu::const]] [[nodiscard]]
+  int g();
+
+  * ``ABS_Never`` (in configuration: ``Never``)
+Never break after attributes.
+
+.. code-block:: c++
+
+  [[nodiscard]] inline int f();
+  [[gnu::const]] [[nodiscard]] int g();
+
+
+
 **BreakAfterJavaFieldAnnotations** (``Boolean``) :versionbadge:`clang-format 
3.8`
   Break after each annotation on a field in Java files.
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 235684c1f9b87..3d7b07f88101d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -891,6 +891,8 @@ clang-format
   To match the default behavior of clang-format 15, use the ``Keyword`` value.
 - Add ``IntegerLiteralSeparator`` option for fixing integer literal separators
   in C++, C#, Java, and JavaScript.
+- Add ``BreakAfterAttributes`` option for breaking after a group of C++11
+  attributes before a function declaration/definition name.
 - Add ``InsertNewlineAtEOF`` option for inserting a newline at EOF if missing.
 
 clang-extdef-mapping

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 5d5a044158dfb..3a90c1fe5be99 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1221,6 +1221,36 @@ struct FormatStyle {
   /// \version 3.8
   BraceWrappingFlags BraceWrapping;
 
+  /// Different ways to break after attributes.
+  enum AttributeBreakingStyle : int8_t {
+/// Always break after attributes.
+/// \code
+///   [[nodiscard]]
+///   inline int f();
+///   [[gnu::const]] [[nodiscard]]
+///   int g();
+/// \endcode
+ABS_Always,
+/// Leave the line breaking after attributes as is.
+/// \code
+///   [[nodiscard]] inline int f();
+///   [[gnu::const]] [[nodiscard]]
+///   int g();
+/// \endcode
+ABS_Leave,
+/// Never break after attributes.
+/// \code
+///   [[nodiscard]] inline int f();
+///   [[gnu::const]] [[nodiscard]] int g();
+/// \endcode
+ABS_Never,
+  };
+
+  /// Break after a group of C++11 attributes before a function
+  /// declaration/definition name.
+  /// \version 16
+  AttributeBreakingStyle BreakAfterAttributes;
+
   /// If ``true``, clang-format will always break after a Json array `[`
   /// otherwise it will scan until the closing `]` to determine if it should 
add
   /// newlines between elements (prettier compatible).
@@ -4097,6 +4127,7 @@ struct FormatStyle {
BinPackArguments == R.BinPackArguments &&
BinPackParameters == R.BinPackParameters &&
BitFieldColonSpacing == R.BitFieldColonSpacing &&
+   BreakAfterAttributes == R.BreakAfterAttributes &&
BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations 
&&
BreakArrays == R.BreakArrays &&
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&

diff  --git a/clang/lib/Format/ContinuationIndente

[PATCH] D140956: [clang-format] Add an option for breaking after C++11 attributes

2023-01-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D140956#4042990 , @krasimir wrote:

>> Was it actually a regression or did this patch also fix a bug? It seems that 
>> the continuation indent before the & in your example is inconsistent with 
>> other similar function declarations.
>
> Nice catch! I fully agree with you!
> Thank you for looking into this, sorry for the false alarm!

Np!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140956

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


[clang] 83c5040 - [include-mapping] Fix the instructions for running stdlib recognizer. Mention python command explicitly. Remove angle brackets.

2023-01-11 Thread Viktoriia Bakalova via cfe-commits

Author: Viktoriia Bakalova
Date: 2023-01-11T11:35:53Z
New Revision: 83c5040f6f3234a1fbf705b4aebe3ec1cf9d3bf6

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

LOG: [include-mapping] Fix the instructions for running stdlib recognizer. 
Mention python command explicitly. Remove angle brackets.

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

Added: 


Modified: 
clang/tools/include-mapping/gen_std.py

Removed: 




diff  --git a/clang/tools/include-mapping/gen_std.py 
b/clang/tools/include-mapping/gen_std.py
index f3dabe13471fb..f494ff0b88679 100755
--- a/clang/tools/include-mapping/gen_std.py
+++ b/clang/tools/include-mapping/gen_std.py
@@ -24,13 +24,13 @@

https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup
   2. Download cppreference offline HTML files (e.g. html_book_20181028.zip) at
https://en.cppreference.com/w/Cppreference:Archives
-  3. Unzip the zip file from step 2 to directory , you should
- get a "reference" directory in 
+  3. Unzip the zip file from step 2 (e.g., to a "cppreference" directory). You 
should
+ get a "cppreference/reference" directory.
   4. Run the command:
// Generate C++ symbols
-   gen_std.py -cppreference  -language=cpp > 
StdSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=cpp > 
StdSymbolMap.inc
// Generate C symbols
-   gen_std.py -cppreference  -language=c > 
CSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=c > 
CSymbolMap.inc
 """
 
 



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


[PATCH] D141477: [include-mapping] Fix the instructions for running stdlib recognizer. Mention python command explicitly. Remove angle brackets.

2023-01-11 Thread Viktoriia Bakalova 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 rG83c5040f6f32: [include-mapping] Fix the instructions for 
running stdlib recognizer. Mention… (authored by VitaNuo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141477

Files:
  clang/tools/include-mapping/gen_std.py


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -24,13 +24,13 @@

https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup
   2. Download cppreference offline HTML files (e.g. html_book_20181028.zip) at
https://en.cppreference.com/w/Cppreference:Archives
-  3. Unzip the zip file from step 2 to directory , you should
- get a "reference" directory in 
+  3. Unzip the zip file from step 2 (e.g., to a "cppreference" directory). You 
should
+ get a "cppreference/reference" directory.
   4. Run the command:
// Generate C++ symbols
-   gen_std.py -cppreference  -language=cpp > 
StdSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=cpp > 
StdSymbolMap.inc
// Generate C symbols
-   gen_std.py -cppreference  -language=c > 
CSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=c > 
CSymbolMap.inc
 """
 
 


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -24,13 +24,13 @@
https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup
   2. Download cppreference offline HTML files (e.g. html_book_20181028.zip) at
https://en.cppreference.com/w/Cppreference:Archives
-  3. Unzip the zip file from step 2 to directory , you should
- get a "reference" directory in 
+  3. Unzip the zip file from step 2 (e.g., to a "cppreference" directory). You should
+ get a "cppreference/reference" directory.
   4. Run the command:
// Generate C++ symbols
-   gen_std.py -cppreference  -language=cpp > StdSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=cpp > StdSymbolMap.inc
// Generate C symbols
-   gen_std.py -cppreference  -language=c > CSymbolMap.inc
+   python3 gen_std.py -cppreference cppreference/reference -language=c > CSymbolMap.inc
 """
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-01-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488144.
eopXD added a comment.

Rebase on top of landing of D141198 .


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:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv2f32.i64( [[DEST:%.*]],  

[clang] 3696941 - [clang][Interp][NFC] Add an assertion

2023-01-11 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-11T13:05:14+01:00
New Revision: 3696941dae5cc5bb379c50eae6190e29f7edbbb1

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

LOG: [clang][Interp][NFC] Add an assertion

This is unnecessary in the current state of the interpreter, but will ne
important later.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index f817fb4aedef..4e4f2eecd172 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -359,6 +359,7 @@ template  class ExprScope final : public 
LocalScope {
   ExprScope(ByteCodeExprGen *Ctx) : LocalScope(Ctx) {}
 
   void addExtended(const Scope::Local &Local) override {
+assert(this->Parent);
 this->Parent->addLocal(Local);
   }
 };



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


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

2023-01-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488150.
eopXD added a comment.

Rebase on top of landing of D141198 .


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


[clang] 78a9ee7 - [clang][Interp][NFC] Remove code duplication in VisitRecordInitializer

2023-01-11 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-11T13:08:51+01:00
New Revision: 78a9ee7834331fb4360457cc565fa36f5452f7e0

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

LOG: [clang][Interp][NFC] Remove code duplication in VisitRecordInitializer

We can just use the regular VisitCallExpr logic here, since we have the
pointer to initialize already on the stack.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 0c2eaac0e4e7..0bbab0cc0665 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1041,20 +1041,12 @@ bool 
ByteCodeExprGen::visitRecordInitializer(const Expr *Initializer) {
 
 return true;
   } else if (const CallExpr *CE = dyn_cast(Initializer)) {
-const Decl *Callee = CE->getCalleeDecl();
-const Function *Func = getFunction(dyn_cast(Callee));
-
-if (!Func)
+// RVO functions expect a pointer to initialize on the stack.
+// Dup our existing pointer so it has its own copy to use.
+if (!this->emitDupPtr(Initializer))
   return false;
 
-if (Func->hasRVO()) {
-  // RVO functions expect a pointer to initialize on the stack.
-  // Dup our existing pointer so it has its own copy to use.
-  if (!this->emitDupPtr(Initializer))
-return false;
-
-  return this->visit(CE);
-}
+return this->VisitCallExpr(CE);
   } else if (const auto *DIE = dyn_cast(Initializer)) {
 return this->visitInitializer(DIE->getExpr());
   }



___
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-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488152.
eopXD added a comment.

Rebase on top of landing of D141198 .


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(vbool64_t mask, vfloat16mf4_t dest, vfloat16mf4_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16mf4_t test_vcompress_vm_f16mf4(vbool64_t mask, vfloat16mf4_t src, size_t vl) {
+  return vcompress(mask, src, 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(vbool32_t mask, vfloat16mf2_t dest, vfloat16mf2_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16mf2_t test_vcompress_vm_f16mf2(vbool32_t mask, vfloat16mf2_t src, size_t vl) {
+  return vcompress(mask, src, 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(vbool16_t mask, vfloat16m1_t dest, vfloat16m1_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16m1_t test_vcompress_vm_f16m1(vbool16_t mask, vfloat16m1_t src, size_t vl) {
+  return vcompress(mask, src, 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(vbool8_t mask, vfloat16m2_t dest, vfloat16m2_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16m2_t test_vcompress_vm_f16m2(vbool8_t mask, vfloat16m2_t src, size_t vl) {
+  return vcompress(mask, src, 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(vbool4_t mask, vfloat16m4_t dest, vfloat16m4_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16m4_t test_vcompress_vm_f16m4(vbool4_t mask, vfloat16m4_t src, size_t vl) {
+  return vcompress(mask, src, 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(vbool2_t mask, vfloat16m8_t dest, vfloat16m8_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16m8_t test_vcompress_vm_f16m8(vbool2_t mask, vfloat16m8_t src, size_t vl) {
+  return vcompress(mask, src, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f32mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = c

[PATCH] D141008: [Clang][SPIR-V] Emit target extension types for OpenCL types on SPIR-V.

2023-01-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2260
 
-return CGF.CGM.getNullPointer(cast(ConvertType(DestTy)),
-  DestTy);
+// The type may be a target extension type instead of a pointer type
+// (e.g., OpenCL types mapped for SPIR-V). In the former case, emit a

Ok, yet this looks strange to me... do you have an example that hits this code?

At some point we added `CK_ZeroToOCLOpaqueType` so I wonder if we should be 
using this instead of `CK_NullToPointer` here i.e. ideally clang should not 
assume too early how type are mapped into target specific representation.




Comment at: clang/lib/CodeGen/CGOpenCLRuntime.cpp:200
+
+  // Choose the dimension of the image--this corresponds to the Dim parameter,
+  // so (e.g.) a 2D image has value 1, not 2.

Any reason for this? Can we create a `constexpr` map or enum type that would 
contain those numbers instead of using hard coded ones scattered around?



Comment at: clang/lib/CodeGen/CGOpenCLRuntime.cpp:226
+
+llvm::Type *CGSpirVOpenCLRuntime::convertOpenCLSpecificType(const Type *T) {
+  assert(T->isOpenCLSpecificType() && "Not an OpenCL specific type!");

This looks good in general but we keep CodeGen hierarchy target agnostic so the 
way to add specifics of an individual target is to extend `TargetCodeGenInfo` 
adding a new target hook member function for example it could be 
`getOpenCLSpecificType` or something like that. Then you can add SPIR-V 
specific logic into either `CommonSPIRTargetCodeGenInfo` or 
`SPIRVTargetCodeGenInfo` subclass. I would recommend to look at 
 `createEnqueuedBlockKernel` for inspiration 
https://clang.llvm.org/doxygen/CodeGen_2TargetInfo_8cpp_source.html#l12407. 





Comment at: clang/lib/CodeGen/CodeGenModule.cpp:239
+  // extension types.
+  if (getTriple().isSPIRV() || getTriple().isSPIR())
+OpenCLRuntime.reset(new CGSpirVOpenCLRuntime(*this));

Do we want to change old SPIR representation or keep it as is? It seems that 
SPIR spec defined them as LLVM's opaque pointer types... but I appreciate that 
for maintenance purposes it's easier to keep those in sync.



Comment at: llvm/docs/SPIRVUsage.rst:103
+
+All integer arguments take the same value as they do in the SPIR-V type name.
+For example, the OpenCL type ``image2d_depth_ro_t`` would be represented in

svenvh wrote:
> 
Any reference to the document/section explaining these instructions would be 
useful here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141008

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


[clang] d3b5634 - Speculatively fix the Clang sphinx build

2023-01-11 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-01-11T07:32:55-05:00
New Revision: d3b563444606b5d9a45c74eb60e7ebbcb97cc711

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

LOG: Speculatively fix the Clang sphinx build

This file builds correctly for me locally, but gives a warning about
not being able to lex the binary literal as C++ code.

This should fix the issue found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/38522

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 05eca35aa971..7fe74f2d4e3b 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3222,7 +3222,7 @@ the configuration (without a prefix: ``Auto``).
 
   * ``int8_t Binary`` Format separators in binary literals.
 
-.. code-block:: c++
+.. code-block:: text
 
-1: 0b10001101
 0: 0b10011'11'0110'1



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


[PATCH] D141432: Add two additional float8 types to MLIR and APFloat.

2023-01-11 Thread Jake Hall via Phabricator via cfe-commits
jakeh-gc added a comment.

The build failure is for clang-format on `APFloat.cpp`. That file has an 
unusual indentation, so I don't believe I can make that pass without 
reformatting the whole file. I believe doing that would make this diff harder 
to review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141432

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


[PATCH] D141297: [OpenCL] Allow undefining header-only features

2023-01-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!

Btw I wonder if in the future we could add some error or warning in case 
someone uses the same approach for frontend specific features, i.e.

  #ifdef __undef___opencl_c_generic_address_space
  #error "Feature __opencl_c_generic_address_space can only be disabled via 
-cl-ext flag"
  #endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141297

___
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-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488156.
eopXD added a comment.

Rebase on top of landing of D141198 .


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:[[TMP0:%.*]] = call i16 @llvm.riscv.vmv.x.s.nxv1i16( [[SRC:%.*]])
@@ -673,15 +610,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i16mf4

[PATCH] D141478: [include-cleaner] Improve header spelling in the presence of links

2023-01-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for tracking it down. The solution looks good to me. Since this is a 
fragile and subtle issue, is it possible to have a unittest for it? If it is 
not too hard, it would be nice to have a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141478

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


[PATCH] D141449: clang/OpenCL: Fix not setting convergent on block invoke kernels

2023-01-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:12426
 
   // FIXME: Apply default attributes
   F->addFnAttr(llvm::Attribute::NoUnwind);

If `ConstructDefaultFnAttrList` was used it would get convergent correctly... 
Should we be using the helper function here instead?


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

https://reviews.llvm.org/D141449

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


[clang] 800f0f1 - [docs] Apply previous sphinx fix to its actual source

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

Author: Emilia Dreamer
Date: 2023-01-11T14:44:36+02:00
New Revision: 800f0f1546b2352ba42a4777149afb13cb874fcd

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

LOG: [docs] Apply previous sphinx fix to its actual source

This clang-format documentation file is auto-generated from Format.h,
so the fix should be applied there, or else it will be overwritten
whenever Format.h is modified and that file is regenerated.

Added: 


Modified: 
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 3a90c1fe5be9..f6c8723e4d33 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2501,7 +2501,7 @@ struct FormatStyle {
   /// \endcode
   struct IntegerLiteralSeparatorStyle {
 /// Format separators in binary literals.
-/// \code
+/// \code{.text}
 ///-1: 0b10001101
 /// 0: 0b10011'11'0110'1
 /// 3: 0b100'111'101'101



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


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

2023-01-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488157.
eopXD added a comment.

Rebase on top of landing of D141198 .


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 =
   TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
   Out.push_back(std::make_unique(
   Name, SuffixStr, OverloadedName, OverloadedSuffixStr,
   MaskedIRName, /*IsMasked=*/t

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

2023-01-11 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 488158.
junaire added a comment.

Make build bots happy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/PrettyPrint.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -18,6 +19,8 @@
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h" // llvm_shutdown
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
@@ -65,6 +68,18 @@
   return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
+static void DeclareMagicFunctions(clang::Interpreter &Interp) {
+  llvm::ArrayRef MagicFunctions = {
+  "void __InterpreterPrettyPrint(void*, char);",
+  "void __InterpreterPrettyPrint(void*, int);",
+  "void __InterpreterPrettyPrint(void*, float);",
+  "void __InterpreterPrettyPrint(void*, double);",
+  };
+  for (llvm::StringRef Function : MagicFunctions) {
+llvm::cantFail(Interp.ParseAndExecute(Function));
+  }
+}
+
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
   ExitOnErr.setBanner("clang-repl: ");
@@ -109,21 +124,57 @@
 
   bool HasError = false;
 
+  DeclareMagicFunctions(*Interp);
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
 while (llvm::Optional Line = LE.readLine()) {
-  if (*Line == R"(%quit)")
+  llvm::StringRef Code = *Line;
+  if (Code.empty()) {
+continue;
+  }
+  if (Code == R"(%quit)")
 break;
-  if (*Line == R"(%undo)") {
+  if (Code == R"(%undo)") {
 if (auto Err = Interp->Undo()) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
   HasError = true;
 }
 continue;
   }
+  // TODO: Find a more reliable way to determine if this is something we
+  // need to prettty print.
+  if (!Code.starts_with("//") && !Code.starts_with("#") &&
+  !Code.ends_with("}") && !Code.ends_with(";")) {
+clang::Interpreter::PrettyPrintRAII X(*Interp);
+// Capture the expression we want to print.
+auto ExprOrErr = Interp->CaptureExpr(Code);
+if (!ExprOrErr) {
+  llvm::logAllUnhandledErrors(ExprOrErr.takeError(), llvm::errs(),
+  "error: ");
+  HasError = true;
+} else {
+  // Synthesize a CallExpr to `__InterpreterPrettyPrint`.
+  clang::Expr *E = Interp->SynthesizeCall(ExprOrErr.get());
+  // Generate a PartialTranslationUnit from the CallExpr.
+  llvm::Expected SynthesizedPTUOrErr =
+  Interp->GenPTU(E);
+  if (!SynthesizedPTUOrErr) {
+llvm::logAllUnhandledErrors(SynthesizedPTUOrErr.takeError(),
+llvm::errs(), "error: ");
+HasError = true;
+  }
+  // Let JIT handle all the rest.
+  if (auto Err = Interp->Execute(SynthesizedPTUOrErr.get())) {
+llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(),
+"error: ");
+HasError = true;
+  }
+}
+continue;
+  }
 
-  if (auto Err = Interp->ParseAndExecute(*Line)) {
+  if (auto Err = Interp->ParseAndExecute(Code)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 HasError = true;
   }
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -12,6 +12,7 @@
   )
 
 clang_target_link_libraries(clang-repl PRIVATE
+  clangAST
   clangBasic
   clangFrontend
   clangInterpreter
Index: clang/lib/Interpreter/PrettyPrint.cpp
===
--- /dev/null
+++ clang/lib/Interpreter/PrettyPrint.cpp
@@ -0,0 +1,37 @@
+#include "clang/AST/Type.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+static 

[PATCH] D112932: Use llvm.is_fpclass to implement FP classification functions

2023-01-11 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 488159.
sepavloff added a comment.

Remove support of __builtin_is{subnormal,zero,signaling}, rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112932

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/builtin_float.c
  clang/test/CodeGen/builtin_float_strictfp.c
  clang/test/CodeGen/builtins.c
  clang/test/CodeGen/isfpclass.c
  clang/test/CodeGen/strictfp_builtins.c

Index: clang/test/CodeGen/strictfp_builtins.c
===
--- clang/test/CodeGen/strictfp_builtins.c
+++ clang/test/CodeGen/strictfp_builtins.c
@@ -17,7 +17,7 @@
 // CHECK-NEXT:store i32 [[X:%.*]], ptr [[X_ADDR]], align 4
 // CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[STR_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[X_ADDR]], align 4
-// CHECK-NEXT:[[CALL:%.*]] = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef [[TMP0]], i32 noundef [[TMP1]]) [[ATTR4:#.*]]
+// CHECK-NEXT:[[CALL:%.*]] = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef [[TMP0]], i32 noundef [[TMP1]]) #[[ATTR4:[0-9]+]]
 // CHECK-NEXT:ret void
 //
 void p(char *str, int x) {
@@ -31,21 +31,21 @@
 // CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
 // CHECK-NEXT:store double [[D:%.*]], ptr [[D_ADDR]], align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load double, ptr [[D_ADDR]], align 8
-// CHECK-NEXT:[[ISZERO:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double 0.00e+00, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[ISZERO:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double 0.00e+00, metadata !"oeq", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:br i1 [[ISZERO]], label [[FPCLASSIFY_END:%.*]], label [[FPCLASSIFY_NOT_ZERO:%.*]]
 // CHECK:   fpclassify_end:
 // CHECK-NEXT:[[FPCLASSIFY_RESULT:%.*]] = phi i32 [ 4, [[ENTRY:%.*]] ], [ 0, [[FPCLASSIFY_NOT_ZERO]] ], [ 1, [[FPCLASSIFY_NOT_NAN:%.*]] ], [ [[TMP2:%.*]], [[FPCLASSIFY_NOT_INF:%.*]] ]
-// CHECK-NEXT:call void @p(ptr noundef @.str.1, i32 noundef [[FPCLASSIFY_RESULT]]) [[ATTR4]]
+// CHECK-NEXT:call void @p(ptr noundef @.str.1, i32 noundef [[FPCLASSIFY_RESULT]]) #[[ATTR4]]
 // CHECK-NEXT:ret void
 // CHECK:   fpclassify_not_zero:
-// CHECK-NEXT:[[CMP:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double [[TMP0]], metadata !"uno", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[CMP:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double [[TMP0]], metadata !"uno", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:br i1 [[CMP]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_NAN]]
 // CHECK:   fpclassify_not_nan:
-// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5:#.*]]
-// CHECK-NEXT:[[ISINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) #[[ATTR5:[0-9]+]]
+// CHECK-NEXT:[[ISINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:br i1 [[ISINF]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_INF]]
 // CHECK:   fpclassify_not_inf:
-// CHECK-NEXT:[[ISNORMAL:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x10, metadata !"uge", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[ISNORMAL:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x10, metadata !"uge", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:[[TMP2]] = select i1 [[ISNORMAL]], i32 2, i32 3
 // CHECK-NEXT:br label [[FPCLASSIFY_END]]
 //
@@ -57,14 +57,12 @@
 
 // CHECK-LABEL: @test_fp16_isinf(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca half, align 2
-// CHECK-NEXT:store half [[H:%.*]], ptr [[LD_ADDR]], align 2
-// CHECK-NEXT:[[TMP0:%.*]] = load half, ptr [[LD_ADDR]], align 2
-// CHECK-NEXT:[[BITCAST:%.*]] = bitcast half [[TMP0]] to i16
-// CHECK-NEXT:[[SHL1:%.*]] = shl i16 [[BITCAST]], 1
-// CHECK-NEXT:[[CMP:%.*]] = icmp eq i16 [[SHL1]], -2048
-// CHECK-NEXT:[[RES:%.*]] = zext i1 [[CMP]] to i32
-// CHECK-NEXT:call void @p(ptr noundef @.str.[[#STRID:2]], i32 noundef [[RES]]) [[ATTR4]]
+// CHECK-NEXT:[[H_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:store half [[H:%.*]], ptr [[H_ADDR]], align 2
+// CHECK-NEXT:[[TMP0:%.*]] = load half, ptr [[H_ADDR]], align 2
+// CHECK-NEXT:[[TMP1:%.

Re: [clang] 8bd65e5 - Revert "[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen."

2023-01-11 Thread Roman Lebedev via cfe-commits
Reminder to please always mention the reason for the revert/recommit
in the commit message.

On Wed, Jan 11, 2023 at 12:23 PM Francesco Petrogalli via cfe-commits
 wrote:
>
>
> Author: Francesco Petrogalli
> Date: 2023-01-11T10:22:56+01:00
> New Revision: 8bd65e535fb33bc48805bafed8217b16a853e158
>
> URL: 
> https://github.com/llvm/llvm-project/commit/8bd65e535fb33bc48805bafed8217b16a853e158
> DIFF: 
> https://github.com/llvm/llvm-project/commit/8bd65e535fb33bc48805bafed8217b16a853e158.diff
>
> LOG: Revert "[TargetParser] Generate the defs for RISCV CPUs using 
> llvm-tblgen."
>
> This reverts commit cf7a8305a2b4ddfd299c748136cb9a2960ef7089.
>
> Added:
> llvm/include/llvm/TargetParser/RISCVTargetParser.def
>
> Modified:
> clang/lib/Basic/Targets/RISCV.cpp
> clang/lib/Driver/ToolChains/Arch/RISCV.cpp
> llvm/include/llvm/CMakeLists.txt
> llvm/include/llvm/TargetParser/TargetParser.h
> llvm/include/llvm/module.extern.modulemap
> llvm/include/llvm/module.install.modulemap
> llvm/include/llvm/module.modulemap
> llvm/lib/Target/RISCV/RISCV.td
> llvm/lib/Target/RISCV/RISCVISelLowering.h
> llvm/lib/TargetParser/CMakeLists.txt
> llvm/lib/TargetParser/TargetParser.cpp
> llvm/utils/TableGen/CMakeLists.txt
> llvm/utils/TableGen/TableGen.cpp
> llvm/utils/TableGen/TableGenBackends.h
>
> Removed:
> llvm/include/llvm/TargetParser/CMakeLists.txt
> llvm/include/llvm/TargetParser/RISCVTargetParser.h
> llvm/lib/TargetParser/RISCVTargetParser.cpp
> llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
>
>
> 
> diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
> b/clang/lib/Basic/Targets/RISCV.cpp
> index a9adafddb7e54..7713398c83b20 100644
> --- a/clang/lib/Basic/Targets/RISCV.cpp
> +++ b/clang/lib/Basic/Targets/RISCV.cpp
> @@ -15,8 +15,8 @@
>  #include "clang/Basic/MacroBuilder.h"
>  #include "clang/Basic/TargetBuiltins.h"
>  #include "llvm/ADT/StringSwitch.h"
> +#include "llvm/Support/TargetParser.h"
>  #include "llvm/Support/raw_ostream.h"
> -#include "llvm/TargetParser/RISCVTargetParser.h"
>  #include 
>
>  using namespace clang;
>
> diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
> b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
> index 5c11064d81d59..4724e5c5a37ec 100644
> --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
> +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
> @@ -17,8 +17,8 @@
>  #include "llvm/Support/Error.h"
>  #include "llvm/Support/Host.h"
>  #include "llvm/Support/RISCVISAInfo.h"
> +#include "llvm/Support/TargetParser.h"
>  #include "llvm/Support/raw_ostream.h"
> -#include "llvm/TargetParser/RISCVTargetParser.h"
>
>  using namespace clang::driver;
>  using namespace clang::driver::tools;
>
> diff  --git a/llvm/include/llvm/CMakeLists.txt 
> b/llvm/include/llvm/CMakeLists.txt
> index d1dc0a99463ba..b46319f24fc8e 100644
> --- a/llvm/include/llvm/CMakeLists.txt
> +++ b/llvm/include/llvm/CMakeLists.txt
> @@ -1,7 +1,6 @@
>  add_subdirectory(IR)
>  add_subdirectory(Support)
>  add_subdirectory(Frontend)
> -add_subdirectory(TargetParser)
>
>  # If we're doing an out-of-tree build, copy a module map for generated
>  # header files into the build area.
>
> diff  --git a/llvm/include/llvm/TargetParser/CMakeLists.txt 
> b/llvm/include/llvm/TargetParser/CMakeLists.txt
> deleted file mode 100644
> index d102dcf4dde7e..0
> --- a/llvm/include/llvm/TargetParser/CMakeLists.txt
> +++ /dev/null
> @@ -1,4 +0,0 @@
> -set(LLVM_TARGET_DEFINITIONS ${CMAKE_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
> -tablegen(LLVM RISCVTargetParserDef.inc -gen-riscv-target-def -I 
> ${CMAKE_SOURCE_DIR}/lib/Target/RISCV/)
> -add_public_tablegen_target(RISCVTargetParserTableGen)
> -
>
> diff  --git a/llvm/include/llvm/TargetParser/RISCVTargetParser.def 
> b/llvm/include/llvm/TargetParser/RISCVTargetParser.def
> new file mode 100644
> index 0..6d65ac1c398e7
> --- /dev/null
> +++ b/llvm/include/llvm/TargetParser/RISCVTargetParser.def
> @@ -0,0 +1,35 @@
> +#ifndef PROC
> +#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)
> +#endif
> +
> +PROC(INVALID, {"invalid"}, FK_INVALID, {""})
> +PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""})
> +PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""})
> +PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""})
> +PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""})
> +PROC(SIFIVE_E20, {"sifive-e20"}, FK_NONE, {"rv32imc"})
> +PROC(SIFIVE_E21, {"sifive-e21"}, FK_NONE, {"rv32imac"})
> +PROC(SIFIVE_E24, {"sifive-e24"}, FK_NONE, {"rv32imafc"})
> +PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
> +PROC(SIFIVE_E34, {"sifive-e34"}, FK_NONE, {"rv32imafc"})
> +PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
> +PROC(SIFIVE_S21, {"sifive-s21"}, FK_64BIT, {"rv64imac"})
> +PROC(SIFIVE_S51, {"sifive-s51"}, FK_64BIT, {"rv64imac"})
> +PROC(SIFIVE_S54, {"sifive-s54"}, FK_64BIT, {"rv64gc"})
> +PROC(SIFIVE_S76, {"sifive-s76"}, FK_64BIT, {"rv64gc"})

[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

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



Comment at: clang/test/FixIt/fixit-const-var-init.cpp:24
+
+template <> constexpr float d; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{24:42-24:42}:" = 0.0"

v1nh1shungry wrote:
> aaron.ballman wrote:
> > v1nh1shungry wrote:
> > > aaron.ballman wrote:
> > > > I'd like to see some additional test coverage for more complicated 
> > > > declarators:
> > > > ```
> > > > void (* const func)(int, int);
> > > > const int var [[clang::annotate("")]];
> > > > ```
> > > One more question: I just did the second test
> > > 
> > > ```
> > > const int var [[clang::annotate("")]];
> > > ```
> > > 
> > > and it inserted the fix hint after the identifier.
> > > 
> > > Is this the expected behavior of `getEndLoc()`?
> > @erichkeane and I talked about this off-list because it's a bit of an 
> > academic question as to whether an attribute is "part" of a declaration or 
> > not. We ultimately decided that we think it's best for the attribute to 
> > *not* be considered part of the source range of the variable declaration; 
> > they are wholly separate AST nodes.
> > 
> > So based on that, we think you will need some changes to SemaInit.cpp after 
> > all. And you'll have to use `SourceManager::isBeforeInTranslationUnit()` to 
> > determine if the begin source location of the attribute is after the end 
> > source location of the variable or not (because the attribute could go 
> > before the type information or after the variable name).
> > 
> > There's another test case to consider that hopefully will Just Work with 
> > this design, but is worth testing explicitly:
> > ```
> > void (* const func [[clang::annotate("test")]])(int, int);
> > ```
> I have trouble getting the location of the right bracket of the attribute 
> list, which may be used to insert the fix hint. Could you please give me some 
> hints? Thanks a lot!
> I have trouble getting the location of the right bracket of the attribute 
> list, which may be used to insert the fix hint. Could you please give me some 
> hints? Thanks a lot!

Oh boy, that's an interesting problem, isn't it! We keep all of the attribute 
AST nodes with the declaration, and each attribute knows its own source range, 
but we *don't* keep the source locations for where the full attribute list 
appears. e.g.,
```
__attribute__((foo)) const int var [[bar, baz]];
```
`var` will have three attributes associated with it, but the only source 
location information you have access to is for the `foo`, `bar`, and `baz` 
tokens. Each of those attributes also keeps track of what syntax was used, so 
you could tell that `foo` was a GNU-style attribute while `bar` and `baz` were 
C++. But we don't keep enough information about `bar` and `baz` being part of 
the same attribute list or whether that attribute list is leading or trailing. 
You have to calculate all of this yourself and some of it might not even be 
possible to calculate (for example, the user could have done 
`__attribute__((foo)) const int var [[bar]] [[baz]];` and the AST would come 
out the same as the previous example).

I'd say that's way more work than is reasonable for this patch, so my 
suggestion is to file a GitHub issue about the problem with attributes, note 
the implementation issues, and then we'll ignore attributes for this patch.

@erichkeane -- something for us to consider is how to improve this in the AST. 
We run into problems when doing AST pretty printing because of attributes for 
these same reasons. It seems to me that the `Decl`/`Stmt`/`TypeLoc` nodes need 
to keep a list of source ranges for attributes around (since there can be 
multiple ranges for declarations). WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

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


[PATCH] D141440: [OpenMP] Adjust phases for AMDGPU offloading for OpenMP in save-temps mode

2023-01-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4411
 ++TCAndArch;
   }
 }

JonChesterfield wrote:
> Why is rdc involved here?
HIP goes straight through a separate linker phase in non-RDC mode. Setting the 
type here would prevent that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141440

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


[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

2023-01-11 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry added a comment.

Thanks for the reply! I'll raise a GitHub issue.

> var will have three attributes associated with it, but the only source 
> location information you have access to is for the foo, bar, and baz tokens. 
> Each of those attributes also keeps track of what syntax was used, so you 
> could tell that foo was a GNU-style attribute while bar and baz were C++. But 
> we don't keep enough information about bar and baz being part of the same 
> attribute list or whether that attribute list is leading or trailing. You 
> have to calculate all of this yourself and some of it might not even be 
> possible to calculate (for example, the user could have done 
> __attribute__((foo)) const int var [[bar]] [[baz]]; and the AST would come 
> out the same as the previous example).

Can I post your reply there? I think it will help.

> and then we'll ignore attributes for this patch.

Then I think this patch is ready for a review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

___
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-11 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 488169.
ccotter added a comment.

- revert git changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141463

Files:
  clang-tools-extra/clang-tidy/rename_check.py


Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -93,12 +93,9 @@
 
 
 def getListOfFiles(clang_tidy_path):
-  files = glob.glob(os.path.join(clang_tidy_path, '*'))
-  for dirname in files:
-if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname, '*'))
+  files = glob.glob(os.path.join(clang_tidy_path, '**'), recursive=True)
   files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',
-  'clang-tidy', '*'))
+  'clang-tidy', 'checkers', '**'), 
recursive=True)
   files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs',
   'clang-tidy', 'checks', '*'))
   return [filename for filename in files if os.path.isfile(filename)]
@@ -273,10 +270,12 @@
 deleteMatchingLines(os.path.join(old_module_path, modulecpp),
   '\\b' + check_name_camel + '|\\b' + args.old_check_name)
 
+  old_check_filename = '-'.join(args.old_check_name.split('-')[1:])
+  new_check_filename = '-'.join(args.new_check_name.split('-')[1:])
+
   for filename in getListOfFiles(clang_tidy_path):
 originalName = filename
-filename = fileRename(filename, args.old_check_name,
-  args.new_check_name)
+filename = fileRename(filename, old_check_filename, new_check_filename)
 filename = fileRename(filename, check_name_camel, new_check_name_camel)
 replaceInFile(filename, generateCommentLineHeader(originalName),
   generateCommentLineHeader(filename))


Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -93,12 +93,9 @@
 
 
 def getListOfFiles(clang_tidy_path):
-  files = glob.glob(os.path.join(clang_tidy_path, '*'))
-  for dirname in files:
-if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname, '*'))
+  files = glob.glob(os.path.join(clang_tidy_path, '**'), recursive=True)
   files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',
-  'clang-tidy', '*'))
+  'clang-tidy', 'checkers', '**'), recursive=True)
   files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs',
   'clang-tidy', 'checks', '*'))
   return [filename for filename in files if os.path.isfile(filename)]
@@ -273,10 +270,12 @@
 deleteMatchingLines(os.path.join(old_module_path, modulecpp),
   '\\b' + check_name_camel + '|\\b' + args.old_check_name)
 
+  old_check_filename = '-'.join(args.old_check_name.split('-')[1:])
+  new_check_filename = '-'.join(args.new_check_name.split('-')[1:])
+
   for filename in getListOfFiles(clang_tidy_path):
 originalName = filename
-filename = fileRename(filename, args.old_check_name,
-  args.new_check_name)
+filename = fileRename(filename, old_check_filename, new_check_filename)
 filename = fileRename(filename, check_name_camel, new_check_name_camel)
 replaceInFile(filename, generateCommentLineHeader(originalName),
   generateCommentLineHeader(filename))
___
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-11 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked an inline comment as done.
ccotter added inline comments.



Comment at: clang-tools-extra/clang-tidy/rename_check.py:75
   print("Renaming '%s' -> '%s'..." % (fileName, newFileName))
-  os.rename(fileName, newFileName)
+  subprocess.check_call(["git", "mv", fileName, newFileName])
   return newFileName

carlosgalvezp wrote:
> I'm not sure it's the responsibility of this check to do git stuff, there may 
> be use cases where this is not wanted / users might not expect this behavior. 
> Introducing a dependency to git might also make this script harder to unit 
> test in the future.
> 
> Thus I think it'd be better to keep the original behavior so the script has 
> one single responsibility. What do you think @njames93 ?
I wasn't sure about this - reverted this. Single responsibility is better.


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] D140693: [Driver][RISCV] Adjust the priority between -mcpu, -mtune and -march

2023-01-11 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 488173.
kito-cheng added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Changes:

- Add release note to mention the behavior change for `-march` and `-mcpu`.
- New way to implement this behavior, passing all supported extension with `-` 
or `+`, this way is less RISC-V specific logical around `-mcpu`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140693

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-cpus.c
  clang/test/Driver/riscv-default-features.c
  clang/test/Driver/riscv-march-mcpu-mtune.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp

Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
@@ -329,9 +330,9 @@
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(
-std::vector &Features,
-std::function StrAlloc) const {
+void RISCVISAInfo::toFeatures(std::vector &Features,
+  std::function StrAlloc,
+  bool AddAllExtension) const {
   for (auto const &Ext : Exts) {
 StringRef ExtName = Ext.first;
 
@@ -344,6 +345,19 @@
   Features.push_back(StrAlloc("+" + ExtName));
 }
   }
+  if (AddAllExtension) {
+for (auto const Ext : SupportedExtensions) {
+  if (Exts.find(Ext.Name) != Exts.end())
+continue;
+  Features.push_back(StrAlloc(Twine("-") + Ext.Name));
+}
+
+for (auto const Ext : SupportedExperimentalExtensions) {
+  if (Exts.find(Ext.Name) != Exts.end())
+continue;
+  Features.push_back(StrAlloc(Twine("-experimental-") + Ext.Name));
+}
+  }
 }
 
 // Extensions may have a version number, and may be separated by
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -56,7 +56,8 @@
 
   /// Convert RISCV ISA info to a feature vector.
   void toFeatures(std::vector &Features,
-  std::function StrAlloc) const;
+  std::function StrAlloc,
+  bool AddAllExtension) const;
 
   const OrderedExtensionMap &getExtensions() const { return Exts; };
 
Index: clang/test/Driver/riscv-march-mcpu-mtune.c
===
--- /dev/null
+++ clang/test/Driver/riscv-march-mcpu-mtune.c
@@ -0,0 +1,75 @@
+// Check the priority between -mcpu, -mtune and -march
+
+// sifive-e76 is rv32imafc and sifive-e31 is rv32imac
+
+// -mcpu, -mtune and -march are not given, pipeline model and arch ext. use
+// default setting.
+// RUN: %clang --target=riscv32-elf -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-DEFAULT %s
+// CHECK-DEFAULT: "-target-cpu" "generic-rv32"
+// CHECK-DEFAULT: "-target-feature" "+m" "-target-feature" "+a"
+// CHECK-DEFAULT: "-target-feature" "+c"
+
+// -mtune is given, pipeline model take from -mtune, arch ext. use
+// default setting.
+// RUN: %clang --target=riscv32 -mtune=sifive-e76 -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MTUNE-E76 %s
+// MTUNE-E76: "-target-feature" "+m" "-target-feature" "+a"
+// MTUNE-E76: "-target-feature" "+c"
+// MTUNE-E76: "-target-feature" "-f"
+// MTUNE-E76: "-tune-cpu" "sifive-e76"
+
+// -march is given, arch ext. take from -march, pipeline model use
+// default setting.
+// RUN: %clang --target=riscv32 -### -c %s -march=rv32imafdc 2>&1 \
+// RUN: | FileCheck -check-prefix=MARCH-RV32IMAFDC %s
+// MARCH-RV32IMAFDC: "-target-cpu" "generic-rv32"
+// MARCH-RV32IMAFDC: "-target-feature" "+m" "-target-feature" "+a"
+// MARCH-RV32IMAFDC: "-target-feature" "+f" "-target-feature" "+d"
+// MARCH-RV32IMAFDC: "-target-feature" "+c"
+// MARCH-RV32IMAFDC-NOT: "-target-cpu"
+
+// -mcpu is given, pipeline model and arch ext. from -mcpu.
+// RUN: %clang --target=riscv32 -### -c %s -mcpu=sifive-e76 2>&1 \
+// RUN: | FileCheck -check-prefix=MCPU-E76 %s
+// MCPU-E76: "-target-cpu" "sifive-e76"
+// MCPU-E76: "-target-feature" "+m" "-target-feature" "+a"
+// MCPU-E76: "-target-feature" "+f" "-target-feature" "+c"
+
+// -mcpu and -mtune are given, so pipeline model take from -mtune, and arch ext.
+// take from -mcpu since -march is not given.
+// RUN: %clang --target=riscv32 -### -c %s -mcpu=sifive-e76 -mtune=sifive-e31 2>&1 \
+// RUN: | FileCheck -check-prefix=MCPU-E76-MTUNE-E31 %s
+// MCPU-E76-MTUNE-E31: "-target-cpu" "sifive-e76"
+// MCPU-E76-MTU

[PATCH] D140693: [Driver][RISCV] Adjust the priority between -mcpu, -mtune and -march

2023-01-11 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 488175.
kito-cheng added a comment.

Changes:

- Trim unexpected change by clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140693

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-cpus.c
  clang/test/Driver/riscv-default-features.c
  clang/test/Driver/riscv-march-mcpu-mtune.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp

Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
@@ -329,9 +330,9 @@
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(
-std::vector &Features,
-std::function StrAlloc) const {
+void RISCVISAInfo::toFeatures(std::vector &Features,
+  std::function StrAlloc,
+  bool AddAllExtension) const {
   for (auto const &Ext : Exts) {
 StringRef ExtName = Ext.first;
 
@@ -344,6 +345,19 @@
   Features.push_back(StrAlloc("+" + ExtName));
 }
   }
+  if (AddAllExtension) {
+for (auto const Ext : SupportedExtensions) {
+  if (Exts.find(Ext.Name) != Exts.end())
+continue;
+  Features.push_back(StrAlloc(Twine("-") + Ext.Name));
+}
+
+for (auto const Ext : SupportedExperimentalExtensions) {
+  if (Exts.find(Ext.Name) != Exts.end())
+continue;
+  Features.push_back(StrAlloc(Twine("-experimental-") + Ext.Name));
+}
+  }
 }
 
 // Extensions may have a version number, and may be separated by
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -56,7 +56,8 @@
 
   /// Convert RISCV ISA info to a feature vector.
   void toFeatures(std::vector &Features,
-  std::function StrAlloc) const;
+  std::function StrAlloc,
+  bool AddAllExtension) const;
 
   const OrderedExtensionMap &getExtensions() const { return Exts; };
 
Index: clang/test/Driver/riscv-march-mcpu-mtune.c
===
--- /dev/null
+++ clang/test/Driver/riscv-march-mcpu-mtune.c
@@ -0,0 +1,75 @@
+// Check the priority between -mcpu, -mtune and -march
+
+// sifive-e76 is rv32imafc and sifive-e31 is rv32imac
+
+// -mcpu, -mtune and -march are not given, pipeline model and arch ext. use
+// default setting.
+// RUN: %clang --target=riscv32-elf -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-DEFAULT %s
+// CHECK-DEFAULT: "-target-cpu" "generic-rv32"
+// CHECK-DEFAULT: "-target-feature" "+m" "-target-feature" "+a"
+// CHECK-DEFAULT: "-target-feature" "+c"
+
+// -mtune is given, pipeline model take from -mtune, arch ext. use
+// default setting.
+// RUN: %clang --target=riscv32 -mtune=sifive-e76 -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MTUNE-E76 %s
+// MTUNE-E76: "-target-feature" "+m" "-target-feature" "+a"
+// MTUNE-E76: "-target-feature" "+c"
+// MTUNE-E76: "-target-feature" "-f"
+// MTUNE-E76: "-tune-cpu" "sifive-e76"
+
+// -march is given, arch ext. take from -march, pipeline model use
+// default setting.
+// RUN: %clang --target=riscv32 -### -c %s -march=rv32imafdc 2>&1 \
+// RUN: | FileCheck -check-prefix=MARCH-RV32IMAFDC %s
+// MARCH-RV32IMAFDC: "-target-cpu" "generic-rv32"
+// MARCH-RV32IMAFDC: "-target-feature" "+m" "-target-feature" "+a"
+// MARCH-RV32IMAFDC: "-target-feature" "+f" "-target-feature" "+d"
+// MARCH-RV32IMAFDC: "-target-feature" "+c"
+// MARCH-RV32IMAFDC-NOT: "-target-cpu"
+
+// -mcpu is given, pipeline model and arch ext. from -mcpu.
+// RUN: %clang --target=riscv32 -### -c %s -mcpu=sifive-e76 2>&1 \
+// RUN: | FileCheck -check-prefix=MCPU-E76 %s
+// MCPU-E76: "-target-cpu" "sifive-e76"
+// MCPU-E76: "-target-feature" "+m" "-target-feature" "+a"
+// MCPU-E76: "-target-feature" "+f" "-target-feature" "+c"
+
+// -mcpu and -mtune are given, so pipeline model take from -mtune, and arch ext.
+// take from -mcpu since -march is not given.
+// RUN: %clang --target=riscv32 -### -c %s -mcpu=sifive-e76 -mtune=sifive-e31 2>&1 \
+// RUN: | FileCheck -check-prefix=MCPU-E76-MTUNE-E31 %s
+// MCPU-E76-MTUNE-E31: "-target-cpu" "sifive-e76"
+// MCPU-E76-MTUNE-E31: "-target-feature" "+m" "-target-feature" "+a"
+// MCPU-E76-MTUNE-E31: "-target-feature" "+f" "-target-feature" "+c"
+// MCPU-E76-MTUNE-E31: "-tune-cpu" "sifive-e31"
+
+// RUN: %clang --target=riscv32 -### -c %s -mtune=sifive-e76 -mcpu=sifive-e31 2>&1 \

[PATCH] D140693: [Driver][RISCV] Adjust the priority between -mcpu, -mtune and -march

2023-01-11 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: clang/test/Driver/riscv-cpus.c:13
+// MCPU-SYNTACORE-SCR1-BASE: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR1-BASE: "-target-feature" "-64bit"
 // MCPU-SYNTACORE-SCR1-BASE: "-target-abi" "ilp32"

Need to break this into two line since we'll add bunch of negative list of 
extension here.



Comment at: clang/test/Driver/riscv-default-features.c:5
+// RV32: "target-features"="+32bit,+a,+c,+m,+relax,
+// RV32-SAME: -save-restore
+// RV64: "target-features"="+64bit,+a,+c,+m,+relax,

Same reason here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140693

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


[PATCH] D141478: [include-cleaner] Improve header spelling in the presence of links

2023-01-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D141478#4043134 , @hokein wrote:

> Thanks for tracking it down. The solution looks good to me. Since this is a 
> fragile and subtle issue, is it possible to have a unittest for it? If it is 
> not too hard, it would be nice to have a test.

I think it's hard to write a test that's worth anything :-(

It can't be a test that poking FileManager doesn't affect spelling, because I 
didn't fix that.
I can test specifically that getExports() doesn't affect the getName() of 
relevant fileentries, but if we regress this symptom that's very unlikely to be 
the mechanism.
An end-to-end test for the symptom needs to be set up in a way that tickles the 
bad side-effect at exactly the wrong time, and it's hard to predict how to do 
that in general.

I'm not happy with this patch, but I'm not sure a bad test would help with that 
:-\


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141478

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


[clang-tools-extra] d7bba07 - [include-cleaner] Improve header spelling in the presence of links

2023-01-11 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-01-11T14:44:22+01:00
New Revision: d7bba07526a7298c9331de031dec15daecff3503

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

LOG: [include-cleaner] Improve header spelling in the presence of links

HeaderSearch uses FileEntry::getName() to determine the best spelling of a
header. FileEntry::getName() is now the name of the *last* retrieved ref.
This means that when FileManager::getFile() hits an existing inode through a new
path, it changes the spelling of that header.

In the absence of explicit logic to track the preferred name(s) of header files,
we should avoid gratuitously calling getFile() with paths different than how
the header was originally included, such as the result of realpath().

The originally-specified path should be fine here:
 - if the same filemanager is being used for record/analysis, we'll hit the
   filename cache
 - if a different filemanager is being used e.g. preamble scenario, we should
   get the same result unless either the working directory has changed (which it
   shouldn't, else many other things will fail) or the file has gone/changed
   inode (in which case the old method doesn't work either)

Needless to say this is fragile, but talking to @kadircet offline, it's good
enough for our purposes for now.

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

Added: 


Modified: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
clang-tools-extra/include-cleaner/lib/Record.cpp

Removed: 




diff  --git 
a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h 
b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
index a077c26a04b83..cf01e3416dec2 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
+++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
@@ -90,12 +90,15 @@ class PragmaIncludes {
   IWYUPublic;
 
   /// A reverse map from the underlying header to its exporter headers.
-  //
-  //  There's no way to get a FileEntry from a UniqueID, especially when it
-  //  hasn't been opened before. So store the full path and convert it to a
-  //  FileEntry by opening the file again through a FileManager.
+  ///
+  /// There's no way to get a FileEntry from a UniqueID, especially when it
+  /// hasn't been opened before. So store the path and convert it to a
+  /// FileEntry by opening the file again through a FileManager.
+  ///
+  /// We don't use RealPathName, as opening the file through a 
diff erent name
+  /// changes its preferred name. Clearly this is fragile!
   llvm::DenseMap>
+ llvm::SmallVector>
   IWYUExportBy;
 
   /// Contains all non self-contained files detected during the parsing.

diff  --git a/clang-tools-extra/include-cleaner/lib/Record.cpp 
b/clang-tools-extra/include-cleaner/lib/Record.cpp
index 4df65959011c5..54350df0b00f9 100644
--- a/clang-tools-extra/include-cleaner/lib/Record.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -204,7 +204,7 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, 
public CommentHandler {
 Top.SeenAtLine == HashLine) {
   if (IncludedHeader)
 Out->IWYUExportBy[IncludedHeader->getUniqueID()].push_back(
-Top.FullPath);
+Top.Path);
   // main-file #include with export pragma should never be removed.
   if (Top.SeenAtFile == SM.getMainFileID())
 Out->ShouldKeep.insert(HashLine);
@@ -251,14 +251,13 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, 
public CommentHandler {
SM.getFileOffset(Range.getBegin()));
 // Record export pragma.
 if (Pragma->startswith("export")) {
-  ExportStack.push_back(
-  {CommentLine, CommentFID,
-   save(SM.getFileEntryForID(CommentFID)->tryGetRealPathName()),
-   false});
+  ExportStack.push_back({CommentLine, CommentFID,
+ save(SM.getFileEntryForID(CommentFID)->getName()),
+ false});
 } else if (Pragma->startswith("begin_exports")) {
-  ExportStack.push_back(
-  {CommentLine, CommentFID,
-   save(SM.getFileEntryForID(CommentFID)->tryGetRealPathName()), 
true});
+  ExportStack.push_back({CommentLine, CommentFID,
+ save(SM.getFileEntryForID(CommentFID)->getName()),
+ true});
 } else if (Pragma->startswith("end_exports")) {
   // FIXME: be robust on unmatching cases. We should only pop the stack if
   // the begin_exports and end_exports is in the same file.
@@ -297,8 +296,8 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, 
public CommentHandler {
 int SeenAtLine

[PATCH] D141478: [include-cleaner] Improve header spelling in the presence of links

2023-01-11 Thread Sam McCall 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 rGd7bba07526a7: [include-cleaner] Improve header spelling in 
the presence of links (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141478

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/Record.cpp


Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -204,7 +204,7 @@
 Top.SeenAtLine == HashLine) {
   if (IncludedHeader)
 Out->IWYUExportBy[IncludedHeader->getUniqueID()].push_back(
-Top.FullPath);
+Top.Path);
   // main-file #include with export pragma should never be removed.
   if (Top.SeenAtFile == SM.getMainFileID())
 Out->ShouldKeep.insert(HashLine);
@@ -251,14 +251,13 @@
SM.getFileOffset(Range.getBegin()));
 // Record export pragma.
 if (Pragma->startswith("export")) {
-  ExportStack.push_back(
-  {CommentLine, CommentFID,
-   save(SM.getFileEntryForID(CommentFID)->tryGetRealPathName()),
-   false});
+  ExportStack.push_back({CommentLine, CommentFID,
+ save(SM.getFileEntryForID(CommentFID)->getName()),
+ false});
 } else if (Pragma->startswith("begin_exports")) {
-  ExportStack.push_back(
-  {CommentLine, CommentFID,
-   save(SM.getFileEntryForID(CommentFID)->tryGetRealPathName()), 
true});
+  ExportStack.push_back({CommentLine, CommentFID,
+ save(SM.getFileEntryForID(CommentFID)->getName()),
+ true});
 } else if (Pragma->startswith("end_exports")) {
   // FIXME: be robust on unmatching cases. We should only pop the stack if
   // the begin_exports and end_exports is in the same file.
@@ -297,8 +296,8 @@
 int SeenAtLine = 0; // 1-based line number.
 // The file where we saw the pragma.
 FileID SeenAtFile;
-// FullPath of the file SeenAtFile.
-StringRef FullPath;
+// Name (per FileEntry::getName()) of the file SeenAtFile.
+StringRef Path;
 // true if it is a block begin/end_exports pragma; false if it is a
 // single-line export pragma.
 bool Block = false;
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
@@ -90,12 +90,15 @@
   IWYUPublic;
 
   /// A reverse map from the underlying header to its exporter headers.
-  //
-  //  There's no way to get a FileEntry from a UniqueID, especially when it
-  //  hasn't been opened before. So store the full path and convert it to a
-  //  FileEntry by opening the file again through a FileManager.
+  ///
+  /// There's no way to get a FileEntry from a UniqueID, especially when it
+  /// hasn't been opened before. So store the path and convert it to a
+  /// FileEntry by opening the file again through a FileManager.
+  ///
+  /// We don't use RealPathName, as opening the file through a different name
+  /// changes its preferred name. Clearly this is fragile!
   llvm::DenseMap>
+ llvm::SmallVector>
   IWYUExportBy;
 
   /// Contains all non self-contained files detected during the parsing.


Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -204,7 +204,7 @@
 Top.SeenAtLine == HashLine) {
   if (IncludedHeader)
 Out->IWYUExportBy[IncludedHeader->getUniqueID()].push_back(
-Top.FullPath);
+Top.Path);
   // main-file #include with export pragma should never be removed.
   if (Top.SeenAtFile == SM.getMainFileID())
 Out->ShouldKeep.insert(HashLine);
@@ -251,14 +251,13 @@
SM.getFileOffset(Range.getBegin()));
 // Record export pragma.
 if (Pragma->startswith("export")) {
-  ExportStack.push_back(
-  {CommentLine, CommentFID,
-   save(SM.getFileEntryForID(CommentFID)->tryGetRealPathName()),
-   false});
+  ExportStack.push_back({CommentLine, CommentFID,
+ save(SM.getFileEntryForID(CommentFID)->getName()),
+ false});
 } else if (Pragma->startswith("begin_exports")) {
-  ExportStack.push_back(
-  

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

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

LGTM, thanks for the fix! Let's give a few days for other reviewers to get a 
look.


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] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-01-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: erichkeane.
aaron.ballman added a subscriber: erichkeane.
aaron.ballman added a comment.

In D128440#4042753 , @pmatos wrote:

> @aaron.ballman Hi Aaron, since you requested an RFC for this. I wonder if you 
> have any comments for this or the other related patches: D122215 
> , D139010 

I appreciate your patience with the extreme delay on getting you feedback after 
I asked you to post the RFC; I wanted to give the RFC a chance to bake and then 
ran into the holiday season as a result. Sorry for that!

Adding @erichkeane as new attributes code owner as well, in case he's got 
additional thoughts.




Comment at: clang/include/clang/Basic/TokenKinds.def:666
+// WebAssembly Type Extension
+KEYWORD(__funcref , KEYALL)
+

pmatos wrote:
> aaron.ballman wrote:
> > Why is this a keyword in all language modes?
> I might have misread the docs but this keyword should be available for both C 
> and C++. Maybe I want `KEYC99 | KEYCXX` ?
I was thinking this keyword would only work for a web assembly target, so we'd 
likely want to add `KEYWEBASM` or something to the list like we have for 
`KEYALTIVEC`. But now I'm second-guessing that instinct and am wondering what 
behavior we want here.

1) Parse the keyword in all language modes and for all targets, give an ignored 
attribute warning if the target isn't web assembly
2) Parse the keyword in all language modes and for all targets, give a parse 
time diagnostic (error?) if the target isn't web assembly
3) Only expose the keyword if the target is web assembly, otherwise it parses 
as an identifier and you get the usual parse errors

My original thinking was that we wanted #3, but on reflection both #1 and #2 
seem reasonable to me. Do you have a preference? I think I prefer either 2 or 3 
over 1 because this involves the type system (errors are usually a better 
approach in that case).



Comment at: clang/lib/AST/TypePrinter.cpp:1652-1653
 
+  if (T->isWebAssemblyFuncrefSpec()) {
+assert(T->getAttrKind() == attr::WebAssemblyFuncref);
+OS << "__funcref";

I'm not certain that the `assert` adds much here given that the predicate tests 
exactly the same thing, perhaps remove it (and drop the curly braces)?



Comment at: clang/lib/Basic/Targets/WebAssembly.h:44-45
+0,  // ptr64
+10, // wasm_externref,
+20, // wasm_funcref
+};

I'm not super familiar with the address space maps, but this sets of my spidey 
senses. All of the other address space maps end with:

ptr64, hlsl_groupshared, wasm_funcref

but this one is ending with:

ptr64, wasm_externref, wasm_funcref

which makes me think something's amiss here. Thoughts?



Comment at: clang/lib/Parse/ParseDecl.cpp:844
+void Parser::ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &attrs) {
+  if (Tok.is(tok::kw___funcref)) {
+IdentifierInfo *AttrName = Tok.getIdentifierInfo();

I think we should assert this condition; we already know what the token is 
before we call this function anyway.



Comment at: clang/lib/Parse/ParseDecl.cpp:5911-5914
+  if (AttrReqs & AR_DeclspecAttributesParsed) {
+ParseWebAssemblyFuncrefTypeAttribute(DS.getAttributes());
+continue;
+  }

I don't think we need to care about attribute requirements because this is a 
keyword attribute (this feature is used to prohibit attributes in certain 
grammars and I don't think that applies here).



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

These comments no longer seem to match the code -- nothing creates a 
`FunctionDecl` here.



Comment at: clang/lib/Sema/SemaChecking.cpp:6711
+  // Prepare FDecl type
+  QualType Pointee = Context.getFunctionType(Context.VoidTy, {}, {});
+  QualType Type = Context.getPointerType(Pointee);

I'm still wondering why this code is needed and what it's trying to do. It 
worries me that we're changing the type of the call expression like this.



Comment at: clang/lib/Sema/SemaDecl.cpp:14816
+  // WebAssembly allows reference types as parameters. Funcref in 
particular
+  // lives in a different address space
+  !(T->isFunctionPointerType() &&





Comment at: clang/lib/Sema/SemaType.cpp:7351
+  if (Attrs[NewAttrKind]) {
+S.Diag(PAttr.getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
+return true;

We're missing Sema test coverage for all the various diagnostics you've a

[PATCH] D141206: [clang] [MinGW] Avoid adding /include and /lib when cross compiling

2023-01-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 488182.
mstorsjo added a comment.

Updated with some testcases. This does test that the include directory is 
omitted when cross compiling, but those kinds of tests, which set up a 
simulated toolchain environment with symlinks, don't run on actual Windows - so 
it's not quite as easy to test the case that we actually do keep the unprefixed 
include directory on Windows. As this matches the current testing coverage 
status quo, I hope this is ok...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141206

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/test/Driver/mingw-sysroot.cpp


Index: clang/test/Driver/mingw-sysroot.cpp
===
--- clang/test/Driver/mingw-sysroot.cpp
+++ clang/test/Driver/mingw-sysroot.cpp
@@ -31,6 +31,18 @@
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10"
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include"
 
+// This test is only executed on non-Windows systems, i.e. only when
+// cross compiling. Check that we don't add the tool root's plain include
+// directory to the path - this would end up including /usr/include for
+// cross toolchains installed in /usr.
+// CHECK_TESTROOT_GCC-NOT: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}include"
+
+// If we pass --sysroot explicitly, then we do include /include
+// even when cross compiling.
+// RUN: %clang -target x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ 
--sysroot="%T/testroot-gcc" -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_TESTROOT_GCC_EXPLICIT %s
+
+// CHECK_TESTROOT_GCC_EXPLICIT: "-internal-isystem" 
"{{[^"]+}}/testroot-gcc{{/|}}include"
+
 
 // If there's a matching sysroot next to the clang binary itself, prefer that
 // over a gcc in the path:
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -348,6 +348,15 @@
  Exec, CmdArgs, Inputs, Output));
 }
 
+static bool isCrossCompiling(const llvm::Triple &T, bool RequireArchMatch) {
+  llvm::Triple HostTriple(llvm::Triple::normalize(LLVM_HOST_TRIPLE));
+  if (HostTriple.getOS() != llvm::Triple::Win32)
+return true;
+  if (RequireArchMatch && HostTriple.getArch() != T.getArch())
+return true;
+  return false;
+}
+
 // Simplified from 
Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
 static bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
std::string &Ver,
@@ -487,7 +496,13 @@
   getFilePaths().push_back(
   (Base + SubdirName + llvm::sys::path::get_separator() + 
"mingw/lib").str());
 
-  getFilePaths().push_back(Base + "lib");
+  // Only include /lib if we're not cross compiling (not even for
+  // windows->windows to a different arch), or if the sysroot has been set
+  // (where we presume the user has pointed it at an arch specific
+  // subdirectory).
+  if (!::isCrossCompiling(getTriple(), /*RequireArchMatch=*/true) ||
+  getDriver().SysRoot.size())
+getFilePaths().push_back(Base + "lib");
 
   NativeLLVMSupport =
   Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER)
@@ -649,7 +664,13 @@
   addSystemInclude(DriverArgs, CC1Args,
Base + SubdirName + llvm::sys::path::get_separator() + 
"usr/include");
 
-  addSystemInclude(DriverArgs, CC1Args, Base + "include");
+  // Only include /include if we're not cross compiling (but do allow it
+  // if we're on Windows and building for Windows on another architecture),
+  // or if the sysroot has been set (where we presume the user has pointed it
+  // at an arch specific subdirectory).
+  if (!::isCrossCompiling(getTriple(), /*RequireArchMatch=*/false) ||
+  getDriver().SysRoot.size())
+addSystemInclude(DriverArgs, CC1Args, Base + "include");
 }
 
 void toolchains::MinGW::addClangTargetOptions(


Index: clang/test/Driver/mingw-sysroot.cpp
===
--- clang/test/Driver/mingw-sysroot.cpp
+++ clang/test/Driver/mingw-sysroot.cpp
@@ -31,6 +31,18 @@
 // CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10"
 // CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include"
 
+// This test is only executed on non-Windows systems, i.e. only when
+// cross compiling. Check that we don't add the tool root's plain include
+// directory to the path - this would end up including /usr/include for
+// cross toolchains installed 

[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

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

In D139705#4043225 , @v1nh1shungry 
wrote:

> Thanks for the reply! I'll raise a GitHub issue.
>
>> var will have three attributes associated with it, but the only source 
>> location information you have access to is for the foo, bar, and baz tokens. 
>> Each of those attributes also keeps track of what syntax was used, so you 
>> could tell that foo was a GNU-style attribute while bar and baz were C++. 
>> But we don't keep enough information about bar and baz being part of the 
>> same attribute list or whether that attribute list is leading or trailing. 
>> You have to calculate all of this yourself and some of it might not even be 
>> possible to calculate (for example, the user could have done 
>> __attribute__((foo)) const int var [[bar]] [[baz]]; and the AST would come 
>> out the same as the previous example).
>
> Can I post your reply there? I think it will help.

Yes, absolutely!

>> and then we'll ignore attributes for this patch.
>
> Then I think this patch is ready for a review.

Changes LGTM though you should add a release note to tell users about the fix. 
Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

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


[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

2023-01-11 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry added a comment.

Thank you for reviewing! I have opened an issue on GitHub: 
https://github.com/llvm/llvm-project/issues/59935. Hope my description is 
appropriate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

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


[PATCH] D141105: [OpenMP] Add support for '--offload-arch=native' to OpenMP offloading

2023-01-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 marked an inline comment as done.
jhuber6 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:894
+return;
+  }
+

jdoerfert wrote:
> Does this necessarily mean we failed with `=native`, if so it's ok. Just 
> didn't follow the logic all the way.
I think this might trigger if someone passed `--offload-arch=` maybe we should 
treat that the same as native?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141105

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


[PATCH] D140983: [IRBuilder] Use canonical i64 type for insertelement index used by vector splats.

2023-01-11 Thread Paul Walker 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 rGeae26b6640af: [IRBuilder] Use canonical i64 type for 
insertelement index used by vector… (authored by paulwalker-arm).

Changed prior to commit:
  https://reviews.llvm.org/D140983?vs=486332&id=488185#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140983

Files:
  clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
  clang/test/CodeGen/SystemZ/zvector.c
  clang/test/CodeGen/aarch64-sve-vector-arith-ops.c
  clang/test/CodeGen/aarch64-sve-vector-bitwise-ops.c
  clang/test/CodeGen/aarch64-sve-vector-shift-ops.c
  clang/test/CodeGen/aarch64-sve-vls-arith-ops.c
  clang/test/CodeGen/aarch64-sve-vls-shift-ops.c
  clang/test/CodeGen/arm-mve-intrinsics/compare.c
  clang/test/CodeGen/arm-mve-intrinsics/cplusplus.cpp
  clang/test/CodeGen/arm-mve-intrinsics/dup.c
  clang/test/CodeGen/arm-mve-intrinsics/ternary.c
  clang/test/CodeGen/arm-mve-intrinsics/vaddq.c
  clang/test/CodeGen/arm-mve-intrinsics/vhaddq.c
  clang/test/CodeGen/arm-mve-intrinsics/vhsubq.c
  clang/test/CodeGen/arm-mve-intrinsics/vmulq.c
  clang/test/CodeGen/arm-mve-intrinsics/vqaddq.c
  clang/test/CodeGen/arm-mve-intrinsics/vqdmulhq.c
  clang/test/CodeGen/arm-mve-intrinsics/vqdmullbq.c
  clang/test/CodeGen/arm-mve-intrinsics/vqdmulltq.c
  clang/test/CodeGen/arm-mve-intrinsics/vqrdmulhq.c
  clang/test/CodeGen/arm-mve-intrinsics/vqsubq.c
  clang/test/CodeGen/arm-mve-intrinsics/vsubq.c
  clang/test/CodeGen/matrix-type-operators-fast-math.c
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGen/vecshift.c
  clang/test/CodeGenCXX/aarch64-sve-vector-conditional-op.cpp
  clang/test/CodeGenCXX/ext-int.cpp
  clang/test/CodeGenCXX/ext-vector-type-conditional.cpp
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/CodeGenCXX/vector-size-conditional.cpp
  clang/test/CodeGenCXX/vector-splat-conversion.cpp
  clang/test/CodeGenOpenCL/bool_cast.cl
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/test/CodeGen/Generic/expand-vp-gather-scatter.ll
  llvm/test/CodeGen/Generic/expand-vp-load-store.ll
  llvm/test/CodeGen/Generic/expand-vp.ll
  llvm/test/CodeGen/Thumb2/mve-gather-optimisation-deep.ll
  llvm/test/Transforms/CodeGenPrepare/AArch64/gather-scatter-opt-inseltpoison.ll
  llvm/test/Transforms/CodeGenPrepare/AArch64/gather-scatter-opt.ll
  llvm/test/Transforms/ConstraintElimination/geps-ptrvector.ll
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-abs-srshl.ll
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-fmul-idempotency.ll
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-mul-idempotency.ll
  llvm/test/Transforms/InstCombine/div.ll
  llvm/test/Transforms/InstCombine/fdiv.ll
  llvm/test/Transforms/InstCombine/fmul.ll
  llvm/test/Transforms/InstCombine/select.ll
  llvm/test/Transforms/InstCombine/sub.ll
  llvm/test/Transforms/InstCombine/zext-ctlz-trunc-to-ctlz-add.ll
  llvm/test/Transforms/InstSimplify/ConstProp/vscale-inseltpoison.ll
  llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll
  llvm/test/Transforms/InstSimplify/cmp-vec-fast-path.ll
  llvm/test/Transforms/InstSimplify/gep.ll
  llvm/test/Transforms/InstSimplify/vscale-inseltpoison.ll
  llvm/test/Transforms/InstSimplify/vscale.ll
  
llvm/test/Transforms/LoopVectorize/AArch64/epilog-vectorization-widen-inductions.ll
  
llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll
  llvm/test/Transforms/LoopVectorize/AArch64/first-order-recurrence.ll
  
llvm/test/Transforms/LoopVectorize/AArch64/gather-do-not-vectorize-addressing.ll
  
llvm/test/Transforms/LoopVectorize/AArch64/interleaved-store-of-first-order-recurrence.ll
  
llvm/test/Transforms/LoopVectorize/AArch64/outer_loop_test1_no_explicit_vect_width.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-avoid-scalarization.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-call.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-reduction-inloop-cond.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-strict-fadd.ll
  llvm/test/Transforms/LoopVectorize/AArch64/strict-fadd.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-basic-vec.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-cond-inv-loads.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-epilog-vect.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-inductions-unusual-types.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-loads.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-live-out-pointer-induction.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-low-trip-count.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-select-cmp.ll
  llvm/test/Tran

[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

2023-01-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added inline comments.



Comment at: clang/test/FixIt/fixit-const-var-init.cpp:24
+
+template <> constexpr float d; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{24:42-24:42}:" = 0.0"

aaron.ballman wrote:
> v1nh1shungry wrote:
> > aaron.ballman wrote:
> > > v1nh1shungry wrote:
> > > > aaron.ballman wrote:
> > > > > I'd like to see some additional test coverage for more complicated 
> > > > > declarators:
> > > > > ```
> > > > > void (* const func)(int, int);
> > > > > const int var [[clang::annotate("")]];
> > > > > ```
> > > > One more question: I just did the second test
> > > > 
> > > > ```
> > > > const int var [[clang::annotate("")]];
> > > > ```
> > > > 
> > > > and it inserted the fix hint after the identifier.
> > > > 
> > > > Is this the expected behavior of `getEndLoc()`?
> > > @erichkeane and I talked about this off-list because it's a bit of an 
> > > academic question as to whether an attribute is "part" of a declaration 
> > > or not. We ultimately decided that we think it's best for the attribute 
> > > to *not* be considered part of the source range of the variable 
> > > declaration; they are wholly separate AST nodes.
> > > 
> > > So based on that, we think you will need some changes to SemaInit.cpp 
> > > after all. And you'll have to use 
> > > `SourceManager::isBeforeInTranslationUnit()` to determine if the begin 
> > > source location of the attribute is after the end source location of the 
> > > variable or not (because the attribute could go before the type 
> > > information or after the variable name).
> > > 
> > > There's another test case to consider that hopefully will Just Work with 
> > > this design, but is worth testing explicitly:
> > > ```
> > > void (* const func [[clang::annotate("test")]])(int, int);
> > > ```
> > I have trouble getting the location of the right bracket of the attribute 
> > list, which may be used to insert the fix hint. Could you please give me 
> > some hints? Thanks a lot!
> > I have trouble getting the location of the right bracket of the attribute 
> > list, which may be used to insert the fix hint. Could you please give me 
> > some hints? Thanks a lot!
> 
> Oh boy, that's an interesting problem, isn't it! We keep all of the attribute 
> AST nodes with the declaration, and each attribute knows its own source 
> range, but we *don't* keep the source locations for where the full attribute 
> list appears. e.g.,
> ```
> __attribute__((foo)) const int var [[bar, baz]];
> ```
> `var` will have three attributes associated with it, but the only source 
> location information you have access to is for the `foo`, `bar`, and `baz` 
> tokens. Each of those attributes also keeps track of what syntax was used, so 
> you could tell that `foo` was a GNU-style attribute while `bar` and `baz` 
> were C++. But we don't keep enough information about `bar` and `baz` being 
> part of the same attribute list or whether that attribute list is leading or 
> trailing. You have to calculate all of this yourself and some of it might not 
> even be possible to calculate (for example, the user could have done 
> `__attribute__((foo)) const int var [[bar]] [[baz]];` and the AST would come 
> out the same as the previous example).
> 
> I'd say that's way more work than is reasonable for this patch, so my 
> suggestion is to file a GitHub issue about the problem with attributes, note 
> the implementation issues, and then we'll ignore attributes for this patch.
> 
> @erichkeane -- something for us to consider is how to improve this in the 
> AST. We run into problems when doing AST pretty printing because of 
> attributes for these same reasons. It seems to me that the 
> `Decl`/`Stmt`/`TypeLoc` nodes need to keep a list of source ranges for 
> attributes around (since there can be multiple ranges for declarations). WDYT?
I took conversation to the bug here: 
https://github.com/llvm/llvm-project/issues/59935


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

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


[PATCH] D141440: [OpenMP] Adjust phases for AMDGPU offloading for OpenMP in save-temps mode

2023-01-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 488187.
jhuber6 added a comment.

I realized that if I fix up how we propagate the ToolChains I can use it in 
`ConstructPhaseAction`. Should be cleaner this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141440

Files:
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c

Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -1,9 +1,9 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
 // RUN:  -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib %s 2>&1 \
 // RUN:   | FileCheck %s
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
 // RUN:  --offload-arch=gfx906 --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib %s 2>&1 \
 // RUN:   | FileCheck %s
 
@@ -13,7 +13,7 @@
 // CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-obj"
 // CHECK: clang-linker-wrapper{{.*}}"--"{{.*}} "-o" "a.out"
 
-// RUN:   %clang -ccc-print-phases --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
+// RUN:   %clang -ccc-print-phases --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PHASES %s
 // CHECK-PHASES: 0: input, "[[INPUT:.+]]", c, (host-openmp)
 // CHECK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp)
@@ -22,39 +22,50 @@
 // CHECK-PHASES: 4: preprocessor, {3}, cpp-output, (device-openmp)
 // CHECK-PHASES: 5: compiler, {4}, ir, (device-openmp)
 // CHECK-PHASES: 6: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (amdgcn-amd-amdhsa)" {5}, ir
-// CHECK-PHASES: 7: backend, {6}, assembler, (device-openmp)
-// CHECK-PHASES: 8: assembler, {7}, object, (device-openmp)
-// CHECK-PHASES: 9: offload, "device-openmp (amdgcn-amd-amdhsa)" {8}, object
-// CHECK-PHASES: 10: clang-offload-packager, {9}, image
-// CHECK-PHASES: 11: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (x86_64-unknown-linux-gnu)" {10}, ir
-// CHECK-PHASES: 12: backend, {11}, assembler, (host-openmp)
-// CHECK-PHASES: 13: assembler, {12}, object, (host-openmp)
-// CHECK-PHASES: 14: clang-linker-wrapper, {13}, image, (host-openmp)
+// CHECK-PHASES: 7: backend, {6}, ir, (device-openmp)
+// CHECK-PHASES: 8: offload, "device-openmp (amdgcn-amd-amdhsa)" {7}, ir
+// CHECK-PHASES: 9: clang-offload-packager, {8}, image, (device-openmp)
+// CHECK-PHASES: 10: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (x86_64-unknown-linux-gnu)" {9}, ir
+// CHECK-PHASES: 11: backend, {10}, assembler, (host-openmp)
+// CHECK-PHASES: 12: assembler, {11}, object, (host-openmp)
+// CHECK-PHASES: 13: clang-linker-wrapper, {12}, image, (host-openmp)
 
 // handling of --libomptarget-amdgpu-bc-path
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIBOMPTARGET
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIBOMPTARGET
 // CHECK-LIBOMPTARGET: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc"{{.*}}
 
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOGPULIB
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOGPULIB
 // CHECK-NOGPULIB-NOT: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgpu-gfx803.bc"{{.*}}
 
-// RUN:   %clang -### --target=x86_6

[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

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

add a release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/test/FixIt/fixit-const-var-init.cpp


Index: clang/test/FixIt/fixit-const-var-init.cpp
===
--- /dev/null
+++ clang/test/FixIt/fixit-const-var-init.cpp
@@ -0,0 +1,28 @@
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++14 %s 
2>&1 | FileCheck %s
+
+const int a; // expected-error {{default initialization of an object of const 
type}}
+// CHECK: fix-it:"{{.*}}":{3:12-3:12}:" = 0"
+
+template  const int b; // expected-error {{default 
initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{6:36-6:36}:" = 0"
+
+template  const int b; // expected-error {{default 
initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{9:39-9:39}:" = 0"
+
+template <> const int b; // expected-error {{default 
initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{12:36-12:36}:" = 0"
+
+constexpr float c; // expected-error {{must be initialized by a constant 
expression}}
+// CHECK: fix-it:"{{.*}}":{15:18-15:18}:" = 0.0"
+
+template  constexpr float d; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{18:42-18:42}:" = 0.0"
+
+template  constexpr float d; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{21:45-21:45}:" = 0.0"
+
+template <> constexpr float d; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{24:42-24:42}:" = 0.0"
+
+void (* const func)(int, int); // expected-error {{default initialization of 
an object of const type}}
+// CHECK: fix-it:"{{.*}}":{27:30-27:30}:" = nullptr"
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2924,6 +2924,14 @@
 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
   }
 
+  SourceRange getSourceRange() const override LLVM_READONLY {
+if (isExplicitSpecialization()) {
+  if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
+return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+}
+return VarDecl::getSourceRange();
+  }
+
   void Profile(llvm::FoldingSetNodeID &ID) const {
 Profile(ID, TemplateArgs->asArray(), getASTContext());
   }
@@ -3081,6 +3089,14 @@
 return First->InstantiatedFromMember.setInt(true);
   }
 
+  SourceRange getSourceRange() const override LLVM_READONLY {
+if (isExplicitSpecialization()) {
+  if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
+return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+}
+return VarDecl::getSourceRange();
+  }
+
   void Profile(llvm::FoldingSetNodeID &ID) const {
 Profile(ID, getTemplateArgs().asArray(), getTemplateParameters(),
 getASTContext());
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -348,6 +348,8 @@
 - Fix issue that the standard C++ modules importer will call global
   constructor/destructor for the global varaibles in the importing modules.
   This fixes `Issue 59765 `_
+- Fix the bug of inserting the ``ZeroInitializationFixit`` before the template
+  argument list of ``VarTemplateSpecializationDecl``.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/FixIt/fixit-const-var-init.cpp
===
--- /dev/null
+++ clang/test/FixIt/fixit-const-var-init.cpp
@@ -0,0 +1,28 @@
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++14 %s 2>&1 | FileCheck %s
+
+const int a; // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{3:12-3:12}:" = 0"
+
+template  const int b; // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{6:36-6:36}:" = 0"
+
+template  const int b; // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{9:39-9:39}:" = 0"
+
+template <> const int b; // expected-error {{default initialization of an object of const type}}
+// CHECK: fix-it:"{{.*}}":{12:36-12:36}:" = 0"
+
+constexpr float c; // expected-error {{must be initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{15:18-15:18}:" = 0.0"
+
+template  constexpr float d; // expected-error {{must be initialized by a constant expression}}
+// CHECK: fi

[PATCH] D141105: [OpenMP] Add support for '--offload-arch=native' to OpenMP offloading

2023-01-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 488193.
jhuber6 added a comment.

Change to `SuppressError` and make`--offload-arch=` just default to native.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141105

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/openmp-system-arch.c

Index: clang/test/Driver/openmp-system-arch.c
===
--- /dev/null
+++ clang/test/Driver/openmp-system-arch.c
@@ -0,0 +1,56 @@
+// RUN: mkdir -p %t
+// RUN: cp %S/Inputs/amdgpu-arch/amdgpu_arch_fail %t/
+// RUN: cp %S/Inputs/amdgpu-arch/amdgpu_arch_gfx906 %t/
+// RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_fail %t/
+// RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_sm_70 %t/
+// RUN: echo '#!/bin/sh' > %t/amdgpu_arch_empty
+// RUN: chmod +x %t/amdgpu_arch_fail
+// RUN: chmod +x %t/amdgpu_arch_gfx906
+// RUN: chmod +x %t/amdgpu_arch_empty
+// RUN: echo '#!/bin/sh' > %t/nvptx_arch_empty
+// RUN: chmod +x %t/nvptx_arch_fail
+// RUN: chmod +x %t/nvptx_arch_sm_70
+// RUN: chmod +x %t/nvptx_arch_empty
+
+// case when nvptx-arch and amdgpu-arch return nothing or fails
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp --offload-arch=native \
+// RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp --offload-arch=native \
+// RUN: --nvptx-arch-tool=%t/nvptx_arch_empty --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp --offload-arch= \
+// RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp --offload-arch= \
+// RUN: --nvptx-arch-tool=%t/nvptx_arch_empty --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
+// NO-OUTPUT-ERROR: error: failed to deduce triple for target architecture 'native'; specify the triple using '-fopenmp-targets' and '-Xopenmp-target' instead.
+
+// case when amdgpu-arch succeeds.
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp --offload-arch=native \
+// RUN: --nvptx-arch-tool=%t/nvptx_arch_fail --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=ARCH-GFX906
+// ARCH-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906"
+
+// case when nvptx-arch succeeds.
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp --offload-arch=native \
+// RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=ARCH-SM_70
+// ARCH-SM_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
+
+// case when both nvptx-arch and amdgpu-arch succeed.
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp --offload-arch=native \
+// RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=ARCH-SM_70-GFX906
+// ARCH-SM_70-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906"
+// ARCH-SM_70-GFX906: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
+
+// case when both nvptx-arch and amdgpu-arch succeed with other archs.
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp --offload-arch=native,sm_75,gfx1030 \
+// RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=ARCH-MULTIPLE
+// ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx1030"
+// ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906"
+// ARCH-MULTIPLE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
+// ARCH-MULTIPLE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_75"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -859,9 +859,30 @@
   HostTC->getTriple());
 
   // Attempt to deduce the offloading triple from the set of architectures.
-  // We can only correctly deduce NVPTX / AMDGPU triples currently.
-  llvm::DenseSet Archs =
-  getOffloadArchs(C, C.getArgs(), Action::OFK_OpenMP, nullptr);
+  // We can only correctly deduce NVPTX / AMDGPU triples currently. We need
+  // to temporarily create these toolchains so that we can 

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

2023-01-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:4129
+  let Documentation = [WebAssemblyExportNameDocs];
+  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
+}

Note that it seems this is likely not going to work correctly on template type 
aliases!  You probably want to make sure that is acceptable to you.



Comment at: clang/include/clang/Basic/AttrDocs.td:6855
+Clang supports the ``__funcref`` attribute for the WebAssembly target. 
+This attribute may be attached to a function pointer declaration, where it 
modifies 
+its underlying representation to be a WebAssembly ``funcref``.

This says 'function pointer declaration', but you have it's subject as Typedef?



Comment at: clang/include/clang/Basic/TokenKinds.def:666
+// WebAssembly Type Extension
+KEYWORD(__funcref , KEYALL)
+

aaron.ballman wrote:
> pmatos wrote:
> > aaron.ballman wrote:
> > > Why is this a keyword in all language modes?
> > I might have misread the docs but this keyword should be available for both 
> > C and C++. Maybe I want `KEYC99 | KEYCXX` ?
> I was thinking this keyword would only work for a web assembly target, so 
> we'd likely want to add `KEYWEBASM` or something to the list like we have for 
> `KEYALTIVEC`. But now I'm second-guessing that instinct and am wondering what 
> behavior we want here.
> 
> 1) Parse the keyword in all language modes and for all targets, give an 
> ignored attribute warning if the target isn't web assembly
> 2) Parse the keyword in all language modes and for all targets, give a parse 
> time diagnostic (error?) if the target isn't web assembly
> 3) Only expose the keyword if the target is web assembly, otherwise it parses 
> as an identifier and you get the usual parse errors
> 
> My original thinking was that we wanted #3, but on reflection both #1 and #2 
> seem reasonable to me. Do you have a preference? I think I prefer either 2 or 
> 3 over 1 because this involves the type system (errors are usually a better 
> approach in that case).
I don't think #1 is acceptable for the keyword, we shouldn't ignore keywords 
like we do attributes.  Doing an ignored warning in SemaDeclAttr.td for the 
ATTRIBUTE is fine, but keyword form needs to be an error.

My preference is #2, an error if we encounter it during parsing and we're not 
in WebAsm target.



Comment at: clang/lib/Basic/Targets/DirectX.h:45
 3, // hlsl_groupshared
+// Wasm address space values for this map are dummy
+20, // wasm_funcref

Also apply to the rest of the targets.  Also, why is there only 1 added here?  
I thought we had 2 address spaces for Wasm?



Comment at: clang/lib/Basic/Targets/WebAssembly.h:44-45
+0,  // ptr64
+10, // wasm_externref,
+20, // wasm_funcref
+};

aaron.ballman wrote:
> I'm not super familiar with the address space maps, but this sets of my 
> spidey senses. All of the other address space maps end with:
> 
> ptr64, hlsl_groupshared, wasm_funcref
> 
> but this one is ending with:
> 
> ptr64, wasm_externref, wasm_funcref
> 
> which makes me think something's amiss here. Thoughts?
That DEFINITELY looks suspicious to me as well, I noted above too, but either 
we need to specify we're re-using the `hlsl_groupshared` for `wasm_externref` 
address space (at which point, i wonder: why not re-use a different address 
space?), or correct this.



Comment at: clang/lib/Parse/ParseDecl.cpp:847
+SourceLocation AttrNameLoc = ConsumeToken();
+attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0,
+ ParsedAttr::AS_Keyword);





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

Does this diagnose?  Should we be emitting an error here?



Comment at: clang/lib/Sema/SemaChecking.cpp:6708
+  // CallExpr
+  // `- FunctionDecl
+

All those comments don't really seem relevant here, and are not really correct. 
 The only thing SemaChecking should do is either modify its arguments (though 
you don't have any), or set its return type.  



Comment at: clang/lib/Sema/SemaChecking.cpp:6711
+  // Prepare FDecl type
+  QualType Pointee = Context.getFunctionType(Context.VoidTy, {}, {});
+  QualType Type = Context.getPointerType(Pointee);

aaron.ballman wrote:
> I'm still wondering why this code is needed and what it's trying to do. It 
> worries me that we're changing the type of the call expression like this.
This appears to be a 'custom type checking' builtin, where the code in Sema has 
to check the arguments (rather than the automatic behavior working), and set 
its return type to the 'correct' one.  It appears that this acc

[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-11 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:739
+- Correctly handle access-checks in requires expression. Fixes `GH53364 
`_,
+  `GH53334 `_.
 C++2b Feature Support

@usaxena95 This has broken the sphinx buildbot - please can you take a look? 
https://lab.llvm.org/buildbot/#/builders/92/builds/38512


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

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


[PATCH] D141495: [clangd] Suppress clang-tidy warnings for code spelled in system macros

2023-01-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a reviewer: njames93.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This aligns with the default behavior of clang-tidy (which we offer no
way to override).

Fixes https://github.com/clangd/clangd/issues/1448


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141495

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -527,6 +527,37 @@
   diagName("bugprone-integer-division");
 }
 
+TEST(DiagnosticTest, ClangTidySystemMacro) {
+  Annotations Main(R"cpp(
+#include "user.h"
+#include "system.h"
+int i = 3;
+double x = $inline[[8]] / i;
+double y = $user[[DIVIDE_USER]](i);
+double z = DIVIDE_SYS(i);
+  )cpp");
+
+  auto TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["user.h"] = R"cpp(
+#define DIVIDE_USER(Y) 8/Y
+  )cpp";
+  TU.AdditionalFiles["system.h"] = R"cpp(
+#pragma clang system_header
+#define DIVIDE_SYS(Y) 8/Y
+  )cpp";
+
+  TU.ClangTidyProvider = addTidyChecks("bugprone-integer-division");
+  std::string BadDivision = "result of integer division used in a floating "
+"point context; possible loss of precision";
+
+  // Expect to see warning from user macros, but not system macros.
+  // This matches clang-tidy --system-headers=0 (the default).
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ifTidyChecks(
+  UnorderedElementsAre(Diag(Main.range("inline"), BadDivision),
+   Diag(Main.range("user"), 
BadDivision;
+}
+
 TEST(DiagnosticTest, ClangTidyWarningAsError) {
   Annotations Main(R"cpp(
 int main() {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -11,7 +11,6 @@
 #include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
 #include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "AST.h"
-#include "ASTSignals.h"
 #include "Compiler.h"
 #include "Config.h"
 #include "Diagnostics.h"
@@ -543,6 +542,10 @@
 // NOLINT comments)?
 return DiagnosticsEngine::Ignored;
   }
+  // Match behavior for clang-tidy --system-headers=0 (the default).
+  if (Info.hasSourceManager() &&
+  Info.getSourceManager().isInSystemMacro(Info.getLocation()))
+return DiagnosticsEngine::Ignored;
 
   // Check for warning-as-error.
   if (DiagLevel == DiagnosticsEngine::Warning &&


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -527,6 +527,37 @@
   diagName("bugprone-integer-division");
 }
 
+TEST(DiagnosticTest, ClangTidySystemMacro) {
+  Annotations Main(R"cpp(
+#include "user.h"
+#include "system.h"
+int i = 3;
+double x = $inline[[8]] / i;
+double y = $user[[DIVIDE_USER]](i);
+double z = DIVIDE_SYS(i);
+  )cpp");
+
+  auto TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["user.h"] = R"cpp(
+#define DIVIDE_USER(Y) 8/Y
+  )cpp";
+  TU.AdditionalFiles["system.h"] = R"cpp(
+#pragma clang system_header
+#define DIVIDE_SYS(Y) 8/Y
+  )cpp";
+
+  TU.ClangTidyProvider = addTidyChecks("bugprone-integer-division");
+  std::string BadDivision = "result of integer division used in a floating "
+"point context; possible loss of precision";
+
+  // Expect to see warning from user macros, but not system macros.
+  // This matches clang-tidy --system-headers=0 (the default).
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ifTidyChecks(
+  UnorderedElementsAre(Diag(Main.range("inline"), BadDivision),
+   Diag(Main.range("user"), BadDivision;
+}
+
 TEST(DiagnosticTest, ClangTidyWarningAsError) {
   Annotations Main(R"cpp(
 int main() {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -11,7 +11,6 @@
 #include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
 #include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "AST.h"
-#include "ASTSignals.h"
 #include "Compiler.h"
 #i

[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:739
+- Correctly handle access-checks in requires expression. Fixes `GH53364 
`_,
+  `GH53334 `_.
 C++2b Feature Support

RKSimon wrote:
> @usaxena95 This has broken the sphinx buildbot - please can you take a look? 
> https://lab.llvm.org/buildbot/#/builders/92/builds/38512
Looks like he already fixed it in 75c0d43e857dd


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

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


[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-11 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:739
+- Correctly handle access-checks in requires expression. Fixes `GH53364 
`_,
+  `GH53334 `_.
 C++2b Feature Support

erichkeane wrote:
> RKSimon wrote:
> > @usaxena95 This has broken the sphinx buildbot - please can you take a 
> > look? https://lab.llvm.org/buildbot/#/builders/92/builds/38512
> Looks like he already fixed it in 75c0d43e857dd
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

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


[PATCH] D141495: [clangd] Suppress clang-tidy warnings for code spelled in system macros

2023-01-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141495

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


[PATCH] D112932: Use llvm.is_fpclass to implement FP classification functions

2023-01-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

This change itself LGTM but I think it should wait until after we get more 
optimizations in to go back to fcmp, and after the release branch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112932

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


[PATCH] D141497: [clang][Interp] Record initialization via conditional operator

2023-01-11 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Factor this out into a `visitConditional()` that calls the given visitor 
function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141497

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

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -335,3 +335,14 @@
   constexpr piecewise_construct_t piecewise_construct =
 piecewise_construct_t();
 };
+
+namespace ConditionalInit {
+  struct S { int a; };
+
+  constexpr S getS(bool b) {
+return b ? S{12} : S{13};
+  }
+
+  static_assert(getS(true).a == 12, "");
+  static_assert(getS(false).a == 13, "");
+};
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -196,6 +196,10 @@
 return this->emitPopPtr(I);
   }
 
+  using ExprVisitorFunc = std::function;
+  bool visitConditional(const AbstractConditionalOperator *E,
+ExprVisitorFunc VisitFunc);
+
   /// Creates a local primitive value.
   unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsMutable,
   bool IsExtended = false);
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -589,32 +589,8 @@
 template 
 bool ByteCodeExprGen::VisitAbstractConditionalOperator(
 const AbstractConditionalOperator *E) {
-  const Expr *Condition = E->getCond();
-  const Expr *TrueExpr = E->getTrueExpr();
-  const Expr *FalseExpr = E->getFalseExpr();
-
-  LabelTy LabelEnd = this->getLabel();   // Label after the operator.
-  LabelTy LabelFalse = this->getLabel(); // Label for the false expr.
-
-  if (!this->visit(Condition))
-return false;
-  if (!this->jumpFalse(LabelFalse))
-return false;
-
-  if (!this->visit(TrueExpr))
-return false;
-  if (!this->jump(LabelEnd))
-return false;
-
-  this->emitLabel(LabelFalse);
-
-  if (!this->visit(FalseExpr))
-return false;
-
-  this->fallthrough(LabelEnd);
-  this->emitLabel(LabelEnd);
-
-  return true;
+  return this->visitConditional(
+  E, [&](const Expr *Ex) { return this->visit(Ex); });
 }
 
 template 
@@ -930,6 +906,39 @@
   }
 }
 
+template 
+bool ByteCodeExprGen::visitConditional(
+const AbstractConditionalOperator *E, ExprVisitorFunc VisitFunc) {
+
+  const Expr *Condition = E->getCond();
+  const Expr *TrueExpr = E->getTrueExpr();
+  const Expr *FalseExpr = E->getFalseExpr();
+
+  LabelTy LabelEnd = this->getLabel();   // Label after the operator.
+  LabelTy LabelFalse = this->getLabel(); // Label for the false expr.
+
+  Condition->dump();
+  if (!this->visit(Condition))
+return false;
+  if (!this->jumpFalse(LabelFalse))
+return false;
+
+  if (!VisitFunc(TrueExpr))
+return false;
+  if (!this->jump(LabelEnd))
+return false;
+
+  this->emitLabel(LabelFalse);
+
+  if (!VisitFunc(FalseExpr))
+return false;
+
+  this->fallthrough(LabelEnd);
+  this->emitLabel(LabelEnd);
+
+  return true;
+}
+
 template 
 bool ByteCodeExprGen::visitZeroInitializer(PrimType T, const Expr *E) {
   switch (T) {
@@ -1420,6 +1429,10 @@
 return this->visitInitializer(CE->getSubExpr());
   } else if (const auto *CE = dyn_cast(Initializer)) {
 return this->visitInitializer(CE->getSubExpr());
+  } else if (const auto *ACO =
+ dyn_cast(Initializer)) {
+return this->visitConditional(
+ACO, [&](const Expr *Ex) { return this->visitRecordInitializer(Ex); });
   }
 
   // Explictly reject these. They only get generated for invalid code.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141497: [clang][Interp] Record initialization via conditional operator

2023-01-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:920
+
+  Condition->dump();
+  if (!this->visit(Condition))

This meant to be here?



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:921
+  Condition->dump();
+  if (!this->visit(Condition))
+return false;

Is this condition supposed to be just a 'visit', or should this be using the 
functor?



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.h:200
+  using ExprVisitorFunc = std::function;
+  bool visitConditional(const AbstractConditionalOperator *E,
+ExprVisitorFunc VisitFunc);

I'd probably rather make this a template taking a functor, rather than bringing 
in the atrocities that come with std::function.



Comment at: clang/test/AST/Interp/records.cpp:339
+
+namespace ConditionalInit {
+  struct S { int a; };

Did this not work before?  I don't see what part of teh code changes makes this 
work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141497

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


[PATCH] D141226: [clangd] support expanding `decltype(expr)`

2023-01-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for doing this!

There are a couple of separate logical changes here - I don't think it's a 
problem per se, but it does mean it takes a bit longer to get the good + 
obvious stuff reviewed and landed.




Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp:57
+std::string ExpandDeducedType::title() const {
+  return IsAutoType ? "Expand auto type" : "Expand decltype";
+}

Maybe "Replace with deduced type" would be clearer for both cases?

Then we don't need to track IsAutoType.
(I have no objection with spending a bit of code to provide better text, but 
given that the cursor is either on top of "auto" or "decltype" I don't think 
we're actually adding anything by echoing it back)



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp:119
+  if (auto DTTL = TypeNode->getAs()) {
+if (!isDeducedAsLambda(Node, DTTL.getBeginLoc()))
+  Range = DTTL.getSourceRange();

isDeducedAsLambda is detecting the specific pattern `auto x = [&} { ... };`, 
which doesn't occur with decltype.

On the other hand I suspect the `DecltypeTypeLoc` for `decltype(some_lambda)` 
doesn't suffer from the same issue as the `AutoTypeLoc` in a declaration, and 
we can simply call getUnderlyingType().

So I think you can simply factor out `isLambda(QualType)`  from 
`isDeducedAsLambda`, and call `isLambda(DTTL.getType()->getUnderlyingType())` 
here.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp:139
 
-  // if it's a lambda expression, return an error message
-  if (isa(*DeducedType) &&
-  cast(*DeducedType)->getDecl()->isLambda()) {
-return error("Could not expand type of lambda expression");
+  // we shouldn't replace a dependent type, e.g.
+  //   template 

why not? replacing this with `T` seems perfectly reasonable.
(The fact that we don't do this with `auto t = T{}` is just because we're 
hitting a limitation of clang's AST)



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp:149
+  //   int arr[10];
+  //   decltype(auto) foobar = arr;
+  //   ^^ is `int[10]`

these are unrelated to the decltype change (`decltype(auto)` is an AutoType 
rather than a DecltypeType and already works/has this bug today).

In future it's best to split unrelated changes into different patches/a patch 
sequence, though this is simple enough it's probably OK.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp:151
+  //   ^^ is `int[10]`
+  if ((*DeducedType)->isArrayType())
+return error("Could not expand type of array");

the commonality between these cases you're excluding (and the function types 
below) is that they use C-style declarator syntax that may have chunks 
following the declarator-id. Specifically:
 - array, function, and paren types always have chunks following the declarator
 - pointer and reference types compose inside-out so their pointee types may 
contain trailing chunks

If we want to make some attempt to detect more cases, we should pull out a 
function here and do it properly, something like: `bool 
hasTrailingChunks(QualType)` which calls recursively for pointertype etc.

But there's a cheaper way: when we call `printType()` below, we can optionally 
specify the declarator-id. Then we can simply check whether it's at the end of 
the string:

```
std::string PrettyDeclarator = printType(..., "DECLARATOR_ID");
llvm::StringRef PrettyType = PrettyDeclarator;
if (!PrettyType.consume_back("DECLARATOR_ID"))
  return error("could not expand non-contiguous type {0}", PrettyType);
PrettyType = PrettyType.rtrim();
```

This feels slightly hacky, but it's direct and simple and we shouldn't miss a 
case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141226

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


[PATCH] D141495: [clangd] Suppress clang-tidy warnings for code spelled in system macros

2023-01-11 Thread Sam McCall 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 rGf0e60f99aeff: [clangd] Suppress clang-tidy warnings for code 
spelled in system macros (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141495

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -527,6 +527,37 @@
   diagName("bugprone-integer-division");
 }
 
+TEST(DiagnosticTest, ClangTidySystemMacro) {
+  Annotations Main(R"cpp(
+#include "user.h"
+#include "system.h"
+int i = 3;
+double x = $inline[[8]] / i;
+double y = $user[[DIVIDE_USER]](i);
+double z = DIVIDE_SYS(i);
+  )cpp");
+
+  auto TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["user.h"] = R"cpp(
+#define DIVIDE_USER(Y) 8/Y
+  )cpp";
+  TU.AdditionalFiles["system.h"] = R"cpp(
+#pragma clang system_header
+#define DIVIDE_SYS(Y) 8/Y
+  )cpp";
+
+  TU.ClangTidyProvider = addTidyChecks("bugprone-integer-division");
+  std::string BadDivision = "result of integer division used in a floating "
+"point context; possible loss of precision";
+
+  // Expect to see warning from user macros, but not system macros.
+  // This matches clang-tidy --system-headers=0 (the default).
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ifTidyChecks(
+  UnorderedElementsAre(Diag(Main.range("inline"), BadDivision),
+   Diag(Main.range("user"), 
BadDivision;
+}
+
 TEST(DiagnosticTest, ClangTidyWarningAsError) {
   Annotations Main(R"cpp(
 int main() {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -11,7 +11,6 @@
 #include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
 #include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "AST.h"
-#include "ASTSignals.h"
 #include "Compiler.h"
 #include "Config.h"
 #include "Diagnostics.h"
@@ -543,6 +542,10 @@
 // NOLINT comments)?
 return DiagnosticsEngine::Ignored;
   }
+  // Match behavior for clang-tidy --system-headers=0 (the default).
+  if (Info.hasSourceManager() &&
+  Info.getSourceManager().isInSystemMacro(Info.getLocation()))
+return DiagnosticsEngine::Ignored;
 
   // Check for warning-as-error.
   if (DiagLevel == DiagnosticsEngine::Warning &&


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -527,6 +527,37 @@
   diagName("bugprone-integer-division");
 }
 
+TEST(DiagnosticTest, ClangTidySystemMacro) {
+  Annotations Main(R"cpp(
+#include "user.h"
+#include "system.h"
+int i = 3;
+double x = $inline[[8]] / i;
+double y = $user[[DIVIDE_USER]](i);
+double z = DIVIDE_SYS(i);
+  )cpp");
+
+  auto TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["user.h"] = R"cpp(
+#define DIVIDE_USER(Y) 8/Y
+  )cpp";
+  TU.AdditionalFiles["system.h"] = R"cpp(
+#pragma clang system_header
+#define DIVIDE_SYS(Y) 8/Y
+  )cpp";
+
+  TU.ClangTidyProvider = addTidyChecks("bugprone-integer-division");
+  std::string BadDivision = "result of integer division used in a floating "
+"point context; possible loss of precision";
+
+  // Expect to see warning from user macros, but not system macros.
+  // This matches clang-tidy --system-headers=0 (the default).
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ifTidyChecks(
+  UnorderedElementsAre(Diag(Main.range("inline"), BadDivision),
+   Diag(Main.range("user"), BadDivision;
+}
+
 TEST(DiagnosticTest, ClangTidyWarningAsError) {
   Annotations Main(R"cpp(
 int main() {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -11,7 +11,6 @@
 #include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
 #include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "AST.h"
-#include "ASTSignals.h"
 #include "Compiler.h"
 #include "Config.h"
 #include "Diagnostics.h"
@@ -543,6 +542,10 @@
 // NOLINT comments)?
 return DiagnosticsEngine::

[clang-tools-extra] f0e60f9 - [clangd] Suppress clang-tidy warnings for code spelled in system macros

2023-01-11 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-01-11T16:11:25+01:00
New Revision: f0e60f99aefff66ca6223eb3c3a36615f36454ec

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

LOG: [clangd] Suppress clang-tidy warnings for code spelled in system macros

This aligns with the default behavior of clang-tidy (which we offer no
way to override).

Fixes https://github.com/clangd/clangd/issues/1448

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

Added: 


Modified: 
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index b8dd161649fdb..637cadaf86c64 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -11,7 +11,6 @@
 #include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
 #include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "AST.h"
-#include "ASTSignals.h"
 #include "Compiler.h"
 #include "Config.h"
 #include "Diagnostics.h"
@@ -543,6 +542,10 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs &Inputs,
 // NOLINT comments)?
 return DiagnosticsEngine::Ignored;
   }
+  // Match behavior for clang-tidy --system-headers=0 (the default).
+  if (Info.hasSourceManager() &&
+  Info.getSourceManager().isInSystemMacro(Info.getLocation()))
+return DiagnosticsEngine::Ignored;
 
   // Check for warning-as-error.
   if (DiagLevel == DiagnosticsEngine::Warning &&

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 7310a11dc632f..824756a970211 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -527,6 +527,37 @@ TEST(DiagnosticTest, ClangTidySuppressionComment) {
   diagName("bugprone-integer-division");
 }
 
+TEST(DiagnosticTest, ClangTidySystemMacro) {
+  Annotations Main(R"cpp(
+#include "user.h"
+#include "system.h"
+int i = 3;
+double x = $inline[[8]] / i;
+double y = $user[[DIVIDE_USER]](i);
+double z = DIVIDE_SYS(i);
+  )cpp");
+
+  auto TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["user.h"] = R"cpp(
+#define DIVIDE_USER(Y) 8/Y
+  )cpp";
+  TU.AdditionalFiles["system.h"] = R"cpp(
+#pragma clang system_header
+#define DIVIDE_SYS(Y) 8/Y
+  )cpp";
+
+  TU.ClangTidyProvider = addTidyChecks("bugprone-integer-division");
+  std::string BadDivision = "result of integer division used in a floating "
+"point context; possible loss of precision";
+
+  // Expect to see warning from user macros, but not system macros.
+  // This matches clang-tidy --system-headers=0 (the default).
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ifTidyChecks(
+  UnorderedElementsAre(Diag(Main.range("inline"), BadDivision),
+   Diag(Main.range("user"), 
BadDivision;
+}
+
 TEST(DiagnosticTest, ClangTidyWarningAsError) {
   Annotations Main(R"cpp(
 int main() {



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


[PATCH] D141497: [clang][Interp] Record initialization via conditional operator

2023-01-11 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:920
+
+  Condition->dump();
+  if (!this->visit(Condition))

erichkeane wrote:
> This meant to be here?
Nope! :(



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:921
+  Condition->dump();
+  if (!this->visit(Condition))
+return false;

erichkeane wrote:
> Is this condition supposed to be just a 'visit', or should this be using the 
> functor?
The visit is correct here, the functor is just for the true/false expr.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.h:200
+  using ExprVisitorFunc = std::function;
+  bool visitConditional(const AbstractConditionalOperator *E,
+ExprVisitorFunc VisitFunc);

erichkeane wrote:
> I'd probably rather make this a template taking a functor, rather than 
> bringing in the atrocities that come with std::function.
Alright, will look into that



Comment at: clang/test/AST/Interp/records.cpp:339
+
+namespace ConditionalInit {
+  struct S { int a; };

erichkeane wrote:
> Did this not work before?  I don't see what part of teh code changes makes 
> this work?
We call `visitInitializer` also when the return value is constructed in the 
calling function, so the return statement in `getS()` exercises the code added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141497

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


[PATCH] D141226: [clangd] support expanding `decltype(expr)`

2023-01-11 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry added a comment.

Thank you for reviewing and giving suggestions!




Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp:57
+std::string ExpandDeducedType::title() const {
+  return IsAutoType ? "Expand auto type" : "Expand decltype";
+}

sammccall wrote:
> Maybe "Replace with deduced type" would be clearer for both cases?
> 
> Then we don't need to track IsAutoType.
> (I have no objection with spending a bit of code to provide better text, but 
> given that the cursor is either on top of "auto" or "decltype" I don't think 
> we're actually adding anything by echoing it back)
I think your suggestion is better. Thanks!



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp:139
 
-  // if it's a lambda expression, return an error message
-  if (isa(*DeducedType) &&
-  cast(*DeducedType)->getDecl()->isLambda()) {
-return error("Could not expand type of lambda expression");
+  // we shouldn't replace a dependent type, e.g.
+  //   template 

sammccall wrote:
> why not? replacing this with `T` seems perfectly reasonable.
> (The fact that we don't do this with `auto t = T{}` is just because we're 
> hitting a limitation of clang's AST)
I'd like it too. But the `printType()` would give out a ``. 
Though I haven't looked into this, would you mind giving some suggestions about 
it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141226

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


[PATCH] D140992: clang: Add __builtin_elementwise_fma

2023-01-11 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:634
  the most negative integer remains 
the most negative integer
+ T __builtin_elementwise_fma(T x, T y, T z)  fused multiply add.   
   floating point types
  T __builtin_elementwise_ceil(T x)   return the smallest integral 
value greater than or equal to xfloating point types

(trivial) improve the operation description to make it clear the fma order - I 
guess most devs will assume "(x*y)+z" but it'd be good to be explicit here


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

https://reviews.llvm.org/D140992

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


[PATCH] D140699: [OptTable] Make ValuesCode initialisation of Options constexpr

2023-01-11 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:268
+if (!isa(R.getValueInit("ValuesCode"))) {
+  assert(!isa(R.getValueInit("Values")) &&
+   "Cannot choose between Values and ValuesCode");

Isn't this assert the wrong way around?


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

https://reviews.llvm.org/D140699

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


[PATCH] D140800: [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-11 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Just to check, this isn't going to cause some warning spew about all those 
OptTable implementations being non-final?




Comment at: llvm/include/llvm/Option/OptTable.h:256
 
+/// Specialization of
+class GenericOptTable : public OptTable {

Comment looks a bit unfinished :)



Comment at: llvm/unittests/Option/OptionParsingTest.cpp:87
+
+template  class DISABLED_OptTableTest : public ::testing::Test {};
+

What's this about?


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

https://reviews.llvm.org/D140800

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: rjmccall.
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:1480
+  /// Return a WebAssembly externref type.
+  QualType getExternrefType() const;
+

`getWebAssemblyExternrefType` ?



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11778
+def err_wasm_reference_pr : Error<
+  "%select{pointers|references}0 to WebAssembly reference types are illegal">;
+def err_wasm_ca_reference : Error<

Rewording to avoid using "illegal" (and changes to the singular form).



Comment at: clang/include/clang/Basic/WebAssemblyReferenceTypes.def:16
+//
+//  - Name is the name of the builtin type.  MangledName is the mangled name.
+//

aaron.ballman wrote:
> What kind of mangling is this name? Itanium? Microsoft? Something else?
Still wondering about this.



Comment at: clang/lib/AST/ASTContext.cpp:4012-4018
+  if (Target->getTriple().isWasm() && Target->hasFeature("reference-types")) {
+#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS)  
\
+  if (BuiltinType::Id == BuiltinType::WasmExternRef)   
\
+return SingletonId;
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
+  }
+  return QualType();

Rather than returning a null type, should we assert we're in a wasm triple? We 
shouldn't be trying to form the type outside of a wasm target, right?



Comment at: clang/lib/AST/ItaniumMangle.cpp:3147
+type_name = MangledName;   
\
+Out << (type_name == InternalName ? "u" : "") << type_name.size()  
\
+<< type_name;  
\

aaron.ballman wrote:
> tlively wrote:
> > Our `MangledName` is not the same as our `InternalName`, so it looks like 
> > this condition will never be true. Should be follow the simpler pattern 
> > from the previous two targets instead?
> I'm not an Itanium mangling expert, but doesn't this *have* to use the `u` 
> marking per 
> https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.builtin-type 
> because this is definitely a vendor extension type.
Still wondering about this, pinging @rjmccall for Itanium ABI expertise



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2480-2481
 #include "clang/Basic/RISCVVTypes.def"
+#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
   case BuiltinType::ShortAccum:

aaron.ballman wrote:
> Is it reasonable that this simply cannot mangle in Microsoft ABI mode?
Still wondering about this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

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


[PATCH] D141226: [clangd] support expanding `decltype(expr)`

2023-01-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp:139
 
-  // if it's a lambda expression, return an error message
-  if (isa(*DeducedType) &&
-  cast(*DeducedType)->getDecl()->isLambda()) {
-return error("Could not expand type of lambda expression");
+  // we shouldn't replace a dependent type, e.g.
+  //   template 

v1nh1shungry wrote:
> sammccall wrote:
> > why not? replacing this with `T` seems perfectly reasonable.
> > (The fact that we don't do this with `auto t = T{}` is just because we're 
> > hitting a limitation of clang's AST)
> I'd like it too. But the `printType()` would give out a ``. 
> Though I haven't looked into this, would you mind giving some suggestions 
> about it?
Ah, there are three subtly different concepts here:
 - is this type usefully printable? There are various reasons why it may not 
be, it can contain DependentTy, or a canonical template parameter 
(``), or a lambda.
 - is this type dependent in the language sense - an example is some type 
parameter `T`. This may or may not be usefully printable. (e.g. try 
`template std::vector y;` and hover on y)
 - is this type specifically `DependentTy`, the placeholder dependent type 
which we have no information about. This is never usefully printable: prints as 
``

As a heuristic, I'm happy with saying dependent types (in the language sense) 
are likely not to print usefully, so don't replace them. But the comment should 
say so (this is a heuristic for unprintable rather than an end in itself), and 
probably give examples.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141226

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


[PATCH] D140867: [C++20] [Modules] Don't generate global ctors/dtors for variables which are available externally

2023-01-11 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan added a comment.

In D140867#4042405 , @ChuanqiXu wrote:

> In D140867#4042351 , @Jake-Egan 
> wrote:
>
>>> Would you like to take a double look?
>>
>> Yes, it still fails on the bot and on my local machine. I've added an XFAIL 
>> to the test for now just to get the AIX bot green.
>
> Weird. Maybe you can find a method by adding `REQUIRES` or `NOT-SUPPORTED` 
> and test it locally. If it goes well then you can upstream the change.

It seems that it's because the test fails when running on AIX - not just when 
it's being targeted.

  // REQUIRES: x86-registered-target,aarch64-registered-target

The above doesn't stop the test from being run on AIX. So, I can add:

  // UNSUPPORTED: system-aix

But do you want to keep the REQUIRES for other targets?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140867

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


[PATCH] D141092: Optionally install clang-tblgen to aid cross-compiling

2023-01-11 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D141092

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


[PATCH] D141495: [clangd] Suppress clang-tidy warnings for code spelled in system macros

2023-01-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:545
   }
+  // Match behavior for clang-tidy --system-headers=0 (the default).
+  if (Info.hasSourceManager() &&

Why not check `CTContext->getOptions().SystemHeaders`, since we have ready 
access to it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141495

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


[PATCH] D121517: Incorrectly accepts overload of (T&, int) vs. (T const&, U) #54347

2023-01-11 Thread Ed Catmur via Phabricator via cfe-commits
ecatmur added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121517

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


[clang] 6916ebd - [clang][NFC] Use the TypeSize::getXXXValue() instead of TypeSize::getXXXSize)

2023-01-11 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2023-01-11T16:07:48Z
New Revision: 6916ebd026500061462917666a0e0d228ed52681

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

LOG: [clang][NFC] Use the TypeSize::getXXXValue() instead of 
TypeSize::getXXXSize)

This change is one of a series to implement the discussion from
https://reviews.llvm.org/D141134.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGGPUBuiltin.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a6994688d44e1..430b5f43cdd5a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6784,8 +6784,8 @@ static Value *EmitCommonNeonSISDBuiltinExpr(
 
   Value *Result = CGF.EmitNeonCall(F, Ops, s);
   llvm::Type *ResultType = CGF.ConvertType(E->getType());
-  if (ResultType->getPrimitiveSizeInBits().getFixedSize() <
-  Result->getType()->getPrimitiveSizeInBits().getFixedSize())
+  if (ResultType->getPrimitiveSizeInBits().getFixedValue() <
+  Result->getType()->getPrimitiveSizeInBits().getFixedValue())
 return CGF.Builder.CreateExtractElement(Result, C0);
 
   return CGF.Builder.CreateBitCast(Result, ResultType, s);

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 06976ba5fb44a..41084956e1979 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1261,7 +1261,7 @@ static llvm::Value *CreateCoercedLoad(Address Src, 
llvm::Type *Ty,
 
   if (llvm::StructType *SrcSTy = dyn_cast(SrcTy)) {
 Src = EnterStructPointerForCoercedAccess(Src, SrcSTy,
- DstSize.getFixedSize(), CGF);
+ DstSize.getFixedValue(), CGF);
 SrcTy = Src.getElementType();
   }
 
@@ -1277,7 +1277,7 @@ static llvm::Value *CreateCoercedLoad(Address Src, 
llvm::Type *Ty,
 
   // If load is legal, just bitcast the src pointer.
   if (!SrcSize.isScalable() && !DstSize.isScalable() &&
-  SrcSize.getFixedSize() >= DstSize.getFixedSize()) {
+  SrcSize.getFixedValue() >= DstSize.getFixedValue()) {
 // Generally SrcSize is never greater than DstSize, since this means we are
 // losing bits. However, this can happen in cases where the structure has
 // additional padding, for example due to a user specified alignment.
@@ -1323,7 +1323,7 @@ static llvm::Value *CreateCoercedLoad(Address Src, 
llvm::Type *Ty,
   CGF.Builder.CreateMemCpy(
   Tmp.getPointer(), Tmp.getAlignment().getAsAlign(), Src.getPointer(),
   Src.getAlignment().getAsAlign(),
-  llvm::ConstantInt::get(CGF.IntPtrTy, SrcSize.getKnownMinSize()));
+  llvm::ConstantInt::get(CGF.IntPtrTy, SrcSize.getKnownMinValue()));
   return CGF.Builder.CreateLoad(Tmp);
 }
 
@@ -1366,7 +1366,7 @@ static void CreateCoercedStore(llvm::Value *Src,
 
   if (llvm::StructType *DstSTy = dyn_cast(DstTy)) {
 Dst = EnterStructPointerForCoercedAccess(Dst, DstSTy,
- SrcSize.getFixedSize(), CGF);
+ SrcSize.getFixedValue(), CGF);
 DstTy = Dst.getElementType();
   }
 
@@ -1393,7 +1393,7 @@ static void CreateCoercedStore(llvm::Value *Src,
   // If store is legal, just bitcast the src pointer.
   if (isa(SrcTy) ||
   isa(DstTy) ||
-  SrcSize.getFixedSize() <= DstSize.getFixedSize()) {
+  SrcSize.getFixedValue() <= DstSize.getFixedValue()) {
 Dst = CGF.Builder.CreateElementBitCast(Dst, SrcTy);
 CGF.EmitAggregateStore(Src, Dst, DstIsVolatile);
   } else {
@@ -1411,7 +1411,7 @@ static void CreateCoercedStore(llvm::Value *Src,
 CGF.Builder.CreateMemCpy(
 Dst.getPointer(), Dst.getAlignment().getAsAlign(), Tmp.getPointer(),
 Tmp.getAlignment().getAsAlign(),
-llvm::ConstantInt::get(CGF.IntPtrTy, DstSize.getFixedSize()));
+llvm::ConstantInt::get(CGF.IntPtrTy, DstSize.getFixedValue()));
   }
 }
 
@@ -4725,7 +4725,7 @@ class AllocAlignAttrEmitter final
 
 static unsigned getMaxVectorWidth(const llvm::Type *Ty) {
   if (auto *VT = dyn_cast(Ty))
-return VT->getPrimitiveSizeInBits().getKnownMinSize();
+return VT->getPrimitiveSizeInBits().getKnownMinValue();
   if (auto *AT = dyn_cast(Ty))
 return getMaxVectorWidth(AT->getElementType());
 

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index afdee52aec629..6d5e729b1eea9 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3089,7 +3089,7 @@ llvm::Value *CodeGenFunction::EmitCheckValue(llvm::Value 
*V) {
   // Floating-poi

[PATCH] D141507: [NFC] Fixed a typo in clang help docs

2023-01-11 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen created this revision.
jolanta.jensen added a reviewer: mgabka.
Herald added a project: All.
jolanta.jensen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixed minor typo in clang help docs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141507

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1952,7 +1952,7 @@
   " fast (fuses across statements disregarding pragmas)"
   " | on (only fuses in the same statement unless dictated by pragmas)"
   " | off (never fuses)"
-  " | fast-honor-pragmas (fuses across statements unless diectated by 
pragmas)."
+  " | fast-honor-pragmas (fuses across statements unless dictated by pragmas)."
   " Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' 
otherwise.">,
   HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1952,7 +1952,7 @@
   " fast (fuses across statements disregarding pragmas)"
   " | on (only fuses in the same statement unless dictated by pragmas)"
   " | off (never fuses)"
-  " | fast-honor-pragmas (fuses across statements unless diectated by pragmas)."
+  " | fast-honor-pragmas (fuses across statements unless dictated by pragmas)."
   " Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' otherwise.">,
   HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >