[clang] [clang-format] Correctly annotate designated initializer with PP if (PR #65409)

2023-09-06 Thread via cfe-commits


@@ -1998,6 +1998,41 @@ TEST_F(TokenAnnotatorTest, UnderstandsNestedBlocks) {
   EXPECT_BRACE_KIND(Tokens[10], BK_Block);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandDesignatedInitializers) {
+  auto Tokens = annotate("SomeStruct { .a = 1 };");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_BRACE_KIND(Tokens[1], BK_BracedInit);
+  EXPECT_TOKEN(Tokens[2], tok::period, TT_DesignatedInitializerPeriod);
+
+  Tokens = annotate("SomeStruct { .a = 1, .b = 2 };");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_BRACE_KIND(Tokens[1], BK_BracedInit);
+  EXPECT_TOKEN(Tokens[2], tok::period, TT_DesignatedInitializerPeriod);
+  EXPECT_TOKEN(Tokens[7], tok::period, TT_DesignatedInitializerPeriod);
+
+  Tokens = annotate("SomeStruct {\n"
+  "#ifdef FOO\n"
+  "  .a = 1,\n"
+  "#endif\n"
+  "  .b = 2\n"
+  "};");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_BRACE_KIND(Tokens[1], BK_BracedInit);
+  EXPECT_TOKEN(Tokens[5], tok::period, TT_DesignatedInitializerPeriod);
+  EXPECT_TOKEN(Tokens[12], tok::period, TT_DesignatedInitializerPeriod);
+
+  Tokens = annotate("SomeStruct {\n"
+  "#if defined FOO\n"
+  "  .a = 1,\n"
+  "#endif\n"
+  "  .b = 2\n"
+  "};");

owenca wrote:

Ditto.

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


[clang] [clang-format] Correctly annotate designated initializer with PP if (PR #65409)

2023-09-06 Thread via cfe-commits


@@ -1998,6 +1998,41 @@ TEST_F(TokenAnnotatorTest, UnderstandsNestedBlocks) {
   EXPECT_BRACE_KIND(Tokens[10], BK_Block);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandDesignatedInitializers) {
+  auto Tokens = annotate("SomeStruct { .a = 1 };");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_BRACE_KIND(Tokens[1], BK_BracedInit);
+  EXPECT_TOKEN(Tokens[2], tok::period, TT_DesignatedInitializerPeriod);
+
+  Tokens = annotate("SomeStruct { .a = 1, .b = 2 };");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_BRACE_KIND(Tokens[1], BK_BracedInit);
+  EXPECT_TOKEN(Tokens[2], tok::period, TT_DesignatedInitializerPeriod);
+  EXPECT_TOKEN(Tokens[7], tok::period, TT_DesignatedInitializerPeriod);
+
+  Tokens = annotate("SomeStruct {\n"
+  "#ifdef FOO\n"
+  "  .a = 1,\n"
+  "#endif\n"
+  "  .b = 2\n"

owenca wrote:

Not clang-formatted.

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


[PATCH] D159167: [clang-repl][Orc] Export executable symbols in ClangReplInterpreterExceptionTests

2023-09-06 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159167

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


[clang] [clang-format] Correctly annotate designated initializer with PP if (PR #65409)

2023-09-06 Thread via cfe-commits


@@ -626,6 +626,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool 
ExpectClassBody) {
 case tok::kw_switch:
 case tok::kw_try:
 case tok::kw___try:
+  if (PrevTok->is(tok::hash))
+break;

owenca wrote:

This should be applied to `kw_if` only, right? So something like the following 
instead?
```
case tok::identifier:
  if (Tok->isNot(TT_StatementMacro))
break;
  [[fallthrough]];
case tok::kw_if:
  if (PrevTok->is(tok::hash))
break;
  [[fallthrough]];
case tok::at:
case tok::semi:
case tok::kw_while:
case tok::kw_for:
case tok::kw_switch:
case tok::kw_try:
case tok::kw___try:
  if (!LBraceStack.empty() && LBraceStack.back().Tok->is(BK_Unknown))
LBraceStack.back().Tok->setBlockKind(BK_Block);
  break;
```

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/65558:

>From f25a855ac2d3ec4b89f55a08e415596b3b65f142 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Thu, 7 Sep 2023 10:14:28 +0800
Subject: [PATCH 1/2] [clang-tidy][modernize-use-using]fix function pointer
 typedef correctly

---
 clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp   | 6 --
 clang-tools-extra/docs/ReleaseNotes.rst| 3 +++
 .../test/clang-tidy/checkers/modernize/use-using.cpp   | 7 +++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index c1af8b5bfa11cac..22dc9e21cab9d5a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -120,8 +120,10 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
&Result) {
 Type.substr(0, FirstTypedefType.size()) == FirstTypedefType)
   Type = FirstTypedefName + Type.substr(FirstTypedefType.size() + 1);
   }
-  if (!ReplaceRange.getEnd().isMacroID())
-LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Name.size());
+  if (!ReplaceRange.getEnd().isMacroID()) {
+const SourceLocation::IntTy Offset = MatchedDecl->getFunctionType() ? 0 : 
Name.size();
+LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Offset);
+  }
 
   auto Diag = diag(ReplaceRange.getBegin(), UseUsingWarning);
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a2cde526a8c04d9..90a782fa53b257d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -246,6 +246,9 @@ Changes in existing checks
   ` check to accurately generate
   fixes for reordering arguments.
 
+- Improved :doc:`modernize-use-using` 
+  check to fix function pointer ``typedef`` correctly.
+
 - Improved :doc:`performance-faster-string-find
   ` check to properly escape
   single quotes.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index 14469e31c826249..01f22f26c034ebe 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -314,3 +314,10 @@ typedef struct { struct { int a; struct { struct { int b; 
} c; int d; } e; } f;
 typedef struct { struct { int a; } b; union { int c; float d; struct { int e; 
}; }; struct { double f; } g; } PR50990_siblings;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using PR50990_siblings = struct { struct { int a; } b; union { 
int c; float d; struct { int e; }; }; struct { double f; } g; };
+
+typedef void (*ISSUE_65055_1)(int);
+typedef bool (*ISSUE_65055_2)(int);
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using ISSUE_65055_1 = void (*)(int)
+// CHECK-FIXES: using ISSUE_65055_2 = bool (*)(int)

>From 6aef0e7f658ada3f95f2fdf9deae89310a2a9038 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Thu, 7 Sep 2023 13:56:12 +0800
Subject: [PATCH 2/2] fix according to comments

---
 clang-tools-extra/docs/ReleaseNotes.rst  | 5 +++--
 .../test/clang-tidy/checkers/modernize/use-using.cpp | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 90a782fa53b257d..998e763d792af6b 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -246,8 +246,9 @@ Changes in existing checks
   ` check to accurately generate
   fixes for reordering arguments.
 
-- Improved :doc:`modernize-use-using` 
-  check to fix function pointer ``typedef`` correctly.
+- Improved :doc:`modernize-use-using
+  ` check to fix function pointer
+  ``typedef`` correctly.
 
 - Improved :doc:`performance-faster-string-find
   ` check to properly escape
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index 01f22f26c034ebe..f1f62b4051a8e78 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -319,5 +319,5 @@ typedef void (*ISSUE_65055_1)(int);
 typedef bool (*ISSUE_65055_2)(int);
 // CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using ISSUE_65055_1 = void (*)(int)
-// CHECK-FIXES: using ISSUE_65055_2 = bool (*)(int)
+// CHECK-FIXES: using ISSUE_65055_1 = void (*)(int);
+// CHECK-FIXES: using ISSUE_65

[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/65558:

>From f25a855ac2d3ec4b89f55a08e415596b3b65f142 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Thu, 7 Sep 2023 10:14:28 +0800
Subject: [PATCH 1/2] [clang-tidy][modernize-use-using]fix function pointer
 typedef correctly

---
 clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp   | 6 --
 clang-tools-extra/docs/ReleaseNotes.rst| 3 +++
 .../test/clang-tidy/checkers/modernize/use-using.cpp   | 7 +++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index c1af8b5bfa11cac..22dc9e21cab9d5a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -120,8 +120,10 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
&Result) {
 Type.substr(0, FirstTypedefType.size()) == FirstTypedefType)
   Type = FirstTypedefName + Type.substr(FirstTypedefType.size() + 1);
   }
-  if (!ReplaceRange.getEnd().isMacroID())
-LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Name.size());
+  if (!ReplaceRange.getEnd().isMacroID()) {
+const SourceLocation::IntTy Offset = MatchedDecl->getFunctionType() ? 0 : 
Name.size();
+LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Offset);
+  }
 
   auto Diag = diag(ReplaceRange.getBegin(), UseUsingWarning);
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a2cde526a8c04d9..90a782fa53b257d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -246,6 +246,9 @@ Changes in existing checks
   ` check to accurately generate
   fixes for reordering arguments.
 
+- Improved :doc:`modernize-use-using` 
+  check to fix function pointer ``typedef`` correctly.
+
 - Improved :doc:`performance-faster-string-find
   ` check to properly escape
   single quotes.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index 14469e31c826249..01f22f26c034ebe 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -314,3 +314,10 @@ typedef struct { struct { int a; struct { struct { int b; 
} c; int d; } e; } f;
 typedef struct { struct { int a; } b; union { int c; float d; struct { int e; 
}; }; struct { double f; } g; } PR50990_siblings;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using PR50990_siblings = struct { struct { int a; } b; union { 
int c; float d; struct { int e; }; }; struct { double f; } g; };
+
+typedef void (*ISSUE_65055_1)(int);
+typedef bool (*ISSUE_65055_2)(int);
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using ISSUE_65055_1 = void (*)(int)
+// CHECK-FIXES: using ISSUE_65055_2 = bool (*)(int)

>From f46eb6ef4305c5362577d0da70b592237e3c180b Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Thu, 7 Sep 2023 13:56:12 +0800
Subject: [PATCH 2/2] fix according to comments

---
 clang-tools-extra/docs/ReleaseNotes.rst  | 5 +++--
 .../test/clang-tidy/checkers/modernize/use-using.cpp | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 90a782fa53b257d..998e763d792af6b 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -246,8 +246,9 @@ Changes in existing checks
   ` check to accurately generate
   fixes for reordering arguments.
 
-- Improved :doc:`modernize-use-using` 
-  check to fix function pointer ``typedef`` correctly.
+- Improved :doc:`modernize-use-using
+  ` check to fix function pointer
+  ``typedef`` correctly.
 
 - Improved :doc:`performance-faster-string-find
   ` check to properly escape
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index 01f22f26c034ebe..f1f62b4051a8e78 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -319,5 +319,5 @@ typedef void (*ISSUE_65055_1)(int);
 typedef bool (*ISSUE_65055_2)(int);
 // CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using ISSUE_65055_1 = void (*)(int)
-// CHECK-FIXES: using ISSUE_65055_2 = bool (*)(int)
+// CHECK-FIXES: using ISSUE_65055_1 = void (*)(int);
+// CHECK-FIXES: using ISSUE_65

[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits


@@ -314,3 +314,10 @@ typedef struct { struct { int a; struct { struct { int b; 
} c; int d; } e; } f;
 typedef struct { struct { int a; } b; union { int c; float d; struct { int e; 
}; }; struct { double f; } g; } PR50990_siblings;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using PR50990_siblings = struct { struct { int a; } b; union { 
int c; float d; struct { int e; }; }; struct { double f; } g; };
+
+typedef void (*ISSUE_65055_1)(int);

HerrCai0907 wrote:

length of variable names is not related with this bugs.

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


[clang] c998106 - [Lex] Remove unused AddGnuCPlusPlusIncludePaths after e75f240a0432d827c28a5d77fad26a099ceb7a72

2023-09-06 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-09-06T22:25:47-07:00
New Revision: c998106a7fea2b11bee250dd1f92ed4418a08c5a

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

LOG: [Lex] Remove unused AddGnuCPlusPlusIncludePaths after 
e75f240a0432d827c28a5d77fad26a099ceb7a72

Added: 


Modified: 
clang/lib/Lex/InitHeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Lex/InitHeaderSearch.cpp 
b/clang/lib/Lex/InitHeaderSearch.cpp
index 2c2fb767ca1ef9..2aaaca89a6a3ac 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -77,12 +77,6 @@ class InitHeaderSearch {
 SystemHeaderPrefixes.emplace_back(std::string(Prefix), IsSystemHeader);
   }
 
-  /// Add the necessary paths to support a gnu libstdc++.
-  /// Returns true if the \p Base path was found, false if it does not exist.
-  bool AddGnuCPlusPlusIncludePaths(StringRef Base, StringRef ArchDir,
-   StringRef Dir32, StringRef Dir64,
-   const llvm::Triple &triple);
-
   /// Add the necessary paths to support a MinGW libstdc++.
   void AddMinGWCPlusPlusIncludePaths(StringRef Base,
  StringRef Arch,
@@ -190,27 +184,6 @@ bool InitHeaderSearch::AddUnmappedPath(const Twine &Path, 
IncludeDirGroup Group,
   return false;
 }
 
-bool InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base,
-   StringRef ArchDir,
-   StringRef Dir32,
-   StringRef Dir64,
-   const llvm::Triple &triple) 
{
-  // Add the base dir
-  bool IsBaseFound = AddPath(Base, CXXSystem, false);
-
-  // Add the multilib dirs
-  llvm::Triple::ArchType arch = triple.getArch();
-  bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64;
-  if (is64bit)
-AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, false);
-  else
-AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, false);
-
-  // Add the backward dir
-  AddPath(Base + "/backward", CXXSystem, false);
-  return IsBaseFound;
-}
-
 void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base,
  StringRef Arch,
  StringRef Version) {



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


[PATCH] D155978: [SPIRV] Add SPIR-V logical triple.

2023-09-06 Thread Michal Paszkowski via Phabricator via cfe-commits
mpaszkowski added a comment.

In D155978#4639499 , @Keenuts wrote:

> In D155978#4639094 , @mpaszkowski 
> wrote:
>
>> @Keenuts Hi Nathan, thanks for the patch! I agree with your approach and I 
>> think that this solution despite being a "hack" seems to be the most 
>> straightforward. Eventual differences could be handled in the backend. I 
>> would be open for other solutions in the future (for example in case other 
>> targets would also stumble upon a similar dilemma), but this looks like a 
>> completely valid approach to me.
>
> Thanks!
> Do you know how we can get this merged? (we have no commit access on our end).

Either I could push the patch for you (adding you as an author) or preferably 
you could gain commit access yourself for this and future patches. Please see 
this guide  
and send an email to Chris (include your GitHub user name and a link to this 
Phabricator review). Please let me know which option you would prefer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155978

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


[PATCH] D158715: [Driver] Cleanup last vestiges of Minix / Contiki support

2023-09-06 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: clang/lib/Lex/InitHeaderSearch.cpp:336
-  case llvm::Triple::Minix:
-AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
-"", "", "", triple);

brad wrote:
> uabelho wrote:
> > @brad :
> > I think this was the last use of the AddGnuCPlusPlusIncludePaths method, 
> > should we remove it now or is it likely it will be used again?
> > 
> > @brad :
> > I think this was the last use of the AddGnuCPlusPlusIncludePaths method, 
> > should we remove it now or is it likely it will be used again?
> 
> I noticed a function of the same name with the Darwin Driver.
Yeah Darwin defines and uses its own function with that name, but the one in 
InitHeaderSearch is unused since this patch.

I don't know anything about this, just noticed that gcc warns about it being 
unused.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158715

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


[PATCH] D158266: [OpenMP] Patch for Support to loop bind clause : Checking Parent Region

2023-09-06 Thread Sunil K via Phabricator via cfe-commits
koops added a comment.

Can someone please review the changes that I uploaded last week?


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

https://reviews.llvm.org/D158266

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


[clang] [clang-format] Fix misannotation of && before noexcept (PR #65526)

2023-09-06 Thread via cfe-commits

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


[clang] [clang-format] Fix misannotation of && before noexcept (PR #65526)

2023-09-06 Thread via cfe-commits

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


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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Piotr Zegar via cfe-commits


@@ -246,6 +246,9 @@ Changes in existing checks
   ` check to accurately generate
   fixes for reordering arguments.
 
+- Improved :doc:`modernize-use-using` 

PiotrZSL wrote:

put space before <, juts for visibility.

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Piotr Zegar via cfe-commits


@@ -314,3 +314,10 @@ typedef struct { struct { int a; struct { struct { int b; 
} c; int d; } e; } f;
 typedef struct { struct { int a; } b; union { int c; float d; struct { int e; 
}; }; struct { double f; } g; } PR50990_siblings;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using PR50990_siblings = struct { struct { int a; } b; union { 
int c; float d; struct { int e; }; }; struct { double f; } g; };
+
+typedef void (*ISSUE_65055_1)(int);

PiotrZSL wrote:

Original issue were mainly with single character variable names, maybe test 
something like:
`typedef void (*C)(int);`

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Piotr Zegar via cfe-commits


@@ -314,3 +314,10 @@ typedef struct { struct { int a; struct { struct { int b; 
} c; int d; } e; } f;
 typedef struct { struct { int a; } b; union { int c; float d; struct { int e; 
}; }; struct { double f; } g; } PR50990_siblings;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using PR50990_siblings = struct { struct { int a; } b; union { 
int c; float d; struct { int e; }; }; struct { double f; } g; };
+
+typedef void (*ISSUE_65055_1)(int);
+typedef bool (*ISSUE_65055_2)(int);
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using ISSUE_65055_1 = void (*)(int)

PiotrZSL wrote:

put `;` at the end of CHECK-FIXES, just to verify that it wont be removed.

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


[clang-tools-extra] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-06 Thread Saleem Abdulrasool via cfe-commits

compnerd wrote:

I think that might be a bit too accelerated.  I work mostly with a fork of LLVM 
(https://github.com/apple/llvm-project) and do care about the usability of 
`cmd` as a shell.  I think that Swift is a large enough consumer of LLVM to 
consider testing that before declaring this feature removed.

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


[clang-tools-extra] [clang-tidy] Exclude bitwise operators in bugprone-non-zero-enum-to-bool-conversion (PR #65498)

2023-09-06 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

> explicit bit usage will not case false positive without this patch. Should we 
> consider case of operator overloading?

Yes, thats a side effect due to implicit casting enums to integers. I added 
tests because those were missing, then I implemented version with 
cxxOverloadCallExpr and changed it into more generic version by using 
binaryOperation.
If you want, then yes, I can reduce this back to overload operators calls only.

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


[clang] [APINotes] Support `SwiftImportAs` for C++ structs (PR #65323)

2023-09-06 Thread Saleem Abdulrasool via cfe-commits

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


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


[PATCH] D92733: Fix PR25627 - false positive diagnostics involving implicit-captures in dependent lambda expressions.

2023-09-06 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

In D92733#4638319 , @cor3ntin wrote:

> @Fznamznon This might be of interest to you
> @faisalv  are you still working on this?

Yeah - sorry - been a little distracted with other stuff.
I tried uploading an updated patch to phabricator - but i get an exception - do 
i need to figure out how to convert this review to a git pull request to move 
this fwd?  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92733

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


[PATCH] D159115: [clang-repl] Adapt to the recent dylib-related changes in ORC.

2023-09-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D159115#4640154 , @tuliom wrote:

> This new test does not work on ppc64le.

I'm sorry, by "new" you mean the version with `uintptr_t` or the original as 
well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159115

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65558
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy][modernize-use-using]fix function pointer typedef correctly (PR #65558)

2023-09-06 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/65558:

Fixed #65055


>From f25a855ac2d3ec4b89f55a08e415596b3b65f142 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Thu, 7 Sep 2023 10:14:28 +0800
Subject: [PATCH] [clang-tidy][modernize-use-using]fix function pointer typedef
 correctly

---
 clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp   | 6 --
 clang-tools-extra/docs/ReleaseNotes.rst| 3 +++
 .../test/clang-tidy/checkers/modernize/use-using.cpp   | 7 +++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index c1af8b5bfa11cac..22dc9e21cab9d5a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -120,8 +120,10 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
&Result) {
 Type.substr(0, FirstTypedefType.size()) == FirstTypedefType)
   Type = FirstTypedefName + Type.substr(FirstTypedefType.size() + 1);
   }
-  if (!ReplaceRange.getEnd().isMacroID())
-LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Name.size());
+  if (!ReplaceRange.getEnd().isMacroID()) {
+const SourceLocation::IntTy Offset = MatchedDecl->getFunctionType() ? 0 : 
Name.size();
+LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Offset);
+  }
 
   auto Diag = diag(ReplaceRange.getBegin(), UseUsingWarning);
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a2cde526a8c04d9..90a782fa53b257d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -246,6 +246,9 @@ Changes in existing checks
   ` check to accurately generate
   fixes for reordering arguments.
 
+- Improved :doc:`modernize-use-using` 
+  check to fix function pointer ``typedef`` correctly.
+
 - Improved :doc:`performance-faster-string-find
   ` check to properly escape
   single quotes.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index 14469e31c826249..01f22f26c034ebe 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -314,3 +314,10 @@ typedef struct { struct { int a; struct { struct { int b; 
} c; int d; } e; } f;
 typedef struct { struct { int a; } b; union { int c; float d; struct { int e; 
}; }; struct { double f; } g; } PR50990_siblings;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using PR50990_siblings = struct { struct { int a; } b; union { 
int c; float d; struct { int e; }; }; struct { double f; } g; };
+
+typedef void (*ISSUE_65055_1)(int);
+typedef bool (*ISSUE_65055_2)(int);
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using ISSUE_65055_1 = void (*)(int)
+// CHECK-FIXES: using ISSUE_65055_2 = bool (*)(int)

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


[clang-tools-extra] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits


@@ -116,6 +116,7 @@ 
add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ENABLE_ROCM_CONVERSIONS})
 
 set(MLIR_ENABLE_CUDA_RUNNER 0 CACHE BOOL "Enable building the mlir CUDA 
runner")
 set(MLIR_ENABLE_ROCM_RUNNER 0 CACHE BOOL "Enable building the mlir ROCm 
runner")
+set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir Sycl 
runner")

keryell wrote:

Please spell SYCL correctly.
```suggestion
set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir SYCL runner")
```
One could argue that `mlir` should be spelled `MLIR` but the train seems to 
have left long time ago. :-)

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


[clang-tools-extra] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits


@@ -0,0 +1,223 @@
+//===- SyclRuntimeWrappers.cpp - MLIR SYCL wrapper library ===//
+//
+// 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
+//
+//===--===//
+//
+// Implements C wrappers around the sycl runtime library.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef _WIN32
+#define SYCL_RUNTIME_EXPORT __declspec(dllexport)
+#else
+#define SYCL_RUNTIME_EXPORT
+#endif // _WIN32
+
+namespace {
+
+template 
+auto catchAll(F &&func) {
+  try {
+return func();
+  } catch (const std::exception &e) {
+fprintf(stdout, "An exception was thrown: %s\n", e.what());
+fflush(stdout);
+abort();
+  } catch (...) {
+fprintf(stdout, "An unknown exception was thrown\n");
+fflush(stdout);
+abort();
+  }
+}
+
+#define L0_SAFE_CALL(call) 
\
+  {
\
+ze_result_t status = (call);   
\
+if (status != ZE_RESULT_SUCCESS) { 
\
+  fprintf(stdout, "L0 error %d\n", status);
\
+  fflush(stdout);  
\
+  abort(); 
\
+}  
\
+  }
+
+} // namespace
+
+static sycl::device getDefaultDevice() {
+  auto platformList = sycl::platform::get_platforms();
+  for (const auto &platform : platformList) {
+auto platformName = platform.get_info();
+bool isLevelZero = platformName.find("Level-Zero") != std::string::npos;
+if (!isLevelZero)
+  continue;
+
+return platform.get_devices()[0];
+  }
+  throw std::runtime_error("getDefaultDevice failed");
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+
+// Create global device and context
+sycl::device syclDevice = getDefaultDevice();
+sycl::context syclContext = sycl::context(syclDevice);
+
+#pragma clang diagnostic pop
+
+struct QUEUE {
+  sycl::queue syclQueue_;
+
+  QUEUE() { syclQueue_ = sycl::queue(syclContext, syclDevice); }
+};
+
+static void *allocDeviceMemory(QUEUE *queue, size_t size, bool isShared) {
+  void *memPtr = nullptr;
+  if (isShared) {
+memPtr = sycl::aligned_alloc_shared(64, size, syclDevice, syclContext);
+  } else {
+memPtr = sycl::aligned_alloc_device(64, size, syclDevice, syclContext);
+  }
+  if (memPtr == nullptr) {
+throw std::runtime_error("mem allocation failed!");
+  }
+  return memPtr;
+}
+
+static void deallocDeviceMemory(QUEUE *queue, void *ptr) {
+  sycl::free(ptr, queue->syclQueue_);
+}
+
+static ze_module_handle_t loadModule(const void *data, size_t dataSize) {
+  assert(data);
+  ze_module_handle_t zeModule;
+  ze_module_desc_t desc = {ZE_STRUCTURE_TYPE_MODULE_DESC,
+   nullptr,
+   ZE_MODULE_FORMAT_IL_SPIRV,
+   dataSize,
+   (const uint8_t *)data,
+   nullptr,
+   nullptr};
+  auto zeDevice =
+  sycl::get_native(syclDevice);
+  auto zeContext =
+  sycl::get_native(syclContext);
+  L0_SAFE_CALL(zeModuleCreate(zeContext, zeDevice, &desc, &zeModule, nullptr));
+  return zeModule;
+}
+
+static sycl::kernel *getKernel(ze_module_handle_t zeModule, const char *name) {
+  assert(zeModule);
+  assert(name);
+  ze_kernel_handle_t zeKernel;
+  sycl::kernel *syclKernel;
+  ze_kernel_desc_t desc = {};
+  desc.pKernelName = name;
+
+  L0_SAFE_CALL(zeKernelCreate(zeModule, &desc, &zeKernel));
+  sycl::kernel_bundle kernelBundle =
+  sycl::make_kernel_bundle({zeModule},
+   syclContext);
+
+  auto kernel = sycl::make_kernel(
+  {kernelBundle, zeKernel}, syclContext);
+  syclKernel = new sycl::kernel(kernel);
+  return syclKernel;
+}
+
+static void launchKernel(QUEUE *queue, sycl::kernel *kernel, size_t gridX,
+ size_t gridY, size_t gridZ, size_t blockX,
+ size_t blockY, size_t blockZ, size_t sharedMemBytes,
+ void **params, size_t paramsCount) {
+  auto syclGlobalRange =
+  ::sycl::range<3>(blockZ * gridZ, blockY * gridY, blockX * gridX);
+  auto syclLocalRange = ::sycl::range<3>(blockZ, blockY, blockX);
+  sycl::nd_range<3> syclNdRange(
+  sycl::nd_range<3>(syclGloba

[clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits


@@ -0,0 +1,223 @@
+//===- SyclRuntimeWrappers.cpp - MLIR SYCL wrapper library ===//
+//
+// 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
+//
+//===--===//
+//
+// Implements C wrappers around the sycl runtime library.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef _WIN32
+#define SYCL_RUNTIME_EXPORT __declspec(dllexport)
+#else
+#define SYCL_RUNTIME_EXPORT
+#endif // _WIN32
+
+namespace {
+
+template 
+auto catchAll(F &&func) {
+  try {
+return func();
+  } catch (const std::exception &e) {
+fprintf(stdout, "An exception was thrown: %s\n", e.what());
+fflush(stdout);
+abort();
+  } catch (...) {
+fprintf(stdout, "An unknown exception was thrown\n");
+fflush(stdout);
+abort();
+  }
+}
+
+#define L0_SAFE_CALL(call) 
\
+  {
\
+ze_result_t status = (call);   
\
+if (status != ZE_RESULT_SUCCESS) { 
\
+  fprintf(stdout, "L0 error %d\n", status);
\
+  fflush(stdout);  
\
+  abort(); 
\
+}  
\
+  }
+
+} // namespace
+
+static sycl::device getDefaultDevice() {
+  auto platformList = sycl::platform::get_platforms();
+  for (const auto &platform : platformList) {
+auto platformName = platform.get_info();
+bool isLevelZero = platformName.find("Level-Zero") != std::string::npos;
+if (!isLevelZero)
+  continue;
+
+return platform.get_devices()[0];
+  }
+  throw std::runtime_error("getDefaultDevice failed");
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+
+// Create global device and context
+sycl::device syclDevice = getDefaultDevice();
+sycl::context syclContext = sycl::context(syclDevice);

keryell wrote:

```suggestion
sycl::context syclContext { syclDevice };
```

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


[clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits

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


[clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits


@@ -0,0 +1,223 @@
+//===- SyclRuntimeWrappers.cpp - MLIR SYCL wrapper library ===//
+//
+// 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
+//
+//===--===//
+//
+// Implements C wrappers around the sycl runtime library.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef _WIN32
+#define SYCL_RUNTIME_EXPORT __declspec(dllexport)
+#else
+#define SYCL_RUNTIME_EXPORT
+#endif // _WIN32
+
+namespace {
+
+template 
+auto catchAll(F &&func) {
+  try {
+return func();
+  } catch (const std::exception &e) {
+fprintf(stdout, "An exception was thrown: %s\n", e.what());
+fflush(stdout);
+abort();
+  } catch (...) {
+fprintf(stdout, "An unknown exception was thrown\n");
+fflush(stdout);
+abort();
+  }
+}
+
+#define L0_SAFE_CALL(call) 
\
+  {
\
+ze_result_t status = (call);   
\
+if (status != ZE_RESULT_SUCCESS) { 
\
+  fprintf(stdout, "L0 error %d\n", status);
\
+  fflush(stdout);  
\
+  abort(); 
\
+}  
\
+  }
+
+} // namespace
+
+static sycl::device getDefaultDevice() {
+  auto platformList = sycl::platform::get_platforms();
+  for (const auto &platform : platformList) {
+auto platformName = platform.get_info();
+bool isLevelZero = platformName.find("Level-Zero") != std::string::npos;
+if (!isLevelZero)
+  continue;
+
+return platform.get_devices()[0];
+  }
+  throw std::runtime_error("getDefaultDevice failed");
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+
+// Create global device and context
+sycl::device syclDevice = getDefaultDevice();
+sycl::context syclContext = sycl::context(syclDevice);
+
+#pragma clang diagnostic pop
+
+struct QUEUE {

keryell wrote:

Why this spelling? Coding standard?
Why do you need this object? At the end this looks like a 
`std::optional`.

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


[clang-tools-extra] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits


@@ -0,0 +1,223 @@
+//===- SyclRuntimeWrappers.cpp - MLIR SYCL wrapper library ===//
+//
+// 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
+//
+//===--===//
+//
+// Implements C wrappers around the sycl runtime library.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef _WIN32
+#define SYCL_RUNTIME_EXPORT __declspec(dllexport)
+#else
+#define SYCL_RUNTIME_EXPORT
+#endif // _WIN32
+
+namespace {
+
+template 
+auto catchAll(F &&func) {
+  try {
+return func();
+  } catch (const std::exception &e) {
+fprintf(stdout, "An exception was thrown: %s\n", e.what());
+fflush(stdout);
+abort();
+  } catch (...) {
+fprintf(stdout, "An unknown exception was thrown\n");
+fflush(stdout);
+abort();
+  }
+}
+
+#define L0_SAFE_CALL(call) 
\
+  {
\
+ze_result_t status = (call);   
\
+if (status != ZE_RESULT_SUCCESS) { 
\
+  fprintf(stdout, "L0 error %d\n", status);
\
+  fflush(stdout);  
\
+  abort(); 
\
+}  
\
+  }
+
+} // namespace
+
+static sycl::device getDefaultDevice() {
+  auto platformList = sycl::platform::get_platforms();
+  for (const auto &platform : platformList) {
+auto platformName = platform.get_info();
+bool isLevelZero = platformName.find("Level-Zero") != std::string::npos;
+if (!isLevelZero)
+  continue;
+
+return platform.get_devices()[0];
+  }
+  throw std::runtime_error("getDefaultDevice failed");
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+
+// Create global device and context
+sycl::device syclDevice = getDefaultDevice();
+sycl::context syclContext = sycl::context(syclDevice);
+
+#pragma clang diagnostic pop
+
+struct QUEUE {

keryell wrote:

Why this spelling? Coding standard?
Why do you need this object? At the end this looks like a 
`std::optional`.

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


[clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits


@@ -0,0 +1,223 @@
+//===- SyclRuntimeWrappers.cpp - MLIR SYCL wrapper library ===//
+//
+// 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
+//
+//===--===//
+//
+// Implements C wrappers around the sycl runtime library.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef _WIN32
+#define SYCL_RUNTIME_EXPORT __declspec(dllexport)
+#else
+#define SYCL_RUNTIME_EXPORT
+#endif // _WIN32
+
+namespace {
+
+template 
+auto catchAll(F &&func) {
+  try {
+return func();
+  } catch (const std::exception &e) {
+fprintf(stdout, "An exception was thrown: %s\n", e.what());
+fflush(stdout);
+abort();
+  } catch (...) {
+fprintf(stdout, "An unknown exception was thrown\n");
+fflush(stdout);
+abort();
+  }
+}
+
+#define L0_SAFE_CALL(call) 
\
+  {
\
+ze_result_t status = (call);   
\
+if (status != ZE_RESULT_SUCCESS) { 
\
+  fprintf(stdout, "L0 error %d\n", status);
\
+  fflush(stdout);  
\
+  abort(); 
\
+}  
\
+  }
+
+} // namespace
+
+static sycl::device getDefaultDevice() {
+  auto platformList = sycl::platform::get_platforms();
+  for (const auto &platform : platformList) {
+auto platformName = platform.get_info();
+bool isLevelZero = platformName.find("Level-Zero") != std::string::npos;
+if (!isLevelZero)
+  continue;
+
+return platform.get_devices()[0];
+  }
+  throw std::runtime_error("getDefaultDevice failed");
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+
+// Create global device and context
+sycl::device syclDevice = getDefaultDevice();
+sycl::context syclContext = sycl::context(syclDevice);
+
+#pragma clang diagnostic pop
+
+struct QUEUE {
+  sycl::queue syclQueue_;
+
+  QUEUE() { syclQueue_ = sycl::queue(syclContext, syclDevice); }
+};
+
+static void *allocDeviceMemory(QUEUE *queue, size_t size, bool isShared) {
+  void *memPtr = nullptr;
+  if (isShared) {
+memPtr = sycl::aligned_alloc_shared(64, size, syclDevice, syclContext);
+  } else {
+memPtr = sycl::aligned_alloc_device(64, size, syclDevice, syclContext);
+  }
+  if (memPtr == nullptr) {
+throw std::runtime_error("mem allocation failed!");
+  }
+  return memPtr;
+}
+
+static void deallocDeviceMemory(QUEUE *queue, void *ptr) {
+  sycl::free(ptr, queue->syclQueue_);
+}
+
+static ze_module_handle_t loadModule(const void *data, size_t dataSize) {
+  assert(data);
+  ze_module_handle_t zeModule;
+  ze_module_desc_t desc = {ZE_STRUCTURE_TYPE_MODULE_DESC,
+   nullptr,
+   ZE_MODULE_FORMAT_IL_SPIRV,
+   dataSize,
+   (const uint8_t *)data,
+   nullptr,
+   nullptr};
+  auto zeDevice =
+  sycl::get_native(syclDevice);
+  auto zeContext =
+  sycl::get_native(syclContext);
+  L0_SAFE_CALL(zeModuleCreate(zeContext, zeDevice, &desc, &zeModule, nullptr));
+  return zeModule;
+}
+
+static sycl::kernel *getKernel(ze_module_handle_t zeModule, const char *name) {
+  assert(zeModule);
+  assert(name);
+  ze_kernel_handle_t zeKernel;
+  sycl::kernel *syclKernel;
+  ze_kernel_desc_t desc = {};
+  desc.pKernelName = name;
+
+  L0_SAFE_CALL(zeKernelCreate(zeModule, &desc, &zeKernel));
+  sycl::kernel_bundle kernelBundle =
+  sycl::make_kernel_bundle({zeModule},
+   syclContext);
+
+  auto kernel = sycl::make_kernel(
+  {kernelBundle, zeKernel}, syclContext);
+  syclKernel = new sycl::kernel(kernel);
+  return syclKernel;
+}
+
+static void launchKernel(QUEUE *queue, sycl::kernel *kernel, size_t gridX,

keryell wrote:

```suggestion
static void launchKernel(QUEUE queue, sycl::kernel kernel, size_t gridX,
```
or even use `&` if you are afraid of using the reference semantics of SYCL 
behind the scene.

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


[clang-tools-extra] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits


@@ -0,0 +1,223 @@
+//===- SyclRuntimeWrappers.cpp - MLIR SYCL wrapper library ===//
+//
+// 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
+//
+//===--===//
+//
+// Implements C wrappers around the sycl runtime library.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef _WIN32
+#define SYCL_RUNTIME_EXPORT __declspec(dllexport)
+#else
+#define SYCL_RUNTIME_EXPORT
+#endif // _WIN32
+
+namespace {
+
+template 
+auto catchAll(F &&func) {
+  try {
+return func();
+  } catch (const std::exception &e) {
+fprintf(stdout, "An exception was thrown: %s\n", e.what());
+fflush(stdout);
+abort();
+  } catch (...) {
+fprintf(stdout, "An unknown exception was thrown\n");
+fflush(stdout);
+abort();
+  }
+}
+
+#define L0_SAFE_CALL(call) 
\
+  {
\
+ze_result_t status = (call);   
\
+if (status != ZE_RESULT_SUCCESS) { 
\
+  fprintf(stdout, "L0 error %d\n", status);
\
+  fflush(stdout);  
\
+  abort(); 
\
+}  
\
+  }
+
+} // namespace
+
+static sycl::device getDefaultDevice() {
+  auto platformList = sycl::platform::get_platforms();
+  for (const auto &platform : platformList) {
+auto platformName = platform.get_info();
+bool isLevelZero = platformName.find("Level-Zero") != std::string::npos;
+if (!isLevelZero)
+  continue;
+
+return platform.get_devices()[0];
+  }
+  throw std::runtime_error("getDefaultDevice failed");
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+
+// Create global device and context
+sycl::device syclDevice = getDefaultDevice();
+sycl::context syclContext = sycl::context(syclDevice);

keryell wrote:

```suggestion
sycl::context syclContext { syclDevice };
```

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


[clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits


@@ -116,6 +116,7 @@ 
add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ENABLE_ROCM_CONVERSIONS})
 
 set(MLIR_ENABLE_CUDA_RUNNER 0 CACHE BOOL "Enable building the mlir CUDA 
runner")
 set(MLIR_ENABLE_ROCM_RUNNER 0 CACHE BOOL "Enable building the mlir ROCm 
runner")
+set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir Sycl 
runner")

keryell wrote:

Please spell SYCL correctly.
```suggestion
set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir SYCL runner")
```
One could argue that `mlir` should be spelled `MLIR` but the train seems to 
have left long time ago. :-)

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


[clang-tools-extra] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via cfe-commits

https://github.com/keryell commented:

Quite interesting!
At some point it would be nice to have some design document or documentation 
somewhere explaining how all these MLIR runners works, including this one.
Globally this PR add a SYCL runner, but it is very specific for Intel Level 0.
It would be nice to have in the future some generalization, like SYCL using 
OpenCL interoperability interface to run the SPIR-V kernels or even native 
kernels.

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


[PATCH] D159250: [X86][RFC] Add new option `-m[no-]evex512` to disable ZMM and 64-bit mask instructions for AVX512 features

2023-09-06 Thread Kan Shengchen via Phabricator via cfe-commits
skan accepted this revision.
skan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159250

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


[PATCH] D159250: [X86][RFC] Add new option `-m[no-]evex512` to disable ZMM and 64-bit mask instructions for AVX512 features

2023-09-06 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: llvm/lib/Target/X86/X86Subtarget.cpp:277
+
+  if (posAVX512F != StringRef::npos &&
+  (posNoAVX512F == StringRef::npos || posNoAVX512F < posAVX512F))

Well. It's a very tricky implementation, but I can find out a better way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159250

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


[PATCH] D159167: [clang-repl][Orc] Export executable symbols in ClangReplInterpreterExceptionTests

2023-09-06 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159167

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


[PATCH] D158920: Delete CloudABI support

2023-09-06 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

In D158920#4620361 , @brad wrote:

> Looking for any feedback from the FreeBSD guys.

Sorry for no reply earlier, I was away for some of the summer and missed this 
originally. While CloudABI was a very interesting FreeBSD-related project it 
was removed from FreeBSD as you noted, and there's no reason to keep support in 
llvm

  commit cf0ee8738e31aa9e6fbf4dca4dac56d89226a71a
  Author: Konstantin Belousov 
  Date:   Mon Sep 13 01:50:39 2021 +0300
  
  Drop cloudabi
  
  According to https://github.com/NuxiNL/cloudlibc:
  CloudABI is no longer being maintained. It was an awesome experiment,
  but it never got enough traction to be sustainable.
  
  There is no reason to keep it in FreeBSD.
  
  Approved by:ed (private mail)
  Reviewed by:emaste
  Sponsored by:   The FreeBSD Foundation
  Differential revision:  https://reviews.freebsd.org/D31923


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158920

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


[clang-tools-extra] [clang-tidy] Exclude bitwise operators in bugprone-non-zero-enum-to-bool-conversion (PR #65498)

2023-09-06 Thread Congcong Cai via cfe-commits

HerrCai0907 wrote:

explicit bit usage will not case false positive without this patch. Should we 
consider case of operator overloading?
```cpp
bool explicitBitUsage1(EStatus value) {
  return (value & SUCCESS);
}
bool explicitBitUsage2(EStatus value) {
  return (value | SUCCESS);
}
```


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


[PATCH] D159250: [X86][RFC] Add new option `-m[no-]evex512` to disable ZMM and 64-bit mask instructions for AVX512 features

2023-09-06 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159250

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


[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits

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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits

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


[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits

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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits

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


[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits


@@ -0,0 +1,190 @@
+//===--===//
+//
+// 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
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsIt = requires(Iter iter, Sent sent) { 
std::ranges::contains(iter, sent, *iter); };
+
+static_assert(HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt, 
SentinelForNotSemiregular>);
+static_assert(!HasContainsIt, 
InputRangeNotSentinelEqualityComparableWith>);
+
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+
+template 
+concept HasContainsR = requires(Range range) { std::ranges::contains(range, 
ValT{}); };
+
+static_assert(HasContainsR, int>);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR, 
NotEqualityComparable>);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+
+static std::vector comparable_data;
+
+// clang-format off
+template 
+constexpr void test_iterators() {
+  using ValueT = std::iter_value_t;
+  {  // simple tests
+{
+  ValueT a[] = {1, 2, 3, 4, 5, 6};

ZijunZhaoCCK wrote:

> Why does it matter that we're "testing the exact same data"? You can repeat 
> yourself in tests.

I think what var-const means is that I can simplify the code by moving out the 
input and I don't have to write the same code twice.

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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits


@@ -0,0 +1,190 @@
+//===--===//
+//
+// 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
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsIt = requires(Iter iter, Sent sent) { 
std::ranges::contains(iter, sent, *iter); };
+
+static_assert(HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt, 
SentinelForNotSemiregular>);
+static_assert(!HasContainsIt, 
InputRangeNotSentinelEqualityComparableWith>);
+
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+
+template 
+concept HasContainsR = requires(Range range) { std::ranges::contains(range, 
ValT{}); };
+
+static_assert(HasContainsR, int>);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR, 
NotEqualityComparable>);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+
+static std::vector comparable_data;
+
+// clang-format off
+template 
+constexpr void test_iterators() {
+  using ValueT = std::iter_value_t;
+  {  // simple tests
+{
+  ValueT a[] = {1, 2, 3, 4, 5, 6};

ZijunZhaoCCK wrote:

> Why does it matter that we're "testing the exact same data"? You can repeat 
> yourself in tests.

I think what var-const means is that I can simplify the code by moving out the 
input and I don't have to write the same code twice.

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


[clang-tools-extra] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] [clang-format] Skip additional tests of the same case upon failure (PR #65540)

2023-09-06 Thread via cfe-commits

owenca wrote:

Before:
```
.../llvm-project/clang/unittests/Format/FormatTestBase.h:93: Failure
Expected equality of these values:
  Expected.str()
Which is: 
"(\n
\"x\t\");"
  format(Code, Style, SC_ExpectComplete, Ranges)
Which is: 
"(\"x\t\");"
With diff:
@@ -1,2 +1,1 @@
-(
-\"x\t\");
+(\"x\t\");

Google Test trace:
.../llvm-project/clang/unittests/Format/FormatTest.cpp:14824: 
(
"x  ");
.../llvm-project/clang/unittests/Format/FormatTestBase.h:102: Failure
Expected equality of these values:
  Expected.str()
Which is: 
"(\n
\"x\t\");"
  format(Code, ObjCStyle, SC_ExpectComplete, Ranges)
Which is: 
"(\"x\t\");"
With diff:
@@ -1,2 +1,1 @@
-(
-\"x\t\");
+(\"x\t\");

Google Test trace:
.../llvm-project/clang/unittests/Format/FormatTest.cpp:14824: 
(
"x  ");
.../llvm-project/clang/unittests/Format/FormatTestBase.h:90: Failure
Expected equality of these values:
  Expected.str()
Which is: 
"(\n
\"x\t\");"
  format(Expected, Style, SC_ExpectComplete, Ranges)
Which is: 
"(\"x\t\");"
With diff:
@@ -1,2 +1,1 @@
-(
-\"x\t\");
+(\"x\t\");

Expected code is not stable
Google Test trace:
.../llvm-project/clang/unittests/Format/FormatTest.cpp:14824: 
( "x
  ");
```
After:
```
.../llvm-project/clang/unittests/Format/FormatTestBase.h:90: Failure
Expected equality of these values:
  ExpectedCode
Which is: 
"(\n
\"x\t\");"
  FormattedCode
Which is: 
"(\"x\t\");"
With diff:
@@ -1,2 +1,1 @@
-(
-\"x\t\");
+(\"x\t\");

Google Test trace:
.../llvm-project/clang/unittests/Format/FormatTest.cpp:14824: 
(
```

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


[PATCH] D159126: [Clang] Add captures to the instantiation scope of lambda call operators

2023-09-06 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

I'm seeing libcxx failures after this patch. See 
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8770673168839783889/overview

  # .---command stderr
  # | 
/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/std/ranges/range.adaptors/range.all/range.owning.view/empty.pass.cpp:38:19:
 error: static assertion failed due to requirement '!HasEmpty &>'
  # |38 | static_assert(!HasEmpty);
  # |   |   ^~~~
  # | 
/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/std/ranges/range.adaptors/range.all/range.owning.view/empty.pass.cpp:39:19:
 error: static assertion failed due to requirement '!HasEmpty &&>'
  # |39 | static_assert(!HasEmpty);
  # |   |   ^
  # | 2 errors generated.
  # `-

I've verified that reverting this patch fixes those errors. Would you mind 
taking a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159126

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


[clang] [clang-format] Skip additional tests of the same case upon failure (PR #65540)

2023-09-06 Thread via cfe-commits

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/65540:

>From e67336055c73e9d8c1d1fccff24395ca0197e985 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Wed, 6 Sep 2023 14:53:39 -0700
Subject: [PATCH] [clang-format] Skip additional tests of the same case upon
 failure

A typical test case goes through the format, stability, ObjC, and
messUp tests. If any of theses tests fails, we should skip the rest
of the tests for the same test case.
---
 clang/unittests/Format/FormatTestBase.h | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/clang/unittests/Format/FormatTestBase.h 
b/clang/unittests/Format/FormatTestBase.h
index 22eea23b869a212..eaadb1c9f83e5a5 100644
--- a/clang/unittests/Format/FormatTestBase.h
+++ b/clang/unittests/Format/FormatTestBase.h
@@ -80,17 +80,22 @@ class FormatTestBase : public ::testing::Test {
 return Style;
   }
 
-  void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
+  bool _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
  llvm::StringRef Code,
  const std::optional &Style = {},
  const std::vector &Ranges = {}) {
 testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+const auto ExpectedCode{Expected.str()};
+auto FormattedCode{format(Code, Style, SC_ExpectComplete, Ranges)};
+EXPECT_EQ(ExpectedCode, FormattedCode);
+if (ExpectedCode != FormattedCode)
+  return false;
 if (Expected != Code) {
-  EXPECT_EQ(Expected.str(),
-format(Expected, Style, SC_ExpectComplete, Ranges))
-  << "Expected code is not stable";
+  FormattedCode = format(Expected, Style, SC_ExpectComplete, Ranges);
+  EXPECT_EQ(ExpectedCode, FormattedCode) << "Expected code is not stable";
+  if (ExpectedCode != FormattedCode)
+return false;
 }
-EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges));
 auto UsedStyle = Style ? Style.value() : getDefaultStyle();
 if (UsedStyle.Language == FormatStyle::LK_Cpp) {
   // Objective-C++ is a superset of C++, so everything checked for C++
@@ -98,14 +103,18 @@ class FormatTestBase : public ::testing::Test {
   FormatStyle ObjCStyle = UsedStyle;
   ObjCStyle.Language = FormatStyle::LK_ObjC;
   // FIXME: Additional messUp is superfluous.
-  EXPECT_EQ(Expected.str(),
-format(Code, ObjCStyle, SC_ExpectComplete, Ranges));
+  FormattedCode = format(Code, ObjCStyle, SC_ExpectComplete, Ranges);
+  EXPECT_EQ(ExpectedCode, FormattedCode);
+  if (ExpectedCode != FormattedCode)
+return false;
 }
+return true;
   }
 
   void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
  const std::optional &Style = {}) {
-_verifyFormat(File, Line, Code, Code, Style);
+if (!_verifyFormat(File, Line, Code, Code, Style))
+  return;
 if (const auto MessedUpCode{messUp(Code)}; MessedUpCode != Code)
   _verifyFormat(File, Line, Code, MessedUpCode, Style);
   }

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


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-06 Thread Richard Smith via cfe-commits

https://github.com/zygoloid commented:

The change looks good and like a nice improvement to me. I don't think this is 
undoing any of the intended functional changes of @mizvekov's work.

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits


@@ -0,0 +1,70 @@
+//===- SerializeToSPIRV.cpp - Convert GPU kernel to SPIRV blob 
-===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This pass iterates all the SPIR-V modules in the top module and serializes
+/// each SPIR-V module to SPIR-V binary and then attachs the binary blob as a
+/// string attribute to the corresponding gpu module.
+///
+//===--===//
+
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+
+#include "mlir/Dialect/GPU/IR/GPUDialect.h"
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Target/SPIRV/Serialization.h"
+
+namespace mlir {
+#define GEN_PASS_DEF_GPUSERIALIZETOSPIRVPASS
+#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+struct GpuSerializeToSPIRVPass : public 
mlir::impl::GpuSerializeToSPIRVPassBase {
+public:
+  void runOnOperation() override {
+auto mod = getOperation();
+llvm::SmallVector spvBinary;
+for (mlir::gpu::GPUModuleOp gpuMod : mod.getOps()) {
+  auto name = gpuMod.getName();
+  // check that the spv module has the same name with gpu module except the
+  // prefix "__spv__"
+  auto isSameMod = [&](spirv::ModuleOp spvMod) -> bool {
+auto spvModName = spvMod.getName();
+return spvModName->consume_front("__spv__") && spvModName == name;
+  };
+  auto spvMods = mod.getOps();
+  auto it = llvm::find_if(spvMods, isSameMod);
+  if (it == spvMods.end()) {
+gpuMod.emitError() << "Unable to find corresponding SPIR-V module";
+signalPassFailure();
+return;
+  }
+  auto spvMod = *it;
+
+  spvBinary.clear();
+  // serialize the spv module to spv binary
+  if (mlir::failed(spirv::serialize(spvMod, spvBinary))) {
+spvMod.emitError() << "Failed to serialize SPIR-V module";
+signalPassFailure();
+return;
+  }
+
+  // attach the spv binary to the gpu module
+  auto spvData =
+  llvm::StringRef(reinterpret_cast(spvBinary.data()),
+  spvBinary.size() * sizeof(uint32_t));
+  auto spvAttr = mlir::StringAttr::get(&getContext(), spvData);
+  gpuMod->setAttr(gpu::getDefaultGpuBinaryAnnotation(), spvAttr);
+  spvMod->erase();
+}
+  }
+};

joker-eph wrote:

@fabianmcg : how would that fit in the new serialization flow?

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

joker-eph wrote:

I see a unit-test for this: but can you send everything related to 
`isHostShared` in a separate PR?


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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits


@@ -0,0 +1,70 @@
+//===- SerializeToSPIRV.cpp - Convert GPU kernel to SPIRV blob 
-===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This pass iterates all the SPIR-V modules in the top module and serializes
+/// each SPIR-V module to SPIR-V binary and then attachs the binary blob as a
+/// string attribute to the corresponding gpu module.
+///
+//===--===//
+
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+
+#include "mlir/Dialect/GPU/IR/GPUDialect.h"
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Target/SPIRV/Serialization.h"
+
+namespace mlir {
+#define GEN_PASS_DEF_GPUSERIALIZETOSPIRVPASS
+#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+struct GpuSerializeToSPIRVPass : public 
mlir::impl::GpuSerializeToSPIRVPassBase {
+public:
+  void runOnOperation() override {
+auto mod = getOperation();
+llvm::SmallVector spvBinary;
+for (mlir::gpu::GPUModuleOp gpuMod : mod.getOps()) {
+  auto name = gpuMod.getName();
+  // check that the spv module has the same name with gpu module except the
+  // prefix "__spv__"
+  auto isSameMod = [&](spirv::ModuleOp spvMod) -> bool {
+auto spvModName = spvMod.getName();
+return spvModName->consume_front("__spv__") && spvModName == name;
+  };
+  auto spvMods = mod.getOps();
+  auto it = llvm::find_if(spvMods, isSameMod);

joker-eph wrote:

This is really costly, can you build a symbol table once at the beginning of 
the function and use it for the queries instead?

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

joker-eph wrote:

I see a unit-test for this: but can you send everything related to 
`isHostShared` in a separate PR?


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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits


@@ -0,0 +1,70 @@
+//===- SerializeToSPIRV.cpp - Convert GPU kernel to SPIRV blob 
-===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This pass iterates all the SPIR-V modules in the top module and serializes
+/// each SPIR-V module to SPIR-V binary and then attachs the binary blob as a
+/// string attribute to the corresponding gpu module.
+///
+//===--===//
+
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+
+#include "mlir/Dialect/GPU/IR/GPUDialect.h"
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Target/SPIRV/Serialization.h"
+
+namespace mlir {
+#define GEN_PASS_DEF_GPUSERIALIZETOSPIRVPASS
+#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+struct GpuSerializeToSPIRVPass : public 
mlir::impl::GpuSerializeToSPIRVPassBase {
+public:
+  void runOnOperation() override {
+auto mod = getOperation();
+llvm::SmallVector spvBinary;
+for (mlir::gpu::GPUModuleOp gpuMod : mod.getOps()) {
+  auto name = gpuMod.getName();
+  // check that the spv module has the same name with gpu module except the
+  // prefix "__spv__"
+  auto isSameMod = [&](spirv::ModuleOp spvMod) -> bool {
+auto spvModName = spvMod.getName();
+return spvModName->consume_front("__spv__") && spvModName == name;
+  };
+  auto spvMods = mod.getOps();
+  auto it = llvm::find_if(spvMods, isSameMod);

joker-eph wrote:

This is really costly, can you build a symbol table once at the beginning of 
the function and use it for the queries instead?

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits

https://github.com/joker-eph commented:

LGTM overall, this should likely get reviewed by @antiagainst / @kuhar ; and 
it's be great if you can split the independent changes and send them ahead of 
the e2e integration.

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits


@@ -1158,7 +1178,7 @@ LogicalResult 
ConvertLaunchFuncOpToGpuRuntimeCallPattern::matchAndRewrite(
   {function.getResult(), adaptor.getGridSizeX(), adaptor.getGridSizeY(),
adaptor.getGridSizeZ(), adaptor.getBlockSizeX(), 
adaptor.getBlockSizeY(),
adaptor.getBlockSizeZ(), dynamicSharedMemorySize, stream, kernelParams,
-   /*extra=*/nullpointer});
+   /*extra=*/nullpointer, paramsCount});

joker-eph wrote:

I see a unit-test for this: but can you send everything related, but can you 
send everything related to paramsCount in a separate PR?

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits


@@ -71,7 +71,8 @@ void GPUToSPIRVPass::runOnOperation() {
   std::unique_ptr target =
   spirv::getMemorySpaceToStorageClassTarget(*context);
   spirv::MemorySpaceToStorageClassMap memorySpaceMap =
-  spirv::mapMemorySpaceToVulkanStorageClass;
+  this->useOpenCL ? spirv::mapMemorySpaceToOpenCLStorageClass :
+  spirv::mapMemorySpaceToVulkanStorageClass;

joker-eph wrote:

Can you point out which unit-test is covering this? Can you send this in a 
separate PR?

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits

https://github.com/joker-eph commented:

LGTM overall, this should likely get reviewed by @antiagainst / @kuhar ; and 
it's be great if you can split the independent changes and send them ahead of 
the e2e integration.

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via cfe-commits


@@ -71,7 +71,8 @@ void GPUToSPIRVPass::runOnOperation() {
   std::unique_ptr target =
   spirv::getMemorySpaceToStorageClassTarget(*context);
   spirv::MemorySpaceToStorageClassMap memorySpaceMap =
-  spirv::mapMemorySpaceToVulkanStorageClass;
+  this->useOpenCL ? spirv::mapMemorySpaceToOpenCLStorageClass :
+  spirv::mapMemorySpaceToVulkanStorageClass;

joker-eph wrote:

Can you point out which unit-test is covering this? Can you send this in a 
separate PR?

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


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-06 Thread Jessica Clarke via cfe-commits

jrtc27 wrote:

> > > So it looks like some of these changes undo some of the change introduced 
> > > by @mizvekov in some tests. Maybe @zygoloid or @AaronBallman has some 
> > > more input here.
> > 
> > 
> > Do you have a pointer to such changes?
> 
> One of the commits is here: 
> [15f3cd6](https://github.com/llvm/llvm-project/commit/15f3cd6bfc670ba6106184a903eb04be059e5977)
> 
> I know he did a lot of work in this area and I am not familiar with it in 
> detail but I want to make sure interested parties are not stepping on each 
> others work.

My view is that the `'struct S':'struct S'` is just an unintended side-effect 
of adding that sugar. I'm not removing that sugar, and in cases where the 
as-written type differs from the desugared type it will still print both, it 
just doesn't print both when textually there is no difference.

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


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-06 Thread Shafik Yaghmour via cfe-commits

shafik wrote:

> > So it looks like some of these changes undo some of the change introduced 
> > by @mizvekov in some tests. Maybe @zygoloid or @AaronBallman has some more 
> > input here.
> 
> Do you have a pointer to such changes?

One of the commits is here: 15f3cd6bfc670 

I know he did a lot of work in this area and I am not familiar with it in 
detail but I want to make sure interested parties are not stepping on each 
others work.

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] [Clang] Fix the for statement disappearing in AST when an error occurs in the conditional expression of the for statement (PR #65381)

2023-09-06 Thread Shafik Yaghmour via cfe-commits


@@ -2158,8 +2158,10 @@ StmtResult Parser::ParseForStatement(SourceLocation 
*TrailingElseLoc) {
 // for-range-declaration next.
 bool MightBeForRangeStmt = !ForRangeInfo.ParsedForRangeDecl();
 ColonProtectionRAIIObject ColonProtection(*this, MightBeForRangeStmt);
+SourceLocation SecondPartStart = Tok.getLocation();
+Sema::ConditionKind CK = Sema::ConditionKind::Boolean;
 SecondPart = ParseCXXCondition(
-nullptr, ForLoc, Sema::ConditionKind::Boolean,
+nullptr, ForLoc, CK,
 // FIXME: recovery if we don't see another semi!
 /*MissingOK=*/true, MightBeForRangeStmt ? &ForRangeInfo : nullptr,
 /*EnterForConditionScope*/ true);

shafik wrote:

```suggestion
/*InitStmt=*/nullptr, ForLoc, CK,
// FIXME: recovery if we don't see another semi!
/*MissingOK=*/true, MightBeForRangeStmt ? &ForRangeInfo : nullptr,
/*EnterForConditionScope=*/true);
```

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


[clang] [Clang] Fix the for statement disappearing in AST when an error occurs in the conditional expression of the for statement (PR #65381)

2023-09-06 Thread Shafik Yaghmour via cfe-commits

https://github.com/shafik commented:

This looks good to me but I would like another set of eyes on it.

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


[clang] [Clang] Fix the for statement disappearing in AST when an error occurs in the conditional expression of the for statement (PR #65381)

2023-09-06 Thread Shafik Yaghmour via cfe-commits

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[PATCH] D158715: [Driver] Cleanup last vestiges of Minix / Contiki support

2023-09-06 Thread Brad Smith via Phabricator via cfe-commits
brad added inline comments.



Comment at: clang/lib/Lex/InitHeaderSearch.cpp:336
-  case llvm::Triple::Minix:
-AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
-"", "", "", triple);

uabelho wrote:
> @brad :
> I think this was the last use of the AddGnuCPlusPlusIncludePaths method, 
> should we remove it now or is it likely it will be used again?
> 
> @brad :
> I think this was the last use of the AddGnuCPlusPlusIncludePaths method, 
> should we remove it now or is it likely it will be used again?

I noticed a function of the same name with the Darwin Driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158715

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


[PATCH] D157762: Implement [[msvc::no_unique_address]]

2023-09-06 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 556091.
akhuang added a comment.

add note to the docs about no ABI compatibility


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157762

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/AST/Decl.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Layout/ms-no-unique-address.cpp

Index: clang/test/Layout/ms-no-unique-address.cpp
===
--- /dev/null
+++ clang/test/Layout/ms-no-unique-address.cpp
@@ -0,0 +1,338 @@
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -triple x86_64-windows-msvc -fms-compatibility -fdump-record-layouts %s | FileCheck %s
+
+namespace Empty {
+  struct A {};
+  struct A2 {};
+  struct A3 { [[msvc::no_unique_address]] A a; };
+  struct alignas(8) A4 {};
+
+  struct B {
+[[msvc::no_unique_address]] A a;
+char b;
+  };
+  static_assert(sizeof(B) == 1);
+
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::B
+  // CHECK-NEXT: 0 |   struct Empty::A a (empty)
+  // CHECK-NEXT: 0 |   char b
+  // CHECK-NEXT:   | [sizeof=1, align=1,
+  // CHECK-NEXT:   |  nvsize=1, nvalign=1]
+
+  struct C {
+[[msvc::no_unique_address]] A a;
+[[msvc::no_unique_address]] A2 a2;
+char c;
+  };
+  static_assert(sizeof(C) == 1);
+
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::C
+  // CHECK-NEXT: 0 |   struct Empty::A a (empty)
+  // CHECK-NEXT: 0 |   struct Empty::A2 a2 (empty)
+  // CHECK-NEXT: 0 |   char c
+  // CHECK-NEXT:   | [sizeof=1, align=1,
+  // CHECK-NEXT:   |  nvsize=1, nvalign=1]
+
+  struct D {
+[[msvc::no_unique_address]] A3 a;
+int i;
+  };
+  static_assert(sizeof(D) == 8);
+
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::D
+  // CHECK-NEXT: 0 |   struct Empty::A3 a (empty)
+  // CHECK-NEXT: 0 | struct Empty::A a (empty)
+  // CHECK-NEXT: 4 |   int i
+  // CHECK-NEXT:   | [sizeof=8, align=4,
+  // CHECK-NEXT:   |  nvsize=8, nvalign=4]
+
+  struct E {
+[[msvc::no_unique_address]] A a1;
+[[msvc::no_unique_address]] A a2;
+char e;
+  };
+  static_assert(sizeof(E) == 2);
+
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::E
+  // CHECK-NEXT: 0 |   struct Empty::A a1 (empty)
+  // CHECK-NEXT: 1 |   struct Empty::A a2 (empty)
+  // CHECK-NEXT: 0 |   char e
+  // CHECK-NEXT:   | [sizeof=2, align=1,
+  // CHECK-NEXT:   |  nvsize=2, nvalign=1]
+
+  struct F {
+~F();
+[[msvc::no_unique_address]] A a1;
+[[msvc::no_unique_address]] A a2;
+char f;
+  };
+  static_assert(sizeof(F) == 2);
+
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::F
+  // CHECK-NEXT: 0 |   struct Empty::A a1 (empty)
+  // CHECK-NEXT: 1 |   struct Empty::A a2 (empty)
+  // CHECK-NEXT: 0 |   char f
+  // CHECK-NEXT:   | [sizeof=2, align=1,
+  // CHECK-NEXT:   |  nvsize=2, nvalign=1]
+
+  struct G { [[msvc::no_unique_address]] A a; ~G(); };
+  static_assert(sizeof(G) == 1);
+
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::G
+  // CHECK-NEXT: 0 |   struct Empty::A a (empty)
+  // CHECK-NEXT:   | [sizeof=1, align=1,
+  // CHECK-NEXT:   |  nvsize=1, nvalign=1]
+
+  struct H {
+[[msvc::no_unique_address]] A a;
+[[msvc::no_unique_address]] A b;
+~H();
+  };
+  static_assert(sizeof(H) == 2);
+
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::H
+  // CHECK-NEXT: 0 |   struct Empty::A a (empty)
+  // CHECK-NEXT: 1 |   struct Empty::A b (empty)
+  // CHECK-NEXT:   | [sizeof=2, align=1,
+  // CHECK-NEXT:   |  nvsize=2, nvalign=1]
+
+  struct I {
+[[msvc::no_unique_address]] A4 a;
+[[msvc::no_unique_address]] A4 b;
+  };
+  static_assert(sizeof(I) == 16);
+
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::I
+  // CHECK-NEXT: 0 |   struct Empty::A4 a (empty)
+  // CHECK-NEXT: 8 |   struct Empty::A4 b (empty)
+  // CHECK-NEXT:   | [sizeof=16, align=8,
+  // CHECK-NEXT:   |  nvsize=16, nvalign=8]
+
+  struct J {
+[[msvc::no_unique_address]] A4 a;
+A4 b;
+  };
+  static_assert(sizeof(J) == 16);
+
+  // MSVC puts a and b at the same offset.
+  // CHECK:*** Dumping AST Record Layout
+  // CHECK:  0 | struct Empty::J
+  // CHECK-NEXT: 0 |   struct Empty::A4 a (empty)
+  // CHECK-NEXT: 8 |   struct Empty::A4 b (empty)
+  // CHECK-NEXT:   | [sizeof=16, align=8,
+  // CHECK-NEXT:   |  nvsize=16, nvalign=8]
+
+  struct K {
+[[msvc::no_unique_address]] A4 a;
+[[msvc::no_unique_address]] char c;
+[[msvc::no_unique_address]] A4 b;
+  }

[PATCH] D147655: Implement mangling rules for C++20 concepts and requires-expressions.

2023-09-06 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Ping. Are there any further concerns here? (This obviously needs to be merged 
with trunk, and the `-fclang-abi-compat=` checks and release notes need to be 
updated to match the latest release version.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147655

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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits

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


[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits

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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/2] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec14..024aa8959fb720 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 00..647b7ea34be342
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// 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_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.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 {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef8..003bf132b38b4d 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 
a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_

[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-06 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/2] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec14..024aa8959fb720 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 00..647b7ea34be342
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// 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_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.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 {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef8..003bf132b38b4d 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 
a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_

[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

silee2 wrote:

> I suggest to extract `mgpu` interface changes and `serializetoSpirv` pass to 
> 2 separate PRs.

Agree. And the changes are originally from different authors so should be 
splitted.

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


[clang] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

silee2 wrote:

> I suggest to extract `mgpu` interface changes and `serializetoSpirv` pass to 
> 2 separate PRs.

Agree. And the changes are originally from different authors so should be 
splitted.

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


[clang-tools-extra] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via cfe-commits

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


  1   2   3   4   5   >