[PATCH] D154758: [clang][Interp] Emit correct diagnostic for uninitialized reads

2023-07-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 538325.

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

https://reviews.llvm.org/D154758

Files:
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp
  clang/test/AST/Interp/cxx20.cpp
  clang/test/AST/Interp/literals.cpp
  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
@@ -429,7 +429,7 @@
   static_assert(D.Val == 0, ""); // ref-error {{not an integral constant expression}} \
  // ref-note {{initializer of 'D' is not a constant expression}} \
  // expected-error {{not an integral constant expression}} \
- // expected-note {{read of object outside its lifetime}}
+ // expected-note {{read of uninitialized object}}
 #endif
 
   struct AnotherBase {
@@ -492,7 +492,7 @@
   constexpr A a{10}; // expected-error {{must be initialized by a constant expression}}
   static_assert(a.m == 10, "");
   static_assert(a.f == 10, ""); // expected-error {{not an integral constant expression}} \
-// expected-note {{read of object outside its lifetime}}
+// expected-note {{read of uninitialized object}}
 
   class Foo {
   public:
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -510,10 +510,10 @@
 T a;
 if constexpr (Inc)
   ++a; // ref-note 2{{increment of uninitialized}} \
-   // expected-note 2{{increment of object outside its lifetime}}
+   // expected-note 2{{increment of uninitialized}}
 else
   --a; // ref-note 2{{decrement of uninitialized}} \
-   // expected-note 2{{decrement of object outside its lifetime}}
+   // expected-note 2{{decrement of uninitialized}}
 return 1;
   }
   static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -59,8 +59,7 @@
 constexpr int unInitLocal() {
   int a;
   return a; // ref-note {{read of uninitialized object}} \
-// expected-note {{read of object outside its lifetime}}
-// FIXME: ^^^ Wrong diagnostic.
+// expected-note {{read of uninitialized object}}
 }
 static_assert(unInitLocal() == 0, ""); // ref-error {{not an integral constant expression}} \
// ref-note {{in call to 'unInitLocal()'}} \
@@ -76,7 +75,7 @@
 
 constexpr int initializedLocal2() {
   int a[2];
-  return *a; // expected-note {{read of object outside its lifetime}} \
+  return *a; // expected-note {{read of uninitialized object is not allowed in a constant expression}} \
  // ref-note {{read of uninitialized object is not allowed in a constant expression}}
 }
 static_assert(initializedLocal2() == 20); // expected-error {{not an integral constant expression}} \
@@ -89,7 +88,7 @@
 constexpr int initializedLocal3() {
   Int i;
   return i.a; // ref-note {{read of uninitialized object is not allowed in a constant expression}} \
-  // expected-note {{read of object outside its lifetime}}
+  // expected-note {{read of uninitialized object}}
 }
 static_assert(initializedLocal3() == 20); // expected-error {{not an integral constant expression}} \
   // expected-note {{in call to}} \
@@ -315,7 +314,7 @@
 
   static_assert(Final{1, 2, 3}.c == 3, ""); // OK
   static_assert(Final{1, 2, 3}.a == 0, ""); // expected-error {{not an integral constant expression}} \
-// expected-note {{read of object outside its lifetime}} \
+// expected-note {{read of uninitialized object}} \
 // ref-error {{not an integral constant expression}} \
 // ref-note {{read of uninitialized object}}
 
@@ -337,7 +336,7 @@
   static_assert(Final2{1, 2, 3}.c == 3, ""); // OK
   static_assert(Final2{1, 2, 3}.b == 2, ""); // OK
   static_assert(Final2{1, 2, 3}.a == 0, ""); // expected-error {{not an integral constant expression}} \
- // expected-note {{read of object outside its lifetime}} \
+ // expected-note {{read of uninitialized object}} \
  // ref-error {{not an integral constant expression}} \
  // ref-note {{read of 

[PATCH] D154675: [Clang] Fix crash when emitting diagnostic for out of order designated initializers in C++

2023-07-07 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 538323.
shafik marked an inline comment as done.
shafik added a comment.

-Add fix for wrong field in diagnostic


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

https://reviews.llvm.org/D154675

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp


Index: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
@@ -63,7 +63,7 @@
   .x = 1, // override-note {{previous}}
   .x = 1, // override-error {{overrides prior initialization}} override-note 
{{previous}}
   .y = 1, // override-note {{previous}}
-  .y = 1, // override-error {{overrides prior initialization}}
+  .y = 1, // override-error {{overrides prior initialization}} // reorder-note 
{{previous initialization for field 'y' is here}}
   .x = 1, // reorder-error {{declaration order}} override-error {{overrides 
prior initialization}} override-note {{previous}}
   .x = 1, // override-error {{overrides prior initialization}}
 };
@@ -177,3 +177,22 @@
 h({.a = 1});
   }
 }
+
+namespace GH63605 {
+struct {
+  unsigned : 2;
+  unsigned a : 6;
+  unsigned : 1;
+  unsigned b : 6;
+  unsigned : 2;
+  unsigned c : 6;
+  unsigned d : 1;
+  unsigned e : 2;
+} data = {
+.e = 1, // reorder-note {{previous initialization for field 'e' is here}}
+.d = 1, // reorder-error {{field 'e' will be initialized after field 'd'}} 
// reorder-note {{previous initialization for field 'd' is here}}
+.c = 1, // reorder-error {{field 'd' will be initialized after field 'c'}} 
// reorder-note {{previous initialization for field 'c' is here}}
+.b = 1, // reorder-error {{field 'c' will be initialized after field 'b'}} 
// reorder-note {{previous initialization for field 'b' is here}}
+.a = 1, // reorder-error {{field 'b' will be initialized after field 'a'}}
+};
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -2844,7 +2844,7 @@
 SemaRef.Diag(DIE->getBeginLoc(), diag::ext_designated_init_reordered)
 << KnownField << PrevField << DIE->getSourceRange();
 
-unsigned OldIndex = NumBases + PrevField->getFieldIndex();
+unsigned OldIndex = NumBases + StructuredIndex - 1;
 if (StructuredList && OldIndex <= StructuredList->getNumInits()) {
   if (Expr *PrevInit = StructuredList->getInit(OldIndex)) {
 SemaRef.Diag(PrevInit->getBeginLoc(),
@@ -2948,8 +2948,12 @@
 // If this the first designator, our caller will continue checking
 // the rest of this struct/class/union subobject.
 if (IsFirstDesignator) {
+  if (Field != RD->field_end() && Field->isUnnamedBitfield())
+++Field;
+
   if (NextField)
 *NextField = Field;
+
   StructuredIndex = FieldIndex;
   return false;
 }


Index: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
@@ -63,7 +63,7 @@
   .x = 1, // override-note {{previous}}
   .x = 1, // override-error {{overrides prior initialization}} override-note {{previous}}
   .y = 1, // override-note {{previous}}
-  .y = 1, // override-error {{overrides prior initialization}}
+  .y = 1, // override-error {{overrides prior initialization}} // reorder-note {{previous initialization for field 'y' is here}}
   .x = 1, // reorder-error {{declaration order}} override-error {{overrides prior initialization}} override-note {{previous}}
   .x = 1, // override-error {{overrides prior initialization}}
 };
@@ -177,3 +177,22 @@
 h({.a = 1});
   }
 }
+
+namespace GH63605 {
+struct {
+  unsigned : 2;
+  unsigned a : 6;
+  unsigned : 1;
+  unsigned b : 6;
+  unsigned : 2;
+  unsigned c : 6;
+  unsigned d : 1;
+  unsigned e : 2;
+} data = {
+.e = 1, // reorder-note {{previous initialization for field 'e' is here}}
+.d = 1, // reorder-error {{field 'e' will be initialized after field 'd'}} // reorder-note {{previous initialization for field 'd' is here}}
+.c = 1, // reorder-error {{field 'd' will be initialized after field 'c'}} // reorder-note {{previous initialization for field 'c' is here}}
+.b = 1, // reorder-error {{field 'c' will be initialized after field 'b'}} // reorder-note {{previous initialization for field 'b' is here}}
+.a = 1, // reorder-error {{field 'b' will be initialized after field 'a'}}
+};
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -2844,7 +2844,7 @@
 SemaRef.Diag(DIE->getBeginLoc(), diag::ext_designated_init_reordered)
 

[PATCH] D105759: Implement P2361 Unevaluated string literals

2023-07-07 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

@cor3ntin 
I've been working on pretty much the same functionality in our downstream fork. 
I was not aware of the paper, nor of the ongoing work in this direction, and so 
I unfortunately missed the review.
Thanks for this patch, it significantly reduces the number of changes 
downstream and makes it easier to merge with upstream in the future.

I have a couple of questions about future work:

- IIUC the paper initially addressed this issue with `#line` directive, but the 
changes were reverted(?). Is there any chance they can get back?
- Are there any plans for making similar changes to asm statement parsing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-07 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG661d91a0fd4a: [clang] Make amdgpu-arch tool work on Windows 
(authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D153725?vs=538207=538318#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
  clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt

Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -8,6 +8,6 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
+add_clang_tool(amdgpu-arch AMDGPUArch.cpp AMDGPUArchByHSA.cpp AMDGPUArchByHIP.cpp)
 
 target_link_libraries(amdgpu-arch PRIVATE clangBasic)
Index: clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
@@ -1,4 +1,4 @@
-//===- AMDGPUArch.cpp - list AMDGPU installed --*- C++ -*-===//
+//===- AMDGPUArchLinux.cpp - list AMDGPU installed --*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
 //===--===//
 //
 // This file implements a tool for detecting name of AMDGPU installed in system
-// using HSA. This tool is used by AMDGPU OpenMP driver.
+// using HSA on Linux. This tool is used by AMDGPU OpenMP and HIP driver.
 //
 //===--===//
 
@@ -15,21 +15,13 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
 
 using namespace llvm;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
-// Mark all our options with this category.
-static cl::OptionCategory AMDGPUArchCategory("amdgpu-arch options");
-
-static void PrintVersion(raw_ostream ) {
-  OS << clang::getClangToolFullVersion("amdgpu-arch") << '\n';
-}
-
 typedef enum {
   HSA_STATUS_SUCCESS = 0x0,
 } hsa_status_t;
@@ -101,22 +93,7 @@
   return HSA_STATUS_SUCCESS;
 }
 
-int main(int argc, char *argv[]) {
-  cl::HideUnrelatedOptions(AMDGPUArchCategory);
-
-  cl::SetVersionPrinter(PrintVersion);
-  cl::ParseCommandLineOptions(
-  argc, argv,
-  "A tool to detect the presence of AMDGPU devices on the system. \n\n"
-  "The tool will output each detected GPU architecture separated by a\n"
-  "newline character. If multiple GPUs of the same architecture are found\n"
-  "a string will be printed for each\n");
-
-  if (Help) {
-cl::PrintHelpMessage();
-return 0;
-  }
-
+int printGPUsByHSA() {
   // Attempt to load the HSA runtime.
   if (llvm::Error Err = loadHSA()) {
 logAllUnhandledErrors(std::move(Err), llvm::errs());
@@ -135,7 +112,7 @@
   }
 
   for (const auto  : GPUs)
-printf("%s\n", GPU.c_str());
+llvm::outs() << GPU << '\n';
 
   if (GPUs.size() < 1)
 return 1;
Index: clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
===
--- /dev/null
+++ clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
@@ -0,0 +1,96 @@
+//===- AMDGPUArch.cpp - list AMDGPU installed --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a tool for detecting name of AMDGPU installed in system
+// using HIP runtime. This tool is used by AMDGPU OpenMP and HIP driver.
+//
+//===--===//
+
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+typedef struct {
+  char padding[396];
+  char gcnArchName[256];
+  char padding2[1024];
+} hipDeviceProp_t;
+
+typedef enum {
+  hipSuccess = 0,
+} hipError_t;
+
+typedef hipError_t (*hipGetDeviceCount_t)(int *);
+typedef hipError_t (*hipDeviceGet_t)(int *, int);
+typedef hipError_t (*hipGetDeviceProperties_t)(hipDeviceProp_t *, int);
+
+int printGPUsByHIP() {
+#ifdef _WIN32
+  constexpr const char *DynamicHIPPath = "amdhip64.dll";

[clang] 661d91a - [clang] Make amdgpu-arch tool work on Windows

2023-07-07 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-07-08T00:01:02-04:00
New Revision: 661d91a0fd4ad80ecc49ebb9e0fff01b4de2ce1c

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

LOG: [clang] Make amdgpu-arch tool work on Windows

Currently amdgpu-arch tool detects AMD GPU by dynamically
loading HSA runtime shared library and using HSA API's,
which is not available on Windows.

This patch makes it work on Windows by dynamically loading
HIP runtime dll and using HIP API's.

Reviewed by: Matt Arsenault, Joseph Huber, Johannes Doerfert

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

Added: 
clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp

Modified: 
clang/tools/amdgpu-arch/AMDGPUArch.cpp
clang/tools/amdgpu-arch/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/amdgpu-arch/AMDGPUArch.cpp 
b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
index 17d188adc3b7d9..7ae57b7877e1fe 100644
--- a/clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -6,18 +6,13 @@
 //
 
//===--===//
 //
-// This file implements a tool for detecting name of AMDGPU installed in system
-// using HSA. This tool is used by AMDGPU OpenMP driver.
+// This file implements a tool for detecting name of AMDGPU installed in 
system.
+// This tool is used by AMDGPU OpenMP and HIP driver.
 //
 
//===--===//
 
 #include "clang/Basic/Version.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/DynamicLibrary.h"
-#include "llvm/Support/Error.h"
-#include 
-#include 
-#include 
 
 using namespace llvm;
 
@@ -30,76 +25,8 @@ static void PrintVersion(raw_ostream ) {
   OS << clang::getClangToolFullVersion("amdgpu-arch") << '\n';
 }
 
-typedef enum {
-  HSA_STATUS_SUCCESS = 0x0,
-} hsa_status_t;
-
-typedef enum {
-  HSA_DEVICE_TYPE_CPU = 0,
-  HSA_DEVICE_TYPE_GPU = 1,
-} hsa_device_type_t;
-
-typedef enum {
-  HSA_AGENT_INFO_NAME = 0,
-  HSA_AGENT_INFO_DEVICE = 17,
-} hsa_agent_info_t;
-
-typedef struct hsa_agent_s {
-  uint64_t handle;
-} hsa_agent_t;
-
-hsa_status_t (*hsa_init)();
-hsa_status_t (*hsa_shut_down)();
-hsa_status_t (*hsa_agent_get_info)(hsa_agent_t, hsa_agent_info_t, void *);
-hsa_status_t (*hsa_iterate_agents)(hsa_status_t (*)(hsa_agent_t, void *),
-   void *);
-
-constexpr const char *DynamicHSAPath = "libhsa-runtime64.so";
-
-llvm::Error loadHSA() {
-  std::string ErrMsg;
-  auto DynlibHandle = std::make_unique(
-  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHSAPath, ));
-  if (!DynlibHandle->isValid()) {
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "Failed to 'dlopen' %s", DynamicHSAPath);
-  }
-#define DYNAMIC_INIT(SYMBOL)   
\
-  {
\
-void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   
\
-if (!SymbolPtr)
\
-  return llvm::createStringError(llvm::inconvertibleErrorCode(),   
\
- "Failed to 'dlsym' " #SYMBOL);
\
-SYMBOL = reinterpret_cast(SymbolPtr);
\
-  }
-  DYNAMIC_INIT(hsa_init);
-  DYNAMIC_INIT(hsa_shut_down);
-  DYNAMIC_INIT(hsa_agent_get_info);
-  DYNAMIC_INIT(hsa_iterate_agents);
-#undef DYNAMIC_INIT
-  return llvm::Error::success();
-}
-
-static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
-  hsa_device_type_t DeviceType;
-  hsa_status_t Status =
-  hsa_agent_get_info(Agent, HSA_AGENT_INFO_DEVICE, );
-
-  // continue only if device type if GPU
-  if (Status != HSA_STATUS_SUCCESS || DeviceType != HSA_DEVICE_TYPE_GPU) {
-return Status;
-  }
-
-  std::vector *GPUs =
-  static_cast *>(Data);
-  char GPUName[64];
-  Status = hsa_agent_get_info(Agent, HSA_AGENT_INFO_NAME, GPUName);
-  if (Status != HSA_STATUS_SUCCESS) {
-return Status;
-  }
-  GPUs->push_back(GPUName);
-  return HSA_STATUS_SUCCESS;
-}
+int printGPUsByHSA();
+int printGPUsByHIP();
 
 int main(int argc, char *argv[]) {
   cl::HideUnrelatedOptions(AMDGPUArchCategory);
@@ -117,29 +44,10 @@ int main(int argc, char *argv[]) {
 return 0;
   }
 
-  // Attempt to load the HSA runtime.
-  if (llvm::Error Err = loadHSA()) {
-logAllUnhandledErrors(std::move(Err), llvm::errs());
-return 1;
-  }
-
-  hsa_status_t Status = hsa_init();
-  if (Status != HSA_STATUS_SUCCESS) {
-return 1;
-  }
-
-  std::vector GPUs;
-  Status = hsa_iterate_agents(iterateAgentsCallback, );
-  if (Status != 

[PATCH] D154758: [clang][Interp] Emit correct diagnostic for uninitialized reads

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

This fixes a long standing diagnostic difference between the two interpreters.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154758

Files:
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp
  clang/test/AST/Interp/cxx20.cpp
  clang/test/AST/Interp/literals.cpp
  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
@@ -429,7 +429,7 @@
   static_assert(D.Val == 0, ""); // ref-error {{not an integral constant expression}} \
  // ref-note {{initializer of 'D' is not a constant expression}} \
  // expected-error {{not an integral constant expression}} \
- // expected-note {{read of object outside its lifetime}}
+ // expected-note {{read of uninitialized object}}
 #endif
 
   struct AnotherBase {
@@ -492,7 +492,7 @@
   constexpr A a{10}; // expected-error {{must be initialized by a constant expression}}
   static_assert(a.m == 10, "");
   static_assert(a.f == 10, ""); // expected-error {{not an integral constant expression}} \
-// expected-note {{read of object outside its lifetime}}
+// expected-note {{read of uninitialized object}}
 
   class Foo {
   public:
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -515,10 +515,10 @@
 T a;
 if constexpr (Inc)
   ++a; // ref-note 2{{increment of uninitialized}} \
-   // expected-note 2{{increment of object outside its lifetime}}
+   // expected-note 2{{increment of uninitialized}}
 else
   --a; // ref-note 2{{decrement of uninitialized}} \
-   // expected-note 2{{decrement of object outside its lifetime}}
+   // expected-note 2{{decrement of uninitialized}}
 return 1;
   }
   static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -59,8 +59,7 @@
 constexpr int unInitLocal() {
   int a;
   return a; // ref-note {{read of uninitialized object}} \
-// expected-note {{read of object outside its lifetime}}
-// FIXME: ^^^ Wrong diagnostic.
+// expected-note {{read of uninitialized object}}
 }
 static_assert(unInitLocal() == 0, ""); // ref-error {{not an integral constant expression}} \
// ref-note {{in call to 'unInitLocal()'}} \
@@ -76,7 +75,7 @@
 
 constexpr int initializedLocal2() {
   int a[2];
-  return *a; // expected-note {{read of object outside its lifetime}} \
+  return *a; // expected-note {{read of uninitialized object is not allowed in a constant expression}} \
  // ref-note {{read of uninitialized object is not allowed in a constant expression}}
 }
 static_assert(initializedLocal2() == 20); // expected-error {{not an integral constant expression}} \
@@ -89,7 +88,7 @@
 constexpr int initializedLocal3() {
   Int i;
   return i.a; // ref-note {{read of uninitialized object is not allowed in a constant expression}} \
-  // expected-note {{read of object outside its lifetime}}
+  // expected-note {{read of uninitialized object}}
 }
 static_assert(initializedLocal3() == 20); // expected-error {{not an integral constant expression}} \
   // expected-note {{in call to}} \
@@ -315,7 +314,7 @@
 
   static_assert(Final{1, 2, 3}.c == 3, ""); // OK
   static_assert(Final{1, 2, 3}.a == 0, ""); // expected-error {{not an integral constant expression}} \
-// expected-note {{read of object outside its lifetime}} \
+// expected-note {{read of uninitialized object}}
 // ref-error {{not an integral constant expression}} \
 // ref-note {{read of uninitialized object}}
 
@@ -337,7 +336,7 @@
   static_assert(Final2{1, 2, 3}.c == 3, ""); // OK
   static_assert(Final2{1, 2, 3}.b == 2, ""); // OK
   static_assert(Final2{1, 2, 3}.a == 0, ""); // expected-error {{not an integral constant expression}} \
- // expected-note {{read of object outside its lifetime}} \
+  

[PATCH] D154396: [clang] Add support for SerenityOS

2023-07-07 Thread Andrew Kaster via Phabricator via cfe-commits
ADKaster planned changes to this revision.
ADKaster added a comment.

Planning to rebase on top of Generic_ELF per Petr's suggestion.




Comment at: clang/lib/Driver/ToolChains/Serenity.cpp:85
+  auto linkerIs = [Exec](const char *name) {
+return llvm::sys::path::filename(Exec).equals_insensitive(name) ||
+   llvm::sys::path::stem(Exec).equals_insensitive(name);

MaskRay wrote:
> Avoid `equals_insensitive`. It's only recommended in some places for Windows.
What is the recommendation for this use case instead? This is the same pattern 
that is used by the Fuchsia driver. 
https://github.com/llvm/llvm-project/blob/01e3393b94d194ee99e57f23f9c08160cef94753/clang/lib/Driver/ToolChains/Fuchsia.cpp#L59-L61

though it looks like Fuchsia used that pattern back when it was called 
`equals_lower()`. 
https://github.com/llvm/llvm-project/commit/3e199ecdadf7b546054c5a5820d1678f1e83c821


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154396

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


[PATCH] D154552: [clang-format] Add note directive generation for docs

2023-07-07 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

It looks like this:
F28163425: image.png 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154552

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


[PATCH] D153359: [clang][Diagnostics] Fix distant source ranges in bad-conversion notes

2023-07-07 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb accepted this revision.
cjdb added a comment.
This revision is now accepted and ready to land.

Yep! Thanks for working on this :-)


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

https://reviews.llvm.org/D153359

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


[PATCH] D154552: [clang-format] Add note directive generation for docs

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

Can you attach a screenshot of how the new `note` section would look like?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154552

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


[PATCH] D154755: [clang-format] Fix formatting of if statements with BlockIndent

2023-07-07 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

Although I chose to preserve the existing behavior of `AlwaysBreak` and to 
mimic it for `BlockIndent`, I think it would be best to choose a consistent 
approach and document it. I also have a patch that does not apply the 
AlignAfterOpenBracket for if clauses, which could be done for only 
`BlockIndent`, or it could be done for `AlwaysBreak` too but that will cause 
some backward compatibility problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154755

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


[clang] 0556ab3 - [clang-format][NFC] Improve efficiency of isFunctionDeclarationName

2023-07-07 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-07-07T16:29:36-07:00
New Revision: 0556ab33532964dd8720b3b3ebd87dfe459d81d2

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

LOG: [clang-format][NFC] Improve efficiency of isFunctionDeclarationName

Return immediately in isFunctionDeclarationName() if the token is neither a
keyword nor an identifier.

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 2ffa07bffa1f32..7bec899754362d 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3129,6 +3129,9 @@ void TokenAnnotator::annotate(AnnotatedLine ) {
 static bool isFunctionDeclarationName(bool IsCpp, const FormatToken ,
   const AnnotatedLine ) {
   assert(Current.Previous);
+  if (!Current.Tok.getIdentifierInfo())
+return false;
+
   auto skipOperatorName = [](const FormatToken *Next) -> const FormatToken * {
 for (; Next; Next = Next->Next) {
   if (Next->is(TT_OverloadedOperatorLParen))



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


[PATCH] D154755: [clang-format] Fix formatting of if statements with BlockIndent

2023-07-07 Thread Gedare Bloom via Phabricator via cfe-commits
gedare created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
gedare requested review of this revision.

A bug with BlockIndent prevents line breaks within if (and else if) clauses.
While fixing this bug, it appears that AlignAfterOpenBracket is not designed
to work with loop and if statements, but AlwaysBreak works on if clauses.
The documentation and tests are not clear on whether or not this is intended.
This patch preserves the AlwaysBreak behavior and supports BlockIndent on if
clauses while fixing the bug.

It may be reasonable to go the other way and create an explicit option for
alignment of if (and loop) clauses intentionally.

Fixes #54663.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154755

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25483,7 +25483,6 @@
   verifyFormat("if (quitelongarg !=\n"
"(alsolongarg - 1)) { // ABC is a very long "
"comment\n"
-   "  return;\n"
"}",
Style);
 
@@ -25494,12 +25493,56 @@
"}",
Style);
 
+  // Treating if clauses as block indents causes a known bug (#54808, #63383)
+  // breaking the following test. It gets formatted instead as:
+  // "if (quitelongarg != (alsolongarg - 1)\n"
+  // ") { // ABC is a very long comment"
+  // "return;"
+  // "}"
+
+#if 0
   verifyFormat("if (quitelongarg !=\n"
"(alsolongarg - 1)) { // ABC is a very long "
"comment\n"
"  return;\n"
"}",
Style);
+#endif
+
+  verifyFormat("void foo() {\n"
+   "  if (quitelongname < alsolongname ||\n"
+   "  anotherevenlongername <=\n"
+   "  thisreallyreallyreallyreallyreallyreallylongername 
||"
+   "\n"
+   "  othername < thislastname) {\n"
+   "return;\n"
+   "  } else if (\n"
+   "  quitelongname < alsolongname ||\n"
+   "  anotherevenlongername <=\n"
+   "  thisreallyreallyreallyreallyreallyreallylongername 
||"
+   "\n"
+   "  othername < thislastname\n"
+   "  ) {\n"
+   "return;\n"
+   "  }\n"
+   "}",
+   Style);
+
+  Style.ContinuationIndentWidth = 2;
+  verifyFormat("void foo() {\n"
+   "  if (\n"
+   "ThisIsRatherALongIfClause && thatIExpectToBeBroken ||\n"
+   "ontoMultipleLines && whenFormattedCorrectly\n"
+   "  ) {\n"
+   "if (false) {\n"
+   "} else if (\n"
+   "  thisIsRatherALongIfClause && thatIExpectToBeBroken ||\n"
+   "  ontoMultipleLines && whenFormattedCorrectly\n"
+   ") {\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentForStatement) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5499,7 +5499,7 @@
 if (Next && Next->is(tok::l_paren))
   return false;
 const FormatToken *Previous = Right.MatchingParen->Previous;
-return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+return !(Previous && Previous->is(tok::kw_for));
   }
 
   // Allow breaking after a trailing annotation, e.g. after a method


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25483,7 +25483,6 @@
   verifyFormat("if (quitelongarg !=\n"
"(alsolongarg - 1)) { // ABC is a very long "
"comment\n"
-   "  return;\n"
"}",
Style);
 
@@ -25494,12 +25493,56 @@
"}",
Style);
 
+  // Treating if clauses as block indents causes a known bug (#54808, #63383)
+  // breaking the following test. It gets formatted instead as:
+  // "if (quitelongarg != (alsolongarg - 1)\n"
+  // ") { // ABC is a very long comment"
+  // "return;"
+  // "}"
+
+#if 0
   verifyFormat("if (quitelongarg !=\n"
"(alsolongarg - 1)) { // ABC is a very long "
"comment\n"
"  return;\n"
"}",

[PATCH] D122874: [clang] Add GNU spelling for no_unqiue_address attribute

2023-07-07 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik abandoned this revision.
philnik added a comment.

I'm dropping this in favour of D151683 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122874

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


[PATCH] D154693: [RISCV] Remote redundant _ta suffix in RVV intrinsics builtins. NFC

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154693

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


[PATCH] D153920: [clang] Move the clang formatting job to run-buildbot to fix the CI

2023-07-07 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 538290.
philnik marked 7 inline comments as done.
philnik added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153920

Files:
  clang/utils/ci/buildkite-pipeline.yml
  clang/utils/ci/run-buildbot
  libcxx/utils/ci/buildkite-pipeline-clang.yml
  libcxx/utils/ci/generate-buildkite-pipeline

Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -11,16 +11,4 @@
 # This script generates the appropriate libc++ CI pipeline based on which project(s) were changed.
 #
 
-if git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/"; then
-  LIBCXX_CHANGED=true
-fi
-
-if git diff --name-only HEAD~1 | grep -q -E "^clang/"; then
-  CLANG_CHANGED=true
-fi
-
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat libcxx/utils/ci/buildkite-pipeline-clang.yml
-else
-  cat libcxx/utils/ci/buildkite-pipeline.yml
-fi
+cat clang/utils/ci/buildkite-pipeline.yml
Index: clang/utils/ci/run-buildbot
===
--- /dev/null
+++ clang/utils/ci/run-buildbot
@@ -0,0 +1,129 @@
+#!/usr/bin/env bash
+#===--===##
+#
+# 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
+#
+#===--===##
+
+set -ex
+set -o pipefail
+unset LANG
+unset LC_ALL
+unset LC_COLLATE
+
+PROGNAME="$(basename "${0}")"
+
+function usage() {
+cat <
+
+[-h|--help] Display this help and exit.
+
+--llvm-rootPath to the root of the LLVM monorepo. By default, we try
+to figure it out based on the current working directory.
+
+--build-dirThe directory to use for building the library. By default,
+this is '/build/'.
+EOF
+}
+
+if [[ $# == 0 ]]; then
+   usage
+   exit 0
+fi
+
+while [[ $# -gt 0 ]]; do
+case ${1} in
+-h|--help)
+usage
+exit 0
+;;
+--llvm-root)
+MONOREPO_ROOT="${2}"
+shift; shift
+;;
+--build-dir)
+BUILD_DIR="${2}"
+shift; shift
+;;
+--osx-roots
+*)
+BUILDER="${1}"
+shift
+;;
+esac
+done
+
+MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
+BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
+INSTALL_DIR="${BUILD_DIR}/install"
+
+# Print the version of a few tools to aid diagnostics in some cases
+cmake --version
+ninja --version
+
+case "${BUILDER}" in
+check-format)
+! grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs
+;;
+build-clang)
+mkdir install
+# We use Release here to avoid including debug information. Otherwise, the
+# clang binary is very large, which is problematic because we need to upload
+# the artifacts for other jobs to use. This may seem like nothing, but with
+# the number of jobs we run daily, this can result in thousands of GB of
+# network I/O.
+cmake  \
+-S llvm\
+-B build   \
+-G Ninja   \
+-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
+-DCMAKE_BUILD_TYPE=Release \
+-DCMAKE_INSTALL_PREFIX=install \
+-DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \
+
+ninja -C build install-clang install-clang-resource-headers
+ccache -s
+tar -cJvf install.tar.xz install/
+buildkite-agent artifact upload --debug install.tar.xz
+;;
+generic-cxx03)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf install.tar.xz
+export CC=$(pwd)/install/bin/clang
+export CXX=$(pwd)/install/bin/clang++
+chmod +x install/bin/clang install/bin/clang++
+libcxx/utils/ci/run-buildbot generic-cxx03
+;;
+generic-cxx26)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf install.tar.xz
+export CC=$(pwd)/install/bin/clang
+export CXX=$(pwd)/install/bin/clang++
+chmod +x install/bin/clang install/bin/clang++
+libcxx/utils/ci/run-buildbot generic-cxx26
+;;
+generic-modules)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf 

[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-07-07 Thread Galen Elias via Phabricator via cfe-commits
galenelias updated this revision to Diff 538288.
galenelias marked 2 inline comments as done.
galenelias added a comment.

Addressed outstanding review comments.


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

https://reviews.llvm.org/D151761

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19244,6 +19244,257 @@
BracedAlign);
 }
 
+TEST_F(FormatTest, AlignConsecutiveShortCaseStatements) {
+  FormatStyle Alignment = getLLVMStyle();
+  Alignment.AllowShortCaseLabelsOnASingleLine = true;
+  Alignment.AlignConsecutiveShortCaseStatements.Enabled = true;
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "default:   return \"default\";\n"
+   "}",
+   Alignment);
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "  return \"warning\";\n"
+   "}",
+   Alignment);
+
+  // Empty case statements push out the alignment, but non-short case labels
+  // don't.
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::critical:\n"
+   "case log::warning:\n"
+   "case log::severe:   return \"severe\";\n"
+   "case log::extra_severe:\n"
+   "  // comment\n"
+   "  return \"extra_severe\";\n"
+   "}",
+   Alignment);
+
+  // Verify comments and empty lines break the alignment.
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "// comment\n"
+   "case log::critical: return \"critical\";\n"
+   "default:return \"default\";\n"
+   "\n"
+   "case log::severe: return \"severe\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "// comment\n"
+   "case log::critical: return \"critical\";\n"
+   "default:return \"default\";\n"
+   "\n"
+   "case log::severe: return \"severe\";\n"
+   "}",
+   Alignment);
+
+  // Empty case statements don't break the alignment, and potentially push it
+  // out.
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "case log::critical:\n"
+   "default:return \"default\";\n"
+   "}",
+   Alignment);
+
+  // Implicit fallthrough cases can be aligned with either a comment or
+  // [[fallthrough]]
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:  // fallthrough\n"
+   "case log::error:return \"error\";\n"
+   "case log::critical: /*fallthrough*/\n"
+   "case log::severe:   return \"severe\";\n"
+   "case log::diag: [[fallthrough]];\n"
+   "default:return \"default\";\n"
+   "}",
+   Alignment);
+
+  // Verify trailing comment that needs a reflow also gets aligned properly.
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: // fallthrough\n"
+   "case log::error:   return \"error\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: //fallthrough\n"
+   "case log::error:   return \"error\";\n"
+   "}",
+   Alignment);
+
+  // Verify adjacent non-short case statements don't change the alignment, and
+  // properly break the set of consecutive statements.
+  verifyFormat("switch (level) {\n"
+   "case log::critical:\n"
+   "  // comment\n"
+   "  return \"critical\";\n"
+   "case log::info:return \"info\";\n"
+   "case 

[PATCH] D141757: [clangd] allow extracting to variable for lambda expressions

2023-07-07 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti updated this revision to Diff 538289.
5chmidti added a comment.

Ping, and:

- removed mention of captures from the condition about blocking extraction 
because that is allowed
- removed `(of a lambda)` from the following comment because it is not just 
about defaulted parameters of lambdas, but of all functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141757

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -66,6 +66,11 @@
 Code completion
 ^^^
 
+Code actions
+
+
+- The extract variable tweak gained support for extracting lambda expressions to a variable.
+
 Signature help
 ^^
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -131,7 +131,43 @@
   goto label;
   label:
 a = [[1]];
-}
+
+  // lambdas
+  [][[(){}]];
+
+  // lambdas: captures
+  int x = 0;
+  [ [[=]] ](){};
+  [ [[&]] ](){};
+  [ [[x]] ](){};
+  [ [[] ]](){};
+  [y = [[x]] ](){};
+  [ [[y = x]] ](){};
+
+  // lambdas: default args
+  [](int x = [[10]]){};
+  [](auto h = [i = [[ [](){} ]]](){}) {};
+  [](auto h = [[ [i = [](){}](){} ]]) {};
+
+  // lambdas: scope
+  if (int a = 1)
+if ([[ [&](){ return a + 1; } ]]() == 4)
+  a = a + 1;
+
+  for (int c = 0; [[ [&]() { return c < b; } ]](); ++c) {
+  }
+  for (int c = 0; [[ [&]() { return c < b; } () ]]; ++c) {
+  }
+
+  // lambdas: scope with structured binding
+  struct Coordinates {
+int x{};
+int y{};
+  };
+  Coordinates c{};
+  if (const auto [x, y] = c; x > y)
+auto f = [[ [&]() { return x + y; } ]];
+  }
   )cpp";
   EXPECT_UNAVAILABLE(UnavailableCases);
 
@@ -282,6 +318,209 @@
  void f() {
auto placeholder = S(2) + S(3) + S(4); S x = S(1) + placeholder + S(5);
  })cpp"},
+  // lambda expressions
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f([[ [](){ return 42; }]]);
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2() {
+  auto placeholder = [](){ return 42; }; f( placeholder);
+}
+)cpp"},
+  {R"cpp(auto foo(int VarA) {
+  return [VarA]() {
+return [[ [VarA, VarC = 42 + VarA](int VarB) { return VarA + VarB + VarC; }]];
+  };
+}
+)cpp",
+   R"cpp(auto foo(int VarA) {
+  return [VarA]() {
+auto placeholder = [VarA, VarC = 42 + VarA](int VarB) { return VarA + VarB + VarC; }; return  placeholder;
+  };
+}
+)cpp"},
+  {R"cpp(template  void f(T) {}
+void f2(int var) {
+  f([[ [](){ auto internal_val = 42; return var + internal_val; }]]);
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2(int var) {
+  auto placeholder = [](){ auto internal_val = 42; return var + internal_val; }; f( placeholder);
+}
+)cpp"},
+  {R"cpp(template  void f(T) { }
+struct A {
+void f2(int& var) {
+auto local_var = 42;
+f([[ [, _var, this]() {
+auto internal_val = 42;
+return var + local_var + internal_val + member;
+}]]);
+}
+
+int member = 42;
+};
+)cpp",
+   R"cpp(template  void f(T) { }
+struct A {
+void f2(int& var) {
+auto local_var = 42;
+auto placeholder = [, _var, this]() {
+auto internal_val = 42;
+return var + local_var + internal_val + member;
+}; f( placeholder);
+}
+
+int member = 42;
+};
+)cpp"},
+  {R"cpp(void f() { auto x = [[ [](){ return 42; }]]; })cpp",
+   R"cpp(void f() { auto placeholder = [](){ return 42; }; auto x =  placeholder; })cpp"},
+  {R"cpp(
+

[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-07-07 Thread Galen Elias via Phabricator via cfe-commits
galenelias marked 6 inline comments as done.
galenelias added inline comments.



Comment at: clang/include/clang/Format/Format.h:380
+}
+bool operator!=(const ShortCaseStatementsAlignmentStyle ) const {
+  return !(*this == R);

HazardyKnusperkeks wrote:
> I'd drop that. We don't have it for any other struct.
> 
> And with C++20 you don't need this anymore (although I don't know when llvm 
> will switch to c++20).
We do have it for `TrailingCommentsAlignmentStyle` and `AlignConsecutiveStyle`, 
but I will drop it.



Comment at: clang/unittests/Format/ConfigParseTest.cpp:321
   CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveDeclarations);
+  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveShortCaseStatements);
 

HazardyKnusperkeks wrote:
> You now have to write your own checks for the parsing. (It's just copy & 
> paste.)
Aah, I had missed the `CHECK_PARSE_NESTED_BOOL`s for the existing 
alignConsecutive options within their macro.  Will fix. Thanks


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

https://reviews.llvm.org/D151761

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


[PATCH] D138499: [clangd] Extract Function: add hoisting support

2023-07-07 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti updated this revision to Diff 538286.
5chmidti added a comment.

Ping, and:

- change find_if of post-use detection to range-for with a filtered range
- make `renderHoistedCall` a private member of `NewFunction`
- remove the `Render` lambda in `renderHoistSet` in favor of putting the body 
into the loop, improving readability imo.
- swapped order in tertiary operator to remove the `!` in the condition for 
better readability
- add abort condtition if any of the `NamedDecl`s to be hoisted is a 
`TypeDecl`. The `HoistedSet` can contain `TypeDecl`s, which block the 
extraction because types cannot be hoisted as easily as variables. Hoisting 
types could be done by moving the declaration into the scope that the functions 
are declared in (global, namespace or records). I could take a look at this if 
there is interest, but I think that should be its own diff.
- add tests about full and partial selection of type aliases and classes

Open questions:

- I think that ``/`` should be included if a `tuple` or `pair` 
is used, but couldn't figure out a clean way to include the headers. It looks 
like the way to go would be through `IncludeCleaner`s `insert` function, but 
for that I woul dneed to construct the `IncludeInserter`. I don't think I can 
get the `FormatStyle` or `BuildDir` from inside of a tweak. Does anyone have an 
idea or is this a non-issue?
- The tweak is unavailable if a tuple or pair is required for the hoisting, but 
no auto return-type deduction is available. This is the case because I 
implemented the return type of the hoisted variables to use `tuple` or `pair` 
if two or more variables are returned, but to keep the return type short, I set 
the return type in these cases to `auto`. Should the return type be fully 
spelled out? Should it be spelled out always or should there be a config option 
(seems a bit overkill)?
- I'm not a fan of the `const&` `HoistSet` member that I used. Should I change 
this to a pointer (its always non-null)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138499

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -78,6 +78,9 @@
 Miscellaneous
 ^
 
+- The extract function tweak gained support for hoisting, i.e. returning decls declared
+  inside the selection that are used outside of the selection.
+
 Improvements to clang-doc
 -
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -30,8 +30,9 @@
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
   // Partial statements aren't extracted.
   EXPECT_THAT(apply("int [[x = 0]];"), "unavailable");
-  // FIXME: Support hoisting.
-  EXPECT_THAT(apply(" [[int a = 5;]] a++; "), "unavailable");
+
+  // Extract regions that require hoisting
+  EXPECT_THAT(apply(" [[int a = 5;]] a++; "), HasSubstr("extracted"));
 
   // Ensure that end of Zone and Beginning of PostZone being adjacent doesn't
   // lead to break being included in the extraction zone.
@@ -192,6 +193,310 @@
   EXPECT_EQ(apply(CompoundFailInput), "unavailable");
 }
 
+TEST_F(ExtractFunctionTest, Hoisting) {
+  ExtraArgs.emplace_back("-std=c++17");
+  std::string HoistingInput = R"cpp(
+int foo() {
+  int a = 3;
+  [[int x = 39 + a;
+  ++x;
+  int y = x * 2;
+  int z = 4;]]
+  return x + y + z;
+}
+  )cpp";
+  std::string HoistingOutput = R"cpp(
+auto extracted(int ) {
+int x = 39 + a;
+  ++x;
+  int y = x * 2;
+  int z = 4;
+return std::tuple{x, y, z};
+}
+int foo() {
+  int a = 3;
+  auto [x, y, z] = extracted(a);
+  return x + y + z;
+}
+  )cpp";
+  EXPECT_EQ(apply(HoistingInput), HoistingOutput);
+
+  std::string HoistingInput2 = R"cpp(
+int foo() {
+  int a{};
+  [[int b = a + 1;]]
+  return b;
+}
+  )cpp";
+  std::string HoistingOutput2 = R"cpp(
+int extracted(int ) {
+int b = a + 1;
+return b;
+}
+int foo() {
+  int a{};
+  auto b = extracted(a);
+  return b;
+}
+  )cpp";
+  EXPECT_EQ(apply(HoistingInput2), HoistingOutput2);
+
+  std::string HoistingInput3 = R"cpp(
+int foo(int b) {
+  int a{};
+  if (b == 42) {
+[[a = 123;
+return a + b;]]
+  }
+  a = 456;
+  return a;
+}
+  )cpp";
+  std::string HoistingOutput3 = R"cpp(
+int extracted(int , int ) {
+a = 123;
+return a + b;
+}
+int foo(int 

[PATCH] D154658: Optimize emission of `dynamic_cast` to final classes.

2023-07-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 538283.
rsmith added a comment.

- Mark gep as inbounds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154658

Files:
  clang/lib/AST/ExprCXX.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/dynamic-cast-always-null.cpp
  clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
  clang/test/CodeGenCXX/dynamic-cast-exact.cpp

Index: clang/test/CodeGenCXX/dynamic-cast-exact.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dynamic-cast-exact.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s --implicit-check-not='call {{.*}} @__dynamic_cast'
+struct Offset { virtual ~Offset(); };
+struct A { virtual ~A(); };
+struct B final : Offset, A { };
+
+struct C { virtual ~C(); int c; };
+struct D : A { int d; };
+struct E : A { int e; };
+struct F : virtual A { int f; };
+struct G : virtual A { int g; };
+struct H final : C, D, E, F, G { int h; };
+
+// CHECK-LABEL: @_Z7inexactP1A
+C *inexact(A *a) {
+  // CHECK: call {{.*}} @__dynamic_cast
+  return dynamic_cast(a);
+}
+
+// CHECK-LABEL: @_Z12exact_singleP1A
+B *exact_single(A *a) {
+  // CHECK: %[[PTR_NULL:.*]] = icmp eq ptr %[[PTR:.*]], null
+  // CHECK: br i1 %[[PTR_NULL]], label %[[LABEL_FAILED:.*]], label %[[LABEL_NOTNULL:.*]]
+
+  // CHECK: [[LABEL_NOTNULL]]:
+  // CHECK: %[[VPTR:.*]] = load ptr, ptr %[[PTR]]
+  // CHECK: %[[MATCH:.*]] = icmp eq ptr %[[VPTR]], getelementptr inbounds ({ [4 x ptr], [4 x ptr] }, ptr @_ZTV1B, i32 0, inrange i32 1, i32 2)
+  // CHECK: %[[RESULT:.*]] = getelementptr inbounds i8, ptr %[[PTR]], i64 -8
+  // CHECK: br i1 %[[MATCH]], label %[[LABEL_END:.*]], label %[[LABEL_FAILED]]
+
+  // CHECK: [[LABEL_FAILED]]:
+  // CHECK: br label %[[LABEL_END]]
+
+  // CHECK: [[LABEL_END]]:
+  // CHECK: phi ptr [ %[[RESULT]], %[[LABEL_NOTNULL]] ], [ null, %[[LABEL_FAILED]] ]
+  return dynamic_cast(a);
+}
+
+// CHECK-LABEL: @_Z9exact_refR1A
+B _ref(A ) {
+  // CHECK: %[[PTR_NULL:.*]] = icmp eq ptr %[[PTR:.*]], null
+  // CHECK: br i1 %[[PTR_NULL]], label %[[LABEL_FAILED:.*]], label %[[LABEL_NOTNULL:.*]]
+
+  // CHECK: [[LABEL_NOTNULL]]:
+  // CHECK: %[[VPTR:.*]] = load ptr, ptr %[[PTR]]
+  // CHECK: %[[MATCH:.*]] = icmp eq ptr %[[VPTR]], getelementptr inbounds ({ [4 x ptr], [4 x ptr] }, ptr @_ZTV1B, i32 0, inrange i32 1, i32 2)
+  // CHECK: %[[RESULT:.*]] = getelementptr inbounds i8, ptr %[[PTR]], i64 -8
+  // CHECK: br i1 %[[MATCH]], label %[[LABEL_END:.*]], label %[[LABEL_FAILED]]
+
+  // CHECK: [[LABEL_FAILED]]:
+  // CHECK: call {{.*}} @__cxa_bad_cast
+  // CHECK: unreachable
+
+  // CHECK: [[LABEL_END]]:
+  // CHECK: ret ptr %[[RESULT]]
+  return dynamic_cast(a);
+}
+
+// CHECK-LABEL: @_Z11exact_multiP1A
+H *exact_multi(A *a) {
+  // CHECK: %[[PTR_NULL:.*]] = icmp eq ptr %[[PTR:.*]], null
+  // CHECK: br i1 %[[PTR_NULL]], label %[[LABEL_FAILED:.*]], label %[[LABEL_NOTNULL:.*]]
+
+  // CHECK: [[LABEL_NOTNULL]]:
+  // CHECK: %[[VPTR:.*]] = load ptr, ptr %[[PTR]]
+  // CHECK: %[[OFFSET_TO_TOP_SLOT:.*]] = getelementptr inbounds i64, ptr %[[VPTR]], i64 -2
+  // CHECK: %[[OFFSET_TO_TOP:.*]] = load i64, ptr %[[OFFSET_TO_TOP_SLOT]]
+  // CHECK: %[[RESULT:.*]] = getelementptr inbounds i8, ptr %[[PTR]], i64 %[[OFFSET_TO_TOP]]
+  // CHECK: %[[DERIVED_VPTR:.*]] = load ptr, ptr %[[RESULT]]
+  // CHECK: %[[MATCH:.*]] = icmp eq ptr %[[DERIVED_VPTR]], getelementptr inbounds ({ [5 x ptr], [4 x ptr], [4 x ptr], [6 x ptr], [6 x ptr] }, ptr @_ZTV1H, i32 0, inrange i32 0, i32 3)
+  // CHECK: br i1 %[[MATCH]], label %[[LABEL_END:.*]], label %[[LABEL_FAILED]]
+
+  // CHECK: [[LABEL_FAILED]]:
+  // CHECK: br label %[[LABEL_END]]
+
+  // CHECK: [[LABEL_END]]:
+  // CHECK: phi ptr [ %[[RESULT]], %[[LABEL_NOTNULL]] ], [ null, %[[LABEL_FAILED]] ]
+  return dynamic_cast(a);
+}
Index: clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,EXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -fvisibility=hidden -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
+
+struct A { virtual ~A(); };
+struct B final : A { };
+
+// CHECK-LABEL: @_Z5exactP1A
+B *exact(A *a) {
+  // INEXACT: call 

[PATCH] D154503: [Sema] Fix handling of functions that hide classes

2023-07-07 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added reviewers: aaron.ballman, clang-language-wg.
shafik added a comment.

For more visibility.


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

https://reviews.llvm.org/D154503

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


[PATCH] D154658: Optimize emission of `dynamic_cast` to final classes.

2023-07-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith marked an inline comment as done.
rsmith added a comment.

In D154658#4481225 , @rjmccall wrote:

> In D154658#4479213 , @rsmith wrote:
>
>> I think (hope?) we should be able to apply this to a much larger set of 
>> cases. Would it be correct to do this optimization unless the vtable might 
>> be emitted with vague linkage and non-default visibility (that is, unless 
>> we're in the odd case where people expect non-default visibility classes to 
>> be the same type across DSOs)? Or are there cases where we might be using a 
>> vtable that (eg) doesn't even have the right symbol?
>
> I don't know of any problems other than the total failure of vague linkage 
> across DSO boundaries, so if we just treat that as an implicit exception to 
> the vtable uniqueness guarantee in the ABI, I think you've got the condition 
> exactly right: we could do this for any class where either the v-table 
> doesn't have vague linkage or the class's formal visibility is not `default`. 
>  Our experience at Apple with enforcing type visibility is that it's usually 
> good for one or two bug reports a year, but it's pretty easy to explain to 
> users what they did wrong, and Clang's visibility attributes are pretty 
> simple to use.  (`type_visibility` helps a lot with managing tradeoffs.)

I did some checking through the Clang implementation and found another two 
cases:

- under `-fapple-kext`, vague-linkage vtables get emitted in each translation 
unit that references them
- under `-fno-rtti`, identical vtables for distinct types could get merged 
because we emit vtables as `unnamed_addr` (this doesn't affect `dynamic_cast`, 
because `-fno-rtti` also disables `dynamic_cast` entirely)

The good news seems to be that if you don't use any language extensions (type 
visibility, `-fno-rtti`, `-fapple-kext`), then we do actually provide the 
guarantee that the ABI describes. :)

In D154658#4479170 , @rjmccall wrote:

> If there are multiple subobjects of the source type in the destination type, 
> consider just casting to `void*` first instead of doing multiple comparisons.

This turned out to be a little subtle: the vptr comparison we do after the cast 
requires loading a vptr of an object of entirely-unknown type. This is the 
first time we're doing that in IR generation, and `GetVTablePtr` expected to be 
told which class it's loading the vtable for (presumably, so that it can load 
from the right offset within the class). However, the implementation of 
`GetVTablePtr` didn't use the class for anything; it's always at the start for 
all of our supported ABIs. But this patch would make it harder to support an 
ABI that didn't put the vptr at the start of the most-derived object.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154658

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


[PATCH] D154658: Optimize emission of `dynamic_cast` to final classes.

2023-07-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 538281.
rsmith added a comment.

- Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154658

Files:
  clang/lib/AST/ExprCXX.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/dynamic-cast-always-null.cpp
  clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
  clang/test/CodeGenCXX/dynamic-cast-exact.cpp

Index: clang/test/CodeGenCXX/dynamic-cast-exact.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dynamic-cast-exact.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s --implicit-check-not='call {{.*}} @__dynamic_cast'
+struct Offset { virtual ~Offset(); };
+struct A { virtual ~A(); };
+struct B final : Offset, A { };
+
+struct C { virtual ~C(); int c; };
+struct D : A { int d; };
+struct E : A { int e; };
+struct F : virtual A { int f; };
+struct G : virtual A { int g; };
+struct H final : C, D, E, F, G { int h; };
+
+// CHECK-LABEL: @_Z7inexactP1A
+C *inexact(A *a) {
+  // CHECK: call {{.*}} @__dynamic_cast
+  return dynamic_cast(a);
+}
+
+// CHECK-LABEL: @_Z12exact_singleP1A
+B *exact_single(A *a) {
+  // CHECK: %[[PTR_NULL:.*]] = icmp eq ptr %[[PTR:.*]], null
+  // CHECK: br i1 %[[PTR_NULL]], label %[[LABEL_FAILED:.*]], label %[[LABEL_NOTNULL:.*]]
+
+  // CHECK: [[LABEL_NOTNULL]]:
+  // CHECK: %[[VPTR:.*]] = load ptr, ptr %[[PTR]]
+  // CHECK: %[[MATCH:.*]] = icmp eq ptr %[[VPTR]], getelementptr inbounds ({ [4 x ptr], [4 x ptr] }, ptr @_ZTV1B, i32 0, inrange i32 1, i32 2)
+  // CHECK: %[[RESULT:.*]] = getelementptr i8, ptr %[[PTR]], i64 -8
+  // CHECK: br i1 %[[MATCH]], label %[[LABEL_END:.*]], label %[[LABEL_FAILED]]
+
+  // CHECK: [[LABEL_FAILED]]:
+  // CHECK: br label %[[LABEL_END]]
+
+  // CHECK: [[LABEL_END]]:
+  // CHECK: phi ptr [ %[[RESULT]], %[[LABEL_NOTNULL]] ], [ null, %[[LABEL_FAILED]] ]
+  return dynamic_cast(a);
+}
+
+// CHECK-LABEL: @_Z9exact_refR1A
+B _ref(A ) {
+  // CHECK: %[[PTR_NULL:.*]] = icmp eq ptr %[[PTR:.*]], null
+  // CHECK: br i1 %[[PTR_NULL]], label %[[LABEL_FAILED:.*]], label %[[LABEL_NOTNULL:.*]]
+
+  // CHECK: [[LABEL_NOTNULL]]:
+  // CHECK: %[[VPTR:.*]] = load ptr, ptr %[[PTR]]
+  // CHECK: %[[MATCH:.*]] = icmp eq ptr %[[VPTR]], getelementptr inbounds ({ [4 x ptr], [4 x ptr] }, ptr @_ZTV1B, i32 0, inrange i32 1, i32 2)
+  // CHECK: %[[RESULT:.*]] = getelementptr i8, ptr %[[PTR]], i64 -8
+  // CHECK: br i1 %[[MATCH]], label %[[LABEL_END:.*]], label %[[LABEL_FAILED]]
+
+  // CHECK: [[LABEL_FAILED]]:
+  // CHECK: call {{.*}} @__cxa_bad_cast
+  // CHECK: unreachable
+
+  // CHECK: [[LABEL_END]]:
+  // CHECK: ret ptr %[[RESULT]]
+  return dynamic_cast(a);
+}
+
+// CHECK-LABEL: @_Z11exact_multiP1A
+H *exact_multi(A *a) {
+  // CHECK: %[[PTR_NULL:.*]] = icmp eq ptr %[[PTR:.*]], null
+  // CHECK: br i1 %[[PTR_NULL]], label %[[LABEL_FAILED:.*]], label %[[LABEL_NOTNULL:.*]]
+
+  // CHECK: [[LABEL_NOTNULL]]:
+  // CHECK: %[[VPTR:.*]] = load ptr, ptr %[[PTR]]
+  // CHECK: %[[OFFSET_TO_TOP_SLOT:.*]] = getelementptr inbounds i64, ptr %[[VPTR]], i64 -2
+  // CHECK: %[[OFFSET_TO_TOP:.*]] = load i64, ptr %[[OFFSET_TO_TOP_SLOT]]
+  // CHECK: %[[RESULT:.*]] = getelementptr inbounds i8, ptr %[[PTR]], i64 %[[OFFSET_TO_TOP]]
+  // CHECK: %[[DERIVED_VPTR:.*]] = load ptr, ptr %[[RESULT]]
+  // CHECK: %[[MATCH:.*]] = icmp eq ptr %[[DERIVED_VPTR]], getelementptr inbounds ({ [5 x ptr], [4 x ptr], [4 x ptr], [6 x ptr], [6 x ptr] }, ptr @_ZTV1H, i32 0, inrange i32 0, i32 3)
+  // CHECK: br i1 %[[MATCH]], label %[[LABEL_END:.*]], label %[[LABEL_FAILED]]
+
+  // CHECK: [[LABEL_FAILED]]:
+  // CHECK: br label %[[LABEL_END]]
+
+  // CHECK: [[LABEL_END]]:
+  // CHECK: phi ptr [ %[[RESULT]], %[[LABEL_NOTNULL]] ], [ null, %[[LABEL_FAILED]] ]
+  return dynamic_cast(a);
+}
Index: clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,EXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -fvisibility=hidden -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
+
+struct A { virtual ~A(); };
+struct B final : A { };
+
+// CHECK-LABEL: @_Z5exactP1A
+B *exact(A *a) {
+  // INEXACT: call {{.*}} 

[PATCH] D131533: [Flang][Driver] Enable PIC in the frontend

2023-07-07 Thread Valentin Clement via Phabricator via cfe-commits
clementval added inline comments.
Herald added a subscriber: sunshaoce.



Comment at: flang/test/Driver/pic-flags.f90:3
 
-! RUN: %flang -### %s --target=aarch64-linux-gnu 2>&1 | FileCheck %s 
--check-prefix=CHECK-NOPIE
-! RUN: %flang -### %s --target=aarch64-linux-gnu -fno-pie 2>&1 | FileCheck %s 
--check-prefix=CHECK-NOPIE
+! RUN: %flang -v -S -emit-llvm -o - %s --target=aarch64-linux-gnu 2>&1 | 
FileCheck %s --check-prefixes=CHECK,CHECK-PIE-LEVEL2,CHECK-PIE-LEVEL2-IR
+! RUN: %flang -v -S -emit-llvm -o - %s --target=aarch64-linux-gnu -fpie 2>&1 | 
FileCheck %s --check-prefixes=CHECK,CHECK-PIE-LEVEL1,CHECK-PIE-LEVEL1-IR

This test has been failing on my side for very long time. Just curious why we 
check for PIE-LEVEL-2 when no level is given. Where is the default given?

On my machine I have `-mrelocation-model static` for this run line. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131533

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


[PATCH] D143617: [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT options

2023-07-07 Thread Amir Ayupov via Phabricator via cfe-commits
Amir updated this revision to Diff 538271.
Amir added a comment.

Rebase + reformatted with `black` (D150761 )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143617

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/BOLT.cmake
  clang/utils/perf-training/CMakeLists.txt
  clang/utils/perf-training/bolt.lit.cfg
  clang/utils/perf-training/bolt.lit.site.cfg.in
  clang/utils/perf-training/perf-helper.py

Index: clang/utils/perf-training/perf-helper.py
===
--- clang/utils/perf-training/perf-helper.py
+++ clang/utils/perf-training/perf-helper.py
@@ -67,6 +67,71 @@
 return 0
 
 
+def perf(args):
+parser = argparse.ArgumentParser(
+prog="perf-helper perf", description="perf wrapper for BOLT profile collection"
+)
+parser.add_argument(
+"--lbr", required=False, action="store_true", help="Use perf with branch stacks"
+)
+parser.add_argument("cmd", nargs="*", help="")
+
+# Use python's arg parser to handle all leading option arguments, but pass
+# everything else through to perf
+first_cmd = next(arg for arg in args if not arg.startswith("--"))
+last_arg_idx = args.index(first_cmd)
+
+opts = parser.parse_args(args[:last_arg_idx])
+# cmd = shlex.split(args[last_arg_idx:])
+cmd = args[last_arg_idx:]
+
+perf_args = []
+perf_args.extend(
+(
+"perf",
+"record",
+"--event=cycles:u",
+"--freq=max",
+"--output=%d.perf.data" % os.getpid(),
+)
+)
+if opts.lbr:
+perf_args += ["--branch-filter=any,u"]
+perf_args.extend(cmd)
+
+start_time = time.time()
+subprocess.check_call(perf_args)
+
+elapsed = time.time() - start_time
+print("... data collection took %.4fs" % elapsed)
+return 0
+
+
+def perf2bolt(args):
+parser = argparse.ArgumentParser(
+prog="perf-helper perf2bolt",
+description="perf2bolt conversion wrapper for perf.data files",
+)
+parser.add_argument("p2b_path", help="Path to llvm-bolt")
+parser.add_argument("path", help="Path containing perf.data files")
+parser.add_argument("binary", help="Input binary")
+parser.add_argument(
+"--nolbr", required=False, action="store_true", help="Use -nl perf2bolt mode"
+)
+opts = parser.parse_args(args)
+
+p2b_args = []
+p2b_args.extend(
+(opts.p2b_path, opts.binary, "--aggregate-only", "--profile-format=yaml")
+)
+if opts.nolbr:
+p2b_args += ["-nl"]
+p2b_args += ["-p"]
+for filename in findFilesWithExtension(opts.path, "perf.data"):
+subprocess.check_call(p2b_args + [filename, "-o", filename + ".fdata"])
+return 0
+
+
 def dtrace(args):
 parser = argparse.ArgumentParser(
 prog="perf-helper dtrace",
@@ -507,6 +572,8 @@
 "cc1": cc1,
 "gen-order-file": genOrderFile,
 "merge-fdata": merge_fdata,
+"perf": perf,
+"perf2bolt": perf2bolt,
 }
 
 
Index: clang/utils/perf-training/bolt.lit.site.cfg.in
===
--- clang/utils/perf-training/bolt.lit.site.cfg.in
+++ clang/utils/perf-training/bolt.lit.site.cfg.in
@@ -9,6 +9,7 @@
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_exe = "@Python3_EXECUTABLE@"
 config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
+config.clang_bolt_mode = "@CLANG_BOLT@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/bolt.lit.cfg")
Index: clang/utils/perf-training/bolt.lit.cfg
===
--- clang/utils/perf-training/bolt.lit.cfg
+++ clang/utils/perf-training/bolt.lit.cfg
@@ -6,15 +6,52 @@
 import os
 import subprocess
 
-config.clang = os.path.realpath(lit.util.which('clang-bolt.inst', config.clang_tools_dir)).replace('\\', '/')
+clang_binary = "clang"
+perf_wrapper = ""
+if config.clang_bolt_mode.lower() == "instrument":
+clang_binary = "clang-bolt.inst"
+else:  # perf or LBR
+perf_wrapper = "%s %s/perf-helper.py perf" % (
+config.python_exe,
+config.perf_helper_dir,
+)
+if config.clang_bolt_mode.lower() == "lbr":
+perf_wrapper += " --lbr"
+perf_wrapper += " -- "
 
-config.name = 'Clang Perf Training'
-config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test']
+config.clang = os.path.realpath(
+lit.util.which(clang_binary, config.clang_tools_dir)
+).replace("\\", "/")
+
+config.name = "Clang Perf Training"
+config.suffixes = [
+".c",
+".cc",
+".cpp",
+".m",
+".mm",
+".cu",
+".ll",
+".cl",
+".s",
+".S",
+".modulemap",
+".test",
+]
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = 

[clang] 2a65d03 - [libc] Add support for creating wrapper headers for offloading in clang

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

Author: Joseph Huber
Date: 2023-07-07T16:02:33-05:00
New Revision: 2a65d0388ca0f1c756f4c1a859cbb9e24b364942

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

LOG: [libc] Add support for creating wrapper headers for offloading in clang

This is an alternate approach to the patches proposed in D153897 and
D153794. Rather than exporting a single header that can be included on
the GPU in all circumstances, this patch chooses to instead generate a
separate set of headers that only provides the declarations. This can
then be used by external tooling to set up what's on the GPU. This
leaves room for header hacks for offloading languages without needing to
worry about the `libc` implementation.

Currently this generates a set of headers that only contain the
declarations. These will then be installed to a new clang resource
directory called `llvm_libc_wrappers/` which will house the shim code.
We can then automaticlaly include this from `clang` when offloading to
wrap around the headers while specifying what's on the GPU.

Reviewed By: jdoerfert, JonChesterfield

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

Added: 
clang/lib/Headers/llvm_libc_wrappers/ctype.h
clang/lib/Headers/llvm_libc_wrappers/inttypes.h
clang/lib/Headers/llvm_libc_wrappers/llvm-libc-decls/README.txt
clang/lib/Headers/llvm_libc_wrappers/stdio.h
clang/lib/Headers/llvm_libc_wrappers/stdlib.h
clang/lib/Headers/llvm_libc_wrappers/string.h

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Headers/CMakeLists.txt
clang/test/Driver/gpu-libc-headers.c
libc/cmake/modules/LLVMLibCHeaderRules.cmake
libc/include/CMakeLists.txt
libc/utils/HdrGen/Generator.cpp
libc/utils/HdrGen/Generator.h
libc/utils/HdrGen/Main.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 595cb649603736..e3d7b05d2521c0 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1181,23 +1181,30 @@ void Clang::AddPreprocessingOptions(Compilation , 
const JobAction ,
 
   // If we are compiling for a GPU target we want to override the system 
headers
   // with ones created by the 'libc' project if present.
-  // FIXME: We need to find a way to make these headers compatible with the
-  // host environment so they can be included from offloading languages. For 
now
-  // these are only active when targeting the GPU with cross-compilation.
   if (!Args.hasArg(options::OPT_nostdinc) &&
   !Args.hasArg(options::OPT_nogpuinc) &&
   !Args.hasArg(options::OPT_nobuiltininc) &&
-  C.getActiveOffloadKinds() == Action::OFK_None &&
   (getToolChain().getTriple().isNVPTX() ||
getToolChain().getTriple().isAMDGCN())) {
 
-  // Add include/gpu-none-libc/* to our system include path. This lets us 
use
-  // GPU-specific system headers first.
+// Without an offloading language we will include these headers directly.
+// Offloading languages will instead only use the declarations stored in
+// the resource directory at clang/lib/Headers/llvm_libc_wrappers.
+if (C.getActiveOffloadKinds() == Action::OFK_None) {
   SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir));
   llvm::sys::path::append(P, "include");
   llvm::sys::path::append(P, "gpu-none-llvm");
   CmdArgs.push_back("-c-isystem");
   CmdArgs.push_back(Args.MakeArgString(P));
+} else if (C.getActiveOffloadKinds() == Action::OFK_OpenMP) {
+  // TODO: CUDA / HIP include their own headers for some common functions
+  // implemented here. We'll need to clean those up so they do not 
conflict.
+  SmallString<128> P(D.ResourceDir);
+  llvm::sys::path::append(P, "include");
+  llvm::sys::path::append(P, "llvm_libc_wrappers");
+  CmdArgs.push_back("-internal-isystem");
+  CmdArgs.push_back(Args.MakeArgString(P));
+}
   }
 
   // If we are offloading to a target via OpenMP we need to include the

diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index 9d6ac8b7e449a1..5a219e234452a9 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -298,6 +298,14 @@ set(openmp_wrapper_files
   openmp_wrappers/new
 )
 
+set(llvm_libc_wrapper_files
+  llvm_libc_wrappers/stdio.h
+  llvm_libc_wrappers/stdlib.h
+  llvm_libc_wrappers/string.h
+  llvm_libc_wrappers/ctype.h
+  llvm_libc_wrappers/inttypes.h
+)
+
 include(GetClangResourceDir)
 get_clang_resource_dir(output_dir PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. 
SUBDIR include)
 set(out_files)
@@ -333,7 +341,8 @@ endfunction(clang_generate_header)
 
 # Copy header files from the source directory to the build directory
 foreach( f ${files} 

[PATCH] D154696: [Clang] Diagnose jumps into statement expressions

2023-07-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin marked 2 inline comments as done.
cor3ntin added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:571
   (`#61758 `_)
+- Correcly diagnose jumps into statement expressions.
+  (`#63682 `_)

shafik wrote:
> Maybe remark this conforms with gcc behavior.
I added something. should we link to GCC documentation?



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:489
+Scopes.push_back(GotoScope(ParentScope,
+   diag::note_enters_statement_expression, 0,
+   SE->getBeginLoc()));

shafik wrote:
> I guess we don't have a variable that stands or no-diagnostic.
nope, we use 0 all over the place in that file 



Comment at: clang/lib/Sema/SemaExpr.cpp:16468
   PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+  setFunctionHasBranchProtectedScope();
 }

shafik wrote:
> I see why we need this but I am not sure how someone would know that need to 
> do this in addition to the change in `BuildScopeInformation(...)`
I added a comment.
I may have spent some time trying to figure out that i needed that line :)



Comment at: clang/test/Sema/scope-check.c:251
+  {
+(void)sizeof (int){({ goto O; 1; })}; // ok (not evaluated)
+O: ;

shafik wrote:
> I am sorry for this example:
> 
> ```
> int main() {
>sizeof(({goto label;}), 0);
>return 3;
>   ({label:1;});  
> }
> ```
> 
> see godbolt: https://godbolt.org/z/aeb6TbsoG
> 
> Note gcc's behavior Vs clangs.
I added it. It's gnarly :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154696

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


[PATCH] D154696: [Clang] Diagnose jumps into statement expressions

2023-07-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 538252.
cor3ntin marked an inline comment as done.
cor3ntin added a comment.

Fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154696

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/test/Sema/asm-goto.cpp
  clang/test/Sema/scope-check.c
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaObjC/scope-check.m

Index: clang/test/SemaObjC/scope-check.m
===
--- clang/test/SemaObjC/scope-check.m
+++ clang/test/SemaObjC/scope-check.m
@@ -36,21 +36,20 @@
   } @finally {
 goto L7; // expected-error{{cannot jump}}
   }
-  
+
   goto L8;  // expected-error{{cannot jump}}
-  @try { 
+  @try {
   } @catch (A *c) {
   } @catch (B *c) {
   } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
   L8: ;
   }
-  
+
   // rdar://6810106
   id X;
   goto L9;// expected-error{{cannot jump}}
-  goto L10;   // ok
-  @synchronized// expected-note {{jump bypasses initialization of @synchronized block}}
-  ( ({ L10: ; X; })) {
+  @synchronized (X)  // expected-note {{jump bypasses initialization of @synchronized block}}
+  {
   L9:
 ;
   }
Index: clang/test/SemaCXX/constant-expression-cxx14.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx14.cpp
+++ clang/test/SemaCXX/constant-expression-cxx14.cpp
@@ -831,8 +831,9 @@
 case 0:
   return 0;
 
-  ({
-case 1: // expected-note {{not supported}}
+  ({  // expected-note {{jump enters a statement expression}}
+case 1:// expected-error {{cannot jump from switch statement to this case label}} \
+   // expected-note  {{not supported}}
   return 1;
   });
 }
Index: clang/test/Sema/scope-check.c
===
--- clang/test/Sema/scope-check.c
+++ clang/test/Sema/scope-check.c
@@ -65,7 +65,8 @@
 
   // Statement expressions.
   goto L3;   // expected-error {{cannot jump from this goto statement to its label}}
-  int Y = ({  int a[x];   // expected-note {{jump bypasses initialization of variable length array}}  
+  int Y = ({  int a[x];   // expected-note {{jump bypasses initialization of variable length array}} \
+  // expected-note {{jump enters a statement expression}}
L3: 4; });
   
   goto L4; // expected-error {{cannot jump from this goto statement to its label}}
@@ -107,25 +108,25 @@
4; })];
   L10:; // bad
   }
-  
+
   {
 // FIXME: Crashes goto checker.
 //goto L11;// ok
 //int A[({   L11: 4; })];
   }
-  
+
   {
 goto L12;
-
+
 int y = 4;   // fixme-warn: skips initializer.
   L12:
 ;
   }
-  
+
   // Statement expressions 2.
   goto L1; // expected-error {{cannot jump from this goto statement to its label}}
-  return x == ({
- int a[x];   // expected-note {{jump bypasses initialization of variable length array}}  
+  return x == ({ // expected-note {{jump enters a statement expression}}
+ int a[x];   // expected-note {{jump bypasses initialization of variable length array}}
L1:
  42; });
 }
@@ -232,3 +233,27 @@
 
 // rdar://9024687
 int test16(int [sizeof &]); // expected-error {{use of address-of-label extension outside of a function body}}
+
+void GH63682() {
+  {
+goto L; // expected-error {{cannot jump from this goto statement to its label}}
+(void)sizeof (int){({ L:; 1; })}; // expected-note {{jump enters a statement expression}}
+  }
+  {
+goto M; // expected-error {{cannot jump from this goto statement to its label}}
+(void)({ M:; 1; }); // expected-note {{jump enters a statement expression}}
+  }
+  {
+(void)({ goto N; 1; });  // ok
+N: ;
+  }
+  {
+(void)sizeof (int){({ goto O; 1; })}; // ok (not evaluated)
+O: ;
+  }
+  {
+(void)sizeof(({goto P;}), 0); // expected-error {{cannot jump from this goto statement to its label}}
+return;
+(void)({P:1;});  // expected-note {{jump enters a statement expression}}
+  }
+}
Index: clang/test/Sema/asm-goto.cpp
===
--- clang/test/Sema/asm-goto.cpp
+++ clang/test/Sema/asm-goto.cpp
@@ -50,9 +50,10 @@
   // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
   // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
   asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
-  // expected-note@+2 {{jump bypasses initialization of variable length array}}
-  // expected-note@+1 

[PATCH] D154696: [Clang] Diagnose jumps into statement expressions

2023-07-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 538250.
cor3ntin marked an inline comment as done.
cor3ntin added a comment.

Missed a comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154696

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/test/Sema/asm-goto.cpp
  clang/test/Sema/scope-check.c
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaObjC/scope-check.m

Index: clang/test/SemaObjC/scope-check.m
===
--- clang/test/SemaObjC/scope-check.m
+++ clang/test/SemaObjC/scope-check.m
@@ -36,21 +36,20 @@
   } @finally {
 goto L7; // expected-error{{cannot jump}}
   }
-  
+
   goto L8;  // expected-error{{cannot jump}}
-  @try { 
+  @try {
   } @catch (A *c) {
   } @catch (B *c) {
   } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
   L8: ;
   }
-  
+
   // rdar://6810106
   id X;
   goto L9;// expected-error{{cannot jump}}
-  goto L10;   // ok
-  @synchronized// expected-note {{jump bypasses initialization of @synchronized block}}
-  ( ({ L10: ; X; })) {
+  @synchronized (X)  // expected-note {{jump bypasses initialization of @synchronized block}}
+  {
   L9:
 ;
   }
Index: clang/test/SemaCXX/constant-expression-cxx14.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx14.cpp
+++ clang/test/SemaCXX/constant-expression-cxx14.cpp
@@ -831,8 +831,9 @@
 case 0:
   return 0;
 
-  ({
-case 1: // expected-note {{not supported}}
+  ({  // expected-note {{jump enters a statement expression}}
+case 1:// expected-error {{cannot jump from switch statement to this case label}} \
+   // expected-note  {{not supported}}
   return 1;
   });
 }
Index: clang/test/Sema/scope-check.c
===
--- clang/test/Sema/scope-check.c
+++ clang/test/Sema/scope-check.c
@@ -65,7 +65,8 @@
 
   // Statement expressions.
   goto L3;   // expected-error {{cannot jump from this goto statement to its label}}
-  int Y = ({  int a[x];   // expected-note {{jump bypasses initialization of variable length array}}  
+  int Y = ({  int a[x];   // expected-note {{jump bypasses initialization of variable length array}} \
+  // expected-note {{jump enters a statement expression}}
L3: 4; });
   
   goto L4; // expected-error {{cannot jump from this goto statement to its label}}
@@ -107,25 +108,25 @@
4; })];
   L10:; // bad
   }
-  
+
   {
 // FIXME: Crashes goto checker.
 //goto L11;// ok
 //int A[({   L11: 4; })];
   }
-  
+
   {
 goto L12;
-
+
 int y = 4;   // fixme-warn: skips initializer.
   L12:
 ;
   }
-  
+
   // Statement expressions 2.
   goto L1; // expected-error {{cannot jump from this goto statement to its label}}
-  return x == ({
- int a[x];   // expected-note {{jump bypasses initialization of variable length array}}  
+  return x == ({ // expected-note {{jump enters a statement expression}}
+ int a[x];   // expected-note {{jump bypasses initialization of variable length array}}
L1:
  42; });
 }
@@ -232,3 +233,27 @@
 
 // rdar://9024687
 int test16(int [sizeof &]); // expected-error {{use of address-of-label extension outside of a function body}}
+
+void GH63682() {
+  {
+goto L; // expected-error {{cannot jump from this goto statement to its label}}
+(void)sizeof (int){({ L:; 1; })}; // expected-note {{jump enters a statement expression}}
+  }
+  {
+goto M; // expected-error {{cannot jump from this goto statement to its label}}
+(void)({ M:; 1; }); // expected-note {{jump enters a statement expression}}
+  }
+  {
+(void)({ goto N; 1; });  // ok
+N: ;
+  }
+  {
+(void)sizeof (int){({ goto O; 1; })}; // ok (not evaluated)
+O: ;
+  }
+  {
+(void)sizeof(({goto P;}), 0); // expected-error {{cannot jump from this goto statement to its label}}
+return 3;
+(void)({P:1;});  // expected-note {{jump enters a statement expression}}
+  }
+}
Index: clang/test/Sema/asm-goto.cpp
===
--- clang/test/Sema/asm-goto.cpp
+++ clang/test/Sema/asm-goto.cpp
@@ -50,9 +50,10 @@
   // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
   // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
   asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
-  // expected-note@+2 {{jump bypasses initialization of variable length array}}
-  // expected-note@+1 

[PATCH] D154696: [Clang] Diagnose jumps into statement expressions

2023-07-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 538249.
cor3ntin added a comment.

Address Shafik's feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154696

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
  clang/test/Sema/asm-goto.cpp
  clang/test/Sema/scope-check.c
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaObjC/scope-check.m

Index: clang/test/SemaObjC/scope-check.m
===
--- clang/test/SemaObjC/scope-check.m
+++ clang/test/SemaObjC/scope-check.m
@@ -36,21 +36,20 @@
   } @finally {
 goto L7; // expected-error{{cannot jump}}
   }
-  
+
   goto L8;  // expected-error{{cannot jump}}
-  @try { 
+  @try {
   } @catch (A *c) {
   } @catch (B *c) {
   } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
   L8: ;
   }
-  
+
   // rdar://6810106
   id X;
   goto L9;// expected-error{{cannot jump}}
-  goto L10;   // ok
-  @synchronized// expected-note {{jump bypasses initialization of @synchronized block}}
-  ( ({ L10: ; X; })) {
+  @synchronized (X)  // expected-note {{jump bypasses initialization of @synchronized block}}
+  {
   L9:
 ;
   }
Index: clang/test/SemaCXX/constant-expression-cxx14.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx14.cpp
+++ clang/test/SemaCXX/constant-expression-cxx14.cpp
@@ -831,8 +831,9 @@
 case 0:
   return 0;
 
-  ({
-case 1: // expected-note {{not supported}}
+  ({  // expected-note {{jump enters a statement expression}}
+case 1:// expected-error {{cannot jump from switch statement to this case label}} \
+   // expected-note  {{not supported}}
   return 1;
   });
 }
Index: clang/test/Sema/scope-check.c
===
--- clang/test/Sema/scope-check.c
+++ clang/test/Sema/scope-check.c
@@ -65,7 +65,8 @@
 
   // Statement expressions.
   goto L3;   // expected-error {{cannot jump from this goto statement to its label}}
-  int Y = ({  int a[x];   // expected-note {{jump bypasses initialization of variable length array}}  
+  int Y = ({  int a[x];   // expected-note {{jump bypasses initialization of variable length array}} \
+  // expected-note {{jump enters a statement expression}}
L3: 4; });
   
   goto L4; // expected-error {{cannot jump from this goto statement to its label}}
@@ -107,25 +108,25 @@
4; })];
   L10:; // bad
   }
-  
+
   {
 // FIXME: Crashes goto checker.
 //goto L11;// ok
 //int A[({   L11: 4; })];
   }
-  
+
   {
 goto L12;
-
+
 int y = 4;   // fixme-warn: skips initializer.
   L12:
 ;
   }
-  
+
   // Statement expressions 2.
   goto L1; // expected-error {{cannot jump from this goto statement to its label}}
-  return x == ({
- int a[x];   // expected-note {{jump bypasses initialization of variable length array}}  
+  return x == ({ // expected-note {{jump enters a statement expression}}
+ int a[x];   // expected-note {{jump bypasses initialization of variable length array}}
L1:
  42; });
 }
@@ -232,3 +233,27 @@
 
 // rdar://9024687
 int test16(int [sizeof &]); // expected-error {{use of address-of-label extension outside of a function body}}
+
+void GH63682() {
+  {
+goto L; // expected-error {{cannot jump from this goto statement to its label}}
+(void)sizeof (int){({ L:; 1; })}; // expected-note {{jump enters a statement expression}}
+  }
+  {
+goto M; // expected-error {{cannot jump from this goto statement to its label}}
+(void)({ M:; 1; }); // expected-note {{jump enters a statement expression}}
+  }
+  {
+(void)({ goto N; 1; });  // ok
+N: ;
+  }
+  {
+(void)sizeof (int){({ goto O; 1; })}; // ok (not evaluated)
+O: ;
+  }
+  {
+(void)sizeof(({goto P;}), 0); // expected-error {{cannot jump from this goto statement to its label}}
+return 3;
+(void)({P:1;});  // expected-note {{jump enters a statement expression}}
+  }
+}
Index: clang/test/Sema/asm-goto.cpp
===
--- clang/test/Sema/asm-goto.cpp
+++ clang/test/Sema/asm-goto.cpp
@@ -50,9 +50,10 @@
   // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
   // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
   asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
-  // expected-note@+2 {{jump bypasses initialization of variable length array}}
-  // expected-note@+1 {{possible target of asm goto 

[PATCH] D154672: [OPENMP52] Deprecation of 'depend' clause in ordered directive.

2023-07-07 Thread Jennifer Yu 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 rG852fe30b687e: [OPENMP52] Deprecation of depend 
clause in ordered directive. (authored by jyu2).

Changed prior to commit:
  https://reviews.llvm.org/D154672?vs=538162=538240#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154672

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/ordered_doacross_codegen.c
  clang/test/OpenMP/ordered_messages.cpp


Index: clang/test/OpenMP/ordered_messages.cpp
===
--- clang/test/OpenMP/ordered_messages.cpp
+++ clang/test/OpenMP/ordered_messages.cpp
@@ -402,6 +402,7 @@
   for (int i = 0; i < 10; ++i) { // expected-error {{expected 2 for loops 
after '#pragma omp for', but found only 1}}
 #if _OPENMP >= 202111
 #pragma omp ordered doacross(sink : i)
+#pragma omp ordered depend(source) // expected-warning {{'depend' clause for 
'ordered' is deprecated; use 'doacross' instead}}
 int j;
 #pragma omp ordered doacross(sink : i, j) // omp52-error {{expected loop 
iteration variable}}
 #else
Index: clang/test/OpenMP/ordered_doacross_codegen.c
===
--- clang/test/OpenMP/ordered_doacross_codegen.c
+++ clang/test/OpenMP/ordered_doacross_codegen.c
@@ -2,21 +2,21 @@
 // RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL
 
-// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown -emit-llvm 
%s -o - -fopenmp-version=52 | FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown -emit-llvm 
%s -o - -fopenmp-version=52 -DOMP52 | FileCheck %s 
--check-prefixes=CHECK,CHECK-NORMAL
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-IRBUILDER
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -fopenmp-version=52 -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-IRBUILDER
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -fopenmp-version=52 -DOMP52 -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,CHECK-IRBUILDER
 
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fopenmp-enable-irbuilder 
-triple x86_64-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fopenmp-enable-irbuilder 
-triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -DOMP52 
-fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -DOMP52 
-fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -DOMP52 -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -emit-pch -o 
%t %s
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -triple 
x86_64-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -triple 
x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -DOMP52 -triple 
x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -DOMP52 -triple 
x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 
@@ -59,7 +59,7 @@
 // CHECK-NORMAL-NEXT: call void 

[clang] 852fe30 - [OPENMP52] Deprecation of 'depend' clause in ordered directive.

2023-07-07 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2023-07-07T13:07:17-07:00
New Revision: 852fe30b687e1df9f67007944a90c748ea77f587

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

LOG: [OPENMP52] Deprecation of 'depend' clause in ordered directive.

BTW, I need change test ordered_doacross_codegen.c since I can not use
macro _OPENMP >= 202111 due to use of -fopenmp-simd.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseOpenMP.cpp
clang/test/OpenMP/ordered_doacross_codegen.c
clang/test/OpenMP/ordered_messages.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 40e1a381eb77f6..4b1dcc89e7cae8 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1529,6 +1529,8 @@ def err_omp_requires_out_inout_depend_type : Error<
 def warn_omp_more_one_omp_all_memory : Warning<
   "reserved locator 'omp_all_memory' cannot be specified more than once">,
   InGroup;
+def warn_omp_depend_in_ordered_deprecated : Warning<"'depend' clause for"
+  " 'ordered' is deprecated; use 'doacross' instead">, InGroup;
 
 // Pragma loop support.
 def err_pragma_loop_missing_argument : Error<

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index fc7f0070ff06a3..96d2e2cede6289 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3367,6 +3367,9 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind 
DKind,
   case OMPC_exclusive:
   case OMPC_affinity:
   case OMPC_doacross:
+if (getLangOpts().OpenMP >= 52 && DKind == OMPD_ordered &&
+CKind == OMPC_depend)
+  Diag(Tok, diag::warn_omp_depend_in_ordered_deprecated);
 Clause = ParseOpenMPVarListClause(DKind, CKind, WrongDirective);
 break;
   case OMPC_sizes:

diff  --git a/clang/test/OpenMP/ordered_doacross_codegen.c 
b/clang/test/OpenMP/ordered_doacross_codegen.c
index 48e075346ca11a..1a22c13f287622 100644
--- a/clang/test/OpenMP/ordered_doacross_codegen.c
+++ b/clang/test/OpenMP/ordered_doacross_codegen.c
@@ -2,21 +2,21 @@
 // RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL
 
-// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown -emit-llvm 
%s -o - -fopenmp-version=52 | FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown -emit-llvm 
%s -o - -fopenmp-version=52 -DOMP52 | FileCheck %s 
--check-prefixes=CHECK,CHECK-NORMAL
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-IRBUILDER
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -fopenmp-version=52 -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-IRBUILDER
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -fopenmp-version=52 -DOMP52 -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,CHECK-IRBUILDER
 
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fopenmp-enable-irbuilder 
-triple x86_64-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fopenmp-enable-irbuilder 
-triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -DOMP52 
-fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -DOMP52 
-fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -DOMP52 -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
 // RUN: 

[PATCH] D154647: [RISCV] Re-define sha256, Zksed, and Zksh intrinsics to use i32 types.

2023-07-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 538239.
craig.topper added a comment.

Rebase and add the missing autoupgrade tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154647

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksed.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
  clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVInstrInfoZk.td
  llvm/test/CodeGen/RISCV/rv32zknh-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv32zksed-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv32zksh-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zknh-intrinsic-autoupgrade.ll
  llvm/test/CodeGen/RISCV/rv64zknh-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zksed-intrinsic-autoupgrade2.ll
  llvm/test/CodeGen/RISCV/rv64zksed-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zksh-intrinsic-autoupgrade.ll
  llvm/test/CodeGen/RISCV/rv64zksh-intrinsic.ll
  llvm/test/CodeGen/RISCV/sextw-removal.ll

Index: llvm/test/CodeGen/RISCV/sextw-removal.ll
===
--- llvm/test/CodeGen/RISCV/sextw-removal.ll
+++ llvm/test/CodeGen/RISCV/sextw-removal.ll
@@ -1319,13 +1319,11 @@
 ; NOREMOVAL-NEXT:addi sp, sp, 32
 ; NOREMOVAL-NEXT:ret
 bb:
-  %sext = sext i32 %arg1 to i64
-  %i = call i64 @llvm.riscv.sha256sig0.i64(i64 %sext)
-  %trunc = trunc i64 %i to i32
+  %i = call i32 @llvm.riscv.sha256sig0(i32 %arg1)
   br label %bb2
 
 bb2:  ; preds = %bb2, %bb
-  %i3 = phi i32 [ %trunc, %bb ], [ %i5, %bb2 ]
+  %i3 = phi i32 [ %i, %bb ], [ %i5, %bb2 ]
   %i4 = tail call signext i32 @bar(i32 signext %i3)
   %i5 = shl i32 %i3, %arg1
   %i6 = icmp eq i32 %i4, 0
@@ -1334,7 +1332,7 @@
 bb7:  ; preds = %bb2
   ret void
 }
-declare i64 @llvm.riscv.sha256sig0.i64(i64)
+declare i32 @llvm.riscv.sha256sig0(i32)
 
 ; The type promotion of %7 forms a sext_inreg, but %7 and %6 are combined to
 ; form a sh2add. This leaves behind a sext.w that isn't needed.
Index: llvm/test/CodeGen/RISCV/rv64zksh-intrinsic.ll
===
--- llvm/test/CodeGen/RISCV/rv64zksh-intrinsic.ll
+++ llvm/test/CodeGen/RISCV/rv64zksh-intrinsic.ll
@@ -2,24 +2,24 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+zksh -verify-machineinstrs < %s \
 ; RUN:   | FileCheck %s -check-prefix=RV64ZKSH
 
-declare i64 @llvm.riscv.sm3p0.i64(i64);
+declare i32 @llvm.riscv.sm3p0(i32);
 
-define i64 @sm3p0_i64(i64 %a) nounwind {
-; RV64ZKSH-LABEL: sm3p0_i64:
+define signext i32 @sm3p0_i32(i32 signext %a) nounwind {
+; RV64ZKSH-LABEL: sm3p0_i32:
 ; RV64ZKSH:   # %bb.0:
 ; RV64ZKSH-NEXT:sm3p0 a0, a0
 ; RV64ZKSH-NEXT:ret
-  %val = call i64 @llvm.riscv.sm3p0.i64(i64 %a)
-  ret i64 %val
+  %val = call i32 @llvm.riscv.sm3p0(i32 signext %a)
+  ret i32 %val
 }
 
-declare i64 @llvm.riscv.sm3p1.i64(i64);
+declare i32 @llvm.riscv.sm3p1(i32);
 
-define i64 @sm3p1_i64(i64 %a) nounwind {
-; RV64ZKSH-LABEL: sm3p1_i64:
+define signext i32 @sm3p1_i32(i32 signext %a) nounwind {
+; RV64ZKSH-LABEL: sm3p1_i32:
 ; RV64ZKSH:   # %bb.0:
 ; RV64ZKSH-NEXT:sm3p1 a0, a0
 ; RV64ZKSH-NEXT:ret
-  %val = call i64 @llvm.riscv.sm3p1.i64(i64 %a)
-  ret i64 %val
+  %val = call i32 @llvm.riscv.sm3p1(i32 signext %a)
+  ret i32 %val
 }
Index: llvm/test/CodeGen/RISCV/rv64zksed-intrinsic.ll
===
--- llvm/test/CodeGen/RISCV/rv64zksed-intrinsic.ll
+++ llvm/test/CodeGen/RISCV/rv64zksed-intrinsic.ll
@@ -2,24 +2,24 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+zksed -verify-machineinstrs < %s \
 ; RUN:   | FileCheck %s -check-prefix=RV64ZKSED
 
-declare i64 @llvm.riscv.sm4ks.i64(i64, i64, i32);
+declare i32 @llvm.riscv.sm4ks(i32, i32, i32);
 
-define i64 @sm4ks_i64(i64 %a, i64 %b) nounwind {
-; RV64ZKSED-LABEL: sm4ks_i64:
+define signext i32 @sm4ks_i32(i32 signext %a, i32 signext %b) nounwind {
+; RV64ZKSED-LABEL: sm4ks_i32:
 ; RV64ZKSED:   # %bb.0:
-; RV64ZKSED-NEXT:sm4ks a0, a0, a1, 0
+; RV64ZKSED-NEXT:sm4ks a0, a0, a1, 2
 ; RV64ZKSED-NEXT:ret
-  %val = call i64 @llvm.riscv.sm4ks.i64(i64 %a, i64 %b, i32 0)
-  ret i64 %val
+  %val = call i32 @llvm.riscv.sm4ks(i32 %a, i32 %b, i32 2)
+  ret i32 %val
 }
 
-declare i64 @llvm.riscv.sm4ed.i64(i64, i64, i32);
+declare i32 @llvm.riscv.sm4ed(i32, i32, i32);
 
-define i64 @sm4ed_i64(i64 %a, i64 %b) nounwind {
-; RV64ZKSED-LABEL: sm4ed_i64:
+define signext i32 @sm4ed_i32(i32 signext %a, i32 signext 

[PATCH] D154543: [Support] Move StringExtras.h include from Error.h to Error.cpp

2023-07-07 Thread Elliot Goodrich via Phabricator via cfe-commits
IncludeGuardian updated this revision to Diff 538238.
IncludeGuardian added a comment.

Rebasing on `main`


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

https://reviews.llvm.org/D154543

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  llvm/include/llvm/Support/Error.h
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/Support/Error.cpp
  llvm/lib/Transforms/IPO/Internalize.cpp
  llvm/lib/Transforms/Scalar/MergeICmps.cpp
  llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
  llvm/lib/Transforms/Utils/ModuleUtils.cpp
  llvm/tools/llvm-objdump/XCOFFDump.cpp
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -12,99 +12,100 @@

 #include "llvm/Support/Compression.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/Error.h"
 #include "gtest/gtest.h"

 using namespace llvm;
 using namespace llvm::compression;

 namespace {

 #if LLVM_ENABLE_ZLIB
 static void testZlibCompression(StringRef Input, int Level) {
   SmallVector Compressed;
   SmallVector Uncompressed;
   zlib::compress(arrayRefFromStringRef(Input), Compressed, Level);

   // Check that uncompressed buffer is the same as original.
   Error E = zlib::decompress(Compressed, Uncompressed, Input.size());
   EXPECT_FALSE(std::move(E));
   EXPECT_EQ(Input, toStringRef(Uncompressed));

   // decompress with Z dispatches to zlib::decompress.
   E = compression::decompress(DebugCompressionType::Zlib, Compressed,
   Uncompressed, Input.size());
   EXPECT_FALSE(std::move(E));
   EXPECT_EQ(Input, toStringRef(Uncompressed));

   if (Input.size() > 0) {
 // Decompression fails if expected length is too short.
 E = zlib::decompress(Compressed, Uncompressed, Input.size() - 1);
 EXPECT_EQ("zlib error: Z_BUF_ERROR", llvm::toString(std::move(E)));
   }
 }

 TEST(CompressionTest, Zlib) {
   testZlibCompression("", zlib::DefaultCompression);

   testZlibCompression("hello, world!", zlib::NoCompression);
   testZlibCompression("hello, world!", zlib::BestSizeCompression);
   testZlibCompression("hello, world!", zlib::BestSpeedCompression);
   testZlibCompression("hello, world!", zlib::DefaultCompression);

   const size_t kSize = 1024;
   char BinaryData[kSize];
   for (size_t i = 0; i < kSize; ++i)
 BinaryData[i] = i & 255;
   StringRef BinaryDataStr(BinaryData, kSize);

   testZlibCompression(BinaryDataStr, zlib::NoCompression);
   testZlibCompression(BinaryDataStr, zlib::BestSizeCompression);
   testZlibCompression(BinaryDataStr, zlib::BestSpeedCompression);
   testZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 #endif

 #if LLVM_ENABLE_ZSTD
 static void testZstdCompression(StringRef Input, int Level) {
   SmallVector Compressed;
   SmallVector Uncompressed;
   zstd::compress(arrayRefFromStringRef(Input), Compressed, Level);

   // Check that uncompressed buffer is the same as original.
   Error E = zstd::decompress(Compressed, Uncompressed, Input.size());
   EXPECT_FALSE(std::move(E));
   EXPECT_EQ(Input, toStringRef(Uncompressed));

   // decompress with Zstd dispatches to zstd::decompress.
   E = compression::decompress(DebugCompressionType::Zstd, Compressed,
   Uncompressed, Input.size());
   EXPECT_FALSE(std::move(E));
   EXPECT_EQ(Input, toStringRef(Uncompressed));

   if (Input.size() > 0) {
 // Decompression fails if expected length is too short.
 E = zstd::decompress(Compressed, Uncompressed, Input.size() - 1);
 EXPECT_EQ("Destination buffer is too small", llvm::toString(std::move(E)));
   }
 }

 TEST(CompressionTest, Zstd) {
   testZstdCompression("", zstd::DefaultCompression);

   testZstdCompression("hello, world!", zstd::NoCompression);
   testZstdCompression("hello, world!", zstd::BestSizeCompression);
   testZstdCompression("hello, world!", zstd::BestSpeedCompression);
   testZstdCompression("hello, world!", zstd::DefaultCompression);

   const size_t kSize = 1024;
   char BinaryData[kSize];
   for (size_t i = 0; i < kSize; ++i)
 BinaryData[i] = i & 255;
   StringRef BinaryDataStr(BinaryData, kSize);

   testZstdCompression(BinaryDataStr, zstd::NoCompression);
   testZstdCompression(BinaryDataStr, zstd::BestSizeCompression);
   testZstdCompression(BinaryDataStr, zstd::BestSpeedCompression);
Index: llvm/tools/llvm-objdump/XCOFFDump.cpp
===
--- llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -14,6 +14,7 @@
 #include "XCOFFDump.h"

 #include "llvm-objdump.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Demangle/Demangle.h"
 #include "llvm/MC/MCInstPrinter.h"
 #include 

[PATCH] D154543: [Support] Move StringExtras.h include from Error.h to Error.cpp

2023-07-07 Thread Elliot Goodrich via Phabricator via cfe-commits
IncludeGuardian added a comment.

@MaskRay Thanks. I have updated the title to use `[Support]` and I will land 
the additional includes separately to the removal.  This was very good advice 
last attempt as it I did have to revert the change.


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

https://reviews.llvm.org/D154543

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


[PATCH] D154123: [HIP] Start document HIP support by clang

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



Comment at: clang/docs/HIPSupport.rst:49
+
+You can also use ``--offload-arch=native`` to let ``amdgpu-arch`` 
automatically detect the GPU architecture on your system:
+

s/architecture/architectures



Comment at: clang/docs/HIPSupport.rst:99
+
+Note: The compiler options override environment variables. Specifying HIP 
runtime and device library paths individually will override the ROCm path.
+

We should really not have the environment variables I wouldn't go out of the 
way to advertise them, just mark as deprecated


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

https://reviews.llvm.org/D154123

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


[PATCH] D153835: [Sema] Clone VisibilityAttr for functions in template instantiations

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

I agree that the change to test51 is the right result, yes.  The explicit 
visibility attribute on the template declaration should take precedence over 
the visibility of the types in the template parameter list, and then the 
explicit visibility attribute on the variables should take precedence over the 
visibility of the variable types, and then the instantiation should be a 
specialization of a default-visibility template with default-visibility 
arguments.  But I think that logic ought to be fixed in `getLVFor...`, not by 
changing the basic propagation of attributes.

> I actually think that the patch makes VisibilityAttr behave in a more normal 
> way as the majority of attributes are cloned by instantiateTemplateAttribute 
> in the tablegen-generated 
> tools/clang/include/clang/Sema/AttrTemplateInstantiate.inc.

You're not really just cloning it, because making the cloned attribute implicit 
(i.e. giving it the effect of a visibility pragma instead of an attribute) is a 
huge difference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153835

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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

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



Comment at: clang/include/clang/Format/Format.h:380
+}
+bool operator!=(const ShortCaseStatementsAlignmentStyle ) const {
+  return !(*this == R);

I'd drop that. We don't have it for any other struct.

And with C++20 you don't need this anymore (although I don't know when llvm 
will switch to c++20).



Comment at: clang/lib/Format/WhitespaceManager.cpp:108
   alignConsecutiveAssignments();
+  alignConsecutiveShortCaseStatements();
   alignChainedConditionals();

galenelias wrote:
> HazardyKnusperkeks wrote:
> > Is this the right position?
> > Could you add a test with aligning assignments and case statements?
> > 
> > ```
> > case XX: xx = 2; break;
> > case X: x = 1; break;
> > ```
> > It should end up as
> > ```
> > case XX: xx = 2; break;
> > case X:  x  = 1; break;
> > ``` 
> Great point, I hadn't actually really fully considered the ordering 
> dependency here.  I agree that aligning short case statements before 
> assignments (and probably declarations?) seems more correct.  However, these 
> other alignConsecutive* methods don't actually align across scopes, so won't 
> align declarations/assignments within the body of a case statement.  I 
> verified that these don't align today using AlignConsecutiveAssignments.  I 
> will however move this up to try to make it as logically correct as possible.
Too bad, that would really be nice. :)
But certainly out of scope for this change.



Comment at: clang/unittests/Format/ConfigParseTest.cpp:321
   CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveDeclarations);
+  CHECK_ALIGN_CONSECUTIVE(AlignConsecutiveShortCaseStatements);
 

You now have to write your own checks for the parsing. (It's just copy & paste.)


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

https://reviews.llvm.org/D151761

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


[PATCH] D154706: [RISCV] Add XLEN width integer type: riscv_int.h

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



Comment at: clang/lib/Headers/riscv_int.h:10
+
+#ifndef __RISCV_INT_H
+

Don't you have to `#define __RISCV_INT_H` after this to make this a complete 
include guard?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154706

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


[PATCH] D154503: [Sema] Fix handling of functions that hide classes

2023-07-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaLookup.cpp:542
+N = Decls.size();
+  }
+

john.brawn wrote:
> rjmccall wrote:
> > This is going to fire on every single ordinary lookup that finds multiple 
> > declarations, right?  I haven't fully internalized the issue you're solving 
> > here, but this is a very performance-sensitive path in the compiler; 
> > there's a reason this code is written to very carefully only do extra work 
> > when we've detected in the loop below that we're in a hidden-declarations 
> > situation.  Is there any way we can restore that basic structure?
> Test4 in the added tests is an example of why we can't wait until after the 
> main loop. The `using A::X` in namespace D is eliminated by the UniqueResult 
> check, so the check for a declaration being hidden can only see the using 
> declarations in namespace C. We also can't do it in the loop itself, as then 
> we can't handle Test5: at the time we process the `using A::X` in namespace D 
> it looks like it may cause ambiguity, but it's later hidden by the `using 
> B::X` in the same namespace which we haven't yet processed.
> 
> I have adjusted it though so the nested loop and erasing of decls only 
> happens when we both have things that hide and things that can be hidden. 
> Doing some quick testing of compiling SemaOpenMP.cpp (the largest file in 
> clang), LookupResult::resolveKind is called 75318 times, of which 75283 calls 
> have HideTags=true, of which 56 meet this condition, i.e. 0.07%.
Okay, I can see why you need to not mix tag-hiding with the removal of 
duplicates.  However, I think you can maintain the current structure by 
delaying the actual removal of declarations until after the main loop; have the 
loop build up a set of indices to remove instead.  (Also, you can keep this set 
as a bitset instead of a `std::set`.)

It's a shame that the hiding algorithm has to check every other declaration in 
the lookup in case they're from different scopes.  I guess to avoid that we'd 
have to do the filtering immediately when we collect the declarations from a 
particular DC.


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

https://reviews.llvm.org/D154503

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


[PATCH] D154130: [lit] Avoid os.path.realpath on Windows due to MAX_PATH limitations

2023-07-07 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian added a comment.

In D154130#4481673 , @aaron.ballman 
wrote:

> Adding a few more folks who are interested in lit changes to try to get the 
> review unstuck.
>
> FWIW, I worry about the subtlety of the `>` change because it's not entirely 
> clear to me when I'd need to use `%>t` in a test. I worry code reviewers will 
> miss this sort of thing and we'll only find out there's an issue when the 
> test fails for someone with a problematic path. Is there a rule of thumb we 
> should be following for its use?

Thanks for the extra reviewers!

95% of the `%>t` are around clang modulemap files, because that code resolves 
real paths in C++ by design, so I can't avoid it. In fact I should rename 
`PREFIX_EXPANDED` to `MODULEMAP_PREFIX` and it should be much clearer.

There are three cases where I didn't expect to need the expanded paths: 
`relative_include.m`, `case-insensitive-include-win.c` and 
`module-header-mismatches.m`. There may be a way to change the clang 
implementation to not need expanded paths, but that felt like a different 
investigation.

I'm happy to consider alternative syntaxes to `%>t` too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154130

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


[PATCH] D153835: [Sema] Clone VisibilityAttr for functions in template instantiations

2023-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a subscriber: erichkeane.
MaskRay added a comment.

In D153835#4481462 , @rjmccall wrote:

> We made a decision ten years or so ago to use a slightly different 
> interpretation of the visibility attributes, so differences from GCC are not 
> by themselves unexpected or problematic.

Sure, I think we should assess every corner case and decide whether it makes 
sense to match GCC compatibility.
I started the patch by noticing 
https://github.com/llvm/llvm-project/issues/31462 (D29157 
) to address a specific libc++ problem, not 
that I started to match a random GCC behavior.
I have noticed that libcxx/include/__config:592 says

  // The inline should be removed once PR32114 is resolved
  #  define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline 
_LIBCPP_HIDDEN

(The doc is old stale. This is something I want to improve next.)

> In this case, I'm not sure I agree that it's a bug that an attribute on an 
> explicit class template instantiation overrides attributes on member 
> functions in the template pattern.

OK, I think this is whether our opinions differ. I think that:

- (test51)(consensus bugfix?) the visibility attribute in `template 
void DEFAULT zed()` should affect template void zed<>();
- (test71)(differed opinion) the visibility attribute in `template  
HIDDEN U bar();` should override the visibility attribute in `extern template 
struct DEFAULT foo;`, like GCC does, as the method attribute is more 
specific.

Perhaps #libc  folks and @erichkeane (who 
introduced `MeaningfulToClassTemplateDefinition`) can weigh in.

> Even if we decide to adopt a new rule here, though, I agree with Eli that 
> this seems like a very heavy-handed way of implementing it; basically every 
> line in this patch seems to be impactful in ways that are hard to anticipate.

I actually think that the patch makes VisibilityAttr behave in a more normal 
way as the majority of attributes are cloned by `instantiateTemplateAttribute` 
in the tablegen-generated 
`tools/clang/include/clang/Sema/AttrTemplateInstantiate.inc`. 
However, `MeaningfulToClassTemplateDefinition` attributes are rare and even few 
need to think about precedence for class attributes and method attributes.
This does make VisibilityAttr unusual, but I think the complexity resides 
mainly in the existing code, not the code I added in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153835

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2023-07-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

42d4c85ca83f25f993444fb5bbaa58525f724991 



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

https://reviews.llvm.org/D139629

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


[clang] 42d4c85 - clang: Stop emitting "strictfp"

2023-07-07 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-07-07T15:28:21-04:00
New Revision: 42d4c85ca83f25f993444fb5bbaa58525f724991

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

LOG: clang: Stop emitting "strictfp"

The attribute is a proper enum attribute, strictfp. We were getting
strictfp and "strictfp" set on every function with
-fexperimental-strict-floating-point.

https://reviews.llvm.org/D139629

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/fp-floatcontrol-stack.cpp
clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index b5d26395ebba6a..304646c3dad18c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2416,15 +2416,6 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   }
 }
 
-void CodeGenModule::setLLVMFunctionFEnvAttributes(const FunctionDecl *D,
-  llvm::Function *F) {
-  if (D->hasAttr()) {
-llvm::AttrBuilder FuncAttrs(F->getContext());
-FuncAttrs.addAttribute("strictfp");
-F->addFnAttrs(FuncAttrs);
-  }
-}
-
 void CodeGenModule::SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV) {
   const Decl *D = GD.getDecl();
   if (isa_and_nonnull(D))
@@ -5661,9 +5652,6 @@ void 
CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
 
   maybeSetTrivialComdat(*D, *Fn);
 
-  // Set CodeGen attributes that represent floating point environment.
-  setLLVMFunctionFEnvAttributes(D, Fn);
-
   CodeGenFunction(*this).GenerateCode(GD, Fn, FI);
 
   setNonAliasAttributes(GD, Fn);

diff  --git a/clang/test/CodeGen/fp-floatcontrol-stack.cpp 
b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
index 3de3af0cbad050..7357a42838c2d7 100644
--- a/clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -284,3 +284,6 @@ MyComplex useAdd() {
 // CHECK-FAST: Function Attrs: noinline nounwind{{$$}}
 // CHECK-NOHONOR: Function Attrs: noinline nounwind{{$$}}
 // CHECK-LABEL: define{{.*}} @_GLOBAL__sub_I_fp_floatcontrol_stack
+
+// CHECK-DEBSTRICT: {{[ ]}}strictfp{{[ ]}}
+// CHECK-DEBSTRICT-NOT: "strictfp"

diff  --git a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl 
b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
index cd00d49bbb3779..e7433787c89c88 100644
--- a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
+++ b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
@@ -168,7 +168,7 @@ kernel void device_side_enqueue(global float *a, global 
float *b, int i) {
 // SPIR32: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind 
speculatable willreturn memory(none) }
 // SPIR32: attributes #[[ATTR4]] = { convergent nounwind 
"denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" }
 //.
-// STRICTFP: attributes #[[ATTR0]] = { convergent noinline norecurse nounwind 
optnone strictfp "stack-protector-buffer-size"="8" "strictfp" 
"uniform-work-group-size"="false" }
+// STRICTFP: attributes #[[ATTR0]] = { convergent noinline norecurse nounwind 
optnone strictfp "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="false" }
 // STRICTFP: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nounwind 
willreturn memory(argmem: readwrite) }
 // STRICTFP: attributes #[[ATTR2]] = { convergent noinline nounwind optnone 
strictfp "stack-protector-buffer-size"="8" }
 // STRICTFP: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync 
nounwind willreturn memory(inaccessiblemem: readwrite) }



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


[clang] 75b7901 - clang: Regenerate test checks

2023-07-07 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-07-07T15:28:21-04:00
New Revision: 75b79019013b0891fe5afcd19097ad3c5958d34d

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

LOG: clang: Regenerate test checks

Added: 


Modified: 
clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl 
b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
index 88fafbbc98f43c..cd00d49bbb3779 100644
--- a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
+++ b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
@@ -162,30 +162,30 @@ kernel void device_side_enqueue(global float *a, global 
float *b, int i) {
 // STRICTFP-NEXT:ret void
 //
 //.
-// SPIR32: attributes #0 = { convergent noinline norecurse nounwind optnone 
"denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
-// SPIR32: attributes #1 = { nocallback nofree nounwind willreturn 
memory(argmem: readwrite) }
-// SPIR32: attributes #2 = { convergent noinline nounwind optnone 
"denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" }
-// SPIR32: attributes #3 = { nocallback nofree nosync nounwind speculatable 
willreturn memory(none) }
-// SPIR32: attributes #4 = { convergent nounwind 
"denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" }
+// SPIR32: attributes #[[ATTR0]] = { convergent noinline norecurse nounwind 
optnone "denormal-fp-math-f32"="preserve-sign,preserve-sign" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="true" }
+// SPIR32: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nounwind 
willreturn memory(argmem: readwrite) }
+// SPIR32: attributes #[[ATTR2]] = { convergent noinline nounwind optnone 
"denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" }
+// SPIR32: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind 
speculatable willreturn memory(none) }
+// SPIR32: attributes #[[ATTR4]] = { convergent nounwind 
"denormal-fp-math-f32"="preserve-sign,preserve-sign" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" }
 //.
-// STRICTFP: attributes #0 = { convergent noinline norecurse nounwind optnone 
strictfp "stack-protector-buffer-size"="8" "strictfp" 
"uniform-work-group-size"="false" }
-// STRICTFP: attributes #1 = { nocallback nofree nounwind willreturn 
memory(argmem: readwrite) }
-// STRICTFP: attributes #2 = { convergent noinline nounwind optnone strictfp 
"stack-protector-buffer-size"="8" }
-// STRICTFP: attributes #3 = { nocallback nofree nosync nounwind willreturn 
memory(inaccessiblemem: readwrite) }
-// STRICTFP: attributes #4 = { convergent nounwind 
"stack-protector-buffer-size"="8" }
-// STRICTFP: attributes #5 = { strictfp }
+// STRICTFP: attributes #[[ATTR0]] = { convergent noinline norecurse nounwind 
optnone strictfp "stack-protector-buffer-size"="8" "strictfp" 
"uniform-work-group-size"="false" }
+// STRICTFP: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nounwind 
willreturn memory(argmem: readwrite) }
+// STRICTFP: attributes #[[ATTR2]] = { convergent noinline nounwind optnone 
strictfp "stack-protector-buffer-size"="8" }
+// STRICTFP: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync 
nounwind willreturn memory(inaccessiblemem: readwrite) }
+// STRICTFP: attributes #[[ATTR4]] = { convergent nounwind 
"stack-protector-buffer-size"="8" }
+// STRICTFP: attributes #[[ATTR5]] = { strictfp }
 //.
-// SPIR32: !0 = !{i32 1, !"wchar_size", i32 4}
-// SPIR32: !1 = !{i32 2, i32 0}
-// SPIR32: !2 = !{i32 1, i32 1, i32 0}
-// SPIR32: !3 = !{!"none", !"none", !"none"}
-// SPIR32: !4 = !{!"float*", !"float*", !"int"}
-// SPIR32: !5 = !{!"", !"", !""}
+// SPIR32: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
+// SPIR32: [[META1:![0-9]+]] = !{i32 2, i32 0}
+// SPIR32: [[META2:![0-9]+]] = !{i32 1, i32 1, i32 0}
+// SPIR32: [[META3:![0-9]+]] = !{!"none", !"none", !"none"}
+// SPIR32: [[META4:![0-9]+]] = !{!"float*", !"float*", !"int"}
+// SPIR32: [[META5:![0-9]+]] = !{!"", !"", !""}
 //.
-// STRICTFP: !0 = !{i32 1, !"wchar_size", i32 4}
-// STRICTFP: !1 = !{i32 2, i32 0}
-// STRICTFP: !2 = !{i32 1, i32 1, i32 0}
-// STRICTFP: !3 = !{!"none", !"none", !"none"}
-// STRICTFP: !4 = !{!"float*", !"float*", !"int"}
-// STRICTFP: !5 = !{!"", !"", !""}
+// STRICTFP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
+// STRICTFP: [[META1:![0-9]+]] = !{i32 2, i32 0}
+// STRICTFP: [[META2:![0-9]+]] = !{i32 1, i32 1, i32 0}
+// STRICTFP: 

[PATCH] D139629: clang: Stop emitting "strictfp"

2023-07-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

self accept after latest comments


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

https://reviews.llvm.org/D139629

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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-07-07 Thread Galen Elias via Phabricator via cfe-commits
galenelias updated this revision to Diff 538228.
galenelias marked an inline comment as done.
galenelias edited the summary of this revision.
galenelias added a comment.

This iteration switches away from using `AlignConsecutiveStyle` and instead 
uses a new `ShortCaseStatementsAlignmentStyle`.


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

https://reviews.llvm.org/D151761

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19244,6 +19244,257 @@
BracedAlign);
 }
 
+TEST_F(FormatTest, AlignConsecutiveShortCaseStatements) {
+  FormatStyle Alignment = getLLVMStyle();
+  Alignment.AllowShortCaseLabelsOnASingleLine = true;
+  Alignment.AlignConsecutiveShortCaseStatements.Enabled = true;
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "default:   return \"default\";\n"
+   "}",
+   Alignment);
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "  return \"warning\";\n"
+   "}",
+   Alignment);
+
+  // Empty case statements push out the alignment, but non-short case labels
+  // don't.
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::critical:\n"
+   "case log::warning:\n"
+   "case log::severe:   return \"severe\";\n"
+   "case log::extra_severe:\n"
+   "  // comment\n"
+   "  return \"extra_severe\";\n"
+   "}",
+   Alignment);
+
+  // Verify comments and empty lines break the alignment.
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "// comment\n"
+   "case log::critical: return \"critical\";\n"
+   "default:return \"default\";\n"
+   "\n"
+   "case log::severe: return \"severe\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "// comment\n"
+   "case log::critical: return \"critical\";\n"
+   "default:return \"default\";\n"
+   "\n"
+   "case log::severe: return \"severe\";\n"
+   "}",
+   Alignment);
+
+  // Empty case statements don't break the alignment, and potentially push it
+  // out.
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "case log::critical:\n"
+   "default:return \"default\";\n"
+   "}",
+   Alignment);
+
+  // Implicit fallthrough cases can be aligned with either a comment or
+  // [[fallthrough]]
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:  // fallthrough\n"
+   "case log::error:return \"error\";\n"
+   "case log::critical: /*fallthrough*/\n"
+   "case log::severe:   return \"severe\";\n"
+   "case log::diag: [[fallthrough]];\n"
+   "default:return \"default\";\n"
+   "}",
+   Alignment);
+
+  // Verify trailing comment that needs a reflow also gets aligned properly.
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: // fallthrough\n"
+   "case log::error:   return \"error\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: //fallthrough\n"
+   "case log::error:   return \"error\";\n"
+   "}",
+   Alignment);
+
+  // Verify adjacent non-short case statements don't change the alignment, and
+  // properly break the set of consecutive statements.
+  verifyFormat("switch (level) {\n"
+   "case log::critical:\n"
+   "  // comment\n"
+   "  return 

[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-07-07 Thread Galen Elias via Phabricator via cfe-commits
galenelias marked an inline comment as done.
galenelias added inline comments.



Comment at: clang/include/clang/Format/Format.h:327
+  /// \version 17
+  AlignConsecutiveStyle AlignConsecutiveShortCaseStatements;
 

HazardyKnusperkeks wrote:
> Since you are not using AlignTokens anymore, I'd say use your own struct. You 
> don't have the not used memberand you don't have to add a new member which is 
> not used by AlignTokens.
Sure. Will post an iteration with this - hopefully I'm getting all the plumbing 
correct.



Comment at: clang/lib/Format/WhitespaceManager.cpp:108
   alignConsecutiveAssignments();
+  alignConsecutiveShortCaseStatements();
   alignChainedConditionals();

HazardyKnusperkeks wrote:
> Is this the right position?
> Could you add a test with aligning assignments and case statements?
> 
> ```
> case XX: xx = 2; break;
> case X: x = 1; break;
> ```
> It should end up as
> ```
> case XX: xx = 2; break;
> case X:  x  = 1; break;
> ``` 
Great point, I hadn't actually really fully considered the ordering dependency 
here.  I agree that aligning short case statements before assignments (and 
probably declarations?) seems more correct.  However, these other 
alignConsecutive* methods don't actually align across scopes, so won't align 
declarations/assignments within the body of a case statement.  I verified that 
these don't align today using AlignConsecutiveAssignments.  I will however move 
this up to try to make it as logically correct as possible.


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

https://reviews.llvm.org/D151761

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


[PATCH] D153738: Add LibClang guide

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

In D153738#4474602 , @manuel5975p 
wrote:

> Incorporate Aaron Ballman's corrections

Hmm, something seems to have gone sideways somewhere because it looks like none 
of the comments were addressed -- did you perhaps re-upload the original patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153738

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


[PATCH] D154130: [lit] Avoid os.path.realpath on Windows due to MAX_PATH limitations

2023-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: jdenny, jhenderson.
aaron.ballman added a comment.

Adding a few more folks who are interested in lit changes to try to get the 
review unstuck.

FWIW, I worry about the subtlety of the `>` change because it's not entirely 
clear to me when I'd need to use `%>t` in a test. I worry code reviewers will 
miss this sort of thing and we'll only find out there's an issue when the test 
fails for someone with a problematic path. Is there a rule of thumb we should 
be following for its use?

In D154130#4480946 , @MrTrillian 
wrote:

> All premerge build failures seem like flukes.
>
> - `x64 windows` failed 1/3 times
> - `x64 debian` failed 2/3 times with a timeout (passes locally)
> - `libcxx` seems to be failing for everyone: 
> https://buildkite.com/llvm-project/libcxx-ci

FWIW, I agree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154130

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


[PATCH] D154696: [Clang] Diagnose jumps into statement expressions

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



Comment at: clang/docs/ReleaseNotes.rst:571
   (`#61758 `_)
+- Correcly diagnose jumps into statement expressions.
+  (`#63682 `_)

Maybe remark this conforms with gcc behavior.



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:489
+Scopes.push_back(GotoScope(ParentScope,
+   diag::note_enters_statement_expression, 0,
+   SE->getBeginLoc()));

I guess we don't have a variable that stands or no-diagnostic.



Comment at: clang/lib/Sema/SemaExpr.cpp:16468
   PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+  setFunctionHasBranchProtectedScope();
 }

I see why we need this but I am not sure how someone would know that need to do 
this in addition to the change in `BuildScopeInformation(...)`



Comment at: clang/test/Sema/scope-check.c:251
+  {
+(void)sizeof (int){({ goto O; 1; })}; // ok (not evaluated)
+O: ;

I am sorry for this example:

```
int main() {
   sizeof(({goto label;}), 0);
   return 3;
  ({label:1;});  
}
```

see godbolt: https://godbolt.org/z/aeb6TbsoG

Note gcc's behavior Vs clangs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154696

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


[PATCH] D148216: [UTC] Add fallback support for specific metadata, and check their defs

2023-07-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert reopened this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

This is broken: https://github.com/llvm/llvm-project/issues/63746


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D148216: [UTC] Add fallback support for specific metadata, and check their defs

2023-07-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert closed this revision.
jdoerfert added a comment.

When you commit things, can you please add the Differential Revision into the 
commit message so it is closed here and we can easily find the review for a 
change.

Committed as 8a3fdf7b908978625e9a7e57fbb443e4e6f98976 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D153920: [clang] Move the clang formatting job to run-buildbot to fix the CI

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

In D153920#4481410 , @philnik wrote:

> @aaron.ballman @erichkeane @cor3ntin (anybody else?) are you fine with moving 
> the clang build kite-pipeline to `clang/utils/ci` and adding a `run-buildbot`?

I think that seems reasonable, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153920

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


[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

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

This is a bit of an odd situation -- the condition variable *is* used (e.g., 
its value is loaded to determine whether to go into the if branch or the else 
branch), so we should not be marking it as unused in 
`Sema::CheckConditionVariable()`. Instead, I think we need to decide what 
constitutes "unused" in this case. Consider:

  struct RAII {
int 
  
RAII(int ) : x(ref) {}
~RAII() { x = 0; }
  
operator bool() const { return true; }
  };
  
  void func() {
int i = 12;
if (RAII name{i}) {
}
  }

I don't think `name` is unused in the same way that `i` is unused in `if (int i 
= 1) {}`. So I think we only want this to apply to scalars and not class types. 
I think the changes should be happening in `Sema::ShouldDiagnoseUnusedDecl()`  
(and you might need to thread the `Scope` object through to that call -- my 
naive thinking is that a variable declaration in a condition scope should be 
diagnosed as unused if it is used but not referenced, but I could be off-base).




Comment at: clang/docs/ReleaseNotes.rst:340
   with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
+- Clang now warns on unused variables declaread and initialized in condition
+  expressions.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152495

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


[PATCH] D154736: [Driver][ARM] Warn about -mabi= for assembler input with -fno-integrated-as

2023-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: michaelplatings, peter.smith, simon_tatham, 
nathanchance, nickdesaulniers.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Similar to D153691 , but for `-x assembler 
-fno-integrated-as`.

Close https://github.com/ClangBuiltLinux/linux/issues/1878


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154736

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/arm-abi.c
  clang/test/Driver/linux-as.c


Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -15,10 +15,11 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
 // CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
 //
-// RUN: %clang -target arm-linux -march=armv7-a -### \
+// RUN: %clang --target=arm-linux -march=armv7-a -mabi=aapcs-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MARCH %s
 // CHECK-ARM-MARCH: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-march=armv7-a"
+// CHECK-ARM-MARCH-NOT: "-mabi=
 //
 // RUN: %clang -target armeb-linux -mlittle-endian -mcpu=cortex-a8 -mfpu=neon 
-march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
Index: clang/test/Driver/arm-abi.c
===
--- clang/test/Driver/arm-abi.c
+++ clang/test/Driver/arm-abi.c
@@ -64,6 +64,8 @@
 
 // RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o 
/dev/null 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
+// RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o 
/dev/null -fno-integrated-as 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 
 /// The combination -x assember & -mabi is not implemented, but for GCC 
compatibility we accept with a warning.
 // CHECK-ASM: warning: argument unused during compilation: '-mabi={{.*}}'
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -849,6 +849,11 @@
 normalizeCPUNamesForAssembler(Args, CmdArgs);
 
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
+// The integrated assembler doesn't implement e_flags setting behavior for
+// -meabi=gnu (gcc -mabi={apcs-gnu,atpcs} passes -meabi=gnu to gas). For
+// compatibility we accept but warn.
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_mabi_EQ))
+  A->ignoreTargetSpecific();
 break;
   }
   case llvm::Triple::aarch64:


Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -15,10 +15,11 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
 // CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
 //
-// RUN: %clang -target arm-linux -march=armv7-a -### \
+// RUN: %clang --target=arm-linux -march=armv7-a -mabi=aapcs-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MARCH %s
 // CHECK-ARM-MARCH: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-march=armv7-a"
+// CHECK-ARM-MARCH-NOT: "-mabi=
 //
 // RUN: %clang -target armeb-linux -mlittle-endian -mcpu=cortex-a8 -mfpu=neon -march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
Index: clang/test/Driver/arm-abi.c
===
--- clang/test/Driver/arm-abi.c
+++ clang/test/Driver/arm-abi.c
@@ -64,6 +64,8 @@
 
 // RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o /dev/null 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
+// RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o /dev/null -fno-integrated-as 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 
 /// The combination -x assember & -mabi is not implemented, but for GCC compatibility we accept with a warning.
 // CHECK-ASM: warning: argument unused during compilation: '-mabi={{.*}}'
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -849,6 +849,11 @@
 normalizeCPUNamesForAssembler(Args, CmdArgs);
 
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
+// The integrated assembler doesn't implement e_flags setting behavior for
+// -meabi=gnu (gcc -mabi={apcs-gnu,atpcs} passes -meabi=gnu to gas). For
+// compatibility we accept but warn.
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_mabi_EQ))
+  A->ignoreTargetSpecific();
 break;
   }
   case llvm::Triple::aarch64:

[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-07-07 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan added inline comments.



Comment at: clang/docs/AMDGPUSupport.rst:47
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the 
feature is enabled and 0 if it is disabled. Allowed feature names are sramecc 
and xnack.
+   * - ``__AMDGCN_CUMODE__``

yaxunl wrote:
> scchan wrote:
> > This set of feature macros is tricky.  A feature macro is defined only when 
> > the corresponding target feature has been explicitly specified during 
> > compilation; otherwise it's undefined.  Users will have to refer to the 
> > target feature table to get the semantic of each state.  For example, for 
> > xnack, undefined=="any", 1 for xnack+, 0 for xnack-.
> > 
> > Is there a reason we don't support features other than sramecc and xnack?
> This macro is designed to support Target ID only, therefore it is only 
> emitted when target ID containing the feature is used.
> 
> The target ID features are stable since they are used to select code objects 
> from fat binaries.
> 
> My understanding is that other features used by amdgpu backend do not have 
> stable feature names, therefore are not suitable to be used as predefined 
> macros for users to condition their code.
The current wording seems to imply that a feature macro is always defined if 
that target feature is supported but that's not the case.  For example, the 
macro __amdgcn_feature_xnack__ is undefined if a user compiles for xnack="any".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154133

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


[PATCH] D153920: [clang] Move the clang formatting job to run-buildbot to fix the CI

2023-07-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne requested changes to this revision.
ldionne added a comment.
This revision now requires changes to proceed.

I really like where this is going, this will create a framework where Clang can 
add more pre-commit CI checks if they desire.




Comment at: clang/utils/ci/run-buildbot:31-34
+--osx-rootsPath to pre-downloaded macOS dylibs. By default, we 
download
+them from Green Dragon. This is only relevant at all when
+running back-deployment testing if one wants to override
+the old dylibs we use to run the tests with different ones.

This should go away.



Comment at: clang/utils/ci/run-buildbot:36-42
+CC  The C compiler to use, this value is used by CMake. This
+variable is optional.
+
+CXX The C++ compiler to use, this value is used by CMake. This
+variable is optional.
+
+CMAKE   The CMake binary to use. This variable is optional.

Let's remove those since they are not enforced.



Comment at: clang/utils/ci/run-buildbot:65-68
+--osx-roots)
+OSX_ROOTS="${2}"
+shift; shift
+;;

This too.



Comment at: clang/utils/ci/run-buildbot:80-101
+# If we can find Ninja/CMake provided by Xcode, use those since we know their
+# version will generally work with the Clang shipped in Xcode (e.g. if Clang
+# knows about -std=c++20, the CMake bundled in Xcode will probably know about
+# that flag too).
+if xcrun --find ninja &>/dev/null; then
+NINJA="$(xcrun --find ninja)"
+elif which ninja &>/dev/null; then

Let's get rid of all this.



Comment at: clang/utils/ci/run-buildbot:104-105
+# Print the version of a few tools to aid diagnostics in some cases
+${CMAKE} --version
+${NINJA} --version
+





Comment at: clang/utils/ci/run-buildbot:107
+
+if [ ! -z "${CXX}" ]; then ${CXX} --version; fi
+

Let's remove this line entirely, CMake prints the version of the compiler in 
use.



Comment at: libcxx/utils/ci/run-buildbot:206
 ;;
+check-format-clang)
+! grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs

This can be removed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153920

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


[PATCH] D154689: [clang] Correct calculation of MemberExpr's dependence

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

LGTM, thank you for the quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154689

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


[PATCH] D153835: [Sema] Clone VisibilityAttr for functions in template instantiations

2023-07-07 Thread John McCall via Phabricator via cfe-commits
rjmccall requested changes to this revision.
rjmccall added a comment.
This revision now requires changes to proceed.

We made a decision ten years or so ago to use a slightly different 
interpretation of the visibility attributes, so differences from GCC are not by 
themselves unexpected or problematic.  In this case, I'm not sure I agree that 
it's a bug that an attribute on an explicit class template instantiation 
overrides attributes on member functions in the template pattern.  Even if we 
decide to adopt a new rule here, though, I agree with Eli that this seems like 
a very heavy-handed way of implementing it; basically every line in this patch 
seems to be impactful in ways that are hard to anticipate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153835

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2023-07-07 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D139629#4481408 , @rjmccall wrote:

> In D139629#4481030 , @zahiraam 
> wrote:
>
>> According to this comment https://reviews.llvm.org/D87528#2342132, it looks 
>> like @rjmccall had proposed the addition of the attribute. @rjmccall Do you 
>> recall why it was added?
>
> My suggestion was that we track the pragma in the Clang AST with an attribute 
> instead of a bit on the Decl.  I have no idea why IR generation is adding 
> both a string attribute and the builtin attribute to the IR function, but if 
> doesn't have any obvious effect, I suggest just removing it.

Thanks for your response. I second removing it then.


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

https://reviews.llvm.org/D139629

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


[PATCH] D153920: [clang] Move the clang formatting job to run-buildbot to fix the CI

2023-07-07 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added subscribers: cor3ntin, erichkeane, aaron.ballman.
philnik added a comment.

@aaron.ballman @erichkeane @cor3ntin (anybody else?) are you fine with moving 
the clang build kite-pipeline to `clang/utils/ci` and adding a `run-buildbot`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153920

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


[PATCH] D139629: clang: Stop emitting "strictfp"

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

In D139629#4481030 , @zahiraam wrote:

> According to this comment https://reviews.llvm.org/D87528#2342132, it looks 
> like @rjmccall had proposed the addition of the attribute. @rjmccall Do you 
> recall why it was added?

My suggestion was that we track the pragma in the Clang AST with an attribute 
instead of a bit on the Decl.  I have no idea why IR generation is adding both 
a string attribute and the builtin attribute to the IR function, but if doesn't 
have any obvious effect, I suggest just removing it.


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

https://reviews.llvm.org/D139629

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-07 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LG


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

https://reviews.llvm.org/D153725

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


[PATCH] D153920: [clang] Move the clang formatting job to run-buildbot to fix the CI

2023-07-07 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 538208.
philnik marked 2 inline comments as done.
philnik added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153920

Files:
  clang/utils/ci/buildkite-pipeline.yml
  clang/utils/ci/run-buildbot
  libcxx/utils/ci/buildkite-pipeline-clang.yml
  libcxx/utils/ci/generate-buildkite-pipeline
  libcxx/utils/ci/run-buildbot

Index: libcxx/utils/ci/run-buildbot
===
--- libcxx/utils/ci/run-buildbot
+++ libcxx/utils/ci/run-buildbot
@@ -203,6 +203,9 @@
 # Check if the diff is empty, fail otherwise.
 ! grep -q '^--- a' ${BUILD_DIR}/clang-format.patch
 ;;
+check-format-clang)
+! grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs
+;;
 check-generated-output)
 # `! foo` doesn't work properly with `set -e`, use `! foo || false` instead.
 # https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not
Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -11,16 +11,4 @@
 # This script generates the appropriate libc++ CI pipeline based on which project(s) were changed.
 #
 
-if git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/"; then
-  LIBCXX_CHANGED=true
-fi
-
-if git diff --name-only HEAD~1 | grep -q -E "^clang/"; then
-  CLANG_CHANGED=true
-fi
-
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat libcxx/utils/ci/buildkite-pipeline-clang.yml
-else
-  cat libcxx/utils/ci/buildkite-pipeline.yml
-fi
+cat libcxx/utils/ci/buildkite-pipeline-clang.yml
Index: clang/utils/ci/run-buildbot
===
--- /dev/null
+++ clang/utils/ci/run-buildbot
@@ -0,0 +1,170 @@
+#!/usr/bin/env bash
+#===--===##
+#
+# 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
+#
+#===--===##
+
+set -ex
+set -o pipefail
+unset LANG
+unset LC_ALL
+unset LC_COLLATE
+
+PROGNAME="$(basename "${0}")"
+
+function usage() {
+cat <
+
+[-h|--help] Display this help and exit.
+
+--llvm-rootPath to the root of the LLVM monorepo. By default, we try
+to figure it out based on the current working directory.
+
+--build-dirThe directory to use for building the library. By default,
+this is '/build/'.
+
+--osx-rootsPath to pre-downloaded macOS dylibs. By default, we download
+them from Green Dragon. This is only relevant at all when
+running back-deployment testing if one wants to override
+the old dylibs we use to run the tests with different ones.
+Environment variables
+CC  The C compiler to use, this value is used by CMake. This
+variable is optional.
+
+CXX The C++ compiler to use, this value is used by CMake. This
+variable is optional.
+
+CMAKE   The CMake binary to use. This variable is optional.
+EOF
+}
+
+if [[ $# == 0 ]]; then
+   usage
+   exit 0
+fi
+
+while [[ $# -gt 0 ]]; do
+case ${1} in
+-h|--help)
+usage
+exit 0
+;;
+--llvm-root)
+MONOREPO_ROOT="${2}"
+shift; shift
+;;
+--build-dir)
+BUILD_DIR="${2}"
+shift; shift
+;;
+--osx-roots)
+OSX_ROOTS="${2}"
+shift; shift
+;;
+*)
+BUILDER="${1}"
+shift
+;;
+esac
+done
+
+MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
+BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
+INSTALL_DIR="${BUILD_DIR}/install"
+
+# If we can find Ninja/CMake provided by Xcode, use those since we know their
+# version will generally work with the Clang shipped in Xcode (e.g. if Clang
+# knows about -std=c++20, the CMake bundled in Xcode will probably know about
+# that flag too).
+if xcrun --find ninja &>/dev/null; then
+NINJA="$(xcrun --find ninja)"
+elif which ninja &>/dev/null; then
+# The current implementation of modules needs the absolute path to the ninja
+# binary.
+# TODO MODULES Is this still needed when CMake has libc++ module support?
+NINJA="$(which ninja)"
+else
+NINJA="ninja"
+fi
+
+if [ -z "${CMAKE}" ]; then
+if xcrun --find cmake 

[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

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



Comment at: clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp:96
+  return 0;
+}

jdoerfert wrote:
> Where is the call to this?
forgot to call this in main. fixed.


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

https://reviews.llvm.org/D153725

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


[PATCH] D154672: [OPENMP52] Deprecation of 'depend' clause in ordered directive.

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



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1532
   InGroup;
+def warn_omp_depend_in_ordered_deprecated : Warning<"denpend clause for 
ordered is deprecated; use doacross instaed">, InGroup;
 

jyu2 wrote:
> aaron.ballman wrote:
> > ABataev wrote:
> > > denpend->depend
> > > instaed->instead
> > Also, wrap to 80 columns and put syntax elements in single quotes. e.g., 
> > 'depend' clause for 'ordered'
> Thanks Alexey and Aaron for the review!!!  Just a question, do you know why 
> git-clang-format does not format .td file now.  It was working before.
> Thanks.
> Jennifer
I'm not certain; it's never worked properly for me in a .td file (but I use a 
plugin in Visual Studio). Either it does no formatting, or it formats very 
oddly because it doesn't understand the syntax.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154672

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

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

revised by comments


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

https://reviews.llvm.org/D153725

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
  clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt

Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -8,6 +8,6 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
+add_clang_tool(amdgpu-arch AMDGPUArch.cpp AMDGPUArchByHSA.cpp AMDGPUArchByHIP.cpp)
 
 target_link_libraries(amdgpu-arch PRIVATE clangBasic)
Index: clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
===
--- /dev/null
+++ clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
@@ -0,0 +1,122 @@
+//===- AMDGPUArchLinux.cpp - list AMDGPU installed --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a tool for detecting name of AMDGPU installed in system
+// using HSA on Linux. This tool is used by AMDGPU OpenMP and HIP driver.
+//
+//===--===//
+
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+
+typedef enum {
+  HSA_STATUS_SUCCESS = 0x0,
+} hsa_status_t;
+
+typedef enum {
+  HSA_DEVICE_TYPE_CPU = 0,
+  HSA_DEVICE_TYPE_GPU = 1,
+} hsa_device_type_t;
+
+typedef enum {
+  HSA_AGENT_INFO_NAME = 0,
+  HSA_AGENT_INFO_DEVICE = 17,
+} hsa_agent_info_t;
+
+typedef struct hsa_agent_s {
+  uint64_t handle;
+} hsa_agent_t;
+
+hsa_status_t (*hsa_init)();
+hsa_status_t (*hsa_shut_down)();
+hsa_status_t (*hsa_agent_get_info)(hsa_agent_t, hsa_agent_info_t, void *);
+hsa_status_t (*hsa_iterate_agents)(hsa_status_t (*)(hsa_agent_t, void *),
+   void *);
+
+constexpr const char *DynamicHSAPath = "libhsa-runtime64.so";
+
+llvm::Error loadHSA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHSAPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s", DynamicHSAPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(hsa_init);
+  DYNAMIC_INIT(hsa_shut_down);
+  DYNAMIC_INIT(hsa_agent_get_info);
+  DYNAMIC_INIT(hsa_iterate_agents);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+
+static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
+  hsa_device_type_t DeviceType;
+  hsa_status_t Status =
+  hsa_agent_get_info(Agent, HSA_AGENT_INFO_DEVICE, );
+
+  // continue only if device type if GPU
+  if (Status != HSA_STATUS_SUCCESS || DeviceType != HSA_DEVICE_TYPE_GPU) {
+return Status;
+  }
+
+  std::vector *GPUs =
+  static_cast *>(Data);
+  char GPUName[64];
+  Status = hsa_agent_get_info(Agent, HSA_AGENT_INFO_NAME, GPUName);
+  if (Status != HSA_STATUS_SUCCESS) {
+return Status;
+  }
+  GPUs->push_back(GPUName);
+  return HSA_STATUS_SUCCESS;
+}
+
+int printGPUsByHSA() {
+  // Attempt to load the HSA runtime.
+  if (llvm::Error Err = loadHSA()) {
+logAllUnhandledErrors(std::move(Err), llvm::errs());
+return 1;
+  }
+
+  hsa_status_t Status = hsa_init();
+  if (Status != HSA_STATUS_SUCCESS) {
+return 1;
+  }
+
+  std::vector GPUs;
+  Status = hsa_iterate_agents(iterateAgentsCallback, );
+  if (Status != HSA_STATUS_SUCCESS) {
+return 1;
+  }
+
+  for (const auto  : GPUs)
+llvm::outs() << GPU << '\n';
+
+  if (GPUs.size() < 1)
+return 1;
+
+  hsa_shut_down();
+  return 0;
+}
Index: clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
===
--- /dev/null
+++ 

[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

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



Comment at: clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp:96
+  return 0;
+}

Where is the call to this?


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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

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



Comment at: clang/tools/amdgpu-arch/AMDGPUArch.cpp:48-52
+  if (!printGPUsByHSA())
+return 0;
+#endif
 
+  return printGPUsByHSA();

jhuber6 wrote:
> Are we missing something here ? They look the same.
sorry my mistake. will fix.


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

https://reviews.llvm.org/D153725

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


[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

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



Comment at: clang/docs/AMDGPUSupport.rst:47
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the 
feature is enabled and 0 if it is disabled. Allowed feature names are sramecc 
and xnack.
+   * - ``__AMDGCN_CUMODE__``

scchan wrote:
> This set of feature macros is tricky.  A feature macro is defined only when 
> the corresponding target feature has been explicitly specified during 
> compilation; otherwise it's undefined.  Users will have to refer to the 
> target feature table to get the semantic of each state.  For example, for 
> xnack, undefined=="any", 1 for xnack+, 0 for xnack-.
> 
> Is there a reason we don't support features other than sramecc and xnack?
This macro is designed to support Target ID only, therefore it is only emitted 
when target ID containing the feature is used.

The target ID features are stable since they are used to select code objects 
from fat binaries.

My understanding is that other features used by amdgpu backend do not have 
stable feature names, therefore are not suitable to be used as predefined 
macros for users to condition their code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154133

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


[PATCH] D154123: [HIP] Start document HIP support by clang

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

revised by comments


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

https://reviews.llvm.org/D154123

Files:
  clang/docs/HIPSupport.rst

Index: clang/docs/HIPSupport.rst
===
--- /dev/null
+++ clang/docs/HIPSupport.rst
@@ -0,0 +1,132 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.part { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: part
+.. role:: good
+
+.. contents::
+   :local:
+
+===
+HIP Support
+===
+
+`HIP (Heterogeneous-Compute Interface for Portability) `_
+is a C++ Runtime API and Kernel Language that allows developers to create portable applications for
+GPUs from single source code.
+
+Clang supports HIP on `ROCm platform `_.
+
+Example Usage
+=
+
+To compile a HIP program, you can use the following command:
+
+.. code-block:: shell
+
+   clang -c --offload-arch=gfx906 -xhip test.cpp -o test.o
+
+To link a HIP program, you can use this command:
+
+.. code-block:: shell
+
+   clang --hip-link --offload-arch=gfx906 test.o -o test
+
+In the above commands, ``gfx906`` is the GPU architecture that the code is being compiled for.
+The supported GPU architectures can be found in the `AMDGPU Processor Table `_.
+Alternatively, you can run the ``amdgpu-arch`` tool that comes with Clang to list the GPU architecture on your sytem:
+
+.. code-block:: shell
+
+   amdgpu-arch
+
+You can also use ``--offload-arch=native`` to let ``amdgpu-arch`` automatically detect the GPU architecture on your system:
+
+.. code-block:: shell
+
+   clang -c --offload-arch=native -xhip test.cpp -o test.o
+
+Path Setting for Dependencies
+=
+
+Compiling a HIP program depends on the HIP runtime and device library. The paths to the HIP runtime and device libraries can be specified either using compiler options or environment variables. The paths can also be set through the ROCm path if they follow the ROCm installation directory structure.
+
+Order of Precedence for HIP Path
+
+
+1. ``--hip-path`` compiler option
+2. ``HIP_PATH`` environment variable
+3. ``--rocm-path`` compiler option
+4. ``ROCM_PATH`` environment variable
+5. Default automatic detection (relative to Clang or at the default ROCm installation location)
+
+Order of Precedence for Device Library Path
+---
+
+1. ``--hip-device-lib-path`` compiler option
+2. ``HIP_DEVICE_LIB_PATH`` environment variable
+3. ``--rocm-path`` compiler option
+4. ``ROCM_PATH`` environment variable
+5. Default automatic detection (relative to Clang or at the default ROCm installation location)
+
+
+.. list-table::
+   :header-rows: 1
+
+   * - Compiler Option
+ - Environment Variable
+ - Description
+ - Default Value
+   * - ``--rocm-path=``
+ - ``ROCM_PATH``
+ - Specifies the ROCm installation path.
+ - Automatic detection
+   * - ``--hip-path=``
+ - ``HIP_PATH``
+ - Specifies the HIP runtime installation path.
+ - Determined by ROCm directory structure
+   * - ``--hip-device-lib-path=``
+ - ``HIP_DEVICE_LIB_PATH``
+ - Specifies the HIP device library installation path.
+ - Determined by ROCm directory structure
+
+Note: The compiler options override environment variables. Specifying HIP runtime and device library paths individually will override the ROCm path.
+
+
+Predefined Macros
+=
+
+.. list-table::
+   :header-rows: 1
+
+   * - Macro
+ - Description
+   * - ``__CLANG_RDC__``
+ - Defined when Clang is compiling code in Relocatable Device Code (RDC) mode. RDC, enabled with the ``-fgpu-rdc`` compiler option, is necessary for linking device codes across translation units.
+   * - ``__HIP__``
+ - Defined when compiling with HIP language support, indicating that the code targets the HIP environment.
+   * - ``__HIPCC__``
+ - Alias to ``__HIP__``.
+   * - ``__HIP_DEVICE_COMPILE__``
+ - Defined during device code compilation in Clang's separate compilation process for the host and each offloading GPU architecture.
+   * - ``__HIP_MEMORY_SCOPE_SINGLETHREAD``
+ - Represents single-thread memory scope in HIP (value is 1).
+   * - ``__HIP_MEMORY_SCOPE_WAVEFRONT``
+ - Represents wavefront memory scope in HIP (value is 2).
+   * - ``__HIP_MEMORY_SCOPE_WORKGROUP``
+ - Represents workgroup memory scope in HIP (value is 3).
+   * - ``__HIP_MEMORY_SCOPE_AGENT``
+ - Represents agent memory scope in HIP (value is 4).
+   * - ``__HIP_MEMORY_SCOPE_SYSTEM``
+ - Represents system-wide memory scope in HIP (value is 5).
+   * - ``__HIP_NO_IMAGE_SUPPORT``
+ - Defined with 

[PATCH] D154123: [HIP] Start document HIP support by clang

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



Comment at: clang/docs/HIPSupport.rst:82
+===
+
+1. **Compiler Options**: If you specify paths using the compiler options, 
these will override the correponding paths set via environment variables. 

scchan wrote:
> I think it would be easier to understand by explicitly calling out the order 
> of precedence:
> 
> - For HIP path:
>   - --hip-path option
>   - HIP_PATH env var
>   - --rocm-path option
>  - ROCM_PATH env var
>  - default automatic detection
> 
> 
> -- For device lib:
>   - --hip-device-lib-path option
>   - HIP_DEVICE_LIB_PATH env var
>   - --rocm-path option
>   -  ROCM_PATH env var
>   - default automatic detection
> 
wil do


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

https://reviews.llvm.org/D154123

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


[PATCH] D151575: [clang][diagnostics] Always show include stacks on errors

2023-07-07 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao updated this revision to Diff 538197.
SlaterLatiao added a comment.

- Emit include stack on all top-level diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151575

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Frontend/DiagnosticRenderer.cpp
  clang/test/Misc/Inputs/include-stack-on-error-1.h
  clang/test/Misc/Inputs/include-stack-on-error-2.h
  clang/test/Misc/Inputs/include-stack-on-error-3.h
  clang/test/Misc/include-stack-on-error-1.cpp
  clang/test/Misc/include-stack-on-error-2.cpp

Index: clang/test/Misc/include-stack-on-error-2.cpp
===
--- /dev/null
+++ clang/test/Misc/include-stack-on-error-2.cpp
@@ -0,0 +1,15 @@
+// Test duplicate include stacks that are not on a new error are skipped.
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=NOTESTACK
+
+#include "include-stack-on-error-1.h"
+#include "include-stack-on-error-3.h"
+
+// NOTESTACK:  In file included from
+// NOTESTACK: error: no matching function for call to 'b1'
+// This include should be skipped due to duplicate include location.
+// NOTESTACK-NOT:  In file included from
+// NOTESTACK: note: candidate function not viable
+// NOTESTACK:  In file included from
+// NOTESTACK: error: invalid operands to binary expression
+// NOTESTACK:  In file included from
+// NOTESTACK: note: in instantiation of function template specialization
Index: clang/test/Misc/include-stack-on-error-1.cpp
===
--- /dev/null
+++ clang/test/Misc/include-stack-on-error-1.cpp
@@ -0,0 +1,24 @@
+// Test duplicate include stacks on a new error are not skipped.
+// RUN: not %clang_cc1 -fsyntax-only -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=STACK
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=NOTESTACK
+
+#include "include-stack-on-error-1.h"
+#include "include-stack-on-error-2.h"
+
+// STACK:  In file included from
+// STACK: error: no matching function for call to 'b1'
+// STACK-NOT:  In file included from
+// STACK: note: candidate function not viable
+// STACK:  In file included from
+// STACK: error: invalid operands to binary expression
+// STACK-NOT:  In file included from
+// STACK: note: in instantiation of function template specialization
+
+// NOTESTACK:  In file included from
+// NOTESTACK: error: no matching function for call to 'b1'
+// NOTESTACK:  In file included from
+// NOTESTACK: note: candidate function not viable
+// NOTESTACK:  In file included from
+// NOTESTACK: error: invalid operands to binary expression
+// NOTESTACK:  In file included from
+// NOTESTACK: note: in instantiation of function template specialization
Index: clang/test/Misc/Inputs/include-stack-on-error-3.h
===
--- /dev/null
+++ clang/test/Misc/Inputs/include-stack-on-error-3.h
@@ -0,0 +1,5 @@
+void b1();
+void c() {
+b1(0);
+b2("0", "0");
+}
Index: clang/test/Misc/Inputs/include-stack-on-error-2.h
===
--- /dev/null
+++ clang/test/Misc/Inputs/include-stack-on-error-2.h
@@ -0,0 +1,4 @@
+void c() {
+b1(0);
+b2("0", "0");
+}
Index: clang/test/Misc/Inputs/include-stack-on-error-1.h
===
--- /dev/null
+++ clang/test/Misc/Inputs/include-stack-on-error-1.h
@@ -0,0 +1,2 @@
+void b1();
+template  void b2(T x, T y) { x + y; }
Index: clang/lib/Frontend/DiagnosticRenderer.cpp
===
--- clang/lib/Frontend/DiagnosticRenderer.cpp
+++ clang/lib/Frontend/DiagnosticRenderer.cpp
@@ -167,8 +167,8 @@
   PLoc.isInvalid() ? FullSourceLoc()
: FullSourceLoc(PLoc.getIncludeLoc(), Loc.getManager());
 
-  // Skip redundant include stacks altogether.
-  if (LastIncludeLoc == IncludeLoc)
+  // Skip redundant include stacks altogether on non-top-level.
+  if (Level < DiagnosticsEngine::Warning && LastIncludeLoc == IncludeLoc)
 return;
 
   LastIncludeLoc = IncludeLoc;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -359,6 +359,9 @@
 - The Fix-It emitted for unused labels used to expand to the next line, which caused
   visual oddities now that Clang shows more than one line of code snippet. This has
   been fixed and the Fix-It now only spans to the end of the ``:``.
+- Clang now does not skip the include stack on top-level diagnostics when it's a 
+  duplicate of the previous include stack.
+  (`#62001 `_)
 
 Bug Fixes in This Version
 

[PATCH] D151730: [RISCV] Support target attribute for function

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

Can you separate the change to RISCVAsmPrinter.cpp into it's own review?  This 
looks useful for any case where we have functions in the same model with 
different function attributes.  The __attribute__((target...) syntax is one way 
to have that, but there are also others.  LTO will see this, and so may other 
frontends.

This will also help with review as the set of people who can review RISCV 
backend changes and clang frontend changes is fairly non-overlapping.




Comment at: llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll:5
+; CHECK-NEXT: .optionarch,   +c, +v, +zifencei, +zve32f, +zve32x, 
+zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test1() #0 {
+; CHECK-LABEL: test1

This test would be a lot easier to follow if you pruned all the spurious 
attributes, and uses the inline attribute syntax rather than the #0 reference 
syntax.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151730

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


[PATCH] D152093: [clang][Analysis] Handle && and || against variable and its negation as tautology

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

Seems like a nice idea to me, thanks!

Do you have any numbers on how often this fires in practice, and what the true 
positive rate is? (Build some large-ish open source  project with this, and see 
what it finds.)
Did you verify that this has negligible compile time impact for building a 
large-ish project?

With that, looks good.




Comment at: clang/lib/Analysis/CFG.cpp:1096
+if (Negate->getOpcode() == UO_LNot &&
+Expr::isSameComparisonOperand(Negate->getSubExpr(), E2)) {
+  bool AlwaysTrue = B->getOpcode() == BO_LOr;

Do you want to IgnoreParens() on the ! subexpr too?


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

https://reviews.llvm.org/D152093

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


[PATCH] D154543: [llvm] Move StringExtras.h include from Error.h to Error.cpp

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

> [llvm] Move StringExtras.h include from Error.h to Error.cpp

If you land the #include changes separately, I think the tag can be changed to 
`[Support] `. `Support` is sufficient to refer to llvm-project/llvm/


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

https://reviews.llvm.org/D154543

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


[PATCH] D154543: [llvm] Move StringExtras.h include from Error.h to Error.cpp

2023-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

I have spot checked a few files and the additional #include looks great!
As mentioned in the other patch, it would be better landing the #include 
adjustment part separately so that the `llvm/Support/Error.h` change is more 
focused.
Also, there is lower risk if something breaks, either you or someone else 
reverts the patch, and causes unneeded churn to many files.


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

https://reviews.llvm.org/D154543

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


[PATCH] D154658: Optimize emission of `dynamic_cast` to final classes.

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

In D154658#4479213 , @rsmith wrote:

> In D154658#4479170 , @rjmccall 
> wrote:
>
>> I don't think it's an intended guarantee of the Itanium ABI that the v-table 
>> will be unique, and v-tables are frequently not unique in the presence of 
>> shared libraries.
>
> https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-general explicitly 
> guarantees this: "[...] However, the virtual table pointers within all the 
> objects (instances) of a particular most-derived class point to the same set 
> of virtual tables."

Huh, I've never noticed that before.  I still don't think it's satisfied in 
practice, at least in the presence of shared libraries.  This is notably the 
exact same setup that eventually forced (or "forced") GCC to start using string 
comparison for RTTI instead of the ABI-prescribed algorithm that relies on 
`_ZTS` pointer equality.

>> They should be unique for classes with internal linkage, but of course 
>> that's a vastly reduced domain for the optimization.
>
> I think (hope?) we should be able to apply this to a much larger set of 
> cases. Would it be correct to do this optimization unless the vtable might be 
> emitted with vague linkage and non-default visibility (that is, unless we're 
> in the odd case where people expect non-default visibility classes to be the 
> same type across DSOs)? Or are there cases where we might be using a vtable 
> that (eg) doesn't even have the right symbol?

I don't know of any problems other than the total failure of vague linkage 
across DSO boundaries, so if we just treat that as an implicit exception to the 
vtable uniqueness guarantee in the ABI, I think you've got the condition 
exactly right: we could do this for any class where either the v-table doesn't 
have vague linkage or the class's formal visibility is not `default`.  Our 
experience at Apple with enforcing type visibility is that it's usually good 
for one or two bug reports a year, but it's pretty easy to explain to users 
what they did wrong, and Clang's visibility attributes are pretty simple to 
use.  (`type_visibility` helps a lot with managing tradeoffs.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154658

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


[clang] 9306352 - [Clang] Emit KCFI type hashes for member functions

2023-07-07 Thread Sami Tolvanen via cfe-commits

Author: Sami Tolvanen
Date: 2023-07-07T16:50:30Z
New Revision: 930635271f810316f48bd1aa78935acf36a08f8f

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

LOG: [Clang] Emit KCFI type hashes for member functions

With `-fsanitize=kcfi`, Clang currently won't emit type hashes for
C++ member functions, which leads to check failures if they are
indirectly called. As there's no reason to exclude member functions
in CodeGenModule::setKCFIType, emit type hashes also for them to fix
member function pointer calls with KCFI, and add a test to confirm
that types are emitted correctly.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/kcfi.c

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 6ea499958695d4..b5d26395ebba6a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2610,9 +2610,6 @@ void 
CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
 }
 
 void CodeGenModule::setKCFIType(const FunctionDecl *FD, llvm::Function *F) {
-  if (isa(FD) && !cast(FD)->isStatic())
-return;
-
   llvm::LLVMContext  = F->getContext();
   llvm::MDBuilder MDB(Ctx);
   F->setMetadata(llvm::LLVMContext::MD_kcfi_type,

diff  --git a/clang/test/CodeGen/kcfi.c b/clang/test/CodeGen/kcfi.c
index 1adf6df92a6543..f6b2e4b398aa7c 100644
--- a/clang/test/CodeGen/kcfi.c
+++ b/clang/test/CodeGen/kcfi.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi 
-o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi 
-x c++ -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi 
-x c++ -o - %s | FileCheck %s --check-prefixes=CHECK,MEMBER
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi 
-fpatchable-function-entry-offset=3 -o - %s | FileCheck %s 
--check-prefixes=CHECK,OFFSET
 #if !__has_feature(kcfi)
 #error Missing kcfi?
@@ -54,7 +54,21 @@ int test(void) {
  f6();
 }
 
+#ifdef __cplusplus
+struct A {
+  // MEMBER-DAG: define{{.*}} void @_ZN1A1fEv(ptr{{.*}} %this){{.*}} 
!kcfi_type ![[#TYPE3:]]
+  void f() {}
+};
+
+void test_member_call(void) {
+  void (A::* p)() = ::f;
+  // MEMBER-DAG: call void %[[#]](ptr{{.*}} [ "kcfi"(i32 [[#%d,HASH3:]]) ]
+  (A().*p)();
+}
+#endif
+
 // CHECK-DAG: ![[#]] = !{i32 4, !"kcfi", i32 1}
 // OFFSET-DAG: ![[#]] = !{i32 4, !"kcfi-offset", i32 3}
 // CHECK-DAG: ![[#TYPE]] = !{i32 [[#HASH]]}
 // CHECK-DAG: ![[#TYPE2]] = !{i32 [[#%d,HASH2:]]}
+// MEMBER-DAG: ![[#TYPE3]] = !{i32 [[#HASH3]]}



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


[PATCH] D154123: [HIP] Start document HIP support by clang

2023-07-07 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan added inline comments.



Comment at: clang/docs/HIPSupport.rst:82
+===
+
+1. **Compiler Options**: If you specify paths using the compiler options, 
these will override the correponding paths set via environment variables. 

I think it would be easier to understand by explicitly calling out the order of 
precedence:

- For HIP path:
  - --hip-path option
  - HIP_PATH env var
  - --rocm-path option
 - ROCM_PATH env var
 - default automatic detection


-- For device lib:
  - --hip-device-lib-path option
  - HIP_DEVICE_LIB_PATH env var
  - --rocm-path option
  -  ROCM_PATH env var
  - default automatic detection



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

https://reviews.llvm.org/D154123

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


[PATCH] D153273: [analyzer] Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime elements

2023-07-07 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added inline comments.



Comment at: clang/lib/Analysis/CFG.cpp:773
   void addLoopExit(const Stmt *LoopStmt);
-  void addAutomaticObjDtors(LocalScope::const_iterator B,
-LocalScope::const_iterator E, Stmt *S);
-  void addLifetimeEnds(LocalScope::const_iterator B,
-   LocalScope::const_iterator E, Stmt *S);
   void addAutomaticObjHandling(LocalScope::const_iterator B,
LocalScope::const_iterator E, Stmt *S);

Consider adding comments describing these methods, either here or at the 
function definitions.



Comment at: clang/lib/Analysis/CFG.cpp:1815
+
+  for (std::size_t idx = 1; idx < LocalScopeEndMarkers.size(); ++idx) {
+LocalScope::const_iterator B = LocalScopeEndMarkers[idx];

if `LocalScopeEndMarkers` isn't supposed to change inside the body of the loop, 
then consider making this call once
`for (std::size_t idx = 1, N = LocalScopeEndMarkers.size(); idx < N; ...`



Comment at: clang/lib/Analysis/CFG.cpp:1847-1849
+  if (Ty->isReferenceType()) {
+Ty = getReferenceInitTemporaryType(VD->getInit());
+  }





Comment at: clang/lib/Analysis/CFG.cpp:1911-1918
+  if (!BuildOpts.AddImplicitDtors && !BuildOpts.AddLifetime &&
+  !BuildOpts.AddScopes) {
 return;
+  }
 
-  autoCreateBlock();
+  if (SrcPos == DstPos) {
+return;

Remove extra braces?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153273

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


[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-07-07 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan added inline comments.



Comment at: clang/docs/AMDGPUSupport.rst:47
+   * - ``__amdgcn_feature___``
+ - Defined for each supported target feature. The value is 1 if the 
feature is enabled and 0 if it is disabled. Allowed feature names are sramecc 
and xnack.
+   * - ``__AMDGCN_CUMODE__``

This set of feature macros is tricky.  A feature macro is defined only when the 
corresponding target feature has been explicitly specified during compilation; 
otherwise it's undefined.  Users will have to refer to the target feature table 
to get the semantic of each state.  For example, for xnack, undefined=="any", 1 
for xnack+, 0 for xnack-.

Is there a reason we don't support features other than sramecc and xnack?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154133

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

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



Comment at: clang/tools/amdgpu-arch/AMDGPUArch.cpp:48-52
+  if (!printGPUsByHSA())
+return 0;
+#endif
 
+  return printGPUsByHSA();

Are we missing something here ? They look the same.


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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

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



Comment at: clang/tools/amdgpu-arch/AMDGPUArch.cpp:50
+#else
+  return printGPUsByHSA();
+#endif

jhuber6 wrote:
> arsenm wrote:
> > The HIP path should work on linux too. I generally think we should build as 
> > much code as possible on all hosts, so how about
> > ```
> > #ifndef _WIN32
> >   if (tryHSA())
> > return 0;
> > #endif
> > 
> > tryHIP()
> > ```
> > 
> > 
> > 
> That'd be fine, I'm in favor of sticking to HSA since it's a smaller runtime 
> that's more reasonable to build standalone without the whole ROCm stack.
done


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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

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

revised by comments


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

https://reviews.llvm.org/D153725

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
  clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt

Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -8,6 +8,6 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
+add_clang_tool(amdgpu-arch AMDGPUArch.cpp AMDGPUArchByHSA.cpp AMDGPUArchByHIP.cpp)
 
 target_link_libraries(amdgpu-arch PRIVATE clangBasic)
Index: clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
===
--- /dev/null
+++ clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
@@ -0,0 +1,122 @@
+//===- AMDGPUArchLinux.cpp - list AMDGPU installed --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a tool for detecting name of AMDGPU installed in system
+// using HSA on Linux. This tool is used by AMDGPU OpenMP and HIP driver.
+//
+//===--===//
+
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+
+typedef enum {
+  HSA_STATUS_SUCCESS = 0x0,
+} hsa_status_t;
+
+typedef enum {
+  HSA_DEVICE_TYPE_CPU = 0,
+  HSA_DEVICE_TYPE_GPU = 1,
+} hsa_device_type_t;
+
+typedef enum {
+  HSA_AGENT_INFO_NAME = 0,
+  HSA_AGENT_INFO_DEVICE = 17,
+} hsa_agent_info_t;
+
+typedef struct hsa_agent_s {
+  uint64_t handle;
+} hsa_agent_t;
+
+hsa_status_t (*hsa_init)();
+hsa_status_t (*hsa_shut_down)();
+hsa_status_t (*hsa_agent_get_info)(hsa_agent_t, hsa_agent_info_t, void *);
+hsa_status_t (*hsa_iterate_agents)(hsa_status_t (*)(hsa_agent_t, void *),
+   void *);
+
+constexpr const char *DynamicHSAPath = "libhsa-runtime64.so";
+
+llvm::Error loadHSA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHSAPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s", DynamicHSAPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(hsa_init);
+  DYNAMIC_INIT(hsa_shut_down);
+  DYNAMIC_INIT(hsa_agent_get_info);
+  DYNAMIC_INIT(hsa_iterate_agents);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+
+static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
+  hsa_device_type_t DeviceType;
+  hsa_status_t Status =
+  hsa_agent_get_info(Agent, HSA_AGENT_INFO_DEVICE, );
+
+  // continue only if device type if GPU
+  if (Status != HSA_STATUS_SUCCESS || DeviceType != HSA_DEVICE_TYPE_GPU) {
+return Status;
+  }
+
+  std::vector *GPUs =
+  static_cast *>(Data);
+  char GPUName[64];
+  Status = hsa_agent_get_info(Agent, HSA_AGENT_INFO_NAME, GPUName);
+  if (Status != HSA_STATUS_SUCCESS) {
+return Status;
+  }
+  GPUs->push_back(GPUName);
+  return HSA_STATUS_SUCCESS;
+}
+
+int printGPUsByHSA() {
+  // Attempt to load the HSA runtime.
+  if (llvm::Error Err = loadHSA()) {
+logAllUnhandledErrors(std::move(Err), llvm::errs());
+return 1;
+  }
+
+  hsa_status_t Status = hsa_init();
+  if (Status != HSA_STATUS_SUCCESS) {
+return 1;
+  }
+
+  std::vector GPUs;
+  Status = hsa_iterate_agents(iterateAgentsCallback, );
+  if (Status != HSA_STATUS_SUCCESS) {
+return 1;
+  }
+
+  for (const auto  : GPUs)
+llvm::outs() << GPU << '\n';
+
+  if (GPUs.size() < 1)
+return 1;
+
+  hsa_shut_down();
+  return 0;
+}
Index: clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
===
--- /dev/null
+++ 

[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-07-07 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 538165.
Fznamznon added a comment.

Rebase, move the logic, modify c-style casts as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -273,7 +273,6 @@
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a 
parenthesized list of values is a C++20 extension}}
 }
 
-
 namespace GH63278 {
 struct S {
   int a = 0;
@@ -294,3 +293,23 @@
 }
 
 }
+
+namespace gh62863 {
+int (&)[] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[1] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[2] = static_cast(42); // expected-error {{reference to 
type 'int[2]' could not bind to an rvalue of type 'int[1]'}}
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[3] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[3]' from a 
parenthesized list of values is a C++20 extension}}
+
+int (&)[] = (int[])(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[1] = (int[])(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[2] = (int[])(42); // expected-error {{reference to type 'int[2]' 
could not bind to an rvalue of type 'int[1]'}}
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[3] = (int[3])(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[3]' from a 
parenthesized list of values is a C++20 extension}}
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8853,6 +8853,18 @@
   }
 }
   }
+  if (isa(E)) {
+QualType DestType = E->getType();
+if (const auto *IAT = Context.getAsIncompleteArrayType(DestType)) {
+  // C++20 [expr.static.cast]p.4: ... If T is “array of unknown bound of 
U”,
+  // this direct-initialization defines the type of the expression as U[1]
+  QualType ResultType = Context.getConstantArrayType(
+  IAT->getElementType(),
+  llvm::APInt(Context.getTypeSize(Context.getSizeType()), 1),
+  /*SizeExpr=*/nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0);
+  E->setType(ResultType);
+}
+  }
 }
 
 QualType Sema::getCompletedType(Expr *E) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -573,6 +573,8 @@
 - Stop evaluating a constant expression if the condition expression which in
   switch statement contains errors.
   (`#63453 _`)
+- Fixed `static_cast` to array of unknown bound.
+  (`#62863 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -273,7 +273,6 @@
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
 }
 
-
 namespace GH63278 {
 struct S {
   int a = 0;
@@ -294,3 +293,23 @@
 }
 
 }
+
+namespace gh62863 {
+int (&)[] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a parenthesized list of values is a C++20 extension}}
+int (&)[1] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a parenthesized list of values is a C++20 extension}}
+int (&)[2] = static_cast(42); // expected-error {{reference to type 'int[2]' could not bind to an rvalue of type 'int[1]'}}
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a parenthesized list of values is a C++20 extension}}
+int (&)[3] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[3]' from a parenthesized list of values is a C++20 extension}}
+
+int (&)[] = (int[])(42);
+// beforecxx20-warning@-1 {{aggregate initialization of 

[PATCH] D153914: [clang-cl] Enable concatenation of predefined identifiers

2023-07-07 Thread Richard Dzenis via Phabricator via cfe-commits
RIscRIpt added a comment.

Added @aaron.ballman as reviewer, because he was reviewer of related patch: 
878e590503dff 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153914

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


[PATCH] D154672: [OPENMP52] Deprecation of 'depend' clause in ordered directive.

2023-07-07 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1532
   InGroup;
+def warn_omp_depend_in_ordered_deprecated : Warning<"denpend clause for 
ordered is deprecated; use doacross instaed">, InGroup;
 

aaron.ballman wrote:
> ABataev wrote:
> > denpend->depend
> > instaed->instead
> Also, wrap to 80 columns and put syntax elements in single quotes. e.g., 
> 'depend' clause for 'ordered'
Thanks Alexey and Aaron for the review!!!  Just a question, do you know why 
git-clang-format does not format .td file now.  It was working before.
Thanks.
Jennifer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154672

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


[PATCH] D154672: [OPENMP52] Deprecation of 'depend' clause in ordered directive.

2023-07-07 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 538162.
jyu2 added a comment.

Thanks @jdoerfert, @ABataev and @aaron.ballman for the code reviews.  This is 
addressing comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154672

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/ordered_doacross_codegen.c
  clang/test/OpenMP/ordered_messages.cpp


Index: clang/test/OpenMP/ordered_messages.cpp
===
--- clang/test/OpenMP/ordered_messages.cpp
+++ clang/test/OpenMP/ordered_messages.cpp
@@ -402,6 +402,7 @@
   for (int i = 0; i < 10; ++i) { // expected-error {{expected 2 for loops 
after '#pragma omp for', but found only 1}}
 #if _OPENMP >= 202111
 #pragma omp ordered doacross(sink : i)
+#pragma omp ordered depend(source) // expected-warning {{'depend' clause for 
'ordered' is deprecated; use doacross instead}}
 int j;
 #pragma omp ordered doacross(sink : i, j) // omp52-error {{expected loop 
iteration variable}}
 #else
Index: clang/test/OpenMP/ordered_doacross_codegen.c
===
--- clang/test/OpenMP/ordered_doacross_codegen.c
+++ clang/test/OpenMP/ordered_doacross_codegen.c
@@ -2,21 +2,21 @@
 // RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL
 
-// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown -emit-llvm 
%s -o - -fopenmp-version=52 | FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown -emit-llvm 
%s -o - -fopenmp-version=52 -DOMP52 | FileCheck %s 
--check-prefixes=CHECK,CHECK-NORMAL
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-IRBUILDER
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -fopenmp-version=52 -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-IRBUILDER
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -fopenmp-version=52 -DOMP52 -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -triple 
x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,CHECK-IRBUILDER
 
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fopenmp-enable-irbuilder 
-triple x86_64-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fopenmp-enable-irbuilder 
-triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -DOMP52 
-fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -DOMP52 
-fopenmp-enable-irbuilder -triple x86_64-unknown-unknown -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-IRBUILDER
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -DOMP52 -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -emit-pch -o 
%t %s
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -triple 
x86_64-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -triple 
x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -DOMP52 -triple 
x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -DOMP52 -triple 
x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 
@@ -59,7 +59,7 @@
 // CHECK-NORMAL-NEXT: call void @__kmpc_doacross_post(ptr [[IDENT]], i32 
[[GTID]], ptr [[TMP]])
 // CHECK-IRBUILDER-NEXT: [[GTID1:%.+]] = call i32 
@__kmpc_global_thread_num(ptr [[IDENT:@.+]])
 

[PATCH] D154423: [clang][analyzer] Add all success/failure messages to StdLibraryFunctionsChecker.

2023-07-07 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The standard streams may need special handling, this can be useful for 
`StreamChecker` too. One problem is that the standard streams can be changed by 
the program, so we can not know for sure if these are the original values. 
Still it can be better to assume that `fileno` can not fail if used with the 
standard streams.
The result with `ftell` looks interesting, I checked this case already and I 
think the note tag is missing because there is a hidden conversion so the 
original symbol (that is set to interesting) is different than the real `ftell` 
function call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154423

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-07-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D153418#4478766 , @tahonermann 
wrote:

>> Please correct me if I'm wrong, I'm not too familiar with icu4c, but I think 
>> adding support for ICU would be the better long-term solution since it seems 
>> to allow the same behaviour across different platforms.
>
> I tend to agree. Additionally, as more Unicode support is added to C++, the 
> likelihood that we'll want to use other functionality from ICU increases.
>
>> However, the issue on the z/OS platform is that there currently isn't 
>> support for this library so iconv seems to be the only solution we can use 
>> until we do get support. So would an alternative be to use iconv only on 
>> z/OS (and hopefully this is a temporary solution until icu is supported on 
>> z/OS) and use icu on all other platforms?
>
> ICU isn't supported on z/OS because the historical z/OS compiler (xlC) never 
> gained support for C++11 or later so support for z/OS was dropped when ICU 
> moved to C++11. Now that IBM has embraced LLVM and Clang, I would expect it 
> to be possible to build ICU for z/OS again with moderate porting effort. It 
> would be great if someone from IBM could confirm whether such an effort is 
> underway (@hubert.reinterpretcast?).

We currently have no plan or resources allocated towards porting ICU on z/OS. 
Our users also rely on iconv for the system locales, but (and please correct me 
if I'm wrong) it seems like ICU does not use system locales so this may not 
meet our users' needs. So we would still prefer to have iconv support available 
at the very least for z/OS, even if ICU is the preferred default.

I'll also post the same reply on the RFC so we can continue the discussion there


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2023-07-07 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a subscriber: rjmccall.
zahiraam added a comment.

According to this comment https://reviews.llvm.org/D87528#2342132, it looks 
like @rjmccall had proposed the addition of the attribute. @rjmccall Do you 
recall why it was added?


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

https://reviews.llvm.org/D139629

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


[PATCH] D154290: [WIP][Clang] Implement P2741R3 - user-generated static_assert messages

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



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16893
+
+  if (const StringLiteral *SL = dyn_cast(Message);
+  SL && SL->getCharByteWidth() == 1) {





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16898
+  }
+
+  QualType T = Message->getType().getNonReferenceType();

What if the message is ` StringLiteral` but `getCharByteWidth()` doesn't return 
`1`? We would get the `err_static_assert_invalid_message` because` !RD` is 
true, right?



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16900
+  QualType T = Message->getType().getNonReferenceType();
+  auto *RD = T->getAsCXXRecordDecl();
+  if (!RD) {





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16912
+  return std::nullopt;
+for (NamedDecl *D : MemberLookup) {
+  if (FunctionDecl *FD = dyn_cast(D->getUnderlyingDecl());





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16913
+for (NamedDecl *D : MemberLookup) {
+  if (FunctionDecl *FD = dyn_cast(D->getUnderlyingDecl());
+  FD && FD->getMinRequiredArguments() == 0 &&




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

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


[PATCH] D154290: [WIP][Clang] Implement P2741R3 - user-generated static_assert messages

2023-07-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 538154.
cor3ntin added a comment.

Rebase.
This is now ready for review.

Note that after discussion with CWG, the consensus seems to be that the wording 
is fine, an implementation has to behave

As if the full expression Message.data()[I] is called for each character.
Obviously this is not a viable implementation strategy so we materialize
intermediate expressions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   User-generated static_assert messages
   https://wg21.link/P2741R3;>P2741R3
-  No
+  Clang 17
  
  
   Placeholder variables with no name
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,7 +1294,7 @@
 bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
   if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
 return true;
-  if (StringLiteral *Message = D->getMessage())
+  if (auto *Message = dyn_cast(D->getMessage()))
 if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
   return true;
   return false;
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -std=c++2c -fsyntax-only %s -verify
+
+static_assert(true, "");
+static_assert(true, 0); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+struct Empty{};
+static_assert(true, Empty{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+struct NoData {
+unsigned long size() const;
+};
+struct NoSize {
+const char* data() const;
+};
+static_assert(true, NoData{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+static_assert(true, NoSize{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+
+struct InvalidSize {
+const char* size() const;
+const char* data() const;
+};
+static_assert(true, InvalidSize{}); // expected-error {{the message in a static_assert declaration must have a size() member function returning an object convertible to std::size_t}} \
+// expected-error {{value of type 'const char *' is not implicitly convertible to 'unsigned long'}}
+struct InvalidData {
+unsigned long size() const;
+unsigned long data() const;
+};
+static_assert(true, InvalidData{}); // expected-error {{the message in a static_assert declaration must have a data() member function returning an object convertible to const char*}} \
+// expected-error {{value of type 'unsigned long' is not implicitly convertible to 'const char *'}}
+
+struct NonConstexprSize {
+unsigned long size() const; // expected-note {{declared here}}
+constexpr const char* data() const;
+};
+
+static_assert(true, NonConstexprSize{});
+static_assert(false, NonConstexprSize{}); // expected-error {{the message in a static_assert declaration must be produced by constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'size' cannot be used in a constant expression}}
+
+struct NonConstexprData {
+constexpr unsigned long size() const {
+return 32;
+}
+const char* data() const;  // expected-note {{declared here}}
+};
+
+static_assert(true, NonConstexprData{});
+static_assert(false, NonConstexprData{}); // expected-error {{the message in a static_assert declaration must be produced by constant expression}} \
+  

[PATCH] D149248: [RISCV][MC] MC layer support for the experimental zacas extension

2023-07-07 Thread Philip Reames via Phabricator via cfe-commits
reames accepted this revision.
reames added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:3338
+unsigned Rs2 = Inst.getOperand(2).getReg();
+if (Rd % 2 == 1) {
+  SMLoc Loc = Operands[1]->getStartLoc();

Very minor, but != 0 would read more naturally for me here.  Checking for odd, 
and then an error message about even requires one extra second of thought.

Same with the one below.


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

https://reviews.llvm.org/D149248

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


[clang] 5e9ab9c - Fix the Clang sphinx bot

2023-07-07 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-07-07T11:08:17-04:00
New Revision: 5e9ab9c615c3b108b05d729a5706dd46f5ebdc97

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

LOG: Fix the Clang sphinx bot

This adds AMDGPUSupport to the index page to address the issue found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/46936

Added: 


Modified: 
clang/docs/index.rst

Removed: 




diff  --git a/clang/docs/index.rst b/clang/docs/index.rst
index 9fc7c6fff701e4..7d08cea95db19b 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -51,6 +51,7 @@ Using Clang as a Compiler
ThinLTO
APINotes
DebuggingCoroutines
+   AMDGPUSupport
CommandGuide/index
FAQ
 



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


[PATCH] D154130: [lit] Avoid os.path.realpath on Windows due to MAX_PATH limitations

2023-07-07 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian added a comment.

@rnk , I would appreciate your review on this since you helped with the 
previous iteration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154130

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


[PATCH] D154130: [lit] Avoid os.path.realpath on Windows due to MAX_PATH limitations

2023-07-07 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian added a comment.

All premerge build failures seem like flukes.

- `x64 windows` failed 1/3 times
- `x64 debian` failed 2/3 times with a timeout (passes locally)
- `libcxx` seems to be failing for everyone: 
https://buildkite.com/llvm-project/libcxx-ci


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154130

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


  1   2   3   >