[PATCH] D139398: [AMDGPU] Add bf16 storage support

2022-12-12 Thread Pierre van Houtryve via Phabricator via cfe-commits
Pierre-vh added inline comments.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:5573-5576
+  SDLoc SL(Op);
+  return DAG.getNode(
+  ISD::FP_EXTEND, SL, MVT::f32,
+  DAG.getNode(ISD::BITCAST, SL, MVT::f16, Op->getOperand(0)));

arsenm wrote:
> arsenm wrote:
> > Pierre-vh wrote:
> > > arsenm wrote:
> > > > ExpandNode covers lowering BF16_TO_FP. It also has a shift by 16-bits 
> > > > into the high bits. Is this correct?
> > > Ah I didn't know that, though as long as we use custom lowering, and our 
> > > FP_TO_BF16/BF16_TO_FP methods are consistent, it should be fine, no?
> > bfloat16 has the same number of exponent bits in the same high bits as f32; 
> > I kind of think the idea is you can just do a bitshift and then operate on 
> > f32?  I think the fp_extend here is wrong
> The default legalization also looks wrong to me. I don't understand why it 
> isn't shifting down the mantissa bit
Indeed it was terribly wrong. I rewrote both legalizations following what I 
found online: https://en.wikipedia.org/wiki/Bfloat16_floating-point_format

bf16 is designed to be very easily convertible from/to f32, save for some edge 
cases with denormalized numbers I think, thus:
- bf16 -> f32 is just left-shift by 16, filling the least-significant bits with 
zeroes.
- f32 -> bf16 is just cutting off the 16 least-significant bits.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:4819-4831
+// When we don't have 16 bit instructions, bf16 is illegal and gets
+// softened to i16 for storage, with float being used for arithmetic.
+//
+// After softening, some i16 -> fp32 bf16_to_fp operations can be left 
over.
+// Lower those to (f32 (fp_extend (f16 (bitconvert x
+if (!Op->getValueType(0).isFloatingPoint() ||
+Op->getOperand(0).getValueType() != MVT::i16)

arsenm wrote:
> Pierre-vh wrote:
> > arsenm wrote:
> > > Pierre-vh wrote:
> > > > arsenm wrote:
> > > > > Pierre-vh wrote:
> > > > > > arsenm wrote:
> > > > > > > Pierre-vh wrote:
> > > > > > > > arsenm wrote:
> > > > > > > > > The generic legalizer should have handled this?
> > > > > > > > It looks like those operations are not implemented in the 
> > > > > > > > generic legalizer, e.g. I get 
> > > > > > > > ``` 
> > > > > > > > Do not know how to promote this operator's operand!
> > > > > > > > ```
> > > > > > > Right, this is the code that would go there
> > > > > > Do I just copy/paste this code in that PromoteInt function, and 
> > > > > > keep a copy here too in LowerOperation? (not really a fan of 
> > > > > > copy-pasting code in different files, I'd rather keep it all here)
> > > > > > We need to have the lowering too AFAIK, it didn't go well when I 
> > > > > > tried to remove it
> > > > > I'm not following why you need to handle it here
> > > > IIRC:
> > > >  - I need to handle FP_TO_BF16 in ReplaceNodeResult because that's what 
> > > > the Integer Legalizer calls (through CustomLowerNode)
> > > >  - I need to handle both opcodes in LowerOperation because otherwise 
> > > > they'll fail selection. They can be left over from expanding/legalizing 
> > > > other operations.
> > > But why are they custom? We don't have to handle FP16_TO_FP or FP_TO_FP16 
> > > there, and they aren't custom lowered. They have the same basic 
> > > properties. We have this:
> > > 
> > > 
> > > ```
> > > setOperationAction(ISD::FP16_TO_FP, MVT::i16, Promote);
> > > AddPromotedToType(ISD::FP16_TO_FP, MVT::i16, MVT::i32);
> > > setOperationAction(ISD::FP_TO_FP16, MVT::i16, Promote);
> > > AddPromotedToType(ISD::FP_TO_FP16, MVT::i16, MVT::i32);
> > > ```
> > > 
> > > I'd expect the same basic pattern
> > PromoteIntegerOperand, PromoteFloatOperand and PromoteIntegerResult don't 
> > handle FP_TO_BF16 and BF16_TO_FP, and unless we put a Custom lowering mode 
> > it'll assert/unreachable.
> > I tried to make it work (for a while) using the default expand but I can't 
> > quite get it to work. It feels like there is some legalizer work missing 
> > for handling BF16 like we want to.
> > Even though it's not ideal I think the custom lowering is easiest
> What about Expand? that's where the implemented part is
Last I tried, Expand will emit a libcall in many cases that we don't handle


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139398

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


[clang-tools-extra] 4ce6dfb - [include-cleaner] Add a unique_ptr-style member expr test in WalkASTTest.

2022-12-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-12-12T09:58:54+01:00
New Revision: 4ce6dfbcd6f0cbe8e03ecf6f99b306f6826bf239

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

LOG: [include-cleaner] Add a unique_ptr-style member expr test in WalkASTTest.

This is a test I missed to mention in https://reviews.llvm.org/D139087.

Reviewed By: VitaNuo

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

Added: 


Modified: 
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index 551eb66bcdef0..a197c1b763ad8 100644
--- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -196,6 +196,20 @@ TEST(WalkAST, MemberExprs) {
"Derived foo(); void fun() { foo().^a; }");
   testWalk("struct Base { int a; }; struct $explicit^Derived : public Base 
{};",
"Derived& foo(); void fun() { foo().^a; }");
+  testWalk(R"cpp(
+  template 
+  struct unique_ptr {
+T *operator->();
+  };
+  struct $explicit^Foo { int a; };)cpp",
+   "void test(unique_ptr &V) { V->^a; }");
+  testWalk(R"cpp(
+  template 
+  struct $explicit^unique_ptr {
+void release();
+  };
+  struct Foo {};)cpp",
+   "void test(unique_ptr &V) { V.^release(); }");
 }
 
 TEST(WalkAST, ConstructExprs) {



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


[PATCH] D139696: [include-cleaner] Add a unique_ptr-style member expr test in WalkASTTest.

2022-12-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG4ce6dfbcd6f0: [include-cleaner] Add a unique_ptr-style 
member expr test in WalkASTTest. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D139696?vs=481546&id=482019#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139696

Files:
  clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -196,6 +196,20 @@
"Derived foo(); void fun() { foo().^a; }");
   testWalk("struct Base { int a; }; struct $explicit^Derived : public Base 
{};",
"Derived& foo(); void fun() { foo().^a; }");
+  testWalk(R"cpp(
+  template 
+  struct unique_ptr {
+T *operator->();
+  };
+  struct $explicit^Foo { int a; };)cpp",
+   "void test(unique_ptr &V) { V->^a; }");
+  testWalk(R"cpp(
+  template 
+  struct $explicit^unique_ptr {
+void release();
+  };
+  struct Foo {};)cpp",
+   "void test(unique_ptr &V) { V.^release(); }");
 }
 
 TEST(WalkAST, ConstructExprs) {


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -196,6 +196,20 @@
"Derived foo(); void fun() { foo().^a; }");
   testWalk("struct Base { int a; }; struct $explicit^Derived : public Base {};",
"Derived& foo(); void fun() { foo().^a; }");
+  testWalk(R"cpp(
+  template 
+  struct unique_ptr {
+T *operator->();
+  };
+  struct $explicit^Foo { int a; };)cpp",
+   "void test(unique_ptr &V) { V->^a; }");
+  testWalk(R"cpp(
+  template 
+  struct $explicit^unique_ptr {
+void release();
+  };
+  struct Foo {};)cpp",
+   "void test(unique_ptr &V) { V.^release(); }");
 }
 
 TEST(WalkAST, ConstructExprs) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139409: [include-cleaner] Handle dependent type members in AST

2022-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

thanks, looks mostly good, I think we can simplify the unittest further.




Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:51
   Type = Type->getPointeeType();
+if (const TemplateSpecializationType *TST =
+Type->getAs()) {

nit: we can use `const auto*` here as the type is explicitly spelled in the 
`getAs`



Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:52
+if (const TemplateSpecializationType *TST =
+Type->getAs()) {
+  return TST->getTemplateName().getAsTemplateDecl();

nit: remove the {} around the if statement



Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:74
   }
 
+  bool VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E) {

nit: I will remove this blank line, to make `VisitMemberExpr` and 
`VisitCXXDependentScopeMemberExpr` group together as they both achieve the same 
goal.



Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:207
+  testWalk("template struct $explicit^Base { void method(); };",
+   "template void k(Base* t) { t->^method(); }");
+  testWalk("template struct $explicit^Base { void method(); };",

I think keeping the above 3 test cases is enough, I would probably add them to 
the exiting MemberExprs test (with a comment saying this is dependent-type 
case).



Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:209
+  testWalk("template struct $explicit^Base { void method(); };",
+   "template void k() { Base t; t.^method(); }");
+  testWalk("template struct $explicit^Base { void method(); };",

I think we can remove this test, this test duplicates the first test



Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:211
+  testWalk("template struct $explicit^Base { void method(); };",
+   "template void k() { Base* t; t->^method(); }");
+  testWalk("template struct $explicit^Base { void method(); };",

And this case as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139409

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


[clang] 9853c02 - [LoongArch] Test CodeGen/LoongArch/intrinsic-la32.c with -O2. NFC.

2022-12-12 Thread via cfe-commits

Author: gonglingqin
Date: 2022-12-12T17:22:07+08:00
New Revision: 9853c0263efc71c6b392ab4f0af5b7ab117ab76e

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

LOG: [LoongArch] Test CodeGen/LoongArch/intrinsic-la32.c with -O2. NFC.

To avoid excessive redundancy in test cases, use -O2 instead of -O0
for testing.

Added: 


Modified: 
clang/test/CodeGen/LoongArch/intrinsic-la32.c

Removed: 




diff  --git a/clang/test/CodeGen/LoongArch/intrinsic-la32.c 
b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
index d9c201f05141c..490082dc1d5af 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la32.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
@@ -1,13 +1,13 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple loongarch32 -emit-llvm %s -o - \
+// RUN: %clang_cc1 -triple loongarch32 -O2 -emit-llvm %s -o - \
 // RUN: | FileCheck %s -check-prefix=LA32
 
 #include 
 
 // LA32-LABEL: @dbar(
 // LA32-NEXT:  entry:
-// LA32-NEXT:call void @llvm.loongarch.dbar(i32 0)
-// LA32-NEXT:call void @llvm.loongarch.dbar(i32 0)
+// LA32-NEXT:tail call void @llvm.loongarch.dbar(i32 0)
+// LA32-NEXT:tail call void @llvm.loongarch.dbar(i32 0)
 // LA32-NEXT:ret void
 //
 void dbar() {
@@ -17,8 +17,8 @@ void dbar() {
 
 // LA32-LABEL: @ibar(
 // LA32-NEXT:  entry:
-// LA32-NEXT:call void @llvm.loongarch.ibar(i32 0)
-// LA32-NEXT:call void @llvm.loongarch.ibar(i32 0)
+// LA32-NEXT:tail call void @llvm.loongarch.ibar(i32 0)
+// LA32-NEXT:tail call void @llvm.loongarch.ibar(i32 0)
 // LA32-NEXT:ret void
 //
 void ibar() {
@@ -28,8 +28,8 @@ void ibar() {
 
 // LA32-LABEL: @loongarch_break(
 // LA32-NEXT:  entry:
-// LA32-NEXT:call void @llvm.loongarch.break(i32 1)
-// LA32-NEXT:call void @llvm.loongarch.break(i32 1)
+// LA32-NEXT:tail call void @llvm.loongarch.break(i32 1)
+// LA32-NEXT:tail call void @llvm.loongarch.break(i32 1)
 // LA32-NEXT:ret void
 //
 void loongarch_break() {
@@ -39,8 +39,8 @@ void loongarch_break() {
 
 // LA32-LABEL: @syscall(
 // LA32-NEXT:  entry:
-// LA32-NEXT:call void @llvm.loongarch.syscall(i32 1)
-// LA32-NEXT:call void @llvm.loongarch.syscall(i32 1)
+// LA32-NEXT:tail call void @llvm.loongarch.syscall(i32 1)
+// LA32-NEXT:tail call void @llvm.loongarch.syscall(i32 1)
 // LA32-NEXT:ret void
 //
 void syscall() {
@@ -50,12 +50,8 @@ void syscall() {
 
 // LA32-LABEL: @csrrd_w(
 // LA32-NEXT:  entry:
-// LA32-NEXT:[[A:%.*]] = alloca i32, align 4
-// LA32-NEXT:[[B:%.*]] = alloca i32, align 4
-// LA32-NEXT:[[TMP0:%.*]] = call i32 @llvm.loongarch.csrrd.w(i32 1)
-// LA32-NEXT:store i32 [[TMP0]], ptr [[A]], align 4
-// LA32-NEXT:[[TMP1:%.*]] = call i32 @llvm.loongarch.csrrd.w(i32 1)
-// LA32-NEXT:store i32 [[TMP1]], ptr [[B]], align 4
+// LA32-NEXT:[[TMP0:%.*]] = tail call i32 @llvm.loongarch.csrrd.w(i32 1)
+// LA32-NEXT:[[TMP1:%.*]] = tail call i32 @llvm.loongarch.csrrd.w(i32 1)
 // LA32-NEXT:ret i32 0
 //
 unsigned int csrrd_w() {
@@ -66,16 +62,8 @@ unsigned int csrrd_w() {
 
 // LA32-LABEL: @csrwr_w(
 // LA32-NEXT:  entry:
-// LA32-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
-// LA32-NEXT:[[B:%.*]] = alloca i32, align 4
-// LA32-NEXT:[[C:%.*]] = alloca i32, align 4
-// LA32-NEXT:store i32 [[A:%.*]], ptr [[A_ADDR]], align 4
-// LA32-NEXT:[[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
-// LA32-NEXT:[[TMP1:%.*]] = call i32 @llvm.loongarch.csrwr.w(i32 [[TMP0]], 
i32 1)
-// LA32-NEXT:store i32 [[TMP1]], ptr [[B]], align 4
-// LA32-NEXT:[[TMP2:%.*]] = load i32, ptr [[A_ADDR]], align 4
-// LA32-NEXT:[[TMP3:%.*]] = call i32 @llvm.loongarch.csrwr.w(i32 [[TMP2]], 
i32 1)
-// LA32-NEXT:store i32 [[TMP3]], ptr [[C]], align 4
+// LA32-NEXT:[[TMP0:%.*]] = tail call i32 @llvm.loongarch.csrwr.w(i32 
[[A:%.*]], i32 1)
+// LA32-NEXT:[[TMP1:%.*]] = tail call i32 @llvm.loongarch.csrwr.w(i32 
[[A]], i32 1)
 // LA32-NEXT:ret i32 0
 //
 unsigned int csrwr_w(unsigned int a) {
@@ -86,20 +74,8 @@ unsigned int csrwr_w(unsigned int a) {
 
 // LA32-LABEL: @csrxchg_w(
 // LA32-NEXT:  entry:
-// LA32-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
-// LA32-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
-// LA32-NEXT:[[C:%.*]] = alloca i32, align 4
-// LA32-NEXT:[[D:%.*]] = alloca i32, align 4
-// LA32-NEXT:store i32 [[A:%.*]], ptr [[A_ADDR]], align 4
-// LA32-NEXT:store i32 [[B:%.*]], ptr [[B_ADDR]], align 4
-// LA32-NEXT:[[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
-// LA32-NEXT:[[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4
-// LA32-NEXT:[[TMP2:%.*]] = call i32 @llvm.loongarch.csrxchg.w(i32 
[[TMP0]], i32 [[TMP1]], i32 1)
-// LA32-NEXT:store i32 [[TM

[PATCH] D138675: [flang] Add -ffast-math and -Ofast

2022-12-12 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.
Herald added a subscriber: jdoerfert.

I have the `Driver/fast_math.f90` failing on my side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138675

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


[PATCH] D136594: [clangd] Add support for semantic token type "operator"

2022-12-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

While we're waiting for Sam to weigh in on the modifier question, a couple of 
comments about the details of the patch:

- Does the implementation handle explicit operator calls, e.g. 
`a.operator+(b)`? If so, it would be nice to add some test coverage.
- I see the patch handles new and delete expression but I couldn't spot any 
test cases for them, could you add some? (Apologies if I've overlooked it.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594

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


[PATCH] D139716: [include-cleaner] Use expansion locations for macros.

2022-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

The implementation looks good. Some comments around the test.




Comment at: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp:161
 
+TEST_F(FindHeadersTest, TargetIsArgumentExpandedFromMacroInHeader) {
+  llvm::Annotations MainFile(R"cpp(

these 3 newly-added tests are similar, instead of duplicating them, we can use 
a table-gen style test, see an 
[example](https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp#L265)



Comment at: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp:167
+  Inputs.Code = MainFile.code();
+  Inputs.ExtraFiles["declare.h"] = R"cpp(
+#include "macro.h"

nit: use `guard(R"cpp(...)cpp)` for the normal header code.



Comment at: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp:186
+  std::vector Headers;
+  walkUsed(
+  TopLevelDecls, {}, nullptr, AST->sourceManager(),

The intention of the test is to test the function `findHeaders`, we're testing 
it in an implicit way (`findHeaders` is hidden inside the `walkUsed`), there is 
no code here explicitly calling this function. 

We can make it clearer (no need to use walkUsed):
1. we get a `Foo` Decl AST node from the testcase.
2. with the AST node from step1, we cam call the `findHeaders` directly in the 
test code.

for 1, we can just write a simple RecursiveASTVisitor, and capture a NamedDecl 
which called Foo, something like:

```
 struct Visitor : RecursiveASTVisitor {
  const NamedDecl *Out = nullptr;
  bool VisitNamedDecl(const NamedDecl *ND) {
if (ND->getName() == "Foo") {
  EXPECT_TRUE(Out == nullptr);
  Out = ND;
}
return true;
  }
};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139716

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


[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2022-12-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge resigned from this revision.
nridge added a comment.

In D138546#3980350 , @cpsauer wrote:

> @nridge, I took a shot at amending the test. Thanks for the pointer! Please 
> me know if that looks good to you!

The test changes look good, thanks.

I'm going to leave the approval to Kadir because his comment sounded like he 
would maybe prefer for https://github.com/clangd/clangd/issues/1403 (note, it 
has a patch at D139277 ) to be fixed before 
merging this.


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

https://reviews.llvm.org/D138546

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


[PATCH] D139717: Revert "[Driver] Remove Joined -X"

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

In D139717#3986227 , @manojgupta 
wrote:

> The removal is also breaking ChromeOS builds which use -Xpattern in some 
> cases.

Do you have a justifying example showing which `-Xpattern` is used? It needs to 
do useful work, instead of just using an option which happened to be ignored 
(and probably not ignored by GCC).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139717

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


[PATCH] D139717: Revert "[Driver] Remove Joined -X"

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

> This change is breaking internal builds. We use the -Xfoo pattern but can now 
> no longer manage whether we allow an unused -Xfoo option to pass as a warning 
> or promote it to an error.

Which `-Xfoo` is used? Do your internal builds reserve `-Xfoo` as a placeholder 
to do other non-upstream work? Then you can consider `-Gfoo` if your builds 
don't need the mips semantics.
Is it possible to clean up the previously-ignored-with-a-warning `-Xfoo`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139717

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


[PATCH] D139305: [clang][driver] Support option '-mcpu' on target AVR.

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

> I think newr AVR projects should use clang common style options instead of 
> older avr-gcc style.

Does GCC prefer `-mcpu=` as well? If not, raise a PR there? This seems like a 
decision we should not unilaterally make on llvm-project side: it's certainly 
something GCC cares about as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139305

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


[PATCH] D139822: Allow using BareMetal toolchain with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR compiler-rt

2022-12-12 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings created this revision.
michaelplatings added reviewers: abidh, jroelofs.
michaelplatings added a project: clang.
Herald added subscribers: dberris, ki.stfu.
Herald added a project: All.
michaelplatings requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.

If you build compiler-rt with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR then the 
library filename will be "libclang_rt.builtins.a" instead of 
"libclang_rt.builtins-.a"

The ToolChain::getCompilerRT method uses the "libclang_rt.builtins.a" name if 
it can find the file in the library directories. If it can't then it falls back 
to using "libclang_rt.builtins-.a". This change adds the library 
directory such that "libclang_rt.builtins.a" can be found.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139822

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -340,3 +340,27 @@
 // CHECK-RV32IMAFC-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-RV32IMAFC-SAME: 
"-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
 // CHECK-RV32IMAFC-SAME: 
"-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
+
+// Check that compiler-rt library without the arch filename suffix will
+// be used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_noarch
+// RUN: mkdir -p %T/baremetal_clang_rt_noarch/lib
+// RUN: touch %T/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_noarch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-NOARCH %s
+// CHECK-CLANGRT-NOARCH: "-lclang_rt.builtins"
+// CHECK-CLANGRT-NOARCH-NOT: "-lclang_rt.builtins-armv6m"
+
+// Check that compiler-rt library with the arch filename suffix will be
+// used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_arch
+// RUN: mkdir -p %T/baremetal_clang_rt_arch/lib
+// RUN: touch %T/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_arch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
+// CHECK-CLANGRT-ARCH: "-lclang_rt.builtins-armv6m"
+// CHECK-CLANGRT-ARCH-NOT: "-lclang_rt.builtins"
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,6 +103,7 @@
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
+getLibraryPaths().push_back(std::string(SysRoot));
   }
 }
 


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -340,3 +340,27 @@
 // CHECK-RV32IMAFC-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-RV32IMAFC-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
 // CHECK-RV32IMAFC-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
+
+// Check that compiler-rt library without the arch filename suffix will
+// be used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_noarch
+// RUN: mkdir -p %T/baremetal_clang_rt_noarch/lib
+// RUN: touch %T/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_noarch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-NOARCH %s
+// CHECK-CLANGRT-NOARCH: "-lclang_rt.builtins"
+// CHECK-CLANGRT-NOARCH-NOT: "-lclang_rt.builtins-armv6m"
+
+// Check that compiler-rt library with the arch filename suffix will be
+// used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_arch
+// RUN: mkdir -p %T/baremetal_clang_rt_arch/lib
+// RUN: touch %T/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_arch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
+// CHECK-CLANGRT-ARCH: "-lclang_rt.builtins-armv6m"
+// CHECK-CLANGRT-ARCH-NOT: "-lclang_rt.builtins"
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,6 +103,7 @@
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
+getLibraryPaths().push_back(std::string(SysRoot));
   }
 }
 
___
cfe-commit

[PATCH] D136554: Implement CWG2631

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

When a CXXDefaultInitExpr calls a Constructor,
make sure that the fields default initialized by that 
constructor are also marked odr used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/UsedDeclVisitor.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/CXX/class/class.local/p1-0x.cpp
  clang/test/CXX/drs/dr26xx.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/CodeGenCXX/default-arguments-with-immediate.cpp
  clang/test/CodeGenCXX/meminit-initializers-odr.cpp
  clang/test/PCH/default-argument-with-immediate-calls.cpp
  clang/test/SemaCXX/cxx11-default-member-initializers.cpp
  clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
  clang/test/SemaCXX/source_location.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15593,7 +15593,7 @@
 https://wg21.link/cwg2631";>2631
 DR
 Immediate function evaluations in default arguments
-Unknown
+Clang 16
   
   
 https://wg21.link/cwg2632";>2632
Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -verify %s
 // expected-no-diagnostics
 
 #define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
@@ -8,15 +9,22 @@
 template 
 struct Printer;
 
+#ifdef USE_CONSTEVAL
+#define SOURCE_LOC_EVAL_KIND consteval
+#else
+#define SOURCE_LOC_EVAL_KIND constexpr
+#endif
+
 namespace std {
 class source_location {
   struct __impl;
 
 public:
-  static constexpr source_location current(const __impl *__p = __builtin_source_location()) noexcept {
-source_location __loc;
-__loc.__m_impl = __p;
-return __loc;
+  static SOURCE_LOC_EVAL_KIND source_location
+current(const __impl *__p = __builtin_source_location()) noexcept {
+  source_location __loc;
+  __loc.__m_impl = __p;
+  return __loc;
   }
   constexpr source_location() = default;
   constexpr source_location(source_location const &) = default;
@@ -593,3 +601,73 @@
   }
   static_assert(test());
 }
+
+namespace Lambda {
+#line 8000 "TestLambda.cpp"
+constexpr int nested_lambda(int l = []{
+  return SL::current().line();
+}()) {
+  return l;
+}
+static_assert(nested_lambda() == __LINE__ - 4);
+
+constexpr int lambda_param(int l = [](int l = SL::current().line()) {
+  return l;
+}()) {
+  return l;
+}
+static_assert(lambda_param() == __LINE__);
+
+
+}
+
+constexpr int compound_literal_fun(int a =
+  (int){ SL::current().line() }
+) { return a ;}
+static_assert(compound_literal_fun() == __LINE__);
+
+struct CompoundLiteral {
+  int a = (int){ SL::current().line() };
+};
+static_assert(CompoundLiteral{}.a == __LINE__);
+
+
+// FIXME
+// Init captures are subexpressions of the lambda expression
+// so according to the standard immediate invocations in init captures
+// should be evaluated at the call site.
+// However Clang does not yet implement this as it would introduce
+// a fair bit of complexity.
+// We intend to implement that functionality once we find real world
+// use cases that require it.
+constexpr int test_init_capture(int a =
+[b = SL::current().line()] { return b; }()) {
+  return a;
+}
+#ifdef USE_CONSTEVAL
+static_assert(test_init_capture() == __LINE__ - 4);
+#else
+static_assert(test_init_capture() == __LINE__ );
+#endif
+
+namespace check_immediate_invocations_in_templates {
+
+template 
+struct G {
+T line = __builtin_LINE();
+};
+template 
+struct S {
+int i = G{}.line;
+};
+static_assert(S{}.i != // intentional new line
+  S{}.i);
+
+template 
+constexpr int f(int i = G{}.line) {
+return i;
+}
+
+static_assert(f() != // intentional new line
+  f());
+}
Index: clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -fsyn

[clang] bb48aa2 - [Clang][NFC] Prevent lit tests from matching substrings in current path

2022-12-12 Thread Sameer Sahasrabuddhe via cfe-commits

Author: Sameer Sahasrabuddhe
Date: 2022-12-12T16:32:58+05:30
New Revision: bb48aa20e761e26226c6f909a07246781d68ba41

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

LOG: [Clang][NFC] Prevent lit tests from matching substrings in current path

Added: 


Modified: 
clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp 
b/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
index 0c9333fb6d7a..9bbf16f55fab 100644
--- a/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
+++ b/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
 
+// Catch the beginning and the end of the IR. This prevents the CHECK- from
+// matching a spurious "constant" string in file paths printed later.
+
+// CHECK-LABEL: target triple
 // CHECK-NOT: constant
+// CHECK-LABEL: attributes
 extern int X;
 const int Y = X;
 const int* foo() { return &Y; }

diff  --git a/clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp 
b/clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp
index 7700e97ae9d5..c9880f91a517 100644
--- a/clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp
+++ b/clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp
@@ -7,7 +7,7 @@ struct S {
 };
 
 void use(bool cond, struct S s1, struct S s2, int val1, int val2) {
-  // CHECK: define {{.*}}use{{.*}}(
+  // CHECK-LABEL: define {{.*}}use{{.*}}(
   // CHECK: %[[S1:.+]] = alloca %struct.S
   // CHECK: %[[S2:.+]] = alloca %struct.S
   // CHECK: %[[COND:.+]] = alloca i8
@@ -43,7 +43,7 @@ void use(bool cond, struct S s1, struct S s2, int val1, int 
val2) {
   // CHECK: store i16 %[[BF_SET]], ptr %[[S1]]
   // CHECK: br label %[[END:.+]]
 
-  // CHECK: [[END]]:
+  // CHECK-LABEL: [[END]]:
   // There is nothing in the 'end' block associated with this, but it is the
   // 'continuation' block for the rest of the function.
 
@@ -77,7 +77,7 @@ void use(bool cond, struct S s1, struct S s2, int val1, int 
val2) {
   // CHECK: store i16 %[[BF_SET]], ptr %[[S2]]
   // CHECK: br label %[[END:.+]]
 
-  // CHECK: [[END]]:
+  // CHECK-LABEL: [[END]]:
   // CHECK-NOT: phi
   // There is nothing in the 'end' block associated with this, but it is the
   // 'continuation' block for the rest of the function.
@@ -86,7 +86,7 @@ void use(bool cond, struct S s1, struct S s2, int val1, int 
val2) {
 
 
 void use2(bool cond1, bool cond2, struct S s1, int val1, int val2, int val3) {
-  // CHECK: define {{.*}}use2{{.*}}(
+  // CHECK-LABEL: define {{.*}}use2{{.*}}(
   // CHECK: %[[S1:.+]] = alloca %struct.S
   // CHECK: %[[COND1:.+]] = alloca i8
   // CHECK: %[[COND2:.+]] = alloca i8
@@ -141,7 +141,10 @@ void use2(bool cond1, bool cond2, struct S s1, int val1, 
int val2, int val3) {
   // CHECK: store i16 %[[BF_SET]], ptr %[[S1]]
   // CHECK: br label %[[END:.+]]
 
-  // CHECK[[END]]:
+  // CHECK-LABEL: [[END]]:
   // CHECK-NOT: phi
   // Nothing left to do here.
 }
+// Catch the end of the IR. This prevents the CHECK-NOT above from matching a
+// spurious "phi" in file paths printed later.
+// CHECK-LABEL: attributes



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


[PATCH] D136594: [clangd] Add support for semantic token type "operator"

2022-12-12 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 482055.
ckandeler added a comment.

Added more test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -113,9 +113,9 @@
   void $Function_def[[foo]](int $Parameter_def[[A]], $Class[[AS]] $Parameter_def[[As]]) {
 $Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[VeryLongVariableName]] = 12312;
 $Class[[AS]] $LocalVariable_def[[AA]];
-$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
+$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] $Operator[[+]] $Parameter[[A]];
 auto $LocalVariable_def[[FN]] = [ $LocalVariable[[AA]]](int $Parameter_def[[A]]) -> void {};
-$LocalVariable[[FN]](12312);
+$LocalVariable[[FN]]$Operator_userProvided[[(]]12312$Operator_userProvided[[)]];
   }
 )cpp",
   R"cpp(
@@ -144,7 +144,7 @@
   struct $Class_def[[B]] {
 $Class_decl_constrDestr[[B]]();
 ~$Class_decl_constrDestr[[B]]();
-void operator<<($Class[[B]]);
+void operator$Operator_decl[[<<]]($Class[[B]]);
 $Class[[AAA]] $Field_decl[[AA]];
   };
   $Class[[B]]::$Class_def_constrDestr[[B]]() {}
@@ -203,20 +203,20 @@
 static double $StaticField_decl_static[[S]];
 static void $StaticMethod_def_static[[bar]]() {}
 void $Method_def[[foo]]() {
-  $Field[[B]] = 123;
-  this->$Field[[B]] = 156;
+  $Field[[B]] $Operator[[=]] 123;
+  this->$Field[[B]] $Operator[[=]] 156;
   this->$Method[[foo]]();
   $Method[[foo]]();
   $StaticMethod_static[[bar]]();
-  $StaticField_static[[S]] = 90.1;
+  $StaticField_static[[S]] $Operator[[=]] 90.1;
 }
   };
   void $Function_def[[foo]]() {
 $Class[[A]] $LocalVariable_def[[AA]];
-$LocalVariable[[AA]].$Field[[B]] += 2;
+$LocalVariable[[AA]].$Field[[B]] $Operator[[+=]] 2;
 $LocalVariable[[AA]].$Method[[foo]]();
 $LocalVariable[[AA]].$Field[[E]].$Field[[C]];
-$Class[[A]]::$StaticField_static[[S]] = 90;
+$Class[[A]]::$StaticField_static[[S]] $Operator[[=]] 90;
   }
 )cpp",
   R"cpp(
@@ -295,10 +295,10 @@
   struct $Class_def[[B]] {};
   struct $Class_def[[A]] {
 $Class[[B]] $Field_decl[[BB]];
-$Class[[A]] &operator=($Class[[A]] &&$Parameter_def[[O]]);
+$Class[[A]] &operator$Operator_decl[[=]]($Class[[A]] &&$Parameter_def[[O]]);
   };
 
-  $Class[[A]] &$Class[[A]]::operator=($Class[[A]] &&$Parameter_def[[O]]) = default;
+  $Class[[A]] &$Class[[A]]::operator$Operator_def[[=]]($Class[[A]] &&$Parameter_def[[O]]) = default;
 )cpp",
   R"cpp(
   enum $Enum_decl[[En]] {
@@ -327,9 +327,9 @@
   $Enum_deduced[[auto]] $Variable_def[[AE]] = $Enum[[E]]::$EnumConstant_readonly[[E]];
   $Class_deduced[[auto]] $Variable_def[[AF]] = $Class[[Foo]]();
   $Class_deduced[[decltype]](auto) $Variable_def[[AF2]] = $Class[[Foo]]();
-  $Class_deduced[[auto]] *$Variable_def[[AFP]] = &$Variable[[AF]];
+  $Class_deduced[[auto]] *$Variable_def[[AFP]] = $Operator[[&]]$Variable[[AF]];
   $Enum_deduced[[auto]] &$Variable_def[[AER]] = $Variable[[AE]];
-  $Primitive_deduced_defaultLibrary[[auto]] $Variable_def[[Form]] = 10.2 + 2 * 4;
+  $Primitive_deduced_defaultLibrary[[auto]] $Variable_def[[Form]] = 10.2 $Operator[[+]] 2 $Operator[[*]] 4;
   $Primitive_deduced_defaultLibrary[[decltype]]($Variable[[Form]]) $Variable_def[[F]] = 10;
   auto $Variable_def[[Fun]] = []()->void{};
 )cpp",
@@ -342,21 +342,21 @@
   template
   class $Class_def[[IP]] {
 void $Method_def[[f]]() {
-  *$TemplateParameter_readonly[[U]] += 5;
+  $Operator[[*]]$TemplateParameter_readonly[[U]] $Operator[[+=]] 5;
 }
   };
   template
   class $Class_def[[Foo]] {
 void $Method_def[[f]]() {
   for(int $LocalVariable_def[[I]] = 0;
-$LocalVariable[[I]] < $TemplateParameter_readonly[[U]];) {}
+$LocalVariable[[I]] $Operator[[<]] $TemplateParameter_readonly[[U]];) {}
 }
   };
 
   $Class[[G]] $Variable_def[[L]];
   void $Function_def[[f]

[PATCH] D139608: [Clang][NFC] Add default `getBFloat16Mangling` impl

2022-12-12 Thread Pierre van Houtryve via Phabricator via cfe-commits
Pierre-vh added a comment.

In D139608#3982494 , @jcranmer-intel 
wrote:

> I don't normally handle name mangling, so I can't comment too much here, but 
> I will note that Itanium ABI is planning on using DF16b for 
> `std::bfloat16_t`: https://github.com/itanium-cxx-abi/cxx-abi/pull/147

This is just a NFC so if we're sure targets will soon start to use different 
mangled names then I can just abandon the commit
I just proposed this change because currently there's no reason not to have a 
default value for this function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139608

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


[PATCH] D136594: [clangd] Add support for semantic token type "operator"

2022-12-12 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

In D136594#3987852 , @nridge wrote:

> - Does the implementation handle explicit operator calls, e.g. 
> `a.operator+(b)`? If so, it would be nice to add some test coverage.

It does now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594

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


[clang] a888825 - [UpdateTestChecks] Match define for labels

2022-12-12 Thread Sebastian Neubauer via cfe-commits

Author: Sebastian Neubauer
Date: 2022-12-12T12:29:54+01:00
New Revision: a25aeef8d6592c6cf5f4e5854cc39af49633

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

LOG: [UpdateTestChecks] Match define for labels

Previously, the label also matched function calls with the function
name, which caused tests to fail because the label matched on the wrong
line.
Add the `define` prefix, so only function defines are matched.

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

Added: 

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/define_after_call.ll

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/define_after_call.ll.expected
llvm/test/tools/UpdateTestChecks/update_test_checks/define_after_call.test

Modified: 
clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected

clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected

clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.expected
clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected

clang/test/utils/update_cc_test_checks/Inputs/explicit-template-instantiation.cpp.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected

clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
clang/test/utils/update_cc_test_checks/Inputs/ifdef.c.expected
clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected

clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected

clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
clang/test/utils/update_cc_test_checks/check-globals.test

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/argument_name_reuse.ll.plain.expected
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic.ll.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/custom-tool.ll.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/scrub_attrs.ll.plain.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/scrub_attrs.ll.scrub.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.expected
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
index 6c7dd730e543..ccd308688374 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
+++ b/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
@@ -8,7 +8,7 @@ class Foo {
 public:
   explicit Foo(int x);
   ~Foo();
-// CHECK-LABEL: @_ZNK3Foo23function_defined_inlineEi(
+// CHECK-LABEL: define {{[^@]+}}@_ZNK3Foo23function_defined_inlineEi(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
 // CHECK-NEXT:[[ARG_ADDR:%.*]] = alloca i32, align 4
@@ -27,7 +27,7 @@ public:
   inline int function_defined_out_of_line(int arg) const;
 };
 
-// CHECK-LABEL: @_ZN3FooC1Ei(
+// CHECK-LABEL: define {{[^@]+}}@_ZN3FooC1Ei(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
 // CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
@@ -39,7 +39,7 @@ public:
 // CHECK-NEXT:r

[PATCH] D139006: [UpdateTestChecks] Match define for labels

2022-12-12 Thread Sebastian Neubauer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa25aeef8: [UpdateTestChecks] Match define for labels 
(authored by sebastian-ne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139006

Files:
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.expected
  clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/explicit-template-instantiation.cpp.expected
  clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/ifdef.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
  clang/test/utils/update_cc_test_checks/check-globals.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/argument_name_reuse.ll.plain.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/custom-tool.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/define_after_call.ll
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/define_after_call.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/scrub_attrs.ll.plain.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/scrub_attrs.ll.scrub.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/define_after_call.test
  llvm/utils/UpdateTestChecks/common.py

Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -1028,7 +1028,7 @@
   func_name, preserve_names, function_sig,
   global_vars_seen_dict, is_filtered):
   # Label format is based on IR string.
-  function_def_regex = 'define {{[^@]+}}' if function_sig else ''
+  function_def_regex = 'define {{[^@]+}}'
   check_label_format = '{} %s-LABEL: {}@%s%s%s'.format(comment_marker, function_def_regex)
   return add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name,
 check_label_format, False, preserve_names, global_vars_seen_dict,
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/define_after_call.test
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/define_after_call.test
@@ -0,0 +1,4 @@
+# Verify that calls and defines of the same function can be mixed
+# RUN: cp -f %S/Inputs/define_after_call.ll %t.ll && %update_test_checks %t.ll
+# RUN: diff -u %t.ll %S/Inputs/define_after_call.ll.expected
+# RUN: opt < %t.ll -S | FileCheck %t.ll
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.expected
===
--- llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.expected
+++ llvm/test/tools/UpdateTestChecks/update_te

[PATCH] D138675: [flang] Add -ffast-math and -Ofast

2022-12-12 Thread Tom Eccles via Phabricator via cfe-commits
tblah added a comment.

In D138675#3987836 , @clementval 
wrote:

> I have the `Driver/fast_math.f90` failing on my side.
>
>   llvm-project/flang/test/Driver/fast_math.f90:63:14: error: CHECK-CRT: 
> expected string not found in input
>   ! CHECK-CRT: crtbeginS.o
>
> I have a `crtbegin.o` in the link line but not a `crtbeginS.o `

Thanks for the heads up. This should be fixed by 
https://github.com/llvm/llvm-project/commit/bea45027b43ec61a3efc4b487ceca2da25504432


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138675

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


[PATCH] D139786: [clang-format] AllowShortRequiresExpressionOnASingleLine

2022-12-12 Thread Zhikai Zeng via Phabricator via cfe-commits
Backl1ght updated this revision to Diff 482062.
Backl1ght retitled this revision from "[clang-format] 
AllowShortRequiresExpressionOnASingleLine and 
AllowShortCompoundRequirementOnASingleLine" to "[clang-format] 
AllowShortRequiresExpressionOnASingleLine".
Backl1ght edited the summary of this revision.
Backl1ght set the repository for this revision to rG LLVM Github Monorepo.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139786

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2899,6 +2899,19 @@
Style);
 }
 
+TEST_F(FormatTest, ShortRequiresExpression) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortRequiresExpressionOnASingleLine);
+  verifyFormat("template \n"
+   "concept c = requires(T a, T b) { a + b; };");
+  Style.AllowShortRequiresExpressionOnASingleLine = false;
+  verifyFormat("template \n"
+   "concept c = requires(T a, T b) {\n"
+   "  a + b;\n"
+   "};");
+  // TODO: support BraceWrapping.AfterRequiresExpression.
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -149,6 +149,7 @@
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortRequiresExpressionOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,6 +1085,12 @@
   FormatTok->setBlockKind(BK_Block);
   const FormatToken *OpeningBrace = FormatTok;
   nextToken();
+
+  if (NextLBracesType == TT_CompoundRequirementLBrace &&
+  !Style.AllowShortRequiresExpressionOnASingleLine) {
+addUnwrappedLine();
+  }
+
   {
 bool SkipIndent = (Style.isJavaScript() &&
(isGoogScope(*Line) || isIIFE(*Line, Keywords)));
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -502,6 +502,8 @@
   // Try to merge records.
   if (TheLine->Last->is(TT_EnumLBrace)) {
 ShouldMerge = Style.AllowShortEnumsOnASingleLine;
+  } else if (TheLine->Last->is(TT_RequiresExpressionLBrace)) {
+ShouldMerge = Style.AllowShortRequiresExpressionOnASingleLine;
   } else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace)) {
 // NOTE: We use AfterClass (whereas AfterStruct exists) for both classes
 // and structs, but it seems that wrapping is still handled correctly
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -816,6 +816,8 @@
Style.AllowShortLambdasOnASingleLine);
 IO.mapOptional("AllowShortLoopsOnASingleLine",
Style.AllowShortLoopsOnASingleLine);
+IO.mapOptional("AllowShortRequiresExpressionOnASingleLine",
+   Style.AllowShortRequiresExpressionOnASingleLine);
 IO.mapOptional("AlwaysBreakAfterDefinitionReturnType",
Style.AlwaysBreakAfterDefinitionReturnType);
 IO.mapOptional("AlwaysBreakAfterReturnType",
@@ -1265,6 +1267,7 @@
   LLVMStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
   LLVMStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
   LLVMStyle.AllowShortLoopsOnASingleLine = false;
+  LLVMStyle.AllowShortRequiresExpressionOnASingleLine = true;
   LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
   LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
   LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -714,6 +714,21 @@
   //

[PATCH] D139786: [clang-format] AllowShortRequiresExpressionOnASingleLine

2022-12-12 Thread Zhikai Zeng via Phabricator via cfe-commits
Backl1ght updated this revision to Diff 482066.

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

https://reviews.llvm.org/D139786

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2899,6 +2899,20 @@
Style);
 }
 
+TEST_F(FormatTest, ShortRequiresExpression) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortRequiresExpressionOnASingleLine);
+  verifyFormat("template \n"
+   "concept c = requires(T a, T b) { a + b; };",
+   Style);
+  Style.AllowShortRequiresExpressionOnASingleLine = false;
+  verifyFormat("template \n"
+   "concept c = requires(T a, T b) {\n"
+   "  a + b;\n"
+   "};",
+   Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -149,6 +149,7 @@
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortRequiresExpressionOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,6 +1085,12 @@
   FormatTok->setBlockKind(BK_Block);
   const FormatToken *OpeningBrace = FormatTok;
   nextToken();
+
+  if (NextLBracesType == TT_CompoundRequirementLBrace &&
+  !Style.AllowShortRequiresExpressionOnASingleLine) {
+addUnwrappedLine();
+  }
+
   {
 bool SkipIndent = (Style.isJavaScript() &&
(isGoogScope(*Line) || isIIFE(*Line, Keywords)));
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -502,6 +502,8 @@
   // Try to merge records.
   if (TheLine->Last->is(TT_EnumLBrace)) {
 ShouldMerge = Style.AllowShortEnumsOnASingleLine;
+  } else if (TheLine->Last->is(TT_RequiresExpressionLBrace)) {
+ShouldMerge = Style.AllowShortRequiresExpressionOnASingleLine;
   } else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace)) {
 // NOTE: We use AfterClass (whereas AfterStruct exists) for both classes
 // and structs, but it seems that wrapping is still handled correctly
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -816,6 +816,8 @@
Style.AllowShortLambdasOnASingleLine);
 IO.mapOptional("AllowShortLoopsOnASingleLine",
Style.AllowShortLoopsOnASingleLine);
+IO.mapOptional("AllowShortRequiresExpressionOnASingleLine",
+   Style.AllowShortRequiresExpressionOnASingleLine);
 IO.mapOptional("AlwaysBreakAfterDefinitionReturnType",
Style.AlwaysBreakAfterDefinitionReturnType);
 IO.mapOptional("AlwaysBreakAfterReturnType",
@@ -1265,6 +1267,7 @@
   LLVMStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
   LLVMStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
   LLVMStyle.AllowShortLoopsOnASingleLine = false;
+  LLVMStyle.AllowShortRequiresExpressionOnASingleLine = true;
   LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
   LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
   LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -714,6 +714,21 @@
   /// \version 3.7
   bool AllowShortLoopsOnASingleLine;
 
+  /// Allow short requires expression on a single line.
+  /// \code
+  ///   true:
+  ///   template 
+  ///   concept c = requires(T a, T b) { a + b; };
+  ///
+  ///   false:
+  ///   template 
+  ///   concept c = requires(T a, T b) {
+  /// a + b;
+  ///   };
+  /// \endcode
+  /// \version 16
+  bool AllowShortRequir

[PATCH] D139006: [UpdateTestChecks] Match define for labels

2022-12-12 Thread Max Kazantsev via Phabricator via cfe-commits
mkazantsev added a comment.

So now every single test needs to be regenerated? It'll create straw diff from 
nowhere...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139006

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


[clang-tools-extra] 5af4408 - [clangd] Remove a gest-internal header, NFC

2022-12-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-12-12T13:16:18+01:00
New Revision: 5af440868c1a1ea880bcbfa3c04b3336af1932c2

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

LOG: [clangd] Remove a gest-internal header, NFC

gmock-more-matchers.h is a private header, we should use gmock.h which
is already included in the test.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp 
b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index a7869f0a2fdb2..27854004094e0 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -22,7 +22,6 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gmock/gmock-matchers.h"
-#include "gmock/gmock-more-matchers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 



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


[PATCH] D136594: [clangd] Add support for semantic token type "operator"

2022-12-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks for the explanation! It makes sense. And given this motivation I don't 
think inverting to "builtin" is a good idea.
The impact is a bit limited because it's not a standard modifier, but it 
doesn't add much complexity, so LGTM.

I think the naming is an issue: "user-provided" is an unusual term with a very 
specific and unusual meaning for functions. I'd prefer the more generic 
"user-defined", if you don't mind changing it. (Also not perfect, but I can't 
think of a really good name).

Something related that might be interesting (and visible in more editors): 
highlighting the **non-**operator uses of `*` or other tokens. (This patch 
largely won't affect them, as they'll probably be client-side highlighted as 
operators if we don't say anything). Filed 
https://github.com/clangd/clangd/issues/1421. (Unfortunately I'm not really 
able to do clangd feature work these days)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594

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


[PATCH] D139006: [UpdateTestChecks] Match define for labels

2022-12-12 Thread Sebastian Neubauer via Phabricator via cfe-commits
sebastian-ne added a comment.

In D139006#3988215 , @mkazantsev 
wrote:

> So now every single test needs to be regenerated? It'll create straw diff 
> from nowhere...

We don’t need to regenerate every test.
Similar to how we don’t reformat all of LLVM after a change in clang-format, we 
can just do that when regenerating tests when they have changes anyway.
So, the churn is that we have extra changes when regenerating a test for a 
patch.
(In my personal experience there are often extra changes anyway, because 
metadata was added or similar changes that pass the old CHECKs but show up on a 
freshly regenerated test.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139006

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


[PATCH] D139834: [clang-format] AllowShortCompoundRequirementOnASingleLine

2022-12-12 Thread Zhikai Zeng via Phabricator via cfe-commits
Backl1ght created this revision.
Backl1ght added reviewers: HazardyKnusperkeks, rymiel.
Backl1ght added a project: clang-format.
Herald added a project: All.
Backl1ght requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

clang-format brace wrapping did not take requires into consideration, compound 
requirements will be affected by BraceWrapping.AfterFunction.

I plan to add 3 options AllowShortRequiresExpressionOnASingleLine, 
AllowShortCompoundRequirementOnASingleLine and 
BraceWrapping.AfterRequiresExpression.

This patch is for AllowShortCompoundRequirementOnASingleLine.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139834

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2899,6 +2899,40 @@
Style);
 }
 
+TEST_F(FormatTest, ShortCompoundRequirement) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortCompoundRequirementOnASingleLine);
+  verifyFormat("template \n"
+   "concept c = requires(T x) {\n"
+   "  { x + 1 } -> std::same_as;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept c = requires(T x) {\n"
+   "  { x + 1 } -> std::same_as;\n"
+   "  { x + 2 } -> std::same_as;\n"
+   "};",
+   Style);
+  Style.AllowShortCompoundRequirementOnASingleLine = false;
+  verifyFormat("template \n"
+   "concept c = requires(T x) {\n"
+   "  {\n"
+   "x + 1\n"
+   "  } -> std::same_as;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept c = requires(T x) {\n"
+   "  {\n"
+   "x + 1\n"
+   "  } -> std::same_as;\n"
+   "  {\n"
+   "x + 2\n"
+   "  } -> std::same_as;\n"
+   "};",
+   Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -147,6 +147,7 @@
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortCompoundRequirementOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -502,6 +502,8 @@
   // Try to merge records.
   if (TheLine->Last->is(TT_EnumLBrace)) {
 ShouldMerge = Style.AllowShortEnumsOnASingleLine;
+  } else if (TheLine->Last->is(TT_CompoundRequirementLBrace)) {
+ShouldMerge = Style.AllowShortCompoundRequirementOnASingleLine;
   } else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace)) {
 // NOTE: We use AfterClass (whereas AfterStruct exists) for both classes
 // and structs, but it seems that wrapping is still handled correctly
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -806,6 +806,8 @@
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
Style.AllowShortCaseLabelsOnASingleLine);
+IO.mapOptional("AllowShortCompoundRequirementOnASingleLine",
+   Style.AllowShortCompoundRequirementOnASingleLine);
 IO.mapOptional("AllowShortEnumsOnASingleLine",
Style.AllowShortEnumsOnASingleLine);
 IO.mapOptional("AllowShortFunctionsOnASingleLine",
@@ -1260,6 +1262,7 @@
   LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
   LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
+  LLVMStyle.AllowShortCompoundRequirementOnASingleLine = true;
   LLVMStyle.AllowShortEnumsOnASingleLine = true;
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
Index: clang/includ

[clang-tools-extra] 843be73 - [clangd] Fix a typo "Features.h" => "Feature.h" in IWYU pragma.

2022-12-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-12-12T13:46:19+01:00
New Revision: 843be73065617a4b55a542aff7d0b286c1e9b888

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

LOG: [clangd] Fix a typo "Features.h" => "Feature.h" in IWYU pragma.

Added: 


Modified: 
clang-tools-extra/clangd/Features.inc.in

Removed: 




diff  --git a/clang-tools-extra/clangd/Features.inc.in 
b/clang-tools-extra/clangd/Features.inc.in
index 764fee7850d4..a43a6ec3a172 100644
--- a/clang-tools-extra/clangd/Features.inc.in
+++ b/clang-tools-extra/clangd/Features.inc.in
@@ -1,4 +1,4 @@
-// IWYU pragma: private, include "Features.h"
+// IWYU pragma: private, include "Feature.h"
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
 #define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
 #define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@



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


[PATCH] D139835: [include-cleaner] Include the reference type when printing the SymbolReference.

2022-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

This information is useful when printing the reference for debugging
purposes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139835

Files:
  clang-tools-extra/include-cleaner/lib/Types.cpp


Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -46,7 +46,7 @@
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolReference &R) 
{
   // We can't decode the Location without SourceManager. Its raw representation
   // isn't completely useless (and distinguishes SymbolReference from Symbol).
-  return OS << R.Target << "@0x"
+  return OS << R.Target << "@" << R.RT << "@0x"
 << llvm::utohexstr(
R.RefLocation.getRawEncoding(), /*LowerCase=*/false,
/*Width=*/CHAR_BIT * sizeof(SourceLocation::UIntTy));


Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -46,7 +46,7 @@
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolReference &R) {
   // We can't decode the Location without SourceManager. Its raw representation
   // isn't completely useless (and distinguishes SymbolReference from Symbol).
-  return OS << R.Target << "@0x"
+  return OS << R.Target << "@" << R.RT << "@0x"
 << llvm::utohexstr(
R.RefLocation.getRawEncoding(), /*LowerCase=*/false,
/*Width=*/CHAR_BIT * sizeof(SourceLocation::UIntTy));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139113: [clang-tidy] Fix a couple additional cases in misc-use-anonymous-namespace

2022-12-12 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal accepted this revision.
vingeldal added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp:46-48
+// OK
+static const int v8{123};
+static constexpr int v9{123};

Is it really the best behavior to allow these? If I got the rationale right we 
don't warn about this because const and constexpr have implicit internal 
linkage anyway, so static doesn't make a difference, right?
Reading the documentation for this check I gather static would probably have 
been deprecated if it wasn't for the fact that deprecation would have broken 
compatibility with C. So, if we drop the static keyword here we still get the 
behavior we want, without a confusing keyword we would rather get rid of if we 
could, while keeping compatibility with C.

I'm thinking it could be better to just discourage from using static for cases 
like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139113

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


[PATCH] D138675: [flang] Add -ffast-math and -Ofast

2022-12-12 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D138675#3988110 , @tblah wrote:

> In D138675#3987836 , @clementval 
> wrote:
>
>> I have the `Driver/fast_math.f90` failing on my side.
>>
>>   llvm-project/flang/test/Driver/fast_math.f90:63:14: error: CHECK-CRT: 
>> expected string not found in input
>>   ! CHECK-CRT: crtbeginS.o
>>
>> I have a `crtbegin.o` in the link line but not a `crtbeginS.o `
>
> Thanks for the heads up. This should be fixed by 
> https://github.com/llvm/llvm-project/commit/bea45027b43ec61a3efc4b487ceca2da25504432

Thanks for the fix. `crtendS.o` has the same issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138675

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2022-12-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: aaron.ballman, erichkeane, rsmith.
Herald added a subscriber: martong.
Herald added a reviewer: shafik.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

except that parenthesized expression-list support is left as TODO since
it depends on D129531 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139837

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp

Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,297 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK: | |-ClassTemplateSpecialization {{.*}} 'S'
+  // CHECK: | `-BuiltinType {{.*}} 'int'
+  // CHECK: `-SubstTemplateTypeParmType {{.*}} 'int' sugar type

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2022-12-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 482088.
ychen added a comment.

format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp

Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,297 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK: | |-ClassTemplateSpecialization {{.*}} 'S'
+  // CHECK: | `-BuiltinType {{.*}} 'int'
+  // CHECK: `-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK:   |-ClassTemplateSpecialization {{.*}} 'S'
+  // CHECK:   `-BuiltinType {{.*}} 'int'
+
+  template  struct E {
+T t;
+decltype(t) t2;
+  };
+
+  E e1 = {1, 2};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} imp

[PATCH] D139835: [include-cleaner] Include the reference type when printing the SymbolReference.

2022-12-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/include-cleaner/lib/Types.cpp:49
   // isn't completely useless (and distinguishes SymbolReference from Symbol).
-  return OS << R.Target << "@0x"
+  return OS << R.Target << "@" << R.RT << "@0x"
 << llvm::utohexstr(

i think this might read better as:
```
OS << R.RT << " reference to " << R.Target << "@0x" << ...;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139835

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


[clang] c9e9a7f - Revert "[Clang][NFC] Prevent lit tests from matching substrings in current path"

2022-12-12 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-12-12T14:44:10+01:00
New Revision: c9e9a7f2fd4b41a842c74ce2a4bbaccf8a4559e5

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

LOG: Revert "[Clang][NFC] Prevent lit tests from matching substrings in current 
path"

This reverts commit bb48aa20e761e26226c6f909a07246781d68ba41.

Using placeholders inside CHECK-LABEL is not legal.

Added: 


Modified: 
clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp 
b/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
index 9bbf16f55fab4..0c9333fb6d7a0 100644
--- a/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
+++ b/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
@@ -1,11 +1,6 @@
 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
 
-// Catch the beginning and the end of the IR. This prevents the CHECK- from
-// matching a spurious "constant" string in file paths printed later.
-
-// CHECK-LABEL: target triple
 // CHECK-NOT: constant
-// CHECK-LABEL: attributes
 extern int X;
 const int Y = X;
 const int* foo() { return &Y; }

diff  --git a/clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp 
b/clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp
index c9880f91a5178..7700e97ae9d5c 100644
--- a/clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp
+++ b/clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp
@@ -7,7 +7,7 @@ struct S {
 };
 
 void use(bool cond, struct S s1, struct S s2, int val1, int val2) {
-  // CHECK-LABEL: define {{.*}}use{{.*}}(
+  // CHECK: define {{.*}}use{{.*}}(
   // CHECK: %[[S1:.+]] = alloca %struct.S
   // CHECK: %[[S2:.+]] = alloca %struct.S
   // CHECK: %[[COND:.+]] = alloca i8
@@ -43,7 +43,7 @@ void use(bool cond, struct S s1, struct S s2, int val1, int 
val2) {
   // CHECK: store i16 %[[BF_SET]], ptr %[[S1]]
   // CHECK: br label %[[END:.+]]
 
-  // CHECK-LABEL: [[END]]:
+  // CHECK: [[END]]:
   // There is nothing in the 'end' block associated with this, but it is the
   // 'continuation' block for the rest of the function.
 
@@ -77,7 +77,7 @@ void use(bool cond, struct S s1, struct S s2, int val1, int 
val2) {
   // CHECK: store i16 %[[BF_SET]], ptr %[[S2]]
   // CHECK: br label %[[END:.+]]
 
-  // CHECK-LABEL: [[END]]:
+  // CHECK: [[END]]:
   // CHECK-NOT: phi
   // There is nothing in the 'end' block associated with this, but it is the
   // 'continuation' block for the rest of the function.
@@ -86,7 +86,7 @@ void use(bool cond, struct S s1, struct S s2, int val1, int 
val2) {
 
 
 void use2(bool cond1, bool cond2, struct S s1, int val1, int val2, int val3) {
-  // CHECK-LABEL: define {{.*}}use2{{.*}}(
+  // CHECK: define {{.*}}use2{{.*}}(
   // CHECK: %[[S1:.+]] = alloca %struct.S
   // CHECK: %[[COND1:.+]] = alloca i8
   // CHECK: %[[COND2:.+]] = alloca i8
@@ -141,10 +141,7 @@ void use2(bool cond1, bool cond2, struct S s1, int val1, 
int val2, int val3) {
   // CHECK: store i16 %[[BF_SET]], ptr %[[S1]]
   // CHECK: br label %[[END:.+]]
 
-  // CHECK-LABEL: [[END]]:
+  // CHECK[[END]]:
   // CHECK-NOT: phi
   // Nothing left to do here.
 }
-// Catch the end of the IR. This prevents the CHECK-NOT above from matching a
-// spurious "phi" in file paths printed later.
-// CHECK-LABEL: attributes



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


[clang] 5f84369 - [Clang] Convert CXX tests to opaque pointers (NFC)

2022-12-12 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-12-12T14:49:32+01:00
New Revision: 5f843693a461696a00f2e349b51e4cc9282a1a7b

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

LOG: [Clang] Convert CXX tests to opaque pointers (NFC)

Added: 


Modified: 
clang/test/CXX/drs/dr158.cpp
clang/test/CXX/except/except.spec/p14-ir.cpp
clang/test/CXX/except/except.spec/p9-dynamic.cpp
clang/test/CXX/except/except.spec/p9-noexcept.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
clang/test/CXX/expr/p10-0x.cpp
clang/test/CXX/special/class.copy/p15-inclass.cpp

Removed: 




diff  --git a/clang/test/CXX/drs/dr158.cpp b/clang/test/CXX/drs/dr158.cpp
index 40603d4a4a05c..a0a8bd05baee3 100644
--- a/clang/test/CXX/drs/dr158.cpp
+++ b/clang/test/CXX/drs/dr158.cpp
@@ -1,15 +1,15 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux -std=c++98 %s -O3 
-disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux -std=c++11 %s -O3 
-disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux -std=c++14 %s -O3 
-disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux -std=c++1z %s -O3 
-disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -O3 -disable-llvm-passes 
-pedantic-errors -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++11 %s -O3 -disable-llvm-passes 
-pedantic-errors -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++14 %s -O3 -disable-llvm-passes 
-pedantic-errors -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++1z %s -O3 -disable-llvm-passes 
-pedantic-errors -emit-llvm -o - | FileCheck %s
 
 // dr158: yes
 
 // CHECK-LABEL: define {{.*}} @_Z1f
 const int *f(const int * const *p, int **q) {
-  // CHECK: load i32**, {{.*}}, !tbaa ![[INTPTR_TBAA:[^,]*]]
+  // CHECK: load ptr, {{.*}}, !tbaa ![[INTPTR_TBAA:[^,]*]]
   const int *x = *p;
-  // CHECK: store i32* null, {{.*}}, !tbaa ![[INTPTR_TBAA]]
+  // CHECK: store ptr null, {{.*}}, !tbaa ![[INTPTR_TBAA]]
   *q = 0;
   return x;
 }
@@ -18,9 +18,9 @@ struct A {};
 
 // CHECK-LABEL: define {{.*}} @_Z1g
 const int *(A::*const *g(const int *(A::* const **p)[3], int 
*(A::***q)[3]))[3] {
-  // CHECK: load i64**, {{.*}}, !tbaa ![[MEMPTR_TBAA:[^,]*]]
+  // CHECK: load ptr, {{.*}}, !tbaa ![[MEMPTR_TBAA:[^,]*]]
   const int *(A::*const *x)[3] = *p;
-  // CHECK: store i64* null, {{.*}}, !tbaa ![[MEMPTR_TBAA]]
+  // CHECK: store ptr null, {{.*}}, !tbaa ![[MEMPTR_TBAA]]
   *q = 0;
   return x;
 }

diff  --git a/clang/test/CXX/except/except.spec/p14-ir.cpp 
b/clang/test/CXX/except/except.spec/p14-ir.cpp
index 1406cd34ac4ce..48d0669ec641e 100644
--- a/clang/test/CXX/except/except.spec/p14-ir.cpp
+++ b/clang/test/CXX/except/except.spec/p14-ir.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin10 
-emit-llvm -fexceptions -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -o - 
%s | FileCheck %s
 
 // Copy constructor
 struct X0 {
@@ -26,12 +26,12 @@ struct X4 {
 struct X5 : X0, X4 { };
 
 void test(X2 x2, X3 x3, X5 x5) {
-  // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* {{[^,]*}} 
%this, %struct.X2* noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) 
%0) unnamed_addr
+  // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(ptr {{[^,]*}} %this, ptr 
noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
   // CHECK:  call void @_ZN2X2C2ERKS_({{.*}}) [[NUW:#[0-9]+]]
   // CHECK-NEXT: ret void
   // CHECK-NEXT: }
   X2 x2a(x2);
-  // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* {{[^,]*}} 
%this, %struct.X3* noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) 
%0) unnamed_addr
+  // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(ptr {{[^,]*}} %this, ptr 
noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
   // CHECK:  call void @_ZN2X3C2ERKS_({{.*}}) [[NUW]]
   // CHECK-NEXT: ret void
   // CHECK-NEXT: }
@@ -55,25 +55,24 @@ struct X8 : X6 { };
 struct X9 : X6, X7 { };
 
 void test() {
-  // CHECK: define linkonce_odr void @_ZN2X8C1Ev(%struct.X8* {{[^,]*}} %this) 
unnamed_addr
+  // CHECK: define linkonce_odr void @_ZN2X8C1Ev(ptr {{[^,]*}} %this) 
unnamed_addr
   // CHECK:  call void @_ZN2X8C2Ev({{.*}}) [[NUW]]
   // CHECK-NEXT: ret void
   X8();
 
-  // CHECK: define linkonce_odr void @_ZN2X9C1Ev(%struct.X9* {{[^,]*}} %this) 
unnamed_addr
+  // CHECK: define linkonce_odr void @_ZN2X

[PATCH] D139720: [clang][PPC] Checking Unknown Values Passed to -mcpu

2022-12-12 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser requested changes to this revision.
jamieschmeiser added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:54
+auto TargetCPUName = llvm::StringSwitch(CPUName)
+ .Case("common", "generic")
+ .Case("440fp", "440")

This seems strange.  If the option is "generic", it calls 
getPPCGenericTargetCPU(), but if it is "common", it returns "generic."  I think 
you may want to also call getPPCGenericTargetCPU() here.  There should probably 
also be an assume where this returns that it didn't return "generic" if that is 
the intended result.  Also, there should also be tests for what happens when 
"generic" and "common" are specified.



Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:77
+ .Default(CPUName);
+return TargetCPUName.str();
   }

Why did you change the type from const char *?  Couldn't you use 
CPUName->data() in the default instead?  With your change, I think it may need 
to create StringRefs around all of the choices and then just get the string 
from them.


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

https://reviews.llvm.org/D139720

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


[PATCH] D138958: [clang] Better UX for Clang’s unwind-affecting attributes

2022-12-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Last(?) ping of the year?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138958

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


[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-12-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Last(?) ping of the year?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381

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


[PATCH] D139835: [include-cleaner] Include the reference type when printing the SymbolReference.

2022-12-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG6c0c280b8ddc: [include-cleaner] Include the reference type 
when printing the SymbolReference. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D139835?vs=482077&id=482092#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139835

Files:
  clang-tools-extra/include-cleaner/lib/Types.cpp


Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -46,7 +46,7 @@
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolReference &R) 
{
   // We can't decode the Location without SourceManager. Its raw representation
   // isn't completely useless (and distinguishes SymbolReference from Symbol).
-  return OS << R.Target << "@0x"
+  return OS << R.RT << " reference to " << R.Target << "@0x"
 << llvm::utohexstr(
R.RefLocation.getRawEncoding(), /*LowerCase=*/false,
/*Width=*/CHAR_BIT * sizeof(SourceLocation::UIntTy));


Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -46,7 +46,7 @@
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolReference &R) {
   // We can't decode the Location without SourceManager. Its raw representation
   // isn't completely useless (and distinguishes SymbolReference from Symbol).
-  return OS << R.Target << "@0x"
+  return OS << R.RT << " reference to " << R.Target << "@0x"
 << llvm::utohexstr(
R.RefLocation.getRawEncoding(), /*LowerCase=*/false,
/*Width=*/CHAR_BIT * sizeof(SourceLocation::UIntTy));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 6c0c280 - [include-cleaner] Include the reference type when printing the SymbolReference.

2022-12-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-12-12T14:52:31+01:00
New Revision: 6c0c280b8ddcede2b78afe948c764cb04503f980

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

LOG: [include-cleaner] Include the reference type when printing the 
SymbolReference.

This information is useful when printing the reference for debugging
purposes.

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

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/Types.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/Types.cpp 
b/clang-tools-extra/include-cleaner/lib/Types.cpp
index 68907917ea640..68311546f724c 100644
--- a/clang-tools-extra/include-cleaner/lib/Types.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -46,7 +46,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const 
Include &I) {
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolReference &R) 
{
   // We can't decode the Location without SourceManager. Its raw representation
   // isn't completely useless (and distinguishes SymbolReference from Symbol).
-  return OS << R.Target << "@0x"
+  return OS << R.RT << " reference to " << R.Target << "@0x"
 << llvm::utohexstr(
R.RefLocation.getRawEncoding(), /*LowerCase=*/false,
/*Width=*/CHAR_BIT * sizeof(SourceLocation::UIntTy));



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


[PATCH] D136100: [clang-format] Do not parse certain characters in pragma directives

2022-12-12 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Chromium is seeing a formatting regression after this: 
https://github.com/llvm/llvm-project/issues/59473


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136100

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


[clang-tools-extra] d3c3de6 - [clang-tidy][NFC] Simply match processing in misc-use-anonymous-namespace

2022-12-12 Thread Carlos Galvez via cfe-commits

Author: Carlos Galvez
Date: 2022-12-12T14:05:19Z
New Revision: d3c3de63ce8416ab2dee7f784e54b00a2aa8ed85

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

LOG: [clang-tidy][NFC] Simply match processing in misc-use-anonymous-namespace

No need for the templated function "processMatch", since
we can infer the type with llvm:isa.

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
index 878cba31eb2ab..fdf7828c8c0fd 100644
--- a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
@@ -31,33 +31,26 @@ AST_MATCHER(Decl, isInAnonymousNamespace) {
 }
 } // namespace
 
-template 
-void UseAnonymousNamespaceCheck::processMatch(const T *MatchedDecl) {
-  StringRef Type = llvm::isa(MatchedDecl) ? "variable" : "function";
-  diag(MatchedDecl->getLocation(),
-   "%0 %1 declared 'static', move to anonymous namespace instead")
-  << Type << MatchedDecl;
-}
-
 void UseAnonymousNamespaceCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   functionDecl(isStatic(),
unless(anyOf(isInAnonymousNamespace(), isMemberFunction(
-  .bind("func"),
+  .bind("x"),
   this);
   Finder->addMatcher(
   varDecl(isStatic(), unless(anyOf(isInAnonymousNamespace(),
isStaticLocal(), isStaticDataMember(
-  .bind("var"),
+  .bind("x"),
   this);
 }
 
 void UseAnonymousNamespaceCheck::check(const MatchFinder::MatchResult &Result) 
{
-  if (const auto *MatchedDecl = Result.Nodes.getNodeAs("func"))
-processMatch(MatchedDecl);
-
-  if (const auto *MatchedDecl = Result.Nodes.getNodeAs("var"))
-processMatch(MatchedDecl);
+  if (const auto *MatchedDecl = Result.Nodes.getNodeAs("x")) {
+StringRef Type = llvm::isa(MatchedDecl) ? "variable" : "function";
+diag(MatchedDecl->getLocation(),
+ "%0 %1 declared 'static', move to anonymous namespace instead")
+<< Type << MatchedDecl;
+  }
 }
 
 } // namespace misc

diff  --git a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h 
b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
index 59c48029711e0..19d76bfc19f63 100644
--- a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
@@ -29,9 +29,6 @@ class UseAnonymousNamespaceCheck : public ClangTidyCheck {
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-
-private:
-  template  void processMatch(const T *MatchedDecl);
 };
 
 } // namespace misc



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


[PATCH] D136100: [clang-format] Do not parse certain characters in pragma directives

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

In D136100#3988424 , @hans wrote:

> Chromium is seeing a formatting regression after this: 
> https://github.com/llvm/llvm-project/issues/59473

My guess is from this line, we could be more specific on the type of pragma.

  if (State.Line->InPragmaDirective)
return CurrentState.Indent + Style.ContinuationIndentWidth;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136100

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


[PATCH] D139786: [clang-format] AllowShortRequiresExpressionOnASingleLine

2022-12-12 Thread Zhikai Zeng via Phabricator via cfe-commits
Backl1ght added a comment.

I just find out I miss one case like below

  template
  concept c = requires(T x) { { x + 1 } -> std::same_as; };

Since I split AllowShortRequiresExpressionOnASingleLine and 
AllowShortCompoundRequirementOnASingleLine into two pathes, I can not fix this 
until AllowShortCompoundRequirementOnASingleLine got merged.


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

https://reviews.llvm.org/D139786

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


[clang-tools-extra] e864749 - [include-cleaner] Add a newline at end of the file, NFC

2022-12-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-12-12T15:29:27+01:00
New Revision: e864749d4dbe57fd4b0874a9ea189f87285ac473

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

LOG: [include-cleaner] Add a newline at end of the file, NFC

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp 
b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
index 321d692d7a8a8..b9e6e29a00667 100644
--- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -54,4 +54,4 @@ llvm::SmallVector findHeaders(const SymbolLocation 
&Loc,
   llvm_unreachable("unhandled SymbolLocation kind!");
 }
 
-} // namespace clang::include_cleaner
\ No newline at end of file
+} // namespace clang::include_cleaner

diff  --git a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
index d176efaf5497d..d1a21ab685346 100644
--- a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -154,4 +154,4 @@ TEST_F(FindHeadersTest, NonSelfContainedTraverseExporter) {
 }
 
 } // namespace
-} // namespace clang::include_cleaner
\ No newline at end of file
+} // namespace clang::include_cleaner



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


[PATCH] D139114: [Clang][Sema] Enabled Wshorten-64-to-32 for CompoundAssignment operator.

2022-12-12 Thread Fahad Nayyar via Phabricator via cfe-commits
fahadnayyar updated this revision to Diff 482102.
fahadnayyar added a comment.

Added forward declare for CheckImplicitConversion to make the diff look clean.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139114

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conversion-64-32.c


Index: clang/test/Sema/conversion-64-32.c
===
--- clang/test/Sema/conversion-64-32.c
+++ clang/test/Sema/conversion-64-32.c
@@ -17,3 +17,25 @@
 int test2(long v) {
   return v / 2; // expected-warning {{implicit conversion loses integer 
precision: 'long' to 'int'}}
 }
+
+// rdar://10466193
+void test3(int i, long long ll) {
+  i += ll; // expected-warning {{implicit conversion loses integer precision}}
+  i -= ll; // expected-warning {{implicit conversion loses integer precision}}
+  i *= ll; // expected-warning {{implicit conversion loses integer precision}}
+  i /= ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+void test4(int i, long long ll) {
+  i += i-ll; // expected-warning {{implicit conversion loses integer 
precision}}
+  i += i+ll; // expected-warning {{implicit conversion loses integer 
precision}}
+  i -= i-ll; // expected-warning {{implicit conversion loses integer 
precision}}
+  i -= i+ll; // expected-warning {{implicit conversion loses integer 
precision}}
+}
+
+void test5(int i, int j, long long ll) {
+  i += (i-j)*ll; // expected-warning {{implicit conversion loses integer 
precision}}
+  i += (i+j)*ll; // expected-warning {{implicit conversion loses integer 
precision}}
+  i -= ll/(i-j); // expected-warning {{implicit conversion loses integer 
precision}}
+  i -= ll/(i-j); // expected-warning {{implicit conversion loses integer 
precision}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13374,6 +13374,11 @@
   }
 }
 
+static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
+SourceLocation CC,
+bool *ICContext = nullptr,
+bool IsListInit = false);
+
 /// Analyze the given compound assignment for the possible losing of
 /// floating-point precision.
 static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) {
@@ -13392,8 +13397,16 @@
 ->getComputationResultType()
 ->getAs();
 
+  // Check for implicit conversion loss of precision form 64-to-32 for compound
+  // statements.
+  if (E->getLHS()->getType()->isIntegerType() &&
+  E->getRHS()->getType()->isIntegerType() && !E->isShiftAssignOp())
+CheckImplicitConversion(S, E->getRHS(), E->getType(),
+E->getRHS()->getExprLoc());
+
   // The below checks assume source is floating point.
-  if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
+  if (!ResultBT || !RBT || !RBT->isFloatingPoint())
+return;
 
   // If source is floating point but target is an integer.
   if (ResultBT->isInteger())
@@ -13682,9 +13695,8 @@
 }
 
 static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
-SourceLocation CC,
-bool *ICContext = nullptr,
-bool IsListInit = false) {
+SourceLocation CC, bool *ICContext,
+bool IsListInit) {
   if (E->isTypeDependent() || E->isValueDependent()) return;
 
   const Type *Source = S.Context.getCanonicalType(E->getType()).getTypePtr();


Index: clang/test/Sema/conversion-64-32.c
===
--- clang/test/Sema/conversion-64-32.c
+++ clang/test/Sema/conversion-64-32.c
@@ -17,3 +17,25 @@
 int test2(long v) {
   return v / 2; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
 }
+
+// rdar://10466193
+void test3(int i, long long ll) {
+  i += ll; // expected-warning {{implicit conversion loses integer precision}}
+  i -= ll; // expected-warning {{implicit conversion loses integer precision}}
+  i *= ll; // expected-warning {{implicit conversion loses integer precision}}
+  i /= ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+void test4(int i, long long ll) {
+  i += i-ll; // expected-warning {{implicit conversion loses integer precision}}
+  i += i+ll; // expected-warning {{implicit conversion loses integer precision}}
+  i -= i-ll; // expected-warning {{implicit conversion loses integer precision}}
+  i -= i+ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+void test5(int i, int j, long long ll) {
+  i += (i-j)*ll; // expected-warning {{implicit conversion loses integer precision}}
+  i

[PATCH] D139720: [clang][PPC] Checking Unknown Values Passed to -mcpu

2022-12-12 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:54
+auto TargetCPUName = llvm::StringSwitch(CPUName)
+ .Case("common", "generic")
+ .Case("440fp", "440")

jamieschmeiser wrote:
> This seems strange.  If the option is "generic", it calls 
> getPPCGenericTargetCPU(), but if it is "common", it returns "generic."  I 
> think you may want to also call getPPCGenericTargetCPU() here.  There should 
> probably also be an assume where this returns that it didn't return "generic" 
> if that is the intended result.  Also, there should also be tests for what 
> happens when "generic" and "common" are specified.
I agree this `generic` vs `common` behaviour is strange. They way this patch 
handles `generic` vs `common` keeps the existing behaviour. In short, before 
this patch, `clang` already treats `-mcpu=generic` and `-mcpu=common` 
differently. 

When `-mcpu=generic` is specified, we [[ 
https://github.com/llvm/llvm-project/blob/d3c3de63ce8416ab2dee7f784e54b00a2aa8ed85/clang/lib/Driver/ToolChains/CommonArgs.cpp#L420
 | do some processing depending ]] on the OS and architecture (effectively 
calling `getPPCGenericTargetCPU`). This happens because `generic` is not one of 
the cases of the big `StringSwitch`, and we return an empty string from 
`ppc::getPPCTargetCPU`.  

On the other hand, when `-mcpu=common` is specified, the `StringSwitch` maps 
`common` to `generic`, and we simply returns `generic` as the target CPU name 
[[ 
https://github.com/llvm/llvm-project/blob/d3c3de63ce8416ab2dee7f784e54b00a2aa8ed85/clang/lib/Driver/ToolChains/CommonArgs.cpp#L418
 | here ]]. 

**//Is this behaviour what we expect? //**If it is not, I will add a bug fix 
(with this patch or with a different patch if a separate one is easier to 
review). We only have an [[ 
https://github.com/llvm/llvm-project/blob/2c69e1d19a2b8bcf27ef1c5a4b5cc0410ed81a52/clang/test/Driver/ppc-cpus.c#L23
 |  existing test case ]] for `generic`, but not for `common`. I will add one 
with the bug fix. 



Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:77
+ .Default(CPUName);
+return TargetCPUName.str();
   }

jamieschmeiser wrote:
> Why did you change the type from const char *?  Couldn't you use 
> CPUName->data() in the default instead?  With your change, I think it may 
> need to create StringRefs around all of the choices and then just get the 
> string from them.
I was worried about the [[ 
https://github.com/llvm/llvm-project/blob/d3c3de63ce8416ab2dee7f784e54b00a2aa8ed85/llvm/include/llvm/ADT/StringRef.h#L129
 | comment ]] on top of `StringRef::data()` which says "Get a pointer to the 
start of the string (which may not be null terminated).". I was not sure what 
would happen if the data inside `CPUName` was not null terminated (it might be 
fine) so I thought it would be safer to use the `StringRef`s directly instead. 


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

https://reviews.llvm.org/D139720

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


[PATCH] D136594: [clangd] Add support for semantic token type "operator"

2022-12-12 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 482103.
ckandeler added a comment.

Renamed modifier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -113,9 +113,9 @@
   void $Function_def[[foo]](int $Parameter_def[[A]], $Class[[AS]] $Parameter_def[[As]]) {
 $Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[VeryLongVariableName]] = 12312;
 $Class[[AS]] $LocalVariable_def[[AA]];
-$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
+$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] $Operator[[+]] $Parameter[[A]];
 auto $LocalVariable_def[[FN]] = [ $LocalVariable[[AA]]](int $Parameter_def[[A]]) -> void {};
-$LocalVariable[[FN]](12312);
+$LocalVariable[[FN]]$Operator_userDefined[[(]]12312$Operator_userDefined[[)]];
   }
 )cpp",
   R"cpp(
@@ -144,7 +144,7 @@
   struct $Class_def[[B]] {
 $Class_decl_constrDestr[[B]]();
 ~$Class_decl_constrDestr[[B]]();
-void operator<<($Class[[B]]);
+void operator$Operator_decl[[<<]]($Class[[B]]);
 $Class[[AAA]] $Field_decl[[AA]];
   };
   $Class[[B]]::$Class_def_constrDestr[[B]]() {}
@@ -203,20 +203,20 @@
 static double $StaticField_decl_static[[S]];
 static void $StaticMethod_def_static[[bar]]() {}
 void $Method_def[[foo]]() {
-  $Field[[B]] = 123;
-  this->$Field[[B]] = 156;
+  $Field[[B]] $Operator[[=]] 123;
+  this->$Field[[B]] $Operator[[=]] 156;
   this->$Method[[foo]]();
   $Method[[foo]]();
   $StaticMethod_static[[bar]]();
-  $StaticField_static[[S]] = 90.1;
+  $StaticField_static[[S]] $Operator[[=]] 90.1;
 }
   };
   void $Function_def[[foo]]() {
 $Class[[A]] $LocalVariable_def[[AA]];
-$LocalVariable[[AA]].$Field[[B]] += 2;
+$LocalVariable[[AA]].$Field[[B]] $Operator[[+=]] 2;
 $LocalVariable[[AA]].$Method[[foo]]();
 $LocalVariable[[AA]].$Field[[E]].$Field[[C]];
-$Class[[A]]::$StaticField_static[[S]] = 90;
+$Class[[A]]::$StaticField_static[[S]] $Operator[[=]] 90;
   }
 )cpp",
   R"cpp(
@@ -295,10 +295,10 @@
   struct $Class_def[[B]] {};
   struct $Class_def[[A]] {
 $Class[[B]] $Field_decl[[BB]];
-$Class[[A]] &operator=($Class[[A]] &&$Parameter_def[[O]]);
+$Class[[A]] &operator$Operator_decl[[=]]($Class[[A]] &&$Parameter_def[[O]]);
   };
 
-  $Class[[A]] &$Class[[A]]::operator=($Class[[A]] &&$Parameter_def[[O]]) = default;
+  $Class[[A]] &$Class[[A]]::operator$Operator_def[[=]]($Class[[A]] &&$Parameter_def[[O]]) = default;
 )cpp",
   R"cpp(
   enum $Enum_decl[[En]] {
@@ -327,9 +327,9 @@
   $Enum_deduced[[auto]] $Variable_def[[AE]] = $Enum[[E]]::$EnumConstant_readonly[[E]];
   $Class_deduced[[auto]] $Variable_def[[AF]] = $Class[[Foo]]();
   $Class_deduced[[decltype]](auto) $Variable_def[[AF2]] = $Class[[Foo]]();
-  $Class_deduced[[auto]] *$Variable_def[[AFP]] = &$Variable[[AF]];
+  $Class_deduced[[auto]] *$Variable_def[[AFP]] = $Operator[[&]]$Variable[[AF]];
   $Enum_deduced[[auto]] &$Variable_def[[AER]] = $Variable[[AE]];
-  $Primitive_deduced_defaultLibrary[[auto]] $Variable_def[[Form]] = 10.2 + 2 * 4;
+  $Primitive_deduced_defaultLibrary[[auto]] $Variable_def[[Form]] = 10.2 $Operator[[+]] 2 $Operator[[*]] 4;
   $Primitive_deduced_defaultLibrary[[decltype]]($Variable[[Form]]) $Variable_def[[F]] = 10;
   auto $Variable_def[[Fun]] = []()->void{};
 )cpp",
@@ -342,21 +342,21 @@
   template
   class $Class_def[[IP]] {
 void $Method_def[[f]]() {
-  *$TemplateParameter_readonly[[U]] += 5;
+  $Operator[[*]]$TemplateParameter_readonly[[U]] $Operator[[+=]] 5;
 }
   };
   template
   class $Class_def[[Foo]] {
 void $Method_def[[f]]() {
   for(int $LocalVariable_def[[I]] = 0;
-$LocalVariable[[I]] < $TemplateParameter_readonly[[U]];) {}
+$LocalVariable[[I]] $Operator[[<]] $TemplateParameter_readonly[[U]];) {}
 }
   };
 
   $Class[[G]] $Variable_def[[L]];
   void $Function_def[[f]]() {
 

[PATCH] D139113: [clang-tidy] Fix a couple additional cases in misc-use-anonymous-namespace

2022-12-12 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp:46-48
+// OK
+static const int v8{123};
+static constexpr int v9{123};

vingeldal wrote:
> Is it really the best behavior to allow these? If I got the rationale right 
> we don't warn about this because const and constexpr have implicit internal 
> linkage anyway, so static doesn't make a difference, right?
> Reading the documentation for this check I gather static would probably have 
> been deprecated if it wasn't for the fact that deprecation would have broken 
> compatibility with C. So, if we drop the static keyword here we still get the 
> behavior we want, without a confusing keyword we would rather get rid of if 
> we could, while keeping compatibility with C.
> 
> I'm thinking it could be better to just discourage from using static for 
> cases like this.
Thanks for the review!

Yes, that example is "bad" code, but this particular check would currently ask 
users to move the variables to the anonymous namespace - which is also 
incorrect.

My plan is to add one more separate checks in the "readability" section that 
warn about redundant usages of 'static' (like this one), and even supports 
automatic fixes (which aren't possible in this check).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139113

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


[PATCH] D136100: [clang-format] Do not parse certain characters in pragma directives

2022-12-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D136100#3988424 , @hans wrote:

> Chromium is seeing a formatting regression after this: 
> https://github.com/llvm/llvm-project/issues/59473

Can we get more specific about what Chromium is seeing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136100

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


[PATCH] D139801: [clang-format] Adds 'friend' to QualifierOrder.

2022-12-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I guess in principle this looks ok, but lets see what the others think @owenpan 
, @HazardyKnusperkeks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139801

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


[clang-tools-extra] dabda23 - [clang-tidy][NFC] Fix compiler warning in GlobListTest.cpp

2022-12-12 Thread Carlos Galvez via cfe-commits

Author: Carlos Galvez
Date: 2022-12-12T14:49:09Z
New Revision: dabda23f1991f7c4e5a840ee6cf1290e18fa2e88

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

LOG: [clang-tidy][NFC] Fix compiler warning in GlobListTest.cpp

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp

Removed: 




diff  --git a/clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
index 833ba78351d4c..1e2780db0e742 100644
--- a/clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
@@ -7,7 +7,7 @@ namespace tidy {
 template  struct GlobListTest : public ::testing::Test {};
 
 using GlobListTypes = ::testing::Types;
-TYPED_TEST_SUITE(GlobListTest, GlobListTypes);
+TYPED_TEST_SUITE(GlobListTest, GlobListTypes, );
 
 TYPED_TEST(GlobListTest, Empty) {
   TypeParam Filter("");



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


[PATCH] D138373: [clang-format] Don't eat two semicolons after namespace

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

Feels like this would only show if someone did

  namespace A {
  };;

Which seems odd


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138373

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


[PATCH] D139444: [ZOS] Convert tests to check 'target={{.*}}-zos'

2022-12-12 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I suppose we could temporarily add a test that does

  ; REQUIRES: target={{.*}}-zos
  ; RUN: %python -c 'import platform; print(platform.system())' && false

and see what gets printed.

Searching the buildbot console page for 'zos' turns up nothing; 's390' turns up 
clang-s390x-linux, clang-s390x-linux-lnt, mlir-s390x-linux.  Are there any zos 
hosted bots?  I.e., is this test ever actually run?  Maybe there are only 
downstream zos bots, in which case this should be a downstream test instead?


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

https://reviews.llvm.org/D139444

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


[PATCH] D138373: [clang-format] Don't eat two semicolons after namespace

2022-12-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2999
 
-// Munch the semicolon after a namespace. This is more common than one 
would
-// think. Putting the semicolon into its own line is very ugly.

This comment was wrong I guess,  because of /*MunchSemi=*/true


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138373

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


[PATCH] D137649: [Clang][OpenMP] Warn and discard write to host for const variable

2022-12-12 Thread Jan-Patrick Lehr via Phabricator via cfe-commits
jplehr planned changes to this revision.
jplehr added a comment.

We had another clarifying example on the github issue, which currently is not 
correctly covered by this patch. I'm currently reworking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137649

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


[PATCH] D136554: Implement CWG2631

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

@aeubanks I just completed a compilation of all of chrome including tests. let 
me know if you want to run more tests on your side and thanks again for 
reporting these issues. I think we are getting there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[clang] 822c274 - [clang-cl] Ignore #pragma managed/unmanaged

2022-12-12 Thread Sylvain Audi via cfe-commits

Author: Sylvain Audi
Date: 2022-12-12T10:01:24-05:00
New Revision: 822c274477ea2f194b4e3f2a38fdb3d3ba8ea611

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

LOG: [clang-cl] Ignore #pragma managed/unmanaged

Those 2 pragmas are ignored by MSVC when not compiling with /CLR, which clang 
doesn't support.
Ignore them in clang -fms-extensions, to avoid -Wunknown-pragma warnings

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

Added: 


Modified: 
clang/lib/Lex/Pragma.cpp
clang/test/Preprocessor/pragma_microsoft.c

Removed: 




diff  --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index 747447e3ab39a..01e0dbe05ac96 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -1957,6 +1957,15 @@ struct PragmaRegionHandler : public PragmaHandler {
   }
 };
 
+/// "\#pragma managed"
+/// "\#pragma managed(...)"
+/// "\#pragma unmanaged"
+/// MSVC ignores this pragma when not compiling using /clr, which clang doesn't
+/// support. We parse it and ignore it to avoid -Wunknown-pragma warnings.
+struct PragmaManagedHandler : public EmptyPragmaHandler {
+  PragmaManagedHandler(const char *pragma) : EmptyPragmaHandler(pragma) {}
+};
+
 /// This handles parsing pragmas that take a macro name and optional message
 static IdentifierInfo *HandleMacroAnnotationPragma(Preprocessor &PP, Token 
&Tok,
const char *Pragma,
@@ -2129,6 +2138,8 @@ void Preprocessor::RegisterBuiltinPragmas() {
 AddPragmaHandler(new PragmaIncludeAliasHandler());
 AddPragmaHandler(new PragmaHdrstopHandler());
 AddPragmaHandler(new PragmaSystemHeaderHandler());
+AddPragmaHandler(new PragmaManagedHandler("managed"));
+AddPragmaHandler(new PragmaManagedHandler("unmanaged"));
   }
 
   // Pragmas added by plugins

diff  --git a/clang/test/Preprocessor/pragma_microsoft.c 
b/clang/test/Preprocessor/pragma_microsoft.c
index aae6e284cb4dc..afbe0ebc8f19d 100644
--- a/clang/test/Preprocessor/pragma_microsoft.c
+++ b/clang/test/Preprocessor/pragma_microsoft.c
@@ -235,6 +235,12 @@ void pragma_optimize_foo() {
 #pragma optimize("", on) // expected-error {{'#pragma optimize' can only 
appear at file scope}}
 }
 
+#pragma managed// no-warning
+#pragma unmanaged  // no-warning
+#pragma managed(push, on)  // no-warning
+#pragma managed(pop)   // no-warning
+#pragma managed2   // expected-warning{{unknown pragma ignored}}
+
 #pragma execution_character_set // expected-warning {{expected 
'('}}
 #pragma execution_character_set(// expected-warning {{expected 
'push' or 'pop'}}
 #pragma execution_character_set()   // expected-warning {{expected 
'push' or 'pop'}}



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


[PATCH] D139632: [clang-cl] Ignore #pragma managed / #pragma unmanaged

2022-12-12 Thread Sylvain Audi 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 rG822c274477ea: [clang-cl] Ignore #pragma managed/unmanaged 
(authored by saudi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139632

Files:
  clang/lib/Lex/Pragma.cpp
  clang/test/Preprocessor/pragma_microsoft.c


Index: clang/test/Preprocessor/pragma_microsoft.c
===
--- clang/test/Preprocessor/pragma_microsoft.c
+++ clang/test/Preprocessor/pragma_microsoft.c
@@ -235,6 +235,12 @@
 #pragma optimize("", on) // expected-error {{'#pragma optimize' can only 
appear at file scope}}
 }
 
+#pragma managed// no-warning
+#pragma unmanaged  // no-warning
+#pragma managed(push, on)  // no-warning
+#pragma managed(pop)   // no-warning
+#pragma managed2   // expected-warning{{unknown pragma ignored}}
+
 #pragma execution_character_set // expected-warning {{expected 
'('}}
 #pragma execution_character_set(// expected-warning {{expected 
'push' or 'pop'}}
 #pragma execution_character_set()   // expected-warning {{expected 
'push' or 'pop'}}
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1957,6 +1957,15 @@
   }
 };
 
+/// "\#pragma managed"
+/// "\#pragma managed(...)"
+/// "\#pragma unmanaged"
+/// MSVC ignores this pragma when not compiling using /clr, which clang doesn't
+/// support. We parse it and ignore it to avoid -Wunknown-pragma warnings.
+struct PragmaManagedHandler : public EmptyPragmaHandler {
+  PragmaManagedHandler(const char *pragma) : EmptyPragmaHandler(pragma) {}
+};
+
 /// This handles parsing pragmas that take a macro name and optional message
 static IdentifierInfo *HandleMacroAnnotationPragma(Preprocessor &PP, Token 
&Tok,
const char *Pragma,
@@ -2129,6 +2138,8 @@
 AddPragmaHandler(new PragmaIncludeAliasHandler());
 AddPragmaHandler(new PragmaHdrstopHandler());
 AddPragmaHandler(new PragmaSystemHeaderHandler());
+AddPragmaHandler(new PragmaManagedHandler("managed"));
+AddPragmaHandler(new PragmaManagedHandler("unmanaged"));
   }
 
   // Pragmas added by plugins


Index: clang/test/Preprocessor/pragma_microsoft.c
===
--- clang/test/Preprocessor/pragma_microsoft.c
+++ clang/test/Preprocessor/pragma_microsoft.c
@@ -235,6 +235,12 @@
 #pragma optimize("", on) // expected-error {{'#pragma optimize' can only appear at file scope}}
 }
 
+#pragma managed// no-warning
+#pragma unmanaged  // no-warning
+#pragma managed(push, on)  // no-warning
+#pragma managed(pop)   // no-warning
+#pragma managed2   // expected-warning{{unknown pragma ignored}}
+
 #pragma execution_character_set // expected-warning {{expected '('}}
 #pragma execution_character_set(// expected-warning {{expected 'push' or 'pop'}}
 #pragma execution_character_set()   // expected-warning {{expected 'push' or 'pop'}}
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1957,6 +1957,15 @@
   }
 };
 
+/// "\#pragma managed"
+/// "\#pragma managed(...)"
+/// "\#pragma unmanaged"
+/// MSVC ignores this pragma when not compiling using /clr, which clang doesn't
+/// support. We parse it and ignore it to avoid -Wunknown-pragma warnings.
+struct PragmaManagedHandler : public EmptyPragmaHandler {
+  PragmaManagedHandler(const char *pragma) : EmptyPragmaHandler(pragma) {}
+};
+
 /// This handles parsing pragmas that take a macro name and optional message
 static IdentifierInfo *HandleMacroAnnotationPragma(Preprocessor &PP, Token &Tok,
const char *Pragma,
@@ -2129,6 +2138,8 @@
 AddPragmaHandler(new PragmaIncludeAliasHandler());
 AddPragmaHandler(new PragmaHdrstopHandler());
 AddPragmaHandler(new PragmaSystemHeaderHandler());
+AddPragmaHandler(new PragmaManagedHandler("managed"));
+AddPragmaHandler(new PragmaManagedHandler("unmanaged"));
   }
 
   // Pragmas added by plugins
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136100: [clang-format] Do not parse certain characters in pragma directives

2022-12-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> Can we get more specific about what Chromium is seeing?

https://github.com/llvm/llvm-project/issues/59473 has a standalone repro. What 
else would you like to see?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136100

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


[clang] 58c9467 - Use std::optional in Tooling/Inclusions.

2022-12-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-12-12T16:01:56+01:00
New Revision: 58c9467f58a3ec77bae4675becfa7f3bc8470230

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

LOG: Use std::optional in Tooling/Inclusions.

Added: 


Modified: 
clang/include/clang/Tooling/Inclusions/HeaderAnalysis.h
clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
clang/unittests/Tooling/HeaderAnalysisTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Inclusions/HeaderAnalysis.h 
b/clang/include/clang/Tooling/Inclusions/HeaderAnalysis.h
index 31854ff6f59da..760b8dd0879c9 100644
--- a/clang/include/clang/Tooling/Inclusions/HeaderAnalysis.h
+++ b/clang/include/clang/Tooling/Inclusions/HeaderAnalysis.h
@@ -9,8 +9,9 @@
 #ifndef LLVM_CLANG_TOOLING_INCLUSIONS_HEADER_ANALYSIS_H
 #define LLVM_CLANG_TOOLING_INCLUSIONS_HEADER_ANALYSIS_H
 
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
+#include 
+
 namespace clang {
 class FileEntry;
 class SourceManager;
@@ -37,7 +38,7 @@ bool codeContainsImports(llvm::StringRef Code);
 /// Input is a null-terminated char* as provided by SM.getCharacterData().
 /// (This should not be StringRef as we do *not* want to scan for its length).
 /// For multi-line comments, we return only the first line.
-llvm::Optional parseIWYUPragma(const char *Text);
+std::optional parseIWYUPragma(const char *Text);
 
 } // namespace tooling
 } // namespace clang

diff  --git a/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp 
b/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
index f2a15c2a568cf..49d23908d33b7 100644
--- a/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
@@ -93,7 +93,7 @@ bool codeContainsImports(llvm::StringRef Code) {
   return false;
 }
 
-llvm::Optional parseIWYUPragma(const char *Text) {
+std::optional parseIWYUPragma(const char *Text) {
   // Skip the comment start, // or /*.
   if (Text[0] != '/' || (Text[1] != '/' && Text[1] != '*'))
 return std::nullopt;

diff  --git a/clang/unittests/Tooling/HeaderAnalysisTest.cpp 
b/clang/unittests/Tooling/HeaderAnalysisTest.cpp
index 186eb87b062d2..623957c3ba237 100644
--- a/clang/unittests/Tooling/HeaderAnalysisTest.cpp
+++ b/clang/unittests/Tooling/HeaderAnalysisTest.cpp
@@ -9,13 +9,12 @@
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Testing/TestAST.h"
-#include "llvm/Testing/Support/SupportHelpers.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace tooling {
 namespace {
-using llvm::ValueIs;
 using testing::Eq;
 
 TEST(HeaderAnalysisTest, IsSelfContained) {
@@ -93,10 +92,10 @@ TEST(HeaderAnalysisTest, CodeContainsImports) {
 }
 
 TEST(HeaderAnalysisTest, ParseIWYUPragma) {
-  EXPECT_THAT(parseIWYUPragma("// IWYU pragma: keep"), ValueIs(Eq("keep")));
+  EXPECT_THAT(parseIWYUPragma("// IWYU pragma: keep"), Eq("keep"));
   EXPECT_THAT(parseIWYUPragma("// IWYU pragma:   keep  me\netc"),
-  ValueIs(Eq("keep  me")));
-  EXPECT_THAT(parseIWYUPragma("/* IWYU pragma: keep */"), ValueIs(Eq("keep")));
+  Eq("keep  me"));
+  EXPECT_THAT(parseIWYUPragma("/* IWYU pragma: keep */"), Eq("keep"));
   EXPECT_EQ(parseIWYUPragma("//  IWYU pragma: keep"), std::nullopt)
   << "Prefix is sensitive to whitespace";
   EXPECT_EQ(parseIWYUPragma("// IWYU pragma:keep"), std::nullopt)



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


[PATCH] D139822: Allow using BareMetal toolchain with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR compiler-rt

2022-12-12 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs 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/D139822/new/

https://reviews.llvm.org/D139822

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


[PATCH] D139720: [clang][PPC] Checking Unknown Values Passed to -mcpu

2022-12-12 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a subscriber: hubert.reinterpretcast.
jamieschmeiser added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:54
+auto TargetCPUName = llvm::StringSwitch(CPUName)
+ .Case("common", "generic")
+ .Case("440fp", "440")

qiongsiwu1 wrote:
> jamieschmeiser wrote:
> > This seems strange.  If the option is "generic", it calls 
> > getPPCGenericTargetCPU(), but if it is "common", it returns "generic."  I 
> > think you may want to also call getPPCGenericTargetCPU() here.  There 
> > should probably also be an assume where this returns that it didn't return 
> > "generic" if that is the intended result.  Also, there should also be tests 
> > for what happens when "generic" and "common" are specified.
> I agree this `generic` vs `common` behaviour is strange. They way this patch 
> handles `generic` vs `common` keeps the existing behaviour. In short, before 
> this patch, `clang` already treats `-mcpu=generic` and `-mcpu=common` 
> differently. 
> 
> When `-mcpu=generic` is specified, we [[ 
> https://github.com/llvm/llvm-project/blob/d3c3de63ce8416ab2dee7f784e54b00a2aa8ed85/clang/lib/Driver/ToolChains/CommonArgs.cpp#L420
>  | do some processing depending ]] on the OS and architecture (effectively 
> calling `getPPCGenericTargetCPU`). This happens because `generic` is not one 
> of the cases of the big `StringSwitch`, and we return an empty string from 
> `ppc::getPPCTargetCPU`.  
> 
> On the other hand, when `-mcpu=common` is specified, the `StringSwitch` maps 
> `common` to `generic`, and we simply returns `generic` as the target CPU name 
> [[ 
> https://github.com/llvm/llvm-project/blob/d3c3de63ce8416ab2dee7f784e54b00a2aa8ed85/clang/lib/Driver/ToolChains/CommonArgs.cpp#L418
>  | here ]]. 
> 
> **//Is this behaviour what we expect? //**If it is not, I will add a bug fix 
> (with this patch or with a different patch if a separate one is easier to 
> review). We only have an [[ 
> https://github.com/llvm/llvm-project/blob/2c69e1d19a2b8bcf27ef1c5a4b5cc0410ed81a52/clang/test/Driver/ppc-cpus.c#L23
>  |  existing test case ]] for `generic`, but not for `common`. I will add one 
> with the bug fix. 
Yeah, I saw that you weren't changing the behaviour; I just suspect that it was 
an existing bug...Not sure who to check with about that @nemanjai? 
@hubert.reinterpretcast?



Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:77
+ .Default(CPUName);
+return TargetCPUName.str();
   }

qiongsiwu1 wrote:
> jamieschmeiser wrote:
> > Why did you change the type from const char *?  Couldn't you use 
> > CPUName->data() in the default instead?  With your change, I think it may 
> > need to create StringRefs around all of the choices and then just get the 
> > string from them.
> I was worried about the [[ 
> https://github.com/llvm/llvm-project/blob/d3c3de63ce8416ab2dee7f784e54b00a2aa8ed85/llvm/include/llvm/ADT/StringRef.h#L129
>  | comment ]] on top of `StringRef::data()` which says "Get a pointer to the 
> start of the string (which may not be null terminated).". I was not sure what 
> would happen if the data inside `CPUName` was not null terminated (it might 
> be fine) so I thought it would be safer to use the `StringRef`s directly 
> instead. 
Probably the same sort of thing that would happen with creating a StringRef 
since that calls strlen to set the size of the string it is wrapping :-)


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

https://reviews.llvm.org/D139720

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


[clang-tools-extra] 647d314 - [clangd] Add support for semantic token type "operator"

2022-12-12 Thread Christian Kandeler via cfe-commits

Author: Christian Kandeler
Date: 2022-12-12T16:17:43+01:00
New Revision: 647d314eb059b6d2e7c00d7eefe6a7afc37dff25

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

LOG: [clangd] Add support for semantic token type "operator"

Also add new modifier for differentiating between built-in and user-
provided operators.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/test/semantic-tokens.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index ccdaab89620b2..6745e2594ead3 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -566,6 +566,71 @@ class CollectExtraHighlightings
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *D) {
+if (D->isOverloadedOperator()) {
+  const auto addOpDeclToken = [&](SourceLocation Loc) {
+auto &Token = H.addToken(Loc, HighlightingKind::Operator)
+  .addModifier(HighlightingModifier::Declaration);
+if (D->isThisDeclarationADefinition())
+  Token.addModifier(HighlightingModifier::Definition);
+  };
+  const auto Range = D->getNameInfo().getCXXOperatorNameRange();
+  addOpDeclToken(Range.getBegin());
+  const auto Kind = D->getOverloadedOperator();
+  if (Kind == OO_Call || Kind == OO_Subscript)
+addOpDeclToken(Range.getEnd());
+}
+return true;
+  }
+
+  bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
+const auto addOpToken = [&](SourceLocation Loc) {
+  H.addToken(Loc, HighlightingKind::Operator)
+  .addModifier(HighlightingModifier::UserDefined);
+};
+addOpToken(E->getOperatorLoc());
+const auto Kind = E->getOperator();
+if (Kind == OO_Call || Kind == OO_Subscript) {
+  if (auto *Callee = E->getCallee())
+addOpToken(Callee->getBeginLoc());
+}
+return true;
+  }
+
+  bool VisitUnaryOperator(UnaryOperator *Op) {
+auto &Token = H.addToken(Op->getOperatorLoc(), HighlightingKind::Operator);
+if (Op->getSubExpr()->isTypeDependent())
+  Token.addModifier(HighlightingModifier::UserDefined);
+return true;
+  }
+
+  bool VisitBinaryOperator(BinaryOperator *Op) {
+auto &Token = H.addToken(Op->getOperatorLoc(), HighlightingKind::Operator);
+if (Op->getLHS()->isTypeDependent() || Op->getRHS()->isTypeDependent())
+  Token.addModifier(HighlightingModifier::UserDefined);
+return true;
+  }
+
+  bool VisitConditionalOperator(ConditionalOperator *Op) {
+H.addToken(Op->getQuestionLoc(), HighlightingKind::Operator);
+H.addToken(Op->getColonLoc(), HighlightingKind::Operator);
+return true;
+  }
+
+  bool VisitCXXNewExpr(CXXNewExpr *E) {
+auto &Token = H.addToken(E->getBeginLoc(), HighlightingKind::Operator);
+if (isa(E->getOperatorNew()))
+  Token.addModifier(HighlightingModifier::UserDefined);
+return true;
+  }
+
+  bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
+auto &Token = H.addToken(E->getBeginLoc(), HighlightingKind::Operator);
+if (isa(E->getOperatorDelete()))
+  Token.addModifier(HighlightingModifier::UserDefined);
+return true;
+  }
+
   bool VisitCallExpr(CallExpr *E) {
 // Highlighting parameters passed by non-const reference does not really
 // make sense for literals...
@@ -671,12 +736,20 @@ class CollectExtraHighlightings
   bool VisitCXXMemberCallExpr(CXXMemberCallExpr *CE) {
 // getMethodDecl can return nullptr with member pointers, e.g.
 // `(foo.*pointer_to_member_fun)(arg);`
-if (isa_and_present(CE->getMethodDecl())) {
-  if (auto *ME = dyn_cast(CE->getCallee())) {
-if (auto *TI = ME->getMemberNameInfo().getNamedTypeInfo()) {
-  H.addExtraModifier(TI->getTypeLoc().getBeginLoc(),
- HighlightingModifier::ConstructorOrDestructor);
+if (auto *D = CE->getMethodDecl()) {
+  if (isa(D)) {
+if (auto *ME = dyn_cast(CE->getCallee())) {
+  if (auto *TI = ME->getMemberNameInfo().getNamedTypeInfo()) {
+H.addExtraModifier(TI->getTypeLoc().getBeginLoc(),
+   HighlightingModifier::ConstructorOrDestructor);
+  }
 }
+  } else if (D->isOverloadedOperator()) {
+if (auto *ME = dyn_cast(CE->getCallee()))
+  H.addToken(
+   ME->getMemberNameInfo().getCXXOperatorNameRange().getBegin(),
+   Highlight

[PATCH] D136594: [clangd] Add support for semantic token type "operator"

2022-12-12 Thread Christian Kandeler via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG647d314eb059: [clangd] Add support for semantic token type 
"operator" (authored by ckandeler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -113,9 +113,9 @@
   void $Function_def[[foo]](int $Parameter_def[[A]], $Class[[AS]] $Parameter_def[[As]]) {
 $Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[VeryLongVariableName]] = 12312;
 $Class[[AS]] $LocalVariable_def[[AA]];
-$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
+$Primitive_deduced_defaultLibrary[[auto]] $LocalVariable_def[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] $Operator[[+]] $Parameter[[A]];
 auto $LocalVariable_def[[FN]] = [ $LocalVariable[[AA]]](int $Parameter_def[[A]]) -> void {};
-$LocalVariable[[FN]](12312);
+$LocalVariable[[FN]]$Operator_userDefined[[(]]12312$Operator_userDefined[[)]];
   }
 )cpp",
   R"cpp(
@@ -144,7 +144,7 @@
   struct $Class_def[[B]] {
 $Class_decl_constrDestr[[B]]();
 ~$Class_decl_constrDestr[[B]]();
-void operator<<($Class[[B]]);
+void operator$Operator_decl[[<<]]($Class[[B]]);
 $Class[[AAA]] $Field_decl[[AA]];
   };
   $Class[[B]]::$Class_def_constrDestr[[B]]() {}
@@ -203,20 +203,20 @@
 static double $StaticField_decl_static[[S]];
 static void $StaticMethod_def_static[[bar]]() {}
 void $Method_def[[foo]]() {
-  $Field[[B]] = 123;
-  this->$Field[[B]] = 156;
+  $Field[[B]] $Operator[[=]] 123;
+  this->$Field[[B]] $Operator[[=]] 156;
   this->$Method[[foo]]();
   $Method[[foo]]();
   $StaticMethod_static[[bar]]();
-  $StaticField_static[[S]] = 90.1;
+  $StaticField_static[[S]] $Operator[[=]] 90.1;
 }
   };
   void $Function_def[[foo]]() {
 $Class[[A]] $LocalVariable_def[[AA]];
-$LocalVariable[[AA]].$Field[[B]] += 2;
+$LocalVariable[[AA]].$Field[[B]] $Operator[[+=]] 2;
 $LocalVariable[[AA]].$Method[[foo]]();
 $LocalVariable[[AA]].$Field[[E]].$Field[[C]];
-$Class[[A]]::$StaticField_static[[S]] = 90;
+$Class[[A]]::$StaticField_static[[S]] $Operator[[=]] 90;
   }
 )cpp",
   R"cpp(
@@ -295,10 +295,10 @@
   struct $Class_def[[B]] {};
   struct $Class_def[[A]] {
 $Class[[B]] $Field_decl[[BB]];
-$Class[[A]] &operator=($Class[[A]] &&$Parameter_def[[O]]);
+$Class[[A]] &operator$Operator_decl[[=]]($Class[[A]] &&$Parameter_def[[O]]);
   };
 
-  $Class[[A]] &$Class[[A]]::operator=($Class[[A]] &&$Parameter_def[[O]]) = default;
+  $Class[[A]] &$Class[[A]]::operator$Operator_def[[=]]($Class[[A]] &&$Parameter_def[[O]]) = default;
 )cpp",
   R"cpp(
   enum $Enum_decl[[En]] {
@@ -327,9 +327,9 @@
   $Enum_deduced[[auto]] $Variable_def[[AE]] = $Enum[[E]]::$EnumConstant_readonly[[E]];
   $Class_deduced[[auto]] $Variable_def[[AF]] = $Class[[Foo]]();
   $Class_deduced[[decltype]](auto) $Variable_def[[AF2]] = $Class[[Foo]]();
-  $Class_deduced[[auto]] *$Variable_def[[AFP]] = &$Variable[[AF]];
+  $Class_deduced[[auto]] *$Variable_def[[AFP]] = $Operator[[&]]$Variable[[AF]];
   $Enum_deduced[[auto]] &$Variable_def[[AER]] = $Variable[[AE]];
-  $Primitive_deduced_defaultLibrary[[auto]] $Variable_def[[Form]] = 10.2 + 2 * 4;
+  $Primitive_deduced_defaultLibrary[[auto]] $Variable_def[[Form]] = 10.2 $Operator[[+]] 2 $Operator[[*]] 4;
   $Primitive_deduced_defaultLibrary[[decltype]]($Variable[[Form]]) $Variable_def[[F]] = 10;
   auto $Variable_def[[Fun]] = []()->void{};
 )cpp",
@@ -342,21 +342,21 @@
   template
   class $Class_def[[IP]] {
 void $Method_def[[f]]() {
-  *$TemplateParameter_readonly[[U]] += 5;
+  $Operator[[*]]$TemplateParameter_readonly[[U]] $Operator[[+=]] 5;
 }
   };
   template
   class $Class_def[[Foo]] {
 void $Method_def[[f]]() {
   for(int $LocalVariable_def[[I]] = 0;
-$LocalVariable[[I]] < $TemplateParameter_readonly[[U]];) {}
+$LocalVariable[[I]] $Operator[[<]] $TemplateParameter_readonly[[U]];) {}

[clang] 8cdb1aa - [Clang] Convert PCH tests to opaque pointers (NFC)

2022-12-12 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-12-12T16:20:49+01:00
New Revision: 8cdb1aa1ec2ba15f5ec8641f5ece23758bf15a06

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

LOG: [Clang] Convert PCH tests to opaque pointers (NFC)

Added: 


Modified: 
clang/test/PCH/block-helpers.cpp
clang/test/PCH/builtin-is-constant-evaluated.cpp
clang/test/PCH/chain-openmp-threadprivate.cpp
clang/test/PCH/chain-pending-instantiations.cpp
clang/test/PCH/dllexport-default-arg-closure.cpp
clang/test/PCH/pr27445.cpp
clang/test/PCH/pragma-weak-functional.c

Removed: 




diff  --git a/clang/test/PCH/block-helpers.cpp 
b/clang/test/PCH/block-helpers.cpp
index 33bd5fad5aa0b..b66abf71b73e5 100644
--- a/clang/test/PCH/block-helpers.cpp
+++ b/clang/test/PCH/block-helpers.cpp
@@ -1,23 +1,20 @@
-// RUN: %clang_cc1 -no-opaque-pointers -x c++-header -triple 
x86_64-apple-darwin11 -emit-pch -fblocks -fexceptions -o %t %S/block-helpers.h
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin11 
-include-pch %t -emit-llvm -fblocks -fexceptions -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++-header -triple x86_64-apple-darwin11 -emit-pch 
-fblocks -fexceptions -o %t %S/block-helpers.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -include-pch %t -emit-llvm 
-fblocks -fexceptions -o - %s | FileCheck %s
 
-// CHECK: %[[STRUCT_BLOCK_BYREF_X:.*]] = type { i8*, 
%[[STRUCT_BLOCK_BYREF_X]]*, i32, i32, i8*, i8*, %[[STRUCT_S0:.*]] }
+// CHECK: %[[STRUCT_BLOCK_BYREF_X:.*]] = type { ptr, ptr, i32, i32, ptr, ptr, 
%[[STRUCT_S0:.*]] }
 // CHECK: %[[STRUCT_S0]] = type { i32 }
-// CHECK: %[[STRUCT_BLOCK_BYREF_Y:.*]] = type { i8*, 
%[[STRUCT_BLOCK_BYREF_Y]]*, i32, i32, i8*, i8*, %[[STRUCT_S0]] }
-// CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
+// CHECK: %[[STRUCT_BLOCK_BYREF_Y:.*]] = type { ptr, ptr, i32, i32, ptr, ptr, 
%[[STRUCT_S0]] }
 
 // Check that byref structs are allocated for x and y.
 
 // CHECK-LABEL: define linkonce_odr void @_ZN1S1mEv(
 // CHECK: %[[X:.*]] = alloca %[[STRUCT_BLOCK_BYREF_X]], align 8
 // CHECK: %[[Y:.*]] = alloca %[[STRUCT_BLOCK_BYREF_Y]], align 8
-// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, 
%[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8* }>, align 8
-// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8* }>, <{ i8*, i32, i32, i8*, 
%[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8* }>* %[[BLOCK]], i32 0, i32 5
-// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_BLOCK_BYREF_X]]* %[[X]] to i8*
-// CHECK: store i8* %[[V0]], i8** %[[BLOCK_CAPTURED]], align 8
-// CHECK: %[[BLOCK_CAPTURED10:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8* }>, <{ i8*, i32, i32, i8*, 
%[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8* }>* %[[BLOCK]], i32 0, i32 6
-// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_BLOCK_BYREF_Y]]* %[[Y]] to i8*
-// CHECK: store i8* %[[V1]], i8** %[[BLOCK_CAPTURED10]], align 8
+// CHECK: %[[BLOCK:.*]] = alloca <{ ptr, i32, i32, ptr, ptr, ptr, ptr }>, 
align 8
+// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ ptr, i32, i32, 
ptr, ptr, ptr, ptr }>, ptr %[[BLOCK]], i32 0, i32 5
+// CHECK: store ptr %[[X]], ptr %[[BLOCK_CAPTURED]], align 8
+// CHECK: %[[BLOCK_CAPTURED10:.*]] = getelementptr inbounds <{ ptr, i32, i32, 
ptr, ptr, ptr, ptr }>, ptr %[[BLOCK]], i32 0, i32 6
+// CHECK: store ptr %[[Y]], ptr %[[BLOCK_CAPTURED10]], align 8
 
 // CHECK-LABEL: define internal void @___ZN1S1mEv_block_invoke(
 

diff  --git a/clang/test/PCH/builtin-is-constant-evaluated.cpp 
b/clang/test/PCH/builtin-is-constant-evaluated.cpp
index 558676fc78bf2..a74f493415a35 100644
--- a/clang/test/PCH/builtin-is-constant-evaluated.cpp
+++ b/clang/test/PCH/builtin-is-constant-evaluated.cpp
@@ -1,14 +1,14 @@
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -Wno-constant-evaluated 
-triple x86_64-linux -include %s -verify %s -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -Wno-constant-evaluated 
-triple x86_64-linux -emit-pch %s -o %t
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -Wno-constant-evaluated 
-triple x86_64-linux -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++98 -Wno-constant-evaluated -triple x86_64-linux 
-include %s -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++98 -Wno-constant-evaluated -triple x86_64-linux 
-emit-pch %s -o %t
+// RUN: %clang_cc1 -std=c++98 -Wno-constant-evaluated -triple x86_64-linux 
-include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -Wno-constant-evaluated 
-triple x86_64-linux -include %s -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CXX11
-// RUN: %clang_cc1 -no-opaque-point

[clang-tools-extra] 35d9f87 - [clang-tidy] Fix a couple additional cases in misc-use-anonymous-namespace only

2022-12-12 Thread Carlos Galvez via cfe-commits

Author: Carlos Galvez
Date: 2022-12-12T15:26:14Z
New Revision: 35d9f873e3f21846de1b8f07271feedbbe8518ed

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

LOG: [clang-tidy] Fix a couple additional cases in misc-use-anonymous-namespace 
only

- Do not analyze header files, since we don't want to promote
  using anonymous namespaces there.

- Do not warn about const/constexpr variables, those are implicitly
  static in C++ and they don't need to be moved to an anonymous
  namespace. Warning about redundant static in general could be
  implemented as a standalone check, moving away some of the
  functionality from this check.

This check has been introduced in the current release, thus
no mention of this change is needed in the Release Notes.

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/use-anonymous-namespace.h

Modified: 
clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
index fdf7828c8c0fd..b26632d107796 100644
--- a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
@@ -21,6 +21,15 @@ AST_POLYMORPHIC_MATCHER(isStatic, 
AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
   return Node.getStorageClass() == SC_Static;
 }
 
+AST_POLYMORPHIC_MATCHER_P(isInHeaderFile,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+  VarDecl),
+  utils::FileExtensionsSet, HeaderFileExtensions) {
+  return utils::isExpansionLocInHeaderFile(
+  Node.getBeginLoc(), Finder->getASTContext().getSourceManager(),
+  HeaderFileExtensions);
+}
+
 AST_MATCHER(FunctionDecl, isMemberFunction) {
   return llvm::isa(&Node);
 }
@@ -31,15 +40,36 @@ AST_MATCHER(Decl, isInAnonymousNamespace) {
 }
 } // namespace
 
+UseAnonymousNamespaceCheck::UseAnonymousNamespaceCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
+  "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
+  if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
+  HeaderFileExtensions,
+  utils::defaultFileExtensionDelimiters())) {
+this->configurationDiag("Invalid header file extension: '%0'")
+<< RawStringHeaderFileExtensions;
+  }
+}
+
+void UseAnonymousNamespaceCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
+}
+
 void UseAnonymousNamespaceCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   functionDecl(isStatic(),
-   unless(anyOf(isInAnonymousNamespace(), isMemberFunction(
+   unless(anyOf(isInHeaderFile(HeaderFileExtensions),
+isInAnonymousNamespace(), isMemberFunction(
   .bind("x"),
   this);
   Finder->addMatcher(
-  varDecl(isStatic(), unless(anyOf(isInAnonymousNamespace(),
-   isStaticLocal(), isStaticDataMember(
+  varDecl(isStatic(),
+  unless(anyOf(isInHeaderFile(HeaderFileExtensions),
+   isInAnonymousNamespace(), isStaticLocal(),
+   isStaticDataMember(), hasType(isConstQualified()
   .bind("x"),
   this);
 }

diff  --git a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h 
b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
index 19d76bfc19f63..af4ac60cf9b25 100644
--- a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_USEANONYMOUSNAMESPACECHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "../utils/FileExtensionsUtils.h"
 
 namespace clang {
 namespace tidy {
@@ -18,17 +19,29 @@ namespace misc {
 /// Warns when using 'static' functions or variables at global scope, and
 /// suggests moving them to an anonymous namespace.
 ///
+/// The check supports these options:
+///   - `HeaderFileExtensions`: a semicolon-separated list of filename
+/// extensions of header files (The fil

[PATCH] D139113: [clang-tidy] Fix a couple additional cases in misc-use-anonymous-namespace

2022-12-12 Thread Carlos Galvez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG35d9f873e3f2: [clang-tidy] Fix a couple additional cases in 
misc-use-anonymous-namespace only (authored by carlosgalvezp).

Changed prior to commit:
  https://reviews.llvm.org/D139113?vs=481257&id=482119#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139113

Files:
  clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
  clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
  clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
  
clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/use-anonymous-namespace.h
  clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s misc-use-anonymous-namespace %t
+// RUN: %check_clang_tidy %s misc-use-anonymous-namespace %t -- -header-filter=.* -- -I%S/Inputs
+#include "use-anonymous-namespace.h"
 
 static void f1();
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function 'f1' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]
@@ -41,3 +42,7 @@
 {
   static int x;
 }
+
+// OK
+static const int v8{123};
+static constexpr int v9{123};
Index: clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/use-anonymous-namespace.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/use-anonymous-namespace.h
@@ -0,0 +1,3 @@
+// Should not warn here, do not require anonymous namespaces in headers
+static int gv{123};
+static void gf(){}
Index: clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
+++ clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
@@ -11,6 +11,14 @@
 keep C compatibility [1]. ``static`` is an overloaded term with different meanings in
 different contexts, so it can create confusion.
 
+The following uses of ``static`` will *not* be diagnosed:
+
+* Functions or variables in header files, since anonymous namespaces in headers
+  is considered an antipattern. Allowed header file extensions can be configured
+  via the `HeaderFileExtensions` option (see below).
+* ``const`` or ``constexpr`` variables, since they already have implicit internal
+  linkage in C++.
+
 Examples:
 
 .. code-block:: c++
@@ -25,4 +33,14 @@
 int x;
   } // namespace
 
+Options
+---
+
+.. option:: HeaderFileExtensions
+
+   A semicolon-separated list of filename extensions of header files (the filename
+   extensions should not include "." prefix). Default is ";h;hh;hpp;hxx".
+   For extension-less header files, using an empty string or leaving an
+   empty string between ";" if there are other filename extensions.
+
 [1] `Undeprecating static `_
Index: clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
===
--- clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
+++ clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_USEANONYMOUSNAMESPACECHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "../utils/FileExtensionsUtils.h"
 
 namespace clang {
 namespace tidy {
@@ -18,17 +19,29 @@
 /// Warns when using 'static' functions or variables at global scope, and
 /// suggests moving them to an anonymous namespace.
 ///
+/// The check supports these options:
+///   - `HeaderFileExtensions`: a semicolon-separated list of filename
+/// extensions of header files (The filename extension should not contain
+/// "." prefix). ";h;hh;hpp;hxx" by default.
+///
+/// For extension-less header files, using an empty string or leaving an
+/// empty string between ";" if there are other filename extensions.
+///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-anonymous-namespace.html
 class UseAnonymousNamespaceCheck : public ClangTidyCheck {
 public:
-  UseAnonymousNamespaceCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  UseAnonymousNamespaceCheck(StringRef Name, ClangTidyContext *Context);
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
 return LangOpts.CPlusPlus;
   }
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) ove

[clang] 6271805 - [Clang] Update Profile tests to opaque pointers (NFC)

2022-12-12 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-12-12T16:28:03+01:00
New Revision: 627180562911b93a523fea000511311ed0d381e4

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

LOG: [Clang] Update Profile tests to opaque pointers (NFC)

Added: 


Modified: 
clang/test/Profile/c-captured.c
clang/test/Profile/c-general.c
clang/test/Profile/c-indirect-call.c
clang/test/Profile/c-linkage-available_externally.c
clang/test/Profile/c-ternary.c
clang/test/Profile/c-unprofiled-blocks.c
clang/test/Profile/c-unreachable-after-switch.c
clang/test/Profile/cxx-abc-deleting-dtor.cpp
clang/test/Profile/cxx-class.cpp
clang/test/Profile/cxx-indirect-call.cpp
clang/test/Profile/cxx-lambda.cpp
clang/test/Profile/cxx-rangefor.cpp
clang/test/Profile/cxx-stmt-initializers.cpp
clang/test/Profile/cxx-templates.cpp
clang/test/Profile/cxx-throws.cpp

Removed: 




diff  --git a/clang/test/Profile/c-captured.c b/clang/test/Profile/c-captured.c
index cfc64b7a7ae64..3a802494eb6a6 100644
--- a/clang/test/Profile/c-captured.c
+++ b/clang/test/Profile/c-captured.c
@@ -1,14 +1,14 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 
-main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instrument=clang | 
FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOGEN 
-check-prefix=PGOALL %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-captured.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck 
-allow-deprecated-dag-overlap  -check-prefix=PGOGEN -check-prefix=PGOALL %s
 
 // RUN: llvm-profdata merge %S/Inputs/c-captured.proftext -o %t.profdata
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 
-main-file-name c-captured.c %s -o - -emit-llvm 
-fprofile-instrument-use-path=%t.profdata | FileCheck 
-allow-deprecated-dag-overlap  -check-prefix=PGOUSE -check-prefix=PGOALL %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-captured.c %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata | 
FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOUSE 
-check-prefix=PGOALL %s
 
 // PGOGEN: @[[DCC:__profc_debug_captured]] = private global [3 x i64] 
zeroinitializer
 // PGOGEN: @[[CSC:__profc_c_captured.c___captured_stmt]] = private global [2 x 
i64] zeroinitializer
 // PGOGEN: @[[C1C:__profc_c_captured.c___captured_stmt.1]] = private global [3 
x i64] zeroinitializer
 
 // PGOALL-LABEL: define{{.*}} void @debug_captured()
-// PGOGEN: store {{.*}} @[[DCC]], i32 0, i32 0
+// PGOGEN: store {{.*}} @[[DCC]]
 void debug_captured(void) {
   int x = 10;
 
@@ -20,7 +20,7 @@ void debug_captured(void) {
 // PGOALL: ret
 
 // PGOALL-LABEL: define internal void @__captured_stmt(
-// PGOGEN: store {{.*}} @[[CSC]], i32 0, i32 0
+// PGOGEN: store {{.*}} @[[CSC]]
 #pragma clang __debug captured
   {
 // PGOGEN: store {{.*}} @[[CSC]], i32 0, i32 1
@@ -32,7 +32,7 @@ void debug_captured(void) {
   if (x) {} // This is DC1. Checked above.
 
 // PGOALL-LABEL: define internal void @__captured_stmt.1(
-// PGOGEN: store {{.*}} @[[C1C]], i32 0, i32 0
+// PGOGEN: store {{.*}} @[[C1C]]
 #pragma clang __debug captured
   {
 // PGOGEN: store {{.*}} @[[C1C]], i32 0, i32 1

diff  --git a/clang/test/Profile/c-general.c b/clang/test/Profile/c-general.c
index 4c354373d2754..b841f9c3d2a1d 100644
--- a/clang/test/Profile/c-general.c
+++ b/clang/test/Profile/c-general.c
@@ -1,13 +1,13 @@
 // Test instrumentation of general constructs in C.
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 
-main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument=clang | 
FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOGEN %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c 
%s -o - -emit-llvm -fprofile-instrument=clang | FileCheck 
-allow-deprecated-dag-overlap  -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 
-main-file-name c-general.c %s -o - -emit-llvm 
-fprofile-instrument-use-path=%t.profdata | FileCheck 
-allow-deprecated-dag-overlap  -check-prefix=PGOUSE %s
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 
-main-file-name c-general.c %s -o - -emit-llvm 
-fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v5 | FileCheck 
-allow-deprecated-dag-overlap  -check-prefix=PGOUSE %s
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 
-main-file-name c-general.c %s -o - -emit-llvm 
-fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v3 | FileCheck 
-allow-deprecated-dag-overlap  -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-nam

[clang] 1f8fecf - [OpenMP][OMPIRBuilder] Migrate code to emit target region functions from clang to OMPIRBuilder

2022-12-12 Thread Jan Sjodin via cfe-commits

Author: Jan Sjodin
Date: 2022-12-12T10:28:58-05:00
New Revision: 1f8fecf26b35cef2713252fb020ff66cee248d99

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

LOG: [OpenMP][OMPIRBuilder] Migrate code to emit target region functions from 
clang to OMPIRBuilder

This patch moves some of the logic on how to emit target region functions and
adds emitTargetRegionFunction to the OpenMPIRBuilder. Also the
OpenMPOffloadMandatory flag is added to the config.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a75e31f40e074..6f3f9b30ac954 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1061,7 +1061,8 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM)
 : CGM(CGM), OMPBuilder(CGM.getModule()), OffloadEntriesInfoManager() {
   KmpCriticalNameTy = llvm::ArrayType::get(CGM.Int32Ty, /*NumElements*/ 8);
   llvm::OpenMPIRBuilderConfig Config(CGM.getLangOpts().OpenMPIsDevice, false,
- hasRequiresUnifiedSharedMemory());
+ hasRequiresUnifiedSharedMemory(),
+ CGM.getLangOpts().OpenMPOffloadMandatory);
   // Initialize Types used in OpenMPIRBuilder from OMPKinds.def
   OMPBuilder.initialize();
   OMPBuilder.setConfig(Config);
@@ -6088,49 +6089,19 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
 const OMPExecutableDirective &D, StringRef ParentName,
 llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID,
 bool IsOffloadEntry, const RegionCodeGenTy &CodeGen) {
-  // Create a unique name for the entry function using the source location
-  // information of the current target region. The name will be something like:
-  //
-  // __omp_offloading_DD__PP_lBB[_CC]
-  //
-  // where DD_ is an ID unique to the file (device and file IDs), PP is the
-  // mangled name of the function that encloses the target region and BB is the
-  // line number of the target region. CC is a count added when more than one
-  // region is located at the same location.
 
-  const bool BuildOutlinedFn = CGM.getLangOpts().OpenMPIsDevice ||
-   !CGM.getLangOpts().OpenMPOffloadMandatory;
   auto EntryInfo =
   getTargetEntryUniqueInfo(CGM.getContext(), D.getBeginLoc(), ParentName);
 
-  SmallString<64> EntryFnName;
-  OffloadEntriesInfoManager.getTargetRegionEntryFnName(EntryFnName, EntryInfo);
-
-  const CapturedStmt &CS = *D.getCapturedStmt(OMPD_target);
-
   CodeGenFunction CGF(CGM, true);
-  CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
-  CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
+  llvm::OpenMPIRBuilder::FunctionGenCallback &&GenerateOutlinedFunction =
+  [this, &CGF, &D, &CodeGen](StringRef EntryFnName) {
+const CapturedStmt &CS = *D.getCapturedStmt(OMPD_target);
 
-  OutlinedFn = BuildOutlinedFn
-   ? CGF.GenerateOpenMPCapturedStmtFunction(CS, 
D.getBeginLoc())
-   : nullptr;
-
-  // If this target outline function is not an offload entry, we don't need to
-  // register it.
-  if (!IsOffloadEntry)
-return;
-
-  // The target region ID is used by the runtime library to identify the 
current
-  // target region, so it only has to be unique and not necessarily point to
-  // anything. It could be the pointer to the outlined function that implements
-  // the target region, but we aren't using that so that the compiler doesn't
-  // need to keep that, and could therefore inline the host function if proven
-  // worthwhile during optimization. In the other hand, if emitting code for 
the
-  // device, the ID has to be the function address so that it can retrieved 
from
-  // the offloading entry and launched by the runtime library. We also mark the
-  // outlined function to have external linkage in case we are emitting code 
for
-  // the device, because these functions will be entry points to the device.
+CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
+CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
+return CGF.GenerateOpenMPCapturedStmtFunction(CS, D.getBeginLoc());
+  };
 
   // Get NumTeams and ThreadLimit attributes
   int32_t DefaultValTeams = -1;
@@ -6138,15 +6109,12 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
   getNumTeamsExprForTargetDirective(CGF, D

[PATCH] D139634: [OpenMP][OMPIRBuilder] Migrate code to emit target region functions from clang to OMPIRBuilder

2022-12-12 Thread Jan Sjödin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f8fecf26b35: [OpenMP][OMPIRBuilder] Migrate code to emit 
target region functions from clang… (authored by jsjodin).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D139634?vs=481662&id=482121#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139634

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -5490,7 +5490,7 @@
 
 TEST_F(OpenMPIRBuilderTest, OffloadEntriesInfoManager) {
   OffloadEntriesInfoManager InfoManager;
-  InfoManager.setConfig(OpenMPIRBuilderConfig(true, false, false));
+  InfoManager.setConfig(OpenMPIRBuilderConfig(true, false, false, false));
   TargetRegionEntryInfo EntryInfo("parent", 1, 2, 4, 0);
   InfoManager.initializeTargetRegionEntryInfo(EntryInfo, 0);
   EXPECT_TRUE(InfoManager.hasTargetRegionEntryInfo(EntryInfo));
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -3970,6 +3970,35 @@
   Constant::getNullValue(Builder.getInt8Ty()), EntryFnName);
 }
 
+void OpenMPIRBuilder::emitTargetRegionFunction(
+OffloadEntriesInfoManager &InfoManager, TargetRegionEntryInfo &EntryInfo,
+FunctionGenCallback &GenerateFunctionCallback, int32_t NumTeams,
+int32_t NumThreads, bool IsOffloadEntry, Function *&OutlinedFn,
+Constant *&OutlinedFnID) {
+
+  SmallString<64> EntryFnName;
+  InfoManager.getTargetRegionEntryFnName(EntryFnName, EntryInfo);
+
+  OutlinedFn = Config.isEmbedded() || !Config.openMPOffloadMandatory()
+   ? GenerateFunctionCallback(EntryFnName)
+   : nullptr;
+
+  // If this target outline function is not an offload entry, we don't need to
+  // register it. This may be in the case of a false if clause, or if there are
+  // no OpenMP targets.
+  if (!IsOffloadEntry)
+return;
+
+  std::string EntryFnIDName =
+  Config.isEmbedded()
+  ? std::string(EntryFnName)
+  : createPlatformSpecificName({EntryFnName, "region_id"});
+
+  OutlinedFnID = registerTargetRegionFunction(
+  InfoManager, EntryInfo, OutlinedFn, EntryFnName, EntryFnIDName, NumTeams,
+  NumThreads);
+}
+
 Constant *OpenMPIRBuilder::registerTargetRegionFunction(
 OffloadEntriesInfoManager &InfoManager, TargetRegionEntryInfo &EntryInfo,
 Function *OutlinedFn, StringRef EntryFnName, StringRef EntryFnIDName,
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -93,6 +93,9 @@
   /// directive is present or not.
   std::optional HasRequiresUnifiedSharedMemory;
 
+  // Flag for specifying if offloading is mandatory.
+  Optional OpenMPOffloadMandatory;
+
   /// First separator used between the initial two parts of a name.
   std::optional FirstSeparator;
   /// Separator used between all of the rest consecutive parts of s name
@@ -100,9 +103,11 @@
 
   OpenMPIRBuilderConfig() {}
   OpenMPIRBuilderConfig(bool IsEmbedded, bool IsTargetCodegen,
-bool HasRequiresUnifiedSharedMemory)
+bool HasRequiresUnifiedSharedMemory,
+bool OpenMPOffloadMandatory)
   : IsEmbedded(IsEmbedded), IsTargetCodegen(IsTargetCodegen),
-HasRequiresUnifiedSharedMemory(HasRequiresUnifiedSharedMemory) {}
+HasRequiresUnifiedSharedMemory(HasRequiresUnifiedSharedMemory),
+OpenMPOffloadMandatory(OpenMPOffloadMandatory) {}
 
   // Getters functions that assert if the required values are not present.
   bool isEmbedded() const {
@@ -121,6 +126,11 @@
 return HasRequiresUnifiedSharedMemory.value();
   }
 
+  bool openMPOffloadMandatory() const {
+assert(OpenMPOffloadMandatory.has_value() &&
+   "OpenMPOffloadMandatory is not set");
+return OpenMPOffloadMandatory.value();
+  }
   // Returns the FirstSeparator if set, otherwise use the default
   // separator depending on isTargetCodegen
   StringRef firstSeparator() const {
@@ -1479,6 +1489,49 @@
 StringRef EntryFnName);
 
 public:
+  /// Functions used to generate a function with the given name.
+  using FunctionGenCallback = std::function;
+
+  /// Create a unique name for th

[clang] 620d2bf - [clang] Allow using BareMetal toolchain with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR compiler-rt

2022-12-12 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2022-12-12T15:36:06Z
New Revision: 620d2bfdadeb7f4936775422a0e965e7fcdcd204

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

LOG: [clang] Allow using BareMetal toolchain with 
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR compiler-rt

If you build compiler-rt with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR then
the library filename will be "libclang_rt.builtins.a" instead of
"libclang_rt.builtins-.a"

The ToolChain::getCompilerRT method uses the "libclang_rt.builtins.a"
name if it can find the file in the library directories. If it can't
then it falls back to using "libclang_rt.builtins-.a". This
change adds the library directory such that "libclang_rt.builtins.a"
can be found.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 135843463b00b..ac9c7036ad6ef 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,6 +103,7 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple 
&Triple,
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
+getLibraryPaths().push_back(std::string(SysRoot));
   }
 }
 

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index b5fc45586908d..24890e87c313c 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -340,3 +340,27 @@
 // CHECK-RV32IMAFC-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-RV32IMAFC-SAME: 
"-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
 // CHECK-RV32IMAFC-SAME: 
"-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
+
+// Check that compiler-rt library without the arch filename suffix will
+// be used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_noarch
+// RUN: mkdir -p %T/baremetal_clang_rt_noarch/lib
+// RUN: touch %T/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_noarch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-NOARCH %s
+// CHECK-CLANGRT-NOARCH: "-lclang_rt.builtins"
+// CHECK-CLANGRT-NOARCH-NOT: "-lclang_rt.builtins-armv6m"
+
+// Check that compiler-rt library with the arch filename suffix will be
+// used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_arch
+// RUN: mkdir -p %T/baremetal_clang_rt_arch/lib
+// RUN: touch %T/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_arch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
+// CHECK-CLANGRT-ARCH: "-lclang_rt.builtins-armv6m"
+// CHECK-CLANGRT-ARCH-NOT: "-lclang_rt.builtins"



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


[PATCH] D139822: Allow using BareMetal toolchain with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR compiler-rt

2022-12-12 Thread Michael Platings via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG620d2bfdadeb: [clang] Allow using BareMetal toolchain with 
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR… (authored by michaelplatings).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139822

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -340,3 +340,27 @@
 // CHECK-RV32IMAFC-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-RV32IMAFC-SAME: 
"-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
 // CHECK-RV32IMAFC-SAME: 
"-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
+
+// Check that compiler-rt library without the arch filename suffix will
+// be used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_noarch
+// RUN: mkdir -p %T/baremetal_clang_rt_noarch/lib
+// RUN: touch %T/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_noarch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-NOARCH %s
+// CHECK-CLANGRT-NOARCH: "-lclang_rt.builtins"
+// CHECK-CLANGRT-NOARCH-NOT: "-lclang_rt.builtins-armv6m"
+
+// Check that compiler-rt library with the arch filename suffix will be
+// used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_arch
+// RUN: mkdir -p %T/baremetal_clang_rt_arch/lib
+// RUN: touch %T/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_arch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
+// CHECK-CLANGRT-ARCH: "-lclang_rt.builtins-armv6m"
+// CHECK-CLANGRT-ARCH-NOT: "-lclang_rt.builtins"
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,6 +103,7 @@
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
+getLibraryPaths().push_back(std::string(SysRoot));
   }
 }
 


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -340,3 +340,27 @@
 // CHECK-RV32IMAFC-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-RV32IMAFC-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
 // CHECK-RV32IMAFC-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
+
+// Check that compiler-rt library without the arch filename suffix will
+// be used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_noarch
+// RUN: mkdir -p %T/baremetal_clang_rt_noarch/lib
+// RUN: touch %T/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_noarch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-NOARCH %s
+// CHECK-CLANGRT-NOARCH: "-lclang_rt.builtins"
+// CHECK-CLANGRT-NOARCH-NOT: "-lclang_rt.builtins-armv6m"
+
+// Check that compiler-rt library with the arch filename suffix will be
+// used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_arch
+// RUN: mkdir -p %T/baremetal_clang_rt_arch/lib
+// RUN: touch %T/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_arch \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
+// CHECK-CLANGRT-ARCH: "-lclang_rt.builtins-armv6m"
+// CHECK-CLANGRT-ARCH-NOT: "-lclang_rt.builtins"
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,6 +103,7 @@
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
+getLibraryPaths().push_back(std::string(SysRoot));
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131830: [OpenMP] Clang Support for taskwait nowait clause

2022-12-12 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim added a comment.

Why do we need __kmpc_omp_taskwait_51 ? Taskwait nowait only makes sense with 
dependencies. It should only result in additional nodes/edges in the task 
dependency graph without any code to execute. There is not taskwait (aka task 
barrier) in this case.

The taskwait construct has the restriction in the spec:

> The **nowait** clause may only appear on a **taskwait** directive if the 
> **depend** clause is present.


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

https://reviews.llvm.org/D131830

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


[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-12 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

The build failed again, but it looks like the cause is unrelated to these 
changes. I restarted the build.


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

https://reviews.llvm.org/D139148

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


[PATCH] D139786: [clang-format] AllowShortRequiresExpressionOnASingleLine

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

Please mark comments as done.




Comment at: clang/lib/Format/Format.cpp:1270
   LLVMStyle.AllowShortLoopsOnASingleLine = false;
+  LLVMStyle.AllowShortRequiresExpressionOnASingleLine = true;
   LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;

Please initialize to false, because that is what we are doing right now.



Comment at: clang/unittests/Format/FormatTest.cpp:2904
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortRequiresExpressionOnASingleLine);
+  verifyFormat("template \n"

Please add a test where the clause is too long and will still be wrapped. 
Reduce the column limit and use some longer identifiers.


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

https://reviews.llvm.org/D139786

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


[PATCH] D139834: [clang-format] AllowShortCompoundRequirementOnASingleLine

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

See the comments on D139786 . And you can 
base your commits on each other, and then add a child rsp. parent revision here 
in phabricator, that will prevent merge conflicts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139834

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


[PATCH] D131830: [OpenMP] Clang Support for taskwait nowait clause

2022-12-12 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: clang/test/OpenMP/taskwait_depend_nowait_codegen.cpp:1
+// RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 
-fopenmp -fopenmp-version=51 -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-version=51 -x c++ 
-triple x86_64-apple-darwin10 -emit-pch -o %t %s

Please do not add any new tests using `-no-opaque-pointers`.


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

https://reviews.llvm.org/D131830

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


[PATCH] D136100: [clang-format] Do not parse certain characters in pragma directives

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

I think you need to parse the first paren as whole and do not indent it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136100

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


[PATCH] D139723: [OpenMP][AMDGPU] Enable use of abs labs and llabs math functions in C code

2022-12-12 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 updated this revision to Diff 482133.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139723

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_hip_runtime_wrapper.h
  clang/lib/Headers/__clang_hip_stdlib.h
  clang/lib/Headers/openmp_wrappers/stdlib.h
  clang/test/Headers/Inputs/include/stdlib.h
  clang/test/Headers/amdgcn_openmp_device_math_c.c
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -85,6 +85,7 @@
 "__clang_hip_cmath.h",
 "__clang_hip_libdevice_declares.h",
 "__clang_hip_math.h",
+"__clang_hip_stdlib.h",
 "__clang_hip_runtime_wrapper.h",
 "__stddef_max_align_t.h",
 "__wmmintrin_aes.h",
@@ -192,6 +193,7 @@
 "openmp_wrappers/complex.h",
 "openmp_wrappers/complex_cmath.h",
 "openmp_wrappers/math.h",
+"openmp_wrappers/stdlib.h",
 "pconfigintrin.h",
 "pkuintrin.h",
 "pmmintrin.h",
Index: clang/test/Headers/amdgcn_openmp_device_math_c.c
===
--- /dev/null
+++ clang/test/Headers/amdgcn_openmp_device_math_c.c
@@ -0,0 +1,131 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]"
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -D__OFFLOAD_ARCH_gfx90a__ -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -include __clang_hip_runtime_wrapper.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK
+// REQUIRES: amdgpu-registered-target
+
+#include 
+
+void test_math_int(int x) {
+#pragma omp target
+  {
+int l1 = abs(x);
+  }
+}
+
+void test_math_long(long x) {
+#pragma omp target
+  {
+long l1 = labs(x);
+  }
+}
+
+void test_math_long_long(long long x) {
+#pragma omp target
+  {
+long long l1 = llabs(x);
+  }
+}
+// CHECK-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_test_math_int_l9
+// CHECK-SAME: (i64 noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL_I:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[__X_ADDR_I:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[__SGN_I:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i64, align 8, addrspace(5)
+// CHECK-NEXT:[[L1:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[X_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[X_ADDR]] to ptr
+// CHECK-NEXT:[[L1_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[L1]] to ptr
+// CHECK-NEXT:store i64 [[X]], ptr [[X_ADDR_ASCAST]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_target_init(ptr addrspacecast (ptr addrspace(1) @[[GLOB1:[0-9]+]] to ptr), i8 1, i1 true, i1 true)
+// CHECK-NEXT:[[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1
+// CHECK-NEXT:br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]]
+// CHECK:   user_code.entry:
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[X_ADDR_ASCAST]], align 4
+// CHECK-NEXT:[[RETVAL_ASCAST_I:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL_I]] to ptr
+// CHECK-NEXT:[[__X_ADDR_ASCAST_I:%.*]] = addrspacecast ptr addrspace(5) [[__X_ADDR_I]] to ptr
+// CHECK-NEXT:[[__SGN_ASCAST_I:%.*]] = addrspacecast ptr addrspace(5) [[__SGN_I]] to ptr
+// CHECK-NEXT:store i32 [[TMP1]], ptr [[__X_ADDR_ASCAST_I]], align 4
+// CHECK-NEXT:[[TMP2:%.*]] = load i32, ptr [[__X_ADDR_ASCAST_I]], align 4
+// CHECK-NEXT:[[SHR_I:%.*]] = ashr i32 [[TMP2]], 31
+// CHECK-NEXT:store i32 [[SHR_I]], ptr [[__SGN_ASCAST_I]], align 4
+// CHECK-NEXT:[[TMP3:%.*]] = load i32, ptr [[__X_ADDR_ASCAST_I]], align 4
+// CHECK-NEXT:[[TMP4:%.*]] = load i32, ptr [[__SGN_ASCAST_I]], align 4
+// CHECK-NEXT:[[XOR_I:%.*]] = xor i32 [[TMP3]], [[TMP4]]
+// CHECK-NEXT:[[TMP5:%.*]] = load i32, ptr [[__SGN_ASCAST_I]], align 4
+// CHECK-NEXT:[[SUB_I:%.*]] = sub nsw i32 [[XOR_I]], [[TMP5]]
+// CHECK-NEXT:store i32 [[SUB_I]], ptr [[L1_ASCAST]], align 4
+// CHECK-NEXT:call void @__kmpc_target_deinit(ptr addrspacecast (ptr addrspace(1) @[[GLOB1]

[PATCH] D139723: [OpenMP][AMDGPU] Enable use of abs labs and llabs math functions in C code

2022-12-12 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 added a comment.

@arsenm I have factored out the abs/labs/llabs functions in a separate 
__clang_hip_stdlib.h file which could be included by C sources.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139723

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:685
+  auto TgtImageOrErr = jit::compile(TgtImage, Triple, Arch,
+/* OptLevel */ 3, PostProcessing);
+  if (!TgtImageOrErr) {

tianshilei1992 wrote:
> Do we want a configurable value for the `OptLevel`, or can we know it from 
> somewhere else what value is used at compile time?
We most likely want a env var and maybe later even pass the value through. Env 
var is good enough for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D139801: [clang-format] Adds 'friend' to QualifierOrder.

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

I'm normally way more lenient than the most to add features, but here I have to 
ask do you want it so that you can get `friend` always as first, or do you 
really want to be able to put `friend` anywhere in the sequence? If only the 
first, I'd say we do that without adding this option.

I had actually to look up that you can put `friend` basically anywhere, all 
examples, tutorials, etc. put it in front. I would discourage that clang-format 
puts it anywhere else, even though it is valid C++.

Technically: Do we need/want a config parse test for friend?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139801

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


[PATCH] D139720: [clang][PPC] Checking Unknown Values Passed to -mcpu

2022-12-12 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 482137.
qiongsiwu1 added a comment.

Updating to revert back to `const char *` in the big `StringSwitch`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139720

Files:
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  clang/lib/Driver/ToolChains/Arch/PPC.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/ppc-cpus.c

Index: clang/test/Driver/ppc-cpus.c
===
--- clang/test/Driver/ppc-cpus.c
+++ clang/test/Driver/ppc-cpus.c
@@ -5,6 +5,15 @@
 // RUN: %clang -### -c -target powerpc64 %s -mcpu=native 2>&1 | FileCheck --check-prefix=MCPU_NATIVE %s
 // MCPU_NATIVE-NOT: "-target-cpu" "native"
 
+/// Check that we are passing unknown mcpu options to the backend so an error
+/// can be triggered.
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=asdf1234 2>&1 | FileCheck --check-prefix=MCPU_UNKNOWN %s
+// MCPU_UNKNOWN: "-target-cpu" "asdf1234"
+
+/// Check for the unknown target error if an unknown mcpu option is used.
+// RUN: not %clang -c -target powerpc64 %s -mcpu=asdf1234 2>&1 | FileCheck --check-prefix=MCPU_ERR %s
+// MCPU_ERR: unknown target CPU 'asdf1234'
+
 // RUN: %clang -### -c -target powerpc64 %s -mcpu=7400 2>&1 | FileCheck --check-prefix=MCPU_7400 %s
 // MCPU_7400: "-target-cpu" "7400"
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -409,25 +409,9 @@
   case llvm::Triple::ppc:
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64:
-  case llvm::Triple::ppc64le: {
-std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
-// LLVM may default to generating code for the native CPU,
-// but, like gcc, we default to a more generic option for
-// each architecture. (except on AIX)
-if (!TargetCPUName.empty())
-  return TargetCPUName;
-
-if (T.isOSAIX())
-  TargetCPUName = "pwr7";
-else if (T.getArch() == llvm::Triple::ppc64le)
-  TargetCPUName = "ppc64le";
-else if (T.getArch() == llvm::Triple::ppc64)
-  TargetCPUName = "ppc64";
-else
-  TargetCPUName = "ppc";
+  case llvm::Triple::ppc64le:
+return ppc::getPPCTargetCPU(Args, T);
 
-return TargetCPUName;
-  }
   case llvm::Triple::csky:
 if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
   return A->getValue();
Index: clang/lib/Driver/ToolChains/Arch/PPC.h
===
--- clang/lib/Driver/ToolChains/Arch/PPC.h
+++ clang/lib/Driver/ToolChains/Arch/PPC.h
@@ -35,7 +35,8 @@
 
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 
-std::string getPPCTargetCPU(const llvm::opt::ArgList &Args);
+std::string getPPCTargetCPU(const llvm::opt::ArgList &Args,
+const llvm::Triple &T);
 const char *getPPCAsmModeForCPU(StringRef Name);
 ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D, const llvm::Triple &Triple,
 const llvm::opt::ArgList &Args);
Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -20,46 +20,45 @@
 using namespace clang;
 using namespace llvm::opt;
 
+static std::string getPPCGenericTargetCPU(const llvm::Triple &T) {
+  // LLVM may default to generating code for the native CPU,
+  // but, like gcc, we default to a more generic option for
+  // each architecture. (except on AIX)
+  if (T.isOSAIX())
+return "pwr7";
+  else if (T.getArch() == llvm::Triple::ppc64le)
+return "ppc64le";
+  else if (T.getArch() == llvm::Triple::ppc64)
+return "ppc64";
+  else
+return "ppc";
+}
+
 /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting.
-std::string ppc::getPPCTargetCPU(const ArgList &Args) {
+std::string ppc::getPPCTargetCPU(const ArgList &Args, const llvm::Triple &T) {
   if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
 StringRef CPUName = A->getValue();
 
+if (CPUName == "generic")
+  return getPPCGenericTargetCPU(T);
+
 if (CPUName == "native") {
   std::string CPU = std::string(llvm::sys::getHostCPUName());
   if (!CPU.empty() && CPU != "generic")
 return CPU;
   else
-return "";
+return getPPCGenericTargetCPU(T);
 }
 
 return llvm::StringSwitch(CPUName)
 .Case("common", "generic")
-.Case("440", "440")
 .Case("440fp", "440")
-.Case("450", "450")
-.Case("601", "601")
-.Case("602", "602")
-.Case("603", "603")
-.Case("603e", "603e")
-.Case("603ev", "603ev")
-.Case("604", "604")
-.Case("604e", "604e")
-.Case("620"

[PATCH] D139400: [clang] Show error when a local variables is passed as default template parameter

2022-12-12 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 482140.
massberg added a comment.

Additionally check for ODR use and remove inlcude added by accident.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139400

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/default-template-arguments.cpp


Index: clang/test/SemaTemplate/default-template-arguments.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/default-template-arguments.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+
+namespace GH48755 {
+constexpr int z = 2;
+
+auto f() {
+  constexpr int x_constexpr = 1;
+  const int x_const = 1;
+  static int x_static = 1;
+
+  auto lambda1 = []  {}; // expected-error {{default 
argument references local variable x_constexpr of enclosing function}}
+  auto lambda2 = []  {}; // expected-error {{default 
argument references local variable x_static of enclosing function}}
+  auto lambda3 = []  {}; // expected-error {{default 
argument references local variable x_const of enclosing function}}
+  auto lambda4 = []  {};
+  auto lambda5 = []  {};
+  auto lambda6 = []  {};
+
+  const int x_int_const = 1;
+  auto lambda7 = []  {}; // expected-error {{default 
argument references local variable x_int_const of enclosing function}}
+}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1587,6 +1587,17 @@
 
   // Check the well-formedness of the default template argument, if provided.
   if (Default) {
+// Local variables may not be used as default template arguments.
+if (auto *DRE = dyn_cast(Default)) {
+  if (VarDecl *VD = dyn_cast(DRE->getDecl())) {
+if (VD->isLocalVarDecl() && !DRE->isNonOdrUse()) {
+  Diag(DRE->getLocation(),
+   diag::err_param_default_argument_references_local)
+  << VD->getNameAsString();
+}
+  }
+}
+
 // Check for unexpanded parameter packs.
 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
   return Param;


Index: clang/test/SemaTemplate/default-template-arguments.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/default-template-arguments.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+
+namespace GH48755 {
+constexpr int z = 2;
+
+auto f() {
+  constexpr int x_constexpr = 1;
+  const int x_const = 1;
+  static int x_static = 1;
+
+  auto lambda1 = []  {}; // expected-error {{default argument references local variable x_constexpr of enclosing function}}
+  auto lambda2 = []  {}; // expected-error {{default argument references local variable x_static of enclosing function}}
+  auto lambda3 = []  {}; // expected-error {{default argument references local variable x_const of enclosing function}}
+  auto lambda4 = []  {};
+  auto lambda5 = []  {};
+  auto lambda6 = []  {};
+
+  const int x_int_const = 1;
+  auto lambda7 = []  {}; // expected-error {{default argument references local variable x_int_const of enclosing function}}
+}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1587,6 +1587,17 @@
 
   // Check the well-formedness of the default template argument, if provided.
   if (Default) {
+// Local variables may not be used as default template arguments.
+if (auto *DRE = dyn_cast(Default)) {
+  if (VarDecl *VD = dyn_cast(DRE->getDecl())) {
+if (VD->isLocalVarDecl() && !DRE->isNonOdrUse()) {
+  Diag(DRE->getLocation(),
+   diag::err_param_default_argument_references_local)
+  << VD->getNameAsString();
+}
+  }
+}
+
 // Check for unexpanded parameter packs.
 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
   return Param;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139720: [clang][PPC] Checking Unknown Values Passed to -mcpu

2022-12-12 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 marked 2 inline comments as done.
qiongsiwu1 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:77
+ .Default(CPUName);
+return TargetCPUName.str();
   }

jamieschmeiser wrote:
> qiongsiwu1 wrote:
> > jamieschmeiser wrote:
> > > Why did you change the type from const char *?  Couldn't you use 
> > > CPUName->data() in the default instead?  With your change, I think it may 
> > > need to create StringRefs around all of the choices and then just get the 
> > > string from them.
> > I was worried about the [[ 
> > https://github.com/llvm/llvm-project/blob/d3c3de63ce8416ab2dee7f784e54b00a2aa8ed85/llvm/include/llvm/ADT/StringRef.h#L129
> >  | comment ]] on top of `StringRef::data()` which says "Get a pointer to 
> > the start of the string (which may not be null terminated).". I was not 
> > sure what would happen if the data inside `CPUName` was not null terminated 
> > (it might be fine) so I thought it would be safer to use the `StringRef`s 
> > directly instead. 
> Probably the same sort of thing that would happen with creating a StringRef 
> since that calls strlen to set the size of the string it is wrapping :-)
Got it! Thanks for the suggestion/clarification! The patch is updated to use 
`const char *`. I looked around and I do see `StringRef::data()` used quite 
liberally here and there (e.g. [[ 
https://github.com/llvm/llvm-project/blob/9466b49171dc4b21f56a48594fc82b1e52f5358a/clang/lib/Driver/ToolChains/Gnu.cpp#L867
 | here ]]). So I agree in this case we should be fine. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139720

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


[clang] f32f293 - [CodeGen] Fix a warning

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

Author: Kazu Hirata
Date: 2022-12-12T08:27:12-08:00
New Revision: f32f29385c90b7be05dc19a137d3b25d3c614a50

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

LOG: [CodeGen] Fix a warning

This patch fixes:

  clang/lib/CodeGen/CGOpenMPRuntime.cpp:6098:8: error: lambda capture
  'this' is not used [-Werror,-Wunused-lambda-capture]

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 6f3f9b30ac95..4a5cb4dfa965 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6095,7 +6095,7 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
 
   CodeGenFunction CGF(CGM, true);
   llvm::OpenMPIRBuilder::FunctionGenCallback &&GenerateOutlinedFunction =
-  [this, &CGF, &D, &CodeGen](StringRef EntryFnName) {
+  [&CGF, &D, &CodeGen](StringRef EntryFnName) {
 const CapturedStmt &CS = *D.getCapturedStmt(OMPD_target);
 
 CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);



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


[PATCH] D139847: Also allow __is_unsigned to be used as an identifier

2022-12-12 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg created this revision.
sberg added reviewers: doug.gregor, aaron.ballman.
Herald added a project: All.
sberg requested review of this revision.
Herald added a project: clang.

...similar to 068730992cf08d7d7e82e7bb147d85f429fc3ddd "libstdc++ 4.4 uses 
__is_signed as an identifier [...]"

Starting with 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5329e1a8e1480d536ff96283a6556e51112ba470
 "libstdc++: Make chrono::hh_mm_ss more compact", libstdc++ 13 trunk used 
`__is_signed` as

  static constexpr bool __is_unsigned
= __and_v,
  is_unsigned>;

in `libstdc++-v3/include/std/chrono`.  Even though that got reverted with 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=cb363fd9f19eb791e1ee1eb0d5c61f5fdf21af32
 "libstdc++: Change names that clash with Win32 or Clang", it might make sense 
to treat `__is_unsigned` the same as `__is_signed` here (and to also make the 
workaround hit for `constexpr` in addition to `const`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139847

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp


Index: clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
===
--- clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
+++ clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
@@ -29,6 +29,13 @@
 
 bool check_signed = test_is_signed::__is_signed;
 
+// Another, similar egregious hack for __is_unsigned, which is a type
+// trait in Embarcadero's compiler but is used as an identifier in
+// libstdc++.
+struct test_is_unsigned {
+  static constexpr bool __is_unsigned = true; // expected-warning {{keyword 
'__is_unsigned' will be made available as an identifier}}
+};
+
 template struct must_be_true {};
 template<> struct must_be_true;
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3519,6 +3519,7 @@
 }
 
 case tok::kw___is_signed:
+case tok::kw___is_unsigned:
   // GNU libstdc++ 4.4 uses __is_signed as an identifier, but Clang
   // typically treats it as a trait. If we see __is_signed as it appears
   // in libstdc++, e.g.,
@@ -3526,8 +3527,15 @@
   //   static const bool __is_signed;
   //
   // then treat __is_signed as an identifier rather than as a keyword.
+  //
+  // Similarly, libstdc++ 13 trunk at one point used __is_unsigned as an
+  // identifier as
+  //
+  //   static constexpr bool __is_unsigned;
+  //
   if (DS.getTypeSpecType() == TST_bool &&
-  DS.getTypeQualifiers() == DeclSpec::TQ_const &&
+  (DS.getTypeQualifiers() == DeclSpec::TQ_const ||
+   DS.getConstexprSpecifier() == ConstexprSpecKind::Constexpr) &&
   DS.getStorageClassSpec() == DeclSpec::SCS_static)
 TryKeywordIdentFallback(true);
 


Index: clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
===
--- clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
+++ clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
@@ -29,6 +29,13 @@
 
 bool check_signed = test_is_signed::__is_signed;
 
+// Another, similar egregious hack for __is_unsigned, which is a type
+// trait in Embarcadero's compiler but is used as an identifier in
+// libstdc++.
+struct test_is_unsigned {
+  static constexpr bool __is_unsigned = true; // expected-warning {{keyword '__is_unsigned' will be made available as an identifier}}
+};
+
 template struct must_be_true {};
 template<> struct must_be_true;
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3519,6 +3519,7 @@
 }
 
 case tok::kw___is_signed:
+case tok::kw___is_unsigned:
   // GNU libstdc++ 4.4 uses __is_signed as an identifier, but Clang
   // typically treats it as a trait. If we see __is_signed as it appears
   // in libstdc++, e.g.,
@@ -3526,8 +3527,15 @@
   //   static const bool __is_signed;
   //
   // then treat __is_signed as an identifier rather than as a keyword.
+  //
+  // Similarly, libstdc++ 13 trunk at one point used __is_unsigned as an
+  // identifier as
+  //
+  //   static constexpr bool __is_unsigned;
+  //
   if (DS.getTypeSpecType() == TST_bool &&
-  DS.getTypeQualifiers() == DeclSpec::TQ_const &&
+  (DS.getTypeQualifiers() == DeclSpec::TQ_const ||
+   DS.getConstexprSpecifier() == ConstexprSpecKind::Constexpr) &&
   DS.getStorageClassSpec() == DeclSpec::SCS_static)
 TryKeywordIdentFallback(true);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139400: [clang] Show error when a local variables is passed as default template parameter

2022-12-12 Thread Jens Massberg via Phabricator via cfe-commits
massberg marked 2 inline comments as done.
massberg added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:11
 
+#include  // massberg
 #include "TreeTransform.h"

shafik wrote:
> Please remove.
Ups, thanks!



Comment at: clang/lib/Sema/SemaTemplate.cpp:1594
+  if (VarDecl *VD = dyn_cast(DRE->getDecl())) {
+if (VD->isLocalVarDecl()) {
+  Diag(DRE->getLocation(),

shafik wrote:
> So if we look at `CheckDefaultArgumentVisitor::VistDeclRefExpr` it has a 
> comment about having to check ODR use due to [cwg 
> 2346](https://cplusplus.github.io/CWG/issues/2346.html) and I believe you 
> should be using that as well.
> 
> Which would make your example below pass since the variable is `const` see: 
> https://godbolt.org/z/78Tojh6q5
> 
> It looks like neither gcc nor MSVC implement this DR.
Thanks! I have extended the check.

However, the error is still shown for the `const` case in the test.
When comparing with your function example, I observed that the difference is 
that cone an `int` and otherwise an `auto` is used.
I haven't expected a difference, but with `auto` the existing check for local 
variables as parameters of functions shows an error in case of
`auto` instead of `int`: https://godbolt.org/z/Kvfvn4aEr (Is this a bug?).

I have extended the test cases to have cases with `auto` and cases with `int`, 
but even in the `int` case the code still prints an error.



Comment at: clang/test/SemaTemplate/default-template-arguments.cpp:9
+
+  auto lambda1 = []  {}; // expected-error {{default argument 
references local variable x of enclosing function}}
+  auto lambda2 = []  {};

shafik wrote:
> To clarify my comment about, I think w/ the ODR use checking this should pass.
Thanks! See my comment above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139400

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


[PATCH] D139717: Revert "[Driver] Remove Joined -X"

2022-12-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

We use -Xcompiler and -Xlinker which are passed in programs and they raise 
error now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139717

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


[PATCH] D139115: [clang][ExtractAPI] Add support for single symbol SGF

2022-12-12 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

libclang changes LGTM, thanks!  I'll let the other reviewers who have domain 
expertise speak for the rest of the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139115

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


[PATCH] D138861: [Clang] Implement CWG2640 Allow more characters in an n-char sequence

2022-12-12 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

This looks good. I'm accepting the change despite one remaining issue that was 
neither introduced nor addressed by this patch; the diagnostic caret will still 
be in the wrong location for many of the diagnostics issued by 
`tryReadNamedUCN()`. Most of them use `StartPtr` which we've established points 
to `N` instead of `\`. If you want to make an additional update to address 
that, I'll be happy to review again. I understand if you would rather that be 
fixed via a separate change.




Comment at: clang/lib/Lex/Lexer.cpp:3323
 if (Diagnose)
   Diag(StartPtr, diag::warn_ucn_escape_incomplete);
 return llvm::None;

tahonermann wrote:
> I was able to confirm that `StartPtr` does point to `N`. See the diagnostic 
> generated at https://godbolt.org/z/qnajcMeso; the diagnostic caret points to 
> `N` instead of `\`.
>   :1:2: warning: incomplete delimited universal character name; 
> treating as '\' 'N' '{' identifier [-Wunicode]
>   \N{abc
>^
I think this still needs to be addressed. `tryReadNumericUCN()` handles this 
case by requiring that callers pass the location of the `\` as `SlashLoc`. I 
guess this is technically required since the `\` character could be written as 
either `\` or the `??/` trigraph.



Comment at: clang/lib/Lex/Lexer.cpp:3386
+
+  if (!Result || CurPtr - StartPtr == (ptrdiff_t)(Buffer.size() + 4))
 StartPtr = CurPtr;

cor3ntin wrote:
> tahonermann wrote:
> > cor3ntin wrote:
> > > tahonermann wrote:
> > > > cor3ntin wrote:
> > > > > cor3ntin wrote:
> > > > > > tahonermann wrote:
> > > > > > > This is a bit of a tangent, but under what circumstances would 
> > > > > > > `CurPtr - StartPtr` not be equal to `Buffer.size() + 4`? 
> > > > > > > Actually, I'm not sure that +4 is correct. It looks like 
> > > > > > > `StartPtr` is expected to point to `N` at the beginning of the 
> > > > > > > function, so the initial `\` is not included in the range. If `N` 
> > > > > > > isn't seen, the function returns early. Likewise, if either of 
> > > > > > > the `{` or `}` delimiters is not found, the function returns 
> > > > > > > early.
> > > > > > > 
> > > > > > > I think the goal of this code is to skip the 
> > > > > > > `getAndAdvanceChar()` machinery when the buffer is being claimed 
> > > > > > > (no need to parse UCNs or trigraphs in the character name), but 
> > > > > > > it looks like, particularly with this DR, that we might always be 
> > > > > > > able to do that.
> > > > > > afaict, 4 is correct here because we are one past-the-end.
> > > > > > I do however agree that this whole pattern which is used a few 
> > > > > > times is probably unnecessary, i do think it would be good to 
> > > > > > investigate. Not in this patch though, imo
> > > > > I looked into it, I'm sure we could improve but not easily, 
> > > > > `getAndAdvanceChar` does set some flags on the token in the presence 
> > > > > of trigraphs/line splicing and we need those flags to be set, this is 
> > > > > the reason we do need to call that method.
> > > > > It's not super efficient but it's such an edge case... I'd rather not 
> > > > > touch that now
> > > > My concern is that, as is, the code always takes the `else` branch 
> > > > (except when `Result` is non-null). Assuming a buffer containing "X", 
> > > > the pointers are arranged as follows (where `$` is one past the end).
> > > >   \ N { X } $
> > > > |   |   `- CurPtr
> > > > |   `- Buffer
> > > > `- StartPtr
> > > > `CurPtr - StartPtr` is 4, but `Buffer.size() + 4` is 5 (`Buffer.size()` 
> > > > is 1 in this case).
> > > > 
> > > > I think there might be an easy test to see if this is working as 
> > > > intended. If it isn't, I would expect a diagnostic to be issued if 
> > > > trigraphs are enabled and the buffer contains a trigraph sequence. 
> > > > Something like:
> > > >   \N{LOTUS??>}
> > > I can try to add tests
> > > 
> > > > My concern is that, as is, the code always takes the else branch 
> > > > (except when Result is non-null). 
> > > Yes, the if branch sole purpose is to set some state in Result.
> > > 
> > > At the start of the function, StartPtr points to `\`
> > > And I'll leave a comment, maybe that will clear up future confusions
> > > 
> > > There may be a potential refactor here, which is to have 
> > > `getAndAdvanceChar` take a `bool & ShouldCleanupToken` parameter instead 
> > > of a token so that we don't have to do that dance, but it's a bit outside 
> > > of the scope of this patch...
> > > At the start of the function, StartPtr points to `\`
> > 
> > It doesn't look like it does. The first use of `StartPtr` is at line 3314 
> > and it expects to read `N`:
> >   3314:   char C = getCharAndSize(StartPtr, CharSize);
> >   3315:   assert(C == 'N' && "expected \\N{...}");
> Yes, you are right. There was a bug in \u too, probably 

[PATCH] D138861: [Clang] Implement CWG2640 Allow more characters in an n-char sequence

2022-12-12 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

@cor3ntin, I suspect the answer is no, but do your changes perhaps address this 
assertion failure? https://godbolt.org/z/1bPcPcWzv

  int \u1{234};

Stack dump:

  clang++: /root/llvm-project/clang/lib/Lex/LiteralSupport.cpp:382: void 
clang::expandUCNs(llvm::SmallVectorImpl&, llvm::StringRef): Assertion 
`Value != -1U' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: 
/opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o 
/app/output.s -mllvm --x86-asm-syntax=intel -S 
--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics 
-fno-crash-diagnostics -std=c++20 
  1.:1:5: current parser token '\u1{234}'
   #0 0x564e3c70a2bf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe12bf)
   #1 0x564e3c70826c llvm::sys::CleanupOnSignal(unsigned long) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fdf26c)
   #2 0x564e3c645468 CrashRecoverySignalHandler(int) 
CrashRecoveryContext.cpp:0:0
   #3 0x7f19aebf0420 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
   #4 0x7f19ae6bd00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
   #5 0x7f19ae69c859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
   #6 0x7f19ae69c729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
   #7 0x7f19ae6adfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
   #8 0x564e4055e8b3 clang::expandUCNs(llvm::SmallVectorImpl&, 
llvm::StringRef) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e358b3)
   #9 0x564e405dd531 
clang::Preprocessor::LookUpIdentifierInfo(clang::Token&) const 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7eb4531)
  #10 0x564e4055646c clang::Lexer::LexIdentifierContinue(clang::Token&, 
char const*) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e2d46c)
  #11 0x564e4055993d clang::Lexer::LexTokenInternal(clang::Token&, bool) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e3093d)
  #12 0x564e4055b1c3 clang::Lexer::Lex(clang::Token&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e321c3)
  #13 0x564e405e0297 clang::Preprocessor::Lex(clang::Token&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7eb7297)
  #14 0x564e3ed354d2 clang::Parser::ConsumeToken() 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x660c4d2)
  #15 0x564e3ed673a3 
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, 
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, 
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, 
clang::ImplicitTypenameContext) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x663e3a3)
  #16 0x564e3ed3814b 
clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x660f14b)
  #17 0x564e3ed38a6f 
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) 
(.part.0) Parser.cpp:0:0
  #18 0x564e3ed3ed59 
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6615d59)
  #19 0x564e3ed3f6ad 
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, 
clang::Sema::ModuleImportState&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66166ad)
  #20 0x564e3ed3fb54 
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, 
clang::Sema::ModuleImportState&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6616b54)
  #21 0x564e3ed335ba clang::ParseAST(clang::Sema&, bool, bool) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x660a5ba)
  #22 0x564e3da51088 clang::CodeGenAction::ExecuteAction() 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5328088)
  #23 0x564e3d2d6599 clang::FrontendAction::Execute() 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bad599)
  #24 0x564e3d25ca9e 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b33a9e)
  #25 0x564e3d3bbf43 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c92f43)
  #26 0x564e39bddf44 cc1_main(llvm::ArrayRef, char const*, 
void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x14b4f44)
  #27 0x564e39bda027 ExecuteCC1Tool(llvm::SmallVectorImpl&) 
driver.cpp:0:0
  #28 0x564e3d0c6829 void llvm::function_ref::callback_fn>,
 std::__cxx11::basic_string, 
std::allo

[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-12 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 482158.
tianshilei1992 added a comment.

add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

Files:
  openmp/cmake/OpenMPTesting.cmake
  openmp/libomptarget/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
  openmp/libomptarget/test/lit.cfg

Index: openmp/libomptarget/test/lit.cfg
===
--- openmp/libomptarget/test/lit.cfg
+++ openmp/libomptarget/test/lit.cfg
@@ -34,6 +34,15 @@
 else:
 config.environment[name] = value
 
+# Evalute the environment variable which is a string boolean value.
+def evaluate_bool_env(env):
+env = env.lower()
+possible_true_values = ["on", "true", "1"]
+for v in possible_true_values:
+if env == v:
+return True
+return False
+
 # name: The name of this test suite.
 config.name = 'libomptarget :: ' + config.libomptarget_current_target
 
@@ -111,10 +120,17 @@
 config.test_flags += " --libomptarget-nvptx-bc-path=" + config.library_dir
 if config.libomptarget_current_target.endswith('-LTO'):
 config.test_flags += " -foffload-lto"
+if config.libomptarget_current_target.endswith('-JIT-LTO') and evaluate_bool_env(
+config.environment['LIBOMPTARGET_NEXTGEN_PLUGINS']
+):
+config.test_flags += " -foffload-lto"
+config.test_flags += " -Wl,--embed-bitcode"
 
 def remove_suffix_if_present(name):
 if name.endswith('-LTO'):
 return name[:-4]
+elif name.endswith('-JIT-LTO'):
+return name[:-8]
 else:
 return name
 
Index: openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
@@ -358,6 +358,10 @@
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 return true;
   }
+
+  Triple::ArchType getTripleArch() const override {
+return Triple::LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE;
+  }
 };
 
 GenericPluginTy *Plugin::createPlugin() { return new GenELF64PluginTy(); }
Index: openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -278,6 +278,14 @@
  GridValues.GV_Warp_Size))
   return Err;
 
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
+ ComputeCapability.Major))
+  return Err;
+
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
+ ComputeCapability.Minor))
+  return Err;
+
 return Plugin::success();
   }
 
@@ -776,6 +784,8 @@
 return Plugin::check(Res, "Error in cuDeviceGetAttribute: %s");
   }
 
+  std::string getArch() const override { return ComputeCapability.str(); }
+
 private:
   using CUDAStreamManagerTy = GenericDeviceResourceManagerTy;
   using CUDAEventManagerTy = GenericDeviceResourceManagerTy;
@@ -792,6 +802,15 @@
 
   /// The CUDA device handler.
   CUdevice Device = CU_DEVICE_INVALID;
+
+  ///
+  struct ComputeCapabilityTy {
+uint32_t Major;
+uint32_t Minor;
+std::string str() const {
+  return "sm_" + std::to_string(Major * 10 + Minor);
+}
+  } ComputeCapability;
 };
 
 Error CUDAKernelTy::launchImpl(GenericDeviceTy &GenericDevice,
@@ -890,6 +909,11 @@
   /// Get the ELF code for recognizing the compatible image binary.
   uint16_t getMagicElfBits() const override { return ELF::EM_CUDA; }
 
+  Triple::ArchType getTripleArch() const override {
+// TODO: I think we can drop the support for 32-bit NVPTX devices.
+return Triple::nvptx64;
+  }
+
   /// Check whether the image is compatible with the available CUDA devices.
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 for (int32_t DevId = 0; DevId < getNumDevices(); ++DevId) {
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
+++ openmp/libomptarget/plugins-nextgen/commo

[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This LG, but not accepting as I believe libc++ is still broken if built with 
modules, right?
I have run `check-cxx` locally and it seems to work, but I suspect that's not 
using modules by default. I have clicked through the links in phrabricator and 
the errors seem to come from the latest uploaded diff.
Let me know if I'm missing something.




Comment at: clang/lib/Sema/SemaInit.cpp:5380
+  }
+  InitExprs.push_back(ER.get());
+}

ayzhao wrote:
> ilya-biryukov wrote:
> > ayzhao wrote:
> > > ayzhao wrote:
> > > > So the libc++ test compile failures are due to this line.
> > > > 
> > > > One example of a failing unit test is 
> > > > [range.take.while/ctor.view.pass](https://github.com/llvm/llvm-project/blob/main/libcxx/test/std/ranges/range.adaptors/range.take.while/ctor.view.pass.cpp).
> > > >  Clang calls this function twice in `TreeTransform.h` - once with 
> > > > `VerifyOnly` set to `true`, once with it set to `false`.
> > > > 
> > > > For some reason, when this function tries to value-initialize the 
> > > > member `MoveOnly mo` in `View`, `Seq.Failed()` returns false after 
> > > > `TryValueInitialization(...)`, but the resulting `ExprResult` is 
> > > > `nullptr`, causing the segfault we see when we push `nullptr` to 
> > > > `InitExprs` and pass `InitExprs` to the constructor of 
> > > > `CXXParenListInitExpr`. One way to be fix this is to move the line 
> > > > `ExprResult ER = Seq.Perform(...)` out of the `if (!VerifyOnly)` block 
> > > > and check for `ER.isInvalid()` instead of `Seq.Failed()`, but that 
> > > > results in test failures due to excess diagnostic messages in 
> > > > `Seq.Perform(...)`
> > > > 
> > > > I'm still looking into this, but if anyone has any ideas, they would be 
> > > > very welcome.
> > > > 
> > > > To repro the buildbot failures, just build clang with this patch, and 
> > > > then in a separate build directory, build the target `check-cxx` using 
> > > > the previously built clang.
> > > I was able to get the above workaround to pass the test by clearing the 
> > > diagnostics after calling `Seq.Perform(...)`.
> > > 
> > > IMO, this should be OK for now, but I'm open to better ideas if anyone 
> > > has any.
> > Clearing all the diagnostics is a nuclear options and definitely seems off 
> > here. We should not call `Perform()` when `VerifyOnly` is `true` to avoid 
> > producing the diagnostics in the first place.
> > 
> > It's fine for the call with `VerifyOnly = true` to return no errors and 
> > later produce diagnostics with `VerifyOnly = false`, I believe this is what 
> > `InitListChecker` is already doing.
> > I have been playing around with the old version of the code, but couldn't 
> > fix it fully. I do have a small example that breaks, we should add it to 
> > the test and it should also be easier to understand what's going on:
> > 
> > ```
> > struct MoveOnly
> > {
> >   MoveOnly(int data = 1);
> >   MoveOnly(const MoveOnly&) = delete;
> >   MoveOnly(MoveOnly&&) = default;
> > };
> > 
> > struct View {
> >   int a;
> >   MoveOnly mo;
> > };
> > 
> > void test() {
> >   View{0};
> >   View(0); // should work, but crashes and produces invalid diagnostics.
> > }
> > ```
> > 
> > In general, my approach would be to try mimicing what `InitListChecker` is 
> > doing as much as possible, trimming all the unnecessary complexity that 
> > braced-init-lists entail.
> > Hope it's helpful.
> So it looks like all I had to do was remove the call to 
> `TryValueInitialization(...)` and just check for `Seq.Failed()`. This is also 
> what we do in `InitListChecker`.
> 
> The `check-cxx` target appears to work for me locally, so fingers crossed 
> that the build passes.
> 
> >  I do have a small example that breaks, we should add it to the test and it 
> > should also be easier to understand what's going on:
> 
> Done.
Good catch! I have also noticed that `TryValueInitialization` is missing in 
`InitListChecker`, but somehow thought it's just doing the same thing without 
reusing the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Since the errors only shows up in modular builds, I would look closely for bugs 
inside `ASTReader`/`ASTWriter`. 
Also, it seems that `ArrayFiller` is not taken in to account in 
`computeDependence` and maybe it should be. This assumption is wrong if 
`ArrayFiller` is only used for non-dependent code and it also does not explain 
the variation between modular and non-modular builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[PATCH] D139287: [OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-12 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 482168.
tianshilei1992 added a comment.

add env for opt level


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

Files:
  openmp/cmake/OpenMPTesting.cmake
  openmp/libomptarget/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
  openmp/libomptarget/test/lit.cfg

Index: openmp/libomptarget/test/lit.cfg
===
--- openmp/libomptarget/test/lit.cfg
+++ openmp/libomptarget/test/lit.cfg
@@ -34,6 +34,15 @@
 else:
 config.environment[name] = value
 
+# Evalute the environment variable which is a string boolean value.
+def evaluate_bool_env(env):
+env = env.lower()
+possible_true_values = ["on", "true", "1"]
+for v in possible_true_values:
+if env == v:
+return True
+return False
+
 # name: The name of this test suite.
 config.name = 'libomptarget :: ' + config.libomptarget_current_target
 
@@ -111,10 +120,17 @@
 config.test_flags += " --libomptarget-nvptx-bc-path=" + config.library_dir
 if config.libomptarget_current_target.endswith('-LTO'):
 config.test_flags += " -foffload-lto"
+if config.libomptarget_current_target.endswith('-JIT-LTO') and evaluate_bool_env(
+config.environment['LIBOMPTARGET_NEXTGEN_PLUGINS']
+):
+config.test_flags += " -foffload-lto"
+config.test_flags += " -Wl,--embed-bitcode"
 
 def remove_suffix_if_present(name):
 if name.endswith('-LTO'):
 return name[:-4]
+elif name.endswith('-JIT-LTO'):
+return name[:-8]
 else:
 return name
 
Index: openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
@@ -358,6 +358,10 @@
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 return true;
   }
+
+  Triple::ArchType getTripleArch() const override {
+return Triple::LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE;
+  }
 };
 
 GenericPluginTy *Plugin::createPlugin() { return new GenELF64PluginTy(); }
Index: openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -278,6 +278,14 @@
  GridValues.GV_Warp_Size))
   return Err;
 
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
+ ComputeCapability.Major))
+  return Err;
+
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
+ ComputeCapability.Minor))
+  return Err;
+
 return Plugin::success();
   }
 
@@ -776,6 +784,8 @@
 return Plugin::check(Res, "Error in cuDeviceGetAttribute: %s");
   }
 
+  std::string getArch() const override { return ComputeCapability.str(); }
+
 private:
   using CUDAStreamManagerTy = GenericDeviceResourceManagerTy;
   using CUDAEventManagerTy = GenericDeviceResourceManagerTy;
@@ -792,6 +802,15 @@
 
   /// The CUDA device handler.
   CUdevice Device = CU_DEVICE_INVALID;
+
+  ///
+  struct ComputeCapabilityTy {
+uint32_t Major;
+uint32_t Minor;
+std::string str() const {
+  return "sm_" + std::to_string(Major * 10 + Minor);
+}
+  } ComputeCapability;
 };
 
 Error CUDAKernelTy::launchImpl(GenericDeviceTy &GenericDevice,
@@ -890,6 +909,11 @@
   /// Get the ELF code for recognizing the compatible image binary.
   uint16_t getMagicElfBits() const override { return ELF::EM_CUDA; }
 
+  Triple::ArchType getTripleArch() const override {
+// TODO: I think we can drop the support for 32-bit NVPTX devices.
+return Triple::nvptx64;
+  }
+
   /// Check whether the image is compatible with the available CUDA devices.
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 for (int32_t DevId = 0; DevId < getNumDevices(); ++DevId) {
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
+++ openmp/libomptarget/plugins-

[PATCH] D139287: [OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-12 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked an inline comment as done and an inline comment as not 
done.
tianshilei1992 added inline comments.



Comment at: openmp/cmake/OpenMPTesting.cmake:6
 function(find_standalone_test_dependencies)
-  include(FindPythonInterp)
+  find_package(Python3 COMPONENTS Interpreter Development)
 

Oh, this change is unrelated. Will remove it later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


  1   2   3   >