[clang] 1d7f9ce - [clang][dataflow] Don't crash when creating pointers to members.

2023-06-29 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-06-29T07:12:55Z
New Revision: 1d7f9ce61f6e689ca63df2e36808885c873cf80b

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

LOG: [clang][dataflow] Don't crash when creating pointers to members.

The newly added tests crash without the other changes in this patch.

Reviewed By: sammccall, xazax.hun, gribozavr2

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 651930f0dd22b..5ad176dc1cdbe 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -231,6 +231,15 @@ class TransferVisitor : public 
ConstStmtVisitor {
   void VisitDeclRefExpr(const DeclRefExpr *S) {
 const ValueDecl *VD = S->getDecl();
 assert(VD != nullptr);
+
+// `DeclRefExpr`s to fields and non-static methods aren't glvalues, and
+// there's also no sensible `Value` we can assign to them, so skip them.
+if (isa(VD))
+  return;
+if (auto *Method = dyn_cast(VD);
+Method && !Method->isStatic())
+  return;
+
 auto *DeclLoc = Env.getStorageLocation(*VD);
 if (DeclLoc == nullptr)
   return;
@@ -397,8 +406,7 @@ class TransferVisitor : public 
ConstStmtVisitor {
   propagateValueOrStorageLocation(*SubExpr, *S, Env);
   break;
 }
-case CK_NullToPointer:
-case CK_NullToMemberPointer: {
+case CK_NullToPointer: {
   auto &Loc = Env.createStorageLocation(S->getType());
   Env.setStorageLocation(*S, Loc);
 
@@ -407,6 +415,10 @@ class TransferVisitor : public 
ConstStmtVisitor {
   Env.setValue(Loc, NullPointerVal);
   break;
 }
+case CK_NullToMemberPointer:
+  // FIXME: Implement pointers to members. For now, don't associate a value
+  // with this expression.
+  break;
 case CK_FunctionToPointerDecay:
 case CK_BuiltinFnToFnPtr: {
   StorageLocation *PointeeLoc =
@@ -440,14 +452,12 @@ class TransferVisitor : public 
ConstStmtVisitor {
   break;
 }
 case UO_AddrOf: {
-  // Do not form a pointer to a reference. If `SubExpr` is assigned a
-  // `ReferenceValue` then form a value that points to the location of its
-  // pointee.
-  StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr);
-  if (PointeeLoc == nullptr)
+  // FIXME: Model pointers to members.
+  if (S->getType()->isMemberPointerType())
 break;
 
-  Env.setValueStrict(*S, Env.create(*PointeeLoc));
+  if (StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr))
+Env.setValueStrict(*S, Env.create(*PointeeLoc));
   break;
 }
 case UO_LNot: {

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 5d2a82b581f3b..210b85f7ae8d6 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2530,10 +2530,56 @@ TEST(TransferTest, NullToPointerCast) {
   });
 }
 
+TEST(TransferTest, PointerToMemberVariable) {
+  std::string Code = R"(
+struct S {
+  int i;
+};
+void target() {
+  int S::*MemberPointer = &S::i;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *MemberPointerDecl =
+findValueDecl(ASTCtx, "MemberPointer");
+ASSERT_THAT(MemberPointerDecl, NotNull());
+ASSERT_THAT(Env.getValue(*MemberPointerDecl), IsNull());
+  });
+}
+
+TEST(TransferTest, PointerToMemberFunction) {
+  std::string Code = R"(
+struct S {
+  void Method();
+};
+void target() {
+  void (S::*MemberPointer)() = &S::Method;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *MemberPointerDecl =
+findValueDecl(ASTCtx, "MemberPointer");
+ASSERT_THAT(MemberPointerDecl, NotNull());
+ASSERT_THAT(Env.getValue(*MemberPointerDecl), IsNull());
+  });
+}
+
 TEST(TransferTest, NullToMemberPointerCast) {
   std::string Code = R"(
 struct Foo {};
-void target(Foo *Foo) {
+void target() {
   int Foo::*MemberPointer = nullptr;
   // [[p]]
 }
@@ -2548,12 +2594,7 @@ TEST(TransferTest, NullToMemberPointerCast) {

[PATCH] D153960: [clang][dataflow] Don't crash when creating pointers to members.

2023-06-29 Thread Martin Böhme 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 rG1d7f9ce61f6e: [clang][dataflow] Don't crash when 
creating pointers to members. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153960

Files:
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2530,10 +2530,56 @@
   });
 }
 
+TEST(TransferTest, PointerToMemberVariable) {
+  std::string Code = R"(
+struct S {
+  int i;
+};
+void target() {
+  int S::*MemberPointer = &S::i;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *MemberPointerDecl =
+findValueDecl(ASTCtx, "MemberPointer");
+ASSERT_THAT(MemberPointerDecl, NotNull());
+ASSERT_THAT(Env.getValue(*MemberPointerDecl), IsNull());
+  });
+}
+
+TEST(TransferTest, PointerToMemberFunction) {
+  std::string Code = R"(
+struct S {
+  void Method();
+};
+void target() {
+  void (S::*MemberPointer)() = &S::Method;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *MemberPointerDecl =
+findValueDecl(ASTCtx, "MemberPointer");
+ASSERT_THAT(MemberPointerDecl, NotNull());
+ASSERT_THAT(Env.getValue(*MemberPointerDecl), IsNull());
+  });
+}
+
 TEST(TransferTest, NullToMemberPointerCast) {
   std::string Code = R"(
 struct Foo {};
-void target(Foo *Foo) {
+void target() {
   int Foo::*MemberPointer = nullptr;
   // [[p]]
 }
@@ -2548,12 +2594,7 @@
 const ValueDecl *MemberPointerDecl =
 findValueDecl(ASTCtx, "MemberPointer");
 ASSERT_THAT(MemberPointerDecl, NotNull());
-
-const auto *MemberPointerVal =
-cast(Env.getValue(*MemberPointerDecl));
-
-const StorageLocation &MemberLoc = MemberPointerVal->getPointeeLoc();
-EXPECT_THAT(Env.getValue(MemberLoc), IsNull());
+ASSERT_THAT(Env.getValue(*MemberPointerDecl), IsNull());
   });
 }
 
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -231,6 +231,15 @@
   void VisitDeclRefExpr(const DeclRefExpr *S) {
 const ValueDecl *VD = S->getDecl();
 assert(VD != nullptr);
+
+// `DeclRefExpr`s to fields and non-static methods aren't glvalues, and
+// there's also no sensible `Value` we can assign to them, so skip them.
+if (isa(VD))
+  return;
+if (auto *Method = dyn_cast(VD);
+Method && !Method->isStatic())
+  return;
+
 auto *DeclLoc = Env.getStorageLocation(*VD);
 if (DeclLoc == nullptr)
   return;
@@ -397,8 +406,7 @@
   propagateValueOrStorageLocation(*SubExpr, *S, Env);
   break;
 }
-case CK_NullToPointer:
-case CK_NullToMemberPointer: {
+case CK_NullToPointer: {
   auto &Loc = Env.createStorageLocation(S->getType());
   Env.setStorageLocation(*S, Loc);
 
@@ -407,6 +415,10 @@
   Env.setValue(Loc, NullPointerVal);
   break;
 }
+case CK_NullToMemberPointer:
+  // FIXME: Implement pointers to members. For now, don't associate a value
+  // with this expression.
+  break;
 case CK_FunctionToPointerDecay:
 case CK_BuiltinFnToFnPtr: {
   StorageLocation *PointeeLoc =
@@ -440,14 +452,12 @@
   break;
 }
 case UO_AddrOf: {
-  // Do not form a pointer to a reference. If `SubExpr` is assigned a
-  // `ReferenceValue` then form a value that points to the location of its
-  // pointee.
-  StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr);
-  if (PointeeLoc == nullptr)
+  // FIXME: Model pointers to members.
+  if (S->getType()->isMemberPointerType())
 break;
 
-  Env.setValueStrict(*S, Env.create(*PointeeLoc));
+  if (StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr))
+Env.setValueStrict(*S, Env.create(*PointeeLoc));
   break;
 }
 case UO_LNot: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151730: [RISCV] Support target attribute for function

2023-06-29 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 535653.
BeMg added a comment.

Use getTargetFeatureForExtension instead of isSupportExtension


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151730

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/RISCV/riscv-func-attr-target.c
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll

Index: llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll
@@ -0,0 +1,81 @@
+; RUN: llc -mtriple=riscv64 -mattr=+a,+d,+f,+m -verify-machineinstrs < %s | FileCheck %s
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test1() #0 {
+; CHECK-LABEL: test1
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test2() #1 {
+; CHECK-LABEL: test2
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test3() #1 {
+; CHECK-LABEL: test3
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test4() #2 {
+; CHECK-LABEL: test4
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +experimental-zihintntl, +zifencei
+define void @test5() #3 {
+; CHECK-LABEL: test5
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +zifencei
+define void @test7() #4 {
+; CHECK-LABEL: test7
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test9() #6 {
+; CHECK-LABEL: test9
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test10() #7 {
+; CHECK-LABEL: test10
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv64" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smaia,-experimental-ssaia,-experimental-zca,-experimental-zcb,-experimental-zcd,-experimental-zcf,-experimental-zcmp,-experimental-zcmt,-experimental-zfa,-experimental-zfbfmin,-experimental-zicond,-experimental-zihintntl,-experimental-ztso,-experimental-zvbb,-experimental-zvbc,-experimental-zvfbfmin,-experimental-zvfbfwma,-experimental-zvfh,-experimental-zvkg,-experimental-zvkn,-experimental-zvkned,-experimental-zvkng,-experimental-zvknha,-experimental-zvknhb,-experimental-zvks,-experimental-zvksed,-experimental-zvksg,-experimental-zvksh,-experimental-zvkt,-h,-save-restore,-svinval,-svnapot,-svpbmt,-xsfvcp,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zdinx,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zicbom,-zicbop,-zicboz,-zicntr,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b" }
+attributes #1 = { noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv64" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+zicsr,+zifencei,-e,-experimental-smaia,-experimental-ssaia,-experimental-zca,-experimental-zcb,-experimental-zcd,-experimental-zcf,-experimental-zcmp,-experimental-zcmt,-experimental-zfa,-experimental-zfbfmin,-experimental-zicond,-experimental-zihintntl,-experimental-ztso,-experimental-zvbb,-experimental-zvbc,-experimental-zvfbfmin,-experimental-zvfbfwma,-experimental-zvfh,-experimental-zvkg,-experimental-zvkn,-experimental-zvkned,-experimental-zvkng,-experimental-zvknha,-experimental-zvknhb,-experimental-zvks,-experimental-zvksed,-experimental-zvksg,-experimental-zvksh,-experimental-zvkt,-h,-save-restore,-svinval,-svnapot,-svpbmt,-v,-xsfvcp,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zdinx,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zicbom,-zicbop,-zicboz,-zicntr,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zve32f,-

[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

2023-06-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 535655.
balazske marked 3 inline comments as done.
balazske added a comment.

Fixed review issues.
Note tag is added for `fread`.
Notes contain now the function name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

Files:
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/errno-stdlibraryfunctions-notes.c
  clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-path-notes.c
  clang/test/Analysis/stream-errno-note.c
  clang/test/Analysis/stream-note.c

Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -7,11 +7,13 @@
 
 void check_note_at_correct_open(void) {
   FILE *F1 = tmpfile(); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'tmpfile' is successful}}
   if (!F1)
 // expected-note@-1 {{'F1' is non-null}}
 // expected-note@-2 {{Taking false branch}}
 return;
   FILE *F2 = tmpfile();
+  // stdargs-note@-1 {{'tmpfile' is successful}}
   if (!F2) {
 // expected-note@-1 {{'F2' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -20,6 +22,7 @@
   }
   rewind(F2);
   fclose(F2);
+  // stdargs-note@-1 {{'fclose' fails}}
   rewind(F1);
 }
 // expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
@@ -27,6 +30,7 @@
 
 void check_note_fopen(void) {
   FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
   if (!F)
 // expected-note@-1 {{'F' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -37,11 +41,13 @@
 
 void check_note_freopen(void) {
   FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
   if (!F)
 // expected-note@-1 {{'F' is non-null}}
 // expected-note@-2 {{Taking false branch}}
 return;
   F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
+  // stdargs-note@-1 {{'freopen' is successful}}
   if (!F)
 // expected-note@-1 {{'F' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -52,6 +58,8 @@
 
 void check_note_leak_2(int c) {
   FILE *F1 = fopen("foo1.c", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
+  // stdargs-note@-2 {{'fopen' is successful}}
   if (!F1)
 // expected-note@-1 {{'F1' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -59,6 +67,8 @@
 // expected-note@-4 {{Taking false branch}}
 return;
   FILE *F2 = fopen("foo2.c", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
+  // stdargs-note@-2 {{'fopen' is successful}}
   if (!F2) {
 // expected-note@-1 {{'F2' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -84,6 +94,7 @@
 void check_track_null(void) {
   FILE *F;
   F = fopen("foo1.c", "r"); // expected-note {{Value assigned to 'F'}} expected-note {{Assuming pointer value is null}}
+  // stdargs-note@-1 {{'fopen' fails}}
   if (F != NULL) {  // expected-note {{Taking false branch}} expected-note {{'F' is equal to NULL}}
 fclose(F);
 return;
@@ -96,13 +107,16 @@
   FILE *F;
   char Buf[10];
   F = fopen("foo1.c", "r");
+  // stdargs-note@-1 {{'fopen' is successful}}
   if (F == NULL) { // expected-note {{Taking false branch}} expected-note {{'F' is not equal to NULL}}
 return;
   }
   fread(Buf, 1, 1, F);
+  // stdargs-note@-1 {{'fread' fails}}
   if (feof(F)) { // expected-note {{Taking true branch}}
 clearerr(F);
 fread(Buf, 1, 1, F);   // expected-note {{Assuming stream reaches end-of-file here}}
+// stdargs-note@-1 {{'fread' fails}}
 if (feof(F)) { // expected-note {{Taking true branch}}
   fread(Buf, 1, 1, F); // expected-warning {{Read function called when stream is in EOF state. Function has no effect}}
   // expected-note@-1 {{Read function called when stream is in EOF state. Function has no effect}}
@@ -115,10 +129,12 @@
   FILE *F;
   char Buf[10];
   F = fopen("foo1.c", "r");
+  // stdargs-note@-1 {{'fopen' is successful}}
   if (F == NULL) { // expected-note {{Taking false branch}} expected-note {{'F' is not equal to NULL}}
 return;
   }
   fread(Buf, 1, 1, F);
+  // stdargs-note@-1 {{'fread' is successful}}
   if (feof(F)) { // expected-note {{Taking false branch}}
 fclose(F);
 return;
@@ -127,6 +143,7 @@
 return;
   }
   fread(Buf, 1, 1, F);   // expected-note {{Assuming stream reaches end-of-file here}}
+  // stdargs-note@-1 {{'fread' fails}}
   if (feof(F)) { // expected-

[libunwind] 9e37142 - [libunwind] Add cached compile and link flags to libunwind

2023-06-29 Thread via cfe-commits

Author: mgrzywac
Date: 2023-06-29T07:41:08Z
New Revision: 9e37142dc12a7d57a793db56ea5fd259171fe20a

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

LOG: [libunwind] Add cached compile and link flags to libunwind

Add flags allowing to use compile flags and libraries provided in cache with 
libunwind.
Similar flags are already present in libc++ and libc++abi CMakeLists files.

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

Added: 


Modified: 
libunwind/CMakeLists.txt
libunwind/src/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index bd49dfbe53b37..bc2a820fe98eb 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -143,6 +143,10 @@ set(LIBUNWIND_C_FLAGS "")
 set(LIBUNWIND_CXX_FLAGS "")
 set(LIBUNWIND_COMPILE_FLAGS "")
 set(LIBUNWIND_LINK_FLAGS "")
+set(LIBUNWIND_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING
+"Additional Compile only flags which can be provided in cache")
+set(LIBUNWIND_ADDITIONAL_LIBRARIES "" CACHE STRING
+"Additional libraries libunwind is linked to which can be provided in 
cache")
 
 # Include macros for adding and removing libunwind flags.
 include(HandleLibunwindFlags)

diff  --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 6a9572f6cadf0..e5897fedd2125 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -132,6 +132,8 @@ else()
   target_compile_options(unwind_shared_objects PRIVATE -fno-rtti)
 endif()
 target_link_libraries(unwind_shared_objects PRIVATE unwind-headers 
${LIBUNWIND_LIBRARIES})
+target_compile_options(unwind_shared_objects PUBLIC 
"${LIBUNWIND_ADDITIONAL_COMPILE_FLAGS}")
+target_link_libraries(unwind_shared_objects PUBLIC 
"${LIBUNWIND_ADDITIONAL_LIBRARIES}")
 set_target_properties(unwind_shared_objects
   PROPERTIES
 CXX_EXTENSIONS OFF
@@ -170,6 +172,8 @@ else()
   target_compile_options(unwind_static_objects PRIVATE -fno-rtti)
 endif()
 target_link_libraries(unwind_static_objects PRIVATE unwind-headers 
${LIBUNWIND_LIBRARIES})
+target_compile_options(unwind_static_objects PUBLIC 
"${LIBUNWIND_ADDITIONAL_COMPILE_FLAGS}")
+target_link_libraries(unwind_static_objects PUBLIC 
"${LIBUNWIND_ADDITIONAL_LIBRARIES}")
 set_target_properties(unwind_static_objects
   PROPERTIES
 CXX_EXTENSIONS OFF



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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-29 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe marked an inline comment as done.
FreddyYe added inline comments.



Comment at: clang/test/CodeGen/attr-cpuspecific.c:56
 // WINDOWS: %[[FEAT_INIT:.+]] = load i32, ptr getelementptr inbounds ({ i32, 
i32, i32, [1 x i32] }, ptr @__cpu_model, i32 0, i32 3, i32 0), align 4
-// WINDOWS: %[[FEAT_JOIN:.+]] = and i32 %[[FEAT_INIT]], 1023
-// WINDOWS: %[[FEAT_CHECK:.+]] = icmp eq i32 %[[FEAT_JOIN]], 1023
+// WINDOWS: %[[FEAT_JOIN:.+]] = and i32 %[[FEAT_INIT]], 525311
+// WINDOWS: %[[FEAT_CHECK:.+]] = icmp eq i32 %[[FEAT_JOIN]], 525311

pengfei wrote:
> FreddyYe wrote:
> > This value change is because the feature list of knl described in 
> > X86TargetParser.def before missed feature "bmi2" and "aes".
> The comment is for TwoVersions?
Yes. Sorry for wrong point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D153957: [C++20] [Modules] Allow Stmt::Profile to treat lambdas as equal conditionally

2023-06-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 535664.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D153957

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/test/Modules/merge-requires-with-lambdas.cppm
  clang/test/Modules/pr63544.cppm

Index: clang/test/Modules/pr63544.cppm
===
--- /dev/null
+++ clang/test/Modules/pr63544.cppm
@@ -0,0 +1,88 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-module-interface -o %t/m-a.pcm
+// RUN: %clang_cc1 -std=c++23 %t/b.cppm -emit-module-interface -o %t/m-b.pcm
+// RUN: %clang_cc1 -std=c++23 %t/m.cppm -emit-module-interface -o %t/m.pcm \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++23 %t/pr63544.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
+
+//--- foo.h
+
+namespace std {
+struct strong_ordering {
+  int n;
+  constexpr operator int() const { return n; }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+} // namespace std
+
+namespace std {
+template 
+class optional {
+private:
+using value_type = _Tp;
+value_type __val_;
+bool __engaged_;
+public:
+constexpr bool has_value() const noexcept
+{
+return this->__engaged_;
+}
+
+constexpr const value_type& operator*() const& noexcept
+{
+return __val_;
+}
+
+optional(_Tp v) : __val_(v) {
+__engaged_ = true;
+}
+};
+
+template 
+concept __is_derived_from_optional = requires(const _Tp& __t) { [](const optional<__Up>&) {}(__t); };
+
+template 
+requires(!__is_derived_from_optional<_Up>)
+constexpr strong_ordering
+operator<=>(const optional<_Tp>& __x, const _Up& __v) {
+return __x.has_value() ? *__x <=> __v : strong_ordering::less;
+}
+} // namespace std
+
+//--- a.cppm
+module;
+#include "foo.h"
+export module m:a;
+export namespace std {
+using std::optional;
+using std::operator<=>;
+}
+
+//--- b.cppm
+module;
+#include "foo.h"
+export module m:b;
+export namespace std {
+using std::optional;
+using std::operator<=>;
+}
+
+//--- m.cppm
+export module m;
+export import :a;
+export import :b;
+
+//--- pr63544.cpp
+// expected-no-diagnostics
+import m;
+int pr63544() {
+std::optional a(43);
+int t{3};
+return a<=>t;
+}
Index: clang/test/Modules/merge-requires-with-lambdas.cppm
===
--- /dev/null
+++ clang/test/Modules/merge-requires-with-lambdas.cppm
@@ -0,0 +1,100 @@
+// Tests that we can merge the concept declarations with lambda well.
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
+// RUN: %clang_cc1 -std=c++20 %t/A0.cppm -emit-module-interface -o %t/A0.pcm
+// RUN: %clang_cc1 -std=c++20 %t/TestA.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
+//
+// RUN: %clang_cc1 -std=c++20 %t/A1.cppm -emit-module-interface -o %t/A1.pcm
+// RUN: %clang_cc1 -std=c++20 %t/TestA1.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
+//
+// RUN: %clang_cc1 -std=c++20 %t/A2.cppm -emit-module-interface -o %t/A2.pcm
+// RUN: %clang_cc1 -std=c++20 %t/TestA2.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
+//
+// RUN: %clang_cc1 -std=c++20 %t/A3.cppm -emit-module-interface -o %t/A3.pcm
+// RUN: %clang_cc1 -std=c++20 %t/TestA3.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
+
+//--- A.h
+template 
+concept A = requires(const _Tp& __t) { [](const __Up&) {}(__t); };
+
+//--- A1.h
+template 
+concept A = requires(const _Tp& __t) { [](__Up) {}(__t); };
+
+//--- A2.h
+template 
+concept A = requires(const _Tp& __t) { [](const __Up& __u) {
+(int)__u;
+}(__t); };
+
+//--- A3.h
+template 
+concept A = requires(const _Tp& __t) { [t = '?'](const __Up&) {
+(int)t;
+}(__t); };
+
+//--- A.cppm
+module;
+#include "A.h"
+export module A;
+export using ::A;
+
+//--- A0.cppm
+module;
+#include "A.h"
+export module A0;
+export using ::A;
+
+//--- TestA.cpp
+// expected-no-diagnostics
+import A;
+import A0;
+
+template 
+void f(C) requires(A) {}
+
+//--- A1.cppm
+module;
+#include "A1.h"
+export module A1;
+export using ::A;
+
+//--- TestA1.cpp
+import A;
+import A1;
+
+template 
+void f(C) requires(A) {} // expected-error 1+{{reference to 'A' is ambiguous}}
+// expected-note@* 1+{{candidate found by name lookup is 'A'}}
+
+//--- A2.cppm
+module;
+#include "A2.h"
+export module A2;
+export using ::A;
+
+//--- TestA2.cpp
+import A;
+import A2;
+
+template 
+void f(C) requires(A) {} // expected-error 1+{{reference to 'A' is ambiguous}}
+//

[clang] 54c79fa - [test] Replace aarch64-*-eabi with aarch64

2023-06-29 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2023-06-29T09:06:00+01:00
New Revision: 54c79fa53c17a93d3d784738cae52d847102d279

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

LOG: [test] Replace aarch64-*-eabi with aarch64

Also replace aarch64_be-*-eabi with aarch64_be

Using "eabi" for aarch64 targets is a common mistake and warned by Clang Driver.
We want to avoid it elsewhere as well. Just use the common "aarch64" without
other triple components.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
clang/test/CodeGen/aarch64-branch-protection-attr.c
clang/test/CodeGen/codemodels.c
clang/test/CodeGenCXX/bitfield-layout.cpp
clang/test/Driver/aarch64-features.c
clang/test/Driver/aarch64-security-options.c
clang/test/Driver/arm-wchar_t-defaults.c
clang/test/Driver/sls-hardening-options.c
clang/test/Preprocessor/init-arm.c
clang/test/Sema/aarch64-sve-alias-attribute.c
llvm/test/Analysis/MemorySSA/pr43320.ll
llvm/test/CodeGen/AArch64/arm64-aapcs-be.ll
llvm/test/CodeGen/AArch64/arm64-big-endian-varargs.ll
llvm/test/CodeGen/AArch64/arm64-ld-from-st.ll
llvm/test/CodeGen/AArch64/arm64-narrow-st-merge.ll
llvm/test/CodeGen/AArch64/arm64-trn.ll
llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
llvm/test/CodeGen/AArch64/combine-andintoload.ll
llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
llvm/test/CodeGen/AArch64/stack-tagging-ex-2.ll
llvm/test/CodeGen/AArch64/tme.ll
llvm/test/DebugInfo/AArch64/big-endian.ll
llvm/test/MC/AArch64/align.s
llvm/test/MC/AArch64/directive-arch-negative.s
llvm/test/MC/AArch64/directive-arch.s
llvm/test/MC/AArch64/directive-cpu.s
llvm/test/MC/AArch64/directive-variant_pcs-err.s
llvm/test/MC/AArch64/error-location-during-layout.s
llvm/test/MC/AArch64/error-location-ldr-pseudo.s
llvm/test/MC/AArch64/error-location-post-layout.s
llvm/test/MC/AArch64/error-location.s
llvm/test/MC/AArch64/fixup-absolute-signed.s
llvm/test/MC/AArch64/fixup-absolute.s
llvm/test/MC/AArch64/fixup-out-of-range-edge.s
llvm/test/MC/AArch64/fixup-out-of-range.s
llvm/test/Transforms/LoopVectorize/AArch64/maximize-bandwidth-invalidate.ll

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c 
b/clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
index 7f989588eca80e..ccd6d17412a8b4 100644
--- a/clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple aarch64 -target-feature +neon -target-feature +bf16 
\
 // RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -passes=mem2reg | 
FileCheck --check-prefix=CHECK-LE %s
-// RUN: %clang_cc1 -triple aarch64_be-arm-none-eabi -target-feature +neon 
-target-feature +bf16 \
+// RUN: %clang_cc1 -triple aarch64_be -target-feature +neon -target-feature 
+bf16 \
 // RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -passes=mem2reg | 
FileCheck --check-prefix=CHECK-BE %s
 
 // REQUIRES: aarch64-registered-target || arm-registered-target

diff  --git a/clang/test/CodeGen/aarch64-branch-protection-attr.c 
b/clang/test/CodeGen/aarch64-branch-protection-attr.c
index a7f600989b6e69..3c2714e2feda24 100644
--- a/clang/test/CodeGen/aarch64-branch-protection-attr.c
+++ b/clang/test/CodeGen/aarch64-branch-protection-attr.c
@@ -1,5 +1,5 @@
 // REQUIRES: aarch64-registered-target
-// RUN: %clang_cc1 -triple aarch64-unknown-unknown-eabi -emit-llvm  
-target-cpu generic -target-feature +v8.5a %s -o - \
+// RUN: %clang_cc1 -triple aarch64 -emit-llvm  -target-cpu generic 
-target-feature +v8.5a %s -o - \
 // RUN:   | FileCheck %s --check-prefix=CHECK
 
 __attribute__ ((target("branch-protection=none")))

diff  --git a/clang/test/CodeGen/codemodels.c b/clang/test/CodeGen/codemodels.c
index a302016c66d7be..edc1815d475fd4 100644
--- a/clang/test/CodeGen/codemodels.c
+++ b/clang/test/CodeGen/codemodels.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm  %s -o - | FileCheck %s 
-check-prefix=CHECK-NOMODEL
-// RUN: %clang_cc1 -triple aarch64-unknown-none-eabi -emit-llvm -mcmodel=tiny 
%s -o - | FileCheck %s -check-prefix=CHECK-TINY
+// RUN: %clang_cc1 -triple aarch64 -emit-llvm -mcmodel=tiny %s -o - | 
FileCheck %s -check-prefix=CHECK-TINY
 // RUN: %clang_cc1 -emit-llvm -mcmodel=small %s -o - | FileCheck %s 
-check-prefix=CHECK-SMALL
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -mcmodel=kernel 
%s -o - | FileCheck %s -check-prefix=CHE

[PATCH] D153943: [test] Replace aarch64-*-eabi with aarch64

2023-06-29 Thread Michael Platings 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 rG54c79fa53c17: [test] Replace aarch64-*-eabi with aarch64 
(authored by michaelplatings).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153943

Files:
  clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
  clang/test/CodeGen/aarch64-branch-protection-attr.c
  clang/test/CodeGen/codemodels.c
  clang/test/CodeGenCXX/bitfield-layout.cpp
  clang/test/Driver/aarch64-features.c
  clang/test/Driver/aarch64-security-options.c
  clang/test/Driver/arm-wchar_t-defaults.c
  clang/test/Driver/sls-hardening-options.c
  clang/test/Preprocessor/init-arm.c
  clang/test/Sema/aarch64-sve-alias-attribute.c
  llvm/test/Analysis/MemorySSA/pr43320.ll
  llvm/test/CodeGen/AArch64/arm64-aapcs-be.ll
  llvm/test/CodeGen/AArch64/arm64-big-endian-varargs.ll
  llvm/test/CodeGen/AArch64/arm64-ld-from-st.ll
  llvm/test/CodeGen/AArch64/arm64-narrow-st-merge.ll
  llvm/test/CodeGen/AArch64/arm64-trn.ll
  llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
  llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
  llvm/test/CodeGen/AArch64/combine-andintoload.ll
  llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
  llvm/test/CodeGen/AArch64/stack-tagging-ex-2.ll
  llvm/test/CodeGen/AArch64/tme.ll
  llvm/test/DebugInfo/AArch64/big-endian.ll
  llvm/test/MC/AArch64/align.s
  llvm/test/MC/AArch64/directive-arch-negative.s
  llvm/test/MC/AArch64/directive-arch.s
  llvm/test/MC/AArch64/directive-cpu.s
  llvm/test/MC/AArch64/directive-variant_pcs-err.s
  llvm/test/MC/AArch64/error-location-during-layout.s
  llvm/test/MC/AArch64/error-location-ldr-pseudo.s
  llvm/test/MC/AArch64/error-location-post-layout.s
  llvm/test/MC/AArch64/error-location.s
  llvm/test/MC/AArch64/fixup-absolute-signed.s
  llvm/test/MC/AArch64/fixup-absolute.s
  llvm/test/MC/AArch64/fixup-out-of-range-edge.s
  llvm/test/MC/AArch64/fixup-out-of-range.s
  llvm/test/Transforms/LoopVectorize/AArch64/maximize-bandwidth-invalidate.ll

Index: llvm/test/Transforms/LoopVectorize/AArch64/maximize-bandwidth-invalidate.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/maximize-bandwidth-invalidate.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/maximize-bandwidth-invalidate.ll
@@ -4,7 +4,7 @@
 ; RUN: opt < %s -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -debug-only=loop-vectorize 2>&1 -disable-output | FileCheck %s --check-prefix=COST
 
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
-target triple = "aarch64-none-unknown-eabi"
+target triple = "aarch64"
 
 ; Check that the maximize vector bandwidth option does not give incorrect costs
 ; due to invalid cost decisions. The loop below has a low maximum trip count,
Index: llvm/test/MC/AArch64/fixup-out-of-range.s
===
--- llvm/test/MC/AArch64/fixup-out-of-range.s
+++ llvm/test/MC/AArch64/fixup-out-of-range.s
@@ -1,4 +1,4 @@
-// RUN: not llvm-mc -triple aarch64--none-eabi -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: not llvm-mc -triple aarch64 -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
 // RUN: not llvm-mc -triple aarch64-windows -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s -check-prefixes=CHECK,CHECK-WIN
 
 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: fixup value out of range
Index: llvm/test/MC/AArch64/fixup-out-of-range-edge.s
===
--- llvm/test/MC/AArch64/fixup-out-of-range-edge.s
+++ llvm/test/MC/AArch64/fixup-out-of-range-edge.s
@@ -1,4 +1,4 @@
-// RUN: not llvm-mc -triple aarch64--none-eabi -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: not llvm-mc -triple aarch64 -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
 
 // COM: Edge case testing for branches and ADR[P]
 // CHECK-LABEL: :{{[0-9]+}}:{{[0-9]+}}: error: fixup value out of range
Index: llvm/test/MC/AArch64/fixup-absolute.s
===
--- llvm/test/MC/AArch64/fixup-absolute.s
+++ llvm/test/MC/AArch64/fixup-absolute.s
@@ -1,4 +1,4 @@
-// RUN: llvm-mc -triple aarch64--none-eabi -filetype obj < %s -o - | llvm-objdump --no-print-imm-hex -d - | FileCheck %s
+// RUN: llvm-mc -triple aarch64 -filetype obj < %s -o - | llvm-objdump --no-print-imm-hex -d - | FileCheck %s
 
 onepart_before = 0x1234
 twopart_before = 0x12345678
Index: llvm/test/MC/AArch64/fixup-absolute-signed.s
===
--- llvm/test/MC/AArch64/fixup-absolute-signed.s
+++ llvm/test/MC/AArch64/fixup-absolute-signed.s
@@ -1,4 +1,4 @@
-// RUN: llvm-mc -triple aarch64--none-eabi -filetype obj < %s -o - | llvm-objdump --no-print-imm-hex -d - | FileCheck %s
+// RUN: llvm-mc -triple aarch64 

[clang] dc8cbbd - [Clang][Driver] Change missing multilib error to warning

2023-06-29 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2023-06-29T09:08:15+01:00
New Revision: dc8cbbd55f807e832bf8c500205b0f4184531b00

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

LOG: [Clang][Driver] Change missing multilib error to warning

The error could be awkward to work around when experimenting with flags
that didn't have a matching multilib. It also broke many tests when
multilib.yaml was present in the build directory.

Reviewed By: simon_tatham, MaskRay

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal-multilib.yaml

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index d2253bb84a0441..d8112641eaf58f 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -737,8 +737,9 @@ def err_drv_loongarch_invalid_mfpu_EQ : Error<
 def err_drv_expand_response_file : Error<
   "failed to expand response file: %0">;
 
-def err_drv_no_matching_multilib : Error<
-  "no multilib found matching flags: %0">;
+def warn_drv_missing_multilib : Warning<
+  "no multilib found matching flags: %0">,
+  InGroup>;
 def note_drv_available_multilibs : Note<
   "available multilibs are:%0">;
 }

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 47a533501ec730..d56bfafe6dfe1f 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -175,7 +175,7 @@ static void findMultilibsFromYAML(const ToolChain &TC, 
const Driver &D,
   Result.Multilibs = ErrorOrMultilibSet.get();
   if (Result.Multilibs.select(Flags, Result.SelectedMultilibs))
 return;
-  D.Diag(clang::diag::err_drv_no_matching_multilib) << llvm::join(Flags, " ");
+  D.Diag(clang::diag::warn_drv_missing_multilib) << llvm::join(Flags, " ");
   std::stringstream ss;
   for (const Multilib &Multilib : Result.Multilibs)
 ss << "\n" << llvm::join(Multilib.flags(), " ");

diff  --git a/clang/test/Driver/baremetal-multilib.yaml 
b/clang/test/Driver/baremetal-multilib.yaml
index e3281fa3b04b6e..af26e82621c91e 100644
--- a/clang/test/Driver/baremetal-multilib.yaml
+++ b/clang/test/Driver/baremetal-multilib.yaml
@@ -23,7 +23,7 @@
 # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### 
-o %t.out 2>&1 \
 # RUN: --target=thumbv7em-none-eabi -mfpu=fpv4-sp-d16 --sysroot= \
 # RUN:   | FileCheck --check-prefix=CHECK-NO-MATCH %s
-# CHECK-NO-MATCH: error: no multilib found matching flags:
+# CHECK-NO-MATCH: warning: no multilib found matching flags:
 # CHECK-NO-MATCH-SAME: --target=thumbv7em-none-unknown-eabi
 # CHECK-NO-MATCH: note: available multilibs are:
 # CHECK-NO-MATCH: --target=thumbv6m-none-unknown-eabi -mfpu=none



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


[PATCH] D153885: [Clang][Driver] Change missing multilib error to warning

2023-06-29 Thread Michael Platings via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc8cbbd55f80: [Clang][Driver] Change missing multilib error 
to warning (authored by michaelplatings).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153885

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal-multilib.yaml


Index: clang/test/Driver/baremetal-multilib.yaml
===
--- clang/test/Driver/baremetal-multilib.yaml
+++ clang/test/Driver/baremetal-multilib.yaml
@@ -23,7 +23,7 @@
 # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### 
-o %t.out 2>&1 \
 # RUN: --target=thumbv7em-none-eabi -mfpu=fpv4-sp-d16 --sysroot= \
 # RUN:   | FileCheck --check-prefix=CHECK-NO-MATCH %s
-# CHECK-NO-MATCH: error: no multilib found matching flags:
+# CHECK-NO-MATCH: warning: no multilib found matching flags:
 # CHECK-NO-MATCH-SAME: --target=thumbv7em-none-unknown-eabi
 # CHECK-NO-MATCH: note: available multilibs are:
 # CHECK-NO-MATCH: --target=thumbv6m-none-unknown-eabi -mfpu=none
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -175,7 +175,7 @@
   Result.Multilibs = ErrorOrMultilibSet.get();
   if (Result.Multilibs.select(Flags, Result.SelectedMultilibs))
 return;
-  D.Diag(clang::diag::err_drv_no_matching_multilib) << llvm::join(Flags, " ");
+  D.Diag(clang::diag::warn_drv_missing_multilib) << llvm::join(Flags, " ");
   std::stringstream ss;
   for (const Multilib &Multilib : Result.Multilibs)
 ss << "\n" << llvm::join(Multilib.flags(), " ");
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -737,8 +737,9 @@
 def err_drv_expand_response_file : Error<
   "failed to expand response file: %0">;
 
-def err_drv_no_matching_multilib : Error<
-  "no multilib found matching flags: %0">;
+def warn_drv_missing_multilib : Warning<
+  "no multilib found matching flags: %0">,
+  InGroup>;
 def note_drv_available_multilibs : Note<
   "available multilibs are:%0">;
 }


Index: clang/test/Driver/baremetal-multilib.yaml
===
--- clang/test/Driver/baremetal-multilib.yaml
+++ clang/test/Driver/baremetal-multilib.yaml
@@ -23,7 +23,7 @@
 # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \
 # RUN: --target=thumbv7em-none-eabi -mfpu=fpv4-sp-d16 --sysroot= \
 # RUN:   | FileCheck --check-prefix=CHECK-NO-MATCH %s
-# CHECK-NO-MATCH: error: no multilib found matching flags:
+# CHECK-NO-MATCH: warning: no multilib found matching flags:
 # CHECK-NO-MATCH-SAME: --target=thumbv7em-none-unknown-eabi
 # CHECK-NO-MATCH: note: available multilibs are:
 # CHECK-NO-MATCH: --target=thumbv6m-none-unknown-eabi -mfpu=none
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -175,7 +175,7 @@
   Result.Multilibs = ErrorOrMultilibSet.get();
   if (Result.Multilibs.select(Flags, Result.SelectedMultilibs))
 return;
-  D.Diag(clang::diag::err_drv_no_matching_multilib) << llvm::join(Flags, " ");
+  D.Diag(clang::diag::warn_drv_missing_multilib) << llvm::join(Flags, " ");
   std::stringstream ss;
   for (const Multilib &Multilib : Result.Multilibs)
 ss << "\n" << llvm::join(Multilib.flags(), " ");
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -737,8 +737,9 @@
 def err_drv_expand_response_file : Error<
   "failed to expand response file: %0">;
 
-def err_drv_no_matching_multilib : Error<
-  "no multilib found matching flags: %0">;
+def warn_drv_missing_multilib : Warning<
+  "no multilib found matching flags: %0">,
+  InGroup>;
 def note_drv_available_multilibs : Note<
   "available multilibs are:%0">;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153798: [clang-format] Correctly annotate operator free function call

2023-06-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:319
+   Prev->Previous->isOneOf(tok::period, tok::arrow)) ||
+  (!Line.MustBeDeclaration && !Line.InMacroBody);
   Contexts.back().IsExpression = OperatorCalledAsMemberFunction;

rymiel wrote:
> owenpan wrote:
> > Why not `Line.InMacroBody`? Wouldn't it misformat the following snippet?
> > ```
> > #define FOO   \
> >   void foo() {\
> > operator+(a * b); \
> >   }
> > ```
> Yes, but it would break this test case: 
> https://github.com/llvm/llvm-project/blob/e469d0d636f36140b08d0b5f603c043008307bcf/clang/unittests/Format/FormatTest.cpp#L11573
> 
> I understand it's a nasty workaround, though, but it's quick. The other 
> option seems to be rewriting how overloaded operators are annotated to 
> instead be more like regular function declarations, but I haven't gauged how 
> hard that would be
Yeah. Can you add the snippet as a FIXME test case (under `#if 0`)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153798

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


[PATCH] D153889: [analyzer][NFC] Fix dangling StringRef in barely used code

2023-06-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

This is actually needed to get correct bug reports in D153612 
, otherwise I got garbage messages (probably 
a `std::string` stack variable was passed to the `getNoteTag` function). I 
would not say that this is NFC because it is a bugfix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153889

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


[PATCH] D154050: [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

2023-06-29 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, 4vtomat, kito-cheng.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, MaskRay.
Herald added a project: clang.

The existing code assumes that both `DeclareRISCVVBuiltins` and
`DeclareRISCVSiFiveVectorBuiltins` are set when coming into the if-statement
under SemaLookup.cpp.

This is not the case and causes issue issue #63571.

This patch resolves the issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154050

Files:
  clang/include/clang/Sema/RISCVIntrinsicManager.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp

Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -158,6 +158,8 @@
   Sema &S;
   ASTContext &Context;
   RVVTypeCache TypeCache;
+  bool ConstructedRISCVVBuiltins;
+  bool ConstructedRISCVSiFiveVectorBuiltins;
 
   // List of all RVV intrinsic.
   std::vector IntrinsicList;
@@ -166,8 +168,6 @@
   // Mapping function name to RVVOverloadIntrinsicDef.
   StringMap OverloadIntrinsics;
 
-  // Create IntrinsicList
-  void InitIntrinsicList();
 
   // Create RVVIntrinsicDef.
   void InitRVVIntrinsic(const RVVIntrinsicRecord &Record, StringRef SuffixStr,
@@ -179,11 +179,18 @@
   Preprocessor &PP, unsigned Index,
   bool IsOverload);
 
+  void ConstructRVVIntrinsics(ArrayRef Recs,
+  IntrinsicKind K);
+
 public:
   RISCVIntrinsicManagerImpl(clang::Sema &S) : S(S), Context(S.Context) {
-InitIntrinsicList();
+ConstructedRISCVVBuiltins = false;
+ConstructedRISCVSiFiveVectorBuiltins = false;
   }
 
+  // Initialize IntrinsicList
+  void InitIntrinsicList() override;
+
   // Create RISC-V vector intrinsic and insert into symbol table if found, and
   // return true, otherwise return false.
   bool CreateIntrinsicIfFound(LookupResult &LR, IdentifierInfo *II,
@@ -191,139 +198,145 @@
 };
 } // namespace
 
-void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
+void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
+ArrayRef Recs, IntrinsicKind K) {
   const TargetInfo &TI = Context.getTargetInfo();
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
-
-  auto ConstructRVVIntrinsics = [&](ArrayRef Recs,
-IntrinsicKind K) {
-// Construction of RVVIntrinsicRecords need to sync with createRVVIntrinsics
-// in RISCVVEmitter.cpp.
-for (auto &Record : Recs) {
-  // Create Intrinsics for each type and LMUL.
-  BasicType BaseType = BasicType::Unknown;
-  ArrayRef BasicProtoSeq =
-  ProtoSeq2ArrayRef(K, Record.PrototypeIndex, Record.PrototypeLength);
-  ArrayRef SuffixProto =
-  ProtoSeq2ArrayRef(K, Record.SuffixIndex, Record.SuffixLength);
-  ArrayRef OverloadedSuffixProto = ProtoSeq2ArrayRef(
-  K, Record.OverloadedSuffixIndex, Record.OverloadedSuffixSize);
-
-  PolicyScheme UnMaskedPolicyScheme =
-  static_cast(Record.UnMaskedPolicyScheme);
-  PolicyScheme MaskedPolicyScheme =
-  static_cast(Record.MaskedPolicyScheme);
-
-  const Policy DefaultPolicy;
-
-  llvm::SmallVector ProtoSeq =
-  RVVIntrinsic::computeBuiltinTypes(
-  BasicProtoSeq, /*IsMasked=*/false,
-  /*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF,
-  UnMaskedPolicyScheme, DefaultPolicy, Record.IsTuple);
-
-  llvm::SmallVector ProtoMaskSeq =
-  RVVIntrinsic::computeBuiltinTypes(
-  BasicProtoSeq, /*IsMasked=*/true, Record.HasMaskedOffOperand,
-  Record.HasVL, Record.NF, MaskedPolicyScheme, DefaultPolicy,
-  Record.IsTuple);
-
-  bool UnMaskedHasPolicy = UnMaskedPolicyScheme != PolicyScheme::SchemeNone;
-  bool MaskedHasPolicy = MaskedPolicyScheme != PolicyScheme::SchemeNone;
-  SmallVector SupportedUnMaskedPolicies =
-  RVVIntrinsic::getSupportedUnMaskedPolicies();
-  SmallVector SupportedMaskedPolicies =
-  RVVIntrinsic::getSupportedMaskedPolicies(Record.HasTailPolicy,
-   Record.HasMaskPolicy);
-
-  for (unsigned int TypeRangeMaskShift = 0;
-   TypeRangeMaskShift <= static_cast(BasicType::MaxOffset);
-   ++TypeRangeMaskShift) {
-unsigned int BaseTypeI = 1 << TypeRangeMaskShift;
-BaseType = static_cast(BaseTypeI);
-
-if ((BaseTypeI & Record.Ty

[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-29 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe marked an inline comment as done.
FreddyYe added a comment.

In D151696#4458443 , @pengfei wrote:

> It looks to me the failed unit tests might be related to this patch, please 
> take a look.

This is due to FeatureCMOV adding. Should I split into another review?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D154050: [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

2023-06-29 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 535677.
eopXD added a comment.

Add test case of C++ compilation rvv-intrinsics-handcrafted/xsfvcp.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154050

Files:
  clang/include/clang/Sema/RISCVIntrinsicManager.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp
@@ -0,0 +1,15 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v  \
+// RUN:   -target-feature +xsfvcp \
+// RUN:   -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#include 
+
+#define p27_26 (0b11)
+#define p11_7  (0b1)
+
+void test_sf_vc_xv_se_u64m1(vuint64m1_t vs2, uint64_t rs1, size_t vl) {
+  __riscv_sf_vc_xv_se_u64m1(p27_26, p11_7, vs2, rs1, vl);
+}
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -158,6 +158,8 @@
   Sema &S;
   ASTContext &Context;
   RVVTypeCache TypeCache;
+  bool ConstructedRISCVVBuiltins;
+  bool ConstructedRISCVSiFiveVectorBuiltins;
 
   // List of all RVV intrinsic.
   std::vector IntrinsicList;
@@ -166,8 +168,6 @@
   // Mapping function name to RVVOverloadIntrinsicDef.
   StringMap OverloadIntrinsics;
 
-  // Create IntrinsicList
-  void InitIntrinsicList();
 
   // Create RVVIntrinsicDef.
   void InitRVVIntrinsic(const RVVIntrinsicRecord &Record, StringRef SuffixStr,
@@ -179,11 +179,18 @@
   Preprocessor &PP, unsigned Index,
   bool IsOverload);
 
+  void ConstructRVVIntrinsics(ArrayRef Recs,
+  IntrinsicKind K);
+
 public:
   RISCVIntrinsicManagerImpl(clang::Sema &S) : S(S), Context(S.Context) {
-InitIntrinsicList();
+ConstructedRISCVVBuiltins = false;
+ConstructedRISCVSiFiveVectorBuiltins = false;
   }
 
+  // Initialize IntrinsicList
+  void InitIntrinsicList() override;
+
   // Create RISC-V vector intrinsic and insert into symbol table if found, and
   // return true, otherwise return false.
   bool CreateIntrinsicIfFound(LookupResult &LR, IdentifierInfo *II,
@@ -191,139 +198,145 @@
 };
 } // namespace
 
-void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
+void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
+ArrayRef Recs, IntrinsicKind K) {
   const TargetInfo &TI = Context.getTargetInfo();
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
-
-  auto ConstructRVVIntrinsics = [&](ArrayRef Recs,
-IntrinsicKind K) {
-// Construction of RVVIntrinsicRecords need to sync with createRVVIntrinsics
-// in RISCVVEmitter.cpp.
-for (auto &Record : Recs) {
-  // Create Intrinsics for each type and LMUL.
-  BasicType BaseType = BasicType::Unknown;
-  ArrayRef BasicProtoSeq =
-  ProtoSeq2ArrayRef(K, Record.PrototypeIndex, Record.PrototypeLength);
-  ArrayRef SuffixProto =
-  ProtoSeq2ArrayRef(K, Record.SuffixIndex, Record.SuffixLength);
-  ArrayRef OverloadedSuffixProto = ProtoSeq2ArrayRef(
-  K, Record.OverloadedSuffixIndex, Record.OverloadedSuffixSize);
-
-  PolicyScheme UnMaskedPolicyScheme =
-  static_cast(Record.UnMaskedPolicyScheme);
-  PolicyScheme MaskedPolicyScheme =
-  static_cast(Record.MaskedPolicyScheme);
-
-  const Policy DefaultPolicy;
-
-  llvm::SmallVector ProtoSeq =
-  RVVIntrinsic::computeBuiltinTypes(
-  BasicProtoSeq, /*IsMasked=*/false,
-  /*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF,
-  UnMaskedPolicyScheme, DefaultPolicy, Record.IsTuple);
-
-  llvm::SmallVector ProtoMaskSeq =
-  RVVIntrinsic::computeBuiltinTypes(
-  BasicProtoSeq, /*IsMasked=*/true, Record.HasMaskedOffOperand,
-  Record.HasVL, Record.NF, MaskedPolicyScheme, DefaultPolicy,
-  Record.IsTuple);
-
-  bool UnMaskedHasPolicy = UnMaskedPolicyScheme != PolicyScheme::SchemeNone;
-  bool MaskedHasPolicy = MaskedPolicyScheme != PolicyScheme::SchemeNone;
-  SmallVector SupportedUnMaskedPolicies =
-  RVVIntrinsic::getSupportedUnMaskedPolicies();
-  SmallVector SupportedMaskedPolicies =
-  RVVIntrinsic::getSupportedMaskedPolicies(Record.HasTailPolicy,
-   Record.HasMaskPolicy);
-
-  for (unsigned int TypeRangeMaskShift = 0;
-   TypeRangeMaskShift <= static_cast(BasicType::MaxOffset);
-   ++TypeRang

[PATCH] D153702: [Clang] Implement P2738R1 - constexpr cast from void*

2023-06-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/test/CXX/expr/expr.const/p5-26.cpp:13
+(void)static_cast(a); //cxx23-note {{cast from 'void *' is not allowed 
in a constant expression in C++ standards before C++2c}}
+(void)static_cast(a);
+(void)static_cast(a);

shafik wrote:
> Why no diagnostic on this line and the next?
Why do you expect one?
you can add const/volatile (but not remove const) in a static_cast 
https://godbolt.org/z/qEqoEWohc
In c++23, no diag because we stop evaluating the function at that point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153702

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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-29 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

In D151696#4458435 , @pengfei wrote:

> I have some concerns for RULE 3, especially `core_aes_pclmulqdq -> westmere` 
> and `atom_sse4_2_movbe -> silvermont`.
> Sometimes, we have minor feature differences in the same generation targets. 
> I guess that's why we use `arch_feature` naming like core_2_duo_ssse3. 
> Merging them into the same generation or the next generation might corrup the 
> intention here. But I'm not expert in CPUDispatch, and I don't see any 
> existing tests for them, so I won't block the patch since it's an improvement 
> in general.
> Please wait a few days for other reviewers' opinions.

You are right. For historical reasons, I can't find which product each cpu name 
string points to actually. From the old feature list in X86TargetParser.def, 
these three cpu names even share a same feature list:

  atom_sse4_2
  core_i7_sse4_2
  core_aes_pclmulqdq

"core_5th_gen_avx_tsx"  is also same as "broadwell". So I have a new proposal 
for RULE3, which can be considered to be more conservative:

  pentium_4_sse3 -> prescott (FeatureSSE3)
  First introduce FeatureSSE4_1 like prescott
  core_2_duo_ssse3 -> core2 (FeatureSSSE3)
  First introduce FeatureSSE4_1 like core2
  core_2_duo_sse4_1 -> penryn (FeatureSSE4_1)
  First introduce FeatureSSE4_1 like penryn
  atom_sse4_2 -> nehalem (FeatureSSE4_2)
  First introduce FeatureSSE4_2 like nehalem
  core_i7_sse4_2 -> nehalem (FeatureSSE4_2)
  First introduce FeatureSSE4_2 like nehalem
  core_aes_pclmulqdq -> nehalem (FeatureSSE4_2)
  First introduce FeatureSSE4_2 like nehalem
  core_5th_gen_avx_tsx -> broadwell 
  Same feature list as broadwell

Meanwhile, the fact above won't affect code changes in X86.td. I'll still 
define these new cpu names with the TUNE_NAME info in original source.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D153962: [clang] Do not discard cleanups while processing immediate invocation

2023-06-29 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 535687.
Fznamznon added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153962

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/consteval-cleanup.cpp
  clang/test/SemaCXX/consteval-cleanup.cpp

Index: clang/test/SemaCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/consteval-cleanup.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump | FileCheck %s
+
+// expected-no-diagnostics
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: BinaryOperator {{.*}} 'bool' ','
+  // CHECK-NEXT: BinaryOperator {{.*}} 'P':'P' ','
+  // CHECK-NEXT: CXXFunctionalCastExpr {{.*}} 'A':'A'
+  // CHECK-NEXT: CXXBindTemporaryExpr {{.*}} 'A':'A'
+  // CHECK-NEXT: CXXConstructExpr {{.*}} 'A':'A'
+  // CHECK: ConstantExpr {{.*}} 'P':'P'
+  // CHECK-NEXT: value:
+  // CHECK-NEXT: ExprWithCleanups
+}
+
+struct B {
+  int *p = new int(38);
+  consteval int get() { return *p; }
+  constexpr ~B() { delete p; }
+};
+
+void bar() {
+  // CHECK: bar
+  // CHECK: ConstantExpr
+  // CHECK-NEXT: value:
+  // CHECK-NEXT: ExprWithCleanups
+  int k = B().get();
+}
Index: clang/test/CodeGenCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/consteval-cleanup.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: for.cond:
+  // CHECK: call void @_ZN1AC1Ei
+  // CHECK: call void @_ZN1AD1Ev
+  // CHECK: for.body
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18183,7 +18183,15 @@
 return E;
   }
 
-  E = MaybeCreateExprWithCleanups(E);
+  if (Cleanup.exprNeedsCleanups()) {
+// Since an immediate invocation is a full expression itself - it requires
+// an additional ExprWithCleanups node, but it can participate to a bigger
+// full expression which actually requires cleanups to be run after so
+// create ExprWithCleanups without using MaybeCreateExprWithCleanups as it
+// may discard cleanups for outer expression too early.
+E = ExprWithCleanups::Create(getASTContext(), E.get(),
+ Cleanup.cleanupsHaveSideEffects(), {});
+  }
 
   ConstantExpr *Res = ConstantExpr::Create(
   getASTContext(), E.get(),
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -549,6 +549,10 @@
   (`#48512 `_).
 - Fixed a failing assertion when parsing incomplete destructor.
   (`#63503 `_)
+- Fix missing destructor calls and therefore memory leaks in generated code
+  when an immediate invocation appears as a part of an expression that produces
+  temporaries.
+  (`#60709 `_).
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153962: [clang] Do not discard cleanups while processing immediate invocation

2023-06-29 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:7374
   auto *E = ExprWithCleanups::Create(
   Context, SubExpr, Cleanup.cleanupsHaveSideEffects(), Cleanups);
 

ilya-biryukov wrote:
> Because we may potentially pass some cleanups here (which are outside 
> `ConstantExpr`) and won't discard them later, we end up adding the unrelated 
> blocks to this cleanup expression.
> Here's an example. If we start with this code:
> ```cpp
>   struct P {
> consteval P() {}
>   };
> 
>   struct A {
> A(int v) { this->data = new int(v); }
> const int& get() const {
>   return *this->data;
> }
> ~A() { delete data; }
>   private:
> int *data;
>   };
> 
>   void foo() {
> A a(1);
>   for (; ^{ ptr = &a.get(); }(), P(), false;);
>   }
> ```
> And run `clang++ -std=c++20 -fblocks -Xclang=-ast-dump`, we'll get:
> (notice same Block in two cleanups)
> ```
> `-ForStmt 0x5592888b1318 
>   |-<<>>
>   |-<<>>
>   |-ExprWithCleanups 0x5592888b12f0  'bool'
>   | |-cleanup Block 0x5592888ad728
>   | `-BinaryOperator 0x5592888b12d0  'bool' ','
>   |   |-BinaryOperator 0x5592888b12a0  'P':'P' ','
>   |   | |-CallExpr 0x5592888adb48  'void'
>   |   | | `-BlockExpr 0x5592888adb30  'void (^)()'
>   |   | |   `-BlockDecl 0x5592888ad728  col:10
>   |   | | |-capture Var 0x5592888ad318 'a' 'A':'A'
>   |   | | `-CompoundStmt 0x5592888ad930 
>   |   | `-CXXFunctionalCastExpr 0x5592888b1278  'P':'P' 
> functional cast to P 
>   |   |   `-ConstantExpr 0x5592888b1108  'P':'P'
>   |   | |-value: Struct
>   |   | `-ExprWithCleanups 0x5592888b10e8  'P':'P'
>   |   |   |-cleanup Block 0x5592888ad728
>   |   |   `-CXXTemporaryObjectExpr 0x5592888b10b8  
> 'P':'P' 'void ()'
>   |   `-CXXBoolLiteralExpr 0x5592888b12c0  'bool' false
> ```
> I didn't check if this particular error can lead to codegen bug, but even 
> having a misplaced cleanup in the AST is already a red flag.
> 
> I think in case of immediate invocations we could simply create 
> `ExprWithCleanups` and not do anything else:
> - `CleanupVarDeclMarking` will be handled when containing evaluation context 
> is popped from the stack.
> - `ExprCleanupObjects` may only contain blocks at this point (as it's C++ and 
> we have assert for this). One can't use blocks inside a constant expression 
> (Clang will produce an error) so in correct code any cleanups we see inside 
> the current context **must handled by the containing evaluation context** and 
> not this `ExprWithCleanups`.
> 
I see. Thank you. I updated it to only create `ExprWithCleanups`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153962

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


[PATCH] D154050: [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

2023-06-29 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154050

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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-29 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D151696#4458751 , @FreddyYe wrote:

> In D151696#4458443 , @pengfei wrote:
>
>> It looks to me the failed unit tests might be related to this patch, please 
>> take a look.
>
> This is due to FeatureCMOV adding. Should I split into another review?

Yes, it looks like it would be best to split off and commit some of the fixes 
(cmov / the isa changes causing the attr-cpuspecific.c diffs etc.) first, 
before this refactor patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-06-29 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 535696.
4vtomat added a comment.
Herald added a subscriber: wangpc.

Ready for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ms.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3c.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3me.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4k.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsha2ms.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsm3c.c
  
clang/test/C

[PATCH] D153674: [dataflow] Disallow implicit copy of Environment, use fork() instead

2023-06-29 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

I'm also using `gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0` (which supported 
according to the LLVM "Getting Started" page 
)
 and I see the same std::optional compilation errors. Please revert this commit 
or fix the build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153674

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


[PATCH] D153962: [clang] Do not discard cleanups while processing immediate invocation

2023-06-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM with two NITs. Thanks a lot for fixing this!




Comment at: clang/lib/Sema/SemaExpr.cpp:18187
+  if (Cleanup.exprNeedsCleanups()) {
+// Since an immediate invocation is a full expression itself - it requires
+// an additional ExprWithCleanups node, but it can participate to a bigger

NIT: maybe be a bit more specific about the types of cleanups?
```
// Note that ExprWithCleanups created here must always have empty cleanup 
objects:
// - compound literals do not create cleanup objects in C++ and immediate 
invocations are C++-only.
// - blocks are not allowed inside constant expressions and compiler will issue 
an error if they appear there.
// Hence, in correct code any cleanup objects created inside current evaluation 
context must be outside
// the immediate invocation.
```



Comment at: clang/test/SemaCXX/consteval-cleanup.cpp:1
+// RUN: %clang_cc1 -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump 
| FileCheck %s
+

Maybe also add a test with `-fblocks` that checks that only one 
`ExprWithCleanups` has the block cleanup action attached?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153962

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


[PATCH] D153556: [OPENMP52] Initial support for doacross clause.

2023-06-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Upload full context


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153556

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


[PATCH] D153701: [Clang] Implement P2718R0 "Lifetime extension in range-based for loops"

2023-06-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Sorry, I missed the ping on Discord.
Thanks for working on this

I don't feel qualified to review this, but I don't think there are nearly 
enough tests.
FYI there is a previous attempt at this here https://reviews.llvm.org/D139586 - 
with some test suggestions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

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


[PATCH] D153556: [OPENMP52] Initial support for doacross clause.

2023-06-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:20871
   TotalDepCount.getZExtValue());
+
   if ((DepKind == OMPC_DEPEND_sink || DepKind == OMPC_DEPEND_source) &&

Remove this new line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153556

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


[PATCH] D153652: [Support] Don't set "all_exe" mode by default for file written by llvm::writeToOutput

2023-06-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 535712.
hokein marked an inline comment as done.
hokein added a comment.

address the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153652

Files:
  llvm/lib/Support/raw_ostream.cpp
  llvm/test/tools/llvm-dwarfutil/ELF/X86/mirror-permissions-unix.test
  llvm/unittests/Support/raw_ostream_test.cpp

Index: llvm/unittests/Support/raw_ostream_test.cpp
===
--- llvm/unittests/Support/raw_ostream_test.cpp
+++ llvm/unittests/Support/raw_ostream_test.cpp
@@ -504,6 +504,31 @@
   checkFileData(Path, "HelloWorld");
 }
 
+#ifndef _WIN32
+TEST(raw_ostreamTest, filePermissions) {
+  // Set umask to be permissive of all permissions.
+  unsigned OldMask = ::umask(0);
+
+  llvm::unittest::TempDir RootTestDirectory("writToOutput", /*Unique*/ true);
+  SmallString<128> Path(RootTestDirectory.path());
+  sys::path::append(Path, "test.txt");
+
+  ASSERT_THAT_ERROR(writeToOutput(Path,
+  [](raw_ostream &Out) -> Error {
+Out << "HelloWorld";
+return Error::success();
+  }),
+Succeeded());
+
+  ErrorOr Perms = llvm::sys::fs::getPermissions(Path);
+  ASSERT_TRUE(Perms) << "should be able to get permissions";
+  // Verify the permission bits set by writeToOutput are read and write only.
+  EXPECT_EQ(Perms.get(), llvm::sys::fs::all_read | llvm::sys::fs::all_write);
+
+  ::umask(OldMask);
+}
+#endif
+
 TEST(raw_ostreamTest, writeToNonexistingPath) {
   StringRef FileName = "/_bad/_path";
   std::string ErrorMessage = toString(createFileError(
Index: llvm/test/tools/llvm-dwarfutil/ELF/X86/mirror-permissions-unix.test
===
--- /dev/null
+++ llvm/test/tools/llvm-dwarfutil/ELF/X86/mirror-permissions-unix.test
@@ -0,0 +1,51 @@
+## The Unix version of this test must use umask(1) because
+## llvm-dwarfutil respects the umask in setting output permissions.
+## Setting the umask to 0 ensures deterministic permissions across
+## test environments.
+# UNSUPPORTED: system-windows
+# REQUIRES: shell
+
+# RUN: touch %t
+# RUN: chmod 0777 %t
+# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0777
+# RUN: chmod 0666 %t
+# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0666
+# RUN: chmod 0640 %t
+# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0640
+
+## Set umask to be permissive of all permissions,
+## only test mirroring of permissions.
+# RUN: umask 0
+
+# RUN: yaml2obj %s -o %t
+
+# RUN: chmod 0777 %t
+# RUN: llvm-dwarfutil --no-garbage-collection %t %t1
+# RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms
+# RUN: cmp %t1.perms %t.0777
+# RUN: llvm-dwarfutil --garbage-collection --separate-debug-file %t %t2
+# RUN: ls -l %t2 | cut -f 1 -d ' ' > %t2.perms
+# RUN: cmp %t2.perms %t.0777
+
+# RUN: chmod 0666 %t
+# RUN: llvm-dwarfutil --no-garbage-collection %t %t1
+# RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms
+# RUN: cmp %t1.perms %t.0666
+# RUN: llvm-dwarfutil --garbage-collection --separate-debug-file %t %t2
+# RUN: ls -l %t2 | cut -f 1 -d ' ' > %t2.perms
+# RUN: cmp %t2.perms %t.0666
+
+# RUN: chmod 0640 %t
+# RUN: llvm-dwarfutil --no-garbage-collection %t %t1
+# RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms
+# RUN: cmp %t1.perms %t.0640
+# RUN: llvm-dwarfutil --garbage-collection --separate-debug-file %t %t2
+# RUN: ls -l %t2 | cut -f 1 -d ' ' > %t2.perms
+# RUN: cmp %t2.perms %t.0640
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
Index: llvm/lib/Support/raw_ostream.cpp
===
--- llvm/lib/Support/raw_ostream.cpp
+++ llvm/lib/Support/raw_ostream.cpp
@@ -1007,7 +1007,7 @@
 return Write(Out);
   }
 
-  unsigned Mode = sys::fs::all_read | sys::fs::all_write | sys::fs::all_exe;
+  unsigned Mode = sys::fs::all_read | sys::fs::all_write;
   Expected Temp =
   sys::fs::TempFile::create(OutputFileName + ".temp-stream-%%", Mode);
   if (!Temp)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153652: [Support] Don't set "all_exe" mode by default for file written by llvm::writeToOutput

2023-06-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: llvm/unittests/Support/raw_ostream_test.cpp:525
+  ASSERT_TRUE(Perms) << "should be able to get permissions";
+  // Verify that writeToOutput doesn't set exe bit.
+  EXPECT_EQ(Perms.get(), llvm::sys::fs::all_read | llvm::sys::fs::all_write);

avl wrote:
> nit: comment looks a bit inconsistent as we check for read&write bits.
refined the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153652

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


[PATCH] D151445: [Flang] Add main-file-name flag to flang -fc1

2023-06-29 Thread Dominik Adamski via Phabricator via cfe-commits
domada abandoned this revision.
domada added a comment.
Herald added subscribers: gysit, Dinistro.

Patch not needed. Preprocessor change: https://reviews.llvm.org/D153910 enables 
passing information about original source file.


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

https://reviews.llvm.org/D151445

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


[PATCH] D153962: [clang] Do not discard cleanups while processing immediate invocation

2023-06-29 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 535721.
Fznamznon added a comment.

Update the comment, add blocks test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153962

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/consteval-cleanup.cpp
  clang/test/SemaCXX/consteval-cleanup.cpp

Index: clang/test/SemaCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/consteval-cleanup.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fblocks -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump | FileCheck %s
+
+// expected-no-diagnostics
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  const int& get() const {
+return *this->data;
+  }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: BinaryOperator {{.*}} 'bool' ','
+  // CHECK-NEXT: BinaryOperator {{.*}} 'P':'P' ','
+  // CHECK-NEXT: CXXFunctionalCastExpr {{.*}} 'A':'A'
+  // CHECK-NEXT: CXXBindTemporaryExpr {{.*}} 'A':'A'
+  // CHECK-NEXT: CXXConstructExpr {{.*}} 'A':'A'
+  // CHECK: ConstantExpr {{.*}} 'P':'P'
+  // CHECK-NEXT: value:
+  // CHECK-NEXT: ExprWithCleanups
+}
+
+void foobar() {
+  A a(1);
+  for (; ^{ auto ptr = &a.get(); }(), P(), false;);
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: cleanup Block
+  // CHECK-NEXT: BinaryOperator {{.*}} 'bool' ','
+  // CHECK-NEXT: BinaryOperator {{.*}} 'P':'P' ','
+  // CHECK-NEXT: CallExpr
+  // CHECK-NEXT: BlockExpr
+  // CHECK: ConstantExpr {{.*}} 'P':'P'
+  // CHECK-NEXT: value:
+  // CHECK-NEXT: ExprWithCleanups
+  // CHECK-NOT:  cleanup Block
+}
+
+struct B {
+  int *p = new int(38);
+  consteval int get() { return *p; }
+  constexpr ~B() { delete p; }
+};
+
+void bar() {
+  // CHECK: bar
+  // CHECK: ExprWithCleanups
+  // CHECK: ConstantExpr
+  // CHECK-NEXT: value:
+  // CHECK-NEXT: ExprWithCleanups
+  int k = B().get();
+}
Index: clang/test/CodeGenCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/consteval-cleanup.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: for.cond:
+  // CHECK: call void @_ZN1AC1Ei
+  // CHECK: call void @_ZN1AD1Ev
+  // CHECK: for.body
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18183,7 +18183,24 @@
 return E;
   }
 
-  E = MaybeCreateExprWithCleanups(E);
+  if (Cleanup.exprNeedsCleanups()) {
+// Since an immediate invocation is a full expression itself - it requires
+// an additional ExprWithCleanups node, but it can participate to a bigger
+// full expression which actually requires cleanups to be run after so
+// create ExprWithCleanups without using MaybeCreateExprWithCleanups as it
+// may discard cleanups for outer expression too early.
+
+// Note that ExprWithCleanups created here must always have empty cleanup
+// objects:
+// - compound literals do not create cleanup objects in C++ and immediate
+// invocations are C++-only.
+// - blocks are not allowed inside constant expressions and compiler will
+// issue an error if they appear there. Hence, in correct code any cleanup
+// objects created inside current evaluation context must be outside the
+// immediate invocation.
+E = ExprWithCleanups::Create(getASTContext(), E.get(),
+ Cleanup.cleanupsHaveSideEffects(), {});
+  }
 
   ConstantExpr *Res = ConstantExpr::Create(
   getASTContext(), E.get(),
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -549,6 +549,10 @@
   (`#48512 `_).
 - Fixed a failing assertion when parsing incomplete destructor.
   (`#63503 `_)
+- Fix missing destructor calls and therefore memory leaks in generated code
+  when an immediate invocation appears as a part of an expression that produces
+  temporaries.
+  (`#60709 `_).
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153701: [Clang] Implement P2718R0 "Lifetime extension in range-based for loops"

2023-06-29 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

In D153701#4459036 , @cor3ntin wrote:

> Sorry, I missed the ping on Discord.
> Thanks for working on this
>
> I don't feel qualified to review this, but I don't think there are nearly 
> enough tests.
> FYI there is a previous attempt at this here https://reviews.llvm.org/D139586 
> - with some test suggestions

Thank you for take a look!  I'm sorry I have not found D139586 
 already exists, should I close this ticket? 
D139586  seems more complete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

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


[PATCH] D154050: [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

2023-06-29 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 535722.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154050

Files:
  clang/include/clang/Sema/RISCVIntrinsicManager.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp
@@ -0,0 +1,15 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v  \
+// RUN:   -target-feature +xsfvcp \
+// RUN:   -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#include 
+
+#define p27_26 (0b11)
+#define p11_7  (0b1)
+
+void test_sf_vc_xv_se_u64m1(vuint64m1_t vs2, uint64_t rs1, size_t vl) {
+  __riscv_sf_vc_xv_se_u64m1(p27_26, p11_7, vs2, rs1, vl);
+}
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -158,6 +158,8 @@
   Sema &S;
   ASTContext &Context;
   RVVTypeCache TypeCache;
+  bool ConstructedRISCVVBuiltins;
+  bool ConstructedRISCVSiFiveVectorBuiltins;
 
   // List of all RVV intrinsic.
   std::vector IntrinsicList;
@@ -166,8 +168,6 @@
   // Mapping function name to RVVOverloadIntrinsicDef.
   StringMap OverloadIntrinsics;
 
-  // Create IntrinsicList
-  void InitIntrinsicList();
 
   // Create RVVIntrinsicDef.
   void InitRVVIntrinsic(const RVVIntrinsicRecord &Record, StringRef SuffixStr,
@@ -179,11 +179,18 @@
   Preprocessor &PP, unsigned Index,
   bool IsOverload);
 
+  void ConstructRVVIntrinsics(ArrayRef Recs,
+  IntrinsicKind K);
+
 public:
   RISCVIntrinsicManagerImpl(clang::Sema &S) : S(S), Context(S.Context) {
-InitIntrinsicList();
+ConstructedRISCVVBuiltins = false;
+ConstructedRISCVSiFiveVectorBuiltins = false;
   }
 
+  // Initialize IntrinsicList
+  void InitIntrinsicList() override;
+
   // Create RISC-V vector intrinsic and insert into symbol table if found, and
   // return true, otherwise return false.
   bool CreateIntrinsicIfFound(LookupResult &LR, IdentifierInfo *II,
@@ -191,139 +198,145 @@
 };
 } // namespace
 
-void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
+void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
+ArrayRef Recs, IntrinsicKind K) {
   const TargetInfo &TI = Context.getTargetInfo();
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
-
-  auto ConstructRVVIntrinsics = [&](ArrayRef Recs,
-IntrinsicKind K) {
-// Construction of RVVIntrinsicRecords need to sync with createRVVIntrinsics
-// in RISCVVEmitter.cpp.
-for (auto &Record : Recs) {
-  // Create Intrinsics for each type and LMUL.
-  BasicType BaseType = BasicType::Unknown;
-  ArrayRef BasicProtoSeq =
-  ProtoSeq2ArrayRef(K, Record.PrototypeIndex, Record.PrototypeLength);
-  ArrayRef SuffixProto =
-  ProtoSeq2ArrayRef(K, Record.SuffixIndex, Record.SuffixLength);
-  ArrayRef OverloadedSuffixProto = ProtoSeq2ArrayRef(
-  K, Record.OverloadedSuffixIndex, Record.OverloadedSuffixSize);
-
-  PolicyScheme UnMaskedPolicyScheme =
-  static_cast(Record.UnMaskedPolicyScheme);
-  PolicyScheme MaskedPolicyScheme =
-  static_cast(Record.MaskedPolicyScheme);
-
-  const Policy DefaultPolicy;
-
-  llvm::SmallVector ProtoSeq =
-  RVVIntrinsic::computeBuiltinTypes(
-  BasicProtoSeq, /*IsMasked=*/false,
-  /*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF,
-  UnMaskedPolicyScheme, DefaultPolicy, Record.IsTuple);
-
-  llvm::SmallVector ProtoMaskSeq =
-  RVVIntrinsic::computeBuiltinTypes(
-  BasicProtoSeq, /*IsMasked=*/true, Record.HasMaskedOffOperand,
-  Record.HasVL, Record.NF, MaskedPolicyScheme, DefaultPolicy,
-  Record.IsTuple);
-
-  bool UnMaskedHasPolicy = UnMaskedPolicyScheme != PolicyScheme::SchemeNone;
-  bool MaskedHasPolicy = MaskedPolicyScheme != PolicyScheme::SchemeNone;
-  SmallVector SupportedUnMaskedPolicies =
-  RVVIntrinsic::getSupportedUnMaskedPolicies();
-  SmallVector SupportedMaskedPolicies =
-  RVVIntrinsic::getSupportedMaskedPolicies(Record.HasTailPolicy,
-   Record.HasMaskPolicy);
-
-  for (unsigned int TypeRangeMaskShift = 0;
-   TypeRangeMaskShift <= static_cast(BasicType::MaxOffset);
-   ++TypeRangeMaskShift) {
-unsigned int BaseTypeI = 1 << TypeRange

[PATCH] D153701: [Clang] Implement P2718R0 "Lifetime extension in range-based for loops"

2023-06-29 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

In D153701#4459036 , @cor3ntin wrote:

> Sorry, I missed the ping on Discord.
> Thanks for working on this
>
> I don't feel qualified to review this, but I don't think there are nearly 
> enough tests.
> FYI there is a previous attempt at this here https://reviews.llvm.org/D139586 
> - with some test suggestions

If you are no bandwidth to working on D139586 
, I'd be happy to do take over.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

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


[PATCH] D153860: [clang-tidy] Fix modernize-use-std-print check when return value used

2023-06-29 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe requested review of this revision.
mikecrowe added a comment.

I believe that the problems that caused this to be reverted have been fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153860

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


[PATCH] D154068: [clangd] Don't show header for namespace decl in Hover

2023-06-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: VitaNuo.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

The header for namespace symbol is barely useful.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154068

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3059,7 +3059,13 @@
   }
   ns::F^oo d;
 )cpp",
-[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }}};
+[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+{R"cpp(
+  namespace foo {};
+  using namespace fo^o;
+)cpp",
+[](HoverInfo &HI) { HI.Provider = ""; }},
+};
 
   for (const auto &Case : Cases) {
 Annotations Code{Case.Code};
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -1374,7 +1374,10 @@
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext()).PrintedValue;
 maybeAddCalleeArgInfo(N, *HI, PP);
-maybeAddSymbolProviders(AST, *HI, include_cleaner::Symbol{*DeclToUse});
+
+if (!isa(DeclToUse))
+  maybeAddSymbolProviders(AST, *HI,
+  include_cleaner::Symbol{*DeclToUse});
   } else if (const Expr *E = N->ASTNode.get()) {
 HoverCountMetric.record(1, "expr");
 HI = getHoverContents(N, E, AST, PP, Index);


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3059,7 +3059,13 @@
   }
   ns::F^oo d;
 )cpp",
-[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }}};
+[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+{R"cpp(
+  namespace foo {};
+  using namespace fo^o;
+)cpp",
+[](HoverInfo &HI) { HI.Provider = ""; }},
+};
 
   for (const auto &Case : Cases) {
 Annotations Code{Case.Code};
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -1374,7 +1374,10 @@
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext()).PrintedValue;
 maybeAddCalleeArgInfo(N, *HI, PP);
-maybeAddSymbolProviders(AST, *HI, include_cleaner::Symbol{*DeclToUse});
+
+if (!isa(DeclToUse))
+  maybeAddSymbolProviders(AST, *HI,
+  include_cleaner::Symbol{*DeclToUse});
   } else if (const Expr *E = N->ASTNode.get()) {
 HoverCountMetric.record(1, "expr");
 HI = getHoverContents(N, E, AST, PP, Index);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154050: [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

2023-06-29 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat accepted this revision.
4vtomat added a comment.

LGTM, thanks~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154050

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


[clang] 989879f - [Clang] Allow C++11 style initialisation of SVE types.

2023-06-29 Thread Paul Walker via cfe-commits

Author: Paul Walker
Date: 2023-06-29T11:55:36Z
New Revision: 989879f8fded41c732db93864461b3a67b9f1501

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

LOG: [Clang] Allow C++11 style initialisation of SVE types.

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

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

Added: 
clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp

Modified: 
clang/lib/CodeGen/CGExprScalar.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 02b80f3aba21c9..dbba8cc96f8142 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1869,6 +1869,23 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr 
*E) {
 return Visit(E->getInit(0));
   }
 
+  if (isa(VType)) {
+if (NumInitElements == 0) {
+  // C++11 value-initialization for the vector.
+  return EmitNullValue(E->getType());
+}
+
+if (NumInitElements == 1) {
+  Expr *InitVector = E->getInit(0);
+
+  // Initialize from another scalable vector of the same type.
+  if (InitVector->getType() == E->getType())
+return Visit(InitVector);
+}
+
+llvm_unreachable("Unexpected initialization of a scalable vector!");
+  }
+
   unsigned ResElts = cast(VType)->getNumElements();
 
   // Loop over initializers collecting the Value for each, and remembering

diff  --git a/clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp 
b/clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
new file mode 100644
index 00..2088e80acfc80f
--- /dev/null
+++ b/clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
@@ -0,0 +1,881 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define dso_local void @_Z11test_localsv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[S8:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S16:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S32:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S64:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U8:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U16:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U32:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U64:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F16:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F32:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F64:%.*]] = alloca , align 16
+// CHECK-NEXT:[[BF16:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S8X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S16X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S32X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[X64X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U8X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U16X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U32X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U64X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F16X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F32X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F64X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[BF16X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S8X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S16X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S32X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[X64X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U8X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U16X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U32X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U64X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F16X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F32X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F64X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[BF16X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S8X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S16X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S32X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[X64X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U8X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U16X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U32X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U64X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F16X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F32X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F64X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[BF16X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[B8:%.*]] = alloca , align 2
+// CHECK-NEXT:[[B8X2:%.*]] = alloca , align 2
+// CHECK-NEXT:[[B8X4:%.*]] = alloca , align 2
+// CHECK-NEXT:store  zeroinitializer, ptr [[S8]], align 
16
+// CHECK-NEXT:store  zeroinitializer,

[PATCH] D153560: [Clang] Allow C++11 style initialisation of SVE types.

2023-06-29 Thread Paul Walker 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 rG989879f8fded: [Clang] Allow C++11 style initialisation of 
SVE types. (authored by paulwalker-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153560

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp

Index: clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
@@ -0,0 +1,881 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define dso_local void @_Z11test_localsv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[S8:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S16:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S32:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S64:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U8:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U16:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U32:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U64:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F16:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F32:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F64:%.*]] = alloca , align 16
+// CHECK-NEXT:[[BF16:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S8X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S16X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S32X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[X64X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U8X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U16X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U32X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U64X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F16X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F32X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F64X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[BF16X2:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S8X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S16X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S32X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[X64X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U8X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U16X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U32X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U64X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F16X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F32X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F64X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[BF16X3:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S8X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S16X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[S32X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[X64X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U8X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U16X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U32X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[U64X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F16X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F32X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[F64X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[BF16X4:%.*]] = alloca , align 16
+// CHECK-NEXT:[[B8:%.*]] = alloca , align 2
+// CHECK-NEXT:[[B8X2:%.*]] = alloca , align 2
+// CHECK-NEXT:[[B8X4:%.*]] = alloca , align 2
+// CHECK-NEXT:store  zeroinitializer, ptr [[S8]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[S16]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[S32]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[S64]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[U8]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[U16]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[U32]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[U64]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[F16]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[F32]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[F64]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[BF16]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[S8X2]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[S16X2]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[S32X2]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[X64X2]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[U8X2]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[U16X2]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[U32X2]], align 16
+// CHECK-NEXT:store  zeroinitializer, ptr [[U64X2]], a

[PATCH] D153694: [clang][CodeGen] Remove no-op EmitCastToVoidPtr (NFC)

2023-06-29 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 535736.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153694

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp

Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -153,14 +153,13 @@
   bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr,
   QualType SrcRecordTy) override;
 
-  llvm::Value *EmitDynamicCastCall(CodeGenFunction &CGF, Address Value,
+  llvm::Value *emitDynamicCastCall(CodeGenFunction &CGF, Address Value,
QualType SrcRecordTy, QualType DestTy,
QualType DestRecordTy,
llvm::BasicBlock *CastEnd) override;
 
-  llvm::Value *EmitDynamicCastToVoid(CodeGenFunction &CGF, Address Value,
- QualType SrcRecordTy,
- QualType DestTy) override;
+  llvm::Value *emitDynamicCastToVoid(CodeGenFunction &CGF, Address Value,
+ QualType SrcRecordTy) override;
 
   bool EmitBadCastCall(CodeGenFunction &CGF) override;
   bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const override {
@@ -1011,11 +1010,9 @@
  !getContext().getASTRecordLayout(SrcDecl).hasExtendableVFPtr();
 }
 
-llvm::Value *MicrosoftCXXABI::EmitDynamicCastCall(
-CodeGenFunction &CGF, Address This, QualType SrcRecordTy,
-QualType DestTy, QualType DestRecordTy, llvm::BasicBlock *CastEnd) {
-  llvm::Type *DestLTy = CGF.ConvertType(DestTy);
-
+llvm::Value *MicrosoftCXXABI::emitDynamicCastCall(
+CodeGenFunction &CGF, Address This, QualType SrcRecordTy, QualType DestTy,
+QualType DestRecordTy, llvm::BasicBlock *CastEnd) {
   llvm::Value *SrcRTTI =
   CGF.CGM.GetAddrOfRTTIDescriptor(SrcRecordTy.getUnqualifiedType());
   llvm::Value *DestRTTI =
@@ -1041,14 +1038,12 @@
   llvm::Value *Args[] = {
   ThisPtr, Offset, SrcRTTI, DestRTTI,
   llvm::ConstantInt::get(CGF.Int32Ty, DestTy->isReferenceType())};
-  ThisPtr = CGF.EmitRuntimeCallOrInvoke(Function, Args);
-  return CGF.Builder.CreateBitCast(ThisPtr, DestLTy);
+  return CGF.EmitRuntimeCallOrInvoke(Function, Args);
 }
 
-llvm::Value *
-MicrosoftCXXABI::EmitDynamicCastToVoid(CodeGenFunction &CGF, Address Value,
-   QualType SrcRecordTy,
-   QualType DestTy) {
+llvm::Value *MicrosoftCXXABI::emitDynamicCastToVoid(CodeGenFunction &CGF,
+Address Value,
+QualType SrcRecordTy) {
   std::tie(Value, std::ignore, std::ignore) =
   performBaseAdjustment(CGF, Value, SrcRecordTy);
 
@@ -1582,11 +1577,8 @@
   // 1) getThisValue is currently protected
   // 2) in theory, an ABI could implement 'this' returns some other way;
   //HasThisReturn only specifies a contract, not the implementation
-  if (HasThisReturn(CGF.CurGD))
+  if (HasThisReturn(CGF.CurGD) || hasMostDerivedReturn(CGF.CurGD))
 CGF.Builder.CreateStore(getThisValue(CGF), CGF.ReturnValue);
-  else if (hasMostDerivedReturn(CGF.CurGD))
-CGF.Builder.CreateStore(CGF.EmitCastToVoidPtr(getThisValue(CGF)),
-CGF.ReturnValue);
 
   if (isa(MD) && MD->getParent()->getNumVBases()) {
 assert(getStructorImplicitParamDecl(CGF) &&
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -185,14 +185,13 @@
   bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr,
   QualType SrcRecordTy) override;
 
-  llvm::Value *EmitDynamicCastCall(CodeGenFunction &CGF, Address Value,
+  llvm::Value *emitDynamicCastCall(CodeGenFunction &CGF, Address Value,
QualType SrcRecordTy, QualType DestTy,
QualType DestRecordTy,
llvm::BasicBlock *CastEnd) override;
 
-  llvm::Value *EmitDynamicCastToVoid(CodeGenFunction &CGF, Address Value,
- QualType SrcRecordTy,
- QualType DestTy) override;
+  llvm::Value *emitDynamicCastToVoid(CodeGenFunction &CGF, Address Value,
+ 

[PATCH] D154070: [Driver][lld/COFF] Support DWARF fission when using LTO on Windows

2023-06-29 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
Herald added a project: All.
HaohaiWen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This patch added /dwodir to lld/COFF which is equivalent to lld/ELF
option -plugin-opt=dwo_dir=. This option tells LTO backend to create
dwo directory and files and all dwo files will be in it. Otherwise all
dwarf sections will be embeded into image even if -gsplit-dwarf is
specified when using LTO.
For Driver, when user specify -gsplit-dwarf and LTO, /dwodir will be
automatically added.

A simple use case:
$clang-cl -c -flto -gdwarf main.c -o main.o
$clang-cl -c -flto -gdwarf a.c -o a.o
$clang-cl -flto -fuse-ld=lld -gdwarf -gsplit-dwarf main.o a.o

This'll generate a dwo file: main.exe_dwo/0.dwo


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154070

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/lto-dwo.c
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/COFF/Options.td
  lld/test/COFF/lto-debug-fission.ll

Index: lld/test/COFF/lto-debug-fission.ll
===
--- /dev/null
+++ lld/test/COFF/lto-debug-fission.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; RUN: opt %s -o %t1.o
+; RUN: rm -rf %t.dir
+
+; Test to ensure that -dwodir:$DIR creates .dwo files under $DIR
+; RUN: lld-link -dwodir:%t.dir -noentry -dll %t1.o -out:%t.dll
+; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
+
+; CHECK: Format: COFF-x86-64
+
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/COFF/Options.td
===
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -42,6 +42,8 @@
 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
 def delayload : P<"delayload", "Delay loaded DLL name">;
 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
+def dwodir : P<"dwodir",
+"Directory to store .dwo files when LTO and debug fission are used">;
 def entry   : P<"entry", "Name of entry point symbol">;
 def errorlimit : P<"errorlimit",
 "Maximum number of errors to emit before stopping (0 = no limit)">;
Index: lld/COFF/LTO.cpp
===
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -84,6 +84,7 @@
   c.DisableVerify = true;
 #endif
   c.DiagHandler = diagnosticHandler;
+  c.DwoDir = ctx.config.dwoDir.str();
   c.OptLevel = ctx.config.ltoo;
   c.CPU = getCPUStr();
   c.MAttrs = getMAttrs();
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1910,6 +1910,9 @@
 fatal("/manifestinput: requires /manifest:embed");
   }
 
+  // Handle /dwodir
+  config->dwoDir = args.getLastArgValue(OPT_dwodir);
+
   config->thinLTOEmitImportsFiles = args.hasArg(OPT_thinlto_emit_imports_files);
   config->thinLTOIndexOnly = args.hasArg(OPT_thinlto_index_only) ||
  args.hasArg(OPT_thinlto_index_only_arg);
Index: lld/COFF/Config.h
===
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -203,6 +203,9 @@
   StringRef manifestUIAccess = "'false'";
   StringRef manifestFile;
 
+  // used for /dwodir
+  StringRef dwoDir;
+
   // Used for /aligncomm.
   std::map alignComm;
 
Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ clang/test/Driver/lto-dwo.c
@@ -1,6 +1,9 @@
 // Confirm that -gsplit-dwarf=DIR is passed to linker
 
 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf -o a.out 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+// RUN: FileCheck -check-prefix=CHECK-LINK-ELF-DWO-DIR-DEFAULT < %t %s
+// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -### -fuse-ld=lld -flto -gsplit-dwarf -o a.out -- %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-COFF-DWO-DIR-DEFAULT < %t %s
 //
-// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-ELF-DWO-DIR-DEFAULT:  "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-COFF-DWO-DIR-DEFAULT: "/dwodir:a.out_dwo"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,26 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker 

[clang] af19e40 - [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

2023-06-29 Thread via cfe-commits

Author: eopXD
Date: 2023-06-29T05:23:56-07:00
New Revision: af19e406f28e644e645781021c56720b60dc2238

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

LOG: [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

The existing code assumes that both `DeclareRISCVVBuiltins` and
`DeclareRISCVSiFiveVectorBuiltins` are set when coming into the if-statement
under SemaLookup.cpp.

This is not the case and causes issue #63571.

This patch resolves the issue.

Reviewed By: 4vtomat, kito-cheng

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

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp

Modified: 
clang/include/clang/Sema/RISCVIntrinsicManager.h
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaRISCVVectorLookup.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/RISCVIntrinsicManager.h 
b/clang/include/clang/Sema/RISCVIntrinsicManager.h
index 731bc3ae1c9d20..2a3dd1e7c4697b 100644
--- a/clang/include/clang/Sema/RISCVIntrinsicManager.h
+++ b/clang/include/clang/Sema/RISCVIntrinsicManager.h
@@ -28,6 +28,8 @@ class RISCVIntrinsicManager {
 
   virtual ~RISCVIntrinsicManager() = default;
 
+  virtual void InitIntrinsicList() = 0;
+
   // Create RISC-V intrinsic and insert into symbol table and return true if
   // found, otherwise return false.
   virtual bool CreateIntrinsicIfFound(LookupResult &LR, IdentifierInfo *II,

diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index ba873b01874544..d1ff688c2a21d0 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -937,6 +937,8 @@ bool Sema::LookupBuiltin(LookupResult &R) {
 if (!RVIntrinsicManager)
   RVIntrinsicManager = CreateRISCVIntrinsicManager(*this);
 
+RVIntrinsicManager->InitIntrinsicList();
+
 if (RVIntrinsicManager->CreateIntrinsicIfFound(R, II, PP))
   return true;
   }

diff  --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp 
b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
index 5f172d7275c088..fc3086c7d78f06 100644
--- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -158,6 +158,8 @@ class RISCVIntrinsicManagerImpl : public 
sema::RISCVIntrinsicManager {
   Sema &S;
   ASTContext &Context;
   RVVTypeCache TypeCache;
+  bool ConstructedRISCVVBuiltins;
+  bool ConstructedRISCVSiFiveVectorBuiltins;
 
   // List of all RVV intrinsic.
   std::vector IntrinsicList;
@@ -166,8 +168,6 @@ class RISCVIntrinsicManagerImpl : public 
sema::RISCVIntrinsicManager {
   // Mapping function name to RVVOverloadIntrinsicDef.
   StringMap OverloadIntrinsics;
 
-  // Create IntrinsicList
-  void InitIntrinsicList();
 
   // Create RVVIntrinsicDef.
   void InitRVVIntrinsic(const RVVIntrinsicRecord &Record, StringRef SuffixStr,
@@ -179,11 +179,18 @@ class RISCVIntrinsicManagerImpl : public 
sema::RISCVIntrinsicManager {
   Preprocessor &PP, unsigned Index,
   bool IsOverload);
 
+  void ConstructRVVIntrinsics(ArrayRef Recs,
+  IntrinsicKind K);
+
 public:
   RISCVIntrinsicManagerImpl(clang::Sema &S) : S(S), Context(S.Context) {
-InitIntrinsicList();
+ConstructedRISCVVBuiltins = false;
+ConstructedRISCVSiFiveVectorBuiltins = false;
   }
 
+  // Initialize IntrinsicList
+  void InitIntrinsicList() override;
+
   // Create RISC-V vector intrinsic and insert into symbol table if found, and
   // return true, otherwise return false.
   bool CreateIntrinsicIfFound(LookupResult &LR, IdentifierInfo *II,
@@ -191,139 +198,145 @@ class RISCVIntrinsicManagerImpl : public 
sema::RISCVIntrinsicManager {
 };
 } // namespace
 
-void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
+void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
+ArrayRef Recs, IntrinsicKind K) {
   const TargetInfo &TI = Context.getTargetInfo();
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
-
-  auto ConstructRVVIntrinsics = [&](ArrayRef Recs,
-IntrinsicKind K) {
-// Construction of RVVIntrinsicRecords need to sync with 
createRVVIntrinsics
-// in RISCVVEmitter.cpp.
-for (auto &Record : Recs) {
-  // Create Intrinsics for each type and LMUL.
-  BasicType BaseType = BasicType::Unknown;
-  ArrayRef BasicProtoSeq =
-  ProtoSeq2ArrayRef(K, Record.PrototypeIndex, Record.PrototypeLength);
-  ArrayRef SuffixProto =
-  ProtoSeq2ArrayRef(K, Record.SuffixIndex, Record.SuffixLength);
-  ArrayRef OverloadedSuffixProto = ProtoSeq2ArrayRef(
-  K, Record.OverloadedSuffixIndex, Record.OverloadedSuffixSize);
-
-  PolicyScheme UnMaskedPolicyScheme =
-  static_cast(Record.U

[PATCH] D154050: [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

2023-06-29 Thread Yueh-Ting (eop) Chen 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 rGaf19e406f28e: [Clang][RISCV] Fix RISC-V vector / SiFive 
intrinsic inclusion in SemaLookup (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154050

Files:
  clang/include/clang/Sema/RISCVIntrinsicManager.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp.cpp
@@ -0,0 +1,15 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v  \
+// RUN:   -target-feature +xsfvcp \
+// RUN:   -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#include 
+
+#define p27_26 (0b11)
+#define p11_7  (0b1)
+
+void test_sf_vc_xv_se_u64m1(vuint64m1_t vs2, uint64_t rs1, size_t vl) {
+  __riscv_sf_vc_xv_se_u64m1(p27_26, p11_7, vs2, rs1, vl);
+}
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -158,6 +158,8 @@
   Sema &S;
   ASTContext &Context;
   RVVTypeCache TypeCache;
+  bool ConstructedRISCVVBuiltins;
+  bool ConstructedRISCVSiFiveVectorBuiltins;
 
   // List of all RVV intrinsic.
   std::vector IntrinsicList;
@@ -166,8 +168,6 @@
   // Mapping function name to RVVOverloadIntrinsicDef.
   StringMap OverloadIntrinsics;
 
-  // Create IntrinsicList
-  void InitIntrinsicList();
 
   // Create RVVIntrinsicDef.
   void InitRVVIntrinsic(const RVVIntrinsicRecord &Record, StringRef SuffixStr,
@@ -179,11 +179,18 @@
   Preprocessor &PP, unsigned Index,
   bool IsOverload);
 
+  void ConstructRVVIntrinsics(ArrayRef Recs,
+  IntrinsicKind K);
+
 public:
   RISCVIntrinsicManagerImpl(clang::Sema &S) : S(S), Context(S.Context) {
-InitIntrinsicList();
+ConstructedRISCVVBuiltins = false;
+ConstructedRISCVSiFiveVectorBuiltins = false;
   }
 
+  // Initialize IntrinsicList
+  void InitIntrinsicList() override;
+
   // Create RISC-V vector intrinsic and insert into symbol table if found, and
   // return true, otherwise return false.
   bool CreateIntrinsicIfFound(LookupResult &LR, IdentifierInfo *II,
@@ -191,139 +198,145 @@
 };
 } // namespace
 
-void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
+void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
+ArrayRef Recs, IntrinsicKind K) {
   const TargetInfo &TI = Context.getTargetInfo();
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
-
-  auto ConstructRVVIntrinsics = [&](ArrayRef Recs,
-IntrinsicKind K) {
-// Construction of RVVIntrinsicRecords need to sync with createRVVIntrinsics
-// in RISCVVEmitter.cpp.
-for (auto &Record : Recs) {
-  // Create Intrinsics for each type and LMUL.
-  BasicType BaseType = BasicType::Unknown;
-  ArrayRef BasicProtoSeq =
-  ProtoSeq2ArrayRef(K, Record.PrototypeIndex, Record.PrototypeLength);
-  ArrayRef SuffixProto =
-  ProtoSeq2ArrayRef(K, Record.SuffixIndex, Record.SuffixLength);
-  ArrayRef OverloadedSuffixProto = ProtoSeq2ArrayRef(
-  K, Record.OverloadedSuffixIndex, Record.OverloadedSuffixSize);
-
-  PolicyScheme UnMaskedPolicyScheme =
-  static_cast(Record.UnMaskedPolicyScheme);
-  PolicyScheme MaskedPolicyScheme =
-  static_cast(Record.MaskedPolicyScheme);
-
-  const Policy DefaultPolicy;
-
-  llvm::SmallVector ProtoSeq =
-  RVVIntrinsic::computeBuiltinTypes(
-  BasicProtoSeq, /*IsMasked=*/false,
-  /*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF,
-  UnMaskedPolicyScheme, DefaultPolicy, Record.IsTuple);
-
-  llvm::SmallVector ProtoMaskSeq =
-  RVVIntrinsic::computeBuiltinTypes(
-  BasicProtoSeq, /*IsMasked=*/true, Record.HasMaskedOffOperand,
-  Record.HasVL, Record.NF, MaskedPolicyScheme, DefaultPolicy,
-  Record.IsTuple);
-
-  bool UnMaskedHasPolicy = UnMaskedPolicyScheme != PolicyScheme::SchemeNone;
-  bool MaskedHasPolicy = MaskedPolicyScheme != PolicyScheme::SchemeNone;
-  SmallVector SupportedUnMaskedPolicies =
-  RVVIntrinsic::getSupportedUnMaskedPolicies();
-  SmallVector SupportedMaskedPolicies =
-  RVVIntrinsic::getSupportedMaskedPolicies(Record.HasTailPolicy,
-   Record.HasMaskPolicy);
-
-  for (unsigne

[PATCH] D152900: [clangd] Update symbol collector to use include-cleaner.

2023-06-29 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 535740.
VitaNuo marked 27 inline comments as done.
VitaNuo added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152900

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestWorkspace.cpp

Index: clang-tools-extra/clangd/unittests/TestWorkspace.cpp
===
--- clang-tools-extra/clangd/unittests/TestWorkspace.cpp
+++ clang-tools-extra/clangd/unittests/TestWorkspace.cpp
@@ -7,8 +7,10 @@
 //===--===//
 
 #include "TestWorkspace.h"
+#include "clang-include-cleaner/Record.h"
 #include "index/FileIndex.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 
 namespace clang {
@@ -21,14 +23,12 @@
   continue;
 TU.Code = Input.second.Code;
 TU.Filename = Input.first().str();
-TU.preamble(
-[&](CapturedASTCtx ASTCtx,
-const std::shared_ptr CanonIncludes) {
-  auto &Ctx = ASTCtx.getASTContext();
-  auto &PP = ASTCtx.getPreprocessor();
-  Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
-*CanonIncludes);
-});
+TU.preamble([&](CapturedASTCtx ASTCtx,
+std::shared_ptr PI) {
+  auto &Ctx = ASTCtx.getASTContext();
+  auto &PP = ASTCtx.getPreprocessor();
+  Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP, PI);
+});
 ParsedAST MainAST = TU.build();
 Index->updateMain(testPath(Input.first()), MainAST);
   }
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -164,9 +164,9 @@
 
 SymbolSlab TestTU::headerSymbols() const {
   auto AST = build();
-  return std::get<0>(indexHeaderSymbols(/*Version=*/"null", AST.getASTContext(),
-AST.getPreprocessor(),
-AST.getCanonicalIncludes()));
+  return std::get<0>(indexHeaderSymbols(
+  /*Version=*/"null", AST.getASTContext(), AST.getPreprocessor(),
+  AST.getPragmaIncludes()));
 }
 
 RefSlab TestTU::headerRefs() const {
@@ -179,7 +179,7 @@
   auto Idx = std::make_unique();
   Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
   AST.getASTContext(), AST.getPreprocessor(),
-  AST.getCanonicalIncludes());
+  AST.getPragmaIncludes());
   Idx->updateMain(testPath(Filename), AST);
   return std::move(Idx);
 }
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -18,6 +18,7 @@
 #include "TUScheduler.h"
 #include "TestFS.h"
 #include "TestIndex.h"
+#include "clang-include-cleaner/Record.h"
 #include "support/Cancellation.h"
 #include "support/Context.h"
 #include "support/Path.h"
@@ -1129,9 +1130,9 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification &N)
 : BlockVersion(BlockVersion), N(N) {}
-void
-onPreambleAST(PathRef Path, llvm::StringRef Version, CapturedASTCtx,
-  const std::shared_ptr) override {
+void onPreambleAST(
+PathRef Path, llvm::StringRef Version, CapturedASTCtx,
+std::shared_ptr) override {
   if (Version == BlockVersion)
 N.wait();
 }
@@ -1208,9 +1209,9 @@
 BlockPreambleThread(Notification &UnblockPreamble, DiagsCB CB)
 : UnblockPreamble(UnblockPreamble), CB(std::move(CB)) {}
 
-void
-onPreambleAST(PathRef Path, llvm::StringRe

[PATCH] D152900: [clangd] Update symbol collector to use include-cleaner.

2023-06-29 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thanks for comments!




Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.h:40
   /// Adds a file-to-string mapping from \p ID to \p CanonicalPath.
   void addMapping(FileEntryRef Header, llvm::StringRef CanonicalPath);
 

kadircet wrote:
> AFAICT, only users of this endpoint were in `IWYUCommentHandler` (and some 
> tests). we can also get rid of this one now.
> 
> More importantly now this turns into a mapper used only by symbolcollector, 
> that can be cheaply created at use time (we just copy around a pointer every 
> time we want to create it). so you can drop `CanonicalIncludes` from all of 
> the interfaces, including `SymbolCollector::Options` and create one on demand 
> in `HeaderFileURICache`. all we need is langopts, and it's available through 
> preprocessor (not necessarily on construction, but at the time when we want 
> to do the mappings).
> 
> As you're already touching all of the interfaces that propagate 
> `CanonicalIncludes` around, hopefully this change should only make things 
> simpler (and you already need to touch them when you rebase), but if that 
> feels like too much churn in this patch feel free to do that in a follow up 
> as well.
> ... and create one on demand in HeaderFileURICache. all we need is langopts, 
> and it's available through preprocessor (not necessarily on construction, but 
> at the time when we want to do the mappings

This time sounds a little late, since we don't want to rebuild the system 
header mapping every time we request a mapping for a particular header. 
Cache construction time doesn't work, since it happens before the preprocessor 
is set in the symbol collector (and we need the preprocessor to retrieve 
language options).
So far the safe place I've found is right after the preprocessor is set in the 
symbol collector. Another option is to collect the system header options in the 
finish() method, but I can't see why we would need to delay until then. 



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:250
+  // of whether it's an otherwise-good header (header guards etc).
+  llvm::StringRef mapCanonical(FileID FID) {
+if (SysHeaderMapping) {

kadircet wrote:
> let's change the interface here to take in a `FileEntry` instead.
I believe it has to be `FileEntryRef` instead. This is what the 
`CanonicalIncludes::mapHeader` expects, and this is also seems right (somewhere 
in the Clang docs I've read "everything that needs a name should use 
`FileEntryRef`", and name is exactly what `CanonicalIncludes::mapHeader` 
needs). 

For the case of a physical header (i.e., `FileEntry` instance) I've switched to 
using `getLastRef` now. There's also another API `FileManager::getFileRef` 
where I could try passing the result of `tryGetRealPathName`. I am not sure I 
have enough information to judge if any of these options is distinctly better.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:412-413
+
+if (auto Verbatim = PI->getPublic(FileEntry); !Verbatim.empty())
+  return Verbatim;
+

kadircet wrote:
> let's move this logic into `mapCanonical` too.
This would deliver wrong results for C++. We would basically get every 
IWYU-public header twice: once through the `verbatim` branch of the 
include_cleaner results, and then once again when mapping the physical private 
file to a canonical version (e.g., for system headers).



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:849
+  shouldCollectIncludePath(S.SymInfo.Kind) != Symbol::Invalid)
+SymbolProviders[S.ID] = std::move(Headers);
+}

kadircet wrote:
> because you're taking in `Headers` as `const`, this move is not actually 
> moving.
Ok, this is not relevant anymore, but I am not sure I understand why. Am I not 
allowed to say that I don't need this variable/memory anymore, even though it's 
`const`?



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:877
   // We delay this until end of TU so header guards are all resolved.
   for (const auto &[SID, FID] : IncludeFiles) {
 if (const Symbol *S = Symbols.find(SID)) {

kadircet wrote:
> let's iterate over `SymbolProviders` instead, as `IncludeFiles` is a legacy 
> struct now.
Not sure I'm following. Iterating over `SymbolProviders` means retrieving 
`include_cleaner::Header`s. How would I handle the entire Obj-C part then, 
without the FID of the include header? 



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:930
+auto Canonical =
+HeaderFileURIs->mapCanonical(SM.getOrCreateFileID(
+H.physical(), SrcMgr::CharacteristicKind::C_User));

kadircet wrote:
> no need for the `getOrCreateFileID` after you change parameter for 
> `mapCanonical` to be a file entry.
Still need the `g

[PATCH] D154043: [CodeGen] -fsanitize={function, kcfi}: ensure align 4 if +strict-align

2023-06-29 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

The details of this approach look good to me, but is this the best place to 
solve it? Doing it in clang means that //every// language front end that wants 
to use either of these sanitizers is responsible for doing this same work: 
tagging every IR function with `align 4` if it also has `!kcfi_type` or 
`!func_sanitize`, and perhaps also checking the target-features to decide 
whether to do that.

I'd imagined the problem being solved at a lower level, when converting the IR 
into actual function prologues, so that all front ends generating IR would 
benefit from the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154043

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


[PATCH] D154068: [clangd] Don't show header for namespace decl in Hover

2023-06-29 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo accepted this revision.
VitaNuo added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154068

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


[PATCH] D153652: [Support] Don't set "all_exe" mode by default for file written by llvm::writeToOutput

2023-06-29 Thread James Henderson via Phabricator via cfe-commits
jhenderson accepted this revision.
jhenderson added a comment.
This revision is now accepted and ready to land.

The new test LGTM, albeit with one query: I assume `umask` sets some global 
state. When the lit unit tests are running, do the tests within the same 
process run sequentially, or are they in parallel at all? If the latter, there 
could be some thread-safety issue, although I suspect the tests are run 
sequentially.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153652

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


[clang] 5e87ec1 - [SystemZ][z/OS] Add support for z/OS link step (executable and shared libs)

2023-06-29 Thread Abhina Sreeskantharajan via cfe-commits

Author: Sean Perry
Date: 2023-06-29T08:57:11-04:00
New Revision: 5e87ec1e19ce0226ff7c812db07aec1734c407b3

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

LOG: [SystemZ][z/OS] Add support for z/OS link step (executable and shared libs)

Add support for performing a link step on z/OS.  This will support C & C++ 
building executables and shared libs.

Reviewed By: zibi, abhina.sreeskantharajan

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

Added: 
clang/test/Driver/zos-ld.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/ZOS.cpp
clang/lib/Driver/ToolChains/ZOS.h

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 312fa822bf5ccf..a352e20f1f9a0c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3720,6 +3720,12 @@ def meabi : Separate<["-"], "meabi">, Group, 
Flags<[CC1Option]>,
   NormalizedValues<["Default", "EABI4", "EABI5", "GNU"]>;
 def mtargetos_EQ : Joined<["-"], "mtargetos=">, Group,
   HelpText<"Set the deployment target to be the specified OS and OS version">;
+def mzos_hlq_le_EQ : Joined<["-"], "mzos-hlq-le=">, MetaVarName<"">,
+  HelpText<"High level qualifier for z/OS Language Environment datasets">;
+def mzos_hlq_clang_EQ : Joined<["-"], "mzos-hlq-clang=">, 
MetaVarName<"">,
+  HelpText<"High level qualifier for z/OS C++RT side deck datasets">;
+def mzos_hlq_csslib_EQ : Joined<["-"], "mzos-hlq-csslib=">, 
MetaVarName<"">,
+  HelpText<"High level qualifier for z/OS CSSLIB dataset">;
 
 def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, 
Group;
 def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, 
Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/ZOS.cpp 
b/clang/lib/Driver/ToolChains/ZOS.cpp
index f921227076a5ed..c5100a38648580 100644
--- a/clang/lib/Driver/ToolChains/ZOS.cpp
+++ b/clang/lib/Driver/ToolChains/ZOS.cpp
@@ -11,8 +11,10 @@
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
 using namespace clang::driver;
+using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
 using namespace llvm::opt;
 using namespace clang;
@@ -31,3 +33,211 @@ void ZOS::addClangTargetOptions(const ArgList &DriverArgs,
 options::OPT_fno_aligned_allocation))
 CC1Args.push_back("-faligned-alloc-unavailable");
 }
+
+void zos::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
+  const InputInfo &Output,
+  const InputInfoList &Inputs,
+  const ArgList &Args,
+  const char *LinkingOutput) const {
+  ArgStringList CmdArgs;
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  // Specify assembler output file.
+  assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
+  if (Output.isFilename()) {
+CmdArgs.push_back("-o");
+CmdArgs.push_back(Output.getFilename());
+  }
+
+  // Specify assembler input file.
+  // The system assembler on z/OS takes exactly one input file. The driver is
+  // expected to invoke as(1) separately for each assembler source input file.
+  if (Inputs.size() != 1)
+llvm_unreachable("Invalid number of input files.");
+  const InputInfo &II = Inputs[0];
+  assert((II.isFilename() || II.isNothing()) && "Invalid input.");
+  if (II.isFilename())
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs));
+}
+
+static std::string getLEHLQ(const ArgList &Args) {
+  if (Args.hasArg(options::OPT_mzos_hlq_le_EQ)) {
+Arg *LEHLQArg = Args.getLastArg(options::OPT_mzos_hlq_le_EQ);
+StringRef HLQ = LEHLQArg->getValue();
+if (!HLQ.empty())
+  return HLQ.str();
+  }
+  return "CEE";
+}
+
+static std::string getClangHLQ(const ArgList &Args) {
+  if (Args.hasArg(options::OPT_mzos_hlq_clang_EQ)) {
+Arg *ClangHLQArg = Args.getLastArg(options::OPT_mzos_hlq_clang_EQ);
+StringRef HLQ = ClangHLQArg->getValue();
+if (!HLQ.empty())
+  return HLQ.str();
+  }
+  return getLEHLQ(Args);
+}
+
+static std::string getCSSHLQ(const ArgList &Args) {
+  if (Args.hasArg(options::OPT_mzos_hlq_csslib_EQ)) {
+Arg *CsslibHLQArg = Args.getLastArg(options::OPT_mzos_hlq_csslib_EQ);
+StringRef HLQ = CsslibHLQArg->getValue();
+if (!HLQ.empty())
+  return HLQ.str();
+  }
+  return "SYS1";
+}
+
+void zos::Lin

[PATCH] D153580: [SystemZ][z/OS] Add support for z/OS link step (executable and shared libs)

2023-06-29 Thread Abhina Sree 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 rG5e87ec1e19ce: [SystemZ][z/OS] Add support for z/OS link step 
(executable and shared libs) (authored by SeanP, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153580

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/test/Driver/zos-ld.c

Index: clang/test/Driver/zos-ld.c
===
--- /dev/null
+++ clang/test/Driver/zos-ld.c
@@ -0,0 +1,123 @@
+// General tests that ld invocations for z/OS are valid.
+
+// 1. General C link for executable
+// RUN: %clang -### --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=C-LD %s
+
+// C-LD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// C-LD: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// C-LD-SAME: "-e" "CELQSTRT"
+// C-LD-SAME: "-O" "CELQSTRT"
+// C-LD-SAME: "-u" "CELQMAIN"
+// C-LD-SAME: "-x" "/dev/null"
+// C-LD-SAME: "-S" "//'CEE.SCEEBND2'"
+// C-LD-SAME: "-S" "//'SYS1.CSSLIB'"
+// C-LD-SAME: "//'CEE.SCEELIB(CELQS001)'"
+// C-LD-SAME: "//'CEE.SCEELIB(CELQS003)'"
+// C-LD-SAME: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}zos{{/|}}libclang_rt.builtins-s390x.a"
+
+// 2. General C link for dll
+// RUN: %clang -### --shared --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=C-LD-DLL %s
+
+// C-LD-DLL: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// C-LD-DLL: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// C-LD-DLL-NOT: "-e" "CELQSTRT"
+// C-LD-DLL-NOT: "-O" "CELQSTRT"
+// C-LD-DLL-NOT: "-u" "CELQMAIN"
+// C-LD-DLL-SAME: "-x" "{{.*}}.x"
+// C-LD-DLL-SAME: "-S" "//'CEE.SCEEBND2'"
+// C-LD-DLL-SAME: "-S" "//'SYS1.CSSLIB'"
+// C-LD-DLL-SAME: "//'CEE.SCEELIB(CELQS001)'"
+// C-LD-DLL-SAME: "//'CEE.SCEELIB(CELQS003)'"
+// C-LD-DLL-SAME: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}zos{{/|}}libclang_rt.builtins-s390x.a"
+
+// 3. General C++ link for executable
+// RUN: %clangxx -### --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CXX-LD %s
+
+// CXX-LD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CXX-LD: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// CXX-LD-SAME: "-e" "CELQSTRT"
+// CXX-LD-SAME: "-O" "CELQSTRT"
+// CXX-LD-SAME: "-u" "CELQMAIN"
+// CXX-LD-SAME: "-x" "/dev/null"
+// CXX-LD-SAME: "-S" "//'CEE.SCEEBND2'"
+// CXX-LD-SAME: "-S" "//'SYS1.CSSLIB'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CELQS001)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CELQS003)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQCXE)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQCXS)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQCXP)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQCXA)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQXLA)'"
+// CXX-LD-SAME: "//'CEE.SCEELIB(CRTDQUNW)'"
+// CXX-LD-SAME: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}zos{{/|}}libclang_rt.builtins-s390x.a"
+
+// 4. General C++ link for dll
+// RUN: %clangxx -### --shared --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CXX-LD-DLL %s
+
+// CXX-LD-DLL: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CXX-LD-DLL: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// CXX-LD-DLL-NOT: "-e" "CELQSTRT"
+// CXX-LD-DLL-NOT: "-O" "CELQSTRT"
+// CXX-LD-DLL-NOT: "-u" "CELQMAIN"
+// CXX-LD-DLL-SAME: "-x" "{{.*}}.x"
+// CXX-LD-DLL-SAME: "-S" "//'CEE.SCEEBND2'"
+// CXX-LD-DLL-SAME: "-S" "//'SYS1.CSSLIB'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CELQS001)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CELQS003)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQCXE)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQCXS)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQCXP)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQCXA)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQXLA)'"
+// CXX-LD-DLL-SAME: "//'CEE.SCEELIB(CRTDQUNW)'"
+// CXX-LD-DLL-SAME: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}zos{{/|}}libclang_rt.builtins-s390x.a"
+
+// 5. C++ link for executable w/ -mzos-hlq-le=, -mzos-hlq-csslib=
+// RUN: %clangxx -### --target=s390x-ibm-zos %s 2>&1 \
+// RUN:   -mzos-hlq-le= -mzos-hlq-csslib= \
+// RUN:   | FileCheck --check-prefix=CXX-LD5 %s
+
+// CXX-LD5: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CXX-LD5: "AMODE=64,LIST,DYNAM=DLL,MSGLEVEL=4,CASE=MIXED,REUS=RENT"
+// CXX-LD5-SAME: "-e" "CELQSTRT"
+// CXX-LD5-SAME: "-O" "CELQSTRT"
+// CXX-LD5-SAME: "-u" "CELQMAIN"
+// CXX-LD5-SAME: "-x" "/dev/null"
+// CXX-LD5-SAME: "-S" "//'.SCEEBND2'"
+// CXX-LD5-SAME: "-S" "//'.CSSLIB'"
+// CXX-LD5-SAME: "//'.SCEELIB(CELQS001)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CELQS003)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CRTDQCXE)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CRTDQCXS)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CRTDQCXP)'"
+// CXX-LD5-SAME: "//'.SCEELIB(CRTDQCXA)'"
+// CXX-LD5-SAME: "//'.SCEE

[PATCH] D153363: [clang][analyzer] No end-of-file when seek to file begin.

2023-06-29 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy accepted this revision.
donat.nagy 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/D153363/new/

https://reviews.llvm.org/D153363

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


[PATCH] D154077: [HIP] Fix version detection for old HIP-PATH

2023-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: kerbowa, jvesely.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a subscriber: MaskRay.

ROCm used to install components under individual directories,
e.g. HIP installed to /opt/rocm/hip and rocblas installed to
/opt/rocm/rocblas. ROCm has transitioned to a flat directory
structure where all components are installed to /opt/rocm.
HIP-PATH and --hip-path are supposed to be /opt/rocm as
clang detect HIP version by /opt/rocm/share/hip/version.
However, some existing HIP app still uses HIP-PATH=/opt/rocm/hip.
To avoid regression, clang will also try detect share/hip/version
under the parent directory of HIP-PATH or --hip-path.
This way, the detection will work for both new HIP-PATH and
old HIP-PATH.


https://reviews.llvm.org/D154077

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/hip-version.hip


Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -22,11 +22,17 @@
 // RUN: mkdir -p %t/Inputs
 // RUN: cp -r %S/Inputs/rocm %t/Inputs
 // RUN: mkdir -p %t/Inputs/rocm/share/hip
+// RUN: mkdir -p %t/Inputs/rocm/hip
 // RUN: mv %t/Inputs/rocm/bin/.hipVersion %t/Inputs/rocm/share/hip/version
 // RUN: %clang -v --rocm-path=%t/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm 2>&1 \
+// RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm/hip 2>&1 \
+// RUN:   | FileCheck -check-prefixes=HIP-PATH %s
 
 // FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd
+// HIP-PATH: Found HIP installation: {{.*Inputs.*rocm.*hip}}, version 
3.6.20214-a2917cd
 
 // When --rocm-path is set and .hipVersion is not found, use default version
 
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -461,9 +461,14 @@
 SharePath = InstallPath;
 llvm::sys::path::append(SharePath, "share");
 
+// Get parent of InstallPath and append "share"
+SmallString<0> ParentSharePath = llvm::sys::path::parent_path(InstallPath);
+llvm::sys::path::append(ParentSharePath, "share");
+
 // If HIP version file can be found and parsed, use HIP version from there.
 for (const auto &VersionFilePath :
  {std::string(SharePath) + "/hip/version",
+  std::string(ParentSharePath) + "/hip/version",
   std::string(BinPath) + "/.hipVersion"}) {
   llvm::ErrorOr> VersionFile =
   FS.getBufferForFile(VersionFilePath);


Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -22,11 +22,17 @@
 // RUN: mkdir -p %t/Inputs
 // RUN: cp -r %S/Inputs/rocm %t/Inputs
 // RUN: mkdir -p %t/Inputs/rocm/share/hip
+// RUN: mkdir -p %t/Inputs/rocm/hip
 // RUN: mv %t/Inputs/rocm/bin/.hipVersion %t/Inputs/rocm/share/hip/version
 // RUN: %clang -v --rocm-path=%t/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm 2>&1 \
+// RUN:   | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --hip-path=%t/Inputs/rocm/hip 2>&1 \
+// RUN:   | FileCheck -check-prefixes=HIP-PATH %s
 
 // FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd
+// HIP-PATH: Found HIP installation: {{.*Inputs.*rocm.*hip}}, version 3.6.20214-a2917cd
 
 // When --rocm-path is set and .hipVersion is not found, use default version
 
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -461,9 +461,14 @@
 SharePath = InstallPath;
 llvm::sys::path::append(SharePath, "share");
 
+// Get parent of InstallPath and append "share"
+SmallString<0> ParentSharePath = llvm::sys::path::parent_path(InstallPath);
+llvm::sys::path::append(ParentSharePath, "share");
+
 // If HIP version file can be found and parsed, use HIP version from there.
 for (const auto &VersionFilePath :
  {std::string(SharePath) + "/hip/version",
+  std::string(ParentSharePath) + "/hip/version",
   std::string(BinPath) + "/.hipVersion"}) {
   llvm::ErrorOr> VersionFile =
   FS.getBufferForFile(VersionFilePath);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

2023-06-29 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

Thanks for the update! I have two minor remarks (string handling is complicated 
in C++...) but the code looks good otherwise.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1305
+  std::string Note =
+  llvm::formatv(Case.getNote().str().c_str(),
+cast(Call.getDecl())->getDeclName());

Consider using the method `StringRef::data()` which directly converts a 
`StringRef` to a `const char *`. Your two-step conversion has the advantage 
that it adds a `\0` terminator even if the `StringRef` isn't null-terminated, 
but I cannot imagine a "natural" code change that would introduce references to 
non-null-terminated char arrays as note message templates.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1321
+  if (Node->succ_size() > 1)
+return Note.c_str();
+  return "";

The return type of this lambda is `std::string`, so I think it's pointless to 
convert `std::string Note` to a C string (which will be used to implicitly 
construct another `std::string`). 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

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


[PATCH] D153860: [clang-tidy] Fix modernize-use-std-print check when return value used

2023-06-29 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09ed2102eab5: [clang-tidy] Fix modernize-use-std-print check 
when return value used (authored by mikecrowe, committed by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153860

Files:
  clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-absl.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp
@@ -1,11 +1,11 @@
 // RUN: %check_clang_tidy -check-suffixes=,STRICT \
 // RUN:   -std=c++23 %s modernize-use-std-print %t -- \
 // RUN:   -config="{CheckOptions: [{key: StrictMode, value: true}]}" \
-// RUN:   -- -isystem %clang_tidy_headers
+// RUN:   -- -isystem %clang_tidy_headers -fexceptions
 // RUN: %check_clang_tidy -check-suffixes=,NOTSTRICT \
 // RUN:   -std=c++23 %s modernize-use-std-print %t -- \
 // RUN:   -config="{CheckOptions: [{key: StrictMode, value: false}]}" \
-// RUN:   -- -isystem %clang_tidy_headers
+// RUN:   -- -isystem %clang_tidy_headers -fexceptions
 #include 
 #include 
 #include 
@@ -44,6 +44,239 @@
   // CHECK-FIXES: std::println("Hello");
 }
 
+// std::print returns nothing, so any callers that use the return
+// value cannot be automatically translated.
+int printf_uses_return_value(int choice) {
+  const int i = printf("Return value assigned to variable %d\n", 42);
+
+  extern void accepts_int(int);
+  accepts_int(printf("Return value passed to function %d\n", 42));
+
+  if (choice == 0)
+printf("if body %d\n", i);
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("if body {}", i);
+  else if (choice == 1)
+printf("else if body %d\n", i);
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("else if body {}", i);
+  else
+printf("else body %d\n", i);
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("else body {}", i);
+
+  if (printf("Return value used as boolean in if statement"))
+if (printf("Return value used in expression if statement") == 44)
+  if (const int j = printf("Return value used in assignment in if statement"))
+if (const int k = printf("Return value used with initializer in if statement"); k == 44)
+  ;
+
+  int d = 0;
+  while (printf("%d", d) < 2)
+++d;
+
+  while (true)
+printf("while body %d\n", i);
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("while body {}", i);
+
+  do
+printf("do body %d\n", i);
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("do body {}", i);
+  while (true);
+
+  for (;;)
+printf("for body %d\n", i);
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("for body {}", i);
+
+  for (printf("for init statement %d\n", i);;)
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("for init statement {}", i);
+;;
+
+  for (int j = printf("for init statement %d\n", i);;)
+;;
+
+  for (; printf("for condition %d\n", i);)
+;;
+
+  for (;; printf("for expression %d\n", i))
+// CHECK-MESSAGES: [[@LINE-1]]:11: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("for expression {}", i)
+;;
+
+  for (auto C : "foo")
+printf("ranged-for body %d\n", i);
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("ranged-for body {}", i);
+
+  switch (1) {
+  case 1:
+printf("switch case body %d\n", i);
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+// CHECK-FIXES: std::println("switch case body {}", i);
+break;
+  default:
+printf("switch default body %d\n", i);
+// CHECK-MESSAGES: [[@LIN

[clang-tools-extra] 09ed210 - [clang-tidy] Fix modernize-use-std-print check when return value used

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

Author: Mike Crowe
Date: 2023-06-29T14:00:08Z
New Revision: 09ed2102eab5d3d3786046009ff0d6724118b76b

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

LOG: [clang-tidy] Fix modernize-use-std-print check when return value used

The initial implementation of the modernize-use-std-print check was
capable of converting calls to printf (etc.) which used the return value
to calls to std::print which has no return value, thus breaking the
code.

Use code inspired by the implementation of bugprone-unused-return-value
check to ignore cases where the return value is used. Add appropriate
lit test cases and documentation.

Reviewed By: PiotrZSL

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-absl.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index 9b368f9a3e6c94..b1e1189d4ed775 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -70,27 +70,53 @@ void UseStdPrintCheck::registerPPCallbacks(const 
SourceManager &SM,
   IncludeInserter.registerPreprocessor(PP);
 }
 
+static clang::ast_matchers::StatementMatcher
+unusedReturnValue(clang::ast_matchers::StatementMatcher MatchedCallExpr) {
+  auto UnusedInCompoundStmt =
+  compoundStmt(forEach(MatchedCallExpr),
+   // The checker can't currently 
diff erentiate between the
+   // return statement and other statements inside GNU 
statement
+   // expressions, so disable the checker inside them to avoid
+   // false positives.
+   unless(hasParent(stmtExpr(;
+  auto UnusedInIfStmt =
+  ifStmt(eachOf(hasThen(MatchedCallExpr), hasElse(MatchedCallExpr)));
+  auto UnusedInWhileStmt = whileStmt(hasBody(MatchedCallExpr));
+  auto UnusedInDoStmt = doStmt(hasBody(MatchedCallExpr));
+  auto UnusedInForStmt =
+  forStmt(eachOf(hasLoopInit(MatchedCallExpr),
+ hasIncrement(MatchedCallExpr), hasBody(MatchedCallExpr)));
+  auto UnusedInRangeForStmt = cxxForRangeStmt(hasBody(MatchedCallExpr));
+  auto UnusedInCaseStmt = switchCase(forEach(MatchedCallExpr));
+
+  return stmt(anyOf(UnusedInCompoundStmt, UnusedInIfStmt, UnusedInWhileStmt,
+UnusedInDoStmt, UnusedInForStmt, UnusedInRangeForStmt,
+UnusedInCaseStmt));
+}
+
 void UseStdPrintCheck::registerMatchers(MatchFinder *Finder) {
   if (!PrintfLikeFunctions.empty())
 Finder->addMatcher(
-callExpr(argumentCountAtLeast(1),
- hasArgument(0, stringLiteral(isOrdinary())),
- callee(functionDecl(
-unless(cxxMethodDecl()),
-
matchers::matchesAnyListedName(PrintfLikeFunctions))
-.bind("func_decl")))
-.bind("printf"),
+unusedReturnValue(
+callExpr(argumentCountAtLeast(1),
+ hasArgument(0, stringLiteral(isOrdinary())),
+ callee(functionDecl(unless(cxxMethodDecl()),
+ matchers::matchesAnyListedName(
+ PrintfLikeFunctions))
+.bind("func_decl")))
+.bind("printf")),
 this);
 
   if (!FprintfLikeFunctions.empty())
 Finder->addMatcher(
-callExpr(argumentCountAtLeast(2),
- hasArgument(1, stringLiteral(isOrdinary())),
- callee(functionDecl(unless(cxxMethodDecl()),
- matchers::matchesAnyListedName(
- FprintfLikeFunctions))
-.bind("func_decl")))
-.bind("fprintf"),
+unusedReturnValue(
+callExpr(argumentCountAtLeast(2),
+ hasArgument(1, stringLiteral(isOrdinary())),
+ callee(functionDecl(unless(cxxMethodDecl()),
+ matchers::matchesAnyListedName(
+ FprintfLikeFunctions))
+.bind("func_decl")))
+.bind("fprintf")),
 this);
 }
 

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst 
b/clang

[clang] 8038086 - [clang][Sema] Remove dead diagnostic for loss of __unaligned qualifier

2023-06-29 Thread Takuya Shimizu via cfe-commits

Author: Takuya Shimizu
Date: 2023-06-29T23:02:09+09:00
New Revision: 8038086aa75a122e5e632ebb1e7da06a2f7eed4b

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

LOG: [clang][Sema] Remove dead diagnostic for loss of __unaligned qualifier

D120936 has made the loss of `__unaligned` qualifier NOT a bad-conversion.
Because of this, the bad-conversion note about the loss of this qualifier does 
not take effect.
e.g.
```
void foo(int *ptr);

void func(const __unaligned int *var) { foo(var); }
```
BEFORE this patch:
```
source.cpp:3:41: error: no matching function for call to 'foo'
3 | void func(const __unaligned int *var) { foo(var); }
  | ^~~
source.cpp:1:6: note: candidate function not viable: 1st argument ('const 
__unaligned int *') would lose __unaligned qualifier
1 | void foo(int *ptr);
  |  ^
2 |
3 | void func(const __unaligned int *var) { foo(var); }
  | ~~~
```
AFTER this patch:
```
source.cpp:3:41: error: no matching function for call to 'foo'
3 | void func(const __unaligned int *var) { foo(var); }
  | ^~~
source.cpp:1:6: note: candidate function not viable: 1st argument ('const 
__unaligned int *') would lose const qualifier
1 | void foo(int *ptr);
  |  ^
2 |
3 | void func(const __unaligned int *var) { foo(var); }
  | ~~~
```
Please note the different mentions of `__unaligned` and `const` in notes.

Reviewed By: cjdb, rnk
Differential Revision: https://reviews.llvm.org/D153690

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f00082fad24ddf..03c27a207d5e1b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -375,6 +375,8 @@ Improvements to Clang's diagnostics
   by making use of the syntactical structure of function calls. This avoids 
display
   of syntactically invalid codes in diagnostics.
   (`#57081: `_)
+- Clang no longer emits inappropriate notes about the loss of ``__unaligned`` 
qualifier
+  on overload resolution, when the actual reason for the failure is loss of 
other qualifiers.
 
 Bug Fixes in This Version
 -

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 507e9f11f46646..c2b8bd4ce9cd96 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4700,9 +4700,6 @@ def note_ovl_candidate_bad_cvr : Note<
 "%select{const|restrict|const and restrict|volatile|const and volatile|"
 "volatile and restrict|const, volatile, and restrict}4 qualifier"
 "%select{||s||s|s|s}4">;
-def note_ovl_candidate_bad_unaligned : Note<
-"candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: "
-"%ordinal5 argument (%3) would lose __unaligned qualifier">;
 def note_ovl_candidate_bad_base_to_derived_conv : Note<
 "candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: "
 "cannot %select{convert from|convert from|bind}3 "

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 0d2db9fe88c483..febcbad1f3727a 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -10821,15 +10821,6 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
   return;
 }
 
-if (FromQs.hasUnaligned() != ToQs.hasUnaligned()) {
-  S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_unaligned)
-  << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << 
FnDesc
-  << (FromExpr ? FromExpr->getSourceRange() : SourceRange()) << FromTy
-  << FromQs.hasUnaligned() << I + 1;
-  MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
-  return;
-}
-
 unsigned CVR = FromQs.getCVRQualifiers() & ~ToQs.getCVRQualifiers();
 assert(CVR && "expected qualifiers mismatch");
 

diff  --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp 
b/clang/test/SemaCXX/MicrosoftExtensions.cpp
index effe2e6e6f0866..960030d44f0c15 100644
--- a/clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -68,19 +68,23 @@ __unaligned int aligned_type4::* __unaligned 
p3_aligned_type4 = &aligned_type4::
 void (aligned_type4::*__unaligned p4_aligned_type4)();
 
 // Check that __unaligned qualifier can be used for overloading
-void foo_unaligned(int *arg) {

[PATCH] D153690: [clang][Sema] Remove dead diagnostic for loss of __unaligned qualifier

2023-06-29 Thread Takuya Shimizu 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 rG8038086aa75a: [clang][Sema] Remove dead diagnostic for loss 
of __unaligned qualifier (authored by hazohelet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153690

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp


Index: clang/test/SemaCXX/MicrosoftExtensions.cpp
===
--- clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -68,19 +68,23 @@
 void (aligned_type4::*__unaligned p4_aligned_type4)();
 
 // Check that __unaligned qualifier can be used for overloading
-void foo_unaligned(int *arg) {}
-void foo_unaligned(__unaligned int *arg) {}
+void foo_unaligned(int *arg) {} // expected-note {{not viable: 1st argument 
('const __unaligned int *') would lose const qualifier}}
+void foo_unaligned(__unaligned int *arg) {} // expected-note {{not viable: 1st 
argument ('const __unaligned int *') would lose const qualifier}}
 void foo_unaligned(int arg) {} // expected-note {{previous definition is here}}
-void foo_unaligned(__unaligned int arg) {} // expected-error {{redefinition of 
'foo_unaligned'}}
+void foo_unaligned(__unaligned int arg) {} // expected-error {{redefinition of 
'foo_unaligned'}} \
+   // expected-note {{not viable: no 
known conversion from 'const __unaligned int *' to '__unaligned int'}}
 class A_unaligned {};
 class B_unaligned : public A_unaligned {};
-int foo_unaligned(__unaligned A_unaligned *arg) { return 0; }
-void *foo_unaligned(B_unaligned *arg) { return 0; }
+int foo_unaligned(__unaligned A_unaligned *arg) { return 0; } // expected-note 
{{not viable: no known conversion from 'const __unaligned int *' to 
'__unaligned A_unaligned *'}}
+void *foo_unaligned(B_unaligned *arg) { return 0; } // expected-note {{not 
viable: no known conversion from 'const __unaligned int *' to 'B_unaligned *'}}
 
 void test_unaligned() {
   int *p1 = 0;
   foo_unaligned(p1);
 
+  const __unaligned int *const_p1 = 0;
+  foo_unaligned(const_p1); // expected-error {{no matching function for call 
to 'foo_unaligned'}}
+
   __unaligned int *p2 = 0;
   foo_unaligned(p2);
 
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10821,15 +10821,6 @@
   return;
 }
 
-if (FromQs.hasUnaligned() != ToQs.hasUnaligned()) {
-  S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_unaligned)
-  << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << 
FnDesc
-  << (FromExpr ? FromExpr->getSourceRange() : SourceRange()) << FromTy
-  << FromQs.hasUnaligned() << I + 1;
-  MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
-  return;
-}
-
 unsigned CVR = FromQs.getCVRQualifiers() & ~ToQs.getCVRQualifiers();
 assert(CVR && "expected qualifiers mismatch");
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4700,9 +4700,6 @@
 "%select{const|restrict|const and restrict|volatile|const and volatile|"
 "volatile and restrict|const, volatile, and restrict}4 qualifier"
 "%select{||s||s|s|s}4">;
-def note_ovl_candidate_bad_unaligned : Note<
-"candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: "
-"%ordinal5 argument (%3) would lose __unaligned qualifier">;
 def note_ovl_candidate_bad_base_to_derived_conv : Note<
 "candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: "
 "cannot %select{convert from|convert from|bind}3 "
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -375,6 +375,8 @@
   by making use of the syntactical structure of function calls. This avoids 
display
   of syntactically invalid codes in diagnostics.
   (`#57081: `_)
+- Clang no longer emits inappropriate notes about the loss of ``__unaligned`` 
qualifier
+  on overload resolution, when the actual reason for the failure is loss of 
other qualifiers.
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/MicrosoftExtensions.cpp
===
--- clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -68,19 +68,23 @@
 void (aligned_type4::*__unaligned p4_aligned_type4)();
 
 // Ch

[PATCH] D153857: [clang] Fix new-expression with elaborated-type-specifier

2023-06-29 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 535779.
Fznamznon added a comment.

Move test cases to CXX/drs/dr21xx.cpp, update DR status page, add alignof/sizeof
cases, rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153857

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
  clang/test/CXX/drs/dr19xx.cpp
  clang/test/CXX/drs/dr21xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/Parser/cxx11-type-specifier.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
@@ -12653,7 +12653,7 @@
 https://cplusplus.github.io/CWG/issues/2141.html";>2141
 CD4
 Ambiguity in new-expression with elaborated-type-specifier
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2142.html";>2142
Index: clang/test/Parser/cxx11-type-specifier.cpp
===
--- clang/test/Parser/cxx11-type-specifier.cpp
+++ clang/test/Parser/cxx11-type-specifier.cpp
@@ -13,10 +13,8 @@
   } catch (constexpr int) { // expected-error{{type name does not allow constexpr}}
   }
 
-  // These parse as type definitions, not as type references with braced
-  // initializers. Sad but true...
-  (void) new struct S {}; // expected-error{{'S' cannot be defined in a type specifier}}
-  (void) new enum E { e }; // expected-error{{'E' cannot be defined in a type specifier}}
+  (void) new struct S {};
+  (void) new enum E { e };
 }
 
 // And for trailing-type-specifier-seq
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1078,9 +1078,10 @@
 (void)const_cast(0); // expected-error {{cannot be defined in a type specifier}}
 (void)sizeof(struct F*);
 (void)sizeof(struct F{}*); // expected-error {{cannot be defined in a type specifier}}
-(void)new struct G*;
-(void)new struct G{}*; // expected-error {{cannot be defined in a type specifier}}
+(void)new struct G*; // expected-note {{forward}}
+(void)new struct G{}*; // expected-error {{incomplete}}
 #if __cplusplus >= 201103L
+// expected-error@-2 {{expected expression}}
 (void)alignof(struct H*);
 (void)alignof(struct H{}*); // expected-error {{cannot be defined in a type specifier}}
 #endif
Index: clang/test/CXX/drs/dr21xx.cpp
===
--- clang/test/CXX/drs/dr21xx.cpp
+++ clang/test/CXX/drs/dr21xx.cpp
@@ -120,6 +120,31 @@
 #endif
 }
 
+namespace dr2141 { // dr2141: 17
+struct A{};
+
+template 
+struct B{};
+
+void foo() {
+  struct A *b = (1 == 1) ? new struct A : new struct A;
+  struct S *a = (1 == 1) ? new struct S : new struct S; // expected-error 2{{allocation of incomplete type}} // expected-note 2{{forward}}
+
+#if __cplusplus >= 201103L
+  A *aa = new struct A{};
+  B *bb = new struct B{};
+  (void)new struct C{}; // expected-error {{allocation of incomplete type }} // expected-note {{forward}}
+
+  struct A *c = (1 == 1) ? new struct A {} : new struct A {};
+
+  alignof(struct D{}); // expected-error {{cannot be defined in a type specifier}}
+#endif
+
+  sizeof(struct E{}); // expected-error {{cannot be defined in a type specifier}}
+
+}
+}
+
 namespace dr2157 { // dr2157: 11
 #if __cplusplus >= 201103L
   enum E : int;
Index: clang/test/CXX/drs/dr19xx.cpp
===
--- clang/test/CXX/drs/dr19xx.cpp
+++ clang/test/CXX/drs/dr19xx.cpp
@@ -194,7 +194,7 @@
 enum E : int {1}; // expected-error {{expected identifier}} (not bit-field)
   };
   auto *p1 = new enum E : int; // expected-error {{only permitted as a standalone declaration}}
-  auto *p2 = new enum F : int {}; // expected-error {{cannot be defined in a type specifier}}
+  auto *p2 = new enum F : int {}; // expected-error {{only permitted as a standalone declaration}}
   auto *p3 = true ? new enum G : int {}; // expected-error {{forward reference}} expected-error {{incomplete}} expected-note {{declaration}}
   auto h() -> enum E : int {}; // expected-error {{only permitted as a standalone declaration}}
 
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
@@ -21,8 +21,8 @@
   for (struct S { S(int) {} } s : Undeclared); // expected-error{{types may not be defined in a for range declaration}}
// expected-error@-1{{use of undeclared identifier 'Undeclared'}}
 
-  new struct T {}; 

[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

2023-06-29 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

Please help me, I have no better idea on this issue, do you have any better 
idea? @erichkeane @shafik


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153296

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


[PATCH] D153770: Fix test regression on 32-bit x86.

2023-06-29 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 535783.

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

https://reviews.llvm.org/D153770

Files:
  clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
  clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
  clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c

Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
===
--- clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
@@ -1,15 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -verify -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP \
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=extended -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
 // RUN: -ffp-eval-method=extended -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=source %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=double %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=double %s
 
 
 #ifdef NOERROR
Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
===
--- clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
@@ -1,14 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=double -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=double -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=source %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=extended %s 
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=extended %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=extended %s
 
 #ifdef NOERROR
 // expected-no-diagnostics
Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
===
--- clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
@@ -1,15 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source \
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=source -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=source \
 // RUN: -DNOERROR %s
   
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=d

[PATCH] D153556: [OPENMP52] Initial support for doacross clause.

2023-06-29 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 535794.
jyu2 added a comment.

Sorry, full diff.


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

https://reviews.llvm.org/D153556

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/ordered_ast_print.cpp
  clang/test/OpenMP/ordered_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -444,6 +444,10 @@
   let flangClass = "ScalarIntExpr";
 }
 
+def OMPC_Doacross : Clause<"doacross"> {
+  let clangClass = "OMPDoacrossClause";
+}
+
 //===--===//
 // Definition of OpenMP directives
 //===--===//
@@ -604,7 +608,8 @@
 }
 def OMP_Ordered : Directive<"ordered"> {
   let allowedClauses = [
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1937,6 +1937,7 @@
 CHECK_SIMPLE_CLAUSE(Align, OMPC_align)
 CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)
 CHECK_SIMPLE_CLAUSE(CancellationConstructType, OMPC_cancellation_construct_type)
+CHECK_SIMPLE_CLAUSE(Doacross, OMPC_doacross)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2717,6 +2717,9 @@
   VisitOMPClauseWithPreInit(C);
   Visitor->AddStmt(C->getSize());
 }
+void OMPClauseEnqueue::VisitOMPDoacrossClause(const OMPDoacrossClause *C) {
+  VisitOMPClauseList(C);
+}
 
 } // namespace
 
Index: clang/test/OpenMP/ordered_messages.cpp
===
--- clang/test/OpenMP/ordered_messages.cpp
+++ clang/test/OpenMP/ordered_messages.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 100 -o - %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++98 -o - %s -Wuninitialized
@@ -135,12 +136,48 @@
   }
 #pragma omp parallel for ordered
   for (int i = 0; i < 10; ++i) {
+#if _OPENMP >= 202111
+#pragma omp ordered doacross(source:) // omp52-error {{'ordered' directive with 'doacross' clause cannot be closely nested inside ordered region without specified parameter}}
+#pragma omp ordered doacross(sink : i) // omp52-error {{'ordered' directive with 'doacross' clause cannot be closely nested inside ordered region without specified parameter}}
+#else
 #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
 #pragma omp ordered depend(sink : i) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
+#endif
   }
 #pragma omp parallel for ordered(2) // expected-note 3 {{'ordered' clause with specified parameter}}
   for (int i = 0; i < 10; ++i) {
 for (int j = 0; j < 10; ++j) {
+#if _OPENMP >= 202111
+#pragma omp ordered doacross // omp52-error {{expected '(' after 'doacross'}} omp52-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
+#pragma omp ordered doacross( // omp52-error {{expected ')'}} omp52-error {{expected 'source' or 'sink' in OpenMP clause 'doacross'}} omp52-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} omp52-warning {{missing ':' or ')' aft

[PATCH] D154050: [Clang][RISCV] Fix RISC-V vector / SiFive intrinsic inclusion in SemaLookup

2023-06-29 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:201
 
-void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
+void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
+ArrayRef Recs, IntrinsicKind K) {

As far as I can tell this refactoring was entirely gratuitous, and perhaps a 
regression given the function is only ever used by InitIntrinsicList and thus 
can be hidden as a lambda?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154050

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


[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

2023-06-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 535800.
balazske added a comment.

Fixed review issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

Files:
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/errno-stdlibraryfunctions-notes.c
  clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-path-notes.c
  clang/test/Analysis/stream-errno-note.c
  clang/test/Analysis/stream-note.c

Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -7,11 +7,13 @@
 
 void check_note_at_correct_open(void) {
   FILE *F1 = tmpfile(); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'tmpfile' is successful}}
   if (!F1)
 // expected-note@-1 {{'F1' is non-null}}
 // expected-note@-2 {{Taking false branch}}
 return;
   FILE *F2 = tmpfile();
+  // stdargs-note@-1 {{'tmpfile' is successful}}
   if (!F2) {
 // expected-note@-1 {{'F2' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -20,6 +22,7 @@
   }
   rewind(F2);
   fclose(F2);
+  // stdargs-note@-1 {{'fclose' fails}}
   rewind(F1);
 }
 // expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
@@ -27,6 +30,7 @@
 
 void check_note_fopen(void) {
   FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
   if (!F)
 // expected-note@-1 {{'F' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -37,11 +41,13 @@
 
 void check_note_freopen(void) {
   FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
   if (!F)
 // expected-note@-1 {{'F' is non-null}}
 // expected-note@-2 {{Taking false branch}}
 return;
   F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
+  // stdargs-note@-1 {{'freopen' is successful}}
   if (!F)
 // expected-note@-1 {{'F' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -52,6 +58,8 @@
 
 void check_note_leak_2(int c) {
   FILE *F1 = fopen("foo1.c", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
+  // stdargs-note@-2 {{'fopen' is successful}}
   if (!F1)
 // expected-note@-1 {{'F1' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -59,6 +67,8 @@
 // expected-note@-4 {{Taking false branch}}
 return;
   FILE *F2 = fopen("foo2.c", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
+  // stdargs-note@-2 {{'fopen' is successful}}
   if (!F2) {
 // expected-note@-1 {{'F2' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -84,6 +94,7 @@
 void check_track_null(void) {
   FILE *F;
   F = fopen("foo1.c", "r"); // expected-note {{Value assigned to 'F'}} expected-note {{Assuming pointer value is null}}
+  // stdargs-note@-1 {{'fopen' fails}}
   if (F != NULL) {  // expected-note {{Taking false branch}} expected-note {{'F' is equal to NULL}}
 fclose(F);
 return;
@@ -96,13 +107,16 @@
   FILE *F;
   char Buf[10];
   F = fopen("foo1.c", "r");
+  // stdargs-note@-1 {{'fopen' is successful}}
   if (F == NULL) { // expected-note {{Taking false branch}} expected-note {{'F' is not equal to NULL}}
 return;
   }
   fread(Buf, 1, 1, F);
+  // stdargs-note@-1 {{'fread' fails}}
   if (feof(F)) { // expected-note {{Taking true branch}}
 clearerr(F);
 fread(Buf, 1, 1, F);   // expected-note {{Assuming stream reaches end-of-file here}}
+// stdargs-note@-1 {{'fread' fails}}
 if (feof(F)) { // expected-note {{Taking true branch}}
   fread(Buf, 1, 1, F); // expected-warning {{Read function called when stream is in EOF state. Function has no effect}}
   // expected-note@-1 {{Read function called when stream is in EOF state. Function has no effect}}
@@ -115,10 +129,12 @@
   FILE *F;
   char Buf[10];
   F = fopen("foo1.c", "r");
+  // stdargs-note@-1 {{'fopen' is successful}}
   if (F == NULL) { // expected-note {{Taking false branch}} expected-note {{'F' is not equal to NULL}}
 return;
   }
   fread(Buf, 1, 1, F);
+  // stdargs-note@-1 {{'fread' is successful}}
   if (feof(F)) { // expected-note {{Taking false branch}}
 fclose(F);
 return;
@@ -127,6 +143,7 @@
 return;
   }
   fread(Buf, 1, 1, F);   // expected-note {{Assuming stream reaches end-of-file here}}
+  // stdargs-note@-1 {{'fread' fails}}
   if (feof(F)) { // expected-note {{Taking true branch}}
 fread(Buf, 1, 1, F); // expected-warning {{Read function called when stream is

[PATCH] D153993: [Headers][doc] Add load/store/cmp/cvt intrinsic descriptions to avx2intrin.h

2023-06-29 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/lib/Headers/avx2intrin.h:3474
+///   IF __M[j+31] == 1
+/// result[j+31:j] := Load32(__X+(i*4))
+///   ELSE

pengfei wrote:
> A more intrinsic guide format is `MEM[__X+j:j]`
LoadXX is the syntax in the gather intrinsics, e.g. _mm_mask_i32gather_pd. I'd 
prefer to be consistent.


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

https://reviews.llvm.org/D153993

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


[PATCH] D153359: [clang][Diagnostics] Fix distant source ranges in bad-conversion notes

2023-06-29 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 535801.
hazohelet edited the summary of this revision.
hazohelet added a comment.

Address comment from cjdb

- Added example code & before/after diagnostic display to release note

Thanks for reminding!


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

https://reviews.llvm.org/D153359

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Misc/diag-overload-cand-ranges.cpp
  clang/test/Misc/diag-overload-cand-ranges.mm

Index: clang/test/Misc/diag-overload-cand-ranges.mm
===
--- /dev/null
+++ clang/test/Misc/diag-overload-cand-ranges.mm
@@ -0,0 +1,26 @@
+// RUN: not %clang_cc1 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace -check-prefixes=CHECK,ARC
+// RUN: not %clang_cc1 -fobjc-runtime-has-weak -fobjc-gc -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace -check-prefixes=CHECK,GC
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:15-[[@LINE+1]]:28}: note: {{.*}}: 1st argument
+void powerful(__strong id &);
+void lifetime_gcattr_mismatch() {
+  static __weak id weak_id;
+  powerful(weak_id);
+}
+
+// CHECK:  error: no matching function
+// ARC::{[[@LINE+2]]:11-[[@LINE+2]]:21}: note: {{.*}}: cannot implicitly convert
+// GC: :{[[@LINE+1]]:11-[[@LINE+1]]:21}: note: {{.*}}: no known conversion
+void func(char *uiui);
+
+__attribute__((objc_root_class))
+@interface Interface
+- (void)something;
+@end
+
+@implementation Interface
+- (void)something{
+func(self);
+}
+@end
Index: clang/test/Misc/diag-overload-cand-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-overload-cand-ranges.cpp
@@ -0,0 +1,72 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+// CHECK:  error: no matching function
+template  struct mcdata {
+  typedef int result_type;
+};
+template  typename mcdata::result_type wrap_mean(mcdata const &);
+// CHECK:  :{[[@LINE+1]]:19-[[@LINE+1]]:53}: note: {{.*}}: no overload of 'wrap_mean'
+void add_property(double (*)(mcdata const &));
+void f() { add_property(&wrap_mean); }
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:10-[[@LINE+1]]:51}: note: {{.*}}: cannot pass pointer to generic address space
+void baz(__attribute__((opencl_private)) int *Data) {}
+void fizz() {
+  int *Nop;
+  baz(Nop);
+  // CHECK:error: no matching function
+  // CHECK::[[@LINE+1]]:53: note: {{.*}}: 'this' object is in address space '__private'
+  __attribute__((opencl_private)) static auto err = [&]() {};
+  err();
+}
+
+// CHECK:  error: no matching function
+struct Bar {
+// CHECK:  :{[[@LINE+1]]:26-[[@LINE+1]]:32}: note: {{.*}} would lose const qualifier
+static void foo(int num, int *X) {}
+// CHECK:  :{[[@LINE+1]]:17-[[@LINE+1]]:25}: note: {{.*}} no known conversion
+static void foo(int *err, int *x) {}
+};
+void bar(const int *Y) {
+  Bar::foo(5, Y);
+}
+
+struct InComp;
+
+struct A {};
+struct B : public A{};
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+5]]:36-[[@LINE+5]]:50}: note: {{.*}}: cannot convert initializer
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+3]]:36-[[@LINE+3]]:50}: note: {{.*}}: cannot convert argument
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:11-[[@LINE+1]]:18}: note: {{.*}}: no known conversion
+void hoge(char aa, const char *bb, const A& third);
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:14-[[@LINE+1]]:16}: note: {{.*}}: cannot convert from base class
+void derived(B*);
+
+void func(const A &arg) {
+  hoge(1, "pass", {{{arg}}});
+  InComp *a;
+  hoge(1, "pass", a);
+  hoge("first", 5, 6);
+  A *b;
+  derived(b);
+}
+
+struct Q {
+  // CHECK:error: invalid operands
+  // CHECK::[[@LINE+1]]:6: note: {{.*}}: 'this' argument has type 'const Q'
+  Q &operator+(void*);
+};
+
+void fuga(const Q q) { q + 3; }
+
+template  class Type1 {};
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:43-[[@LINE+1]]:54}: note: {{.*}}: expects an lvalue
+template  void Function1(int zz, Type1 &x, int ww) {}
+
+void Function() { Function1(33, Type1<-42>(), 66); }
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10749,6 +10749,8 @@
   Expr *FromExpr = Conv.Bad.FromExpr;
   QualType FromTy = Conv.Bad.getFromType();
   QualType ToTy = Conv.Bad.getToType();
+  SourceRange ToParamRange =
+  !isObjectArgument ? Fn->getParamDecl(I)->getSourceRange() : SourceRange();
 
   if (FromTy == S.Context.OverloadTy) {
 assert(FromExpr && "

[PATCH] D153993: [Headers][doc] Add load/store/cmp/cvt intrinsic descriptions to avx2intrin.h

2023-06-29 Thread Paul Robinson via Phabricator via cfe-commits
probinson updated this revision to Diff 535804.
probinson added a comment.

s/:7/:j/ correcting bit references.


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

https://reviews.llvm.org/D153993

Files:
  clang/lib/Headers/avx2intrin.h

Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -600,30 +600,130 @@
   ((__m256i)__builtin_ia32_pblendw256((__v16hi)(__m256i)(V1), \
   (__v16hi)(__m256i)(V2), (int)(M)))
 
+/// Compares corresponding bytes in the 256-bit integer vectors in \a __a and
+///\a __b for equality and returns the outcomes in the corresponding
+///bytes of the 256-bit result.
+///
+/// \code{.operation}
+/// FOR i := 0 TO 31
+///   j := i*8
+///   result[j+7:j] := (__a[j+7:j] == __b[j+7:j]) ? 0xFF : 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPCMPEQB instruction.
+///
+/// \param __a
+///A 256-bit integer vector containing one of the inputs.
+/// \param __b
+///A 256-bit integer vector containing one of the inputs.
+/// \returns A 256-bit integer vector containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_cmpeq_epi8(__m256i __a, __m256i __b)
 {
   return (__m256i)((__v32qi)__a == (__v32qi)__b);
 }
 
+/// Compares corresponding elements in the 256-bit vectors of [16 x i16] in
+///\a __a and \a __b for equality and returns the outcomes in the
+///corresponding elements of the 256-bit result.
+///
+/// \code{.operation}
+/// FOR i := 0 TO 15
+///   j := i*16
+///   result[j+15:j] := (__a[j+15:j] == __b[j+15:j]) ? 0x : 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPCMPEQW instruction.
+///
+/// \param __a
+///A 256-bit vector of [16 x i16] containing one of the inputs.
+/// \param __b
+///A 256-bit vector of [16 x i16] containing one of the inputs.
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_cmpeq_epi16(__m256i __a, __m256i __b)
 {
   return (__m256i)((__v16hi)__a == (__v16hi)__b);
 }
 
+/// Compares corresponding elements in the 256-bit vectors of [8 x i32] in
+///\a __a and \a __b for equality and returns the outcomes in the
+///corresponding elements of the 256-bit result.
+///
+/// \code{.operation}
+/// FOR i := 0 TO 7
+///   j := i*32
+///   result[j+31:j] := (__a[j+31:j] == __b[j+31:j]) ? 0x : 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPCMPEQD instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x i32] containing one of the inputs.
+/// \param __b
+///A 256-bit vector of [8 x i32] containing one of the inputs.
+/// \returns A 256-bit vector of [8 x i32] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_cmpeq_epi32(__m256i __a, __m256i __b)
 {
   return (__m256i)((__v8si)__a == (__v8si)__b);
 }
 
+/// Compares corresponding elements in the 256-bit vectors of [4 x i64] in
+///\a __a and \a __b for equality and returns the outcomes in the
+///corresponding elements of the 256-bit result.
+///
+/// \code{.operation}
+/// FOR i := 0 TO 3
+///   j := i*64
+///   result[j+63:j] := (__a[j+63:j] == __b[j+63:j]) ? 0x : 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPCMPEQQ instruction.
+///
+/// \param __a
+///A 256-bit vector of [4 x i64] containing one of the inputs.
+/// \param __b
+///A 256-bit vector of [4 x i64] containing one of the inputs.
+/// \returns A 256-bit vector of [4 x i64] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_cmpeq_epi64(__m256i __a, __m256i __b)
 {
   return (__m256i)((__v4di)__a == (__v4di)__b);
 }
 
+/// Compares corresponding signed bytes in the 256-bit integer vectors in
+///\a __a and \a __b for greater-than and returns the outcomes in the
+///corresponding bytes of the 256-bit result.
+///
+/// \code{.operation}
+/// FOR i := 0 TO 31
+///   j := i*8
+///   result[j+7:j] := (__a[j+7:j] > __b[j+7:j]) ? 0xFF : 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPCMPGTB instruction.
+///
+/// \param __a
+///A 256-bit integer vector containing one of the inputs.
+/// \param __b
+///A 256-bit integer vector containing one of the inputs.
+/// \returns A 256-bit integer vector containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_cmpgt_epi8(__m256i __a, __m256i __b)
 {
@@ -632,18 +732,78 @@
   return (__m256i)((__v32qs)__a > (__v32qs)__b);
 }
 
+/// Compares corresponding signed elements in the 256-bit vectors of
+///[16 x i16] in \a __a and \a __b for greater-than and returns the
+///outcomes in the corresponding elements

[PATCH] D153962: [clang] Do not discard cleanups while processing immediate invocation

2023-06-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.

LGTM once again with one NIT about the comment line placement.
Thanks!




Comment at: clang/lib/Sema/SemaExpr.cpp:18198-18199
+// - blocks are not allowed inside constant expressions and compiler will
+// issue an error if they appear there. Hence, in correct code any cleanup
+// objects created inside current evaluation context must be outside the
+// immediate invocation.

NIT: put this on a separate line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153962

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


[clang] 9fd3321 - Fix test regression on 32-bit x86.

2023-06-29 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2023-06-29T11:02:38-04:00
New Revision: 9fd3321db7429098e115c2c46bf6528a85070e53

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

LOG: Fix test regression on 32-bit x86.

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

Added: 


Modified: 
clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c

Removed: 




diff  --git a/clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c 
b/clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
index 6fe048ae8740a9..ed47101d644309 100644
--- a/clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
+++ b/clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
@@ -1,15 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source \
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=source -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP 
\
+// RUN: -ffp-eval-method=source \
 // RUN: -DNOERROR %s
   
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double 
%s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=double %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP 
\
+// RUN: -ffp-eval-method=double %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP \
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=extended %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP 
\
 // RUN: -ffp-eval-method=extended %s  
 
 

diff  --git a/clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c 
b/clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
index 9eccbb74aa28d6..61bf7c970807cb 100644
--- a/clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
+++ b/clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
@@ -1,14 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double 
-DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=double -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP 
\
+// RUN: -ffp-eval-method=double -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source 
%s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP 
\
+// RUN: -ffp-eval-method=source %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP 
-ffp-eval-method=extended %s 
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=extended %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP 
\
+// RUN: -ffp-eval-method=extended %s
 
 #ifdef NOERROR
 // expected-no-diagnostics

diff  --git a/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c 
b/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
index 4aca13eddb7f2f..8be5c5535af39d 100644
--- a/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
+++ b/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
@@ -1,15 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -verify -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-o

[PATCH] D153770: Fix test regression on 32-bit x86.

2023-06-29 Thread Zahira Ammarguellat 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 rG9fd3321db742: Fix test regression on 32-bit x86. (authored 
by zahiraam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153770

Files:
  clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
  clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
  clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c

Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
===
--- clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
@@ -1,15 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -verify -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP \
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=extended -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
 // RUN: -ffp-eval-method=extended -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=source %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=double %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=double %s
 
 
 #ifdef NOERROR
Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
===
--- clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
@@ -1,14 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=double -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=double -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=source %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=extended %s 
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=extended %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=extended %s
 
 #ifdef NOERROR
 // expected-no-diagnostics
Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
===
--- clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
@@ -1,15 +1,21 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -x c++ -DCPP -DNOERROR %s
 
-// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source -DNOERROR %s
-// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source \
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
+// RUN: -ffp-eval-method=source -DNOERROR %s
+// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x 

[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

2023-06-29 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy accepted this revision.
donat.nagy added a comment.
This revision is now accepted and ready to land.

LGTM, but please wait until you can merge this together with D153776 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

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


[clang-tools-extra] 21b6da3 - [clangd] Don't show header for namespace decl in Hover

2023-06-29 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-06-29T17:11:19+02:00
New Revision: 21b6da35f1d5c8ee50c14fa4e498b6c46ac4bc0f

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

LOG: [clangd] Don't show header for namespace decl in Hover

The header for namespace symbol is barely useful.

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 5184fcbe4b5813..fbd0be07961651 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -1374,7 +1374,10 @@ std::optional getHover(ParsedAST &AST, 
Position Pos,
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext()).PrintedValue;
 maybeAddCalleeArgInfo(N, *HI, PP);
-maybeAddSymbolProviders(AST, *HI, include_cleaner::Symbol{*DeclToUse});
+
+if (!isa(DeclToUse))
+  maybeAddSymbolProviders(AST, *HI,
+  include_cleaner::Symbol{*DeclToUse});
   } else if (const Expr *E = N->ASTNode.get()) {
 HoverCountMetric.record(1, "expr");
 HI = getHoverContents(N, E, AST, PP, Index);

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 7002e27e9938ff..0f45e7851bc87e 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3059,7 +3059,13 @@ TEST(Hover, Providers) {
   }
   ns::F^oo d;
 )cpp",
-[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }}};
+[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+{R"cpp(
+  namespace foo {};
+  using namespace fo^o;
+)cpp",
+[](HoverInfo &HI) { HI.Provider = ""; }},
+};
 
   for (const auto &Case : Cases) {
 Annotations Code{Case.Code};



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


[PATCH] D154068: [clangd] Don't show header for namespace decl in Hover

2023-06-29 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.
Closed by commit rG21b6da35f1d5: [clangd] Don't show header for namespace 
decl in Hover (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D154068?vs=535732&id=535809#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154068

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3059,7 +3059,13 @@
   }
   ns::F^oo d;
 )cpp",
-[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }}};
+[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+{R"cpp(
+  namespace foo {};
+  using namespace fo^o;
+)cpp",
+[](HoverInfo &HI) { HI.Provider = ""; }},
+};
 
   for (const auto &Case : Cases) {
 Annotations Code{Case.Code};
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -1374,7 +1374,10 @@
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext()).PrintedValue;
 maybeAddCalleeArgInfo(N, *HI, PP);
-maybeAddSymbolProviders(AST, *HI, include_cleaner::Symbol{*DeclToUse});
+
+if (!isa(DeclToUse))
+  maybeAddSymbolProviders(AST, *HI,
+  include_cleaner::Symbol{*DeclToUse});
   } else if (const Expr *E = N->ASTNode.get()) {
 HoverCountMetric.record(1, "expr");
 HI = getHoverContents(N, E, AST, PP, Index);


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3059,7 +3059,13 @@
   }
   ns::F^oo d;
 )cpp",
-[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }}};
+[](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+{R"cpp(
+  namespace foo {};
+  using namespace fo^o;
+)cpp",
+[](HoverInfo &HI) { HI.Provider = ""; }},
+};
 
   for (const auto &Case : Cases) {
 Annotations Code{Case.Code};
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -1374,7 +1374,10 @@
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext()).PrintedValue;
 maybeAddCalleeArgInfo(N, *HI, PP);
-maybeAddSymbolProviders(AST, *HI, include_cleaner::Symbol{*DeclToUse});
+
+if (!isa(DeclToUse))
+  maybeAddSymbolProviders(AST, *HI,
+  include_cleaner::Symbol{*DeclToUse});
   } else if (const Expr *E = N->ASTNode.get()) {
 HoverCountMetric.record(1, "expr");
 HI = getHoverContents(N, E, AST, PP, Index);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153776: [clang][analyzer] Display notes in StdLibraryFunctionsChecker only if interesting

2023-06-29 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy accepted this revision.
donat.nagy added a comment.
This revision is now accepted and ready to land.

LGTM if you rebase these changes onto the most recent version of D153612 
. Thanks for adding this interestingness 
check!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153776

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-06-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I've not spotted anything major, but I would like some additional test 
coverage. Btw, you need to add this to the table in 
https://github.com/llvm/llvm-project/blob/189033e6bede96de0d74e61715fcd1b48d95e247/clang/docs/LanguageExtensions.rst?plain=1#L1429
 because this is an extension we intentionally support in older language modes 
(we want to let folks like libc++ rely on this behavior in Clang).




Comment at: clang/lib/AST/Decl.cpp:1115-1122
+  if (const VarDecl *VD = dyn_cast(this)) {
+if (isa(VD))
+  return false;
+if (VD->isInitCapture())
+  return true;
+return VD->getStorageDuration() == StorageDuration::SD_Automatic;
+  }





Comment at: clang/lib/Sema/SemaDecl.cpp:1979
 
-static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
+static bool ShouldDiagnoseUnusedDecl(const Sema &SemaRef, const NamedDecl *D) {
   if (D->isInvalidDecl())

This could take `const LangOptions &` instead of `const Sema &` as we don't 
actually use `Sema` here.



Comment at: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp:3
+
+void static_var() {
+static int _; // expected-note {{previous definition is here}} \

Can you also add tests for global namespace and anonymous namespaces?

Can you add coverage for:
```
int _ = 12;
auto lam = [_ = 0]{}; // gets a placeholder extension warning (I don't think we 
issue a shadow warning currently, but probably should?)
```
and
```
void func() {
  // Is a placeholder variable and so it does not get a -Wunused-but-set 
warning despite
  int _ = 12;
  int x = 12; // Gets -Wunused-but-set warning
}
```




Comment at: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp:19
+int arr[4] = {0, 1, 2, 3};
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are 
a C++2c extension}} \
+ // expected-note 4{{placeholder declared here}}

I think we want additional comments explaining why there's only three instances 
of this warning instead of four because this situation is kind of weird. The 
first declaration *is* a placeholder, so we suppress unused variable warnings 
for it. However, because a single variable named `_` is valid code in earlier 
language modes, it's not really an *extension* until we introduce the second 
variable named `_` in the same scope in terms of conformance. It doesn't help 
users to issue an extension warning on the first declaration because the 
diagnostic behavior change is more likely appreciated than a surprising change.

I think this information should be documented somewhere (perhaps just in the 
release notes with an example since we don't have much to document about the 
extension itself).



Comment at: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp:52
+void _() {} // expected-error {{redefinition of '_'}}
+void _(int){};
+}





Comment at: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp:63-70
+struct Members {
+int _; // expected-note {{placeholder declared here}}
+int _; // expected-warning{{placeholder variables are a C++2c extension}} \
+   // expected-note {{placeholder declared here}}
+void f() {
+_++; // expected-error {{ambiguous reference to placeholder '_', which 
is defined multiple times}}
+}

Can you add a test for this case:
```
struct WhoWritesCodeLikeThis {
  int _;
  void f() {
int _;
_ = 12; // Not ambiguous reference to placeholder, accesses the local 
variable which shadows the field
(void)({ int _ = 12; _;}); // Also not an ambiguous reference to a 
placeholder, accesses the GNU statement expression variable which shadows the 
local variable
  }
  // None of the _ declarations should get the extension warning
};
```
and for:
```
typedef int _;
typedef int _; // Not a placeholder, but also not a redefinition, so 
this_is_fine.gif
```
and for:
```
struct S {
  int _, _;
};
constexpr int oh_no = __builtin_offsetof(S, _); // Ambiguous reference error
int S::* ref = &S::_; // Ambiguous reference error
```
and for:
```
struct S {
  int _, _;
  void func() __attribute__((diagnose_if(_ != 0, "oh no!", "warning")));
};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D153969: [clang][ExprConstant] Fix crash on uninitialized base class subobject

2023-06-29 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2422
+  << BS.getType();
+  Info.Note(BS.getBeginLoc(), 
diag::note_constexpr_base_inherited_here);
+  return false;

tbaeder wrote:
> Can you pass `<< BS.getSourceRange()` here? Does that improve things?
Currently, `DiagLoc` points to the variable declaration and the 
`BS.getSourceRange` covers the line where the base class is inherited. This 
causes distant source range and thus unnecessarily many lines of snippet 
printing.
e.g.
```
struct Base {
  Base() = delete;
};
struct Derived : Base {
  constexpr Derived() {}
};
constexpr Derived dd;
```
Output:
```
source.cpp:7:19: error: constexpr variable 'dd' must be initialized by a 
constant expression
7 | constexpr Derived dd;
  |   ^~
source.cpp:7:19: note: constructor of base class 'Base' is not called
7 | struct Derived : Base {
  |  
8 |   constexpr Derived() {}
9 | };
   10 | constexpr Derived dd;
  |   ^
source.cpp:4:18: note: base class inherited here
4 | struct Derived : Base {
  |  ^
```
(The line numbers seem incorrect but is already reported in 
https://github.com/llvm/llvm-project/issues/63524)

I think we don't need two notes here because the error is already pointing to 
the variable declaration. Having something like the following would be succint.
```
source.cpp:7:19: error: constexpr variable 'dd' must be initialized by a 
constant expression
7 | constexpr Derived dd;
  |   ^~
source.cpp:4:18: note: constructor of base class 'Base' is not called
4 | struct Derived : Base {
  |  ^~~~
```
Providing source range would be beneficial because the inherited class often 
spans in a few lines (the code in the crashing report, for example)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153969

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


[clang] be8a65b - [HIP]: Add -fhip-emit-relocatable to override link job creation for -fno-gpu-rdc

2023-06-29 Thread Jeffrey Byrnes via cfe-commits

Author: Jeffrey Byrnes
Date: 2023-06-29T08:18:28-07:00
New Revision: be8a65b598b3b80f73e862a01c7eaafe84d853a0

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

LOG: [HIP]: Add -fhip-emit-relocatable to override link job creation for 
-fno-gpu-rdc

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

Change-Id: Idcc5c7c25dc350b8dc9a1865fd67982904d06ecd

Added: 
clang/test/Driver/hip-dependent-options.hip

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/hip-device-compile.hip
clang/test/Driver/hip-phases.hip
clang/test/Driver/hip-rdc-device-only.hip

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a352e20f1f9a0c..dfecea22ea69b0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1124,6 +1124,10 @@ def gpu_bundle_output : Flag<["--"], 
"gpu-bundle-output">,
   Group, HelpText<"Bundle output files of HIP device compilation">;
 def no_gpu_bundle_output : Flag<["--"], "no-gpu-bundle-output">,
   Group, HelpText<"Do not bundle output files of HIP device 
compilation">;
+def fhip_emit_relocatable : Flag<["-"], "fhip-emit-relocatable">, 
Group,
+  HelpText<"Compile HIP source to relocatable">;
+def fno_hip_emit_relocatable : Flag<["-"], "fno-hip-emit-relocatable">, 
Group,
+  HelpText<"Do not override toolchain to compile HIP source to relocatable">;
 def cuid_EQ : Joined<["-"], "cuid=">, Flags<[CC1Option]>,
   HelpText<"An ID for compilation unit, which should be the same for the same "
"compilation unit but 
diff erent for 
diff erent compilation units. "

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 1580f092bcde0d..ccdaa5c7eb68bb 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2946,7 +2946,12 @@ class OffloadingActionBuilder final {
 CudaActionBuilderBase(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs,
   Action::OffloadKind OFKind)
-: DeviceActionBuilder(C, Args, Inputs, OFKind) {}
+: DeviceActionBuilder(C, Args, Inputs, OFKind) {
+
+  CompileDeviceOnly = C.getDriver().offloadDeviceOnly();
+  Relocatable = Args.hasFlag(options::OPT_fgpu_rdc,
+ options::OPT_fno_gpu_rdc, /*Default=*/false);
+}
 
 ActionBuilderReturnCode addDeviceDependences(Action *HostAction) override {
   // While generating code for CUDA, we only depend on the host input 
action
@@ -3099,9 +3104,6 @@ class OffloadingActionBuilder final {
   !C.hasOffloadToolChain())
 return false;
 
-  Relocatable = Args.hasFlag(options::OPT_fgpu_rdc,
- options::OPT_fno_gpu_rdc, /*Default=*/false);
-
   const ToolChain *HostTC = 
C.getSingleOffloadToolChain();
   assert(HostTC && "No toolchain for host compilation.");
   if (HostTC->getTriple().isNVPTX() ||
@@ -3120,7 +3122,6 @@ class OffloadingActionBuilder final {
   : C.getSingleOffloadToolChain());
 
   CompileHostOnly = C.getDriver().offloadHostOnly();
-  CompileDeviceOnly = C.getDriver().offloadDeviceOnly();
   EmitLLVM = Args.getLastArg(options::OPT_emit_llvm);
   EmitAsm = Args.getLastArg(options::OPT_S);
   FixedCUID = Args.getLastArgValue(options::OPT_cuid_EQ);
@@ -3352,16 +3353,40 @@ class OffloadingActionBuilder final {
 // only compilation. Bundle other type of output files only if
 // --gpu-bundle-output is specified for device only compilation.
 std::optional BundleOutput;
+std::optional EmitReloc;
 
   public:
 HIPActionBuilder(Compilation &C, DerivedArgList &Args,
  const Driver::InputList &Inputs)
 : CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+
   DefaultCudaArch = CudaArch::GFX906;
+
+  if (Args.hasArg(options::OPT_fhip_emit_relocatable,
+  options::OPT_fno_hip_emit_relocatable)) {
+EmitReloc = Args.hasFlag(options::OPT_fhip_emit_relocatable,
+ options::OPT_fno_hip_emit_relocatable, false);
+
+if (*EmitReloc) {
+  if (Relocatable) {
+C.getDriver().Diag(diag::err_opt_not_valid_with_opt)
+<< "-fhip-emit-relocatable"
+<< "-fgpu-rdc";
+  }
+
+  if (!CompileDeviceOnly) {
+C.getDriver().Diag(diag::err_opt_not_valid_without_opt)
+<< "-fhip-emit-relocatable"
+<< "--cuda-device-only";
+  }
+}
+  }
+
   if (Args.hasArg(options::OPT_gpu_bundle_output,
   options::OPT_no_gpu_bundle_output))
   

[PATCH] D153667: [HIP]: Add -fhip-emit-relocatable to override link job creation for -fno-gpu-rdc

2023-06-29 Thread Jeffrey Byrnes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe8a65b598b3: [HIP]: Add -fhip-emit-relocatable to override 
link job creation for -fno-gpu-rdc (authored by jrbyrnes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153667

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-dependent-options.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-rdc-device-only.hip

Index: clang/test/Driver/hip-rdc-device-only.hip
===
--- clang/test/Driver/hip-rdc-device-only.hip
+++ clang/test/Driver/hip-rdc-device-only.hip
@@ -18,6 +18,16 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
 
+// With `-fno-hip-emit-relocatable`, the output should be the same as the aforementioned line
+// as `-fgpu-rdc` in HIP implies `-fno-hip-emit-relocatable`.
+
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -c -fno-hip-emit-relocatable -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
+
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -244,6 +244,43 @@
 // DASM-NOT: clang-offload-bundler
 // DASM-NOT: host
 
+//
+// Test single gpu architecture with compile to relocatable in device-only
+// compilation mode.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOC %s
+// RELOC-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
+// RELOC-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// RELOC-NOT: linker
+// RELOC-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+
+//
+// Test two gpu architectures with compile to relocatable in device-only
+// compilation mode.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOC2 %s
+// RELOC2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
+// RELOC2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// RELOC2-NOT: [[P5:[0-9]+]]: linker, {[[P4]]}, image, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+// RELOC2-DAG: [[P6:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH2:gfx900]])
+// RELOC2-DAG: [[P7:[0-9]+]]: preprocessor, {[[P6]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P8:[0-9]+]]: compiler, {[[P7]]}, ir, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P9:[0-9]+]]: backend, {[[P8]]}, assembler, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P10:[0-9]+]]: assembler, {[[P9]]}, object, (device-[[T]], [[ARCH2]])
+// RELOC2-NOT: linker
+// RELOC2-DAG: [[P11:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH2]])" {[[P10]]}, object
+
 //
 // Test two gpu architectures with complete compilation in device-only
 // compilation mode.
Index: clang/test/Driver/hip-device-compile.hip
===
--- clang/test/Driver/hip-device-compile.hip
+++ clang/test/Driver/hip-device-compile.hip
@@ -45,6 +45,14 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,ASM,NBUN %s
 
+// Output relocatable.
+// RUN: %clang -c --cuda-device-only -### --target=x86_64-linux-gnu \
+// RUN:   -o a.o -x hip --cuda-gpu-arch=gfx900 -fhip-emit-relocatable \
+// RUN:  

[PATCH] D153556: [OPENMP52] Initial support for doacross clause.

2023-06-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


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

https://reviews.llvm.org/D153556

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


[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

2023-06-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

This is the quintessential example of a patch where while the test files look 
promising, we need some evaluation on the real world. I understand that its a 
chore -- but this is simply the nature of the beast.

While the changes in the test file look promising. I'd be more pleased if some 
real world data would back it up (I understand that we shared a link around 
internally, but that kind of defeats the purpose of an open source review).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

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


[PATCH] D154091: [clang-format] Prefer breaking long strings at new lines

2023-06-29 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
sstwcw requested review of this revision.

Previously, escape sequences in string literals were not recognized
when the program considered where to break string literals.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154091

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14807,6 +14807,23 @@
 "\"/and\"",
 format("\"some/tex/and\"", getLLVMStyleWithColumns(6)));
 
+  // Escape sequences should be recognized.
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\n"
+" text";)",
+   R"(x = "some\n text";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(13));
+
   EXPECT_EQ("variable =\n"
 "\"long string \"\n"
 "\"literal\";",
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -176,13 +176,15 @@
   if (ColumnLimit <= UsedColumns)
 return BreakableToken::Split(StringRef::npos, 0);
   unsigned MaxSplit = ColumnLimit - UsedColumns;
-  StringRef::size_type SpaceOffset = 0;
+  StringRef::size_type NewLine = 0;
+  StringRef::size_type AfterSpace = 0;
   StringRef::size_type SlashOffset = 0;
   StringRef::size_type WordStartOffset = 0;
   StringRef::size_type SplitPoint = 0;
   for (unsigned Chars = 0;;) {
 unsigned Advance;
-if (Text[0] == '\\') {
+bool EscapeSequence = Text[0] == '\\';
+if (EscapeSequence) {
   Advance = encoding::getEscapeSequenceLength(Text);
   Chars += Advance;
 } else {
@@ -194,8 +196,21 @@
 if (Chars > MaxSplit || Text.size() <= Advance)
   break;
 
+if (EscapeSequence && Advance == 2) {
+  switch (Text[1]) {
+  case 'n':
+NewLine = SplitPoint + 2;
+break;
+  case 'f':
+  case 'r':
+  case 't':
+  case 'v':
+AfterSpace = SplitPoint + 2;
+break;
+  }
+}
 if (IsBlank(Text[0]))
-  SpaceOffset = SplitPoint;
+  AfterSpace = SplitPoint + 1;
 if (Text[0] == '/')
   SlashOffset = SplitPoint;
 if (Advance == 1 && !isAlphanumeric(Text[0]))
@@ -205,8 +220,10 @@
 Text = Text.substr(Advance);
   }
 
-  if (SpaceOffset != 0)
-return BreakableToken::Split(SpaceOffset + 1, 0);
+  if (NewLine != 0)
+return BreakableToken::Split(NewLine, 0);
+  if (AfterSpace >= 2)
+return BreakableToken::Split(AfterSpace, 0);
   if (SlashOffset != 0)
 return BreakableToken::Split(SlashOffset + 1, 0);
   if (WordStartOffset != 0)


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14807,6 +14807,23 @@
 "\"/and\"",
 format("\"some/tex/and\"", getLLVMStyleWithColumns(6)));
 
+  // Escape sequences should be recognized.
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\n"
+" text";)",
+   R"(x = "some\n text";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(13));
+
   EXPECT_EQ("variable =\n"
 "\"long string \"\n"
 "\"literal\";",
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -176,13 +176,15 @@
   if (ColumnLimit <= UsedColumns)
 return BreakableToken::Split(StringRef::npos, 0);
   unsigned MaxSplit = ColumnLimit - UsedColumns;
-  StringRef::size_type SpaceOffset = 0;
+  StringRef::size_type NewLine = 0;
+  StringRef::size_type AfterSpace = 0;
   StringRef::size_type SlashOffset = 0;
   StringRef::size_type WordSta

[PATCH] D154093: [clang-format] Break strings in Verilog

2023-06-29 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
sstwcw requested review of this revision.

In Verilog, concatenations need to have braces around them and commas
between the parts.

Some const qualifiers were removed.  It is because the new insertBreak
method modifies a field.  And adaptStartOfLine calls that method in
another class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154093

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/BreakableToken.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTestVerilog.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1743,6 +1743,24 @@
   EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_Unknown);
   EXPECT_TOKEN(Tokens[5], tok::comma, TT_Unknown);
   EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_Unknown);
+
+  // String literals in concatenation.
+  Tokens = Annotate("x = {\"\"};");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_VerilogStringInConcatenation);
+  Tokens = Annotate("x = {\"\", \"\"};");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_VerilogStringInConcatenation);
+  EXPECT_TOKEN(Tokens[5], tok::string_literal, TT_VerilogStringInConcatenation);
+  // Cases where the string should not be annotated that type.  Fix the
+  // `TT_Unknown` if needed in the future.
+  Tokens = Annotate("x = {\"\" == \"\"};");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_Unknown);
+  EXPECT_TOKEN(Tokens[5], tok::string_literal, TT_Unknown);
+  Tokens = Annotate("x = '{\"\"};");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::string_literal, TT_Unknown);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandConstructors) {
Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -1155,6 +1155,66 @@
   verifyFormat("{< 0 && Changes[i - 1].OriginalWhitespaceRange.getBegin() ==
- C.OriginalWhitespaceRange.getBegin()) {
-  // Do not generate two replacements for the same location.
-  continue;
+if (i > 0) {
+  auto Last = Changes[i - 1].OriginalWhitespaceRange;
+  auto New = Changes[i].OriginalWhitespaceRange;
+  // Do not generate two replacements for the same location.  As a special
+  // case, it is allowed if there is a replacement for the empty range
+  // between 2 tokens and another non-empty range at the start of the second
+  // token.
+  if (Last.getBegin() == New.getBegin() &&
+  (Last.getEnd() != Last.getBegin() ||
+   New.getEnd() == New.getBegin())) {
+continue;
+  }
 }
 if (C.CreateReplacement) {
   std::string ReplacementText = C.PreviousLinePostfix;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -862,6 +862,11 @@
 OpeningBrace.Previous->is(TT_JsTypeColon)) {
   Contexts.back().IsExpression = false;
 }
+if (Style.isVerilog() &&
+(!OpeningBrace.getPreviousNonComment() ||
+ OpeningBrace.getPreviousNonComment()->isNot(Keywords.kw_apostrophe))) {
+  Contexts.back().VerilogMayBeConcatenation = true;
+}
 
 unsigned CommaCount = 0;
 while (CurrentToken) {
@@ -1736,6 +1741,9 @@
 bool InCpp11AttributeSpecifier = false;
 bool InCSharpAttributeSpecifier = false;
 bool VerilogAssignmentFound = false;
+// Whether the braces may mean concatenation instead of structure or array
+// literal.
+bool VerilogMayBeConcatenation = false;
 enum {
   Unknown,
   // Like the part after `:` in a constructor.
@@ -2068,6 +2076,14 @@
   } else {
 Current.setType(TT_LineComment);
   }
+} else if (Current.is(tok::string_literal)) {
+  if (Style.isVerilog() && Contexts.back().VerilogMayBeConcatenation &&
+  Current.getPreviousNonComment() &&
+  Current.getPreviousNonComment()->isOneOf(tok::comma, tok::l_brace) &&
+  Current.getNextNonComment() &&
+  Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
+Current.setType(TT_VerilogStringInConcatenation);
+  }
 } el

[PATCH] D154091: [clang-format] Prefer breaking long strings at new lines

2023-06-29 Thread sstwcw via Phabricator via cfe-commits
sstwcw added inline comments.



Comment at: clang/lib/Format/BreakableToken.cpp:225
+return BreakableToken::Split(NewLine, 0);
+  if (AfterSpace >= 2)
+return BreakableToken::Split(AfterSpace, 0);

Should I change the threshold from 2 to 1?

It is set to 2 because it is the old behavior.  There is already a test.

```
already in the test:
"some"
" tex"
"t"

I expect:
"some"
" "
"text"
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

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


[clang] 6bf66d8 - [clang-format] Indent Verilog struct literal on new line

2023-06-29 Thread via cfe-commits

Author: sstwcw
Date: 2023-06-29T15:38:44Z
New Revision: 6bf66d839f1386c06e19a3621c02c8fc6a14f94f

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

LOG: [clang-format] Indent Verilog struct literal on new line

Before:
```
c = //
'{default: 0};
```

After:
```
c = //
'{default: 0};
```

If the line has to be broken, the continuation part should be
indented.  Before this fix, it was not the case if the continuation
part was a struct literal.  The rule that caused the problem was added
in 783bac6b.  It was intended for aligning the field labels in
ProtoBuf.  The type `TT_DictLiteral` was only for colons back then, so
the program didn't have to check whether the token was a colon when it
was already type `TT_DictLiteral`.  Now the type applies to more
things including the braces enclosing a dictionary literal.  In
Verilog, struct literals start with a quote.  The quote is regarded as
an identifier by the program.  So the rule for aligning the fields in
ProtoBuf applied to this situation by mistake.

Reviewed By: HazardyKnusperkeks

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTestVerilog.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 13b853ea9e2267..74d82db043e67f 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1173,7 +1173,15 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   }
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
+  // Field labels in a nested type should be aligned to the brace. For example
+  // in ProtoBuf:
+  //   optional int32 b = 2 [(foo_options) = {aaa: 123,
+  //  :"baz"}];
+  // For Verilog, a quote following a brace is treated as an identifier.  And
+  // Both braces and colons get annotated as TT_DictLiteral.  So we have to
+  // check.
   if (Current.is(tok::identifier) && Current.Next &&
+  (!Style.isVerilog() || Current.Next->is(tok::colon)) &&
   (Current.Next->is(TT_DictLiteral) ||
((Style.Language == FormatStyle::LK_Proto ||
  Style.Language == FormatStyle::LK_TextProto) &&

diff  --git a/clang/unittests/Format/FormatTestVerilog.cpp 
b/clang/unittests/Format/FormatTestVerilog.cpp
index 5c94d5afbac960..45839aea54ff0d 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -1172,6 +1172,15 @@ TEST_F(FormatTestVerilog, StructLiteral) {
   verifyFormat("c = '{a : 0, b : 0.0, default : 0};", Style);
   verifyFormat("c = ab'{a : 0, b : 0.0};", Style);
   verifyFormat("c = ab'{cd : cd'{1, 1.0}, ef : ef'{2, 2.0}};", Style);
+
+  // It should be indented correctly when the line has to break.
+  verifyFormat("c = //\n"
+   "'{default: 0};");
+  Style = getDefaultStyle();
+  Style.ContinuationIndentWidth = 2;
+  verifyFormat("c = //\n"
+   "  '{default: 0};",
+   Style);
 }
 
 TEST_F(FormatTestVerilog, StructuredProcedure) {



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


[PATCH] D152623: [clang-format] Indent Verilog struct literal on new line

2023-06-29 Thread sstwcw via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6bf66d839f13: [clang-format] Indent Verilog struct literal 
on new line (authored by sstwcw).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152623

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTestVerilog.cpp


Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -1172,6 +1172,15 @@
   verifyFormat("c = '{a : 0, b : 0.0, default : 0};", Style);
   verifyFormat("c = ab'{a : 0, b : 0.0};", Style);
   verifyFormat("c = ab'{cd : cd'{1, 1.0}, ef : ef'{2, 2.0}};", Style);
+
+  // It should be indented correctly when the line has to break.
+  verifyFormat("c = //\n"
+   "'{default: 0};");
+  Style = getDefaultStyle();
+  Style.ContinuationIndentWidth = 2;
+  verifyFormat("c = //\n"
+   "  '{default: 0};",
+   Style);
 }
 
 TEST_F(FormatTestVerilog, StructuredProcedure) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1173,7 +1173,15 @@
   }
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
+  // Field labels in a nested type should be aligned to the brace. For example
+  // in ProtoBuf:
+  //   optional int32 b = 2 [(foo_options) = {aaa: 123,
+  //  :"baz"}];
+  // For Verilog, a quote following a brace is treated as an identifier.  And
+  // Both braces and colons get annotated as TT_DictLiteral.  So we have to
+  // check.
   if (Current.is(tok::identifier) && Current.Next &&
+  (!Style.isVerilog() || Current.Next->is(tok::colon)) &&
   (Current.Next->is(TT_DictLiteral) ||
((Style.Language == FormatStyle::LK_Proto ||
  Style.Language == FormatStyle::LK_TextProto) &&


Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -1172,6 +1172,15 @@
   verifyFormat("c = '{a : 0, b : 0.0, default : 0};", Style);
   verifyFormat("c = ab'{a : 0, b : 0.0};", Style);
   verifyFormat("c = ab'{cd : cd'{1, 1.0}, ef : ef'{2, 2.0}};", Style);
+
+  // It should be indented correctly when the line has to break.
+  verifyFormat("c = //\n"
+   "'{default: 0};");
+  Style = getDefaultStyle();
+  Style.ContinuationIndentWidth = 2;
+  verifyFormat("c = //\n"
+   "  '{default: 0};",
+   Style);
 }
 
 TEST_F(FormatTestVerilog, StructuredProcedure) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1173,7 +1173,15 @@
   }
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
+  // Field labels in a nested type should be aligned to the brace. For example
+  // in ProtoBuf:
+  //   optional int32 b = 2 [(foo_options) = {aaa: 123,
+  //  :"baz"}];
+  // For Verilog, a quote following a brace is treated as an identifier.  And
+  // Both braces and colons get annotated as TT_DictLiteral.  So we have to
+  // check.
   if (Current.is(tok::identifier) && Current.Next &&
+  (!Style.isVerilog() || Current.Next->is(tok::colon)) &&
   (Current.Next->is(TT_DictLiteral) ||
((Style.Language == FormatStyle::LK_Proto ||
  Style.Language == FormatStyle::LK_TextProto) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154036: [libc] Add support for creating wrapper headers for offloading in clang

2023-06-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 535835.
jhuber6 added a comment.

Semi-fix hack for `string.h` and fix `ctype.h`. `string.h` required undefining
C++ mode so we didn't use weird GNU C++ handling, which we then still need the
`extern "C"` for. The cytpe problems come from GNU defining everything as a
macro so it fails to redeclare.

The amount of hacks that just this has required so far is fairly convincing to
me that this is the more correct solution and should be separate from `libc`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154036

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/llvm_libc_wrappers/ctype.h
  clang/lib/Headers/llvm_libc_wrappers/llvm-libc-decls/README.txt
  clang/lib/Headers/llvm_libc_wrappers/stdio.h
  clang/lib/Headers/llvm_libc_wrappers/stdlib.h
  clang/lib/Headers/llvm_libc_wrappers/string.h
  clang/test/Driver/gpu-libc-headers.c
  libc/cmake/modules/LLVMLibCHeaderRules.cmake
  libc/include/CMakeLists.txt
  libc/utils/HdrGen/Generator.cpp
  libc/utils/HdrGen/Generator.h
  libc/utils/HdrGen/Main.cpp

Index: libc/utils/HdrGen/Main.cpp
===
--- libc/utils/HdrGen/Main.cpp
+++ libc/utils/HdrGen/Main.cpp
@@ -32,6 +32,9 @@
 llvm::cl::list ReplacementValues(
 "args", llvm::cl::desc("Command separated = pairs."),
 llvm::cl::value_desc("[,name=value]"));
+llvm::cl::opt ExportDecls(
+"export-decls",
+llvm::cl::desc("Output a new header containing only the entrypoints."));
 
 void ParseArgValuePairs(std::unordered_map &Map) {
   for (std::string &R : ReplacementValues) {
@@ -48,7 +51,10 @@
   std::unordered_map ArgMap;
   ParseArgValuePairs(ArgMap);
   Generator G(HeaderDefFile, EntrypointNamesOption, StandardHeader, ArgMap);
-  G.generate(OS, Records);
+  if (ExportDecls)
+G.generateDecls(OS, Records);
+  else
+G.generate(OS, Records);
 
   return false;
 }
Index: libc/utils/HdrGen/Generator.h
===
--- libc/utils/HdrGen/Generator.h
+++ libc/utils/HdrGen/Generator.h
@@ -52,6 +52,7 @@
 ArgMap(Map) {}
 
   void generate(llvm::raw_ostream &OS, llvm::RecordKeeper &Records);
+  void generateDecls(llvm::raw_ostream &OS, llvm::RecordKeeper &Records);
 };
 
 } // namespace llvm_libc
Index: libc/utils/HdrGen/Generator.cpp
===
--- libc/utils/HdrGen/Generator.cpp
+++ libc/utils/HdrGen/Generator.cpp
@@ -10,6 +10,7 @@
 
 #include "IncludeFileCommand.h"
 #include "PublicAPICommand.h"
+#include "utils/LibcTableGenUtil/APIIndexer.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -116,4 +117,78 @@
   }
 }
 
+void Generator::generateDecls(llvm::raw_ostream &OS,
+  llvm::RecordKeeper &Records) {
+
+  OS << "//===-- C standard declarations for " << StdHeader << " "
+ << std::string(80 - (42 + StdHeader.size()), '-') << "===//\n"
+ << "//\n"
+ << "// Part of the LLVM Project, under the Apache License v2.0 with LLVM "
+"Exceptions.\n"
+ << "// See https://llvm.org/LICENSE.txt for license information.\n"
+ << "// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n"
+ << "//\n"
+ << "//"
+"===---"
+"---===//\n\n";
+
+  std::string HeaderGuard(StdHeader.size(), '\0');
+  llvm::transform(StdHeader, HeaderGuard.begin(), [](const char C) -> char {
+return !isalnum(C) ? '_' : llvm::toUpper(C);
+  });
+  OS << "#ifndef __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n"
+ << "#define __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n\n";
+
+  OS << "#ifndef __LIBC_ATTRS\n"
+ << "#define __LIBC_ATTRS\n"
+ << "#endif\n\n";
+
+  OS << "#ifdef __cplusplus\n"
+ << "extern \"C\" {\n"
+ << "#endif\n\n";
+
+  APIIndexer G(StdHeader, Records);
+  for (auto &Name : EntrypointNameList) {
+// Filter out functions not exported by this header.
+if (G.FunctionSpecMap.find(Name) == G.FunctionSpecMap.end())
+  continue;
+
+llvm::Record *FunctionSpec = G.FunctionSpecMap[Name];
+llvm::Record *RetValSpec = FunctionSpec->getValueAsDef("Return");
+llvm::Record *ReturnType = RetValSpec->getValueAsDef("ReturnType");
+
+OS << G.getTypeAsString(ReturnType) << " " << Name << "(";
+
+auto ArgsList = FunctionSpec->getValueAsListOfDefs("Args");
+for (size_t i = 0; i < ArgsList.size(); ++i) {
+  llvm::Record *ArgType = ArgsList[i]->getValueAsDef("ArgType");
+  OS << G.getTypeAsString(ArgType);
+  if (i < ArgsList.size() - 1)
+OS << ", ";
+}
+
+OS << ") __LIBC_ATTRS;\n\n";
+  }
+
+  // Make another pass over entrypoints to emit object declarations.
+  for (const auto &Name : EntrypointNameList) {
+if (G.ObjectSpecMap.find(Name)

[PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-06-29 Thread Alison Zhang via Phabricator via cfe-commits
azhan92 marked 3 inline comments as done.
azhan92 added a comment.

@hubert.reinterpretcast I have the call stack on AIX:

  #0  0x0904304c in read () from /usr/lib/libc.a(shr_64.o)
  #1  0x000100d5f044 in llvm::sys::RetryAfterSignal(int const&, long ( const&)(int, 
void*, unsigned long), int const&, char* const&, unsigned long const&) (
  Fail=@0xfff92e4: -1, F=@0x9001000a0083ec0: {long (int, void *, 
unsigned long)} 0x9001000a0083ec0 <_$STATIC+22000>, As=@0xfff92f0: 
16384, As=@0xfff92f0: 16384, As=@0xfff92f0: 16384)
  at 
/home/alisonz/llvm/dev/llvm-project/llvm/include/llvm/Support/Errno.h:37
  #2  0x000100d5973c in llvm::sys::fs::readNativeFile (FD=3, Buf=...) at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/Unix/Path.inc:1186
  #3  0x000100d59404 in llvm::sys::fs::readNativeFileToEOF (FileHandle=3, 
Buffer=..., ChunkSize=16384) at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/Path.cpp:1183
  #4  0x0001010973e0 in getMemoryBufferForStream (FD=3, BufferName=...) at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/MemoryBuffer.cpp:247
  #5  0x000101096df0 in getOpenFileImpl (FD=3, 
Filename=..., FileSize=18446744073709551615, MapSize=18446744073709551615, 
Offset=0, RequiresNullTerminator=true, IsVolatile=false, Alignment=...)
  at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/MemoryBuffer.cpp:474
  #6  0x000101096be8 in llvm::MemoryBuffer::getOpenFile (FD=3, 
Filename=..., FileSize=18446744073709551615, RequiresNullTerminator=true, 
IsVolatile=false, Alignment=...)
  at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/MemoryBuffer.cpp:527
  #7  0x0001015940a0 in (anonymous namespace)::RealFile::getBuffer 
(this=0x1105f6610, Name=..., FileSize=-1, RequiresNullTerminator=true, 
IsVolatile=false) at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp:229
  #8  0x000101570cb8 in llvm::vfs::FileSystem::getBufferForFile 
(this=0x1105f6210, Name=..., FileSize=-1, RequiresNullTerminator=true, 
IsVolatile=false) at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp:124
  #9  0x00010020b058 in llvm::cl::ExpansionContext::expandResponseFile 
(this=0xfffea58, FName=..., NewArgv=...) at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/CommandLine.cpp:1157
  #10 0x00010020dd44 in llvm::cl::ExpansionContext::expandResponseFiles 
(this=0xfffea58, Argv=...) at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/CommandLine.cpp:1332
  #11 0x000100210d78 in llvm::cl::ExpandResponseFiles (Saver=..., 
Tokenizer=@0x1104acfe0: 0x100208890 
&, bool)>, Argv=...)
  at 
/home/alisonz/llvm/dev/llvm-project/llvm/lib/Support/CommandLine.cpp:1381
  #12 0x00010017b7cc in (anonymous 
namespace)::CommandLineTest_BadResponseFile_Test::TestBody (this=0x1105da090) 
at 
/home/alisonz/llvm/dev/llvm-project/llvm/unittests/Support/CommandLineTest.cpp:1066

By lower level do you mean in llvm/include/llvm/Support/Errno.h?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

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


[PATCH] D153969: [clang][ExprConstant] Fix crash on uninitialized base class subobject

2023-06-29 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2422
+  << BS.getType();
+  Info.Note(BS.getBeginLoc(), 
diag::note_constexpr_base_inherited_here);
+  return false;

hazohelet wrote:
> tbaeder wrote:
> > Can you pass `<< BS.getSourceRange()` here? Does that improve things?
> Currently, `DiagLoc` points to the variable declaration and the 
> `BS.getSourceRange` covers the line where the base class is inherited. This 
> causes distant source range and thus unnecessarily many lines of snippet 
> printing.
> e.g.
> ```
> struct Base {
>   Base() = delete;
> };
> struct Derived : Base {
>   constexpr Derived() {}
> };
> constexpr Derived dd;
> ```
> Output:
> ```
> source.cpp:7:19: error: constexpr variable 'dd' must be initialized by a 
> constant expression
> 7 | constexpr Derived dd;
>   |   ^~
> source.cpp:7:19: note: constructor of base class 'Base' is not called
> 7 | struct Derived : Base {
>   |  
> 8 |   constexpr Derived() {}
> 9 | };
>10 | constexpr Derived dd;
>   |   ^
> source.cpp:4:18: note: base class inherited here
> 4 | struct Derived : Base {
>   |  ^
> ```
> (The line numbers seem incorrect but is already reported in 
> https://github.com/llvm/llvm-project/issues/63524)
> 
> I think we don't need two notes here because the error is already pointing to 
> the variable declaration. Having something like the following would be 
> succint.
> ```
> source.cpp:7:19: error: constexpr variable 'dd' must be initialized by a 
> constant expression
> 7 | constexpr Derived dd;
>   |   ^~
> source.cpp:4:18: note: constructor of base class 'Base' is not called
> 4 | struct Derived : Base {
>   |  ^~~~
> ```
> Providing source range would be beneficial because the inherited class often 
> spans in a few lines (the code in the crashing report, for example)
Sorry, I was looking at the line above. The distant source range problem 
doesn't occur.

I tested another input
```
struct Base {
  Base() = delete;
  constexpr Base(int){}
};

struct Derived : Base {
  constexpr Derived() {}
  constexpr Derived(int n): Base(n) {}
};

constexpr Derived darr[3] = {1, Derived(), 3};
```
expecting that the `DiagLoc` points to the second initializer `Derived()`, but 
it pointed to the same location as the error, so I'm still in favor of the idea 
of having a single note here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153969

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


[clang] 08513cb - [OpenMP] Fix lvalue reference type generation in untied task loop

2023-06-29 Thread Alexey Bataev via cfe-commits

Author: Zhiheng Xie
Date: 2023-06-29T09:11:10-07:00
New Revision: 08513cbea4dc1fe10ee864b8fd8c1eccd7917490

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

LOG: [OpenMP] Fix lvalue reference type generation in untied task loop

For variables with lvalue reference type in untied task loop,
it now wrongly sets its actual type as ElementType. It should
be converted to pointer type.

It fixes https://github.com/llvm/llvm-project/issues/62965

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/taskloop_untied_codegen.cpp

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index a9e9b986bc60a9..313bdaab44f0f0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4852,6 +4852,8 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
   // a pointer to this memory.
   for (auto &Pair : UntiedLocalVars) {
 QualType VDType = Pair.first->getType().getNonReferenceType();
+if (Pair.first->getType()->isLValueReferenceType())
+  VDType = CGF.getContext().getPointerType(VDType);
 if (isAllocatableDecl(Pair.first)) {
   llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
   Address Replacement(

diff  --git a/clang/test/OpenMP/taskloop_untied_codegen.cpp 
b/clang/test/OpenMP/taskloop_untied_codegen.cpp
new file mode 100644
index 00..fdb1d017039b61
--- /dev/null
+++ b/clang/test/OpenMP/taskloop_untied_codegen.cpp
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -verify -triple aarch64-unknown-linux-gnu -fopenmp -x c++ 
-std=c++11 -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK-LABEL: define dso_local void @_Z15taskloop_untiedv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[WORK:%.*]] = alloca [100 x float], align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr 
@[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr 
@[[GLOB1]], i32 [[TMP0]], i32 0, i64 472, i64 1, ptr @.omp_task_entry.)
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i32 0, i32 1
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds 
[[STRUCT__KMP_PRIVATES_T:%.*]], ptr [[TMP3]], i32 0, i32 3
+// CHECK-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[TMP4]], ptr 
align 4 [[WORK]], i64 400, i1 false)
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:store i32 0, ptr [[TMP5]], align 8
+// CHECK-NEXT:[[TMP6:%.*]] = call i32 @__kmpc_omp_task(ptr @[[GLOB1]], i32 
[[TMP0]], ptr [[TMP1]])
+// CHECK-NEXT:ret void
+//
+void taskloop_untied() {
+  float work[100];
+#pragma omp task untied
+  for (auto cb : work)
+cb = 1.0;
+}



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


[PATCH] D153321: [OpenMP] Fix lvalue reference type generation in untied task loop

2023-06-29 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08513cbea4dc: [OpenMP] Fix lvalue reference type generation 
in untied task loop (authored by eastb233, committed by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153321

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/taskloop_untied_codegen.cpp


Index: clang/test/OpenMP/taskloop_untied_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/taskloop_untied_codegen.cpp
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -verify -triple aarch64-unknown-linux-gnu -fopenmp -x c++ 
-std=c++11 -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK-LABEL: define dso_local void @_Z15taskloop_untiedv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[WORK:%.*]] = alloca [100 x float], align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr 
@[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr 
@[[GLOB1]], i32 [[TMP0]], i32 0, i64 472, i64 1, ptr @.omp_task_entry.)
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i32 0, i32 1
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds 
[[STRUCT__KMP_PRIVATES_T:%.*]], ptr [[TMP3]], i32 0, i32 3
+// CHECK-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[TMP4]], ptr 
align 4 [[WORK]], i64 400, i1 false)
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:store i32 0, ptr [[TMP5]], align 8
+// CHECK-NEXT:[[TMP6:%.*]] = call i32 @__kmpc_omp_task(ptr @[[GLOB1]], i32 
[[TMP0]], ptr [[TMP1]])
+// CHECK-NEXT:ret void
+//
+void taskloop_untied() {
+  float work[100];
+#pragma omp task untied
+  for (auto cb : work)
+cb = 1.0;
+}
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4852,6 +4852,8 @@
   // a pointer to this memory.
   for (auto &Pair : UntiedLocalVars) {
 QualType VDType = Pair.first->getType().getNonReferenceType();
+if (Pair.first->getType()->isLValueReferenceType())
+  VDType = CGF.getContext().getPointerType(VDType);
 if (isAllocatableDecl(Pair.first)) {
   llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
   Address Replacement(


Index: clang/test/OpenMP/taskloop_untied_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/taskloop_untied_codegen.cpp
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -verify -triple aarch64-unknown-linux-gnu -fopenmp -x c++ -std=c++11 -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK-LABEL: define dso_local void @_Z15taskloop_untiedv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[WORK:%.*]] = alloca [100 x float], align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @[[GLOB1]], i32 [[TMP0]], i32 0, i64 472, i64 1, ptr @.omp_task_entry.)
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i32 0, i32 1
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [[STRUCT__KMP_PRIVATES_T:%.*]], ptr [[TMP3]], i32 0, i32 3
+// CHECK-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[TMP4]], ptr align 4 [[WORK]], i64 400, i1 false)
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:store i32 0, ptr [[TMP5]], align 8
+// CHECK-NEXT:[[TMP6:%.*]] = call i32 @__kmpc_omp_task(ptr @[[GLOB1]], i32 [[TMP0]], ptr [[TMP1]])
+// CHECK-NEXT:ret void
+//
+void taskloop_untied() {
+  float work[100];
+#pragma omp task untied
+  for (auto cb : work)
+cb = 1.0;
+}
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4852,6 +485

[PATCH] D152953: [clang-tidy] Introduce fuchsia-global-variables check

2023-06-29 Thread Caslyn Tonelli via Phabricator via cfe-commits
Caslyn updated this revision to Diff 535845.
Caslyn added a comment.

correct reference in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152953

Files:
  clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
  clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/fuchsia/global-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
@@ -16,6 +16,7 @@
 "DefaultArgumentsDeclarationsCheck.cpp",
 "FuchsiaTidyModule.cpp",
 "MultipleInheritanceCheck.cpp",
+"GlobalVariablesCheck.cpp",
 "OverloadedOperatorCheck.cpp",
 "StaticallyConstructedObjectsCheck.cpp",
 "TrailingReturnCheck.cpp",
Index: clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
@@ -0,0 +1,181 @@
+// RUN: %check_clang_tidy %s fuchsia-global-variables %t \
+// RUN: -config="{CheckOptions: \
+// RUN:   [{key: fuchsia-global-variables.Ignore, value: 'LazyRE2;ThreadLocal'}] \
+// RUN:  }"
+
+using size_t = decltype(sizeof(int));
+
+class TriviallyDestructibleClass {
+ public:
+  // This is a trivially destructible class.
+  int I;
+  float F;
+  char C;
+  char Cs[10];
+};
+
+class NonTriviallyDestructibleClass {
+ public:
+  // We need a destructor to make the class non trivially destructible.
+  ~NonTriviallyDestructibleClass() { Var = 0; }
+  int Var;
+};
+
+template 
+class NonTriviallyDestructibleTemplateClass {
+ public:
+  // We need a destructor to make the class non trivially destructible.
+  ~NonTriviallyDestructibleTemplateClass() { Var = 0; }
+  int Var;
+  T Var2;
+};
+
+int GlobalI;
+_Atomic size_t GlobalAtomic;
+
+TriviallyDestructibleClass Tdc;
+
+NonTriviallyDestructibleClass Ntdc;
+// CHECK-MESSAGES: [[@LINE-1]]:31: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+[[clang::no_destroy]] NonTriviallyDestructibleClass NtdcNoDestory;
+
+TriviallyDestructibleClass TdcArray[2] = { TriviallyDestructibleClass(), TriviallyDestructibleClass()};
+
+NonTriviallyDestructibleClass NtdcArray[2] = {
+NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()};
+// CHECK-MESSAGES: [[@LINE-2]]:31: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+const TriviallyDestructibleClass TdcConstArray[2] = {
+TriviallyDestructibleClass(), TriviallyDestructibleClass()};
+
+const NonTriviallyDestructibleClass NtdcConstArray[2] = {
+NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()};
+// CHECK-MESSAGES: [[@LINE-2]]:37: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+TriviallyDestructibleClass TdcMultiArray[2][2] = {
+{TriviallyDestructibleClass(), TriviallyDestructibleClass()},
+{TriviallyDestructibleClass(), TriviallyDestructibleClass()}};
+
+NonTriviallyDestructibleClass NtdcMultiArray[2][2] = {
+{NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()},
+{NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()}};
+// CHECK-MESSAGES: [[@LINE-3]]:31: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+const TriviallyDestructibleClass TdcMultiConstArray[2][2] = {
+{TriviallyDestructibleClass(), TriviallyDestructibleClass()},
+{TriviallyDestructibleClass(), TriviallyDestructibleClass()}};
+
+const NonTriviallyDestructibleClass NtdcMultiConstArray[2][2] = {
+{NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()},
+{NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()}};
+// CHECK-MESSAGES: [[@LINE-3]]:37: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+typedef TriviallyDestructibleClass TDCArray[1];
+TDCArray TdcTypedefArray[1];
+
+typedef NonTriviallyDestructibleClass NTDCArray[1];
+NTDCArray NTdcTypedefArray[1];
+// CHECK-MESSAGES: [[@LINE-1]]:11: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+const TriviallyDestructibleClass& getTdcRef() {
+  return *n

[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-06-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 535846.
cor3ntin marked 5 inline comments as done.
cor3ntin added a comment.

- Address Aaron's feedback
  - Add more tests
  - Add a longer description of the feature in the release notes
  - address nitpicks

- Improve error message when using __builtin_offsetof


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Lexer/unicode.c
  clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   Placeholder variables with no name
   https://wg21.link/P2169R4";>P2169R4
-  No
+  Clang 17
  
 
 
Index: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
@@ -0,0 +1,143 @@
+// RUN: %clang -cc1 -fsyntax-only -verify -std=c++2c -Wunused-parameter -Wunused %s
+
+void static_var() {
+static int _; // expected-note {{previous definition is here}} \
+  // expected-note {{candidate}}
+static int _; // expected-error {{redefinition of '_'}}
+int _;// expected-warning {{placeholder variables are a C++2c extension}} \
+  // expected-note {{candidate}}
+_++; // expected-error{{reference to '_' is ambiguous}}
+}
+
+void static_var_2() {
+int _; // expected-note {{previous definition is here}}
+static int _; // expected-error {{redefinition of '_'}}
+}
+
+void bindings() {
+int arr[4] = {0, 1, 2, 3};
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are a C++2c extension}} \
+ // expected-note 4{{placeholder declared here}}
+_ == 42; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+{
+// no extension warning as we only introduce a single placeholder.
+auto [_, a, b, c] = arr; // expected-warning {{unused variable '[_, a, b, c]'}}
+}
+{
+auto [_, _, b, c] = arr; // expected-warning {{unused variable '[_, _, b, c]'}} \
+ // expected-warning {{placeholder variables are a C++2c extension}}
+}
+{
+// There are only 3 extension warnings because the first
+// introduction of `_` is valid in all C++ standards
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are a C++2c extension}}
+}
+}
+
+void lambda() {
+(void)[_ = 0, _ = 1] { // expected-warning {{placeholder variables are a C++2c extension}} \
+   // expected-note 4{{placeholder declared here}}
+(void)_++; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+};
+
+{
+int _ = 12;
+(void)[_ = 0]{}; // no warning (different scope)
+}
+}
+
+namespace global_var {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+namespace {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+
+namespace global_fun {
+void _();
+void _();
+
+void _() {} // expected-note {{previous definition is here}}
+void _() {} // expected-error {{redefinition of '_'}}
+void _(int){}
+}
+
+typedef int _;
+typedef int _; // Type redeclaration, nothing to do with placeholders
+
+void extern_test() {
+extern int _;
+extern int _; // expected-note {{candidate}}
+int _; //expected-note {{candidate}}
+_++; // expected-error {{reference to '_' is ambiguous}}
+}
+
+
+struct Members {
+int _; // expected-note 2{{placeholder declared here}}
+int _; // expected-warning{{placeholder variables are a C++2c extension}} \
+   // expected-note 2{{placeholder declared here}}
+void f() {
+_++; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+}
+void attributes() __attribute__((diagnose_if(_ != 0, "oh no!", "warning"))); // expected-error{{ambiguous reference to placeholder '_', which is defined multiple times}}
+};
+
+namespace using_ {
+int _; // expected-note {{target of using declaration}}
+void f() {
+int _; // expected-note {{conflicting declaration}

[PATCH] D153993: [Headers][doc] Add load/store/cmp/cvt intrinsic descriptions to avx2intrin.h

2023-06-29 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/Headers/avx2intrin.h:3474
+///   IF __M[j+31] == 1
+/// result[j+31:j] := Load32(__X+(i*4))
+///   ELSE

probinson wrote:
> pengfei wrote:
> > A more intrinsic guide format is `MEM[__X+j:j]`
> LoadXX is the syntax in the gather intrinsics, e.g. _mm_mask_i32gather_pd. 
> I'd prefer to be consistent.
I think the problem here is the measurement is easily confusing.
From C point of view, `__X` is a `int` pointer, so we should `+ i` rather than 
`i * 4`
From the other part of the code, we are measuring in bits, but here `i * 4` is 
a byte offset.


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

https://reviews.llvm.org/D153993

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


[PATCH] D89918: Fix issue: clang-format result is not consistent if "// clang-format off" is followed by macro definition.

2023-06-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a subscriber: aaron.ballman.
MyDeveloperDay added a comment.

@owenpan @HazardyKnusperkeks @rymiel what are your feeling on how we should 
close old clang-format reviews like this?  (@aaron.ballman any thoughts on how 
it should be done?)

we end up with lots of reviews that either get metaphorically abandoned, 
(without actually being abandoned).. should we have some sort of rule, that 
says reviews left for N months with no activity are automatically abandoned (to 
do this you have to comindeer the revision, which I don't like doing)

Part of me just wants to consume the unit tests (if they pass).. do you think 
we should do anything? what about issues we effectively are saying "no to" like 
D147969  but are then not abandoned by the 
author?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89918

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


[PATCH] D153798: [clang-format] Correctly annotate operator free function call

2023-06-29 Thread Emilia Kond via Phabricator via cfe-commits
rymiel updated this revision to Diff 535859.
rymiel added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153798

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -657,6 +657,33 @@
   EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+
+  Tokens = annotate("class Foo {\n"
+"  int operator+(a* b);\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[5], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[8], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("void foo() {\n"
+"  operator+(a * b);\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[7], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[9], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("class Foo {\n"
+"  void foo() {\n"
+"operator+(a * b);\n"
+"  }\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[10], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[12], tok::star, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11580,6 +11580,14 @@
"  }",
getLLVMStyleWithColumns(50)));
 
+// FIXME: We should be able to figure out this is an operator call
+#if 0
+  verifyFormat("#define FOO \\\n"
+   "  void foo() {  \\\n"
+   "operator+(a * b);   \\\n"
+   "  }", getLLVMStyleWithColumns(25));
+#endif
+
   // FIXME: We cannot handle this case yet; we might be able to figure out that
   // foo d > v; doesn't make sense.
   verifyFormat("foo d> v;");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -310,9 +310,14 @@
   // If faced with "a.operator*(argument)" or "a->operator*(argument)",
   // i.e. the operator is called as a member function,
   // then the argument must be an expression.
-  bool OperatorCalledAsMemberFunction =
-  Prev->Previous && Prev->Previous->isOneOf(tok::period, tok::arrow);
-  Contexts.back().IsExpression = OperatorCalledAsMemberFunction;
+  // If faced with "operator+(argument)", i.e. the operator is called as
+  // a free function, then the argument is an expression only if the 
current
+  // line can't be a declaration.
+  bool IsOperatorCallSite =
+  (Prev->Previous &&
+   Prev->Previous->isOneOf(tok::period, tok::arrow)) ||
+  (!Line.MustBeDeclaration && !Line.InMacroBody);
+  Contexts.back().IsExpression = IsOperatorCallSite;
 } else if (OpeningParen.is(TT_VerilogInstancePortLParen)) {
   Contexts.back().IsExpression = true;
   Contexts.back().ContextType = Context::VerilogInstancePortList;


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -657,6 +657,33 @@
   EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+
+  Tokens = annotate("class Foo {\n"
+"  int operator+(a* b);\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[5], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[8], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("void foo() {\n"
+"  operator+(a * b);\n"
+"}");
+ 

[PATCH] D154016: [clang][modules] Avoid serializing all diag mappings in non-deterministic order

2023-06-29 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added inline comments.



Comment at: clang/lib/Serialization/ASTWriter.cpp:3016
   for (const auto &I : *State) {
-if (I.second.isPragma() || IncludeNonPragmaStates) {
-  Record.push_back(I.first);
-  Record.push_back(I.second.serialize());
-}
+// Maybe skip non-pragmas.
+if (!I.second.isPragma() && !IncludeNonPragmaStates)

Is pragma in this context refer to `#pragma diagnostics push/pop`? Do we have 
test to cover those to be deterministic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154016

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


[PATCH] D153993: [Headers][doc] Add load/store/cmp/cvt intrinsic descriptions to avx2intrin.h

2023-06-29 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/lib/Headers/avx2intrin.h:3474
+///   IF __M[j+31] == 1
+/// result[j+31:j] := Load32(__X+(i*4))
+///   ELSE

pengfei wrote:
> probinson wrote:
> > pengfei wrote:
> > > A more intrinsic guide format is `MEM[__X+j:j]`
> > LoadXX is the syntax in the gather intrinsics, e.g. _mm_mask_i32gather_pd. 
> > I'd prefer to be consistent.
> I think the problem here is the measurement is easily confusing.
> From C point of view, `__X` is a `int` pointer, so we should `+ i` rather 
> than `i * 4`
> From the other part of the code, we are measuring in bits, but here `i * 4` 
> is a byte offset.
Well, the pseudo-code is clearly not C. If you look at the gather code, it 
computes a byte address using an offset multiplied by an explicit scale factor. 
I am doing exactly the same here.

The syntax `MEM[__X+j:j]` is mixing a byte address with a bit offset, which I 
think is more confusing. To be fully consistent, using `[]` with bit offsets 
only, it should be
```
k := __X*8 + i*32
result[j+31:j] := MEM[k+31:k]
```
which I think obscures more than it explains.


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

https://reviews.llvm.org/D153993

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


[PATCH] D153898: [DebugInfo] Enable debug info emission for extern variables in C++

2023-06-29 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song accepted this revision.
yonghong-song added a comment.

I am okay with this change. Once you used this patch and implemented the 
mechanism inside Google. Could you send a follow-up summary on what the 
implementation looks like in Google? This will give people a sense why this is 
useful/better than other alternatives (like macro based approach).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153898

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


[clang] 4986f3f - [clang-format] Correctly annotate operator free function call

2023-06-29 Thread Emilia Kond via cfe-commits

Author: Emilia Kond
Date: 2023-06-29T19:51:27+03:00
New Revision: 4986f3f2f220e4fd2fef4b08e550b399c9f45a9f

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

LOG: [clang-format] Correctly annotate operator free function call

The annotator correctly annotates an overloaded operator call when
called as a member function, like `x.operator+(y)`, however, when called
as a free function, like `operator+(x, y)`, the annotator assumed it was
an overloaded operator function *declaration*, instead of a call.

This patch allows for a free function call to correctly be annotated as
a call, but only if the current like cannot be a declaration, usually
within the bodies of a function.

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay, Nuu

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 27814b8f46862..735089f1ad9d7 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -310,9 +310,14 @@ class AnnotatingParser {
   // If faced with "a.operator*(argument)" or "a->operator*(argument)",
   // i.e. the operator is called as a member function,
   // then the argument must be an expression.
-  bool OperatorCalledAsMemberFunction =
-  Prev->Previous && Prev->Previous->isOneOf(tok::period, tok::arrow);
-  Contexts.back().IsExpression = OperatorCalledAsMemberFunction;
+  // If faced with "operator+(argument)", i.e. the operator is called as
+  // a free function, then the argument is an expression only if the 
current
+  // line can't be a declaration.
+  bool IsOperatorCallSite =
+  (Prev->Previous &&
+   Prev->Previous->isOneOf(tok::period, tok::arrow)) ||
+  (!Line.MustBeDeclaration && !Line.InMacroBody);
+  Contexts.back().IsExpression = IsOperatorCallSite;
 } else if (OpeningParen.is(TT_VerilogInstancePortLParen)) {
   Contexts.back().IsExpression = true;
   Contexts.back().ContextType = Context::VerilogInstancePortList;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 8338799dc2ba6..e1e9719761723 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11580,6 +11580,14 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
"  }",
getLLVMStyleWithColumns(50)));
 
+// FIXME: We should be able to figure out this is an operator call
+#if 0
+  verifyFormat("#define FOO \\\n"
+   "  void foo() {  \\\n"
+   "operator+(a * b);   \\\n"
+   "  }", getLLVMStyleWithColumns(25));
+#endif
+
   // FIXME: We cannot handle this case yet; we might be able to figure out that
   // foo d > v; doesn't make sense.
   verifyFormat("foo d> v;");

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index b7980bb6d923d..b6fbe7380d5d2 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -668,6 +668,33 @@ TEST_F(TokenAnnotatorTest, UnderstandsOverloadedOperators) 
{
   EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+
+  Tokens = annotate("class Foo {\n"
+"  int operator+(a* b);\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[5], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[8], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("void foo() {\n"
+"  operator+(a * b);\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[7], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[9], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("class Foo {\n"
+"  void foo() {\n"
+"operator+(a * b);\n"
+"  }\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[10], tok::l_paren, TT_OverloadedOperatorL

[PATCH] D153798: [clang-format] Correctly annotate operator free function call

2023-06-29 Thread Emilia Kond 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 rG4986f3f2f220: [clang-format] Correctly annotate operator 
free function call (authored by rymiel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153798

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -668,6 +668,33 @@
   EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+
+  Tokens = annotate("class Foo {\n"
+"  int operator+(a* b);\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[5], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[8], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("void foo() {\n"
+"  operator+(a * b);\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[7], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[9], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("class Foo {\n"
+"  void foo() {\n"
+"operator+(a * b);\n"
+"  }\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[10], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(Tokens[12], tok::star, TT_BinaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11580,6 +11580,14 @@
"  }",
getLLVMStyleWithColumns(50)));
 
+// FIXME: We should be able to figure out this is an operator call
+#if 0
+  verifyFormat("#define FOO \\\n"
+   "  void foo() {  \\\n"
+   "operator+(a * b);   \\\n"
+   "  }", getLLVMStyleWithColumns(25));
+#endif
+
   // FIXME: We cannot handle this case yet; we might be able to figure out that
   // foo d > v; doesn't make sense.
   verifyFormat("foo d> v;");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -310,9 +310,14 @@
   // If faced with "a.operator*(argument)" or "a->operator*(argument)",
   // i.e. the operator is called as a member function,
   // then the argument must be an expression.
-  bool OperatorCalledAsMemberFunction =
-  Prev->Previous && Prev->Previous->isOneOf(tok::period, tok::arrow);
-  Contexts.back().IsExpression = OperatorCalledAsMemberFunction;
+  // If faced with "operator+(argument)", i.e. the operator is called as
+  // a free function, then the argument is an expression only if the 
current
+  // line can't be a declaration.
+  bool IsOperatorCallSite =
+  (Prev->Previous &&
+   Prev->Previous->isOneOf(tok::period, tok::arrow)) ||
+  (!Line.MustBeDeclaration && !Line.InMacroBody);
+  Contexts.back().IsExpression = IsOperatorCallSite;
 } else if (OpeningParen.is(TT_VerilogInstancePortLParen)) {
   Contexts.back().IsExpression = true;
   Contexts.back().ContextType = Context::VerilogInstancePortList;


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -668,6 +668,33 @@
   EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+
+  Tokens = annotate("class Foo {\n"
+"  int operator+(a* b);\n"
+"}");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[5], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_OverloadedOperatorLParen);
+  EXPECT_TOKEN(

  1   2   3   >