[PATCH] D123682: [clang-tblgen] Automatically document options values

2022-04-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D123682#3454627 , 
@serge-sans-paille wrote:

> @aaron.ballman Any thoughs on the above suggestion? I'd be happy to adopt any 
> of those :-)

I'd go with:

More than two choices: ` should be 'return', 'branch', 'full', or 'none'`
Only two choices: ` should be 'split' or 'single'.`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123682

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


[PATCH] D123456: [C89/C2x] Diagnose calls to a function without a prototype but passes arguments

2022-04-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've landed in 33d3fc4466479285121cbb1a62db249454da0bda 



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

https://reviews.llvm.org/D123456

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-17 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Partially implement the proposed resolution to CWG2569.

D119136  broke some libstdc++ code, as 
P2036R3, implemented as a DR to
C++11 made ill-formed some previously valid and innocuous code.

We resolve this issue to allow decltype(x) - but not decltype((x)
to appear in the parameter list of a lambda that capture x by copy.

Unlike CWG2569, we do not extend that special treatment to
sizeof/noexcept yet, as the resolution has not been approved yet
and keeping the review small allows a quicker fix of impacted code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123909

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- clang/test/SemaCXX/lambda-capture-type-deduction.cpp
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -87,23 +87,23 @@
   int y, z;// expected-note 2{{declared here}}
   auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
   decltype(
-  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+  [&] { return 0; }) y) { // expected-error{{captured variable 'y' cannot appear here}}
 return y;
   };
 
-  auto init_tpl = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init_tpl = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
   auto implicit = [=]( // expected-note {{variable 'z' is captured here}}
   decltype(
-  [&](decltype(z)) { return 0; }) z) { //expected-error{{captured variable 'z' cannot appear here}}
+  [&](decltype((z))) { return 0; }) z) { // expected-error{{captured variable 'z' cannot appear here}}
 return z;
   };
 
-  auto init = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&](decltype(x)) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&](decltype((x))) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
@@ -141,20 +141,20 @@
   decltype([&](
decltype([=]( // expected-note {{variable 'x' is captured here}}
 decltype([&](
- decltype([&](decltype(x)) {}) // expected-error{{captured variable 'x' cannot appear here}}
+ decltype([&](decltype((x))) {}) // expected-error{{captured variable 'x' cannot appear here}}
  ) {})) {})) {})){};
 
   (void)[&](
   decltype([&](
decltype([&](
 decltype([&](
- decltype([&](decltype(y)) {})) {})) {})) {})){};
+ decltype([&](decltype((y))) {})) {})) {})) {})){};
 
   (void)[=](
   decltype([=](
decltype([=](
-decltype([=](  // expected-note {{variable 'z' is captured here}}
- decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
+decltype([=](// expected-note {{variable 'z' is captured here}}
+ decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
  ) {})) {})) {})){};
 }
 
@@ -171,3 +171,13 @@
   dependent(r);
   dependent(cr);
 }
+
+void test_CWG2569_tpl(auto a) {
+  (void)[=](decltype(a) b = decltype(a)()){};
+}
+
+void test_CWG2569() {
+  int a = 0;
+  (void)[=](decltype(a) b = decltype(a)()){};
+  test_CWG2569_tpl(0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/Se

[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-17 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@grandinj Thanks for notifying me of this issue, and sorry for the 
inconvenience.

There is a fix here https://reviews.llvm.org/D123909
Should the review of that linger too long, I'll revert this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D15166: Fix C++ support on recent DragonFly BSD releases

2022-04-17 Thread Antonio Huete Jimenez via Phabricator via cfe-commits
tuxillo added a comment.
Herald added a project: All.

What can we do to move this forward?


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

https://reviews.llvm.org/D15166

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


[PATCH] D123898: Fix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6

2022-04-17 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

I'd like to.  The test case from the original bug report was very large but I'm 
not sure how to trigger this with anything comprehensibly small.  You need 
something where the callee is responsible for destroying the argument and I'm 
not sure what combination of properties / ABIs results in that.  The original 
test was `-(void)foo:(std::string)aString` on the MSVC ABI, but I don't know 
how much of the Visual Studio `std::string` implementation is necessary to 
trigger this behaviour.  Is it just a non-trivial destructor?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123898

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


[PATCH] D122255: Meta directive runtime support

2022-04-17 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo updated this revision to Diff 423305.
abidmalikwaterloo added a comment.

Cleaned the code and added tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122255

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/OpenMP/metadirective_ast_print_new_1.cpp
  clang/test/OpenMP/metadirective_ast_print_new_2.cpp
  clang/test/OpenMP/metadirective_ast_print_new_3.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPContext.h
  llvm/lib/Frontend/OpenMP/OMPContext.cpp

Index: llvm/lib/Frontend/OpenMP/OMPContext.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -20,6 +20,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include 
 #define DEBUG_TYPE "openmp-ir-builder"
 
 using namespace llvm;
@@ -339,6 +340,41 @@
   return Score;
 }
 
+/// Takes \p VMI and \p Ctx and sort the 
+/// scores using \p A
+void llvm::omp::getArrayVariantMatchForContext(const SmallVectorImpl &VMIs,
+const OMPContext &Ctx, SmallVector> &A){
+	
+//APInt BestScore(64, 0);
+APInt Score (64, 0);
+llvm::DenseMap m;
+		
+for (unsigned u = 0, e = VMIs.size(); u < e; ++u) {
+  const VariantMatchInfo &VMI = VMIs[u];
+
+  SmallVector ConstructMatches;
+  // If the variant is not applicable its not the best.
+  if (!isVariantApplicableInContextHelper(VMI, Ctx, &ConstructMatches,
+   /* DeviceSetOnly */ false)){
+Score = 0;
+m.insert({u, Score});
+  	continue;	}
+   	// Check if its clearly not the best.
+	Score = getVariantMatchScore(VMI, Ctx, ConstructMatches);
+	m.insert({u, Score});	
+	}
+			
+for (auto& it : m) 
+  A.push_back(it);
+	
+std::sort(A.begin(), A.end(), [] (std::pair&a,
+	std::pair&b){	
+	return a.second.ugt(b.second);
+});	
+}
+ 
+
+
 int llvm::omp::getBestVariantMatchForContext(
 const SmallVectorImpl &VMIs, const OMPContext &Ctx) {
 
Index: llvm/include/llvm/Frontend/OpenMP/OMPContext.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPContext.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPContext.h
@@ -189,6 +189,15 @@
 int getBestVariantMatchForContext(const SmallVectorImpl &VMIs,
   const OMPContext &Ctx);
 
+/// Sort array \p A of clause index  with score
+/// This will be used to produce AST clauses
+/// in a sorted order with the clause with the highiest order
+/// on the top and default clause at the bottom
+void getArrayVariantMatchForContext(
+const SmallVectorImpl &VMIs, const OMPContext &Ctx,
+SmallVector> &A);
+
+// new--
 } // namespace omp
 
 template <> struct DenseMapInfo {
Index: clang/test/OpenMP/metadirective_ast_print_new_3.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_ast_print_new_3.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify  -fopenmp  -ast-print %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+int main() {
+  int N = 15;
+#pragma omp metadirective when(user = {condition(N > 10)} : parallel for)\
+ default(target teams) 
+  for (int i = 0; i < N; i++)
+;
+
+
+#pragma omp metadirective when(device = {arch("nvptx64")}, user = {condition(N >= 100)} : parallel for)\
+  default(target parallel for)
+  for (int i = 0; i < N; i++)
+;
+  return 0;
+}
+
+
+
+// CHECK: #pragma omp metadirective when(user={condition(N > 10)}: parallel for) default(target teams)
+// CHECK: #pragma omp metadirective when(device={arch(nvptx64)}, user={condition(N >= 100)}: parallel for) default(target parallel for)
Index: clang/test/OpenMP/metadirective_ast_print_new_2.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_ast_print_new_2.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify  -fopenmp  -ast-print %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+void bar(){
+	int i=0;	
+}
+
+void myfoo(void){
+
+	int N = 13;
+	int b,n;
+	int a[100];
+
+	
+	#pragma omp  metadirective when (user = {condition(N>10)}: target  teams distribute parallel for ) \
+	when (user = {condition(N==10)}: parallel for )\
+	when (user = {condition(N==13)}: parallel for simd) \
+	when ( device={arch("arm")}:   target teams num_teams(512) thread_limit(32))\
+	when ( device={arch("nvptx")}: target teams num

[clang] b27430f - Treat `std::move`, `forward`, etc. as builtins.

2022-04-17 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-04-17T13:26:16-07:00
New Revision: b27430f9f46b88bcd54d992debc8d72e131e1bd0

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

LOG: Treat `std::move`, `forward`, etc. as builtins.

This is extended to all `std::` functions that take a reference to a
value and return a reference (or pointer) to that same value: `move`,
`forward`, `move_if_noexcept`, `as_const`, `addressof`, and the
libstdc++-specific function `__addressof`.

We still require these functions to be declared before they can be used,
but don't instantiate their definitions unless their addresses are
taken. Instead, code generation, constant evaluation, and static
analysis are given direct knowledge of their effect.

This change aims to reduce various costs associated with these functions
-- per-instantiation memory costs, compile time and memory costs due to
creating out-of-line copies and inlining them, code size at -O0, and so
on -- so that they are not substantially more expensive than a cast.
Most of these improvements are very small, but I measured a 3% decrease
in -O0 object file size for a simple C++ source file using the standard
library after this change.

We now automatically infer the `const` and `nothrow` attributes on these
now-builtin functions, in particular meaning that we get a warning for
an unused call to one of these functions.

In C++20 onwards, we disallow taking the addresses of these functions,
per the C++20 "addressable function" rule. In earlier language modes, a
compatibility warning is produced but the address can still be taken.

The same infrastructure is extended to the existing MSVC builtin
`__GetExceptionInfo`, which is now only recognized in namespace `std`
like it always should have been.

This is a re-commit of
  fc3090109643af8d2da9822d0f99c84742b9c877,
  a571f82a50416b767fd3cce0fb5027bb5dfec58c, and
  64c045e25b8471bbb572bd29159c294a82a86a25
which were reverted in
  e75d8b70370435b0ad10388afba0df45fcf9bfcc
due to a crasher bug where CodeGen would emit a builtin glvalue as an
rvalue if it constant-folds.

Reviewed By: aaron.ballman

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

Added: 
clang/test/CodeGenCXX/builtin-std-move.cpp
clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
clang/test/SemaCXX/builtin-std-move.cpp

Modified: 
clang/docs/CommandGuide/clang.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/Builtins.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/ExprConstant.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/Basic/Builtins.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/Analysis/inner-pointer.cpp
clang/test/Analysis/use-after-move.cpp
clang/test/CodeGenCXX/builtins.cpp
clang/test/CodeGenCXX/microsoft-abi-throw.cpp
clang/test/SemaCXX/unqualified-std-call-fixits.cpp
clang/test/SemaCXX/unqualified-std-call.cpp
clang/test/SemaCXX/warn-consumed-analysis.cpp
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index aec62789a43e6..658a30458043e 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -252,8 +252,24 @@ Language Selection and Mode Options
 
 .. option:: -fno-builtin
 
- Disable special handling and optimizations of builtin functions like
- :c:func:`strlen` and :c:func:`malloc`.
+ Disable special handling and optimizations of well-known library functions,
+ like :c:func:`strlen` and :c:func:`malloc`.
+
+.. option:: -fno-builtin-
+
+ Disable special handling and optimizations for the specific library function.
+ For example, ``-fno-builtin-strlen`` removes any special handling for the
+ :c:func:`strlen` library function.
+
+.. option:: -fno-builtin-std-
+
+ Disable special handling and optimizations for the specific C++ standard
+ library function in namespace ``std``. For example,
+ ``-fno-builtin-std-move_if_noexcept`` removes any special handling for the
+ :cpp:func:`std::move_if_noexcept` library function.
+
+ For C standard library functions that the C++ standard library also provides
+ in namespace ``std``, use :option:`-fno-builtin-\` instead.
 
 .. option:: -fmath-errno
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c72028c718586..2aabeaf6d679f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -230,7 +230

[PATCH] D123345: Treat `std::move`, `forward`, and `move_if_noexcept` as builtins.

2022-04-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb27430f9f46b: Treat `std::move`, `forward`, etc. as 
builtins. (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D123345?vs=423165&id=423312#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123345

Files:
  clang/docs/CommandGuide/clang.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Basic/Builtins.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Analysis/inner-pointer.cpp
  clang/test/Analysis/use-after-move.cpp
  clang/test/CodeGenCXX/builtin-std-move.cpp
  clang/test/CodeGenCXX/builtins.cpp
  clang/test/CodeGenCXX/microsoft-abi-throw.cpp
  clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
  clang/test/SemaCXX/builtin-std-move.cpp
  clang/test/SemaCXX/unqualified-std-call-fixits.cpp
  clang/test/SemaCXX/unqualified-std-call.cpp
  clang/test/SemaCXX/warn-consumed-analysis.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1444,7 +1444,7 @@
 TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
   const std::string Reproducer =
   "namespace std {"
-  "template  T forward(T & A) { return static_cast(A); }"
+  "template  T &forward(T &A) { return static_cast(A); }"
   "template  struct __bind {"
   "  T f;"
   "  template  __bind(T v, V &&) : f(forward(v)) {}"
Index: clang/test/SemaCXX/warn-consumed-analysis.cpp
===
--- clang/test/SemaCXX/warn-consumed-analysis.cpp
+++ clang/test/SemaCXX/warn-consumed-analysis.cpp
@@ -953,12 +953,12 @@
 namespace std {
   void move();
   template
-  void move(T&&);
+  T &&move(T&);
 
   namespace __1 {
 void move();
 template
-void move(T&&);
+T &&move(T&);
   }
 }
 
@@ -971,7 +971,7 @@
   void test() {
 x.move();
 std::move();
-std::move(x);
+std::move(x); // expected-warning {{ignoring return value}}
 std::__1::move();
 std::__1::move(x);
   }
Index: clang/test/SemaCXX/unqualified-std-call.cpp
===
--- clang/test/SemaCXX/unqualified-std-call.cpp
+++ clang/test/SemaCXX/unqualified-std-call.cpp
@@ -1,17 +1,17 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wall -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -std=c++11 %s -Wno-unused-value
 
 namespace std {
 
 template 
 void dummy(T &&) {}
 template 
-void move(T &&) {}
+T &&move(T &&x) { return x; }
 template 
 void move(T &&, U &&) {}
 
 inline namespace __1 {
 template 
-void forward(T &) {}
+T &forward(T &x) { return x; }
 } // namespace __1
 
 struct foo {};
Index: clang/test/SemaCXX/unqualified-std-call-fixits.cpp
===
--- clang/test/SemaCXX/unqualified-std-call-fixits.cpp
+++ clang/test/SemaCXX/unqualified-std-call-fixits.cpp
@@ -6,9 +6,9 @@
 
 namespace std {
 
-void move(auto &&a) {}
+int &&move(auto &&a) { return a; }
 
-void forward(auto &a) {}
+int &&forward(auto &a) { return a; }
 
 } // namespace std
 
@@ -16,8 +16,8 @@
 
 void f() {
   int i = 0;
-  move(i); // expected-warning {{unqualified call to std::move}}
-  // CHECK: {{^}}  std::
-  forward(i); // expected-warning {{unqualified call to std::forward}}
-  // CHECK: {{^}}  std::
+  (void)move(i); // expected-warning {{unqualified call to std::move}}
+  // CHECK: {{^}}  (void)std::move
+  (void)forward(i); // expected-warning {{unqualified call to std::forward}}
+  // CHECK: {{^}}  (void)std::forward
 }
Index: clang/test/SemaCXX/builtin-std-move.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-std-move.cpp
@@ -0,0 +1,126 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s -DNO_CONSTEXPR
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+namespace std {
+#ifndef NO_CONSTEXPR
+#define CONSTEXPR constexpr
+#else
+#define CONSTEXPR
+#endif
+
+  template CONSTEXPR T &&move(T &x) {
+static_assert(T::moveable, "instantiated move"); // expected-error {{no member named 'moveable' in 'B'}}
+ // expected-error@-1 {{no memb

[clang-tools-extra] 3eeca52 - Fix wrong signature for std::move and std::swap in test.

2022-04-17 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-04-17T19:25:20-07:00
New Revision: 3eeca524569744d2927fd13304ab5abb7217e108

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

LOG: Fix wrong signature for std::move and std::swap in test.

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
index fb7c089ae8cd6..14d27855d7c5a 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
@@ -3,11 +3,11 @@
 namespace std {
 
 template 
-void swap(T x, T y) {
+void swap(T &x, T &y) {
 }
 
 template 
-T &&move(T x) {
+T &&move(T &x) {
 }
 
 template 
@@ -403,7 +403,7 @@ class CopyAndMove1 {
 class CopyAndMove2 {
 public:
   CopyAndMove2 &operator=(const CopyAndMove2 &object) {
-*this = std::move(CopyAndMove2(object));
+*this = CopyAndMove2(object);
 return *this;
   }
 



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


[clang] 429cbac - [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-04-17 Thread via cfe-commits

Author: luxufan
Date: 2022-04-18T11:16:41+08:00
New Revision: 429cbac0390654f90bba18a41799464adf31a5ec

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

LOG: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

In the past, `clang --target=riscv64-unknown-linux-gnu -mno-relax -c hello.s` 
will assemble hello.s without relaxation, but `clang 
--target=riscv64-unknown-linux-gnu -mno-relax -fno-integrated-as -c hello.s` 
doesn't pass the `-mno-relax` option to assembler, and assemble with relaxation
This patch pass the -mno-relax option to assembler when -fno-integrated-as is 
specified.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/riscv-gnutools.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index ae848cfe81c93..5816b91994102 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -764,6 +764,8 @@ void tools::gnutools::Assembler::ConstructJob(Compilation 
&C,
 StringRef MArchName = riscv::getRISCVArch(Args, 
getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))
+  Args.addOptOutFlag(CmdArgs, options::OPT_mrelax, options::OPT_mno_relax);
 break;
   }
   case llvm::Triple::sparc:

diff  --git a/clang/test/Driver/riscv-gnutools.c 
b/clang/test/Driver/riscv-gnutools.c
index 2b44494336d59..685b320149df9 100644
--- a/clang/test/Driver/riscv-gnutools.c
+++ b/clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang --target=riscv32-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c 
-march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check -mno-relax is passed when -fno-integrated-as specified
+// RUN: %clang -target riscv32-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s 
-### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" 
"rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,12 @@
 // RUN: %clang --target=riscv64-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c 
-march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check -mno-relax is not passed when -fno-integrated-as specified
+// RUN: %clang -target riscv64-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -mrelax 
-fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" 
"rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-RELAX: "{{.*}}as{{(.exe)?}}"
+// CHECK-RV64-RELAX-NOT: "-mno-relax"



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


[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-04-17 Thread luxufan 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 rG429cbac03906: [RISCV] Pass -mno-relax to assembler when 
-fno-integrated-as specified (authored by StephenFan).

Changed prior to commit:
  https://reviews.llvm.org/D120639?vs=418774&id=423327#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120639

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-gnutools.c


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang --target=riscv32-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c 
-march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check -mno-relax is passed when -fno-integrated-as specified
+// RUN: %clang -target riscv32-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s 
-### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" 
"rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,12 @@
 // RUN: %clang --target=riscv64-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c 
-march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check -mno-relax is not passed when -fno-integrated-as specified
+// RUN: %clang -target riscv64-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -mrelax 
-fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" 
"rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-RELAX: "{{.*}}as{{(.exe)?}}"
+// CHECK-RV64-RELAX-NOT: "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -764,6 +764,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, 
getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))
+  Args.addOptOutFlag(CmdArgs, options::OPT_mrelax, options::OPT_mno_relax);
 break;
   }
   case llvm::Triple::sparc:


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang --target=riscv32-unknown-elf --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check -mno-relax is passed when -fno-integrated-as specified
+// RUN: %clang -target riscv32-unknown-elf --gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,12 @@
 // RUN: %clang --target=riscv64-unknown-elf --gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check -mno-relax is not passed when -fno-integrated-as specified
+// RUN: %clang -target riscv64-unknown-elf --gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -mrelax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-RELAX: "{{.*}}as{{(.exe)?}}"
+// CHECK-RV64-RELAX-NOT: "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolCh

[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-04-17 Thread luxufan via Phabricator via cfe-commits
StephenFan added a comment.

Thanks @MaskRay, @asb !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120639

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