[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-16 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,10 @@
+// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;"

vgvassilev wrote:

@p4vook ping.

https://github.com/llvm/llvm-project/pull/75629
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Ensure `-isysroot` in the original command is respected (PR #75694)

2023-12-16 Thread via cfe-commits

https://github.com/kon72 created https://github.com/llvm/llvm-project/pull/75694

In CommandMangler, it guesses sysroot path of the host system and adds that 
through `-isysroot` flag only when there is no `--sysroot` or `-isysroot` flag 
beforehand.
Previously, it could not find `-isysroot` flag in the original compile 
command, resulting in duplicate `-isysroot` flags.
This commit fixes it and ensures the explicitly specified sysroot is respected. 
Also adds unit tests for this fix.

>From 1a6a38fdaa5722f6e3d0cba372459cd1e0feb69d Mon Sep 17 00:00:00 2001
From: kon72 
Date: Sat, 16 Dec 2023 17:39:46 +0900
Subject: [PATCH] [clangd] Ensure `-isysroot` in the original command is
 respected

In CommandMangler, it guesses sysroot path of the host system and adds that 
through `-isysroot` flag only when there is no `--sysroot` or `-isysroot` flag 
beforehand.
Previously, it could not find `-isysroot` flag in the original compile 
command, resulting in duplicate `-isysroot` flags.
This commit fixes it and ensures the explicitly specified sysroot is respected.
Also adds unit tests for this fix.
---
 clang-tools-extra/clangd/CompileCommands.cpp  | 23 +++---
 .../clangd/unittests/CompileCommandsTests.cpp | 81 ++-
 2 files changed, 91 insertions(+), 13 deletions(-)

diff --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f43ce928463b90..a3c6f3f41118e4 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -328,13 +328,15 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
 
   tooling::addTargetAndModeForProgramName(Cmd, Cmd.front());
 
-  // Check whether the flag exists, either as -flag or -flag=*
-  auto Has = [&](llvm::StringRef Flag) {
-for (llvm::StringRef Arg : Cmd) {
-  if (Arg.consume_front(Flag) && (Arg.empty() || Arg[0] == '='))
-return true;
-}
-return false;
+  // Check whether the flag exists in the command.
+  auto HasExact = [&](llvm::StringRef Flag) {
+return llvm::any_of(Cmd, [&](llvm::StringRef Arg) { return Arg == Flag; });
+  };
+
+  // Check whether the flag appears in the command as a prefix.
+  auto HasPrefix = [&](llvm::StringRef Flag) {
+return llvm::any_of(
+Cmd, [&](llvm::StringRef Arg) { return Arg.startswith(Flag); });
   };
 
   llvm::erase_if(Cmd, [](llvm::StringRef Elem) {
@@ -342,12 +344,13 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
   });
 
   std::vector ToAppend;
-  if (ResourceDir && !Has("-resource-dir"))
+  if (ResourceDir && !HasExact("-resource-dir") && 
!HasPrefix("-resource-dir="))
 ToAppend.push_back(("-resource-dir=" + *ResourceDir));
 
   // Don't set `-isysroot` if it is already set or if `--sysroot` is set.
   // `--sysroot` is a superset of the `-isysroot` argument.
-  if (Sysroot && !Has("-isysroot") && !Has("--sysroot")) {
+  if (Sysroot && !HasPrefix("-isysroot") && !HasExact("--sysroot") &&
+  !HasPrefix("--sysroot=")) {
 ToAppend.push_back("-isysroot");
 ToAppend.push_back(*Sysroot);
   }
@@ -358,7 +361,7 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
   }
 
   if (!Cmd.empty()) {
-bool FollowSymlink = !Has("-no-canonical-prefixes");
+bool FollowSymlink = !HasExact("-no-canonical-prefixes");
 Cmd.front() =
 (FollowSymlink ? ResolvedDrivers : ResolvedDriversNoFollow)
 .get(Cmd.front(), [&, this] {
diff --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 
b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
index 28f0d85d332caa..cad135923f71c1 100644
--- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -385,9 +385,8 @@ TEST(ArgStripperTest, OrderDependent) {
 }
 
 TEST(PrintArgvTest, All) {
-  std::vector Args = {
-  "one", "two", "thr ee", "f\"o\"ur", "fi\\ve", "$"
-  };
+  std::vector Args = {"one",  "two","thr ee",
+   "f\"o\"ur", "fi\\ve", "$"};
   const char *Expected = R"(one two "thr ee" "f\"o\"ur" "fi\\ve" $)";
   EXPECT_EQ(Expected, printArgv(Args));
 }
@@ -465,6 +464,82 @@ TEST(CommandMangler, PathsAsPositional) {
   Mangler(Cmd, "a.cc");
   EXPECT_THAT(Cmd.CommandLine, Contains("foo"));
 }
+
+TEST(CommandMangler, RespectsOriginalResourceDir) {
+  auto Mangler = CommandMangler::forTests();
+  Mangler.ResourceDir = testPath("fake/resources");
+
+  {
+tooling::CompileCommand Cmd;
+Cmd.CommandLine = {"clang++", "-resource-dir", testPath("true/resources"),
+   "foo.cc"};
+Mangler(Cmd, "foo.cc");
+EXPECT_THAT(llvm::join(Cmd.CommandLine, " "),
+HasSubstr("-resource-dir " + testPath("true/resources")));
+EXPECT_THAT(llvm::join(Cmd.CommandLine, " "),
+Not(HasSubstr(testPath("fake/resources";
+  }
+
+  {
+tooling::CompileCommand Cmd;
+Cmd.CommandLi

[clang-tools-extra] [clangd] Ensure `-isysroot` in the original command is respected (PR #75694)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: Kon (kon72)


Changes

In CommandMangler, it guesses sysroot path of the host system and adds that 
through `-isysroot` flag only when there is no `--sysroot` or `-isysroot` flag 
beforehand.
Previously, it could not find `-isysroot` flag in the original 
compile command, resulting in duplicate `-isysroot` flags.
This commit fixes it and ensures the explicitly specified sysroot is respected. 
Also adds unit tests for this fix.

---
Full diff: https://github.com/llvm/llvm-project/pull/75694.diff


2 Files Affected:

- (modified) clang-tools-extra/clangd/CompileCommands.cpp (+13-10) 
- (modified) clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 
(+78-3) 


``diff
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f43ce928463b90..a3c6f3f41118e4 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -328,13 +328,15 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
 
   tooling::addTargetAndModeForProgramName(Cmd, Cmd.front());
 
-  // Check whether the flag exists, either as -flag or -flag=*
-  auto Has = [&](llvm::StringRef Flag) {
-for (llvm::StringRef Arg : Cmd) {
-  if (Arg.consume_front(Flag) && (Arg.empty() || Arg[0] == '='))
-return true;
-}
-return false;
+  // Check whether the flag exists in the command.
+  auto HasExact = [&](llvm::StringRef Flag) {
+return llvm::any_of(Cmd, [&](llvm::StringRef Arg) { return Arg == Flag; });
+  };
+
+  // Check whether the flag appears in the command as a prefix.
+  auto HasPrefix = [&](llvm::StringRef Flag) {
+return llvm::any_of(
+Cmd, [&](llvm::StringRef Arg) { return Arg.startswith(Flag); });
   };
 
   llvm::erase_if(Cmd, [](llvm::StringRef Elem) {
@@ -342,12 +344,13 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
   });
 
   std::vector ToAppend;
-  if (ResourceDir && !Has("-resource-dir"))
+  if (ResourceDir && !HasExact("-resource-dir") && 
!HasPrefix("-resource-dir="))
 ToAppend.push_back(("-resource-dir=" + *ResourceDir));
 
   // Don't set `-isysroot` if it is already set or if `--sysroot` is set.
   // `--sysroot` is a superset of the `-isysroot` argument.
-  if (Sysroot && !Has("-isysroot") && !Has("--sysroot")) {
+  if (Sysroot && !HasPrefix("-isysroot") && !HasExact("--sysroot") &&
+  !HasPrefix("--sysroot=")) {
 ToAppend.push_back("-isysroot");
 ToAppend.push_back(*Sysroot);
   }
@@ -358,7 +361,7 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
   }
 
   if (!Cmd.empty()) {
-bool FollowSymlink = !Has("-no-canonical-prefixes");
+bool FollowSymlink = !HasExact("-no-canonical-prefixes");
 Cmd.front() =
 (FollowSymlink ? ResolvedDrivers : ResolvedDriversNoFollow)
 .get(Cmd.front(), [&, this] {
diff --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 
b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
index 28f0d85d332caa..cad135923f71c1 100644
--- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -385,9 +385,8 @@ TEST(ArgStripperTest, OrderDependent) {
 }
 
 TEST(PrintArgvTest, All) {
-  std::vector Args = {
-  "one", "two", "thr ee", "f\"o\"ur", "fi\\ve", "$"
-  };
+  std::vector Args = {"one",  "two","thr ee",
+   "f\"o\"ur", "fi\\ve", "$"};
   const char *Expected = R"(one two "thr ee" "f\"o\"ur" "fi\\ve" $)";
   EXPECT_EQ(Expected, printArgv(Args));
 }
@@ -465,6 +464,82 @@ TEST(CommandMangler, PathsAsPositional) {
   Mangler(Cmd, "a.cc");
   EXPECT_THAT(Cmd.CommandLine, Contains("foo"));
 }
+
+TEST(CommandMangler, RespectsOriginalResourceDir) {
+  auto Mangler = CommandMangler::forTests();
+  Mangler.ResourceDir = testPath("fake/resources");
+
+  {
+tooling::CompileCommand Cmd;
+Cmd.CommandLine = {"clang++", "-resource-dir", testPath("true/resources"),
+   "foo.cc"};
+Mangler(Cmd, "foo.cc");
+EXPECT_THAT(llvm::join(Cmd.CommandLine, " "),
+HasSubstr("-resource-dir " + testPath("true/resources")));
+EXPECT_THAT(llvm::join(Cmd.CommandLine, " "),
+Not(HasSubstr(testPath("fake/resources";
+  }
+
+  {
+tooling::CompileCommand Cmd;
+Cmd.CommandLine = {"clang++", "-resource-dir=" + 
testPath("true/resources"),
+   "foo.cc"};
+Mangler(Cmd, "foo.cc");
+EXPECT_THAT(llvm::join(Cmd.CommandLine, " "),
+HasSubstr("-resource-dir=" + testPath("true/resources")));
+EXPECT_THAT(llvm::join(Cmd.CommandLine, " "),
+Not(HasSubstr(testPath("fake/resources";
+  }
+}
+
+TEST(CommandMangler, RespectsOriginalSysroot) {
+  auto Mangler = CommandMangler::forTests();
+  Mangler.Sysroot = testPath("fake/sysroot");
+
+  {
+toolin

[clang] [Clang][ARM] support arm target attribute, and warning for bad typo (PR #74812)

2023-12-16 Thread via cfe-commits

https://github.com/hstk30-hw updated 
https://github.com/llvm/llvm-project/pull/74812

>From dc88d97d00f389b46f51c19a22c17397e1e89b7f Mon Sep 17 00:00:00 2001
From: hstk30-hw 
Date: Fri, 8 Dec 2023 14:29:33 +0800
Subject: [PATCH] feat: support arm target attribute, and warning for bad typo

---
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Targets/AArch64.cpp   |  6 +-
 clang/lib/Basic/Targets/ARM.cpp   | 87 +++
 clang/lib/Basic/Targets/ARM.h |  2 +
 clang/lib/Sema/SemaDeclAttr.cpp   |  3 +
 clang/test/CodeGen/arm-targetattr.c   | 13 +++
 .../arm-ignore-branch-protection-option.c |  4 +-
 .../Sema/arm-branch-protection-attr-warn.c| 10 +--
 clang/test/Sema/arm-branch-protection.c   | 32 +++
 clang/test/Sema/attr-target.c |  8 ++
 10 files changed, 142 insertions(+), 24 deletions(-)
 create mode 100644 clang/test/CodeGen/arm-targetattr.c

diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 2e218ba7c84cca..89c2713c93dc76 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -134,5 +134,6 @@ add_clang_library(clangBasic
 
 target_link_libraries(clangBasic
   PRIVATE
+  clangAST
   ${LLVM_ATOMIC_LIB}
 )
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index def16c032c869e..66f0c0e159c2ae 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1085,13 +1085,17 @@ ParsedTargetAttr 
AArch64TargetInfo::parseTargetAttr(StringRef Features) const {
   FoundArch = true;
   std::pair Split =
   Feature.split("=").second.trim().split("+");
+  if (Split.first == "")
+continue;
   const std::optional AI =
   llvm::AArch64::parseArch(Split.first);
 
   // Parse the architecture version, adding the required features to
   // Ret.Features.
-  if (!AI)
+  if (!AI) {
+Ret.Features.push_back("+UNKNOWN");
 continue;
+  }
   Ret.Features.push_back(AI->ArchFeature.str());
   // Add any extra features, after the +
   SplitAndAddFeatures(Split.second, Ret.Features);
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index ce7e4d4639ceac..7ed64f4f44a9b5 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "ARM.h"
+#include "clang/AST/Attr.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -639,6 +640,92 @@ bool 
ARMTargetInfo::handleTargetFeatures(std::vector &Features,
   return true;
 }
 
+// Parse ARM Target attributes, which are a comma separated list of:
+//  "arch=" - parsed to features as per -march=..
+//  "cpu=" - parsed to features as per -mcpu=.., with CPU set to 
+//  "tune=" - TuneCPU set to 
+//  "feature", "no-feature" - Add (or remove) feature.
+//  "+feature", "+nofeature" - Add (or remove) feature.
+ParsedTargetAttr ARMTargetInfo::parseTargetAttr(StringRef Features) const {
+  ParsedTargetAttr Ret;
+  if (Features == "default")
+return Ret;
+  SmallVector AttrFeatures;
+  Features.split(AttrFeatures, ",");
+  bool FoundArch = false;
+
+  auto SplitAndAddFeatures = [](StringRef FeatString,
+std::vector &Features) {
+SmallVector SplitFeatures;
+FeatString.split(SplitFeatures, StringRef("+"), -1, false);
+for (StringRef Feature : SplitFeatures) {
+  StringRef FeatureName = llvm::ARM::getArchExtFeature(Feature);
+  if (!FeatureName.empty())
+Features.push_back(FeatureName.str());
+  else
+// Pushing the original feature string to give a sema error later on
+// when they get checked.
+Features.push_back(Feature.str());
+}
+  };
+
+  for (auto &Feature : AttrFeatures) {
+Feature = Feature.trim();
+if (Feature.startswith("fpmath="))
+  continue;
+
+if (Feature.startswith("branch-protection=")) {
+  Ret.BranchProtection = Feature.split('=').second.trim();
+  continue;
+}
+
+if (Feature.startswith("arch=")) {
+  if (FoundArch)
+Ret.Duplicate = "arch=";
+  FoundArch = true;
+  std::pair Split =
+  Feature.split("=").second.trim().split("+");
+  if (Split.first == "")
+continue;
+  llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(Split.first);
+
+  // Parse the architecture version, adding the required features to
+  // Ret.Features.
+  std::vector FeatureStrs;
+  if (ArchKind == llvm::ARM::ArchKind::INVALID) {
+Ret.Features.push_back("+UNKNOWN");
+continue;
+  }
+  std::string ArchFeature = ("+" + llvm::ARM::getArchName(ArchKind)).str();
+  Ret.Features.push_back(ArchFeature);
+  // Add any extra features, after the +
+

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-16 Thread Pavel Kalugin via cfe-commits


@@ -0,0 +1,10 @@
+// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;"

p4vook wrote:

Yep, we can, I'll try to do it this evening. I couldn't figure out why this 
test failed though, I probably need to fix it somehow.

https://github.com/llvm/llvm-project/pull/75629
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 76041a4 - [flang][nfc] Refactor linker invocation logic (#75648)

2023-12-16 Thread via cfe-commits

Author: Andrzej Warzyński
Date: 2023-12-16T11:13:20Z
New Revision: 76041a45bbe3cd2b3b3acad46267f27815e6a652

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

LOG: [flang][nfc] Refactor linker invocation logic (#75648)

Refactor how the Fortran runtime libs are added to the linker
invocation. This is a non-functional change.

This is an updated version of #75534. This iteration makes sure that
FortranMain.a comes before FortranRuntme.a (the former depends on the
latter).

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 3d1df58190ce05..45901ee7157f77 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1116,72 +1116,91 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
-  llvm::opt::ArgStringList &CmdArgs) {
-  // These are handled earlier on Windows by telling the frontend driver to add
-  // the correct libraries to link against as dependents in the object file.
-
-  // if -fno-fortran-main has been passed, skip linking Fortran_main.a
-  bool LinkFortranMain = !Args.hasArg(options::OPT_no_fortran_main);
-  if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
-if (LinkFortranMain) {
-  // The --whole-archive option needs to be part of the link line to
-  // make sure that the main() function from Fortran_main.a is pulled
-  // in by the linker.  Determine if --whole-archive is active when
-  // flang will try to link Fortran_main.a.  If it is, don't add the
-  // --whole-archive flag to the link line.  If it's not, add a proper
-  // --whole-archive/--no-whole-archive bracket to the link line.
-  bool WholeArchiveActive = false;
-  for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA)) {
-if (Arg) {
-  for (StringRef ArgValue : Arg->getValues()) {
-if (ArgValue == "--whole-archive")
-  WholeArchiveActive = true;
-if (ArgValue == "--no-whole-archive")
-  WholeArchiveActive = false;
-  }
-}
+/// Determines if --whole-archive is active in the list of arguments.
+static bool isWholeArchivePresent(const ArgList &Args) {
+  bool WholeArchiveActive = false;
+  for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA)) {
+if (Arg) {
+  for (StringRef ArgValue : Arg->getValues()) {
+if (ArgValue == "--whole-archive")
+  WholeArchiveActive = true;
+if (ArgValue == "--no-whole-archive")
+  WholeArchiveActive = false;
   }
+}
+  }
 
-  // TODO: Find an equivalent of `--whole-archive` for Darwin.
-  if (!WholeArchiveActive && !TC.getTriple().isMacOSX()) {
-CmdArgs.push_back("--whole-archive");
-CmdArgs.push_back("-lFortran_main");
-CmdArgs.push_back("--no-whole-archive");
-  } else {
-CmdArgs.push_back("-lFortran_main");
-  }
+  return WholeArchiveActive;
+}
 
-  // Perform regular linkage of the remaining runtime libraries.
-  CmdArgs.push_back("-lFortranRuntime");
-  CmdArgs.push_back("-lFortranDecimal");
-}
-  } else {
-if (LinkFortranMain) {
-  unsigned RTOptionID = options::OPT__SLASH_MT;
-  if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
-RTOptionID = llvm::StringSwitch(rtl->getValue())
- .Case("static", options::OPT__SLASH_MT)
- .Case("static_dbg", options::OPT__SLASH_MTd)
- .Case("dll", options::OPT__SLASH_MD)
- .Case("dll_dbg", options::OPT__SLASH_MDd)
- .Default(options::OPT__SLASH_MT);
-  }
-  switch (RTOptionID) {
-  case options::OPT__SLASH_MT:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static.lib");
-break;
-  case options::OPT__SLASH_MTd:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static_dbg.lib");
-break;
-  case options::OPT__SLASH_MD:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.dynamic.lib");
-break;
-  case options::OPT__SLASH_MDd:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.dynamic_dbg.lib");
-break;
-  }
-}
+/// Add Fortran runtime libs for MSVC
+static void addFortranRuntimeLibsMSVC(const ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) {
+  unsigned RTOptionID = options::OPT__SLASH_MT;
+  if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
+RTOptionID = llvm::StringSwitch(rtl->

[clang] [flang][nfc] Refactor linker invocation logic (PR #75648)

2023-12-16 Thread Andrzej Warzyński via cfe-commits

https://github.com/banach-space closed 
https://github.com/llvm/llvm-project/pull/75648
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[mlir] [compiler-rt] [clang-tools-extra] [libc] [llvm] [flang] [clang] [lld] [openmp] [lldb] [libcxx] fix issue 73559. (PR #74926)

2023-12-16 Thread via cfe-commits

ChipsSpectre wrote:

@cor3ntin could you please give your review?
@shafik or would you have time to do this?

The fix is ready to be merged, and all review comments are addressed.

https://github.com/llvm/llvm-project/pull/74926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Concepts] Avoid substituting into constraints for invalid TemplateDecls (PR #75697)

2023-12-16 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/75697

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

Substituting into constraints for invalid TemplateDecls might still yield 
dependent expressions and end up crashing later while attempting evaluation.

>From a6e01586f5d406b51492d973cb693ba32cc63d99 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 16 Dec 2023 18:49:59 +0800
Subject: [PATCH] [Concepts] Avoid substituting into constraints for invalid
 TemplateDecls

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

Substituting into constraints for invalid TemplateDecls might still
yield dependent expressions and end up crashing later while
attempting evaluation.
---
 clang/docs/ReleaseNotes.rst   |  3 +++
 clang/lib/Sema/SemaConcept.cpp|  4 
 clang/test/SemaTemplate/instantiate-requires-expr.cpp | 10 ++
 3 files changed, 17 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b4b5352a306c1c..83f98b97925250 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -831,6 +831,9 @@ Bug Fixes to C++ Support
 - Fix crash when parsing nested requirement. Fixes:
   (`#73112 `_)
 
+- Fixed a crash when substituting into constraint expressions for invalid 
variable templates.
+  Fixes: (`#73885 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 719c6aab74e017..73683fee7c1487 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -353,6 +353,10 @@ static ExprResult calculateConstraintSatisfaction(
   if (Inst.isInvalid())
 return ExprError();
 
+  // An empty expression for substitution failure messages.
+  if (Template && Template->isInvalidDecl())
+return ExprEmpty();
+
   llvm::FoldingSetNodeID ID;
   if (Template &&
   DiagRecursiveConstraintEval(S, ID, Template, AtomicExpr, MLTAL)) 
{
diff --git a/clang/test/SemaTemplate/instantiate-requires-expr.cpp 
b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
index ba82fc1313fc95..fb4127182d1cb6 100644
--- a/clang/test/SemaTemplate/instantiate-requires-expr.cpp
+++ b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
@@ -227,3 +227,13 @@ struct r6 {};
 
 using r6i = r6;
 // expected-error@-1 {{constraints not satisfied for class template 'r6' [with 
T = int]}}
+
+namespace GH73885 {
+template  // expected-error {{extraneous template parameter list}}
+template  // expected-error {{'T' shadows template parameter}}
+  // expected-note@-2 {{template parameter is declared 
here}}
+requires(T{})
+T e_v;
+double e = e_v;
+// expected-error@-1 {{constraints not satisfied for variable template 'e_v' 
[with T = double]}}
+}

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


[clang] [Concepts] Avoid substituting into constraints for invalid TemplateDecls (PR #75697)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

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

Substituting into constraints for invalid TemplateDecls might still yield 
dependent expressions and end up crashing later while attempting evaluation.

---
Full diff: https://github.com/llvm/llvm-project/pull/75697.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/lib/Sema/SemaConcept.cpp (+4) 
- (modified) clang/test/SemaTemplate/instantiate-requires-expr.cpp (+10) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b4b5352a306c1c..83f98b97925250 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -831,6 +831,9 @@ Bug Fixes to C++ Support
 - Fix crash when parsing nested requirement. Fixes:
   (`#73112 `_)
 
+- Fixed a crash when substituting into constraint expressions for invalid 
variable templates.
+  Fixes: (`#73885 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 719c6aab74e017..73683fee7c1487 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -353,6 +353,10 @@ static ExprResult calculateConstraintSatisfaction(
   if (Inst.isInvalid())
 return ExprError();
 
+  // An empty expression for substitution failure messages.
+  if (Template && Template->isInvalidDecl())
+return ExprEmpty();
+
   llvm::FoldingSetNodeID ID;
   if (Template &&
   DiagRecursiveConstraintEval(S, ID, Template, AtomicExpr, MLTAL)) 
{
diff --git a/clang/test/SemaTemplate/instantiate-requires-expr.cpp 
b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
index ba82fc1313fc95..fb4127182d1cb6 100644
--- a/clang/test/SemaTemplate/instantiate-requires-expr.cpp
+++ b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
@@ -227,3 +227,13 @@ struct r6 {};
 
 using r6i = r6;
 // expected-error@-1 {{constraints not satisfied for class template 'r6' [with 
T = int]}}
+
+namespace GH73885 {
+template  // expected-error {{extraneous template parameter list}}
+template  // expected-error {{'T' shadows template parameter}}
+  // expected-note@-2 {{template parameter is declared 
here}}
+requires(T{})
+T e_v;
+double e = e_v;
+// expected-error@-1 {{constraints not satisfied for variable template 'e_v' 
[with T = double]}}
+}

``




https://github.com/llvm/llvm-project/pull/75697
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 50f5b5a - [AArch64][SME2] Add FCLAMP, CNTP builtins for SME2 (#72487)

2023-12-16 Thread via cfe-commits

Author: Dinar Temirbulatov
Date: 2023-12-16T12:03:54Z
New Revision: 50f5b5a80bedee08fd4c46fcd171a1c85ee3834b

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

LOG: [AArch64][SME2] Add FCLAMP, CNTP builtins for SME2 (#72487)

This change enables FCLAMP, CNTP builtins for SME2 target.

Added: 


Modified: 
clang/include/clang/Basic/arm_sve.td
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_cntp.c
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 519438a9bc69b2..55fd35c3b6c2d3 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1970,8 +1970,6 @@ def SVPEXT_X2 : SInst<"svpext_lane_{d}_x2", "2.P}i", 
"QcQsQiQl", MergeNone,
 }
 
 let TargetGuard = "sve2p1" in {
-def SVFCLAMP   : SInst<"svclamp[_{d}]", "", "hfd", MergeNone, 
"aarch64_sve_fclamp", [], []>;
-
 def SVWHILEGE_COUNT  : SInst<"svwhilege_{d}",  "}lli", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilege_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
 def SVWHILEGT_COUNT  : SInst<"svwhilegt_{d}",  "}lli", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilegt_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
 def SVWHILELE_COUNT  : SInst<"svwhilele_{d}",  "}lli", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilele_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
@@ -2071,8 +2069,6 @@ let TargetGuard = "sve2p1" in {
 def SVSCLAMP : SInst<"svclamp[_{d}]", "", "csil", MergeNone, 
"aarch64_sve_sclamp", [], []>;
 def SVUCLAMP : SInst<"svclamp[_{d}]", "", "UcUsUiUl", MergeNone, 
"aarch64_sve_uclamp", [], []>;
 
-def SVCNTP_COUNT : SInst<"svcntp_{d}", "n}i", "QcQsQiQl", MergeNone, 
"aarch64_sve_cntp_{d}", [IsOverloadNone], [ImmCheck<1, ImmCheck2_4_Mul2>]>;
-
 defm SVREVD : SInstZPZ<"svrevd", "csilUcUsUiUl", "aarch64_sve_revd">;
 }
 
@@ -2081,6 +2077,9 @@ let TargetGuard = "sve2p1|sme2" in {
   def SVPTRUE_COUNT  : SInst<"svptrue_{d}", "}v", "QcQsQiQl", MergeNone, 
"aarch64_sve_ptrue_{d}", [IsOverloadNone, IsStreamingCompatible], []>;
 
   def SVPFALSE_COUNT_ALIAS : SInst<"svpfalse_c", "}v", "", MergeNone, "", 
[IsOverloadNone, IsStreamingCompatible]>;
+
+  def SVFCLAMP   : SInst<"svclamp[_{d}]", "", "hfd", MergeNone, 
"aarch64_sve_fclamp", [IsStreamingCompatible], []>;
+  def SVCNTP_COUNT : SInst<"svcntp_{d}", "n}i", "QcQsQiQl", MergeNone, 
"aarch64_sve_cntp_{d}", [IsOverloadNone, IsStreamingCompatible], [ImmCheck<1, 
ImmCheck2_4_Mul2>]>;
 }
 
 let TargetGuard = "sve2p1,b16b16" in {

diff  --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_cntp.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_cntp.c
index 18973a6467450a..56b1d992622145 100644
--- a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_cntp.c
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_cntp.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-O1 -Werror -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
index a9f482cab39698..5d8c5b7b8a18c6 100644
--- a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
@@ -10,6 +10,8 @@
 // RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 \
 // RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve \
+// RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
 
 #include 
 



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


[clang] [AArch64][SME2] Add FCLAMP, CNTP builtins for SME2 (PR #72487)

2023-12-16 Thread Dinar Temirbulatov via cfe-commits

https://github.com/dtemirbulatov closed 
https://github.com/llvm/llvm-project/pull/72487
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CGCUDANV] Unify PointerType members of CGNVCUDARuntime (NFC) (PR #75668)

2023-12-16 Thread Nikita Popov via cfe-commits

https://github.com/nikic approved this pull request.

LGTM

There are already C-style function signatures in the comments, so I don't see 
value in keeping separate variable names.

https://github.com/llvm/llvm-project/pull/75668
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [libcxx] [libc] [lldb] [flang] [openmp] [mlir] [compiler-rt] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Mark de Wever via cfe-commits


@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {

mordante wrote:

Nevermind this only applies to non-member functions and classes themselves.

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [openmp] [llvm] [mlir] [lldb] [libc] [libcxx] [flang] [compiler-rt] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Mark de Wever via cfe-commits


@@ -0,0 +1,170 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+template 
+constexpr void testSpanAt(auto&& anySpan, int index, int expectedValue) {
+  // non-const
+  {
+std::same_as decltype(auto) elem = anySpan.at(index);
+assert(elem == expectedValue);
+  }
+
+  // const
+  {
+std::same_as decltype(auto) elem = 
std::as_const(anySpan).at(index);
+assert(elem == expectedValue);
+  }
+}
+
+constexpr bool test() {
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084};
+std::span arrSpan{arr};
+
+assert(std::dynamic_extent != arrSpan.extent);
+
+using ReferenceT = typename decltype(arrSpan)::reference;
+
+testSpanAt(arrSpan, 0, 0);
+testSpanAt(arrSpan, 1, 1);
+testSpanAt(arrSpan, 6, 9084);
+  }
+
+  // With dynamic extent
+  {
+std::vector vec{0, 1, 2, 3, 4, 5, 9084};
+std::span vecSpan{vec};
+
+assert(std::dynamic_extent == vecSpan.extent);
+
+using ReferenceT = typename decltype(vecSpan)::reference;
+
+testSpanAt(vecSpan, 0, 0);
+testSpanAt(vecSpan, 1, 1);
+testSpanAt(vecSpan, 6, 9084);
+  }
+
+  return true;
+}
+
+void test_exceptions() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  using namespace std::string_literals;
+
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084, std::numeric_limits::max()};
+const std::span arrSpan{arr};
+
+try {
+  std::ignore = arrSpan.at(arr.size());
+  assert(false);
+} catch (const std::out_of_range& e) {
+  // pass
+  assert(e.what() == "span"s);
+} catch (...) {
+  assert(false);
+}
+
+try {
+  std::ignore = arrSpan.at(arr.size() - 1);
+  // pass
+  assert(arrSpan.at(arr.size() - 1) == std::numeric_limits::max());
+} catch (const std::out_of_range&) {
+  assert(false);

mordante wrote:

```suggestion
```
It think it looks better to only use a `catch(...)` when we don't expect an 
exception.

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [mlir] [libcxx] [compiler-rt] [clang] [llvm] [lldb] [openmp] [libc] [flang] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Mark de Wever via cfe-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [libcxx] [libc] [lldb] [flang] [openmp] [mlir] [compiler-rt] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Mark de Wever via cfe-commits

https://github.com/mordante requested changes to this pull request.

Mostly looks good, a few comments.

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [clang-tools-extra] [clang] [flang] [mlir] [lldb] [libcxx] [llvm] [openmp] [libc] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Mark de Wever via cfe-commits




mordante wrote:

What is this submodule? I assume it's not intended to be here.

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [compiler-rt] [clang-tools-extra] [llvm] [lldb] [mlir] [libcxx] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-16 Thread Mark de Wever via cfe-commits


@@ -0,0 +1,145 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+
+#include <__algorithm/ranges_search.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains_subrange {
+struct __fn {
+  template  _Sent1,
+forward_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred,
+class _Proj1,
+class _Proj2,
+class _Offset = int>
+  static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred& __pred,
+  _Proj1& __proj1,
+  _Proj2& __proj2,
+  _Offset __offset) {
+if (__offset < 0)
+  return false;
+else {
+  auto result = ranges::search(
+  std::move(__first1),
+  std::move(__last1),
+  std::move(__first2),
+  std::move(__last2),
+  std::ref(__pred),
+  std::ref(__proj1),
+  std::ref(__proj2));
+  return result.empty() == false;
+}
+  }
+
+  template  _Sent1,
+forward_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred  = ranges::equal_to,
+class _Proj1 = identity,
+class _Proj2 = identity>
+requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred __pred   = {},
+  _Proj1 __proj1 = {},
+  _Proj2 __proj2 = {}) const {
+int __n1 = ranges::distance(__first1, __last1);
+int __n2 = ranges::distance(__first2, __last2);
+if (__n2 == 0)
+  return true;
+int __offset = __n1 - __n2;
+
+return __contains_subrange_fn_impl(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+__pred,
+__proj1,
+__proj2,
+std::move(__offset));
+  }
+
+  template 
+requires indirectly_comparable, iterator_t<_Range2>, 
_Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 
__proj1 = {}, _Proj2 __proj2 = {}) const {
+int __n1 = 0;
+int __n2 = 0;
+
+if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
+  __n1 = ranges::size(__range1);
+  __n2 = ranges::size(__range2);
+} else {
+  __n1 = ranges::distance(__range1);
+  __n2 = ranges::distance(__range2);
+}
+
+if (__n2 == 0)
+  return true;
+int __offset = __n1 - __n2;
+return __contains_subrange_fn_impl(
+ranges::begin(__range1),
+ranges::end(__range1),
+ranges::begin(__range2),
+ranges::end(__range2),
+__pred,
+__proj1,
+__proj2,
+__offset);
+  }
+};
+} // namespace __contains_subrange
+
+inline namespace __cpo {
+inline constexpr auto contains_subrange = __contains_subrange::__fn{};

mordante wrote:

This function needs to be exported from modules. See 
https://github.com/llvm/llvm-project/blob/main/libcxx/modules/std/algorithm.inc#L44

https://github.com/llvm/llvm-project/pull/66963
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [llvm] [compiler-rt] [clang-tools-extra] [lldb] [libcxx] [mlir] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-16 Thread Mark de Wever via cfe-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/66963
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [clang] [lld] [clang-tools-extra] [lldb] [mlir] [compiler-rt] [llvm] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-16 Thread Mark de Wever via cfe-commits

https://github.com/mordante commented:

Thanks for your patch!
I mainly glossed over the patch, and left some comments.

https://github.com/llvm/llvm-project/pull/66963
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [compiler-rt] [lld] [clang] [libcxx] [mlir] [lldb] [llvm] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-16 Thread Mark de Wever via cfe-commits


@@ -0,0 +1,145 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+
+#include <__algorithm/ranges_search.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains_subrange {
+struct __fn {
+  template  _Sent1,
+forward_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred,
+class _Proj1,
+class _Proj2,
+class _Offset = int>
+  static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred& __pred,
+  _Proj1& __proj1,
+  _Proj2& __proj2,
+  _Offset __offset) {
+if (__offset < 0)
+  return false;
+else {
+  auto result = ranges::search(
+  std::move(__first1),
+  std::move(__last1),
+  std::move(__first2),
+  std::move(__last2),
+  std::ref(__pred),
+  std::ref(__proj1),
+  std::ref(__proj2));
+  return result.empty() == false;
+}
+  }
+
+  template  _Sent1,
+forward_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred  = ranges::equal_to,
+class _Proj1 = identity,
+class _Proj2 = identity>
+requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(

mordante wrote:

The `_LIBCPP_NODISCARD_EXT` need to be tested. Can you add them too
`libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp`
`libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp`


https://github.com/llvm/llvm-project/pull/66963
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CGCUDANV] Unify PointerType members of CGNVCUDARuntime (NFC) (PR #75668)

2023-12-16 Thread Sergei Barannikov via cfe-commits

https://github.com/s-barannikov approved this pull request.


https://github.com/llvm/llvm-project/pull/75668
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Treat fields in anonymous records as names in enclosing scope when checking name styles (PR #75701)

2023-12-16 Thread Sirui Mu via cfe-commits

https://github.com/Lancern created 
https://github.com/llvm/llvm-project/pull/75701

Currently, fields in anonymous records are treated as normal record members 
during naming style check. This can be undesirable in certain situations since 
these fields are used just like names in their enclosing scopes:

```c++
class Foo {
  union {
int iv_;// warning: invalid case style for public member 'iv_'
float fv_;  // warning: invalid case style for public member 'fv_'
  };
};
```

`iv_` and `fv_` are used in the code like private members of `Foo` but their 
naming style comes from rules for public members.

This PR changes this behavior. It adds a new option `CheckAnonFieldInParent` to 
`readability-identifier-naming`. When set to `true`, fields in anonymous 
records will be treated as names in their enclosing scopes when checking name 
styles. Specifically:

- If the anonymous record is defined within the file scope or in a namespace 
scope, treat its fields as global variables when checking name styles;
- If the anonymous record is defined within a function, treat its fields as 
local variables when checking name styles;
- If the anonymous record is defined within a non-anonymous record, treat its 
fields as non-static record members when checking name styles.

>From 5d04ca8091fc81fad8e33355a0afcce290bf34f0 Mon Sep 17 00:00:00 2001
From: Sirui Mu 
Date: Sat, 16 Dec 2023 21:55:24 +0800
Subject: [PATCH 1/2] [clang-tidy] Check anonymous record field naming in
 enclosing scopes

Currently, fields in anonymous records are regarded as normal fields when
checking their name styles. Naming rules for class/struct/union member apply to
these fields. This commit changes this behavior:

- If the anonymous record is defined within the file scope or in a namespace
  scope, treat its fields as global variables when checking name styles;
- If the anonymous record is defined within a function, treat its fields as
  local variables when checking name styles;
- If the anonymous record is defined within a non-anonymous record, treat its
  fields as non-static record members when checking name styles.
---
 .../readability/IdentifierNamingCheck.cpp | 196 ++
 .../readability/IdentifierNamingCheck.h   |  13 ++
 .../clang-tidy/utils/ASTUtils.cpp |  24 +++
 clang-tools-extra/clang-tidy/utils/ASTUtils.h |   5 +
 .../identifier-naming-anon-record-fields.cpp  | 184 
 5 files changed, 341 insertions(+), 81 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-anon-record-fields.cpp

diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 03dcfa5f811095..0e18712fd27564 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -9,6 +9,7 @@
 #include "IdentifierNamingCheck.h"
 
 #include "../GlobList.h"
+#include "../utils/ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1185,29 +1186,12 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   }
 
   if (const auto *Decl = dyn_cast(D)) {
-QualType Type = Decl->getType();
-
-if (!Type.isNull() && Type.isConstQualified()) {
-  if (NamingStyles[SK_ConstantMember])
-return SK_ConstantMember;
-
-  if (NamingStyles[SK_Constant])
-return SK_Constant;
+const RecordDecl *Record = Decl->getParent();
+if (Record->isAnonymousStructOrUnion()) {
+  return findStyleKindForAnonField(Decl, NamingStyles);
 }
 
-if (Decl->getAccess() == AS_private && NamingStyles[SK_PrivateMember])
-  return SK_PrivateMember;
-
-if (Decl->getAccess() == AS_protected && NamingStyles[SK_ProtectedMember])
-  return SK_ProtectedMember;
-
-if (Decl->getAccess() == AS_public && NamingStyles[SK_PublicMember])
-  return SK_PublicMember;
-
-if (NamingStyles[SK_Member])
-  return SK_Member;
-
-return SK_Invalid;
+return findStyleKindForField(Decl, Decl->getType(), NamingStyles);
   }
 
   if (const auto *Decl = dyn_cast(D)) {
@@ -1244,66 +1228,7 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   }
 
   if (const auto *Decl = dyn_cast(D)) {
-QualType Type = Decl->getType();
-
-if (Decl->isConstexpr() && NamingStyles[SK_ConstexprVariable])
-  return SK_ConstexprVariable;
-
-if (!Type.isNull() && Type.isConstQualified()) {
-  if (Decl->isStaticDataMember() && NamingStyles[SK_ClassConstant])
-return SK_ClassConstant;
-
-  if (Decl->isFileVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-  NamingStyles[SK_GlobalConstantPointer])
-return SK_GlobalConstantPointer;
-
-  if (Decl->isFileVarDecl() && NamingStyles[SK_GlobalConstant])
-return SK_GlobalConstant;
-
-  if (Decl->isStaticLocal() && NamingStyles[

[clang] [llvm] [clang-tools-extra] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

2023-12-16 Thread James Y Knight via cfe-commits


@@ -30095,12 +30102,16 @@ TargetLoweringBase::AtomicExpansionKind
 X86TargetLowering::shouldExpandAtomicStoreInIR(StoreInst *SI) const {
   Type *MemType = SI->getValueOperand()->getType();
 
-  bool NoImplicitFloatOps =
-  SI->getFunction()->hasFnAttribute(Attribute::NoImplicitFloat);
-  if (MemType->getPrimitiveSizeInBits() == 64 && !Subtarget.is64Bit() &&
-  !Subtarget.useSoftFloat() && !NoImplicitFloatOps &&
-  (Subtarget.hasSSE1() || Subtarget.hasX87()))
-return AtomicExpansionKind::None;
+  if (!SI->getFunction()->hasFnAttribute(Attribute::NoImplicitFloat) &&
+  !Subtarget.useSoftFloat()) {
+if (MemType->getPrimitiveSizeInBits() == 64 && !Subtarget.is64Bit() &&
+(Subtarget.hasSSE1() || Subtarget.hasX87()))

jyknight wrote:

No, misaligned atomic ops are converted to `__atomic_*` libcall before this 
function is ever called.

https://github.com/llvm/llvm-project/pull/74275
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Treat fields in anonymous records as names in enclosing scope when checking name styles (PR #75701)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Sirui Mu (Lancern)


Changes

Currently, fields in anonymous records are treated as normal record members 
during naming style check. This can be undesirable in certain situations since 
these fields are used just like names in their enclosing scopes:

```c++
class Foo {
  union {
int iv_;// warning: invalid case style for public member 'iv_'
float fv_;  // warning: invalid case style for public member 'fv_'
  };
};
```

`iv_` and `fv_` are used in the code like private members of `Foo` but their 
naming style comes from rules for public members.

This PR changes this behavior. It adds a new option `CheckAnonFieldInParent` to 
`readability-identifier-naming`. When set to `true`, fields in anonymous 
records will be treated as names in their enclosing scopes when checking name 
styles. Specifically:

- If the anonymous record is defined within the file scope or in a namespace 
scope, treat its fields as global variables when checking name styles;
- If the anonymous record is defined within a function, treat its fields as 
local variables when checking name styles;
- If the anonymous record is defined within a non-anonymous record, treat its 
fields as non-static record members when checking name styles.

---

Patch is 22.95 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/75701.diff


5 Files Affected:

- (modified) clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
(+130-89) 
- (modified) clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h 
(+23-3) 
- (modified) clang-tools-extra/clang-tidy/utils/ASTUtils.cpp (+24) 
- (modified) clang-tools-extra/clang-tidy/utils/ASTUtils.h (+5) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-anon-record-fields.cpp
 (+185) 


``diff
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 03dcfa5f811095..e6f44dd51b4596 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -9,6 +9,7 @@
 #include "IdentifierNamingCheck.h"
 
 #include "../GlobList.h"
+#include "../utils/ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -286,7 +287,9 @@ IdentifierNamingCheck::FileStyle 
IdentifierNamingCheck::getFileStyleFromOptions(
 HPTOpt.value_or(IdentifierNamingCheck::HPT_Off));
   }
   bool IgnoreMainLike = Options.get("IgnoreMainLikeFunctions", false);
-  return {std::move(Styles), std::move(HNOption), IgnoreMainLike};
+  bool CheckAnonFieldInParent = Options.get("CheckAnonFieldInParent", false);
+  return {std::move(Styles), std::move(HNOption), IgnoreMainLike,
+  CheckAnonFieldInParent};
 }
 
 std::string IdentifierNamingCheck::HungarianNotation::getDeclTypeName(
@@ -859,6 +862,8 @@ void 
IdentifierNamingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "IgnoreFailedSplit", IgnoreFailedSplit);
   Options.store(Opts, "IgnoreMainLikeFunctions",
 MainFileStyle->isIgnoringMainLikeFunction());
+  Options.store(Opts, "CheckAnonFieldInParent",
+MainFileStyle->isCheckingAnonFieldInParentScope());
 }
 
 bool IdentifierNamingCheck::matchesStyle(
@@ -,7 +1116,7 @@ std::string IdentifierNamingCheck::fixupWithStyle(
 StyleKind IdentifierNamingCheck::findStyleKind(
 const NamedDecl *D,
 ArrayRef> NamingStyles,
-bool IgnoreMainLikeFunctions) const {
+bool IgnoreMainLikeFunctions, bool CheckAnonFieldInParentScope) const {
   assert(D && D->getIdentifier() && !D->getName().empty() && !D->isImplicit() 
&&
  "Decl must be an explicit identifier with a name.");
 
@@ -1185,29 +1190,14 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   }
 
   if (const auto *Decl = dyn_cast(D)) {
-QualType Type = Decl->getType();
-
-if (!Type.isNull() && Type.isConstQualified()) {
-  if (NamingStyles[SK_ConstantMember])
-return SK_ConstantMember;
-
-  if (NamingStyles[SK_Constant])
-return SK_Constant;
+if (CheckAnonFieldInParentScope) {
+  const RecordDecl *Record = Decl->getParent();
+  if (Record->isAnonymousStructOrUnion()) {
+return findStyleKindForAnonField(Decl, NamingStyles);
+  }
 }
 
-if (Decl->getAccess() == AS_private && NamingStyles[SK_PrivateMember])
-  return SK_PrivateMember;
-
-if (Decl->getAccess() == AS_protected && NamingStyles[SK_ProtectedMember])
-  return SK_ProtectedMember;
-
-if (Decl->getAccess() == AS_public && NamingStyles[SK_PublicMember])
-  return SK_PublicMember;
-
-if (NamingStyles[SK_Member])
-  return SK_Member;
-
-return SK_Invalid;
+return findStyleKindForField(Decl, Decl->getType(), NamingStyles);
   }
 

[clang-tools-extra] [clang-tidy] Treat fields in anonymous records as names in enclosing scope when checking name styles (PR #75701)

2023-12-16 Thread via cfe-commits

EugeneZelenko wrote:

Please mention changes in Release Notes.

https://github.com/llvm/llvm-project/pull/75701
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [clang] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

2023-12-16 Thread James Y Knight via cfe-commits

https://github.com/jyknight updated 
https://github.com/llvm/llvm-project/pull/74275

>From 7baffd6d1f4254b1bd725ddc883a360d79267435 Mon Sep 17 00:00:00 2001
From: James Y Knight 
Date: Sat, 2 Dec 2023 23:05:26 -0500
Subject: [PATCH 1/3] [X86] Use plain load/store instead of cmpxchg16b for
 atomics with AVX

In late 2021, both Intel and AMD finally documented that every
AVX-capable CPU has always been guaranteed to execute aligned 16-byte
loads/stores atomically, and further, guaranteed that all future CPUs
with AVX will do so as well.

Therefore, we may use normal SSE 128-bit load/store instructions to
implement atomics, if AVX is enabled.

Also adjust handling of unordered atomic load/store in LegalizeIntegerTypes.cpp;
currently, it hardcodes a fallback to ATOMIC_CMP_SWAP_WITH_SUCCESS,
but we should instead fallback to ATOMIC_LOAD/ATOMIC_STORE.

Per AMD64 Architecture Programmer's manual, 7.3.2 Access Atomicity:
"""
Processors that report [AVX] extend the atomicity for cacheable,
naturally-aligned single loads or stores from a quadword to a double
quadword.
"""

Per Intel's SDM:
"""
Processors that enumerate support for Intel(R) AVX guarantee that the
16-byte memory operations performed by the following instructions will
always be carried out atomically:
- MOVAPD, MOVAPS, and MOVDQA.
- VMOVAPD, VMOVAPS, and VMOVDQA when encoded with VEX.128.
- VMOVAPD, VMOVAPS, VMOVDQA32, and VMOVDQA64 when encoded with
  EVEX.128 and k0 (masking disabled).
"""

This was also confirmed to be true for Zhaoxin CPUs with AVX, in
https://gcc.gnu.org/PR104688
---
 .../SelectionDAG/LegalizeIntegerTypes.cpp |  28 +-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  94 +--
 llvm/test/CodeGen/X86/atomic-non-integer.ll   |  24 +-
 llvm/test/CodeGen/X86/atomic-unordered.ll |  83 +-
 llvm/test/CodeGen/X86/atomic128.ll| 247 +++---
 llvm/test/CodeGen/X86/cmpxchg-i128-i1.ll  |   8 +-
 6 files changed, 256 insertions(+), 228 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index 54698edce7d6f8..5b496feee7a8f4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -3831,17 +3831,14 @@ void DAGTypeLegalizer::ExpandIntRes_XROUND_XRINT(SDNode 
*N, SDValue &Lo,
 void DAGTypeLegalizer::ExpandIntRes_LOAD(LoadSDNode *N,
  SDValue &Lo, SDValue &Hi) {
   if (N->isAtomic()) {
-// It's typical to have larger CAS than atomic load instructions.
 SDLoc dl(N);
 EVT VT = N->getMemoryVT();
-SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
-SDValue Zero = DAG.getConstant(0, dl, VT);
-SDValue Swap = DAG.getAtomicCmpSwap(
-ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, dl,
-VT, VTs, N->getOperand(0),
-N->getOperand(1), Zero, Zero, N->getMemOperand());
-ReplaceValueWith(SDValue(N, 0), Swap.getValue(0));
-ReplaceValueWith(SDValue(N, 1), Swap.getValue(2));
+// We may support larger values in atomic_load than in a normal load
+// (without splitting), so switch over if needed.
+SDValue New = DAG.getAtomic(ISD::ATOMIC_LOAD, dl, VT, VT, N->getOperand(0),
+N->getOperand(1), N->getMemOperand());
+ReplaceValueWith(SDValue(N, 0), New.getValue(0));
+ReplaceValueWith(SDValue(N, 1), New.getValue(1));
 return;
   }
 
@@ -5399,14 +5396,13 @@ SDValue DAGTypeLegalizer::ExpandIntOp_XINT_TO_FP(SDNode 
*N) {
 
 SDValue DAGTypeLegalizer::ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo) {
   if (N->isAtomic()) {
-// It's typical to have larger CAS than atomic store instructions.
+// We may support larger values in atomic_store than in a normal store
+// (without splitting), so switch over if needed.
 SDLoc dl(N);
-SDValue Swap = DAG.getAtomic(ISD::ATOMIC_SWAP, dl,
- N->getMemoryVT(),
- N->getOperand(0), N->getOperand(2),
- N->getOperand(1),
- N->getMemOperand());
-return Swap.getValue(1);
+SDValue New =
+DAG.getAtomic(ISD::ATOMIC_STORE, dl, N->getMemoryVT(), 
N->getOperand(0),
+  N->getOperand(1), N->getOperand(2), N->getMemOperand());
+return New.getValue(0);
   }
   if (ISD::isNormalStore(N))
 return ExpandOp_NormalStore(N, OpNo);
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 6167be7bdf84e9..1880cbc3a5bf35 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -515,6 +515,13 @@ X86TargetLowering::X86TargetLowering(const 
X86TargetMachine &TM,
   if (!Subtarget.is64Bit())
 setOperationAction(ISD::ATOMIC_LOAD, MVT::i64, Custom);
 
+  if (Subtarget.is64Bit() && Subtarget.hasAVX()) {
+// All CPUs supporting AVX will atomically load/

[clang-tools-extra] [clang] [llvm] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

2023-12-16 Thread James Y Knight via cfe-commits


@@ -228,87 +228,86 @@ define void @widen_broadcast_unaligned(ptr %p0, i32 %v) {
 }
 
 define i128 @load_i128(ptr %ptr) {
-; CHECK-O0-LABEL: load_i128:
-; CHECK-O0:   # %bb.0:
-; CHECK-O0-NEXT:pushq %rbx
-; CHECK-O0-NEXT:.cfi_def_cfa_offset 16
-; CHECK-O0-NEXT:.cfi_offset %rbx, -16
-; CHECK-O0-NEXT:xorl %eax, %eax
-; CHECK-O0-NEXT:movl %eax, %ebx
-; CHECK-O0-NEXT:movq %rbx, %rax
-; CHECK-O0-NEXT:movq %rbx, %rdx
-; CHECK-O0-NEXT:movq %rbx, %rcx
-; CHECK-O0-NEXT:lock cmpxchg16b (%rdi)
-; CHECK-O0-NEXT:popq %rbx
-; CHECK-O0-NEXT:.cfi_def_cfa_offset 8
-; CHECK-O0-NEXT:retq
-;
-; CHECK-O3-LABEL: load_i128:
-; CHECK-O3:   # %bb.0:
-; CHECK-O3-NEXT:pushq %rbx
-; CHECK-O3-NEXT:.cfi_def_cfa_offset 16
-; CHECK-O3-NEXT:.cfi_offset %rbx, -16
-; CHECK-O3-NEXT:xorl %eax, %eax
-; CHECK-O3-NEXT:xorl %edx, %edx
-; CHECK-O3-NEXT:xorl %ecx, %ecx
-; CHECK-O3-NEXT:xorl %ebx, %ebx
-; CHECK-O3-NEXT:lock cmpxchg16b (%rdi)
-; CHECK-O3-NEXT:popq %rbx
-; CHECK-O3-NEXT:.cfi_def_cfa_offset 8
-; CHECK-O3-NEXT:retq
+; CHECK-O0-CUR-LABEL: load_i128:

jyknight wrote:

Done.

https://github.com/llvm/llvm-project/pull/74275
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

2023-12-16 Thread James Y Knight via cfe-commits


@@ -31259,14 +31274,23 @@ static SDValue LowerATOMIC_STORE(SDValue Op, 
SelectionDAG &DAG,
   if (!IsSeqCst && IsTypeLegal)
 return Op;
 
-  if (VT == MVT::i64 && !IsTypeLegal) {
+  if (!IsTypeLegal && !Subtarget.useSoftFloat() &&
+  !DAG.getMachineFunction().getFunction().hasFnAttribute(
+  Attribute::NoImplicitFloat)) {
+SDValue Chain;
+// For illegal i128 atomic_store, when AVX is enabled, we can simply emit a
+// vector store.
+if (VT == MVT::i128) {
+  if (Subtarget.is64Bit() && Subtarget.hasAVX()) {
+SDValue VecVal = DAG.getBitcast(MVT::v2i64, Node->getVal());
+Chain = DAG.getStore(Node->getChain(), dl, VecVal, Node->getBasePtr(),
+ Node->getMemOperand());
+  }
+}
+
 // For illegal i64 atomic_stores, we can try to use MOVQ or MOVLPS if SSE
 // is enabled.
-bool NoImplicitFloatOps =
-DAG.getMachineFunction().getFunction().hasFnAttribute(
-Attribute::NoImplicitFloat);
-if (!Subtarget.useSoftFloat() && !NoImplicitFloatOps) {
-  SDValue Chain;
+if (VT == MVT::i64) {
   if (Subtarget.hasSSE1()) {

jyknight wrote:

This has an "else if" attached, so better not to.

https://github.com/llvm/llvm-project/pull/74275
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [clang-tools-extra] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

2023-12-16 Thread James Y Knight via cfe-commits


@@ -30115,12 +30126,16 @@ 
X86TargetLowering::shouldExpandAtomicLoadInIR(LoadInst *LI) const {
   // If this a 64 bit atomic load on a 32-bit target and SSE2 is enabled, we
   // can use movq to do the load. If we have X87 we can load into an 80-bit
   // X87 register and store it to a stack temporary.

jyknight wrote:

Done.

https://github.com/llvm/llvm-project/pull/74275
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang-tools-extra] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

2023-12-16 Thread James Y Knight via cfe-commits


@@ -31259,14 +31274,23 @@ static SDValue LowerATOMIC_STORE(SDValue Op, 
SelectionDAG &DAG,
   if (!IsSeqCst && IsTypeLegal)
 return Op;
 
-  if (VT == MVT::i64 && !IsTypeLegal) {
+  if (!IsTypeLegal && !Subtarget.useSoftFloat() &&
+  !DAG.getMachineFunction().getFunction().hasFnAttribute(
+  Attribute::NoImplicitFloat)) {
+SDValue Chain;
+// For illegal i128 atomic_store, when AVX is enabled, we can simply emit a
+// vector store.
+if (VT == MVT::i128) {
+  if (Subtarget.is64Bit() && Subtarget.hasAVX()) {

jyknight wrote:

Done.

https://github.com/llvm/llvm-project/pull/74275
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Treat fields in anonymous records as names in enclosing scope when checking name styles (PR #75701)

2023-12-16 Thread Sirui Mu via cfe-commits

https://github.com/Lancern updated 
https://github.com/llvm/llvm-project/pull/75701

>From 5d04ca8091fc81fad8e33355a0afcce290bf34f0 Mon Sep 17 00:00:00 2001
From: Sirui Mu 
Date: Sat, 16 Dec 2023 21:55:24 +0800
Subject: [PATCH 1/3] [clang-tidy] Check anonymous record field naming in
 enclosing scopes

Currently, fields in anonymous records are regarded as normal fields when
checking their name styles. Naming rules for class/struct/union member apply to
these fields. This commit changes this behavior:

- If the anonymous record is defined within the file scope or in a namespace
  scope, treat its fields as global variables when checking name styles;
- If the anonymous record is defined within a function, treat its fields as
  local variables when checking name styles;
- If the anonymous record is defined within a non-anonymous record, treat its
  fields as non-static record members when checking name styles.
---
 .../readability/IdentifierNamingCheck.cpp | 196 ++
 .../readability/IdentifierNamingCheck.h   |  13 ++
 .../clang-tidy/utils/ASTUtils.cpp |  24 +++
 clang-tools-extra/clang-tidy/utils/ASTUtils.h |   5 +
 .../identifier-naming-anon-record-fields.cpp  | 184 
 5 files changed, 341 insertions(+), 81 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-anon-record-fields.cpp

diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 03dcfa5f811095..0e18712fd27564 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -9,6 +9,7 @@
 #include "IdentifierNamingCheck.h"
 
 #include "../GlobList.h"
+#include "../utils/ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1185,29 +1186,12 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   }
 
   if (const auto *Decl = dyn_cast(D)) {
-QualType Type = Decl->getType();
-
-if (!Type.isNull() && Type.isConstQualified()) {
-  if (NamingStyles[SK_ConstantMember])
-return SK_ConstantMember;
-
-  if (NamingStyles[SK_Constant])
-return SK_Constant;
+const RecordDecl *Record = Decl->getParent();
+if (Record->isAnonymousStructOrUnion()) {
+  return findStyleKindForAnonField(Decl, NamingStyles);
 }
 
-if (Decl->getAccess() == AS_private && NamingStyles[SK_PrivateMember])
-  return SK_PrivateMember;
-
-if (Decl->getAccess() == AS_protected && NamingStyles[SK_ProtectedMember])
-  return SK_ProtectedMember;
-
-if (Decl->getAccess() == AS_public && NamingStyles[SK_PublicMember])
-  return SK_PublicMember;
-
-if (NamingStyles[SK_Member])
-  return SK_Member;
-
-return SK_Invalid;
+return findStyleKindForField(Decl, Decl->getType(), NamingStyles);
   }
 
   if (const auto *Decl = dyn_cast(D)) {
@@ -1244,66 +1228,7 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   }
 
   if (const auto *Decl = dyn_cast(D)) {
-QualType Type = Decl->getType();
-
-if (Decl->isConstexpr() && NamingStyles[SK_ConstexprVariable])
-  return SK_ConstexprVariable;
-
-if (!Type.isNull() && Type.isConstQualified()) {
-  if (Decl->isStaticDataMember() && NamingStyles[SK_ClassConstant])
-return SK_ClassConstant;
-
-  if (Decl->isFileVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-  NamingStyles[SK_GlobalConstantPointer])
-return SK_GlobalConstantPointer;
-
-  if (Decl->isFileVarDecl() && NamingStyles[SK_GlobalConstant])
-return SK_GlobalConstant;
-
-  if (Decl->isStaticLocal() && NamingStyles[SK_StaticConstant])
-return SK_StaticConstant;
-
-  if (Decl->isLocalVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-  NamingStyles[SK_LocalConstantPointer])
-return SK_LocalConstantPointer;
-
-  if (Decl->isLocalVarDecl() && NamingStyles[SK_LocalConstant])
-return SK_LocalConstant;
-
-  if (Decl->isFunctionOrMethodVarDecl() && NamingStyles[SK_LocalConstant])
-return SK_LocalConstant;
-
-  if (NamingStyles[SK_Constant])
-return SK_Constant;
-}
-
-if (Decl->isStaticDataMember() && NamingStyles[SK_ClassMember])
-  return SK_ClassMember;
-
-if (Decl->isFileVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-NamingStyles[SK_GlobalPointer])
-  return SK_GlobalPointer;
-
-if (Decl->isFileVarDecl() && NamingStyles[SK_GlobalVariable])
-  return SK_GlobalVariable;
-
-if (Decl->isStaticLocal() && NamingStyles[SK_StaticVariable])
-  return SK_StaticVariable;
-
-if (Decl->isLocalVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-NamingStyles[SK_LocalPointer])
-  return SK_LocalPointer;
-
-if (Decl->isLocalVarDecl() && NamingStyles[SK_LocalVariable])
-  re

[clang-tools-extra] [clang-tidy] Treat fields in anonymous records as names in enclosing scope when checking name styles (PR #75701)

2023-12-16 Thread via cfe-commits


@@ -128,6 +128,11 @@ Improvements to clang-tidy
   as a value for `-export-fixes` to export individual yaml files for each
   compilation unit.
 
+- A new option `readability-identifier-naming.CheckAnonFieldInParent` is 
added. When set

EugeneZelenko wrote:

Please keep alphabetical order (by check name) in this section. If entry for 
`readability-identifier-naming` exists, append statement to it.

https://github.com/llvm/llvm-project/pull/75701
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [llvm] [flang] [clang] [compiler-rt] [libc] [clang-tools-extra] [libc++] Implement ranges::iota (PR #68494)

2023-12-16 Thread James E T Smith via cfe-commits

https://github.com/jamesETsmith updated 
https://github.com/llvm/llvm-project/pull/68494

>From c4a3ccfbad090ad8314aa8ad53092edc8d5432bc Mon Sep 17 00:00:00 2001
From: James Smith 
Date: Thu, 28 Sep 2023 10:11:15 -0400
Subject: [PATCH 01/17] [libc++] Implement ranges::iota and
 ranges::out_value_result

---
 libcxx/include/CMakeLists.txt |   2 +
 libcxx/include/__algorithm/out_value_result.h |  52 +
 libcxx/include/__numeric/ranges_iota.h|  53 +
 libcxx/include/algorithm  |   4 +
 libcxx/include/numeric|   1 +
 libcxx/include/version|   2 +-
 .../out_value_result.pass.cpp | 102 ++
 .../numeric.iota/ranges.iota.pass.cpp |  52 +
 8 files changed, 267 insertions(+), 1 deletion(-)
 create mode 100644 libcxx/include/__algorithm/out_value_result.h
 create mode 100644 libcxx/include/__numeric/ranges_iota.h
 create mode 100644 
libcxx/test/std/algorithms/algorithms.results/out_value_result.pass.cpp
 create mode 100644 
libcxx/test/std/numerics/numeric.ops/numeric.iota/ranges.iota.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 2ec755236dbaee..c6eb03f1d68e98 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -63,6 +63,7 @@ set(files
   __algorithm/next_permutation.h
   __algorithm/none_of.h
   __algorithm/nth_element.h
+  __algorithm/out_value_result.h
   __algorithm/partial_sort.h
   __algorithm/partial_sort_copy.h
   __algorithm/partition.h
@@ -561,6 +562,7 @@ set(files
   __numeric/partial_sum.h
   __numeric/pstl_reduce.h
   __numeric/pstl_transform_reduce.h
+  __numeric/ranges_iota.h
   __numeric/reduce.h
   __numeric/transform_exclusive_scan.h
   __numeric/transform_inclusive_scan.h
diff --git a/libcxx/include/__algorithm/out_value_result.h 
b/libcxx/include/__algorithm/out_value_result.h
new file mode 100644
index 00..8baffec7b9ef4d
--- /dev/null
+++ b/libcxx/include/__algorithm/out_value_result.h
@@ -0,0 +1,52 @@
+// -*- 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
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H
+#define _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+namespace ranges {
+
+template 
+struct out_value_result {
+  _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out;
+  _LIBCPP_NO_UNIQUE_ADDRESS _ValType1 value;
+
+  template 
+requires convertible_to && 
convertible_to
+  constexpr operator out_value_result<_OutIter2, _ValType2>() const& { return 
{out, value}; }
+
+  template 
+requires convertible_to<_OutIter1, _OutIter2> && convertible_to<_ValType1, 
_ValType2>
+  constexpr operator out_value_result<_OutIter2, _ValType2>() && { return 
{std::move(out), std::move(value)}; }
+};
+
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER >= 23
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H
diff --git a/libcxx/include/__numeric/ranges_iota.h 
b/libcxx/include/__numeric/ranges_iota.h
new file mode 100644
index 00..20311a68c2a348
--- /dev/null
+++ b/libcxx/include/__numeric/ranges_iota.h
@@ -0,0 +1,53 @@
+// -*- 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
+//
+//===--===//
+
+#ifndef _LIBCPP___NUMERIC_RANGES_IOTA_H
+#define _LIBCPP___NUMERIC_RANGES_IOTA_H
+
+#include <__algorithm/out_value_result.h>
+#include <__config>
+#include <__ranges/concepts.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+namespace ranges {
+template 
+using iota_result = ranges::out_value_result<_Out, _Tp>;
+
+struct __iota_fn {
+  template  _Sent, 
weakly_incrementable _Tp>
+requires indirectly_writable<_Out, const _Tp&>
+  constexpr iota_result<_Out, _Tp> operator()(_Out __first, _Sent __last, _Tp 
__value) const {
+while (__first != __last) {
+  *__first = static_cast(__value);
+  ++__first;
+  ++__value;
+}
+return {std::move(__first), std::move(__value)};
+

[clang] f49e2b0 - [clang][CGCUDANV] Unify PointerType members of CGNVCUDARuntime (NFC) (#75668)

2023-12-16 Thread via cfe-commits

Author: Youngsuk Kim
Date: 2023-12-16T11:47:37-05:00
New Revision: f49e2b05bf3ececa2fe20c5d658ab92ab974dc36

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

LOG: [clang][CGCUDANV] Unify PointerType members of CGNVCUDARuntime (NFC) 
(#75668)

Unify 3 `Pointertype *` members which all refer to the same llvm type.

Opaque pointer clean-up effort.

Added: 


Modified: 
clang/lib/CodeGen/CGCUDANV.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 520b0c4f117673..353370f1d761b9 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -39,7 +39,7 @@ class CGNVCUDARuntime : public CGCUDARuntime {
 private:
   llvm::IntegerType *IntTy, *SizeTy;
   llvm::Type *VoidTy;
-  llvm::PointerType *CharPtrTy, *VoidPtrTy, *VoidPtrPtrTy;
+  llvm::PointerType *PtrTy;
 
   /// Convenience reference to LLVM Context
   llvm::LLVMContext &Context;
@@ -232,15 +232,12 @@ CGNVCUDARuntime::CGNVCUDARuntime(CodeGenModule &CGM)
   VoidTy = CGM.VoidTy;
   Zeros[0] = llvm::ConstantInt::get(SizeTy, 0);
   Zeros[1] = Zeros[0];
-
-  CharPtrTy = CGM.UnqualPtrTy;
-  VoidPtrTy = CGM.UnqualPtrTy;
-  VoidPtrPtrTy = CGM.UnqualPtrTy;
+  PtrTy = CGM.UnqualPtrTy;
 }
 
 llvm::FunctionCallee CGNVCUDARuntime::getSetupArgumentFn() const {
   // cudaError_t cudaSetupArgument(void *, size_t, size_t)
-  llvm::Type *Params[] = {VoidPtrTy, SizeTy, SizeTy};
+  llvm::Type *Params[] = {PtrTy, SizeTy, SizeTy};
   return CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(IntTy, Params, false),
   addPrefixToName("SetupArgument"));
@@ -250,24 +247,24 @@ llvm::FunctionCallee CGNVCUDARuntime::getLaunchFn() const 
{
   if (CGM.getLangOpts().HIP) {
 // hipError_t hipLaunchByPtr(char *);
 return CGM.CreateRuntimeFunction(
-llvm::FunctionType::get(IntTy, CharPtrTy, false), "hipLaunchByPtr");
+llvm::FunctionType::get(IntTy, PtrTy, false), "hipLaunchByPtr");
   }
   // cudaError_t cudaLaunch(char *);
-  return CGM.CreateRuntimeFunction(
-  llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch");
+  return CGM.CreateRuntimeFunction(llvm::FunctionType::get(IntTy, PtrTy, 
false),
+   "cudaLaunch");
 }
 
 llvm::FunctionType *CGNVCUDARuntime::getRegisterGlobalsFnTy() const {
-  return llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false);
+  return llvm::FunctionType::get(VoidTy, PtrTy, false);
 }
 
 llvm::FunctionType *CGNVCUDARuntime::getCallbackFnTy() const {
-  return llvm::FunctionType::get(VoidTy, VoidPtrTy, false);
+  return llvm::FunctionType::get(VoidTy, PtrTy, false);
 }
 
 llvm::FunctionType *CGNVCUDARuntime::getRegisterLinkedBinaryFnTy() const {
-  llvm::Type *Params[] = {llvm::PointerType::getUnqual(Context), VoidPtrTy,
-  VoidPtrTy, llvm::PointerType::getUnqual(Context)};
+  llvm::Type *Params[] = {llvm::PointerType::getUnqual(Context), PtrTy, PtrTy,
+  llvm::PointerType::getUnqual(Context)};
   return llvm::FunctionType::get(VoidTy, Params, false);
 }
 
@@ -330,15 +327,15 @@ void 
CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction &CGF,
   // args, allocate a single pointer so we still have a valid pointer to the
   // argument array that we can pass to runtime, even if it will be unused.
   Address KernelArgs = CGF.CreateTempAlloca(
-  VoidPtrTy, CharUnits::fromQuantity(16), "kernel_args",
+  PtrTy, CharUnits::fromQuantity(16), "kernel_args",
   llvm::ConstantInt::get(SizeTy, std::max(1, Args.size(;
   // Store pointers to the arguments in a locally allocated launch_args.
   for (unsigned i = 0; i < Args.size(); ++i) {
 llvm::Value* VarPtr = CGF.GetAddrOfLocalVar(Args[i]).getPointer();
-llvm::Value *VoidVarPtr = CGF.Builder.CreatePointerCast(VarPtr, VoidPtrTy);
+llvm::Value *VoidVarPtr = CGF.Builder.CreatePointerCast(VarPtr, PtrTy);
 CGF.Builder.CreateDefaultAlignedStore(
 VoidVarPtr,
-CGF.Builder.CreateConstGEP1_32(VoidPtrTy, KernelArgs.getPointer(), i));
+CGF.Builder.CreateConstGEP1_32(PtrTy, KernelArgs.getPointer(), i));
   }
 
   llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
@@ -386,8 +383,7 @@ void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction 
&CGF,
   CGF.CreateMemTemp(Dim3Ty, CharUnits::fromQuantity(8), "block_dim");
   Address ShmemSize =
   CGF.CreateTempAlloca(SizeTy, CGM.getSizeAlign(), "shmem_size");
-  Address Stream =
-  CGF.CreateTempAlloca(VoidPtrTy, CGM.getPointerAlign(), "stream");
+  Address Stream = CGF.CreateTempAlloca(PtrTy, CGM.getPointerAlign(), 
"stream");
   llvm::FunctionCallee cudaPopConfigFn = CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(IntTy,
   {/*gridDim=*/GridDi

[clang] [clang][CGCUDANV] Unify PointerType members of CGNVCUDARuntime (NFC) (PR #75668)

2023-12-16 Thread Youngsuk Kim via cfe-commits

https://github.com/JOE1994 closed 
https://github.com/llvm/llvm-project/pull/75668
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2023-12-16 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti created 
https://github.com/llvm/llvm-project/pull/75706

Starting with a59b24be47ed6263c254d168567b9ebba391fac9, the severity of
diagnostics that have the 'Deprecated' tag is lowered to 'Remark'.
Because the `Deprecated` tag is applied to clang-tidy checks in
the modernize category, this leads to inconsistencies in reported
clang-tidy diagnostics.


>From fa6a69841102d529a31462affae5cdfabac417ff Mon Sep 17 00:00:00 2001
From: Julian Schmidt <44101708+5chmi...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 18:05:34 +0100
Subject: [PATCH] [clangd] don't lower severity of clang-tidy modernize-*
 checks to remarks

Starting with a59b24be47ed6263c254d168567b9ebba391fac9, the severity of
diagnostics that have the 'Deprecated' tag is lowered to 'Remark'.
Because the `Deprecated` tag is applied to clang-tidy checks in
the modernize category, this leads to inconsistencies in reported
clang-tidy diagnostics.
---
 clang-tools-extra/clangd/Diagnostics.cpp   |  6 --
 .../clangd/unittests/DiagnosticsTests.cpp  | 14 --
 clang-tools-extra/docs/ReleaseNotes.rst|  3 +++
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index 704e61b1e4dd79..a56d450fb44da1 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -474,8 +474,10 @@ void toLSPDiags(
   // We downgrade severity for certain noisy warnings, like deprecated
   // declartions. These already have visible decorations inside the editor and
   // most users find the extra clutter in the UI (gutter, minimap, diagnostics
-  // views) overwhelming.
-  if (D.Severity == DiagnosticsEngine::Warning) {
+  // views) overwhelming. Because clang-tidy's modernize checks get the
+  // `Deprecated` tag, guard against lowering clang-tidy diagnostic levels.
+  if (D.Severity == DiagnosticsEngine::Warning &&
+  D.Source != Diag::DiagSource::ClangTidy) {
 if (llvm::is_contained(D.Tags, DiagnosticTag::Deprecated))
   Main.severity = getSeverity(DiagnosticsEngine::Remark);
   }
diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 37643e5afa2304..b4f7cb71f15e57 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1811,10 +1811,10 @@ TEST(ParsedASTTest, ModuleSawDiag) {
   TestTU TU;
 
   auto AST = TU.build();
-#if 0
+#if 0
   EXPECT_THAT(AST.getDiagnostics(),
   testing::Contains(Diag(Code.range(), KDiagMsg.str(;
-#endif
+#endif
 }
 
 TEST(Preamble, EndsOnNonEmptyLine) {
@@ -1882,6 +1882,16 @@ TEST(Diagnostics, DeprecatedDiagsAreHints) {
   EXPECT_EQ(Diag->severity, getSeverity(DiagnosticsEngine::Remark));
   Diag.reset();
 
+  // Don't downgrade warnings from clang-tidy that have deprecated tags
+  D.Source = Diag::DiagSource::ClangTidy;
+  toLSPDiags(D, {}, Opts,
+ [&](clangd::Diagnostic LSPDiag, ArrayRef) {
+   Diag = std::move(LSPDiag);
+ });
+  EXPECT_EQ(Diag->severity, getSeverity(DiagnosticsEngine::Warning));
+  D.Source = Diag::DiagSource::Unknown;
+  Diag.reset();
+
   // Preserve errors.
   D.Severity = DiagnosticsEngine::Error;
   toLSPDiags(D, {}, Opts,
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d91748e4cef18..2d8d57a535e4a8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -54,6 +54,9 @@ Inlay hints
 Diagnostics
 ^^^
 
+- Fixed a bug where the severity of diagnostics from clang-tidy modernize-* 
checks were
+  lowered to remarks.
+
 Semantic Highlighting
 ^
 

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


[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: Julian Schmidt (5chmidti)


Changes

Starting with a59b24be47ed6263c254d168567b9ebba391fac9, the severity of
diagnostics that have the 'Deprecated' tag is lowered to 'Remark'.
Because the `Deprecated` tag is applied to clang-tidy checks in
the modernize category, this leads to inconsistencies in reported
clang-tidy diagnostics.


---
Full diff: https://github.com/llvm/llvm-project/pull/75706.diff


3 Files Affected:

- (modified) clang-tools-extra/clangd/Diagnostics.cpp (+4-2) 
- (modified) clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp (+12-2) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+3) 


``diff
diff --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index 704e61b1e4dd79..a56d450fb44da1 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -474,8 +474,10 @@ void toLSPDiags(
   // We downgrade severity for certain noisy warnings, like deprecated
   // declartions. These already have visible decorations inside the editor and
   // most users find the extra clutter in the UI (gutter, minimap, diagnostics
-  // views) overwhelming.
-  if (D.Severity == DiagnosticsEngine::Warning) {
+  // views) overwhelming. Because clang-tidy's modernize checks get the
+  // `Deprecated` tag, guard against lowering clang-tidy diagnostic levels.
+  if (D.Severity == DiagnosticsEngine::Warning &&
+  D.Source != Diag::DiagSource::ClangTidy) {
 if (llvm::is_contained(D.Tags, DiagnosticTag::Deprecated))
   Main.severity = getSeverity(DiagnosticsEngine::Remark);
   }
diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 37643e5afa2304..b4f7cb71f15e57 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1811,10 +1811,10 @@ TEST(ParsedASTTest, ModuleSawDiag) {
   TestTU TU;
 
   auto AST = TU.build();
-#if 0
+#if 0
   EXPECT_THAT(AST.getDiagnostics(),
   testing::Contains(Diag(Code.range(), KDiagMsg.str(;
-#endif
+#endif
 }
 
 TEST(Preamble, EndsOnNonEmptyLine) {
@@ -1882,6 +1882,16 @@ TEST(Diagnostics, DeprecatedDiagsAreHints) {
   EXPECT_EQ(Diag->severity, getSeverity(DiagnosticsEngine::Remark));
   Diag.reset();
 
+  // Don't downgrade warnings from clang-tidy that have deprecated tags
+  D.Source = Diag::DiagSource::ClangTidy;
+  toLSPDiags(D, {}, Opts,
+ [&](clangd::Diagnostic LSPDiag, ArrayRef) {
+   Diag = std::move(LSPDiag);
+ });
+  EXPECT_EQ(Diag->severity, getSeverity(DiagnosticsEngine::Warning));
+  D.Source = Diag::DiagSource::Unknown;
+  Diag.reset();
+
   // Preserve errors.
   D.Severity = DiagnosticsEngine::Error;
   toLSPDiags(D, {}, Opts,
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d91748e4cef18..2d8d57a535e4a8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -54,6 +54,9 @@ Inlay hints
 Diagnostics
 ^^^
 
+- Fixed a bug where the severity of diagnostics from clang-tidy modernize-* 
checks were
+  lowered to remarks.
+
 Semantic Highlighting
 ^
 

``




https://github.com/llvm/llvm-project/pull/75706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2023-12-16 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

Explicitly pinging @kadircet and @sam-mccall for your involvement in the 
mentioned commit. What are your thoughts on this? I looked into this because 
someone on discord asked about this difference.

https://github.com/llvm/llvm-project/pull/75706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2023-12-16 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

The tag for `modernize-*` checks gets added here:
https://github.com/llvm/llvm-project/blob/f49e2b05bf3ececa2fe20c5d658ab92ab974dc36/clang-tools-extra/clangd/Diagnostics.cpp#L392-L397

https://github.com/llvm/llvm-project/pull/75706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2023-12-16 Thread Julian Schmidt via cfe-commits


@@ -1811,10 +1811,10 @@ TEST(ParsedASTTest, ModuleSawDiag) {
   TestTU TU;
 
   auto AST = TU.build();
-#if 0
+#if 0

5chmidti wrote:

This formatting change slipped through, should I remove it?

https://github.com/llvm/llvm-project/pull/75706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [mlir] [flang] [clang-tools-extra] [libcxx] [openmp] [lldb] [compiler-rt] [libc] [clang] [lld] fix issue 73559. (PR #74926)

2023-12-16 Thread Antonio Frighetto via cfe-commits

antoniofrighetto wrote:

Could you kindly squash everything into one commit and provide a meaningful git 
commit title and git message description? For example:
```
[clang][Parse] `TryAnnotateCXXScopeToken` to be called only when parsing C++

Assume `TryAnnotateCXXScopeToken` to be parsing C++ code in all of its paths.

Fixes: https://github.com/llvm/llvm-project/issues/73559.
```

https://github.com/llvm/llvm-project/pull/74926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 395f9ce - Use StringRef::{starts,ends}_with (NFC)

2023-12-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-16T10:14:44-08:00
New Revision: 395f9ce30e884cb6ce02f7a3bdd0dd1f72ea9033

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

LOG: Use StringRef::{starts,ends}_with (NFC)

This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.

Added: 


Modified: 
clang/lib/Lex/HeaderSearch.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/DirectX/DXILResource.cpp
llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
llvm/lib/Target/SPIRV/SPIRVUtils.cpp
llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index a0ac0eaf2f9004..0f1090187734ff 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1671,7 +1671,7 @@ static OptionalFileEntryRef 
getPrivateModuleMap(FileEntryRef File,
 if (Filename == "module.map")
   Diags.Report(diag::warn_deprecated_module_dot_map)
   << PrivateFilename << 1
-  << File.getDir().getName().endswith(".framework");
+  << File.getDir().getName().ends_with(".framework");
   }
   return PMMFile;
 }

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 738ec301d14799..6b54047020a05d 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5220,7 +5220,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
   Res.append("-p7:160:256:256:32");
 if (!DL.contains("-p8") && !DL.starts_with("p8"))
   Res.append("-p8:128:128");
-if (!DL.contains("-p9") && !DL.startswith("p9"))
+if (!DL.contains("-p9") && !DL.starts_with("p9"))
   Res.append("-p9:192:256:256:32");
 
 return Res;

diff  --git a/llvm/lib/Target/DirectX/DXILResource.cpp 
b/llvm/lib/Target/DirectX/DXILResource.cpp
index 92306d907e0546..d3ff12a1f7b34d 100644
--- a/llvm/lib/Target/DirectX/DXILResource.cpp
+++ b/llvm/lib/Target/DirectX/DXILResource.cpp
@@ -261,7 +261,7 @@ void UAVResource::parseSourceType(StringRef S) {
   S = S.substr(S.find("<") + 1);
 
   constexpr size_t PrefixLen = StringRef("vector<").size();
-  if (S.startswith("vector<"))
+  if (S.starts_with("vector<"))
 S = S.substr(PrefixLen, S.find(",") - PrefixLen);
   else
 S = S.substr(0, S.find(">"));

diff  --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp 
b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
index 1af7b7a5d7845f..b69031adb16730 100644
--- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
+++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
@@ -177,7 +177,7 @@ std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn 
BuiltInValue) {
 bool getSpirvBuiltInIdByName(llvm::StringRef Name,
  SPIRV::BuiltIn::BuiltIn &BI) {
   const std::string Prefix = "__spirv_BuiltIn";
-  if (!Name.startswith(Prefix))
+  if (!Name.starts_with(Prefix))
 return false;
 
   const SPIRV::SymbolicOperand *Lookup =

diff  --git a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp 
b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
index ae9e801f8f50b8..5ac45079bd0026 100644
--- a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
@@ -872,8 +872,8 @@ static bool generateGroupInst(const SPIRV::IncomingCall 
*Call,
 std::tie(GroupResultRegister, GroupResultType) =
 buildBoolRegister(MIRBuilder, Call->ReturnType, GR);
 
-  auto Scope = Builtin->Name.startswith("sub_group") ? SPIRV::Scope::Subgroup
- : SPIRV::Scope::Workgroup;
+  auto Scope = Builtin->Name.starts_with("sub_group") ? SPIRV::Scope::Subgroup
+  : 
SPIRV::Scope::Workgroup;
   Register ScopeRegister = buildConstantIntReg(Scope, MIRBuilder, GR);
 
   // Build work/sub group instruction.
@@ -1999,13 +1999,13 @@ struct OpenCLType {
 
//===--===//
 
 static Type *parseTypeString(const StringRef Name, LLVMContext &Context) {
-  if (Name.startswith("void"))
+  if (Name.starts_with("void"))
 return Type::getVoidTy(Context);
-  else if (Name.startswith("int") || Name.startswith("uint"))
+  else if (Name.starts_with("int") || Name.starts_with("uint"))
 return Type::getInt32Ty(Context);
-  else if (Name.startswith("float"))
+  else if (Name.starts_with("float"))
 return Type::getFloatTy(Context);
-  else if (Name.starts

[compiler-rt] [clang] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2023-12-16 Thread Axel Lundberg via cfe-commits

https://github.com/Zonotora updated 
https://github.com/llvm/llvm-project/pull/75481

>From 8b76571cb7412f3520abf7df5c56cfc987ab7b6e Mon Sep 17 00:00:00 2001
From: Zonotora 
Date: Sat, 16 Dec 2023 19:33:21 +0100
Subject: [PATCH 1/2] [clang] Extract negativity check lambda to function

---
 clang/lib/CodeGen/CGExprScalar.cpp | 47 --
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 41ad2ddac30d2d..eb7cd8547d1889 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1094,6 +1094,27 @@ void ScalarExprEmitter::EmitIntegerTruncationCheck(Value 
*Src, QualType SrcType,
 {Src, Dst});
 }
 
+static llvm::Value *EmitIsNegativeTestHelper(Value *V, QualType VType,
+ const char *Name,
+ CGBuilderTy &Builder) {
+  // NOTE: zero value is considered to be non-negative.
+  // Is this value a signed type?
+  bool VSigned = VType->isSignedIntegerOrEnumerationType();
+  llvm::Type *VTy = V->getType();
+  if (!VSigned) {
+// If the value is unsigned, then it is never negative.
+// FIXME: can we encounter non-scalar VTy here?
+return llvm::ConstantInt::getFalse(VTy->getContext());
+  }
+  // Get the zero of the same type with which we will be comparing.
+  llvm::Constant *Zero = llvm::ConstantInt::get(VTy, 0);
+  // %V.isnegative = icmp slt %V, 0
+  // I.e is %V *strictly* less than zero, does it have negative value?
+  return Builder.CreateICmp(llvm::ICmpInst::ICMP_SLT, V, Zero,
+llvm::Twine(Name) + "." + V->getName() +
+".negativitycheck");
+};
+
 // Should be called within CodeGenFunction::SanitizerScope RAII scope.
 // Returns 'i1 false' when the conversion Src -> Dst changed the sign.
 static std::pair Value * {
-// Is this value a signed type?
-bool VSigned = VType->isSignedIntegerOrEnumerationType();
-llvm::Type *VTy = V->getType();
-if (!VSigned) {
-  // If the value is unsigned, then it is never negative.
-  // FIXME: can we encounter non-scalar VTy here?
-  return llvm::ConstantInt::getFalse(VTy->getContext());
-}
-// Get the zero of the same type with which we will be comparing.
-llvm::Constant *Zero = llvm::ConstantInt::get(VTy, 0);
-// %V.isnegative = icmp slt %V, 0
-// I.e is %V *strictly* less than zero, does it have negative value?
-return Builder.CreateICmp(llvm::ICmpInst::ICMP_SLT, V, Zero,
-  llvm::Twine(Name) + "." + V->getName() +
-  ".negativitycheck");
-  };
-
   // 1. Was the old Value negative?
-  llvm::Value *SrcIsNegative = EmitIsNegativeTest(Src, SrcType, "src");
+  llvm::Value *SrcIsNegative =
+  EmitIsNegativeTestHelper(Src, SrcType, "src", Builder);
   // 2. Is the new Value negative?
-  llvm::Value *DstIsNegative = EmitIsNegativeTest(Dst, DstType, "dst");
+  llvm::Value *DstIsNegative =
+  EmitIsNegativeTestHelper(Dst, DstType, "dst", Builder);
   // 3. Now, was the 'negativity status' preserved during the conversion?
   //NOTE: conversion from negative to zero is considered to change the 
sign.
   //(We want to get 'false' when the conversion changed the sign)

>From 73a92d16e06fc7c30bb582b86b9441e7ac560d2d Mon Sep 17 00:00:00 2001
From: Zonotora 
Date: Sat, 16 Dec 2023 19:36:04 +0100
Subject: [PATCH 2/2] [clang][UBSan] Add implicit conversion check for
 bitfields

This patch implements the implicit truncation and implicit
sign change checks for bitfields. However, right now some
unnecessary emits are generated which ideally would be removed
in the future.
---
 clang/lib/CodeGen/CGExprScalar.cpp| 262 +-
 .../test/CodeGen/ubsan-bitfield-conversion.c  |  27 ++
 compiler-rt/lib/ubsan/ubsan_diag.h|   2 +-
 compiler-rt/lib/ubsan/ubsan_handlers.cpp  |  10 +-
 compiler-rt/lib/ubsan/ubsan_handlers.h|   1 +
 5 files changed, 293 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CodeGen/ubsan-bitfield-conversion.c

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index eb7cd8547d1889..c93c5d89583d68 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -15,6 +15,7 @@
 #include "CGDebugInfo.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
@@ -324,6 +325,25 @@ class ScalarExprEmitter
   void EmitIntegerSignChangeCheck(Value *Src, QualType SrcType, Value *Dst,
   QualType DstType, SourceLocation Loc);
 
+  /// Emit a check that an [implicit] truncation of a bitfield does not
+  /// discard any bits. It is not UB, so we use the value after truncation.
+  void

[compiler-rt] [clang] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2023-12-16 Thread Axel Lundberg via cfe-commits


@@ -1094,6 +1114,27 @@ void ScalarExprEmitter::EmitIntegerTruncationCheck(Value 
*Src, QualType SrcType,
 {Src, Dst});
 }
 
+static llvm::Value *EmitIsNegativeTestHelper(Value *V, QualType VType,

Zonotora wrote:

fixed

https://github.com/llvm/llvm-project/pull/75481
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [clang] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2023-12-16 Thread Axel Lundberg via cfe-commits

Zonotora wrote:

> Is is UB?

Don't think so? To quote [1]:
> Issues caught by these sanitizers are not undefined behavior, but are often 
> unintentional.

where "these sanitizers" refer to `implicit-unsigned-integer-truncation`, 
`implicit-signed-integer-truncation` and `implicit-integer-sign-change`.

[1] https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

https://github.com/llvm/llvm-project/pull/75481
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [llvm] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-16 Thread via cfe-commits

https://github.com/SunilKuravinakop created 
https://github.com/llvm/llvm-project/pull/75709

This is a continuation of https://reviews.llvm.org/D123235 ([OpenMP] atomic 
compare fail : Parser & AST support). In this branch Support for codegen 
support for atomic compare fail is being added.

>From fe931d64741f427629407bca3e68a61bec6f2b67 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Sat, 16 Dec 2023 11:43:35 -0600
Subject: [PATCH] Adding parameter to fail clause (i.e. memory order clause)
 for codegen.

  Changes to be committed:
modified:   clang/lib/CodeGen/CGStmtOpenMP.cpp
---
 clang/lib/CodeGen/CGStmtOpenMP.cpp | 51 +++---
 1 file changed, 47 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 478d6dbf9ca81d..a502db7ac3a5e0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6516,10 +6516,6 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
  IsPostfixUpdate, IsFailOnly, Loc);
 break;
   }
-  case OMPC_fail: {
-//TODO
-break;
-  }
   default:
 llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
@@ -6527,6 +6523,8 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
 
 void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) {
   llvm::AtomicOrdering AO = llvm::AtomicOrdering::Monotonic;
+  // Fail Memory Clause Ordering.
+  llvm::AtomicOrdering FO = llvm::AtomicOrdering::Monotonic;
   bool MemOrderingSpecified = false;
   if (S.getSingleClause()) {
 AO = llvm::AtomicOrdering::SequentiallyConsistent;
@@ -6580,6 +6578,51 @@ void CodeGenFunction::EmitOMPAtomicDirective(const 
OMPAtomicDirective &S) {
 }
   }
 
+  if (KindsEncountered.contains(OMPC_compare) &&
+  KindsEncountered.contains(OMPC_fail)) {
+Kind = OMPC_compare;
+const OMPFailClause *fC = S.getSingleClause();
+if (fC) {
+  OpenMPClauseKind fP = fC->getFailParameter();
+  if (fP == llvm::omp::OMPC_relaxed)
+FO = llvm::AtomicOrdering::Monotonic;
+  else if (fP == llvm::omp::OMPC_acquire)
+FO = llvm::AtomicOrdering::Acquire;
+  else if (fP == llvm::omp::OMPC_seq_cst)
+FO = llvm::AtomicOrdering::SequentiallyConsistent;
+}
+
+// Logic for 2 memory order clauses in the atomic directive.
+// e.g. #pragma omp atomic compare capture release fail(seq_cst)
+//  if(x > e) { x = j; } else { k = x; }
+// To provide the Memory Order clause in atomic directive
+// there are 2 instructions in LLVM IR atomicrmw & cmpxchgl.
+// 1) atomicrmw can use only 1 memory order clause and can contain the
+//operator in if condition.
+// 2) cmpxchgl can use 2 memory order clauses : Success memory order clause
+//& fail parameter memory clause. However, cmpxchgl uses only equality
+//operator.
+// We need to change atomicrmw to contain the fail parameter clause or add
+// a new instruction in LLVM IR. Changes in LLVM IR need to be done
+// seperately and at present we will use the logic of using the more strict
+// memory order clause of success or fail memory order clauses for the
+// atomicrmw. The following logic takes care of this change in the memory
+// order clause.
+if (AO == llvm::AtomicOrdering::Monotonic)
+  AO = FO;
+else if (FO == llvm::AtomicOrdering::Monotonic)
+  AO = AO;
+else if (AO == llvm::AtomicOrdering::SequentiallyConsistent ||
+ FO == llvm::AtomicOrdering::SequentiallyConsistent)
+  AO = llvm::AtomicOrdering::SequentiallyConsistent;
+else if (AO == llvm::AtomicOrdering::Acquire)
+  AO = llvm::AtomicOrdering::Acquire;
+else if (AO == llvm::AtomicOrdering::Release)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+else if (AO == llvm::AtomicOrdering::AcquireRelease)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+  }
+
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(S.getAssociatedStmt());
   emitOMPAtomicExpr(*this, Kind, AO, S.isPostfixUpdate(), S.getX(), S.getV(),

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


[clang-tools-extra] [clang] [llvm] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: None (SunilKuravinakop)


Changes

This is a continuation of https://reviews.llvm.org/D123235 ([OpenMP] atomic 
compare fail : Parser & AST support). In this branch Support for codegen 
support for atomic compare fail is being added.

---
Full diff: https://github.com/llvm/llvm-project/pull/75709.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+47-4) 


``diff
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index ed426098ac6915..e2caa0d7742126 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6508,10 +6508,6 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
  IsPostfixUpdate, IsFailOnly, Loc);
 break;
   }
-  case OMPC_fail: {
-//TODO
-break;
-  }
   default:
 llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
@@ -6519,6 +6515,8 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
 
 void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) {
   llvm::AtomicOrdering AO = llvm::AtomicOrdering::Monotonic;
+  // Fail Memory Clause Ordering.
+  llvm::AtomicOrdering FO = llvm::AtomicOrdering::Monotonic;
   bool MemOrderingSpecified = false;
   if (S.getSingleClause()) {
 AO = llvm::AtomicOrdering::SequentiallyConsistent;
@@ -6572,6 +6570,51 @@ void CodeGenFunction::EmitOMPAtomicDirective(const 
OMPAtomicDirective &S) {
 }
   }
 
+  if (KindsEncountered.contains(OMPC_compare) &&
+  KindsEncountered.contains(OMPC_fail)) {
+Kind = OMPC_compare;
+const OMPFailClause *fC = S.getSingleClause();
+if (fC) {
+  OpenMPClauseKind fP = fC->getFailParameter();
+  if (fP == llvm::omp::OMPC_relaxed)
+FO = llvm::AtomicOrdering::Monotonic;
+  else if (fP == llvm::omp::OMPC_acquire)
+FO = llvm::AtomicOrdering::Acquire;
+  else if (fP == llvm::omp::OMPC_seq_cst)
+FO = llvm::AtomicOrdering::SequentiallyConsistent;
+}
+
+// Logic for 2 memory order clauses in the atomic directive.
+// e.g. #pragma omp atomic compare capture release fail(seq_cst)
+//  if(x > e) { x = j; } else { k = x; }
+// To provide the Memory Order clause in atomic directive
+// there are 2 instructions in LLVM IR atomicrmw & cmpxchgl.
+// 1) atomicrmw can use only 1 memory order clause and can contain the
+//operator in if condition.
+// 2) cmpxchgl can use 2 memory order clauses : Success memory order clause
+//& fail parameter memory clause. However, cmpxchgl uses only equality
+//operator.
+// We need to change atomicrmw to contain the fail parameter clause or add
+// a new instruction in LLVM IR. Changes in LLVM IR need to be done
+// seperately and at present we will use the logic of using the more strict
+// memory order clause of success or fail memory order clauses for the
+// atomicrmw. The following logic takes care of this change in the memory
+// order clause.
+if (AO == llvm::AtomicOrdering::Monotonic)
+  AO = FO;
+else if (FO == llvm::AtomicOrdering::Monotonic)
+  AO = AO;
+else if (AO == llvm::AtomicOrdering::SequentiallyConsistent ||
+ FO == llvm::AtomicOrdering::SequentiallyConsistent)
+  AO = llvm::AtomicOrdering::SequentiallyConsistent;
+else if (AO == llvm::AtomicOrdering::Acquire)
+  AO = llvm::AtomicOrdering::Acquire;
+else if (AO == llvm::AtomicOrdering::Release)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+else if (AO == llvm::AtomicOrdering::AcquireRelease)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+  }
+
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(S.getAssociatedStmt());
   emitOMPAtomicExpr(*this, Kind, AO, S.isPostfixUpdate(), S.getX(), S.getV(),

``




https://github.com/llvm/llvm-project/pull/75709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [clang-tools-extra] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (SunilKuravinakop)


Changes

This is a continuation of https://reviews.llvm.org/D123235 ([OpenMP] atomic 
compare fail : Parser & AST support). In this branch Support for codegen 
support for atomic compare fail is being added.

---
Full diff: https://github.com/llvm/llvm-project/pull/75709.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+47-4) 


``diff
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index ed426098ac6915..e2caa0d7742126 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6508,10 +6508,6 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
  IsPostfixUpdate, IsFailOnly, Loc);
 break;
   }
-  case OMPC_fail: {
-//TODO
-break;
-  }
   default:
 llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
@@ -6519,6 +6515,8 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
 
 void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) {
   llvm::AtomicOrdering AO = llvm::AtomicOrdering::Monotonic;
+  // Fail Memory Clause Ordering.
+  llvm::AtomicOrdering FO = llvm::AtomicOrdering::Monotonic;
   bool MemOrderingSpecified = false;
   if (S.getSingleClause()) {
 AO = llvm::AtomicOrdering::SequentiallyConsistent;
@@ -6572,6 +6570,51 @@ void CodeGenFunction::EmitOMPAtomicDirective(const 
OMPAtomicDirective &S) {
 }
   }
 
+  if (KindsEncountered.contains(OMPC_compare) &&
+  KindsEncountered.contains(OMPC_fail)) {
+Kind = OMPC_compare;
+const OMPFailClause *fC = S.getSingleClause();
+if (fC) {
+  OpenMPClauseKind fP = fC->getFailParameter();
+  if (fP == llvm::omp::OMPC_relaxed)
+FO = llvm::AtomicOrdering::Monotonic;
+  else if (fP == llvm::omp::OMPC_acquire)
+FO = llvm::AtomicOrdering::Acquire;
+  else if (fP == llvm::omp::OMPC_seq_cst)
+FO = llvm::AtomicOrdering::SequentiallyConsistent;
+}
+
+// Logic for 2 memory order clauses in the atomic directive.
+// e.g. #pragma omp atomic compare capture release fail(seq_cst)
+//  if(x > e) { x = j; } else { k = x; }
+// To provide the Memory Order clause in atomic directive
+// there are 2 instructions in LLVM IR atomicrmw & cmpxchgl.
+// 1) atomicrmw can use only 1 memory order clause and can contain the
+//operator in if condition.
+// 2) cmpxchgl can use 2 memory order clauses : Success memory order clause
+//& fail parameter memory clause. However, cmpxchgl uses only equality
+//operator.
+// We need to change atomicrmw to contain the fail parameter clause or add
+// a new instruction in LLVM IR. Changes in LLVM IR need to be done
+// seperately and at present we will use the logic of using the more strict
+// memory order clause of success or fail memory order clauses for the
+// atomicrmw. The following logic takes care of this change in the memory
+// order clause.
+if (AO == llvm::AtomicOrdering::Monotonic)
+  AO = FO;
+else if (FO == llvm::AtomicOrdering::Monotonic)
+  AO = AO;
+else if (AO == llvm::AtomicOrdering::SequentiallyConsistent ||
+ FO == llvm::AtomicOrdering::SequentiallyConsistent)
+  AO = llvm::AtomicOrdering::SequentiallyConsistent;
+else if (AO == llvm::AtomicOrdering::Acquire)
+  AO = llvm::AtomicOrdering::Acquire;
+else if (AO == llvm::AtomicOrdering::Release)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+else if (AO == llvm::AtomicOrdering::AcquireRelease)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+  }
+
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(S.getAssociatedStmt());
   emitOMPAtomicExpr(*this, Kind, AO, S.isPostfixUpdate(), S.getX(), S.getV(),

``




https://github.com/llvm/llvm-project/pull/75709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[openmp] [libc] [compiler-rt] [flang] [mlir] [lldb] [clang-tools-extra] [llvm] [clang] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/14] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// static_assert(t

[openmp] [libc] [compiler-rt] [flang] [mlir] [lldb] [clang-tools-extra] [llvm] [clang] [libcxx] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-16 Thread Hristo Hristov via cfe-commits




H-G-Hristov wrote:

Thank you for noticing. Somehow what should have been ignored snuck in back 
again.

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add `intrin0.h` header to mimic `intrin0.h` used by MSVC STL for clang-cl (PR #75711)

2023-12-16 Thread via cfe-commits

https://github.com/MaxEW707 created 
https://github.com/llvm/llvm-project/pull/75711

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

 Description 

Provide `intrin0.h` to be the minimal set of intrinsics that the MSVC STL 
requires.
The `intrin0.h` header matches the latest header provided by MSVC 1939 which 
does include some extra intrinsics that the MSVC STL does not use.

Inside `BuiltinHeaders.def` I kept the header description as `intrin.h`. If you 
want me to change those to `intrin0.h` for the moved intrinsics let me know.

This should now allow `immintrin.h` to be used with function targets for 
runtime cpu detection of simd instruction sets without worrying about the 
compile-time overhead from MSVC STL including `intrin.h` on clang.

I still need to figure out how to best update MSVC STL to detect for the 
presence on `intrin0.h` from clang and to use this header over `intrin.h`.

 Testing 

Built clang locally and ran the test suite. I still need to do a pass over the 
existing unit tests for the ms intrinsics to make sure there aren't any gaps. 
Wanted to get this PR up for discussion first.

Modified latest MSVC STL from github to point to `intrin0.h` for clang.

Wrote some test files that included MSVC STL headers that rely on intrinsics 
such as `atomic`, `bit` and `vector`. Built the unit tests against x86, arm, 
aarch64, and x64.

 Benchmarks 

The following include times are based on the x64 target with the modified 
headers in this PR.
These timings were done by using `clang-cl.exe -ftime-trace` and taking the 
wall time for parsing `intrin.h` and `intrin0.h`.

`intrin.h` takes ~897ms to parse.
`intrin0.h` takes ~1ms to parse.

If there is anything required or a different approach is preferred let me know. 
I would very much like to move this over the finish line so we can use function 
targets with clang-cl.

>From 8cd6db09c511ad8fde0e54e96cf3019da5b40d6e Mon Sep 17 00:00:00 2001
From: MaxEW707 <82551778+maxew...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 13:54:16 -0500
Subject: [PATCH] Add `intrin0.h` header to mimic `intrin0.h` used by msvc stl

---
 clang/lib/Headers/CMakeLists.txt |   1 +
 clang/lib/Headers/immintrin.h| 166 +++---
 clang/lib/Headers/intrin.h   | 216 +---
 clang/lib/Headers/intrin0.h  | 233 +++
 4 files changed, 319 insertions(+), 297 deletions(-)
 create mode 100644 clang/lib/Headers/intrin0.h

diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index f8fdd402777e48..e5ce039d5789ad 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -252,6 +252,7 @@ set(x86_files
   )
 
 set(windows_only_files
+  intrin0.h
   intrin.h
   vadefs.h
 )
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 9bfe2fcdabdb3a..f57cd385455c22 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -16,62 +16,62 @@
 
 #include 
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__MMX__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE2__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE3__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSSE3__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 (defined(__SSE4_2__) || defined(__SSE4_1__))
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 (defined(__AES__) || defined(__PCLMUL__))
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__CLFLUSHOPT__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__CLWB__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__AVX__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || _

[clang] [clang] Add `intrin0.h` header to mimic `intrin0.h` used by MSVC STL for clang-cl (PR #75711)

2023-12-16 Thread via cfe-commits

github-actions[bot] wrote:

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/75711
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add `intrin0.h` header to mimic `intrin0.h` used by MSVC STL for clang-cl (PR #75711)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (MaxEW707)


Changes

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

 Description 

Provide `intrin0.h` to be the minimal set of intrinsics that the MSVC STL 
requires.
The `intrin0.h` header matches the latest header provided by MSVC 1939 which 
does include some extra intrinsics that the MSVC STL does not use.

Inside `BuiltinHeaders.def` I kept the header description as `intrin.h`. If you 
want me to change those to `intrin0.h` for the moved intrinsics let me know.

This should now allow `immintrin.h` to be used with function targets for 
runtime cpu detection of simd instruction sets without worrying about the 
compile-time overhead from MSVC STL including `intrin.h` on clang.

I still need to figure out how to best update MSVC STL to detect for the 
presence on `intrin0.h` from clang and to use this header over `intrin.h`.

 Testing 

Built clang locally and ran the test suite. I still need to do a pass over the 
existing unit tests for the ms intrinsics to make sure there aren't any gaps. 
Wanted to get this PR up for discussion first.

Modified latest MSVC STL from github to point to `intrin0.h` for clang.

Wrote some test files that included MSVC STL headers that rely on intrinsics 
such as `atomic`, `bit` and `vector`. Built the unit tests against x86, arm, 
aarch64, and x64.

 Benchmarks 

The following include times are based on the x64 target with the modified 
headers in this PR.
These timings were done by using `clang-cl.exe -ftime-trace` and taking the 
wall time for parsing `intrin.h` and `intrin0.h`.

`intrin.h` takes ~897ms to parse.
`intrin0.h` takes ~1ms to parse.

If there is anything required or a different approach is preferred let me know. 
I would very much like to move this over the finish line so we can use function 
targets with clang-cl.

---

Patch is 46.59 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/75711.diff


4 Files Affected:

- (modified) clang/lib/Headers/CMakeLists.txt (+1) 
- (modified) clang/lib/Headers/immintrin.h (+83-83) 
- (modified) clang/lib/Headers/intrin.h (+2-214) 
- (added) clang/lib/Headers/intrin0.h (+233) 


``diff
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index f8fdd402777e48..e5ce039d5789ad 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -252,6 +252,7 @@ set(x86_files
   )
 
 set(windows_only_files
+  intrin0.h
   intrin.h
   vadefs.h
 )
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 9bfe2fcdabdb3a..f57cd385455c22 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -16,62 +16,62 @@
 
 #include 
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__MMX__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE2__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE3__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSSE3__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 (defined(__SSE4_2__) || defined(__SSE4_1__))
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 (defined(__AES__) || defined(__PCLMUL__))
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__CLFLUSHOPT__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__CLWB__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__AVX__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__AVX2__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) ||

[clang] [clang] Add `intrin0.h` header to mimic `intrin0.h` used by MSVC STL for clang-cl (PR #75711)

2023-12-16 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff b3e353d263f9d6ef061f4e6d89619c72a3553002 
8cd6db09c511ad8fde0e54e96cf3019da5b40d6e -- clang/lib/Headers/intrin0.h 
clang/lib/Headers/immintrin.h clang/lib/Headers/intrin.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index f57cd38545..02877c5709 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -16,281 +16,239 @@
 
 #include 
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__MMX__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__MMX__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__SSE__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__SSE2__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE2__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__SSE3__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE3__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__SSSE3__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__SSSE3__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
+#if !defined(__SCE__) || __has_feature(modules) || 
\
 (defined(__SSE4_2__) || defined(__SSE4_1__))
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
+#if !defined(__SCE__) || __has_feature(modules) || 
\
 (defined(__AES__) || defined(__PCLMUL__))
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__CLFLUSHOPT__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__CLFLUSHOPT__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__CLWB__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__CLWB__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__AVX__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__AVX2__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX2__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__F16C__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__F16C__)
 #include 
 #endif
 
 /* No feature check desired due to internal checks */
 #include 
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__BMI2__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__BMI2__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__LZCNT__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__LZCNT__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__POPCNT__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__POPCNT__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__FMA__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__FMA__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__AVX512F__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512F__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__AVX512VL__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VL__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__AVX512BW__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512BW__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__AVX512BITALG__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512BITALG__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__AVX512CD__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512CD__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defined(__AVX512VPOPCNTDQ__)
+#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VPOPCNTDQ__)
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
+#if !defined(__SCE__) || __has_feature(modules) || 
\
 (defined(__AVX512VL__) && defined(__AVX512VPOPCNTDQ__))
 #include 
 #endif
 
-#if !defined(__SCE__) || __has_feature(modules) ||  \
-defi

[clang] [clang] Add `intrin0.h` header to mimic `intrin0.h` used by MSVC STL for clang-cl (PR #75711)

2023-12-16 Thread via cfe-commits

https://github.com/MaxEW707 updated 
https://github.com/llvm/llvm-project/pull/75711

>From 8cd6db09c511ad8fde0e54e96cf3019da5b40d6e Mon Sep 17 00:00:00 2001
From: MaxEW707 <82551778+maxew...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 13:54:16 -0500
Subject: [PATCH 1/3] Add `intrin0.h` header to mimic `intrin0.h` used by msvc
 stl

---
 clang/lib/Headers/CMakeLists.txt |   1 +
 clang/lib/Headers/immintrin.h| 166 +++---
 clang/lib/Headers/intrin.h   | 216 +---
 clang/lib/Headers/intrin0.h  | 233 +++
 4 files changed, 319 insertions(+), 297 deletions(-)
 create mode 100644 clang/lib/Headers/intrin0.h

diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index f8fdd402777e48..e5ce039d5789ad 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -252,6 +252,7 @@ set(x86_files
   )
 
 set(windows_only_files
+  intrin0.h
   intrin.h
   vadefs.h
 )
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 9bfe2fcdabdb3a..f57cd385455c22 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -16,62 +16,62 @@
 
 #include 
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__MMX__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE2__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSE3__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__SSSE3__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 (defined(__SSE4_2__) || defined(__SSE4_1__))
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 (defined(__AES__) || defined(__PCLMUL__))
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__CLFLUSHOPT__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__CLWB__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__AVX__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__AVX2__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__F16C__)
 #include 
 #endif
@@ -79,217 +79,217 @@
 /* No feature check desired due to internal checks */
 #include 
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__BMI2__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__LZCNT__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__POPCNT__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__FMA__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__AVX512F__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__AVX512VL__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
+#if !defined(__SCE__) || __has_feature(modules) ||  \
 defined(__AVX512BW__)
 #include 
 #endif
 
-#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  

[clang-tools-extra] [clangd] don't lower severity of clang-tidy modernize-* checks to remarks (PR #75706)

2023-12-16 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> Explicitly pinging @kadircet and @sam-mccall for your involvement in the 
> mentioned commit. What are your thoughts on this? I looked into this because 
> someone on discord asked about this difference.

Added Sam and Kadir as reviewers.

This patch seems to contradict the explicit motivation of the previous one 
expressed in this code comment:

```c++
  // We downgrade severity for certain noisy warnings, like deprecated
  // declartions. These already have visible decorations inside the editor and
  // most users find the extra clutter in the UI (gutter, minimap, diagnostics
  // views) overwhelming.
```

I think clang-tidy "modernize" warnings can definitely be noisy in this way.

That said, we've also received feedback that the strike-through style that some 
editors apply for the `Deprecated` tag is even more distracting than the 
underline (https://github.com/clangd/vscode-clangd/issues/482).

https://github.com/llvm/llvm-project/pull/75706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [mlir] [MLIR][Linalg] Support dynamic sizes in `lower_unpack` (PR #75494)

2023-12-16 Thread via cfe-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/75494

>From 3879e633f4e4ba36ca24e6a870942b695ac935e0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Wed, 13 Dec 2023 15:25:31 -0600
Subject: [PATCH 1/6] [MLIR][Linalg] Support dynamic sizes in `lower_unpack`

---
 .../Dialect/Linalg/Transforms/Transforms.cpp  | 20 +--
 .../Dialect/Linalg/transform-lower-pack.mlir  |  4 ++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 10dfbe6cec781d..e66cf4c271d656 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -381,11 +381,6 @@ FailureOr 
linalg::lowerUnPack(RewriterBase &rewriter,
 return rewriter.notifyMatchFailure(unPackOp, "outer dims perm NYI");
 
   RankedTensorType packedTensorType = unPackOp.getSourceType();
-  if (!packedTensorType.hasStaticShape()) {
-return rewriter.notifyMatchFailure(
-unPackOp,
-"non-static shape NYI, needs a more powerful tensor.expand_shape op");
-  }
 
   Location loc = unPackOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
@@ -434,8 +429,21 @@ FailureOr 
linalg::lowerUnPack(RewriterBase &rewriter,
   RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape);
   RankedTensorType collapsedType = tensor::CollapseShapeOp::inferCollapsedType(
   stripMinedTensorType, packingMetadata.reassociations);
+
+  // Get dynamic dims for stripMined shape
+  SmallVector dims(llvm::map_range(
+  llvm::seq(0, packedTensorType.getRank()), [&](int64_t i) {
+return rewriter.create(loc, unPackOp.getSource(), i);
+  }));
+  applyPermutationToVector(dims, lastDimsToInsertPositionsPerm);
+  SmallVector dynDims;
+  for (int64_t i = 0; i < stripMinedTensorType.getRank(); i++) {
+if (stripMinedTensorType.isDynamicDim(i))
+  dynDims.push_back(dims[i]);
+  }
+
   auto emptyOp =
-  rewriter.create(loc, stripMinedTensorType, 
ValueRange{});
+  rewriter.create(loc, stripMinedTensorType, dynDims);
   auto transposeOp = rewriter.create(
   loc, unPackOp.getSource(), emptyOp, lastDimsToInsertPositionsPerm);
 
diff --git a/mlir/test/Dialect/Linalg/transform-lower-pack.mlir 
b/mlir/test/Dialect/Linalg/transform-lower-pack.mlir
index b9706eed54b608..8849ae6084f3ba 100644
--- a/mlir/test/Dialect/Linalg/transform-lower-pack.mlir
+++ b/mlir/test/Dialect/Linalg/transform-lower-pack.mlir
@@ -428,6 +428,8 @@ module attributes {transform.with_named_sequence} {
 // Check that we can lower unpack with dynamic dimensions in the destination.
 // CHECK-LABEL: func.func @unpack_with_dynamic_dest(
 // CHECK-SAME: %[[ARG0:.*]]: tensor<32x2x49x16x16xf32>, %[[ARG1:.*]]: 
tensor<32x?x?xf32>)
+//  CHECK-DAG:  %[[C1:.*]] = arith.constant 1 : index
+//  CHECK-DAG: %[[C2:.*]] = arith.constant 2 : index
 //  CHECK: %[[EMPTY:.*]] = tensor.empty() : tensor<32x2x16x49x16xf32>
 //  CHECK: %[[TRAN:.*]] = linalg.transpose
 // CHECK-SAME:ins(%[[ARG0]] : tensor<32x2x49x16x16xf32>)
@@ -435,9 +437,7 @@ module attributes {transform.with_named_sequence} {
 // CHECK-SAME:   permutation = [0, 1, 3, 2, 4]
 //  CHECK: %[[CLP:.*]] = tensor.collapse_shape %[[TRAN]] {{\[}}[0], [1, 
2], [3, 4]]
 // CHECK-SAME:   : tensor<32x2x16x49x16xf32> into tensor<32x32x784xf32>
-//  CHECK:  %[[C1:.*]] = arith.constant 1 : index
 //  CHECK: %[[DIM1:.*]] = tensor.dim %[[ARG1]], %[[C1]] : 
tensor<32x?x?xf32>
-//  CHECK: %[[C2:.*]] = arith.constant 2 : index
 //  CHECK: %[[DIM2:.*]] = tensor.dim %[[ARG1]], %[[C2]] : 
tensor<32x?x?xf32>
 //  CHECK: %[[SLICE:.*]] = tensor.extract_slice %[[CLP]][0, 0, 0] [32, 
%[[DIM1]], %[[DIM2]]] [1, 1, 1]
 // CHECK-SAME:   : tensor<32x32x784xf32> to tensor<32x?x?xf32>

>From 67d8304adf538cf38bff8c380931203828ae0b7c Mon Sep 17 00:00:00 2001
From: Sam 
Date: Thu, 14 Dec 2023 01:37:37 -0600
Subject: [PATCH 2/6] Add test

---
 .../Dialect/Linalg/Transforms/Transforms.cpp  |  8 ++--
 .../Dialect/Linalg/transform-lower-pack.mlir  | 42 +++
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index e66cf4c271d656..276bf1045eee3a 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -430,13 +430,15 @@ FailureOr 
linalg::lowerUnPack(RewriterBase &rewriter,
   RankedTensorType collapsedType = tensor::CollapseShapeOp::inferCollapsedType(
   stripMinedTensorType, packingMetadata.reassociations);
 
-  // Get dynamic dims for stripMined shape
-  SmallVector dims(llvm::map_range(
+  // Get dynamic dims from input tensor in order of stripMinedTensor
+  // `tensor.empty` op
+  SmallVector dims(llvm::map_range(
   llvm::seq(0, packedTensorType.getRank()), [&](int64_t i) {
 return rewriter.

[libcxx] [llvm] [flang] [clang-tools-extra] [clang] [libc] [mlir] [libc++][memory] P1132R8: out_ptr - a scalable output pointer abstraction (PR #73618)

2023-12-16 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 93b14c3df17500e675f31674165b5378dd0b4eaf 
d7c04396da8d0c6b2270643a3a079e5cd95e887a -- libcxx/include/__memory/inout_ptr.h 
libcxx/include/__memory/out_ptr.h 
libcxx/test/std/utilities/smartptr/adapt/inout_ptr/inout_ptr.general.pass.cpp 
libcxx/test/std/utilities/smartptr/adapt/inout_ptr/inout_ptr.verify.cpp 
libcxx/test/std/utilities/smartptr/adapt/inout_ptr/inout_ptr_t.convert.pass.cpp 
libcxx/test/std/utilities/smartptr/adapt/inout_ptr/inout_ptr_t.ctor.pass.cpp 
libcxx/test/std/utilities/smartptr/adapt/inout_ptr/inout_ptr_t.verify.cpp 
libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr.general.pass.cpp 
libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr.verify.cpp 
libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr_t.convert.pass.cpp 
libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr_t.ctor.pass.cpp 
libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr_t.verify.cpp 
libcxx/test/std/utilities/smartptr/adapt/types.h 
libcxx/include/__memory/allocator_traits.h 
libcxx/include/__memory/pointer_traits.h libcxx/include/memory 
libcxx/include/version libcxx/modules/std/memory.inc 
libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp
 
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr_t.ctor.pass.cpp 
b/libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr_t.ctor.pass.cpp
index 0ec834cc2f..474ab3c162 100644
--- a/libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr_t.ctor.pass.cpp
+++ b/libcxx/test/std/utilities/smartptr/adapt/out_ptr/out_ptr_t.ctor.pass.cpp
@@ -29,7 +29,7 @@ int main(int, char**) {
 
 static_assert(!test_convertible, 
int*>>(), "This constructor must be explicit");
   }
-  
+
   {
 std::unique_ptr> uPtr;
 

``




https://github.com/llvm/llvm-project/pull/73618
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] In compilation databases, add support for relative directories (PR #69856)

2023-12-16 Thread via cfe-commits

Overhatted wrote:

The use-case is the example project here: 
https://github.com/facebook/buck2/pull/517

The documentation update was done here: 
https://github.com/llvm/llvm-project/pull/69856/commits/7a92e0a3996ea3f518b6c3d740e1122902668308#diff-33e467b29775682c8ee8d50375fcabec58ebe215acebf15151f451a82b9c5e67
 which I think is the only place requiring an update.

For the moment I'm passing in the workspace folder to the Buck2 script 
generating the compilation database which is a good workaround. But I think 
this would be a nice feature either way.

I wanted this to work on Windows as well and I don't know of a workaround 
similar to "/proc/self/cwd" on Windows.

Let me know what you think.

https://github.com/llvm/llvm-project/pull/69856
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] b8f89b8 - Use StringRef::{starts, ends}_with (NFC)

2023-12-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-16T15:02:17-08:00
New Revision: b8f89b84bc26c46a5a10d01eb5414fbde3c8700a

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

LOG: Use StringRef::{starts,ends}_with (NFC)

This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang/test/Index/recursive-cxx-member-calls.cpp
libc/utils/HdrGen/Generator.cpp
mlir/examples/toy/Ch2/toyc.cpp
mlir/examples/toy/Ch3/toyc.cpp
mlir/examples/toy/Ch4/toyc.cpp
mlir/examples/toy/Ch5/toyc.cpp
mlir/examples/toy/Ch6/toyc.cpp
mlir/examples/toy/Ch7/toyc.cpp
openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h
openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index e108d4d0b057ba..4ef3ab6f9af9c2 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -451,7 +451,7 @@ std::unique_ptr makeLogger(llvm::StringRef 
LogPrefix,
   void log(Level L, const char *Fmt,
const llvm::formatv_object_base &Message) override {
 if (Context::current().get(CurrentRequest) == nullptr ||
-llvm::StringRef(Fmt).startswith("[public]"))
+llvm::StringRef(Fmt).starts_with("[public]"))
   return StreamLogger::log(L, Fmt, Message);
 if (L >= Error)
   return StreamLogger::log(L, Fmt,

diff  --git a/clang/test/Index/recursive-cxx-member-calls.cpp 
b/clang/test/Index/recursive-cxx-member-calls.cpp
index be908c506e7476..48fc8f14544c48 100644
--- a/clang/test/Index/recursive-cxx-member-calls.cpp
+++ b/clang/test/Index/recursive-cxx-member-calls.cpp
@@ -99,7 +99,7 @@ using namespace clang;
 
 AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
   llvm::StringRef AttrName = Name->getName();
-  if (AttrName.startswith("__") && AttrName.endswith("__"))
+  if (AttrName.starts_with("__") && AttrName.ends_with("__"))
 AttrName = AttrName.substr(2, AttrName.size() - 4);
 
   return llvm::StringSwitch < AttributeList::Kind > (AttrName)

diff  --git a/libc/utils/HdrGen/Generator.cpp b/libc/utils/HdrGen/Generator.cpp
index 24d22680fe525b..3bcf005adda74f 100644
--- a/libc/utils/HdrGen/Generator.cpp
+++ b/libc/utils/HdrGen/Generator.cpp
@@ -57,7 +57,7 @@ void Generator::parseCommandArgs(llvm::StringRef ArgStr, 
ArgVector &Args) {
   ArgStr.split(Args, ",");
   for (llvm::StringRef &A : Args) {
 A = A.trim(' ');
-if (A.startswith(ParamNamePrefix) && A.endswith(ParamNameSuffix)) {
+if (A.starts_with(ParamNamePrefix) && A.ends_with(ParamNameSuffix)) {
   A = A.drop_front(ParamNamePrefixSize).drop_back(ParamNameSuffixSize);
   A = ArgMap[std::string(A)];
 }
@@ -80,7 +80,7 @@ void Generator::generate(llvm::raw_ostream &OS, 
llvm::RecordKeeper &Records) {
 Content = P.second;
 
 llvm::StringRef Line = P.first.trim(' ');
-if (Line.startswith(CommandPrefix)) {
+if (Line.starts_with(CommandPrefix)) {
   Line = Line.drop_front(CommandPrefixSize);
 
   P = Line.split("(");
@@ -107,7 +107,7 @@ void Generator::generate(llvm::raw_ostream &OS, 
llvm::RecordKeeper &Records) {
   Command::ErrorReporter Reporter(
   llvm::SMLoc::getFromPointer(CommandName.data()), SrcMgr);
   Cmd->run(OS, Args, StdHeader, Records, Reporter);
-} else if (!Line.startswith(CommentPrefix)) {
+} else if (!Line.starts_with(CommentPrefix)) {
   // There is no comment or command on this line so we just write it as is.
   OS << P.first << "\n";
 }

diff  --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp
index fa431972e211ef..e33b49b41c5a1d 100644
--- a/mlir/examples/toy/Ch2/toyc.cpp
+++ b/mlir/examples/toy/Ch2/toyc.cpp
@@ -78,7 +78,7 @@ int dumpMLIR() {
 
   // Handle '.toy' input to the compiler.
   if (inputType != InputType::MLIR &&
-  !llvm::StringRef(inputFilename).endswith(".mlir")) {
+  !llvm::StringRef(inputFilename).ends_with(".mlir")) {
 auto moduleAST = parseInputFile(inputFilename);
 if (!moduleAST)
   return 6;

diff  --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp
index 8c27a7af97a002..c2c5f1fe1ba17b 100644
--- a/mlir/examples/toy/Ch3/toyc.cpp
+++ b/mlir/examples/toy/Ch3/toyc.cpp
@@ -82,7 +82,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext 
&context,
  mlir::OwningOpRef &modul

[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread Chris Apple via cfe-commits

https://github.com/cjappl created 
https://github.com/llvm/llvm-project/pull/75721

I found this handy for situations where you want to pass in a config file and 
not rely on a default `.clang-tidy` file.


The new option is `-config` and will expect something that can be passed into 
the `--config-file=` parameter of `clang-tidy`

>From 433f4ac919a6967c278e56a19b5824e474ebd907 Mon Sep 17 00:00:00 2001
From: Chris Apple <14171107+cja...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 15:53:56 -0800
Subject: [PATCH] Add ability to pass in a clang-tidy config file to
 clang-tidy-diff

---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 8817e2914f6e25..fdaf1a4330e060 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -223,6 +223,12 @@ def main():
 default=[],
 help="Load the specified plugin in clang-tidy.",
 )
+parser.add_argument(
+"-config",
+dest="config",
+default=None,
+help="Specifies a clang-tidy config file"
+)
 
 clang_tidy_args = []
 argv = sys.argv[1:]
@@ -309,6 +315,8 @@ def main():
 
 # Form the common args list.
 common_clang_tidy_args = []
+if args.config is not None:
+common_clang_tidy_args.append("--config-file=" + args.config)
 if args.fix:
 common_clang_tidy_args.append("-fix")
 if args.checks != "":

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


[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread via cfe-commits

github-actions[bot] wrote:

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/75721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Chris Apple (cjappl)


Changes

I found this handy for situations where you want to pass in a config file and 
not rely on a default `.clang-tidy` file.


The new option is `-config` and will expect something that can be passed into 
the `--config-file=` parameter of `clang-tidy`

---
Full diff: https://github.com/llvm/llvm-project/pull/75721.diff


1 Files Affected:

- (modified) clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py (+8) 


``diff
diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 8817e2914f6e25..fdaf1a4330e060 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -223,6 +223,12 @@ def main():
 default=[],
 help="Load the specified plugin in clang-tidy.",
 )
+parser.add_argument(
+"-config",
+dest="config",
+default=None,
+help="Specifies a clang-tidy config file"
+)
 
 clang_tidy_args = []
 argv = sys.argv[1:]
@@ -309,6 +315,8 @@ def main():
 
 # Form the common args list.
 common_clang_tidy_args = []
+if args.config is not None:
+common_clang_tidy_args.append("--config-file=" + args.config)
 if args.fix:
 common_clang_tidy_args.append("-fix")
 if args.checks != "":

``




https://github.com/llvm/llvm-project/pull/75721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread Chris Apple via cfe-commits

cjappl wrote:

@njames93 friendly ping for a review on this PR. Thank you in advance!

https://github.com/llvm/llvm-project/pull/75721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
0ca95b269ff90afb706e2cf4c4a59d7c3afe6c65...433f4ac919a6967c278e56a19b5824e474ebd907
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
``





View the diff from darker here.


``diff
--- clang-tidy-diff.py  2023-12-16 23:53:56.00 +
+++ clang-tidy-diff.py  2023-12-16 23:58:40.770370 +
@@ -225,11 +225,11 @@
 )
 parser.add_argument(
 "-config",
 dest="config",
 default=None,
-help="Specifies a clang-tidy config file"
+help="Specifies a clang-tidy config file",
 )
 
 clang_tidy_args = []
 argv = sys.argv[1:]
 if "--" in argv:

``




https://github.com/llvm/llvm-project/pull/75721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2aaeef1 - [Index] Fix recursive-cxx-member-calls.cpp

2023-12-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-16T16:24:32-08:00
New Revision: 2aaeef1fad0c1b233f6d3ca67a6c05877dc9e998

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

LOG: [Index] Fix recursive-cxx-member-calls.cpp

b8f89b84bc26c46a5a10d01eb5414fbde3c8700a inadvertently replaced
startswith/endswith with starts_with/ends_with even though the test
uses a custom StringRef.  This patch reverts the change.

Added: 


Modified: 
clang/test/Index/recursive-cxx-member-calls.cpp

Removed: 




diff  --git a/clang/test/Index/recursive-cxx-member-calls.cpp 
b/clang/test/Index/recursive-cxx-member-calls.cpp
index 48fc8f14544c48..be908c506e7476 100644
--- a/clang/test/Index/recursive-cxx-member-calls.cpp
+++ b/clang/test/Index/recursive-cxx-member-calls.cpp
@@ -99,7 +99,7 @@ using namespace clang;
 
 AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
   llvm::StringRef AttrName = Name->getName();
-  if (AttrName.starts_with("__") && AttrName.ends_with("__"))
+  if (AttrName.startswith("__") && AttrName.endswith("__"))
 AttrName = AttrName.substr(2, AttrName.size() - 4);
 
   return llvm::StringSwitch < AttributeList::Kind > (AttrName)



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


[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread Chris Apple via cfe-commits

https://github.com/cjappl updated 
https://github.com/llvm/llvm-project/pull/75721

>From 433f4ac919a6967c278e56a19b5824e474ebd907 Mon Sep 17 00:00:00 2001
From: Chris Apple <14171107+cja...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 15:53:56 -0800
Subject: [PATCH 1/2] Add ability to pass in a clang-tidy config file to
 clang-tidy-diff

---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 8817e2914f6e25..fdaf1a4330e060 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -223,6 +223,12 @@ def main():
 default=[],
 help="Load the specified plugin in clang-tidy.",
 )
+parser.add_argument(
+"-config",
+dest="config",
+default=None,
+help="Specifies a clang-tidy config file"
+)
 
 clang_tidy_args = []
 argv = sys.argv[1:]
@@ -309,6 +315,8 @@ def main():
 
 # Form the common args list.
 common_clang_tidy_args = []
+if args.config is not None:
+common_clang_tidy_args.append("--config-file=" + args.config)
 if args.fix:
 common_clang_tidy_args.append("-fix")
 if args.checks != "":

>From ff3e289814d8af2c3c8eea12e3ee3c48959aa79a Mon Sep 17 00:00:00 2001
From: Chris Apple <14171107+cja...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 16:42:28 -0800
Subject: [PATCH 2/2] Fix style

---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index fdaf1a4330e060..e20b7a2cda2dde 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -227,7 +227,7 @@ def main():
 "-config",
 dest="config",
 default=None,
-help="Specifies a clang-tidy config file"
+help="Specifies a clang-tidy config file",
 )
 
 clang_tidy_args = []

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


[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread Chris Apple via cfe-commits

https://github.com/cjappl updated 
https://github.com/llvm/llvm-project/pull/75721

>From 433f4ac919a6967c278e56a19b5824e474ebd907 Mon Sep 17 00:00:00 2001
From: Chris Apple <14171107+cja...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 15:53:56 -0800
Subject: [PATCH 1/3] Add ability to pass in a clang-tidy config file to
 clang-tidy-diff

---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 8817e2914f6e25..fdaf1a4330e060 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -223,6 +223,12 @@ def main():
 default=[],
 help="Load the specified plugin in clang-tidy.",
 )
+parser.add_argument(
+"-config",
+dest="config",
+default=None,
+help="Specifies a clang-tidy config file"
+)
 
 clang_tidy_args = []
 argv = sys.argv[1:]
@@ -309,6 +315,8 @@ def main():
 
 # Form the common args list.
 common_clang_tidy_args = []
+if args.config is not None:
+common_clang_tidy_args.append("--config-file=" + args.config)
 if args.fix:
 common_clang_tidy_args.append("-fix")
 if args.checks != "":

>From ff3e289814d8af2c3c8eea12e3ee3c48959aa79a Mon Sep 17 00:00:00 2001
From: Chris Apple <14171107+cja...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 16:42:28 -0800
Subject: [PATCH 2/3] Fix style

---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index fdaf1a4330e060..e20b7a2cda2dde 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -227,7 +227,7 @@ def main():
 "-config",
 dest="config",
 default=None,
-help="Specifies a clang-tidy config file"
+help="Specifies a clang-tidy config file",
 )
 
 clang_tidy_args = []

>From 05ae28f6705a7bccf36bbb3a84a17c3597b44c09 Mon Sep 17 00:00:00 2001
From: Chris Apple <14171107+cja...@users.noreply.github.com>
Date: Sat, 16 Dec 2023 16:51:41 -0800
Subject: [PATCH 3/3] Update ReleaseNotes

---
 clang-tools-extra/docs/ReleaseNotes.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d91748e4cef18..0e2679e4fafb0e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -124,6 +124,10 @@ Improvements to clang-tidy
   exporting fixes fails. It now accepts a directory as a value for
   `-export-fixes` to export individual yaml files for each compilation unit.
 
+- Improved :program:`clang-tidy-diff.py` script. It now accepts a `-config` 
option
+  to pass in a configuration file to :program:`clang-tidy`. This option 
corresponds
+  to the `--config-file` option in :program:`clang-tidy`.
+
 - Improved :program:`run-clang-tidy.py` script. It now accepts a directory
   as a value for `-export-fixes` to export individual yaml files for each
   compilation unit.

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


[clang-tools-extra] Allow to pass config file to clang-tidy-diff (PR #75457)

2023-12-16 Thread Chris Apple via cfe-commits

cjappl wrote:

@MichaelLettrich I just realized I submitted basically the same PR as you! 
Great minds think alike. I found yours when I searched.

https://github.com/llvm/llvm-project/pull/75721

In this PR I added to the release notes, feel free to steal them if you want. I 
would love this feature in `main`

https://github.com/llvm/llvm-project/pull/75457
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread Chris Apple via cfe-commits

https://github.com/cjappl closed https://github.com/llvm/llvm-project/pull/75721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add ability to pass in a clang-tidy config file to clang-tidy-diff (PR #75721)

2023-12-16 Thread Chris Apple via cfe-commits

cjappl wrote:

This is almost exactly the same as #75457 , just with the release notes. I'm 
going to close this for now and re-open it if that one gets stale.

https://github.com/llvm/llvm-project/pull/75721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add `intrin0.h` header to mimic `intrin0.h` used by MSVC STL for clang-cl (PR #75711)

2023-12-16 Thread via cfe-commits

https://github.com/MaxEW707 edited 
https://github.com/llvm/llvm-project/pull/75711
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [LTO] Improve diagnostics handling when parsing module-level inline assembly (PR #75726)

2023-12-16 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/75726

Non-LTO compiles set the buffer name to ""
(`AsmPrinter::addInlineAsmDiagBuffer`) and pass diagnostics to
`ClangDiagnosticHandler` (through the `MCContext` handler in
`MachineModuleInfoWrapperPass::doInitialization`) to ensure that
the exit code is 1 in the presence of errors. In contrast, LTO compiles
spuriously succeed even if error messages are printed.

```
% cat a.c
void _start() {}
asm("unknown instruction");
% clang -c a.c
:1:1: error: invalid instruction mnemonic 'unknown'
1 | unknown instruction
  | ^
1 error generated.
% clang -c -flto a.c; echo $?  # -flto=thin is the same
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~
0
```

`CollectAsmSymbols` parses inline assembly and is transitively called by
both `ModuleSummaryIndexAnalysis::run` and `WriteBitcodeToFile`, leading
to duplicate diagnostics.

This patch updates `CollectAsmSymbols` to be similar to non-LTO
compiles.
```
% clang -c -flto=thin a.c; echo $?
:1:1: error: invalid instruction mnemonic 'unknown'
1 | unknown instruction
  | ^
1 errors generated.
1
```

The `HasErrors` check does not prevent duplicate warnings but assembler
warnings are very uncommon.


>From ddce8597697261dd48ffd81761518496d391b55e Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 10 Dec 2023 10:13:59 -0800
Subject: [PATCH] [LTO] Improve diagnostics handling when parsing module-level
 inline assembly

Non-LTO compiles set the buffer name to ""
(`AsmPrinter::addInlineAsmDiagBuffer`) and pass diagnostics to
`ClangDiagnosticHandler` (through the `MCContext` handler in
`MachineModuleInfoWrapperPass::doInitialization`) to ensure that
the exit code is 1 in the presence of errors. In contrast, LTO compiles
spuriously succeed even if error messages are printed.

```
% cat a.c
void _start() {}
asm("unknown instruction");
% clang -c a.c
:1:1: error: invalid instruction mnemonic 'unknown'
1 | unknown instruction
  | ^
1 error generated.
% clang -c -flto a.c; echo $?  # -flto=thin is the same
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~
0
```

`CollectAsmSymbols` parses inline assembly and is transitively called by
both `ModuleSummaryIndexAnalysis::run` and `WriteBitcodeToFile`, leading
to duplicate diagnostics.

This patch updates `CollectAsmSymbols` to be similar to non-LTO
compiles.
```
% clang -c -flto=thin a.c; echo $?
:1:1: error: invalid instruction mnemonic 'unknown'
1 | unknown instruction
  | ^
1 errors generated.
1
```

The `HasErrors` check does not prevent duplicate warnings but assembler
warnings are very uncommon.
---
 clang/lib/CodeGen/CodeGenAction.cpp  |  2 ++
 clang/test/CodeGen/invalid_global_asm.c  |  5 +
 llvm/include/llvm/IR/DiagnosticHandler.h |  1 +
 llvm/lib/Object/ModuleSymbolTable.cpp| 16 +++-
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 753a8fd74fa696..4121a3709bc3af 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -418,6 +418,8 @@ void BackendConsumer::anchor() { }
 } // namespace clang
 
 bool ClangDiagnosticHandler::handleDiagnostics(const DiagnosticInfo &DI) {
+  if (DI.getSeverity() == DS_Error)
+HasErrors = true;
   BackendCon->DiagnosticHandlerImpl(DI);
   return true;
 }
diff --git a/clang/test/CodeGen/invalid_global_asm.c 
b/clang/test/CodeGen/invalid_global_asm.c
index 5b7e8b43d752d8..d5645f7fc92bf4 100644
--- a/clang/test/CodeGen/invalid_global_asm.c
+++ b/clang/test/CodeGen/invalid_global_asm.c
@@ -1,5 +1,10 @@
 // REQUIRES: arm-registered-target
 // RUN: not %clang_cc1 -emit-obj -triple armv6-unknown-unknown -o %t %s 2>&1 | 
FileCheck %s
+// RUN: not %clang_cc1 -emit-obj -triple armv6-unknown-unknown -flto -o %t %s 
2>&1 | FileCheck %s
+
+/// Test the diagnostic behavior considering the whole system including the 
driver.
+// RUN: not %clang --target=armv6-unknown-unknown -c -flto=thin -o %t %s 2>&1 
| FileCheck %s
 #pragma clang diagnostic ignored "-Wmissing-noreturn"
 __asm__(".Lfoo: movw r2, #:lower16:.Lbar - .Lfoo");
 // CHECK: :1:8: error: instruction requires: armv6t2
+// CHECK-NOT: error:
diff --git a/llvm/include/llvm/IR/DiagnosticHandler.h 
b/llvm/include/llvm/IR/DiagnosticHandler.h
index 55e5e5975808d9..db7d7444f75f05 100644
--- a/llvm/include/llvm/IR/DiagnosticHandler.h
+++ b/llvm/include/llvm/IR/DiagnosticHandler.h
@@ -23,6 +23,7 @@ class DiagnosticInfo;
 /// which remarks are enabled.
 struct DiagnosticHandler {
   void *DiagnosticContext = nullptr;
+  bool HasErrors = false;
   DiagnosticHandler(void *DiagContext = nullptr)
   : DiagnosticContext(DiagContext) {}
   virtual ~DiagnosticHandler() = default;
diff --git a/llvm/lib/Obj

[clang] [llvm] [LTO] Improve diagnostics handling when parsing module-level inline assembly (PR #75726)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Fangrui Song (MaskRay)


Changes

Non-LTO compiles set the buffer name to ""
(`AsmPrinter::addInlineAsmDiagBuffer`) and pass diagnostics to
`ClangDiagnosticHandler` (through the `MCContext` handler in
`MachineModuleInfoWrapperPass::doInitialization`) to ensure that
the exit code is 1 in the presence of errors. In contrast, LTO compiles
spuriously succeed even if error messages are printed.

```
% cat a.c
void _start() {}
asm("unknown instruction");
% clang -c a.c
:1:1: error: invalid instruction mnemonic 'unknown'
1 | unknown instruction
  | ^
1 error generated.
% clang -c -flto a.c; echo $?  # -flto=thin is the same
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~
0
```

`CollectAsmSymbols` parses inline assembly and is transitively called by
both `ModuleSummaryIndexAnalysis::run` and `WriteBitcodeToFile`, leading
to duplicate diagnostics.

This patch updates `CollectAsmSymbols` to be similar to non-LTO
compiles.
```
% clang -c -flto=thin a.c; echo $?
:1:1: error: invalid instruction mnemonic 'unknown'
1 | unknown instruction
  | ^
1 errors generated.
1
```

The `HasErrors` check does not prevent duplicate warnings but assembler
warnings are very uncommon.


---
Full diff: https://github.com/llvm/llvm-project/pull/75726.diff


4 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenAction.cpp (+2) 
- (modified) clang/test/CodeGen/invalid_global_asm.c (+5) 
- (modified) llvm/include/llvm/IR/DiagnosticHandler.h (+1) 
- (modified) llvm/lib/Object/ModuleSymbolTable.cpp (+15-1) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 753a8fd74fa696..4121a3709bc3af 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -418,6 +418,8 @@ void BackendConsumer::anchor() { }
 } // namespace clang
 
 bool ClangDiagnosticHandler::handleDiagnostics(const DiagnosticInfo &DI) {
+  if (DI.getSeverity() == DS_Error)
+HasErrors = true;
   BackendCon->DiagnosticHandlerImpl(DI);
   return true;
 }
diff --git a/clang/test/CodeGen/invalid_global_asm.c 
b/clang/test/CodeGen/invalid_global_asm.c
index 5b7e8b43d752d8..d5645f7fc92bf4 100644
--- a/clang/test/CodeGen/invalid_global_asm.c
+++ b/clang/test/CodeGen/invalid_global_asm.c
@@ -1,5 +1,10 @@
 // REQUIRES: arm-registered-target
 // RUN: not %clang_cc1 -emit-obj -triple armv6-unknown-unknown -o %t %s 2>&1 | 
FileCheck %s
+// RUN: not %clang_cc1 -emit-obj -triple armv6-unknown-unknown -flto -o %t %s 
2>&1 | FileCheck %s
+
+/// Test the diagnostic behavior considering the whole system including the 
driver.
+// RUN: not %clang --target=armv6-unknown-unknown -c -flto=thin -o %t %s 2>&1 
| FileCheck %s
 #pragma clang diagnostic ignored "-Wmissing-noreturn"
 __asm__(".Lfoo: movw r2, #:lower16:.Lbar - .Lfoo");
 // CHECK: :1:8: error: instruction requires: armv6t2
+// CHECK-NOT: error:
diff --git a/llvm/include/llvm/IR/DiagnosticHandler.h 
b/llvm/include/llvm/IR/DiagnosticHandler.h
index 55e5e5975808d9..db7d7444f75f05 100644
--- a/llvm/include/llvm/IR/DiagnosticHandler.h
+++ b/llvm/include/llvm/IR/DiagnosticHandler.h
@@ -23,6 +23,7 @@ class DiagnosticInfo;
 /// which remarks are enabled.
 struct DiagnosticHandler {
   void *DiagnosticContext = nullptr;
+  bool HasErrors = false;
   DiagnosticHandler(void *DiagContext = nullptr)
   : DiagnosticContext(DiagContext) {}
   virtual ~DiagnosticHandler() = default;
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp 
b/llvm/lib/Object/ModuleSymbolTable.cpp
index ab073e18cb4668..07f76688fa43e7 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -16,6 +16,7 @@
 #include "RecordStreamer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalAlias.h"
 #include "llvm/IR/GlobalValue.h"
@@ -68,6 +69,11 @@ void ModuleSymbolTable::addModule(Module *M) {
 static void
 initializeRecordStreamer(const Module &M,
  function_ref Init) {
+  // This function may be called twice, once for ModuleSummaryIndexAnalysis and
+  // the other when writing the IR symbol table. If parsing inline assembly has
+  // caused errors in the first run, suppress the second run.
+  if (M.getContext().getDiagHandlerPtr()->HasErrors)
+return;
   StringRef InlineAsm = M.getModuleInlineAsm();
   if (InlineAsm.empty())
 return;
@@ -95,7 +101,8 @@ initializeRecordStreamer(const Module &M,
   if (!MCII)
 return;
 
-  std::unique_ptr Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
+  std::unique_ptr Buffer(
+  MemoryBuffer::getMemBuffer(InlineAsm, ""));
   SourceMgr SrcMgr;
   SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 
@@ -115,6 +122,13 @@ initializeRecordStreamer(const Module &M,

[llvm] [clang] [LTO] Improve diagnostics handling when parsing module-level inline assembly (PR #75726)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-binary-utilities

Author: Fangrui Song (MaskRay)


Changes

Non-LTO compiles set the buffer name to ""
(`AsmPrinter::addInlineAsmDiagBuffer`) and pass diagnostics to
`ClangDiagnosticHandler` (through the `MCContext` handler in
`MachineModuleInfoWrapperPass::doInitialization`) to ensure that
the exit code is 1 in the presence of errors. In contrast, LTO compiles
spuriously succeed even if error messages are printed.

```
% cat a.c
void _start() {}
asm("unknown instruction");
% clang -c a.c
:1:1: error: invalid instruction mnemonic 'unknown'
1 | unknown instruction
  | ^
1 error generated.
% clang -c -flto a.c; echo $?  # -flto=thin is the same
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~
0
```

`CollectAsmSymbols` parses inline assembly and is transitively called by
both `ModuleSummaryIndexAnalysis::run` and `WriteBitcodeToFile`, leading
to duplicate diagnostics.

This patch updates `CollectAsmSymbols` to be similar to non-LTO
compiles.
```
% clang -c -flto=thin a.c; echo $?
:1:1: error: invalid instruction mnemonic 'unknown'
1 | unknown instruction
  | ^
1 errors generated.
1
```

The `HasErrors` check does not prevent duplicate warnings but assembler
warnings are very uncommon.


---
Full diff: https://github.com/llvm/llvm-project/pull/75726.diff


4 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenAction.cpp (+2) 
- (modified) clang/test/CodeGen/invalid_global_asm.c (+5) 
- (modified) llvm/include/llvm/IR/DiagnosticHandler.h (+1) 
- (modified) llvm/lib/Object/ModuleSymbolTable.cpp (+15-1) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 753a8fd74fa696..4121a3709bc3af 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -418,6 +418,8 @@ void BackendConsumer::anchor() { }
 } // namespace clang
 
 bool ClangDiagnosticHandler::handleDiagnostics(const DiagnosticInfo &DI) {
+  if (DI.getSeverity() == DS_Error)
+HasErrors = true;
   BackendCon->DiagnosticHandlerImpl(DI);
   return true;
 }
diff --git a/clang/test/CodeGen/invalid_global_asm.c 
b/clang/test/CodeGen/invalid_global_asm.c
index 5b7e8b43d752d8..d5645f7fc92bf4 100644
--- a/clang/test/CodeGen/invalid_global_asm.c
+++ b/clang/test/CodeGen/invalid_global_asm.c
@@ -1,5 +1,10 @@
 // REQUIRES: arm-registered-target
 // RUN: not %clang_cc1 -emit-obj -triple armv6-unknown-unknown -o %t %s 2>&1 | 
FileCheck %s
+// RUN: not %clang_cc1 -emit-obj -triple armv6-unknown-unknown -flto -o %t %s 
2>&1 | FileCheck %s
+
+/// Test the diagnostic behavior considering the whole system including the 
driver.
+// RUN: not %clang --target=armv6-unknown-unknown -c -flto=thin -o %t %s 2>&1 
| FileCheck %s
 #pragma clang diagnostic ignored "-Wmissing-noreturn"
 __asm__(".Lfoo: movw r2, #:lower16:.Lbar - .Lfoo");
 // CHECK: :1:8: error: instruction requires: armv6t2
+// CHECK-NOT: error:
diff --git a/llvm/include/llvm/IR/DiagnosticHandler.h 
b/llvm/include/llvm/IR/DiagnosticHandler.h
index 55e5e5975808d9..db7d7444f75f05 100644
--- a/llvm/include/llvm/IR/DiagnosticHandler.h
+++ b/llvm/include/llvm/IR/DiagnosticHandler.h
@@ -23,6 +23,7 @@ class DiagnosticInfo;
 /// which remarks are enabled.
 struct DiagnosticHandler {
   void *DiagnosticContext = nullptr;
+  bool HasErrors = false;
   DiagnosticHandler(void *DiagContext = nullptr)
   : DiagnosticContext(DiagContext) {}
   virtual ~DiagnosticHandler() = default;
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp 
b/llvm/lib/Object/ModuleSymbolTable.cpp
index ab073e18cb4668..07f76688fa43e7 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -16,6 +16,7 @@
 #include "RecordStreamer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalAlias.h"
 #include "llvm/IR/GlobalValue.h"
@@ -68,6 +69,11 @@ void ModuleSymbolTable::addModule(Module *M) {
 static void
 initializeRecordStreamer(const Module &M,
  function_ref Init) {
+  // This function may be called twice, once for ModuleSummaryIndexAnalysis and
+  // the other when writing the IR symbol table. If parsing inline assembly has
+  // caused errors in the first run, suppress the second run.
+  if (M.getContext().getDiagHandlerPtr()->HasErrors)
+return;
   StringRef InlineAsm = M.getModuleInlineAsm();
   if (InlineAsm.empty())
 return;
@@ -95,7 +101,8 @@ initializeRecordStreamer(const Module &M,
   if (!MCII)
 return;
 
-  std::unique_ptr Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
+  std::unique_ptr Buffer(
+  MemoryBuffer::getMemBuffer(InlineAsm, ""));
   SourceMgr SrcMgr;
   SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 
@@ -115,6 +122,13 @@ initializeRecordStreamer(

[clang-tools-extra] [clang-tidy] Treat fields in anonymous records as names in enclosing scope when checking name styles (PR #75701)

2023-12-16 Thread Sirui Mu via cfe-commits

https://github.com/Lancern updated 
https://github.com/llvm/llvm-project/pull/75701

>From 5d04ca8091fc81fad8e33355a0afcce290bf34f0 Mon Sep 17 00:00:00 2001
From: Sirui Mu 
Date: Sat, 16 Dec 2023 21:55:24 +0800
Subject: [PATCH 1/4] [clang-tidy] Check anonymous record field naming in
 enclosing scopes

Currently, fields in anonymous records are regarded as normal fields when
checking their name styles. Naming rules for class/struct/union member apply to
these fields. This commit changes this behavior:

- If the anonymous record is defined within the file scope or in a namespace
  scope, treat its fields as global variables when checking name styles;
- If the anonymous record is defined within a function, treat its fields as
  local variables when checking name styles;
- If the anonymous record is defined within a non-anonymous record, treat its
  fields as non-static record members when checking name styles.
---
 .../readability/IdentifierNamingCheck.cpp | 196 ++
 .../readability/IdentifierNamingCheck.h   |  13 ++
 .../clang-tidy/utils/ASTUtils.cpp |  24 +++
 clang-tools-extra/clang-tidy/utils/ASTUtils.h |   5 +
 .../identifier-naming-anon-record-fields.cpp  | 184 
 5 files changed, 341 insertions(+), 81 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-anon-record-fields.cpp

diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 03dcfa5f811095..0e18712fd27564 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -9,6 +9,7 @@
 #include "IdentifierNamingCheck.h"
 
 #include "../GlobList.h"
+#include "../utils/ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1185,29 +1186,12 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   }
 
   if (const auto *Decl = dyn_cast(D)) {
-QualType Type = Decl->getType();
-
-if (!Type.isNull() && Type.isConstQualified()) {
-  if (NamingStyles[SK_ConstantMember])
-return SK_ConstantMember;
-
-  if (NamingStyles[SK_Constant])
-return SK_Constant;
+const RecordDecl *Record = Decl->getParent();
+if (Record->isAnonymousStructOrUnion()) {
+  return findStyleKindForAnonField(Decl, NamingStyles);
 }
 
-if (Decl->getAccess() == AS_private && NamingStyles[SK_PrivateMember])
-  return SK_PrivateMember;
-
-if (Decl->getAccess() == AS_protected && NamingStyles[SK_ProtectedMember])
-  return SK_ProtectedMember;
-
-if (Decl->getAccess() == AS_public && NamingStyles[SK_PublicMember])
-  return SK_PublicMember;
-
-if (NamingStyles[SK_Member])
-  return SK_Member;
-
-return SK_Invalid;
+return findStyleKindForField(Decl, Decl->getType(), NamingStyles);
   }
 
   if (const auto *Decl = dyn_cast(D)) {
@@ -1244,66 +1228,7 @@ StyleKind IdentifierNamingCheck::findStyleKind(
   }
 
   if (const auto *Decl = dyn_cast(D)) {
-QualType Type = Decl->getType();
-
-if (Decl->isConstexpr() && NamingStyles[SK_ConstexprVariable])
-  return SK_ConstexprVariable;
-
-if (!Type.isNull() && Type.isConstQualified()) {
-  if (Decl->isStaticDataMember() && NamingStyles[SK_ClassConstant])
-return SK_ClassConstant;
-
-  if (Decl->isFileVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-  NamingStyles[SK_GlobalConstantPointer])
-return SK_GlobalConstantPointer;
-
-  if (Decl->isFileVarDecl() && NamingStyles[SK_GlobalConstant])
-return SK_GlobalConstant;
-
-  if (Decl->isStaticLocal() && NamingStyles[SK_StaticConstant])
-return SK_StaticConstant;
-
-  if (Decl->isLocalVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-  NamingStyles[SK_LocalConstantPointer])
-return SK_LocalConstantPointer;
-
-  if (Decl->isLocalVarDecl() && NamingStyles[SK_LocalConstant])
-return SK_LocalConstant;
-
-  if (Decl->isFunctionOrMethodVarDecl() && NamingStyles[SK_LocalConstant])
-return SK_LocalConstant;
-
-  if (NamingStyles[SK_Constant])
-return SK_Constant;
-}
-
-if (Decl->isStaticDataMember() && NamingStyles[SK_ClassMember])
-  return SK_ClassMember;
-
-if (Decl->isFileVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-NamingStyles[SK_GlobalPointer])
-  return SK_GlobalPointer;
-
-if (Decl->isFileVarDecl() && NamingStyles[SK_GlobalVariable])
-  return SK_GlobalVariable;
-
-if (Decl->isStaticLocal() && NamingStyles[SK_StaticVariable])
-  return SK_StaticVariable;
-
-if (Decl->isLocalVarDecl() && Type.getTypePtr()->isAnyPointerType() &&
-NamingStyles[SK_LocalPointer])
-  return SK_LocalPointer;
-
-if (Decl->isLocalVarDecl() && NamingStyles[SK_LocalVariable])
-  re

[clang-tools-extra] [clang] [llvm] [RISCV][ISel] Combine scalable vector add/sub/mul with zero/sign extension (PR #72340)

2023-12-16 Thread via cfe-commits

sun-jacobi wrote:

Sorry for repeating ping. @qcolombet 

https://github.com/llvm/llvm-project/pull/72340
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a bug in `IndentExternBlock: NoIndent` (PR #75731)

2023-12-16 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/75731

Fixes #36620.
Fixes #75719.

>From 9e54c990db8e597a85239b1efea06b597acf6beb Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Sat, 16 Dec 2023 22:50:27 -0800
Subject: [PATCH] [clang-format] Fix a bug in `IndentExternBlock: NoIndent`

Fixes #36620.
Fixes #75719.
---
 clang/lib/Format/Format.cpp   | 5 -
 clang/unittests/Format/FormatTest.cpp | 7 +++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 668e959a9416ba..28271181e07d0c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1315,7 +1315,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
&Expanded) {
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.SplitEmptyFunction = true;
 Expanded.BraceWrapping.SplitEmptyRecord = false;
 break;
@@ -1335,7 +1334,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
&Expanded) {
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1350,7 +1348,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
&Expanded) {
 Expanded.BraceWrapping.AfterObjCDeclaration = true;
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1375,7 +1372,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
&Expanded) {
 /*SplitEmptyFunction=*/true,
 /*SplitEmptyRecord=*/true,
 /*SplitEmptyNamespace=*/true};
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 break;
   case FormatStyle::BS_WebKit:
 Expanded.BraceWrapping.AfterFunction = true;
@@ -1909,7 +1905,6 @@ FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind 
Language) {
   Style.BraceWrapping.AfterObjCDeclaration = true;
   Style.BraceWrapping.AfterStruct = true;
   Style.BraceWrapping.AfterExternBlock = true;
-  Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   Style.BraceWrapping.BeforeWhile = false;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 24b2fd599dc397..0e08723aa9e947 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4571,6 +4571,13 @@ TEST_F(FormatTest, IndentExternBlockStyle) {
"}",
Style);
 
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  verifyFormat("extern \"C\"\n"
+   "{\n"
+   "int i;\n"
+   "}",
+   Style);
+
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterExternBlock = true;
   Style.IndentExternBlock = FormatStyle::IEBS_Indent;

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


[clang] [clang-format] Fix a bug in `IndentExternBlock: NoIndent` (PR #75731)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fixes #36620.
Fixes #75719.

---
Full diff: https://github.com/llvm/llvm-project/pull/75731.diff


2 Files Affected:

- (modified) clang/lib/Format/Format.cpp (-5) 
- (modified) clang/unittests/Format/FormatTest.cpp (+7) 


``diff
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 668e959a9416ba..28271181e07d0c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1315,7 +1315,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
&Expanded) {
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.SplitEmptyFunction = true;
 Expanded.BraceWrapping.SplitEmptyRecord = false;
 break;
@@ -1335,7 +1334,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
&Expanded) {
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1350,7 +1348,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
&Expanded) {
 Expanded.BraceWrapping.AfterObjCDeclaration = true;
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1375,7 +1372,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
&Expanded) {
 /*SplitEmptyFunction=*/true,
 /*SplitEmptyRecord=*/true,
 /*SplitEmptyNamespace=*/true};
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 break;
   case FormatStyle::BS_WebKit:
 Expanded.BraceWrapping.AfterFunction = true;
@@ -1909,7 +1905,6 @@ FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind 
Language) {
   Style.BraceWrapping.AfterObjCDeclaration = true;
   Style.BraceWrapping.AfterStruct = true;
   Style.BraceWrapping.AfterExternBlock = true;
-  Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   Style.BraceWrapping.BeforeWhile = false;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 24b2fd599dc397..0e08723aa9e947 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4571,6 +4571,13 @@ TEST_F(FormatTest, IndentExternBlockStyle) {
"}",
Style);
 
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  verifyFormat("extern \"C\"\n"
+   "{\n"
+   "int i;\n"
+   "}",
+   Style);
+
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterExternBlock = true;
   Style.IndentExternBlock = FormatStyle::IEBS_Indent;

``




https://github.com/llvm/llvm-project/pull/75731
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits