[clang-tools-extra] 541ef3d - Include instead of "llvm/ADT/Optional.h"

2022-12-18 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-18T00:28:54-08:00
New Revision: 541ef3d61e9341cd38420c0dbca9250c4d0ea04c

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

LOG: Include  instead of "llvm/ADT/Optional.h"

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang-tools-extra/clangd/Config.h
llvm/include/llvm/Support/Allocator.h
llvm/include/llvm/Support/FormatProviders.h
llvm/include/llvm/Support/NativeFormatting.h
llvm/include/llvm/Support/VersionTuple.h
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/Support/OptimizedStructLayout.cpp
llvm/lib/Support/Threading.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 7123a900f4175..cbc9c79a66249 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -26,10 +26,10 @@
 
 #include "support/Context.h"
 #include "llvm/ADT/FunctionExtras.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include 
+#include 
 #include 
 #include 
 

diff  --git a/llvm/include/llvm/Support/Allocator.h 
b/llvm/include/llvm/Support/Allocator.h
index ab3e12216d984..c1e5c6d2853bd 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -17,7 +17,6 @@
 #ifndef LLVM_SUPPORT_ALLOCATOR_H
 #define LLVM_SUPPORT_ALLOCATOR_H
 
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Alignment.h"
 #include "llvm/Support/AllocatorBase.h"
@@ -28,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace llvm {

diff  --git a/llvm/include/llvm/Support/FormatProviders.h 
b/llvm/include/llvm/Support/FormatProviders.h
index 3fcd1b38a9675..44da741b456e9 100644
--- a/llvm/include/llvm/Support/FormatProviders.h
+++ b/llvm/include/llvm/Support/FormatProviders.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_SUPPORT_FORMATPROVIDERS_H
 #define LLVM_SUPPORT_FORMATPROVIDERS_H
 
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
@@ -22,6 +21,7 @@
 #include "llvm/Support/NativeFormatting.h"
 
 #include 
+#include 
 #include 
 
 namespace llvm {

diff  --git a/llvm/include/llvm/Support/NativeFormatting.h 
b/llvm/include/llvm/Support/NativeFormatting.h
index 6fc1ee8d190ef..ab85ae20161c2 100644
--- a/llvm/include/llvm/Support/NativeFormatting.h
+++ b/llvm/include/llvm/Support/NativeFormatting.h
@@ -9,8 +9,8 @@
 #ifndef LLVM_SUPPORT_NATIVEFORMATTING_H
 #define LLVM_SUPPORT_NATIVEFORMATTING_H
 
-#include "llvm/ADT/Optional.h"
 #include 
+#include 
 
 namespace llvm {
 class raw_ostream;

diff  --git a/llvm/include/llvm/Support/VersionTuple.h 
b/llvm/include/llvm/Support/VersionTuple.h
index 1483252f4f7da..1118754f7fd46 100644
--- a/llvm/include/llvm/Support/VersionTuple.h
+++ b/llvm/include/llvm/Support/VersionTuple.h
@@ -16,8 +16,8 @@
 
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/Support/Endian.h"
+#include 
 #include 
 #include 
 

diff  --git a/llvm/include/llvm/Support/VirtualFileSystem.h 
b/llvm/include/llvm/Support/VirtualFileSystem.h
index 71dbc80edf9a5..3ef17a7de379d 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -15,7 +15,6 @@
 #define LLVM_SUPPORT_VIRTUALFILESYSTEM_H
 
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
@@ -29,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

diff  --git a/llvm/lib/Support/OptimizedStructLayout.cpp 
b/llvm/lib/Support/OptimizedStructLayout.cpp
index c64eff60c0b12..7b21f927a3462 100644
--- a/llvm/lib/Support/OptimizedStructLayout.cpp
+++ b/llvm/lib/Support/OptimizedStructLayout.cpp
@@ -11,7 +11,7 @@
 
//===--===//
 
 #include "llvm/Support/OptimizedStructLayout.h"
-#include "llvm/ADT/Optional.h"
+#include 
 
 using namespace llvm;
 

diff  --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index f4e3331a4b9b1..923935bbca103 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -12,12 +12,12 @@
 
//===--===//
 
 #include "llvm/Support/Threading.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/Config/config.h"
 #include "llvm/Config/llvm-config.h"
 
 #include 
 #include 
+#include 
 #include 

[clang] bd7f4c5 - [C++20][Modules] Elide unused guard variables in Itanium ABI module initializers.

2022-12-18 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2022-12-18T09:16:27Z
New Revision: bd7f4c561f5e2385ebe5500a044efe0de30cccaa

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

LOG: [C++20][Modules] Elide unused guard variables in Itanium ABI module 
initializers.

For the Itanium ABI, we emit an initializer for each module.  This is 
responsible
for handling initialization of global vars.  Relates to P1874R1.

The initializer has a known mangling and is automatically called from any TU 
that
imports a module. Since, at present, the importer has no way to determine that 
an
imported module does not require an initializer, we generate the initializer for
all cases (even when it is empty).

Initializers must be run once, with the ordering guaranteed by the import graph
and this is ensured in the current code by addition of a guard variable.

In the case that a module has no requirement for global initializers, and also 
does
not import any other modules, we can elide the guard variable.

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

Added: 
clang/test/CodeGenCXX/module-initializer-guard-elision.cpp

Modified: 
clang/lib/CodeGen/CGDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 009749b38509b..dcd811ea257b3 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -640,7 +640,12 @@ void CodeGenModule::EmitCXXThreadLocalInitFunc() {
 
 /* Build the initializer for a C++20 module:
This is arranged to be run only once regardless of how many times the module
-   might be included transitively.  This arranged by using a control variable.
+   might be included transitively.  This arranged by using a guard variable.
+
+   If there are no initalizers at all (and also no imported modules) we reduce
+   this to an empty function (since the Itanium ABI requires that this function
+   be available to a caller, which might be produced by a 
diff erent
+   implementation).
 
First we call any initializers for imported modules.
We then call initializers for the Global Module Fragment (if present)
@@ -652,13 +657,10 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module 
*Primary) {
   while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
 CXXGlobalInits.pop_back();
 
-  // We create the function, even if it is empty, since an importer of this
-  // module will refer to it unconditionally (for the current implementation
-  // there is no way for the importer to know that an importee does not need
-  // an initializer to be run).
-
+  // As noted above, we create the function, even if it is empty.
   // Module initializers for imported modules are emitted first.
-  // Collect the modules that we import
+
+  // Collect all the modules that we import
   SmallVector AllImports;
   // Ones that we export
   for (auto I : Primary->Exports)
@@ -685,7 +687,6 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 FTy, llvm::Function::ExternalLinkage, FnName.str(), &getModule());
 ModuleInits.push_back(Fn);
   }
-  AllImports.clear();
 
   // Add any initializers with specified priority; this uses the same  approach
   // as EmitCXXGlobalInitFunc().
@@ -703,13 +704,11 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module 
*Primary) {
   for (; I < PrioE; ++I)
 ModuleInits.push_back(I->second);
 }
-PrioritizedCXXGlobalInits.clear();
   }
 
   // Now append the ones without specified priority.
   for (auto *F : CXXGlobalInits)
 ModuleInits.push_back(F);
-  CXXGlobalInits.clear();
 
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
   const CGFunctionInfo &FI = getTypes().arrangeNullaryFunction();
@@ -719,7 +718,6 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
   // each init is run just once (even though a module might be imported
   // multiple times via nested use).
   llvm::Function *Fn;
-  llvm::GlobalVariable *Guard = nullptr;
   {
 SmallString<256> InitFnName;
 llvm::raw_svector_ostream Out(InitFnName);
@@ -729,18 +727,26 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module 
*Primary) {
 FTy, llvm::Twine(InitFnName), FI, SourceLocation(), false,
 llvm::GlobalVariable::ExternalLinkage);
 
-Guard = new llvm::GlobalVariable(getModule(), Int8Ty, /*isConstant=*/false,
- llvm::GlobalVariable::InternalLinkage,
- llvm::ConstantInt::get(Int8Ty, 0),
- InitFnName.str() + "__in_chrg");
+// If we have a completely empty initializer then we do not want to create
+// the guard variable.
+ConstantAddress GuardAddr = ConstantAddress::invalid();
+if (!AllImports.empty() || !PrioritizedCXXGlobalInits.

[PATCH] D134589: [C++20][Modules] Elide unused guard variables in Itanium ABI module initializers.

2022-12-18 Thread Iain Sandoe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd7f4c561f5e: [C++20][Modules] Elide unused guard variables 
in Itanium ABI module… (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134589

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/test/CodeGenCXX/module-initializer-guard-elision.cpp

Index: clang/test/CodeGenCXX/module-initializer-guard-elision.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/module-initializer-guard-elision.cpp
@@ -0,0 +1,69 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.cpp \
+// RUN:-emit-module-interface -o O.pcm
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.pcm -S -emit-llvm \
+// RUN:  -o - | FileCheck %s --check-prefix=CHECK-O
+
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 P.cpp \
+// RUN:-emit-module-interface -fmodule-file=O.pcm -o P.pcm
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 P.pcm -S -emit-llvm \
+// RUN:  -o - | FileCheck %s --check-prefix=CHECK-P
+
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 Q.cpp \
+// RUN:-emit-module-interface -fmodule-file=O.pcm -o Q.pcm
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 Q.pcm -S -emit-llvm \
+// RUN:  -o - | FileCheck %s --check-prefix=CHECK-Q
+
+// Testing cases where we can elide the module initializer guard variable.
+
+// This module has no global inits and does not import any other module
+//--- O.cpp
+
+export module O;
+
+export int foo ();
+
+// CHECK-O: define void @_ZGIW1O
+// CHECK-O-LABEL: entry
+// CHECK-O-NEXT: ret void
+// CHECK-O-NOT: @_ZGIW1O__in_chrg
+
+// This has no global inits but imports a module, and therefore needs a guard
+// variable.
+//--- P.cpp
+
+export module P;
+
+export import O;
+export int bar ();
+
+// CHECK-P: define void @_ZGIW1P
+// CHECK-P-LABEL: init
+// CHECK-P: store i8 1, ptr @_ZGIW1P__in_chrg
+// CHECK-P: call void @_ZGIW1O()
+// CHECK-P-NOT: call void @__cxx_global_var_init
+
+// This imports a module and has global inits, so needs a guard.
+//--- Q.cpp
+
+export module Q;
+export import O;
+
+export struct Quack {
+  Quack(){};
+};
+
+export Quack Duck;
+
+export int baz ();
+
+// CHECK-Q: define internal void @__cxx_global_var_init
+// CHECK-Q: call {{.*}} @_ZNW1Q5QuackC1Ev
+// CHECK-Q: define void @_ZGIW1Q
+// CHECK-Q: store i8 1, ptr @_ZGIW1Q__in_chrg
+// CHECK-Q: call void @_ZGIW1O()
+// CHECK-Q: call void @__cxx_global_var_init
+
Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -640,7 +640,12 @@
 
 /* Build the initializer for a C++20 module:
This is arranged to be run only once regardless of how many times the module
-   might be included transitively.  This arranged by using a control variable.
+   might be included transitively.  This arranged by using a guard variable.
+
+   If there are no initalizers at all (and also no imported modules) we reduce
+   this to an empty function (since the Itanium ABI requires that this function
+   be available to a caller, which might be produced by a different
+   implementation).
 
First we call any initializers for imported modules.
We then call initializers for the Global Module Fragment (if present)
@@ -652,13 +657,10 @@
   while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
 CXXGlobalInits.pop_back();
 
-  // We create the function, even if it is empty, since an importer of this
-  // module will refer to it unconditionally (for the current implementation
-  // there is no way for the importer to know that an importee does not need
-  // an initializer to be run).
-
+  // As noted above, we create the function, even if it is empty.
   // Module initializers for imported modules are emitted first.
-  // Collect the modules that we import
+
+  // Collect all the modules that we import
   SmallVector AllImports;
   // Ones that we export
   for (auto I : Primary->Exports)
@@ -685,7 +687,6 @@
 FTy, llvm::Function::ExternalLinkage, FnName.str(), &getModule());
 ModuleInits.push_back(Fn);
   }
-  AllImports.clear();
 
   // Add any initializers with specified priority; this uses the same  approach
   // as EmitCXXGlobalInitFunc().
@@ -703,13 +704,11 @@
   for (; I < PrioE; ++I)
 ModuleInits.push_back(I->second);
 }
-PrioritizedCXXGlobalInits.clear();
   }
 
   // Now append the ones without specified priority.
   for (auto *F : CXXGlobalInits)
 ModuleInits.push_back(F);
-  CXXGlobalInits.clear();
 
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
   const CGFunctionInfo &FI = getTypes().arrangeNullaryFunction();
@@ -719,7 +718,6 @@
   // each init is run just once (

[PATCH] D140267: [clang-format] Allow line break between template closer and right paren

2022-12-18 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Maybe do not limit to `JsTypeColon` but all colons? What about something like 
`f(some_template).method()`? I'd have to check where it breaks if 
there isn't a template in the argument, but I'd guess not before the paren.




Comment at: clang/lib/Format/TokenAnnotator.cpp:4953-4958
   if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener))
 return true;
+  if (Left.is(TT_TemplateCloser) && Right.is(tok::r_paren) &&
+  (!Right.Next || Right.Next->isNot(TT_JsTypeColon))) {
+return true;
+  }

Could you merge this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140267

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


[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2022-12-18 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added a comment.

ping


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

https://reviews.llvm.org/D135495

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


[PATCH] D140086: [analyzer][solver] Improve reasoning for not equal to operator

2022-12-18 Thread Manas Gupta via Phabricator via cfe-commits
manas added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1642
+if (LHS.isUnsigned() ^ RHS.isUnsigned()) {
+  if (LHS.isUnsigned() && (LHS.getBitWidth() >= RHS.getBitWidth())) {
+

steakhal wrote:
> manas wrote:
> > steakhal wrote:
> > > Why do we need this additional condition?
> > > If I remove these, I get no test failures, which suggests to me that we 
> > > have some undertested code paths here.
> > > Why do we need this additional condition?
> > 
> > Bitwidth was important because we should ideally cast smaller bitwidth type 
> > to bigger bitwidth type.
> > 
> > Consider if we have `LHS(u8), RHS(i32)`, then without checking for 
> > bitwidth, we would be casting RHS's maxValue to LHS's type, which will 
> > result in lose of information and will not serve our purpose.
> > 
> > 
> If you think we need that bitwidth check, why did you remove it?
> I'd like to see test cases demonstrating what we are talking about and see if 
> we want that behavior or not.
This test fails.

```

void testfoo(unsigned char u, signed int s) {
  if (u >= 253 && u <= 255 && s < INT_MAX - 2) {
// u: [253, 254], s: [INT_MIN, INT_MAX - 2]
clang_analyzer_eval(u != s); // expected-warning{{UNKNOWN}}
 // but returns TRUE
  }
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140086

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


[PATCH] D124351: [Clang][WIP] Implement Change scope of lambda trailing-return-type - Take 2

2022-12-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 483812.
cor3ntin added a comment.

Handle late constraints checking and fully implement P2579 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1358,7 +1358,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 16
 
 
   https://wg21.link/P2579R0";>P2579R0
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} ();
+  [x = 1]() mutable requires is_same {} ();
+}
+
+void err() {
+  int y, z;
+  (void)[x = 1]
+  requires(is_same) {};
+
+  (void)[x = 1]{};
+
+  (void)[=]{};
+
+  (void)[z]{};
+}
+
+void gnu_attributes() {
+  int y;
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "war

[PATCH] D124351: [Clang][WIP] Implement Change scope of lambda trailing-return-type - Take 2

2022-12-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 483813.
cor3ntin added a comment.

Update release notes and commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1358,7 +1358,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 16
 
 
   https://wg21.link/P2579R0";>P2579R0
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} ();
+  [x = 1]() mutable requires is_same {} ();
+}
+
+void err() {
+  int y, z;
+  (void)[x = 1]
+  requires(is_same) {};
+
+  (void)[x = 1]{};
+
+  (void)[=]{};
+
+  (void)[z]{};
+}
+
+void gnu_attributes() {
+  int y;
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[x=1]() __attribute__((diagno

[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-12-18 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In D138179#4002068 , @nathanchance 
wrote:

> For what it's worth, this breaks building the Linux kernel's `ARCH=mips 
> 32r1_defconfig` with clang and GNU as, with thousands of messages along the 
> line of:
>
>   /tmp/mmc_ops-d329c3.s: Assembler messages:
>   /tmp/mmc_ops-d329c3.s:310: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:473: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:594: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:687: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:781: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:946: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:1023: Error: .module is not permitted after 
> generating code
>   ...
>
> A simplified reproducer:
>
>   void rcu_normal_store() {}
>   void __attribute__ksysfs_init() {}

Thanks for your test. I will work it just now.

>   $ clang --version | head -1
>   ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 
> 9739bb81aed490bfcbcbbac6970da8fb7232fd34)
>   
>   $ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null ksysfs.i
>   /tmp/ksysfs-9b0c50.s: Assembler messages:
>   /tmp/ksysfs-9b0c50.s:44: Error: .module is not permitted after generating 
> code
>   clang-16: error: assembler command failed with exit code 1 (use -v to see 
> invocation)
>
>
>
>   $ clang --version | head -1
>   ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 
> 92619956eb27ef08dd24045307593fc3d7f78db0)
>   
>   $ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null ksysfs.i



In D138179#4002068 , @nathanchance 
wrote:

> For what it's worth, this breaks building the Linux kernel's `ARCH=mips 
> 32r1_defconfig` with clang and GNU as, with thousands of messages along the 
> line of:
>
>   /tmp/mmc_ops-d329c3.s: Assembler messages:
>   /tmp/mmc_ops-d329c3.s:310: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:473: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:594: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:687: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:781: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:946: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:1023: Error: .module is not permitted after 
> generating code
>   ...
>
> A simplified reproducer:
>
>   void rcu_normal_store() {}
>   void __attribute__ksysfs_init() {}
>
>
>
>   $ clang --version | head -1
>   ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 
> 9739bb81aed490bfcbcbbac6970da8fb7232fd34)
>   
>   $ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null ksysfs.i
>   /tmp/ksysfs-9b0c50.s: Assembler messages:
>   /tmp/ksysfs-9b0c50.s:44: Error: .module is not permitted after generating 
> code
>   clang-16: error: assembler command failed with exit code 1 (use -v to see 
> invocation)
>
>
>
>   $ clang --version | head -1
>   ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 
> 92619956eb27ef08dd24045307593fc3d7f78db0)
>   
>   $ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null ksysfs.i




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138179

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


[PATCH] D137531: [clang] Add the check of membership in decltype for the issue #58674

2022-12-18 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 483815.
lime added a comment.

Rebase and ping!


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

https://reviews.llvm.org/D137531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2692,20 +2692,34 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember = ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -326,6 +326,9 @@
 - Fix bug where constant evaluation treated a pointer to member that points to
   a weak member as never being null. Such comparisons are now treated as
   non-constant.
+- Fix an issue about ``decltype`` in the members of class templates derived from
+  templates with related parameters.
+  `Issue 58674 `_
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type

2022-12-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 483816.
cor3ntin added a comment.

Remove unused variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1358,7 +1358,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 16
 
 
   https://wg21.link/P2579R0";>P2579R0
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} ();
+  [x = 1]() mutable requires is_same {} ();
+}
+
+void err() {
+  int y, z;
+  (void)[x = 1]
+  requires(is_same) {};
+
+  (void)[x = 1]{};
+
+  (void)[=]{};
+
+  (void)[z]{};
+}
+
+void gnu_attributes() {
+  int y;
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  (void)[

[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type

2022-12-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 483817.
cor3ntin added a comment.

revert WS only change, removed unused `DelayedCapture` type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1358,7 +1358,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 16
 
 
   https://wg21.link/P2579R0";>P2579R0
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} ();
+  [x = 1]() mutable requires is_same {} ();
+}
+
+void err() {
+  int y, z;
+  (void)[x = 1]
+  requires(is_same) {};
+
+  (void)[x = 1]{};
+
+  (void)[=]{};
+
+  (void)[z]{};
+}
+
+void gnu_attributes() {
+  int y;
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "

[PATCH] D137531: [clang] Add the check of membership in decltype for the issue #58674

2022-12-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D137531#4003723 , @lime wrote:

> Rebase and ping!

I think looks good, but I want to make sure @erichkeane finds his comments 
resolved, and he is in vacation until January.


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

https://reviews.llvm.org/D137531

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


[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type

2022-12-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 483820.
cor3ntin added a comment.

Remove the lookahead parsing code code which is no longer necessary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1358,7 +1358,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 16
 
 
   https://wg21.link/P2579R0";>P2579R0
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} ();
+  [x = 1]() mutable requires is_same {} ();
+}
+
+void err() {
+  int y, z;
+  (void)[x = 1]
+  requires(is_same) {};
+
+  (void)[x = 1]{};
+
+  (void)[=]{};
+
+  (void)[z]{};
+}
+
+void gnu_attributes() {
+  int y;
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  

[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-12-18 Thread Aaron Gokaslan via Phabricator via cfe-commits
Skylion007 added a comment.

Pinging @njames93 to about the questions from the previous comment. Would love 
to see something like this PR get merged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-12-18 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

https://reviews.llvm.org/D140270


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138179

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


[PATCH] D140226: [NVPTX] Introduce attribute to mark kernels without a language mode

2022-12-18 Thread Ronan Keryell via Phabricator via cfe-commits
keryell added subscribers: bader, keryell.
keryell added a comment.

I wonder whether we could not factorize some code/attribute/logic with AMDGPU 
or SYCL.
Is the use case to have for example CUDA+HIP+SYCL in the same TU and thus there 
is a need for different attributes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140226

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


[PATCH] D140226: [NVPTX] Introduce attribute to mark kernels without a language mode

2022-12-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D140226#4003781 , @keryell wrote:

> I wonder whether we could not factorize some code/attribute/logic with AMDGPU 
> or SYCL.
> Is the use case to have for example CUDA+HIP+SYCL in the same TU and thus 
> there is a need for different attributes

It would probably be good to have the high level concept of a "kernel" be 
factored out since this is common between all the offloading languages. The 
actual implementation it gets lowered to would still need to be distinct since 
this usually gets turned into some magic bits stashed in the executable for the 
runtime to read. The use-case for this patch is simply to allow people to 
compile pure C/C++ code to the NVPTX architecture, but still be able to mark 
the necessary metadata for kernels and globals.

I've recently thought if we could just apply the same logic used for shared 
objects with GPU images, that is globals without `hidden` visibility would be 
considered `__global__` and ones with `hidden` visibility would be considered 
`__device__` in CUDA terms. I think the only thing preventing us from thinking 
of a kernel call as a dynamic symbol load is probably the launch parameters. 
But this is purely theoretical, I don't think we need to worry about moving 
away from offloading languages or anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140226

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


[PATCH] D140226: [NVPTX] Introduce attribute to mark kernels without a language mode

2022-12-18 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

There are already SYCL specific attributes: https://reviews.llvm.org/D60455


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140226

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


[PATCH] D140226: [NVPTX] Introduce attribute to mark kernels without a language mode

2022-12-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D140226#4003788 , @tschuett wrote:

> There are already SYCL specific attributes: https://reviews.llvm.org/D60455

We could potentially merge these all into some generic attribute since they all 
do the same thing on a conceptual level. The unique thing about the existing 
`amdgpu_kernel` and corresponding `nvptx_kernel` is that they don't rely on the 
language options like `SYCL` or `CUDA`. Though, semantically those are 
definitely involved because the kernel itself is only meaningful to whatever 
runtime is going to load it (e.g. CUDA or HSA) but we can probably consider 
that separately to the compilation itself and just think of these as calling 
conventions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140226

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


[PATCH] D140226: [NVPTX] Introduce attribute to mark kernels without a language mode

2022-12-18 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

In D140226#4003794 , @jhuber6 wrote:

> In D140226#4003788 , @tschuett 
> wrote:
>
>> There are already SYCL specific attributes: https://reviews.llvm.org/D60455
>
> We could potentially merge these all into some generic attribute since they 
> all do the same thing on a conceptual level. The unique thing about the 
> existing `amdgpu_kernel` and corresponding `nvptx_kernel` is that they don't 
> rely on the language options like `SYCL` or `CUDA`. Though, semantically 
> those are definitely involved because the kernel itself is only meaningful to 
> whatever runtime is going to load it (e.g. CUDA or HSA) but we can probably 
> consider that separately to the compilation itself and just think of these as 
> calling conventions.

But then you are maybe mixing two concepts. `kernel` is source code or AST 
feature. nvptx or AMDGPU are command line flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140226

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


[PATCH] D139986: [clang][TypePrinter] Teach isSubstitutedDefaultArgument about integral types

2022-12-18 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D139986#4001180 , @Michael137 
wrote:

> Missed couple of test cases in libcxx
> About to fix those

There were more breakage due to this patch, which I fixed in D140272 
.

Next time please don't commit patches when the pre-commit CI is red. This build 
https://buildkite.com/llvm-project/libcxx-ci/builds/16118 shows the patch will 
break libc++. These pre-commit CI jobs were added specifically to aid the Clang 
developers to validate whether their changes break libc++. Libc++ heavily 
relies on its pre-commit CI so breaking the CI has a huge impact.
Note that when libc++ breaks there might be other projects that use the latest 
Clang HEAD that will be affected too. (Not likely with diagnostics, but likely 
when the modular build fails.)

When you have issues resolving the libc++ issues you can always reach out to us 
for assistance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139986

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


[PATCH] D140226: [NVPTX] Introduce attribute to mark kernels without a language mode

2022-12-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D140226#4003826 , @tschuett wrote:

> But then you are maybe mixing two concepts. `kernel` is source code or AST 
> feature. nvptx or AMDGPU are command line flags.
>
> CUDA, Sycl, nvtx, and AMDGPU are modes or calling conventions?

The way I understand it, the architecture determines the actual ISA for the 
code and the `kernel` metadata operates like a calling convention for whatever 
"OS" will be executing it. For example, for the triple `amdgcn-amd-amdhsa` we 
generate code for the `amdgcn` architecture and emit kernels such that the 
`hsa` runtime can call them. Similarly, for `nvptx64-nvidia-cuda` we emit code 
for `nvptx64` and our kernels use the calling convention such that the `cuda` 
runtime can call them. I think the main question of this patch is if we can 
separate the `cuda` runtime from the CUDA language. That is, we don't need to 
be using the CUDA language to emit functions that the `cuda` runtime can call. 
So this is more or less thinking of these kernel calls as a calling convention 
for a runtime or operating system rather than as a language feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140226

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


[PATCH] D137020: [clang][AST] Handle variable declaration with unknown typedef in C

2022-12-18 Thread Dilshod Urazov via Phabricator via cfe-commits
urazoff added a comment.

@sammccall @aaron.ballman I am thinking about another solution with tentative 
parsing as implemented for C++ in `Parser::isCXXSimpleDeclaration` (which is 
eventually called from `isDeclarationStatement()`). This approach works well 
for C++. So I want to update this patch with this approach.


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

https://reviews.llvm.org/D137020

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


[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2022-12-18 Thread Romain Geissler via Phabricator via cfe-commits
Romain-Geissler-1A added a comment.
Herald added a subscriber: steakhal.

Hi,

Is there any update about this ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

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


[PATCH] D140274: [clangd] Tweak to fill struct with designated initializers

2022-12-18 Thread Oleg Skoromnik via Phabricator via cfe-commits
tupos created this revision.
tupos added reviewers: sammccall, njames93.
tupos added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
tupos requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140274

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/FillStructDesignatedInit.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/FillStructDesignatedInitTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/FillStructDesignatedInitTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/FillStructDesignatedInitTests.cpp
@@ -0,0 +1,126 @@
+//===-- FillStructDesignatedInitTests.cpp ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TweakTesting.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(FillStructDesignatedInit);
+
+TEST_F(FillStructDesignatedInitTest, AvailableUnavailable) {
+  Header = R"cpp(
+namespace ns1 {
+  struct Foo {
+Foo() {}
+  };
+}
+  )cpp";
+  EXPECT_UNAVAILABLE(R"cpp(
+namespace ns1 {
+  struct Bar {
+int x;
+int y;
+  };
+  void bar(Bar b) {}
+  void foo() {
+Bar b[[{}]];
+  }
+}
+  )cpp");
+  ExtraArgs.push_back("-std=c++20");
+  EXPECT_UNAVAILABLE(R"cpp(
+namespace ns1 {
+  struct Bar : Foo {
+int x;
+int y;
+  };
+  void bar(Bar b) {}
+  void foo() {
+Bar b[[{}]];
+  }
+}
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+namespace ns1 {
+  struct Bar {
+int x;
+int y;
+  };
+  void bar(Bar b) {}
+  void foo() {
+Bar b[[{}]];
+bar([[{}]]);
+  }
+}
+  )cpp");
+}
+
+TEST_F(FillStructDesignatedInitTest, Apply1) {
+  ExtraArgs.push_back("-std=c++20");
+  EXPECT_EQ(apply(R"cpp(
+namespace ns1 {
+  struct D1 {
+int x;
+int* y;
+  };
+  void foo() {
+D1 b[[{}]];
+  }
+}
+  )cpp"),
+R"cpp(
+namespace ns1 {
+  struct D1 {
+int x;
+int* y;
+  };
+  void foo() {
+D1 b{.x = int{}, .y = {}};
+  }
+}
+  )cpp");
+}
+
+TEST_F(FillStructDesignatedInitTest, Apply2) {
+  ExtraArgs.push_back("-std=c++20");
+  Header = R"cpp(
+namespace ns {
+  struct B1 {
+int b1;
+  };
+}
+namespace ns1 {
+  struct D1 {
+int* x;
+ns::B1 b1;
+  };
+}
+  )cpp";
+  EXPECT_EQ(apply(R"cpp(
+namespace ns1 {
+  void foo() {
+D1 b[[{}]];
+  }
+}
+  )cpp"),
+R"cpp(
+namespace ns1 {
+  void foo() {
+D1 b{.x = {}, .b1 = ns::B1{}};
+  }
+}
+  )cpp");
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -118,6 +118,7 @@
   tweaks/ExpandMacroTests.cpp
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp
+  tweaks/FillStructDesignatedInitTests.cpp
   tweaks/MemberwiseConstructorTests.cpp
   tweaks/ObjCLocalizeStringLiteralTests.cpp
   tweaks/ObjCMemberwiseInitializerTests.cpp
Index: clang-tools-extra/clangd/refactor/tweaks/FillStructDesignatedInit.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/FillStructDesignatedInit.cpp
@@ -0,0 +1,128 @@
+//===--- FillStructDesignatedInit.cpp ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "AST.h"
+#include "Selection.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// A tweak that fills an aggregate witho

[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2022-12-18 Thread Oleg Skoromnik via Phabricator via cfe-commits
tupos created this revision.
tupos added reviewers: sammccall, njames93.
tupos added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
tupos requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140275

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/AddDoxygenCommentTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/AddDoxygenCommentTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/AddDoxygenCommentTests.cpp
@@ -0,0 +1,98 @@
+//===-- AddDoxygenCommentTests.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TweakTesting.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(AddDoxygenComment);
+
+TEST_F(AddDoxygenCommentTest, AvailableUnavailable) {
+  EXPECT_AVAILABLE(R"cpp(
+void bar(char b) {^ }
+[[int foo(int x) { }]]
+namespace ns1 {
+  void bar(char b) {^ }
+  [[int foo(int x) { }]]
+}
+  )cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+namespace ns1 {
+  /*!
+   */
+  void bar(char b) {^ }
+  // comment
+  [[int foo(int x) { }]]
+  /// comment
+  [[int meaw(int x) { }]]
+}
+  )cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, Apply1) {
+  EXPECT_EQ(apply(R"cpp(
+namespace ns1 {
+  int foo(int y, char* s) {
+^int x;
+return x;
+  }
+}
+  )cpp"),
+R"cpp(
+namespace ns1 {
+  
+/*!
+ * @brief
+ *
+* @param y
+* @param s
+* @return
+*/
+int foo(int y, char* s) {
+int x;
+return x;
+  }
+}
+  )cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, Apply2) {
+  EXPECT_EQ(apply(R"cpp(
+void foo();
+void ^bar();
+namespace ns1 {
+  int foo(int y, char* s) {
+int x;
+return x;
+  }
+}
+)cpp"),
+R"cpp(
+void foo();
+
+/*!
+ * @brief
+ *
+*/
+void bar();
+namespace ns1 {
+  int foo(int y, char* s) {
+int x;
+return x;
+  }
+}
+)cpp");
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -107,6 +107,7 @@
   support/TestTracer.cpp
   support/TraceTests.cpp
 
+  tweaks/AddDoxygenCommentTests.cpp
   tweaks/AddUsingTests.cpp
   tweaks/AnnotateHighlightingsTests.cpp
   tweaks/DefineInlineTests.cpp
Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -12,6 +12,7 @@
 # $ to a list of sources, see
 # clangd/tool/CMakeLists.txt for an example.
 add_clang_library(clangDaemonTweaks OBJECT
+  AddDoxygenComment.cpp
   AddUsing.cpp
   AnnotateHighlightings.cpp
   DumpAST.cpp
Index: clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp
@@ -0,0 +1,147 @@
+//===--- AddDoxydgenComment.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "AST.h"
+#include "Selection.h"
+#include "refactor/InsertionPoint.h"
+#include "refactor/Tweak.h"
+#include "support/Logger.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// A tweak that adds a doxygen comment to the function declaration
+//
+// Given:
+//   int func(int x, char const* s, Bar bar) {}
+// the tweak add the doxygen comment to the function in the form
+//   /*!
+//* @brief
+//* @param x
+//* @param s
+//* @param bar
+//* @return
+//*/
+//   int func(int x, char 

[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2022-12-18 Thread Oleg Skoromnik via Phabricator via cfe-commits
tupos added a comment.

I do not know but maybe it makes sence to make configurable the style of the 
comment, e.g instead of `@brief` use `\brief` and the same for `/*!` to `/**`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140275

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


[PATCH] D140226: [NVPTX] Introduce attribute to mark kernels without a language mode

2022-12-18 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Calling convention is the right model here. Kernels are functions with a 
different calling convention to the 'normal' functions in a very literal sense. 
The calling convention modelling in clang is different to attribute handling 
and changing nvptx to it is probably invasive, though it seems to me it could 
be done incrementally.

I wouldn't suggest adding a nvptx_kernel calling convention to clang though, 
rather we could repurpose the amdgpu one to be gpu_kernel. Possibly spelled 
nvptx_kernel for the user but represented within clang as gpu_kernel.

Related, I think there's a spirv or opencl kernel representation in llvm for 
amdgpu, I would be interested in collapsing those and the openmp or hip 
annotation to a single thing if possible.

That's all medium term cleanup ideas, current patch looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140226

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


[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2022-12-18 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.

In D112921#4003939 , 
@Romain-Geissler-1A wrote:

> Hi,
>
> Is there any update about this ?

Currently, no.
If someone is interesting in this, please feel free to commandeer. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

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


[PATCH] D140261: [C++20][Modules] Do not allow non-inline external definitions in header units.

2022-12-18 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM generally.




Comment at: clang/lib/Sema/SemaDecl.cpp:12957-12958
+  // units.
+  if (getLangOpts().CPlusPlus20 && getLangOpts().CPlusPlusModules &&
+  !ModuleScopes.empty() && ModuleScopes.back().Module->isHeaderUnit()) {
+if (VDecl->getFormalLinkage() == Linkage::ExternalLinkage &&

`getLangOpts().CPlusPlus20` is redundant. It is also good to define a helper 
interface `withinHeaderUnit` in Sema (not required).



Comment at: clang/lib/Sema/SemaDecl.cpp:15116-15117
+  // units.
+  if (getLangOpts().CPlusPlus20 && getLangOpts().CPlusPlusModules &&
+  !ModuleScopes.empty() && ModuleScopes.back().Module->isHeaderUnit()) {
+if (FD->getFormalLinkage() == Linkage::ExternalLinkage &&

ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140261

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


[PATCH] D116070: [X86] Enable ibt-seal optimization when LTO is used in Kernel

2022-12-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I have a question why the option is needed.

if (IBTSeal) {
  return F.hasAddressTaken();
}
// if !IBTSeal, fall into default case.
LLVM_FALLTHROUGH;
  // Address taken or externally linked functions may be reachable.
  default:
return (F.hasAddressTaken() || !F.hasLocalLinkage());

`F.hasAddressTaken() || !F.hasLocalLinkage()` can be changed to 
`F.hasAddressTaken() || (F.hasHiddenVisibility() && !F.hasLocalLinkage())`

Why can't the kernel use `-fvisibility=hidden`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116070

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


[PATCH] D116070: [X86] Enable ibt-seal optimization when LTO is used in Kernel

2022-12-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

(I substantially edited my previous comment.) It now says this:

> If the link mixes bitcode files and ELF relocatable files, for a function in 
> a bitcode file, `F.hasAddressTaken()` doesn't indicate that its address is 
> not taken by an ELF relocatable file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116070

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


[PATCH] D140281: [X86] Rename CMPCCXADD intrinsics.

2022-12-18 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added a subscriber: pengfei.
Herald added a project: All.
FreddyYe requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

"__cmpccxadd_epi*" -> "_cmpccxadd_epi*"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140281

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/cmpccxaddintrin.h
  clang/test/CodeGen/X86/cmpccxadd-builtins-error-32.c
  clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
  clang/test/CodeGen/X86/cmpccxadd-builtins.c

Index: clang/test/CodeGen/X86/cmpccxadd-builtins.c
===
--- clang/test/CodeGen/X86/cmpccxadd-builtins.c
+++ clang/test/CodeGen/X86/cmpccxadd-builtins.c
@@ -7,191 +7,191 @@
 int test_cmpbexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpbexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 0)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_O);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_O);
 }
 
 long long test_cmpbexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpbexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 0)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_O);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_O);
 }
 
 int test_cmpbxadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpbxadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 1)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NO);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NO);
 }
 
 long long test_cmpbxadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpbxadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 1)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NO);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NO);
 }
 
 int test_cmplexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmplexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 2)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_B);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_B);
 }
 
 long long test_cmplexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmplexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 2)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_B);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_B);
 }
 
 int test_cmplxadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmplxadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 3)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NB);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NB);
 }
 
 long long test_cmplxadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmplxadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 3)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NB);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NB);
 }
 
 int test_cmpnbexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpnbexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 4)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_Z);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_Z);
 }
 
 long long test_cmpnbexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpnbexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 4)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_Z);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_Z);
 }
 
 int test_cmpnbxadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpnbxadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 5)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NZ);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NZ);
 }
 
 long long test_cmpnbxadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpnbxadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 5)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NZ);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NZ);
 }
 
 int test_cmpnlexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpnlexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 6)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_BE);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_BE);
 }
 
 long long test_cmpnlexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpnlexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 6)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_

[PATCH] D139701: [Clang] Don't emit "min-legal-vector-width"="0" for AMDGPU

2022-12-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Please update the title


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139701

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


[PATCH] D137058: [Driver] [Modules] Support -fmodule-output (1/2)

2022-12-18 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:5541-5545
+if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+  TempPath = FinalOutput->getValue();
+else
+  TempPath = BaseInput;
+

tahonermann wrote:
> ChuanqiXu wrote:
> > dblaikie wrote:
> > > ChuanqiXu wrote:
> > > > dblaikie wrote:
> > > > > dblaikie wrote:
> > > > > > ChuanqiXu wrote:
> > > > > > > dblaikie wrote:
> > > > > > > > It'd be nice if we didn't have to recompute this/lookup `OPT_o` 
> > > > > > > > here - any way we can use the object file output path here 
> > > > > > > > (that's already handled `OPT_o` or using the base input name, 
> > > > > > > > etc)?
> > > > > > > I didn't understand this a lot. We don't compute anything here 
> > > > > > > and we just use the object file output path here if `-o` is 
> > > > > > > provided and we replace the suffix then. I feel this is simple 
> > > > > > > enough.
> > > > > > Computing the path to write to is what I'm referring to - and the 
> > > > > > fact that this had a bug (was relative to the source path instead 
> > > > > > of the CWD)/divergence from the `-o` path logic is the sort of 
> > > > > > thing I want to avoid.
> > > > > > 
> > > > > > I'm not sure there's an easy way to do this - but looks like the 
> > > > > > logic to name the .o file output is in `Driver::GetNamedOutputPath` 
> > > > > > and gets stored in the `clang::driver::Compilation` which I 
> > > > > > guess is where we are, but we're going through here with a 
> > > > > > `PrecompileJobAction` insntead of the compile job action, I suppose.
> > > > > > 
> > > > > > Could we keep these two codepaths closer together?
> > > > > > 
> > > > > > It'd be really nice if we could reuse that in some way.
> > > > > > 
> > > > > > Hmm, actually, why doesn't this fall out of the existing algorithm 
> > > > > > without modification?
> > > > > > 
> > > > > > Ah, I see, since the precompile action isn't "at top level" it gets 
> > > > > > a temporary file name - so if we change only that, it seems to fall 
> > > > > > out naturally:
> > > > > > ```
> > > > > > diff --git a/clang/lib/Driver/Driver.cpp 
> > > > > > b/clang/lib/Driver/Driver.cpp
> > > > > > index c7efe60b2335..db878cbfff46 100644
> > > > > > --- a/clang/lib/Driver/Driver.cpp
> > > > > > +++ b/clang/lib/Driver/Driver.cpp
> > > > > > @@ -5556,9 +5556,9 @@ const char 
> > > > > > *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
> > > > > >}
> > > > > >  
> > > > > >// Output to a temporary file?
> > > > > > -  if ((!AtTopLevel && !isSaveTempsEnabled() &&
> > > > > > +  if (((!AtTopLevel && !isSaveTempsEnabled() &&
> > > > > > !C.getArgs().hasArg(options::OPT__SLASH_Fo)) ||
> > > > > > -  CCGenDiagnostics) {
> > > > > > +  CCGenDiagnostics) && JA.getType() != types::TY_ModuleFile) {
> > > > > >  StringRef Name = llvm::sys::path::filename(BaseInput);
> > > > > >  std::pair Split = Name.split('.');
> > > > > >  const char *Suffix = types::getTypeTempSuffix(JA.getType(), 
> > > > > > IsCLMode());
> > > > > > ```
> > > > > > 
> > > > > > Without the need to reimplement/duplicate the `-o` handling logic?
> > > > > Oh, I should say, this patch didn't actually have the flag support, 
> > > > > but it'd be something like this ^ but with the command line argument 
> > > > > test as well (so "other stuff that's already there && !(TY_ModuleFile 
> > > > > && hasArg fmodule-output)")
> > > > To be honest, I prefer the previous patch. I feel it has higher 
> > > > readability. But this is a problem about taste and it doesn't have 
> > > > standard answer. Someone's readability is redundancy for others : )
> > > I think there's real functionality we're at risk of missing by having 
> > > separate implementations.
> > > 
> > > For instance - how does this interact with Apple's multiarch support (eg: 
> > > `clang++ test.cppm -fmodule-output -arch i386 -arch x86_64 -target 
> > > x86_64_apple_darwin`) - from my testing, without specifying an output 
> > > file, you get something semi-usable/not simply incorrect: `test-i386.pcm` 
> > > and `test-x86_64.pcm`. But if you try to name the output file you get 
> > > `foo.pcm` and then another `foo.pcm` that overwrites the previous one. I 
> > > think this could be taken care of if the suffix handling code was 
> > > delegated down towards the else block that starts with `SmallString<128> 
> > > Output(getDefaultImageName());`
> > > 
> > > But maybe solving that ^ problem could come out of a more general 
> > > solution to the next problem:
> > > 
> > > What if you specify multiple source files on the command line without 
> > > `-c`? Without `-o` you get `test1.pcm` and `test2.pcm`, but with `-o foo` 
> > > you get `foo.pcm` overwriting `foo.pcm`. Perhaps if the output file 
> > > specified isn't a .o file, we should ignore the `-o` and use the 
> > > input-filename based naming? I guess we could reject this

[PATCH] D139995: [RISCV] Refactor RVV Policy by structure

2022-12-18 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng 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/D139995/new/

https://reviews.llvm.org/D139995

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


[PATCH] D140281: [X86] Rename CMPCCXADD intrinsics.

2022-12-18 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke accepted this revision.
LuoYuanke added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140281

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


[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2022-12-18 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp:24
+namespace clang {
+namespace clangd {
+namespace {

You can merge this into `namespace clang::clangd`.



Comment at: clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp:58
+};
+
+REGISTER_TWEAK(AddDoxygenComment)

The LLVM coding style kindly asks you stop the anonymous namespace here. 
Furthermore, I believe that the `REGISTER_TWEAK` does not work in an anonymous 
namespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140275

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


[PATCH] D139701: [Clang] Emit "min-legal-vector-width" attribute for X86 only

2022-12-18 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D139701#4004114 , @craig.topper 
wrote:

> Please update the title

Thanks for reminding!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139701

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


[clang] a40ef65 - [Intrinsic] Rename flt.rounds intrinsic to get.rounding

2022-12-18 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2022-12-19T15:22:39+08:00
New Revision: a40ef656d812143d24c810c65ebf6b24646837f0

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

LOG: [Intrinsic] Rename flt.rounds intrinsic to get.rounding

Address the inconsistency between FLT_ROUNDS_ and SET_ROUNDING SDAG
node. Rename FLT_ROUNDS_ to GET_ROUNDING and add llvm.get.rounding
intrinsic to replace flt.rounds.

Reviewed By: nikic

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

Added: 
llvm/test/Bitcode/Inputs/auto_upgrade_flt_rounds.bc
llvm/test/Bitcode/auto_upgrade_flt_rounds.test

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-msp430.c
clang/test/CodeGen/builtins.c
llvm/docs/LangRef.rst
llvm/include/llvm/CodeGen/ISDOpcodes.h
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/CodeGen/IntrinsicLowering.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMISelLowering.h
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/test/CodeGen/AArch64/arm64-fpcr.ll
llvm/test/CodeGen/AArch64/strict-fp-opt.ll
llvm/test/CodeGen/ARM/2012-03-05-FPSCR-bug.ll
llvm/test/CodeGen/ARM/fpscr-intrinsics.ll
llvm/test/CodeGen/ARM/no-fpscr-liveness.ll
llvm/test/CodeGen/MSP430/flt_rounds.ll
llvm/test/CodeGen/PowerPC/frounds.ll
llvm/test/CodeGen/RISCV/flt-rounds.ll
llvm/test/CodeGen/RISCV/fpenv.ll
llvm/test/CodeGen/X86/flt-rounds.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 55aa9f6acd0fe..a9f7d501fc902 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3325,7 +3325,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   }
 
   case Builtin::BI__builtin_flt_rounds: {
-Function *F = CGM.getIntrinsic(Intrinsic::flt_rounds);
+Function *F = CGM.getIntrinsic(Intrinsic::get_rounding);
 
 llvm::Type *ResultType = ConvertType(E->getType());
 Value *Result = Builder.CreateCall(F);

diff  --git a/clang/test/CodeGen/builtins-msp430.c 
b/clang/test/CodeGen/builtins-msp430.c
index 8fb409b66646d..c9d7615014b78 100644
--- a/clang/test/CodeGen/builtins-msp430.c
+++ b/clang/test/CodeGen/builtins-msp430.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple msp430-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s
 
 int test_builtin_flt_rounds() {
-  // CHECK: [[V0:[%A-Za-z0-9.]+]] = call i32 @llvm.flt.rounds()
+  // CHECK: [[V0:[%A-Za-z0-9.]+]] = call i32 @llvm.get.rounding()
   // CHECK-DAG: [[V1:[%A-Za-z0-9.]+]] = trunc i32 [[V0]] to i16
   // CHECK-DAG: ret i16 [[V1]]
   return __builtin_flt_rounds();

diff  --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index 9420b26da3290..21e14cc9c08c0 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -277,7 +277,7 @@ void test_float_builtins(__fp16 *H, float F, double D, long 
double LD) {
   // CHECK: and i1
 
   res = __builtin_flt_rounds();
-  // CHECK: call i32 @llvm.flt.rounds(
+  // CHECK: call i32 @llvm.get.rounding(
 }
 
 // CHECK-LABEL: define{{.*}} void @test_float_builtin_ops

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index c816355bf9fab..2011d17ea3be6 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -24598,7 +24598,7 @@ These functions read or write floating point 
environment, such as rounding
 mode or state of floating point exceptions. Altering the floating point
 environment requires special care. See :ref:`Floating Point Environment 
`.
 
-'``llvm.flt.rounds``' Intrinsic
+'``llvm.get.rounding``' Intrinsic
 ^^^
 
 Syntax:
@@ -24606,17 +24606,17 @@ Syntax:
 
 ::
 
-  declare i32 @llvm.flt.rounds()
+  declare i32 @llvm.get.rounding()
 
 Overview:
 "
 
-The '``llvm.flt.rounds``' intrinsic reads the current rounding mode.
+The '``llvm.get.rounding``' intrinsic reads the current rounding mode.
 
 Semantics:
 ""
 
-The '``llvm.flt.rounds``' intrinsic returns the current rounding mode.
+The '``llvm.get.rounding``' intrinsic returns the current rounding mode.
 Encoding of the returned values is same as the result of ``FLT_ROUNDS

[PATCH] D139507: [Intrinsic] Rename flt.rounds intrinsic to get.rounding

2022-12-18 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa40ef656d812: [Intrinsic] Rename flt.rounds intrinsic to 
get.rounding (authored by qiucf).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139507

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-msp430.c
  clang/test/CodeGen/builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/IntrinsicLowering.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/Bitcode/Inputs/auto_upgrade_flt_rounds.bc
  llvm/test/Bitcode/auto_upgrade_flt_rounds.test
  llvm/test/CodeGen/AArch64/arm64-fpcr.ll
  llvm/test/CodeGen/AArch64/strict-fp-opt.ll
  llvm/test/CodeGen/ARM/2012-03-05-FPSCR-bug.ll
  llvm/test/CodeGen/ARM/fpscr-intrinsics.ll
  llvm/test/CodeGen/ARM/no-fpscr-liveness.ll
  llvm/test/CodeGen/MSP430/flt_rounds.ll
  llvm/test/CodeGen/PowerPC/frounds.ll
  llvm/test/CodeGen/RISCV/flt-rounds.ll
  llvm/test/CodeGen/RISCV/fpenv.ll
  llvm/test/CodeGen/X86/flt-rounds.ll

Index: llvm/test/CodeGen/X86/flt-rounds.ll
===
--- llvm/test/CodeGen/X86/flt-rounds.ll
+++ llvm/test/CodeGen/X86/flt-rounds.ll
@@ -3,7 +3,7 @@
 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-sse2 -verify-machineinstrs < %s | FileCheck %s --check-prefix=X86
 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s --check-prefix=X64
 
-declare i32 @llvm.flt.rounds()
+declare i32 @llvm.get.rounding()
 
 define i32 @test_flt_rounds() nounwind {
 ; X86-LABEL: test_flt_rounds:
@@ -31,7 +31,7 @@
 ; X64-NEXT:shrl %cl, %eax
 ; X64-NEXT:andl $3, %eax
 ; X64-NEXT:retq
-  %1 = call i32 @llvm.flt.rounds()
+  %1 = call i32 @llvm.get.rounding()
   ret i32 %1
 }
 
@@ -172,21 +172,21 @@
 ; X64-NEXT:retq
 entry:
   %call = tail call i32 @fesetround(i32 1024)
-  %0 = tail call i32 @llvm.flt.rounds()
+  %0 = tail call i32 @llvm.get.rounding()
   %cmp = icmp ne i32 %0, 3
   %spec.select = zext i1 %cmp to i32
   %call1 = tail call i32 @fesetround(i32 0)
-  %1 = tail call i32 @llvm.flt.rounds()
+  %1 = tail call i32 @llvm.get.rounding()
   %cmp2 = icmp eq i32 %1, 1
   %inc4 = select i1 %cmp, i32 2, i32 1
   %errs.1 = select i1 %cmp2, i32 %spec.select, i32 %inc4
   %call6 = tail call i32 @fesetround(i32 3072)
-  %2 = tail call i32 @llvm.flt.rounds()
+  %2 = tail call i32 @llvm.get.rounding()
   %cmp7 = icmp ne i32 %2, 0
   %inc9 = zext i1 %cmp7 to i32
   %spec.select22 = add nuw nsw i32 %errs.1, %inc9
   %call11 = tail call i32 @fesetround(i32 2048)
-  %3 = tail call i32 @llvm.flt.rounds()
+  %3 = tail call i32 @llvm.get.rounding()
   %cmp12 = icmp ne i32 %3, 2
   %inc14.neg = sext i1 %cmp12 to i32
   %cmp16 = icmp ne i32 %spec.select22, %inc14.neg
Index: llvm/test/CodeGen/RISCV/fpenv.ll
===
--- llvm/test/CodeGen/RISCV/fpenv.ll
+++ llvm/test/CodeGen/RISCV/fpenv.ll
@@ -22,7 +22,7 @@
 ; RV64IF-NEXT:srl a0, a1, a0
 ; RV64IF-NEXT:andi a0, a0, 7
 ; RV64IF-NEXT:ret
-  %rm = call i32 @llvm.flt.rounds()
+  %rm = call i32 @llvm.get.rounding()
   ret i32 %rm
 }
 
@@ -122,4 +122,4 @@
 }
 
 declare void @llvm.set.rounding(i32)
-declare i32 @llvm.flt.rounds()
+declare i32 @llvm.get.rounding()
Index: llvm/test/CodeGen/RISCV/flt-rounds.ll
===
--- llvm/test/CodeGen/RISCV/flt-rounds.ll
+++ llvm/test/CodeGen/RISCV/flt-rounds.ll
@@ -4,7 +4,7 @@
 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
 ; RUN:   | FileCheck -check-prefix=RV64I %s
 
-declare i32 @llvm.flt.rounds()
+declare i32 @llvm.get.rounding()
 
 define i32 @test_flt_rounds() nounwind {
 ; RV32I-LABEL: test_flt_rounds:
@@ -16,6 +16,6 @@
 ; RV64I:   # %bb.0:
 ; RV64I-NEXT:li a0, 1
 ; RV64I-NEXT:ret
-  %1 = call i32 @llvm.flt.rounds()
+  %1 = call i32 @llvm.get.rounding()
   ret i32 %1
 }
Index: llvm/test/CodeGen/PowerPC/frounds.ll
===
--- llvm/test/CodeGen/PowerPC/frounds.ll
+++ llvm/test/CodeGen/PowerPC/frounds.ll
@@ -66,7 +66,7 @@
 	%retval