[clang] [llvm] [RISCV] Add sifive-p470 processor (PR #102022)

2024-08-07 Thread Yingwei Zheng via cfe-commits

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

LGTM.

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


[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)

2024-08-07 Thread via cfe-commits

yingopq wrote:

@MaskRay please help review, I have added test and update code `MipsMsa`. 
Thanks!

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


[clang] [llvm] [HLSL] Add list of exported functions as named metadata node 'dx.exports` (PR #102275)

2024-08-07 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/102275

>From 340834e9c1ea12c8de4ee9f5a6b7c0191e96f489 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Tue, 6 Aug 2024 23:19:20 -0700
Subject: [PATCH 1/2] [HLSL] Add list of exported functions as named metadata
 node 'dx.exports'

This information will be used by DXILFinalizeLinkage pass (coming soon)
to determine which functions should have internal linkage in the final
DXIL code. After this pass is completed the `dx.exports` metadata node
will be removed.
---
 clang/lib/CodeGen/CGHLSLRuntime.cpp   |  8 
 clang/lib/CodeGen/CGHLSLRuntime.h |  2 +-
 clang/lib/CodeGen/CodeGenFunction.cpp | 10 +++---
 clang/test/CodeGenHLSL/export.hlsl| 18 +
 llvm/lib/Target/DirectX/DXILMetadata.cpp  | 20 +++
 llvm/lib/Target/DirectX/DXILMetadata.h|  1 +
 .../Target/DirectX/DXILTranslateMetadata.cpp  |  1 +
 7 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index a2c3e76f77b7c7..5e59b0f00ebd64 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -412,6 +412,14 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl 
*FD,
   B.CreateRetVoid();
 }
 
+void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD,
+  llvm::Function *Fn) {
+  if (FD->isInExportDeclContext()) {
+const StringRef ExportAttrKindStr = "hlsl.export";
+Fn->addFnAttr(ExportAttrKindStr);
+  }
+}
+
 static void gatherFunctions(SmallVectorImpl &Fns, llvm::Module &M,
 bool CtorOrDtor) {
   const auto *GV =
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 527e73a0e21fc4..590d388c456c45 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -124,7 +124,7 @@ class CGHLSLRuntime {
   void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
 
   void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
-  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(const FunctionDecl *FD, llvm::Function *Fn);
 
 private:
   void addBufferResourceAnnotation(llvm::GlobalVariable *GV,
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index af201554898f31..9e9dd6b9c8e17e 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1223,9 +1223,13 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   if (getLangOpts().OpenMP && CurCodeDecl)
 CGM.getOpenMPRuntime().emitFunctionProlog(*this, CurCodeDecl);
 
-  // Handle emitting HLSL entry functions.
-  if (D && D->hasAttr())
-CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+  if (FD && getLangOpts().HLSL) {
+// Handle emitting HLSL entry functions.
+if (FD->hasAttr()) {
+  CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+}
+CGM.getHLSLRuntime().setHLSLFunctionAttributes(FD, Fn);
+  }
 
   EmitFunctionProlog(*CurFnInfo, CurFn, Args);
 
diff --git a/clang/test/CodeGenHLSL/export.hlsl 
b/clang/test/CodeGenHLSL/export.hlsl
index 53f603739e329b..98d1a5a2f13fb1 100644
--- a/clang/test/CodeGenHLSL/export.hlsl
+++ b/clang/test/CodeGenHLSL/export.hlsl
@@ -1,20 +1,30 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang --driver-mode=dxc -T lib_6_3 -Od %s | FileCheck %s 
--check-prefix=CHECK-MD
 
-// CHECK: define void @"?f1@@YAXXZ"()
+// CHECK: define void @"?f1@@YAXXZ"() [[Attr:\#[0-9]+]]
 export void f1() {
 }
 
-// CHECK: define void @"?f2@MyNamespace@@YAXXZ"()
+// CHECK: define void @"?f2@MyNamespace@@YAXXZ"() [[Attr]]
 namespace MyNamespace {
   export void f2() {
   }
 }
 
 export {
-// CHECK: define void @"?f3@@YAXXZ"()
-// CHECK: define void @"?f4@@YAXXZ"()
+// CHECK: define void @"?f3@@YAXXZ"() [[Attr]]
+// CHECK: define void @"?f4@@YAXXZ"() [[Attr]]
 void f3() {}
 void f4() {}
 }
+
+// CHECK: attributes [[Attr]] = { {{.*}} "hlsl.export" {{.*}} }
+
+// CHECK-MD: !dx.exports = !{[[Exp1:![0-9]+]], [[Exp2:![0-9]+]], 
[[Exp3:![0-9]+]], [[Exp4:![0-9]+]]}
+// CHECK-MD: [[Exp1]] = !{ptr @"?f1@@YAXXZ", !"?f1@@YAXXZ"}
+// CHECK-MD: [[Exp2]] = !{ptr @"?f2@MyNamespace@@YAXXZ", 
!"?f2@MyNamespace@@YAXXZ"}
+// CHECK-MD: [[Exp3]] = !{ptr @"?f3@@YAXXZ", !"?f3@@YAXXZ"}
+// CHECK-MD: [[Exp4]] = !{ptr @"?f4@@YAXXZ", !"?f4@@YAXXZ"}
+
diff --git a/llvm/lib/Target/DirectX/DXILMetadata.cpp 
b/llvm/lib/Target/DirectX/DXILMetadata.cpp
index ed0434ac98a18b..cd554471b15c79 100644
--- a/llvm/lib/Target/DirectX/DXILMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILMetadata.cpp
@@ -328,3 +328,23 @@ void dxil::createEntryMD(Module &M, const uint

[clang] [llvm] [HLSL] Add list of exported functions as named metadata node `dx.exports` (PR #102275)

2024-08-07 Thread Helena Kotas via cfe-commits

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


[clang] [llvm] [HLSL] Add list of exported functions as named metadata node `dx.exports` (PR #102275)

2024-08-07 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/102275

>From 340834e9c1ea12c8de4ee9f5a6b7c0191e96f489 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Tue, 6 Aug 2024 23:19:20 -0700
Subject: [PATCH 1/3] [HLSL] Add list of exported functions as named metadata
 node 'dx.exports'

This information will be used by DXILFinalizeLinkage pass (coming soon)
to determine which functions should have internal linkage in the final
DXIL code. After this pass is completed the `dx.exports` metadata node
will be removed.
---
 clang/lib/CodeGen/CGHLSLRuntime.cpp   |  8 
 clang/lib/CodeGen/CGHLSLRuntime.h |  2 +-
 clang/lib/CodeGen/CodeGenFunction.cpp | 10 +++---
 clang/test/CodeGenHLSL/export.hlsl| 18 +
 llvm/lib/Target/DirectX/DXILMetadata.cpp  | 20 +++
 llvm/lib/Target/DirectX/DXILMetadata.h|  1 +
 .../Target/DirectX/DXILTranslateMetadata.cpp  |  1 +
 7 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index a2c3e76f77b7c7..5e59b0f00ebd64 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -412,6 +412,14 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl 
*FD,
   B.CreateRetVoid();
 }
 
+void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD,
+  llvm::Function *Fn) {
+  if (FD->isInExportDeclContext()) {
+const StringRef ExportAttrKindStr = "hlsl.export";
+Fn->addFnAttr(ExportAttrKindStr);
+  }
+}
+
 static void gatherFunctions(SmallVectorImpl &Fns, llvm::Module &M,
 bool CtorOrDtor) {
   const auto *GV =
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 527e73a0e21fc4..590d388c456c45 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -124,7 +124,7 @@ class CGHLSLRuntime {
   void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
 
   void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
-  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(const FunctionDecl *FD, llvm::Function *Fn);
 
 private:
   void addBufferResourceAnnotation(llvm::GlobalVariable *GV,
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index af201554898f31..9e9dd6b9c8e17e 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1223,9 +1223,13 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   if (getLangOpts().OpenMP && CurCodeDecl)
 CGM.getOpenMPRuntime().emitFunctionProlog(*this, CurCodeDecl);
 
-  // Handle emitting HLSL entry functions.
-  if (D && D->hasAttr())
-CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+  if (FD && getLangOpts().HLSL) {
+// Handle emitting HLSL entry functions.
+if (FD->hasAttr()) {
+  CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+}
+CGM.getHLSLRuntime().setHLSLFunctionAttributes(FD, Fn);
+  }
 
   EmitFunctionProlog(*CurFnInfo, CurFn, Args);
 
diff --git a/clang/test/CodeGenHLSL/export.hlsl 
b/clang/test/CodeGenHLSL/export.hlsl
index 53f603739e329b..98d1a5a2f13fb1 100644
--- a/clang/test/CodeGenHLSL/export.hlsl
+++ b/clang/test/CodeGenHLSL/export.hlsl
@@ -1,20 +1,30 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang --driver-mode=dxc -T lib_6_3 -Od %s | FileCheck %s 
--check-prefix=CHECK-MD
 
-// CHECK: define void @"?f1@@YAXXZ"()
+// CHECK: define void @"?f1@@YAXXZ"() [[Attr:\#[0-9]+]]
 export void f1() {
 }
 
-// CHECK: define void @"?f2@MyNamespace@@YAXXZ"()
+// CHECK: define void @"?f2@MyNamespace@@YAXXZ"() [[Attr]]
 namespace MyNamespace {
   export void f2() {
   }
 }
 
 export {
-// CHECK: define void @"?f3@@YAXXZ"()
-// CHECK: define void @"?f4@@YAXXZ"()
+// CHECK: define void @"?f3@@YAXXZ"() [[Attr]]
+// CHECK: define void @"?f4@@YAXXZ"() [[Attr]]
 void f3() {}
 void f4() {}
 }
+
+// CHECK: attributes [[Attr]] = { {{.*}} "hlsl.export" {{.*}} }
+
+// CHECK-MD: !dx.exports = !{[[Exp1:![0-9]+]], [[Exp2:![0-9]+]], 
[[Exp3:![0-9]+]], [[Exp4:![0-9]+]]}
+// CHECK-MD: [[Exp1]] = !{ptr @"?f1@@YAXXZ", !"?f1@@YAXXZ"}
+// CHECK-MD: [[Exp2]] = !{ptr @"?f2@MyNamespace@@YAXXZ", 
!"?f2@MyNamespace@@YAXXZ"}
+// CHECK-MD: [[Exp3]] = !{ptr @"?f3@@YAXXZ", !"?f3@@YAXXZ"}
+// CHECK-MD: [[Exp4]] = !{ptr @"?f4@@YAXXZ", !"?f4@@YAXXZ"}
+
diff --git a/llvm/lib/Target/DirectX/DXILMetadata.cpp 
b/llvm/lib/Target/DirectX/DXILMetadata.cpp
index ed0434ac98a18b..cd554471b15c79 100644
--- a/llvm/lib/Target/DirectX/DXILMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILMetadata.cpp
@@ -328,3 +328,23 @@ void dxil::createEntryMD(Module &M, const uint

[clang] [llvm] [HLSL] Add list of exported functions as named metadata node `dx.exports` (PR #102275)

2024-08-07 Thread Helena Kotas via cfe-commits

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


[clang] [llvm] [HLSL] Add list of exported functions as named metadata node `dx.exports` (PR #102275)

2024-08-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Helena Kotas (hekota)


Changes

Adds list of exported functions as named metadata node 'dx.exports`.

During CodeGen each exported functions is marked with an "hlsl.export" 
attribute. Based on these attributes the DXILTranslateMetadata pass will create 
a list of all export functions and will add it to the module under `dx.exports`.

This information will be then used by DXILFinalizeLinkage pass (coming soon) to 
determine which functions should have internal linkage in the final DXIL code. 
After this pass is completed the `dx.exports` metadata node will be removed.



---
Full diff: https://github.com/llvm/llvm-project/pull/102275.diff


8 Files Affected:

- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+8) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.h (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+7-3) 
- (modified) clang/test/CodeGenHLSL/export.hlsl (+6-4) 
- (modified) llvm/lib/Target/DirectX/DXILMetadata.cpp (+20) 
- (modified) llvm/lib/Target/DirectX/DXILMetadata.h (+1) 
- (modified) llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp (+1) 
- (added) llvm/test/CodeGen/DirectX/Metadata/exports.ll (+19) 


``diff
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index a2c3e76f77b7c..5e59b0f00ebd6 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -412,6 +412,14 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl 
*FD,
   B.CreateRetVoid();
 }
 
+void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD,
+  llvm::Function *Fn) {
+  if (FD->isInExportDeclContext()) {
+const StringRef ExportAttrKindStr = "hlsl.export";
+Fn->addFnAttr(ExportAttrKindStr);
+  }
+}
+
 static void gatherFunctions(SmallVectorImpl &Fns, llvm::Module &M,
 bool CtorOrDtor) {
   const auto *GV =
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 527e73a0e21fc..590d388c456c4 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -124,7 +124,7 @@ class CGHLSLRuntime {
   void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
 
   void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
-  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(const FunctionDecl *FD, llvm::Function *Fn);
 
 private:
   void addBufferResourceAnnotation(llvm::GlobalVariable *GV,
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index af201554898f3..9e9dd6b9c8e17 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1223,9 +1223,13 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   if (getLangOpts().OpenMP && CurCodeDecl)
 CGM.getOpenMPRuntime().emitFunctionProlog(*this, CurCodeDecl);
 
-  // Handle emitting HLSL entry functions.
-  if (D && D->hasAttr())
-CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+  if (FD && getLangOpts().HLSL) {
+// Handle emitting HLSL entry functions.
+if (FD->hasAttr()) {
+  CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+}
+CGM.getHLSLRuntime().setHLSLFunctionAttributes(FD, Fn);
+  }
 
   EmitFunctionProlog(*CurFnInfo, CurFn, Args);
 
diff --git a/clang/test/CodeGenHLSL/export.hlsl 
b/clang/test/CodeGenHLSL/export.hlsl
index 53f603739e329..63f9f9066f927 100644
--- a/clang/test/CodeGenHLSL/export.hlsl
+++ b/clang/test/CodeGenHLSL/export.hlsl
@@ -2,19 +2,21 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
-// CHECK: define void @"?f1@@YAXXZ"()
+// CHECK: define void @"?f1@@YAXXZ"() [[Attr:\#[0-9]+]]
 export void f1() {
 }
 
-// CHECK: define void @"?f2@MyNamespace@@YAXXZ"()
+// CHECK: define void @"?f2@MyNamespace@@YAXXZ"() [[Attr]]
 namespace MyNamespace {
   export void f2() {
   }
 }
 
 export {
-// CHECK: define void @"?f3@@YAXXZ"()
-// CHECK: define void @"?f4@@YAXXZ"()
+// CHECK: define void @"?f3@@YAXXZ"() [[Attr]]
+// CHECK: define void @"?f4@@YAXXZ"() [[Attr]]
 void f3() {}
 void f4() {}
 }
+
+// CHECK: attributes [[Attr]] = { {{.*}} "hlsl.export" {{.*}} }
diff --git a/llvm/lib/Target/DirectX/DXILMetadata.cpp 
b/llvm/lib/Target/DirectX/DXILMetadata.cpp
index ed0434ac98a18..5ec56a2852502 100644
--- a/llvm/lib/Target/DirectX/DXILMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILMetadata.cpp
@@ -328,3 +328,23 @@ void dxil::createEntryMD(Module &M, const uint64_t 
ShaderFlags) {
   for (auto *Entry : Entries)
 EntryPointsNamedMD->addOperand(Entry);
 }
+
+void dxil::createExportsMD(Module &M) {
+  LLVMContext &Ctx = M.getContext();
+  std::vector ExportsMDList;
+  for (auto &F : M.functions()) {
+if (!F.hasFnAttribute("hlsl.export"))
+  continue;
+
+Metadata *MDVals[2];
+MDVal

[clang] [llvm] [HLSL] Add list of exported functions as named metadata node `dx.exports` (PR #102275)

2024-08-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-directx

Author: Helena Kotas (hekota)


Changes

Adds list of exported functions as named metadata node 'dx.exports`.

During CodeGen each exported functions is marked with an "hlsl.export" 
attribute. Based on these attributes the DXILTranslateMetadata pass will create 
a list of all export functions and will add it to the module under `dx.exports`.

This information will be then used by DXILFinalizeLinkage pass (coming soon) to 
determine which functions should have internal linkage in the final DXIL code. 
After this pass is completed the `dx.exports` metadata node will be removed.



---
Full diff: https://github.com/llvm/llvm-project/pull/102275.diff


8 Files Affected:

- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+8) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.h (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+7-3) 
- (modified) clang/test/CodeGenHLSL/export.hlsl (+6-4) 
- (modified) llvm/lib/Target/DirectX/DXILMetadata.cpp (+20) 
- (modified) llvm/lib/Target/DirectX/DXILMetadata.h (+1) 
- (modified) llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp (+1) 
- (added) llvm/test/CodeGen/DirectX/Metadata/exports.ll (+19) 


``diff
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index a2c3e76f77b7c..5e59b0f00ebd6 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -412,6 +412,14 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl 
*FD,
   B.CreateRetVoid();
 }
 
+void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD,
+  llvm::Function *Fn) {
+  if (FD->isInExportDeclContext()) {
+const StringRef ExportAttrKindStr = "hlsl.export";
+Fn->addFnAttr(ExportAttrKindStr);
+  }
+}
+
 static void gatherFunctions(SmallVectorImpl &Fns, llvm::Module &M,
 bool CtorOrDtor) {
   const auto *GV =
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 527e73a0e21fc..590d388c456c4 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -124,7 +124,7 @@ class CGHLSLRuntime {
   void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
 
   void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
-  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(const FunctionDecl *FD, llvm::Function *Fn);
 
 private:
   void addBufferResourceAnnotation(llvm::GlobalVariable *GV,
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index af201554898f3..9e9dd6b9c8e17 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1223,9 +1223,13 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   if (getLangOpts().OpenMP && CurCodeDecl)
 CGM.getOpenMPRuntime().emitFunctionProlog(*this, CurCodeDecl);
 
-  // Handle emitting HLSL entry functions.
-  if (D && D->hasAttr())
-CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+  if (FD && getLangOpts().HLSL) {
+// Handle emitting HLSL entry functions.
+if (FD->hasAttr()) {
+  CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
+}
+CGM.getHLSLRuntime().setHLSLFunctionAttributes(FD, Fn);
+  }
 
   EmitFunctionProlog(*CurFnInfo, CurFn, Args);
 
diff --git a/clang/test/CodeGenHLSL/export.hlsl 
b/clang/test/CodeGenHLSL/export.hlsl
index 53f603739e329..63f9f9066f927 100644
--- a/clang/test/CodeGenHLSL/export.hlsl
+++ b/clang/test/CodeGenHLSL/export.hlsl
@@ -2,19 +2,21 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
-// CHECK: define void @"?f1@@YAXXZ"()
+// CHECK: define void @"?f1@@YAXXZ"() [[Attr:\#[0-9]+]]
 export void f1() {
 }
 
-// CHECK: define void @"?f2@MyNamespace@@YAXXZ"()
+// CHECK: define void @"?f2@MyNamespace@@YAXXZ"() [[Attr]]
 namespace MyNamespace {
   export void f2() {
   }
 }
 
 export {
-// CHECK: define void @"?f3@@YAXXZ"()
-// CHECK: define void @"?f4@@YAXXZ"()
+// CHECK: define void @"?f3@@YAXXZ"() [[Attr]]
+// CHECK: define void @"?f4@@YAXXZ"() [[Attr]]
 void f3() {}
 void f4() {}
 }
+
+// CHECK: attributes [[Attr]] = { {{.*}} "hlsl.export" {{.*}} }
diff --git a/llvm/lib/Target/DirectX/DXILMetadata.cpp 
b/llvm/lib/Target/DirectX/DXILMetadata.cpp
index ed0434ac98a18..5ec56a2852502 100644
--- a/llvm/lib/Target/DirectX/DXILMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILMetadata.cpp
@@ -328,3 +328,23 @@ void dxil::createEntryMD(Module &M, const uint64_t 
ShaderFlags) {
   for (auto *Entry : Entries)
 EntryPointsNamedMD->addOperand(Entry);
 }
+
+void dxil::createExportsMD(Module &M) {
+  LLVMContext &Ctx = M.getContext();
+  std::vector ExportsMDList;
+  for (auto &F : M.functions()) {
+if (!F.hasFnAttribute("hlsl.export"))
+  continue;
+
+Metadata *MDVals[2];
+MDV

[clang] [llvm] [RISCV] Add vector and vector crypto to SiFiveP400 scheduler model (PR #102155)

2024-08-07 Thread Camel Coder via cfe-commits

camel-cdr wrote:

Are the vrgather.vv numbers correct? Usually LMUL>1 vrgather is implemented by 
aplying a LMUL=1 vrgather LMUL^2 times. Since the LMUL=1 vrgather.vv takes a 
single cycle, I would've expected a 4 cycle LMUL=2 vrgather.vv instead of 12.
12 cycles is less than one element per cycle (128/32*2=8).

Oh, and did you use upstream llvm-exegesis? I didn't managed to get it to work 
last time I tried.


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


[clang] [clang] Emit bad shift warnings (PR #70307)

2024-08-07 Thread Mike Hommey via cfe-commits

glandium wrote:

> We (Chrome) no longer need a revert - we patched the NDK locally.

Patching the NDK is not a solution that is nice everywhere, though. And the new 
warning is an error that can't be disabled.

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


[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p3 requirements (PR #101853)

2024-08-07 Thread Oleksandr T. via cfe-commits

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


[clang] [Clang] [Frontend] fix crash on parsing ternary operator with `vector_size` condition (PR #102004)

2024-08-07 Thread Pavel Skripkin via cfe-commits


@@ -6719,6 +6719,16 @@ QualType Sema::CheckVectorConditionalTypes(ExprResult 
&Cond, ExprResult &LHS,
 : UsualArithmeticConversions(LHS, RHS, QuestionLoc,
  ACK_Conditional);
 
+if (ResultElementTy.isNull()) {
+  Diag(QuestionLoc, diag::err_conditional_vector_mismatched)
+  << LHSType << RHSType;
+  return {};
+}

pskrgag wrote:

Yeah, it looks better, thanks! 

I am actually not sure if we support different types or not. `vector_size` is 
an extension and there is no clear wording what is allowed and what is not...  

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


[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p3 requirements (PR #101853)

2024-08-07 Thread Oleksandr T. via cfe-commits


@@ -8052,10 +8061,7 @@ NamedDecl *Sema::ActOnVariableDeclarator(
   }
 
   // Special handling of variable named 'main'.
-  if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo()->isStr("main") 
&&
-  NewVD->getDeclContext()->getRedeclContext()->isTranslationUnit() &&
-  !getLangOpts().Freestanding && !NewVD->getDescribedVarTemplate()) {
-
+  if (!getLangOpts().Freestanding && isMainVar(Name, NewVD)) {
 // C++ [basic.start.main]p3
 // A program that declares a variable main at global scope is ill-formed.

a-tarasyuk wrote:

@MitalAshok Thanks for the reviews. I’ve added requested changes. 

@MitalAshok @Sirraide If there’s no further feedback, could you please proceed 
with the merge since I don’t have access? Thanks.

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


[clang] [llvm] Revert "demangle function names in trace files (#87626)" (PR #102274)

2024-08-07 Thread Nikita Popov via cfe-commits

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


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


[clang] [clang][ASTMatcher] Add `matchesString` for `StringLiteral` which matches literals on given `RegExp` (PR #102152)

2024-08-07 Thread Ding Fei via cfe-commits

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


[clang] [clang][ASTMatcher] Add `matchesString` for `StringLiteral` which matches literals on given `RegExp` (PR #102152)

2024-08-07 Thread Ding Fei via cfe-commits

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


[clang] [clang-format] Change BinPackParameters to an enum to add a BreakAlways (PR #101882)

2024-08-07 Thread Owen Pan via cfe-commits

owenca wrote:

> When you say rename, do you mean deprecate `BinPackParameters` like in these 
> changes 
> [6739bb5](https://github.com/llvm/llvm-project/commit/6739bb5006bc28e2bdbdb2326eb2c957546634aa)
>  but using `BreakParameters` and `Never`/`OnePerLine`/`Always` for the names?

Yes, deprecate `BinPackParameters` and rename it to either `PackParameters` 
(with `enum` values `Leave`, `Always`, `OnePerLine`, and `Never`) or 
`BreakParameters` (with `enum` values `Leave`, `Never`, `OnePerLine`, and 
`Always`). I don't really like `OnePerLine` but can't think of a better 
alternative that's not wordy. If adding `Leave` is not trivial, we can support 
it in another patch.

Have you given any thought about 
https://github.com/llvm/llvm-project/issues/53190#issuecomment-1973631975?

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


[clang] [llvm] [RISCV] Add Syntacore SCR5 RV32/64 processors definition (PR #102285)

2024-08-07 Thread Anton Sidorenko via cfe-commits

https://github.com/asi-sc created 
https://github.com/llvm/llvm-project/pull/102285

Syntacore SCR5 is an entry-level Linux-capable 32/64-bit RISC-V processor core.
Overview: https://syntacore.com/products/scr5

Scheduling model will be added in a subsequent PR.

Co-authored-by: Dmitrii Petrov 
Co-authored-by: Anton Afanasyev 

>From 4c433796397d7393aefba63489d3e915949b172a Mon Sep 17 00:00:00 2001
From: Anton Sidorenko 
Date: Thu, 4 Jul 2024 18:09:26 +0300
Subject: [PATCH] [RISCV] Add Syntacore SCR5 RV32/64 processors definition

Syntacore SCR5 is an entry-level Linux-capable 32/64-bit RISC-V processor core.
Overview: https://syntacore.com/products/scr5

Co-authored-by: Dmitrii Petrov 
Co-authored-by: Anton Afanasyev 
---
 clang/test/Driver/riscv-cpus.c| 28 +++
 clang/test/Misc/target-invalid-cpu-note.c |  8 +++
 llvm/docs/ReleaseNotes.rst|  2 +-
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 26 +
 4 files changed, 59 insertions(+), 5 deletions(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 7a885cde76d6ae..29b646fcf300ad 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -408,3 +408,31 @@
 
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr4-rv64 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR4-RV64 %s
 // MTUNE-SYNTACORE-SCR4-RV64: "-tune-cpu" "syntacore-scr4-rv64"
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr5-rv32 | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR5-RV32 %s
+// MCPU-SYNTACORE-SCR5-RV32: "-target-cpu" "syntacore-scr5-rv32"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+m"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+a"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+f"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+d"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+zicsr"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+zifencei"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-abi" "ilp32d"
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=syntacore-scr5-rv32 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR5-RV32 %s
+// MTUNE-SYNTACORE-SCR5-RV32: "-tune-cpu" "syntacore-scr5-rv32"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=syntacore-scr5-rv64 | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR5-RV64 %s
+// MCPU-SYNTACORE-SCR5-RV64: "-target-cpu" "syntacore-scr5-rv64"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+m"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+a"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+f"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+d"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+zicsr"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+zifencei"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr5-rv64 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR5-RV64 %s
+// MTUNE-SYNTACORE-SCR5-RV64: "-tune-cpu" "syntacore-scr5-rv64"
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index b87bced18cb2b4..77f781a1f9415e 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -81,16 +81,16 @@
 
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
-// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, 
sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, 
syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, 
syntacore-scr4-rv32{{$}}
+// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, 
sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, 
syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, 
syntacore-scr4-rv32, syntacore-scr5-rv32{{$}}
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, 
syntacore-scr4-rv64, veyron-v1, xiangshan-nanhu{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, 
syntacore-scr4-rv64, syntacore-scr5-rv64, veyron-v1, xiangshan-nanhu{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --ch

[clang] [llvm] [RISCV] Add Syntacore SCR5 RV32/64 processors definition (PR #102285)

2024-08-07 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-clang-driver

Author: Anton Sidorenko (asi-sc)


Changes

Syntacore SCR5 is an entry-level Linux-capable 32/64-bit RISC-V processor core.
Overview: https://syntacore.com/products/scr5

Scheduling model will be added in a subsequent PR.

Co-authored-by: Dmitrii Petrov 
Co-authored-by: Anton Afanasyev 

---
Full diff: https://github.com/llvm/llvm-project/pull/102285.diff


4 Files Affected:

- (modified) clang/test/Driver/riscv-cpus.c (+28) 
- (modified) clang/test/Misc/target-invalid-cpu-note.c (+4-4) 
- (modified) llvm/docs/ReleaseNotes.rst (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+26) 


``diff
diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 7a885cde76d6a..29b646fcf300a 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -408,3 +408,31 @@
 
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr4-rv64 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR4-RV64 %s
 // MTUNE-SYNTACORE-SCR4-RV64: "-tune-cpu" "syntacore-scr4-rv64"
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr5-rv32 | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR5-RV32 %s
+// MCPU-SYNTACORE-SCR5-RV32: "-target-cpu" "syntacore-scr5-rv32"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+m"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+a"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+f"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+d"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+zicsr"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-feature" "+zifencei"
+// MCPU-SYNTACORE-SCR5-RV32-SAME: "-target-abi" "ilp32d"
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=syntacore-scr5-rv32 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR5-RV32 %s
+// MTUNE-SYNTACORE-SCR5-RV32: "-tune-cpu" "syntacore-scr5-rv32"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=syntacore-scr5-rv64 | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR5-RV64 %s
+// MCPU-SYNTACORE-SCR5-RV64: "-target-cpu" "syntacore-scr5-rv64"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+m"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+a"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+f"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+d"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+zicsr"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-feature" "+zifencei"
+// MCPU-SYNTACORE-SCR5-RV64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr5-rv64 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR5-RV64 %s
+// MTUNE-SYNTACORE-SCR5-RV64: "-tune-cpu" "syntacore-scr5-rv64"
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index b87bced18cb2b..77f781a1f9415 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -81,16 +81,16 @@
 
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
-// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, 
sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, 
syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, 
syntacore-scr4-rv32{{$}}
+// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, 
sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, 
syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, 
syntacore-scr4-rv32, syntacore-scr5-rv32{{$}}
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, 
syntacore-scr4-rv64, veyron-v1, xiangshan-nanhu{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, 
syntacore-scr4-rv64, syntacore-scr5-rv64, veyron-v1, xiangshan-nanhu{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV32-NEXT: note: valid target CPU values are: generic-rv32, 
rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, 
sifive-e76, syntacore-scr1-base, syntacor

[clang] [clang-format] Change BinPackParameters to an enum to add a BreakAlways (PR #101882)

2024-08-07 Thread via cfe-commits

mydeveloperday wrote:

Whilst I can understand BinPackParameters being deprecated, as its one of the 
original options I do worry a little about just how much impact such a 
deprecation might have... it needs to be completely seemless because there is 
ALOT of documentation references to its use on say stackoverflow. etc...

One reason I suggested making the change without renaming the option was the 
level of flux the name change was having. I couldn't really see in the review 
what was a change for the name/enum and what was the new behaviour. (maybe that 
could be done in 2 separate commits?)

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


[clang] Reland [C++20] [Modules] [Itanium ABI] Generate the vtable in the mod… (PR #102287)

2024-08-07 Thread Chuanqi Xu via cfe-commits

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


[clang] Reland [C++20] [Modules] [Itanium ABI] Generate the vtable in the mod… (PR #102287)

2024-08-07 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 created 
https://github.com/llvm/llvm-project/pull/102287

Reland https://github.com/llvm/llvm-project/pull/75912

The differences of this PR between 
https://github.com/llvm/llvm-project/pull/75912 are:

- Fixed a regression in `Decl::isInAnotherModuleUnit()` in DeclBase.cpp pointed 
by @mizvekov and add the corresponding test.
- Fixed the regression in windows 
https://github.com/llvm/llvm-project/issues/97447. The changes are in 
`CodeGenModule::getVTableLinkage` from `clang/lib/CodeGen/CGVTables.cpp`. 
According to the feedbacks from MSVC devs, the linkage of vtables won't 
affected by modules. So I simply skipped the case for MSVC.

Given this is more or less fundamental to the use of modules. I hope we can 
backport this to 19.x. 

>From 7daf703b8d2602bd13d9eb9a9e6c9487205427b0 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Wed, 7 Aug 2024 16:05:44 +0800
Subject: [PATCH] Reland [C++20] [Modules] [Itanium ABI] Generate the vtable in
 the module unit of dynamic classes (#75912)

Close https://github.com/llvm/llvm-project/issues/70585 and reflect
https://github.com/itanium-cxx-abi/cxx-abi/issues/170.

The significant change of the patch is: for dynamic classes attached to
module units, we generate the vtable to the attached module units
directly and the key functions for such classes is meaningless.
---
 clang/include/clang/AST/DeclBase.h|   7 ++
 .../include/clang/Serialization/ASTBitCodes.h |   3 +
 clang/include/clang/Serialization/ASTReader.h |   6 +
 clang/include/clang/Serialization/ASTWriter.h |   7 ++
 clang/lib/AST/ASTContext.cpp  |   2 +-
 clang/lib/AST/DeclBase.cpp|  34 +++--
 clang/lib/CodeGen/CGVTables.cpp   |  65 ++
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |   3 +
 clang/lib/Sema/SemaDecl.cpp   |   9 ++
 clang/lib/Sema/SemaDeclCXX.cpp|  14 ++-
 clang/lib/Serialization/ASTReader.cpp |  11 ++
 clang/lib/Serialization/ASTReaderDecl.cpp |   7 ++
 clang/lib/Serialization/ASTWriter.cpp |  33 -
 clang/lib/Serialization/ASTWriterDecl.cpp |   6 +
 clang/test/CodeGenCXX/modules-vtable.cppm |  31 +++--
 clang/test/CodeGenCXX/pr70585.cppm|  47 +++
 clang/test/Modules/pr97313.cppm   | 118 ++
 .../test/Modules/static-func-in-private.cppm  |   8 ++
 clang/test/Modules/vtable-windows.cppm|  26 
 19 files changed, 384 insertions(+), 53 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/pr70585.cppm
 create mode 100644 clang/test/Modules/pr97313.cppm
 create mode 100644 clang/test/Modules/static-func-in-private.cppm
 create mode 100644 clang/test/Modules/vtable-windows.cppm

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 58f0aaba93b71..04dbd1db6cba8 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -670,6 +670,13 @@ class alignas(8) Decl {
   /// Whether this declaration comes from another module unit.
   bool isInAnotherModuleUnit() const;
 
+  /// Whether this declaration comes from the same module unit being compiled.
+  bool isInCurrentModuleUnit() const;
+
+  /// Whether the definition of the declaration should be emitted in external
+  /// sources.
+  bool shouldEmitInExternalSource() const;
+
   /// Whether this declaration comes from explicit global module.
   bool isFromExplicitGlobalModule() const;
 
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index f19eef6c5908d..93d28fbef8e45 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -721,6 +721,9 @@ enum ASTRecordTypes {
 
   /// Record code for \#pragma clang unsafe_buffer_usage begin/end
   PP_UNSAFE_BUFFER_USAGE = 69,
+
+  /// Record code for vtables to emit.
+  VTABLES_TO_EMIT = 70,
 };
 
 /// Record types used within a source manager block.
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 1ae1bf8ec7957..fde39e2c2240e 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -790,6 +790,11 @@ class ASTReader
   /// the consumer eagerly.
   SmallVector EagerlyDeserializedDecls;
 
+  /// The IDs of all vtables to emit. The referenced declarations are passed
+  /// to the consumers's HandleVTable eagerly after passing
+  /// EagerlyDeserializedDecls.
+  SmallVector VTablesToEmit;
+
   /// The IDs of all tentative definitions stored in the chain.
   ///
   /// Sema keeps track of all tentative definitions in a TU because it has to
@@ -1500,6 +1505,7 @@ class ASTReader
   bool isConsumerInterestedIn(Decl *D);
   void PassInterestingDeclsToConsumer();
   void PassInterestingDeclToConsumer(Decl *D);
+  void PassVTableToConsumer(CXXRecordDecl *RD);
 
   void finishPendingActions();
   void dia

[clang] Reland [C++20] [Modules] [Itanium ABI] Generate the vtable in the mod… (PR #102287)

2024-08-07 Thread Chuanqi Xu via cfe-commits

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


[clang] Reland [C++20] [Modules] [Itanium ABI] Generate the vtable in the mod… (PR #102287)

2024-08-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Chuanqi Xu (ChuanqiXu9)


Changes

Reland https://github.com/llvm/llvm-project/pull/75912

The differences of this PR between 
https://github.com/llvm/llvm-project/pull/75912 are:

- Fixed a regression in `Decl::isInAnotherModuleUnit()` in DeclBase.cpp pointed 
by @mizvekov and add the corresponding test.
- Fixed the regression in windows 
https://github.com/llvm/llvm-project/issues/97447. The changes are in 
`CodeGenModule::getVTableLinkage` from `clang/lib/CodeGen/CGVTables.cpp`. 
According to the feedbacks from MSVC devs, the linkage of vtables won't 
affected by modules. So I simply skipped the case for MSVC.

Given this is more or less fundamental to the use of modules. I hope we can 
backport this to 19.x. 

---

Patch is 28.22 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/102287.diff


19 Files Affected:

- (modified) clang/include/clang/AST/DeclBase.h (+7) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+3) 
- (modified) clang/include/clang/Serialization/ASTReader.h (+6) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+7) 
- (modified) clang/lib/AST/ASTContext.cpp (+1-1) 
- (modified) clang/lib/AST/DeclBase.cpp (+25-9) 
- (modified) clang/lib/CodeGen/CGVTables.cpp (+43-22) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+3) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+9) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+9-5) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+11) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+7) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+29-4) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+6) 
- (modified) clang/test/CodeGenCXX/modules-vtable.cppm (+19-12) 
- (added) clang/test/CodeGenCXX/pr70585.cppm (+47) 
- (added) clang/test/Modules/pr97313.cppm (+118) 
- (added) clang/test/Modules/static-func-in-private.cppm (+8) 
- (added) clang/test/Modules/vtable-windows.cppm (+26) 


``diff
diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 58f0aaba93b71b..04dbd1db6cba81 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -670,6 +670,13 @@ class alignas(8) Decl {
   /// Whether this declaration comes from another module unit.
   bool isInAnotherModuleUnit() const;
 
+  /// Whether this declaration comes from the same module unit being compiled.
+  bool isInCurrentModuleUnit() const;
+
+  /// Whether the definition of the declaration should be emitted in external
+  /// sources.
+  bool shouldEmitInExternalSource() const;
+
   /// Whether this declaration comes from explicit global module.
   bool isFromExplicitGlobalModule() const;
 
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index f19eef6c5908d2..93d28fbef8e456 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -721,6 +721,9 @@ enum ASTRecordTypes {
 
   /// Record code for \#pragma clang unsafe_buffer_usage begin/end
   PP_UNSAFE_BUFFER_USAGE = 69,
+
+  /// Record code for vtables to emit.
+  VTABLES_TO_EMIT = 70,
 };
 
 /// Record types used within a source manager block.
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 1ae1bf8ec79570..fde39e2c2240ed 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -790,6 +790,11 @@ class ASTReader
   /// the consumer eagerly.
   SmallVector EagerlyDeserializedDecls;
 
+  /// The IDs of all vtables to emit. The referenced declarations are passed
+  /// to the consumers's HandleVTable eagerly after passing
+  /// EagerlyDeserializedDecls.
+  SmallVector VTablesToEmit;
+
   /// The IDs of all tentative definitions stored in the chain.
   ///
   /// Sema keeps track of all tentative definitions in a TU because it has to
@@ -1500,6 +1505,7 @@ class ASTReader
   bool isConsumerInterestedIn(Decl *D);
   void PassInterestingDeclsToConsumer();
   void PassInterestingDeclToConsumer(Decl *D);
+  void PassVTableToConsumer(CXXRecordDecl *RD);
 
   void finishPendingActions();
   void diagnoseOdrViolations();
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index a0e475ec9f862c..71a7c28047e318 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -500,6 +500,10 @@ class ASTWriter : public ASTDeserializationListener,
   std::vector NonAffectingRanges;
   std::vector NonAffectingOffsetAdjustments;
 
+  /// A list of classes which need to emit the VTable in the corresponding
+  /// object file.
+  llvm::SmallVector PendingEmittingVTables;
+
   /// Computes input files that didn't affect compilation of the current 
module,
   /// and initializes data structures necessar

[clang] [clang-format] Fix a bug in annotating CastRParen (PR #102261)

2024-08-07 Thread via cfe-commits

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


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


[clang] [clang-format] Adjust requires clause wrapping (#101550) (PR #102078)

2024-08-07 Thread via cfe-commits

https://github.com/mydeveloperday requested changes to this pull request.

I'm of the opinion if you are changing tests then something is wrong.

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


[clang] Reland [C++20] [Modules] [Itanium ABI] Generate the vtable in the mod… (PR #102287)

2024-08-07 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 89db3bbd27ddc5ec980799c987dafd167c5a4564 
7daf703b8d2602bd13d9eb9a9e6c9487205427b0 --extensions h,cppm,cpp -- 
clang/test/CodeGenCXX/pr70585.cppm clang/test/Modules/pr97313.cppm 
clang/test/Modules/static-func-in-private.cppm 
clang/test/Modules/vtable-windows.cppm clang/include/clang/AST/DeclBase.h 
clang/include/clang/Serialization/ASTBitCodes.h 
clang/include/clang/Serialization/ASTReader.h 
clang/include/clang/Serialization/ASTWriter.h clang/lib/AST/ASTContext.cpp 
clang/lib/AST/DeclBase.cpp clang/lib/CodeGen/CGVTables.cpp 
clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Sema/SemaDecl.cpp 
clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Serialization/ASTReader.cpp 
clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp 
clang/lib/Serialization/ASTWriterDecl.cpp 
clang/test/CodeGenCXX/modules-vtable.cppm
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 5febe18eca..029fac7ed7 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -1081,10 +1081,10 @@ llvm::GlobalVariable::LinkageTypes
 CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
   if (!RD->isExternallyVisible())
 return llvm::GlobalVariable::InternalLinkage;
-  
+
   // In windows, the linkage of vtable is not related to modules.
-  bool IsInNamedModule = !getTarget().getCXXABI().isMicrosoft() &&
-RD->isInNamedModule();
+  bool IsInNamedModule =
+  !getTarget().getCXXABI().isMicrosoft() && RD->isInNamedModule();
   // If the CXXRecordDecl are not in a module unit, we need to get
   // its key function. We're at the end of the translation unit, so the current
   // key function is fully correct.
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index e5e53af2b7..005b264a87 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6584,8 +6584,7 @@ void ASTRecordWriter::AddCXXDefinitionData(const 
CXXRecordDecl *D) {
 
   bool ModulesCodegen =
   !D->isDependentType() &&
- (Writer->Context->getLangOpts().ModulesDebugInfo ||
-  D->isInNamedModule());
+  (Writer->Context->getLangOpts().ModulesDebugInfo || 
D->isInNamedModule());
   Record->push_back(ModulesCodegen);
   if (ModulesCodegen)
 Writer->AddDeclRef(D, Writer->ModularCodegenDecls);

``




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


[clang] [lld] [llvm] [LTO] enable `ObjCARCContractPass` only on optimized build (PR #101114)

2024-08-07 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] [clang][ASTMatcher] Add `matchesString` for `StringLiteral` which matches literals on given `RegExp` (PR #102152)

2024-08-07 Thread via cfe-commits

https://github.com/Gitspike updated 
https://github.com/llvm/llvm-project/pull/102152

>From c74cea916b5efe739de8a4dc6f63d583f5a46da3 Mon Sep 17 00:00:00 2001
From: hehouhua 
Date: Wed, 7 Aug 2024 11:55:30 +0800
Subject: [PATCH 1/2] [clang][ASTMatcher] Add matches for StringLiteral which
 matches literals on given RegExp

Add Matcher matchesString.
---
 clang/docs/LibASTMatchersReference.html   | 14 +++
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 24 +++
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |  6 +
 5 files changed, 47 insertions(+)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index a16b9c44ef0eab..77b789b1ec4b94 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -5582,6 +5582,20 @@ Narrowing Matchers
 
 
 
+MatcherStringLiteral>matchesStringStringRef RegExp, 
Regex::RegexFlags Flags = NoFlags
+Matches string 
literals that contain a substring matched by the given RegExp
+
+Example matches "foo" and "foobar" but not "bar"
+  (matcher = stringLiteral(matchesString("foo.*")))
+  const char* a = "foo";
+  const char* b = "foobar";
+  const char* c = "bar";
+
+Usable as: Matcher
+
+
+
+
 MatcherStringLiteral>hasSizeunsigned N
 Matches nodes that have the 
specified size.
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 54decb5dbf230d..353e1de6de3648 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -284,6 +284,8 @@ AST Matchers
 - Fixed an issue with the `hasName` and `hasAnyName` matcher when matching
   inline namespaces with an enclosing namespace of the same name.
 
+Add `matchesString` for `StringLiteral` which matches literals on given 
`RegExp`.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index ca44c3ee085654..bff415294c4561 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3116,6 +3116,30 @@ AST_MATCHER_REGEX(NamedDecl, matchesName, RegExp) {
   return RegExp->match(FullNameString);
 }
 
+/// Matches string literals that contain a substring matched by the given 
RegExp.
+///
+/// Example matches "foo" and "foobar" but not "bar"
+///   (matcher = stringLiteral(matchesString("foo.*")))
+/// \code
+///   const char* a = "foo";
+///   const char* b = "foobar";
+///   const char* c = "bar";
+/// \endcode
+///
+/// Usable as: Matcher
+AST_MATCHER_REGEX(StringLiteral, matchesString, RegExp) {
+  constexpr unsigned StringLength = 64;
+  SmallString Str;
+  llvm::raw_svector_ostream OS(Str);
+  Node.outputString(OS);
+  StringRef OSRef = OS.str();
+  if (OSRef.size() < 2U) {
+return false;
+  }
+  OSRef = OSRef.substr(1, OSRef.size() - 2);
+  return RegExp->match(OSRef);
+}
+
 /// Matches overloaded operator names.
 ///
 /// Matches overloaded operator names specified in strings without the
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 2c75e6beb74301..a3a2515d86be70 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -125,6 +125,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER_OVERLOAD(equals);
 
   REGISTER_REGEX_MATCHER(isExpansionInFileMatching);
+  REGISTER_REGEX_MATCHER(matchesString);
   REGISTER_REGEX_MATCHER(matchesName);
   REGISTER_REGEX_MATCHER(matchesSelector);
 
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 611e1f9ba5327c..25106d38826a8d 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2503,6 +2503,12 @@ TEST_P(ASTMatchersTest, IsDelegatingConstructor) {
   cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(1;
 }
 
+TEST_P(ASTMatchersTest, matchesString) {
+  StatementMatcher Literal = stringLiteral(matchesString("foo.*"));
+  EXPECT_TRUE(matches("const char* a = \"foo\";", Literal));
+  EXPECT_TRUE(matches("const char* b = \"foobar\";", Literal));
+}
+
 TEST_P(ASTMatchersTest, HasSize) {
   StatementMatcher Literal = stringLiteral(hasSize(4));
   EXPECT_TRUE(matches("const char *s = \"abcd\";", Literal));

>From ad6ab9695c06a5993f63c2eb1ba7d7ee39fa13bb Mon Sep 17 00:00:00 2001
From: hehouhua 
Date: Wed, 7 Aug 2024 16:57:17 +0800
Subject: [PATCH 2/2] fix test name and add testcase

---
 clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/u

[clang] [clang][ASTMatcher] Add `matchesString` for `StringLiteral` which matches literals on given `RegExp` (PR #102152)

2024-08-07 Thread via cfe-commits

https://github.com/Gitspike updated 
https://github.com/llvm/llvm-project/pull/102152

>From 53182588d50cc3f29621eeb7dba0e5c30ed4bfa3 Mon Sep 17 00:00:00 2001
From: hehouhua 
Date: Wed, 7 Aug 2024 11:55:30 +0800
Subject: [PATCH] [clang][ASTMatcher] Add matches for StringLiteral which
 matches literals on given RegExp

Add Matcher matchesString.
---
 clang/docs/LibASTMatchersReference.html   | 14 +++
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 24 +++
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |  8 +++
 5 files changed, 49 insertions(+)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index a16b9c44ef0ea..77b789b1ec4b9 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -5582,6 +5582,20 @@ Narrowing Matchers
 
 
 
+MatcherStringLiteral>matchesStringStringRef RegExp, 
Regex::RegexFlags Flags = NoFlags
+Matches string 
literals that contain a substring matched by the given RegExp
+
+Example matches "foo" and "foobar" but not "bar"
+  (matcher = stringLiteral(matchesString("foo.*")))
+  const char* a = "foo";
+  const char* b = "foobar";
+  const char* c = "bar";
+
+Usable as: Matcher
+
+
+
+
 MatcherStringLiteral>hasSizeunsigned N
 Matches nodes that have the 
specified size.
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 54decb5dbf230..353e1de6de364 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -284,6 +284,8 @@ AST Matchers
 - Fixed an issue with the `hasName` and `hasAnyName` matcher when matching
   inline namespaces with an enclosing namespace of the same name.
 
+Add `matchesString` for `StringLiteral` which matches literals on given 
`RegExp`.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index ca44c3ee08565..bff415294c456 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3116,6 +3116,30 @@ AST_MATCHER_REGEX(NamedDecl, matchesName, RegExp) {
   return RegExp->match(FullNameString);
 }
 
+/// Matches string literals that contain a substring matched by the given 
RegExp.
+///
+/// Example matches "foo" and "foobar" but not "bar"
+///   (matcher = stringLiteral(matchesString("foo.*")))
+/// \code
+///   const char* a = "foo";
+///   const char* b = "foobar";
+///   const char* c = "bar";
+/// \endcode
+///
+/// Usable as: Matcher
+AST_MATCHER_REGEX(StringLiteral, matchesString, RegExp) {
+  constexpr unsigned StringLength = 64;
+  SmallString Str;
+  llvm::raw_svector_ostream OS(Str);
+  Node.outputString(OS);
+  StringRef OSRef = OS.str();
+  if (OSRef.size() < 2U) {
+return false;
+  }
+  OSRef = OSRef.substr(1, OSRef.size() - 2);
+  return RegExp->match(OSRef);
+}
+
 /// Matches overloaded operator names.
 ///
 /// Matches overloaded operator names specified in strings without the
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 2c75e6beb7430..a3a2515d86be7 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -125,6 +125,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER_OVERLOAD(equals);
 
   REGISTER_REGEX_MATCHER(isExpansionInFileMatching);
+  REGISTER_REGEX_MATCHER(matchesString);
   REGISTER_REGEX_MATCHER(matchesName);
   REGISTER_REGEX_MATCHER(matchesSelector);
 
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 611e1f9ba5327..77b6c4be26f06 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2503,6 +2503,14 @@ TEST_P(ASTMatchersTest, IsDelegatingConstructor) {
   cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(1;
 }
 
+TEST_P(ASTMatchersTest, MatchesString) {
+  StatementMatcher Literal = stringLiteral(matchesString("foo.*"));
+  EXPECT_TRUE(matches("const char* a = \"foo\";", Literal));
+  EXPECT_TRUE(matches("const char* b = \"foobar\";", Literal));
+  EXPECT_TRUE(matches("const char* b = \"fo\"\"obar\";", Literal));
+  EXPECT_TRUE(notMatches("const char* c = \"bar\";", Literal));
+}
+
 TEST_P(ASTMatchersTest, HasSize) {
   StatementMatcher Literal = stringLiteral(hasSize(4));
   EXPECT_TRUE(matches("const char *s = \"abcd\";", Literal));

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


[clang] [clang][ASTMatcher] Add `matchesString` for `StringLiteral` which matches literals on given `RegExp` (PR #102152)

2024-08-07 Thread via cfe-commits

https://github.com/Gitspike updated 
https://github.com/llvm/llvm-project/pull/102152

>From 53182588d50cc3f29621eeb7dba0e5c30ed4bfa3 Mon Sep 17 00:00:00 2001
From: hehouhua 
Date: Wed, 7 Aug 2024 11:55:30 +0800
Subject: [PATCH] [clang][ASTMatcher] Add matches for StringLiteral which
 matches literals on given RegExp

Add Matcher matchesString.
---
 clang/docs/LibASTMatchersReference.html   | 14 +++
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 24 +++
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |  8 +++
 5 files changed, 49 insertions(+)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index a16b9c44ef0eab..77b789b1ec4b94 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -5582,6 +5582,20 @@ Narrowing Matchers
 
 
 
+MatcherStringLiteral>matchesStringStringRef RegExp, 
Regex::RegexFlags Flags = NoFlags
+Matches string 
literals that contain a substring matched by the given RegExp
+
+Example matches "foo" and "foobar" but not "bar"
+  (matcher = stringLiteral(matchesString("foo.*")))
+  const char* a = "foo";
+  const char* b = "foobar";
+  const char* c = "bar";
+
+Usable as: Matcher
+
+
+
+
 MatcherStringLiteral>hasSizeunsigned N
 Matches nodes that have the 
specified size.
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 54decb5dbf230d..353e1de6de3648 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -284,6 +284,8 @@ AST Matchers
 - Fixed an issue with the `hasName` and `hasAnyName` matcher when matching
   inline namespaces with an enclosing namespace of the same name.
 
+Add `matchesString` for `StringLiteral` which matches literals on given 
`RegExp`.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index ca44c3ee085654..bff415294c4561 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3116,6 +3116,30 @@ AST_MATCHER_REGEX(NamedDecl, matchesName, RegExp) {
   return RegExp->match(FullNameString);
 }
 
+/// Matches string literals that contain a substring matched by the given 
RegExp.
+///
+/// Example matches "foo" and "foobar" but not "bar"
+///   (matcher = stringLiteral(matchesString("foo.*")))
+/// \code
+///   const char* a = "foo";
+///   const char* b = "foobar";
+///   const char* c = "bar";
+/// \endcode
+///
+/// Usable as: Matcher
+AST_MATCHER_REGEX(StringLiteral, matchesString, RegExp) {
+  constexpr unsigned StringLength = 64;
+  SmallString Str;
+  llvm::raw_svector_ostream OS(Str);
+  Node.outputString(OS);
+  StringRef OSRef = OS.str();
+  if (OSRef.size() < 2U) {
+return false;
+  }
+  OSRef = OSRef.substr(1, OSRef.size() - 2);
+  return RegExp->match(OSRef);
+}
+
 /// Matches overloaded operator names.
 ///
 /// Matches overloaded operator names specified in strings without the
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 2c75e6beb74301..a3a2515d86be70 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -125,6 +125,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER_OVERLOAD(equals);
 
   REGISTER_REGEX_MATCHER(isExpansionInFileMatching);
+  REGISTER_REGEX_MATCHER(matchesString);
   REGISTER_REGEX_MATCHER(matchesName);
   REGISTER_REGEX_MATCHER(matchesSelector);
 
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 611e1f9ba5327c..77b6c4be26f06b 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2503,6 +2503,14 @@ TEST_P(ASTMatchersTest, IsDelegatingConstructor) {
   cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(1;
 }
 
+TEST_P(ASTMatchersTest, MatchesString) {
+  StatementMatcher Literal = stringLiteral(matchesString("foo.*"));
+  EXPECT_TRUE(matches("const char* a = \"foo\";", Literal));
+  EXPECT_TRUE(matches("const char* b = \"foobar\";", Literal));
+  EXPECT_TRUE(matches("const char* b = \"fo\"\"obar\";", Literal));
+  EXPECT_TRUE(notMatches("const char* c = \"bar\";", Literal));
+}
+
 TEST_P(ASTMatchersTest, HasSize) {
   StatementMatcher Literal = stringLiteral(hasSize(4));
   EXPECT_TRUE(matches("const char *s = \"abcd\";", Literal));

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


[clang] [C++20] [Modules] Don't set modules owner ship information for builtin declarations (PR #102115)

2024-08-07 Thread Chuanqi Xu via cfe-commits


@@ -2376,6 +2376,12 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, 
unsigned ID,
   FunctionDecl *New = CreateBuiltin(II, R, ID, Loc);
   RegisterLocallyScopedExternCDecl(New, S);
 
+  // Builtin functions shouldn't be owned by any module.
+  if (New->hasOwningModule()) {
+New->setLocalOwningModule(nullptr);

ChuanqiXu9 wrote:

I posted https://github.com/llvm/llvm-project/issues/102290. Let's talk about 
this there. And I think I don't have time to do that in the near future and I 
feel the status quo is not really bad. So I'd like to propose to land this 
patch first and remove this after we make the implementation design better 
someday.

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


[clang] [llvm] [AArch64] Add updated FEAT_SVE_B16B16 and begin replacement of 'b16b16' flag (PR #101480)

2024-08-07 Thread via cfe-commits

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


[clang] 96d824d - [ARM] Enable cfi-icall for thumb triples (#102126)

2024-08-07 Thread via cfe-commits

Author: Oliver Stannard
Date: 2024-08-07T10:21:10+01:00
New Revision: 96d824d935d631a4c28133f9f8f1f583eefd040d

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

LOG: [ARM] Enable cfi-icall for thumb triples (#102126)

Support for this was added back in 2016
(https://reviews.llvm.org/D27499), but never enabled in the driver.
Since then, it's been possible to enable this with an arm triple and the
-mthumb option, but not with a thumb triple.

This also caused -fsanitise=cfi to enable cfi-icall for arm triple but
not thumb triples, which caused spurious sanitiser failures if mixing
the two ISAs in one program.

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 20a555afb8092..2d50c2cbbc881 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1381,7 +1381,8 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
   SanitizerKind::Nullability | SanitizerKind::LocalBounds;
   if (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64 ||
-  getTriple().getArch() == llvm::Triple::arm || getTriple().isWasm() ||
+  getTriple().getArch() == llvm::Triple::arm ||
+  getTriple().getArch() == llvm::Triple::thumb || getTriple().isWasm() ||
   getTriple().isAArch64() || getTriple().isRISCV() ||
   getTriple().isLoongArch64())
 Res |= SanitizerKind::CFIICall;

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index db14f6e195c64..678fa432fb0a0 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -611,6 +611,8 @@
 // RUN: %clang --target=arm-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // RUN: %clang --target=aarch64-linux-gnu -fvisibility=hidden -fsanitize=cfi 
-flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // RUN: %clang --target=arm-linux-android -fvisibility=hidden -fsanitize=cfi 
-flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
+// RUN: %clang --target=arm-none-eabi -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
+// RUN: %clang --target=thumb-none-eabi -fvisibility=hidden -fsanitize=cfi 
-flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // RUN: %clang --target=aarch64-linux-android -fvisibility=hidden 
-fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CFI
 // RUN: %clang --target=aarch64_be -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // RUN: %clang --target=riscv32 -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI



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


[clang] [ARM] Enable cfi-icall for thumb triples (PR #102126)

2024-08-07 Thread Oliver Stannard via cfe-commits

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


[clang] [llvm] [NVPTX] Support __usAtomicCAS builtin (PR #99646)

2024-08-07 Thread via cfe-commits

gonzalobg wrote:

@Artem-B this LGTM 

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


[clang] [llvm] [NVPTX] Support __usAtomicCAS builtin (PR #99646)

2024-08-07 Thread via cfe-commits

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


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


[clang] [llvm] [AArch64] Add updated FEAT_SVE_B16B16 and begin replacement of 'b16b16' flag (PR #101480)

2024-08-07 Thread via cfe-commits


@@ -2172,7 +2172,7 @@ let SVETargetGuard = InvalidMode, SMETargetGuard = "sme2" 
in {
   def SVFCLAMP_X4 : SInst<"svclamp[_single_{d}_x4]",  "44dd",   "hfd",  
MergeNone, "aarch64_sve_fclamp_single_x4",  [IsStreaming], []>;
 }
 
-let SVETargetGuard = InvalidMode, SMETargetGuard = "sme2,b16b16"in {
+let SVETargetGuard = InvalidMode, SMETargetGuard = "sme2,sve-b16b16"in {

SpencerAbson wrote:

Thanks for pointing this out.

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


[clang] [llvm] [AArch64] Add updated FEAT_SVE_B16B16 and begin replacement of 'b16b16' flag (PR #101480)

2024-08-07 Thread via cfe-commits


@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2 -verify -verify-ignore-unexpected=error,note -emit-llvm 
-o - %s

SpencerAbson wrote:

Will do :+1: 

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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2 instruction (PR #97755)

2024-08-07 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/97755

>From 22f5bb7cab1673632f1fa5438a35f861c16d63b2 Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Thu, 4 Jul 2024 17:10:36 +
Subject: [PATCH 1/3] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2
 instruction

This patch adds these intrinsics:

// Variants are also available for: _s8
  svuint8x4_t svluti4_zt_u8_x4(uint64_t zt0, svuint8x2_t zn) __arm_streaming 
__arm_in("zt0");

according to PR#324[1]
[1]ARM-software/acle#324
---
 clang/include/clang/Basic/arm_sme.td  |  5 ++
 .../acle_sme2_luti4_zt.c  | 82 +++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  5 ++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  6 ++
 .../Target/AArch64/AArch64ISelDAGToDAG.cpp| 19 -
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |  2 +-
 .../AArch64/sme2-intrinsics-write-zt.ll   | 17 
 7 files changed, 132 insertions(+), 4 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-write-zt.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ce8908f566f2fd..e4a61caae733ec 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -817,4 +817,9 @@ multiclass ZAReadzArray{
 
 defm SVREADZ_VG2 :  ZAReadzArray<"2">;
 defm SVREADZ_VG4 :  ZAReadzArray<"4">;
+
+let SMETargetGuard = "sme2,sme-lutv2" in {
+  def SVLUTI4_ZT_X4 : SInst<"svluti4_zt_{d}_x4", "4i2", "cUc", MergeNone, 
"aarch64_sme_luti4_zt_x4", [IsStreaming, IsInOutZT0], [ImmCheck<0, 
ImmCheck0_0>]>;
+}
+
 } // let SVETargetGuard = InvalidMode
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
new file mode 100644
index 00..2e7cd0939f516b
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
@@ -0,0 +1,82 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 
-Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++  -triple aarch64-none-linux-gnu -target-feature 
+bf16 -target-feature +sme -target-feature +sme2 -target-feature  +sme-lutv2  
-O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-CXX
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS   -triple aarch64-none-linux-gnu 
-target-feature +bf16 -target-feature +sme -target-feature +sme2 
-target-feature  +sme-lutv2  -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -x c++  -triple 
aarch64-none-linux-gnu -target-feature +bf16 -target-feature +sme 
-target-feature +sme2 -target-feature +sme-lutv2 -O2 -Werror -Wall -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-CXX
+
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 -S 
-Werror -Wall -o /dev/null %s
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+// CHECK-LABEL: define dso_local  @test_luti4_zt_u8_x4(
+// CHECK-SAME:  [[OP:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.vector.extract.nxv16i8.nxv32i8( [[OP]], i64 0)
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.vector.extract.nxv16i8.nxv32i8( [[OP]], i64 16)
+// CHECK-NEXT:[[TMP2:%.*]] = tail call { , , ,  } 
@llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0,  [[TMP0]], 
 [[TMP1]])
+// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , ,  } [[TMP2]], 0
+// CHECK-NEXT:[[TMP4:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( poison,  [[TMP3]], i64 0)
+// CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , ,  } [[TMP2]], 1
+// CHECK-NEXT:[[TMP6:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP4]],  [[TMP5]], i64 16)
+// CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , ,  } [[TMP2]], 2
+// CHECK-NEXT:[[TMP8:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP6]],  [[TMP7]], i64 32)
+// CHECK-NEXT:[[TMP9:%.*]] = extractvalue { , , ,  } [[TMP2]], 3
+// CHECK-NEXT:[[TMP10:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP8]],  [[TMP9]], i64 48)
+// CHECK-NEXT:ret  [[TMP10]]
+//
+// CHECK-CXX-LABEL: define dso_local  
@_Z19test_luti4_zt_u8_x411svuint8x2_t(
+// CHECK-CXX-SAME:  [[OP:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-CXX-NEXT:  [[ENTRY:.*:]]
+// CHECK-CXX-NEXT:[[TMP0:%.*]] = tail call  
@llvm.vector.extract.nxv16i8.nxv32i8( [[OP]], i64 0)
+// CHECK-CXX-NEXT:[[TMP1:%.*]] = tail call  
@llvm.vector.extract.nxv16i8.nxv32i8( [[OP]], i64 16)
+// CHECK-CXX-NEXT:[[TMP2:%.*]] = tail call { , , ,

[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits

https://github.com/MichelleCDjunaidi created 
https://github.com/llvm/llvm-project/pull/102299

This checks that classes/structs inheriting from 
``std::enable_shared_from_this`` derive it with the ``public`` access 
specifier, so it prevents crashes due to ``std::make_shared`` and 
``shared_from_this()`` getting called on a non-public class/struct. 

>From 75306bd83eb43d0606630f9f059fc04ad1b20b06 Mon Sep 17 00:00:00 2001
From: Michelle C Djunaidi 
Date: Wed, 7 Aug 2024 13:10:02 +0800
Subject: [PATCH 1/2] [clang-tidy] Add bugprone-public-enable-shared-from-this
 check

This check identifies classes deriving from std::enable_shared_from_this that 
does not inherit with the public keyword,
which may cause problems when std::make_shared is called for that class.
---
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  1 +
 .../PublicEnableSharedFromThisCheck.cpp   | 45 +++
 .../PublicEnableSharedFromThisCheck.h | 33 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../bugprone/public-enable-shared-from-this   |  6 ++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../public-enable-shared-from-this.cpp| 56 +++
 8 files changed, 150 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/public-enable-shared-from-this
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/public-enable-shared-from-this.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d17..f12f0cd1c47da3 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -53,6 +53,7 @@
 #include "ParentVirtualCallCheck.h"
 #include "PointerArithmeticOnPolymorphicObjectCheck.h"
 #include "PosixReturnCheck.h"
+#include "PublicEnableSharedFromThisCheck.h"
 #include "RedundantBranchConditionCheck.h"
 #include "ReservedIdentifierCheck.h"
 #include "ReturnConstRefFromParameterCheck.h"
@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-public-enable-shared-from-this");
 CheckFactories.registerCheck(
 "bugprone-return-const-ref-from-parameter");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac58..c9bea094241edc 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  PublicEnableSharedFromThisCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SuspiciousStringviewDataUsageCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp
new file mode 100644
index 00..dab3e0ac596fe7
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp
@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  co

[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: None (MichelleCDjunaidi)


Changes

This checks that classes/structs inheriting from 
``std::enable_shared_from_this`` derive it with the ``public`` access 
specifier, so it prevents crashes due to ``std::make_shared`` and 
``shared_from_this()`` getting called on a non-public class/struct. 

---
Full diff: https://github.com/llvm/llvm-project/pull/102299.diff


8 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp (+3) 
- (modified) clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt (+1) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp (+45) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.h (+33) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+5) 
- (added) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/public-enable-shared-from-this.rst
 (+26) 
- (modified) clang-tools-extra/docs/clang-tidy/checks/list.rst (+1) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/public-enable-shared-from-this.cpp
 (+45) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d1..f12f0cd1c47da 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -53,6 +53,7 @@
 #include "ParentVirtualCallCheck.h"
 #include "PointerArithmeticOnPolymorphicObjectCheck.h"
 #include "PosixReturnCheck.h"
+#include "PublicEnableSharedFromThisCheck.h"
 #include "RedundantBranchConditionCheck.h"
 #include "ReservedIdentifierCheck.h"
 #include "ReturnConstRefFromParameterCheck.h"
@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-public-enable-shared-from-this");
 CheckFactories.registerCheck(
 "bugprone-return-const-ref-from-parameter");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac5..c9bea094241ed 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  PublicEnableSharedFromThisCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SuspiciousStringviewDataUsageCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp
new file mode 100644
index 0..dab3e0ac596fe
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp
@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");
+  diag(EnableSharedClassDecl->getLocation(), "class %0 is not 
public even though it's derived from std::enable_shared_from_this", 
DiagnosticIDs::Warning)
+  << EnableSharedClassDecl->getNameAsString()
+  <<

[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: None (MichelleCDjunaidi)


Changes

This checks that classes/structs inheriting from 
``std::enable_shared_from_this`` derive it with the ``public`` access 
specifier, so it prevents crashes due to ``std::make_shared`` and 
``shared_from_this()`` getting called on a non-public class/struct. 

---
Full diff: https://github.com/llvm/llvm-project/pull/102299.diff


8 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp (+3) 
- (modified) clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt (+1) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp (+45) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.h (+33) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+5) 
- (added) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/public-enable-shared-from-this.rst
 (+26) 
- (modified) clang-tools-extra/docs/clang-tidy/checks/list.rst (+1) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/public-enable-shared-from-this.cpp
 (+45) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d1..f12f0cd1c47da 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -53,6 +53,7 @@
 #include "ParentVirtualCallCheck.h"
 #include "PointerArithmeticOnPolymorphicObjectCheck.h"
 #include "PosixReturnCheck.h"
+#include "PublicEnableSharedFromThisCheck.h"
 #include "RedundantBranchConditionCheck.h"
 #include "ReservedIdentifierCheck.h"
 #include "ReturnConstRefFromParameterCheck.h"
@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-public-enable-shared-from-this");
 CheckFactories.registerCheck(
 "bugprone-return-const-ref-from-parameter");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac5..c9bea094241ed 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  PublicEnableSharedFromThisCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SuspiciousStringviewDataUsageCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp
new file mode 100644
index 0..dab3e0ac596fe
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/PublicEnableSharedFromThisCheck.cpp
@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");
+  diag(EnableSharedClassDecl->getLocation(), "class %0 is not 
public even though it's derived from std::enable_shared_from_this", 
DiagnosticIDs::Warning)
+  << EnableSharedClassDecl->getNameAsString()
+  << Hint;

[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)

2024-08-07 Thread Timm Baeder via cfe-commits

tbaederr wrote:

@vikramRH Do you need someone else to merge this for you?

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


[clang] [clang-format] Fix a bug in annotating CastRParen (PR #102261)

2024-08-07 Thread Emilia Kond via cfe-commits

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


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


[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)

2024-08-07 Thread Vikram Hegde via cfe-commits

vikramRH wrote:

### Merge activity

* **Aug 7, 6:38 AM EDT**: @vikramRH started a stack merge that includes this 
pull request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/101126).


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


[clang] 7753429 - [clang][ExprConst] allow single element access of vector object to be constant expression (#101126)

2024-08-07 Thread via cfe-commits

Author: Vikram Hegde
Date: 2024-08-07T16:11:08+05:30
New Revision: 77534291fcbd2c784c54e39a60895e4f60f19742

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

LOG: [clang][ExprConst] allow single element access of vector object to be 
constant expression (#101126)

This is a slightly updated version of 
https://github.com/llvm/llvm-project/pull/72607,

originally authored by @yuanfang-chen

Added: 
clang/test/SemaCXX/constexpr-vectors-access-elements.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/Interp/State.h
clang/test/AST/Interp/arrays.cpp
clang/test/AST/Interp/builtin-functions.cpp
clang/test/AST/Interp/vectors.cpp
clang/test/CodeGenCXX/temporaries.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 829a759ca4a0be..978b4ac8ea2e37 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -75,6 +75,9 @@ sections with improvements to Clang's support for those 
languages.
 
 C++ Language Changes
 
+- Allow single element access of GCC vector/ext_vector_type object to be 
+  constant expression. Supports the `V.xyzw` syntax and other tidbits 
+  as seen in OpenCL. Selecting multiple elements is left as a future work.
 
 C++17 Feature Support
 ^

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d4b9095c7509b3..4d2d05307a6de9 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -222,6 +222,11 @@ namespace {
 ArraySize = 2;
 MostDerivedLength = I + 1;
 IsArray = true;
+  } else if (const auto *VT = Type->getAs()) {
+Type = VT->getElementType();
+ArraySize = VT->getNumElements();
+MostDerivedLength = I + 1;
+IsArray = true;
   } else if (const FieldDecl *FD = getAsField(Path[I])) {
 Type = FD->getType();
 ArraySize = 0;
@@ -268,7 +273,6 @@ namespace {
 /// If the current array is an unsized array, the value of this is
 /// undefined.
 uint64_t MostDerivedArraySize;
-
 /// The type of the most derived object referred to by this address.
 QualType MostDerivedType;
 
@@ -442,6 +446,16 @@ namespace {
   MostDerivedArraySize = 2;
   MostDerivedPathLength = Entries.size();
 }
+
+void addVectorElementUnchecked(QualType EltTy, uint64_t Size,
+   uint64_t Idx) {
+  Entries.push_back(PathEntry::ArrayIndex(Idx));
+  MostDerivedType = EltTy;
+  MostDerivedPathLength = Entries.size();
+  MostDerivedArraySize = 0;
+  MostDerivedIsArrayElement = false;
+}
+
 void diagnoseUnsizedArrayPointerArithmetic(EvalInfo &Info, const Expr *E);
 void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E,
const APSInt &N);
@@ -1737,6 +1751,11 @@ namespace {
   if (checkSubobject(Info, E, Imag ? CSK_Imag : CSK_Real))
 Designator.addComplexUnchecked(EltTy, Imag);
 }
+void addVectorElement(EvalInfo &Info, const Expr *E, QualType EltTy,
+  uint64_t Size, uint64_t Idx) {
+  if (checkSubobject(Info, E, CSK_VectorElement))
+Designator.addVectorElementUnchecked(EltTy, Size, Idx);
+}
 void clearIsNullPointer() {
   IsNullPtr = false;
 }
@@ -3310,6 +3329,19 @@ static bool HandleLValueComplexElement(EvalInfo &Info, 
const Expr *E,
   return true;
 }
 
+static bool HandleLValueVectorElement(EvalInfo &Info, const Expr *E,
+  LValue &LVal, QualType EltTy,
+  uint64_t Size, uint64_t Idx) {
+  if (Idx) {
+CharUnits SizeOfElement;
+if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfElement))
+  return false;
+LVal.Offset += SizeOfElement * Idx;
+  }
+  LVal.addVectorElement(Info, E, EltTy, Size, Idx);
+  return true;
+}
+
 /// Try to evaluate the initializer for a variable declaration.
 ///
 /// \param Info   Information about the ongoing evaluation.
@@ -3855,6 +3887,27 @@ findSubobject(EvalInfo &Info, const Expr *E, const 
CompleteObject &Obj,
 return handler.found(Index ? O->getComplexFloatImag()
: O->getComplexFloatReal(), ObjType);
   }
+} else if (const auto *VT = ObjType->getAs()) {
+  uint64_t Index = Sub.Entries[I].getAsArrayIndex();
+  unsigned NumElements = VT->getNumElements();
+  if (Index == NumElements) {
+if (Info.getLangOpts().CPlusPlus11)
+  Info.FFDiag(E, diag::note_constexpr_access_past_end)
+  << handler.AccessKind;
+else
+  Info.FFDiag(E);
+return handler.failed();
+  }
+
+  if (

[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)

2024-08-07 Thread Vikram Hegde via cfe-commits

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


[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)

2024-08-07 Thread Vikram Hegde via cfe-commits

vikramRH wrote:

> @vikramRH Do you need someone else to merge this for you?

sorry for the delay, merged.

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


[clang] [clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) (PR #102302)

2024-08-07 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/102302

We were not doing the final Neg here.

>From 0b1a9b49382802a06fad9ac149e2f2a20539429e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 7 Aug 2024 12:25:06 +0200
Subject: [PATCH] [clang][Interp] Fix BooleanToSignedIntegral casts for
 IntAP(S)

We were not doing the final Neg here.
---
 clang/lib/AST/Interp/Compiler.cpp | 16 +++-
 clang/test/AST/Interp/vectors.cpp | 11 +++
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 02cbe38f5fb1fa..acda6f29fb0f88 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -480,19 +480,25 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
   }
 }
 
+auto maybeNegate = [&]() -> bool {
+  if (CE->getCastKind() == CK_BooleanToSignedIntegral)
+return this->emitNeg(*ToT, CE);
+  return true;
+};
+
 if (ToT == PT_IntAP)
-  return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+  return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+ maybeNegate();
 if (ToT == PT_IntAPS)
-  return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+  return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+ maybeNegate();
 
 if (FromT == ToT)
   return true;
 if (!this->emitCast(*FromT, *ToT, CE))
   return false;
 
-if (CE->getCastKind() == CK_BooleanToSignedIntegral)
-  return this->emitNeg(*ToT, CE);
-return true;
+return maybeNegate();
   }
 
   case CK_PointerToBoolean:
diff --git a/clang/test/AST/Interp/vectors.cpp 
b/clang/test/AST/Interp/vectors.cpp
index 6991a348b07a94..328f38bf21effa 100644
--- a/clang/test/AST/Interp/vectors.cpp
+++ b/clang/test/AST/Interp/vectors.cpp
@@ -91,3 +91,14 @@ namespace Temporaries {
   };
   int &&s = S().w[1];
 }
+
+#ifdef __SIZEOF_INT128__
+namespace bigint {
+  typedef __attribute__((__ext_vector_type__(4))) __int128 bigint4;
+  constexpr bigint4 A = (bigint4)true;
+  static_assert(A[0] == -1, "");
+  static_assert(A[1] == -1, "");
+  static_assert(A[2] == -1, "");
+  static_assert(A[3] == -1, "");
+}
+#endif

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


[clang] [clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) (PR #102302)

2024-08-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

We were not doing the final Neg here.

---
Full diff: https://github.com/llvm/llvm-project/pull/102302.diff


2 Files Affected:

- (modified) clang/lib/AST/Interp/Compiler.cpp (+11-5) 
- (modified) clang/test/AST/Interp/vectors.cpp (+11) 


``diff
diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 02cbe38f5fb1fa..acda6f29fb0f88 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -480,19 +480,25 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
   }
 }
 
+auto maybeNegate = [&]() -> bool {
+  if (CE->getCastKind() == CK_BooleanToSignedIntegral)
+return this->emitNeg(*ToT, CE);
+  return true;
+};
+
 if (ToT == PT_IntAP)
-  return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+  return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+ maybeNegate();
 if (ToT == PT_IntAPS)
-  return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+  return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+ maybeNegate();
 
 if (FromT == ToT)
   return true;
 if (!this->emitCast(*FromT, *ToT, CE))
   return false;
 
-if (CE->getCastKind() == CK_BooleanToSignedIntegral)
-  return this->emitNeg(*ToT, CE);
-return true;
+return maybeNegate();
   }
 
   case CK_PointerToBoolean:
diff --git a/clang/test/AST/Interp/vectors.cpp 
b/clang/test/AST/Interp/vectors.cpp
index 6991a348b07a94..328f38bf21effa 100644
--- a/clang/test/AST/Interp/vectors.cpp
+++ b/clang/test/AST/Interp/vectors.cpp
@@ -91,3 +91,14 @@ namespace Temporaries {
   };
   int &&s = S().w[1];
 }
+
+#ifdef __SIZEOF_INT128__
+namespace bigint {
+  typedef __attribute__((__ext_vector_type__(4))) __int128 bigint4;
+  constexpr bigint4 A = (bigint4)true;
+  static_assert(A[0] == -1, "");
+  static_assert(A[1] == -1, "");
+  static_assert(A[2] == -1, "");
+  static_assert(A[3] == -1, "");
+}
+#endif

``




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


[libunwind] [libunwind] Add GCS support for AArch64 (PR #99335)

2024-08-07 Thread John Brawn via cfe-commits


@@ -680,7 +680,7 @@ 
DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto)
   ldrx16, [x0, #0x0F8]
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   movsp,x16 // restore sp
-  retx30// jump to pc

john-brawn-arm wrote:

Yes you're right, and actually the way I've adjusted __unw_phase2_resume also 
means we need to change the BTI instruction in 
__libunwind_Registers_arm64_jumpto to BTI JC. I'll fix this.

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


[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)

2024-08-07 Thread Vikram Hegde via cfe-commits

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


[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)

2024-08-07 Thread Vikram Hegde via cfe-commits

vikramRH wrote:

closing this, since its handled via 
https://github.com/llvm/llvm-project/pull/101126

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


[clang] [clang-format] Fix a bug in annotating CastRParen (PR #102261)

2024-08-07 Thread Pierre Jolivet via cfe-commits

prj- wrote:

I'm sorry I'm not familiar with LLVM release cycle, but is it too late for this 
to make it into the `release/19.x` branch?

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


[clang] [clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) (PR #102302)

2024-08-07 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/102302

>From 6de1136c9806d3b545b586d91ee56a934cff1669 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 7 Aug 2024 12:25:06 +0200
Subject: [PATCH] [clang][Interp] Fix BooleanToSignedIntegral casts for
 IntAP(S)

We were not doing the final Neg here.
---
 clang/lib/AST/Interp/Compiler.cpp | 16 +++-
 clang/test/AST/Interp/vectors.cpp | 11 +++
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 95f4fe9bd0bec..11fe2acf2d7b9 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -480,19 +480,25 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
   }
 }
 
+auto maybeNegate = [&]() -> bool {
+  if (CE->getCastKind() == CK_BooleanToSignedIntegral)
+return this->emitNeg(*ToT, CE);
+  return true;
+};
+
 if (ToT == PT_IntAP)
-  return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+  return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+ maybeNegate();
 if (ToT == PT_IntAPS)
-  return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+  return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+ maybeNegate();
 
 if (FromT == ToT)
   return true;
 if (!this->emitCast(*FromT, *ToT, CE))
   return false;
 
-if (CE->getCastKind() == CK_BooleanToSignedIntegral)
-  return this->emitNeg(*ToT, CE);
-return true;
+return maybeNegate();
   }
 
   case CK_PointerToBoolean:
diff --git a/clang/test/AST/Interp/vectors.cpp 
b/clang/test/AST/Interp/vectors.cpp
index b25d4d8a2df9a..cf10d9416e956 100644
--- a/clang/test/AST/Interp/vectors.cpp
+++ b/clang/test/AST/Interp/vectors.cpp
@@ -90,3 +90,14 @@ namespace Temporaries {
   };
   int &&s = S().w[1];
 }
+
+#ifdef __SIZEOF_INT128__
+namespace bigint {
+  typedef __attribute__((__ext_vector_type__(4))) __int128 bigint4;
+  constexpr bigint4 A = (bigint4)true;
+  static_assert(A[0] == -1, "");
+  static_assert(A[1] == -1, "");
+  static_assert(A[2] == -1, "");
+  static_assert(A[3] == -1, "");
+}
+#endif

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


[clang] [clang] Fix crash when #embed used in a compound literal (PR #102304)

2024-08-07 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon created 
https://github.com/llvm/llvm-project/pull/102304

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

>From ebeb9264e8a4e6d57a4573376248191f64ad99e7 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Wed, 7 Aug 2024 04:04:09 -0700
Subject: [PATCH] [clang] Fix crash when #embed used in a compound literal

Fixes https://github.com/llvm/llvm-project/issues/102248
---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/lib/Sema/SemaInit.cpp   | 4 ++--
 clang/test/Preprocessor/embed_codegen.cpp | 6 ++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 829a759ca4a0be..946d09b0215e5b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -167,6 +167,7 @@ Bug Fixes in This Version
   be used in C++.
 - Fixed a failed assertion when checking required literal types in C context. 
(#GH101304).
 - Fixed a crash when trying to transform a dependent address space type. Fixes 
#GH101685.
+- Fixed crash when #embed is used in a compound literal Fixes #GH102248.
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 90fd6df782f095..abd4401e029817 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -515,8 +515,8 @@ class InitListChecker {
 uint64_t ElsCount = 1;
 // Otherwise try to fill whole array with embed data.
 if (Entity.getKind() == InitializedEntity::EK_ArrayElement) {
-  ValueDecl *ArrDecl = Entity.getParent()->getDecl();
-  auto *AType = SemaRef.Context.getAsArrayType(ArrDecl->getType());
+  auto *AType =
+  SemaRef.Context.getAsArrayType(Entity.getParent()->getType());
   assert(AType && "expected array type when initializing array");
   ElsCount = Embed->getDataElementCount();
   if (const auto *CAType = dyn_cast(AType))
diff --git a/clang/test/Preprocessor/embed_codegen.cpp 
b/clang/test/Preprocessor/embed_codegen.cpp
index 5baab9b59a9c16..d9624306dc828d 100644
--- a/clang/test/Preprocessor/embed_codegen.cpp
+++ b/clang/test/Preprocessor/embed_codegen.cpp
@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 %s -triple x86_64 --embed-dir=%S/Inputs -emit-llvm -o - | 
FileCheck %s
 
+// CHECK: @.compoundliteral = internal global [2 x i8] c"jk"
 // CHECK: @__const._Z3fooi.ca = private unnamed_addr constant [3 x i32] [i32 
0, i32 106, i32 107], align 4
 // CHECK: @__const._Z3fooi.sc = private unnamed_addr constant %struct.S1 { i32 
106, i32 107, i32 0 }, align 4
 // CHECK: @__const._Z3fooi.t = private unnamed_addr constant [3 x %struct.T] 
[%struct.T { [2 x i32] [i32 48, i32 49], %struct.S1 { i32 50, i32 51, i32 52 } 
}, %struct.T { [2 x i32] [i32 53, i32 54], %struct.S1 { i32 55, i32 56, i32 57 
} }, %struct.T { [2 x i32] [i32 10, i32 0], %struct.S1 zeroinitializer }], 
align 16
 // CHECK: @__const._Z3fooi.W = private unnamed_addr constant %struct.Wrapper { 
i32 48, %struct.HasCharArray { [10 x i8] c"123456789\0A" } }, align 4
+
+char *p = (char[]){
+#embed "jk.txt"
+};
+
 void foo(int a) {
 // CHECK: %a.addr = alloca i32, align 4
 // CHECK: store i32 %a, ptr %a.addr, align 4

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


[clang] [clang] Fix crash when #embed used in a compound literal (PR #102304)

2024-08-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mariya Podchishchaeva (Fznamznon)


Changes

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

---
Full diff: https://github.com/llvm/llvm-project/pull/102304.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaInit.cpp (+2-2) 
- (modified) clang/test/Preprocessor/embed_codegen.cpp (+6) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 829a759ca4a0b..946d09b0215e5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -167,6 +167,7 @@ Bug Fixes in This Version
   be used in C++.
 - Fixed a failed assertion when checking required literal types in C context. 
(#GH101304).
 - Fixed a crash when trying to transform a dependent address space type. Fixes 
#GH101685.
+- Fixed crash when #embed is used in a compound literal Fixes #GH102248.
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 90fd6df782f09..abd4401e02981 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -515,8 +515,8 @@ class InitListChecker {
 uint64_t ElsCount = 1;
 // Otherwise try to fill whole array with embed data.
 if (Entity.getKind() == InitializedEntity::EK_ArrayElement) {
-  ValueDecl *ArrDecl = Entity.getParent()->getDecl();
-  auto *AType = SemaRef.Context.getAsArrayType(ArrDecl->getType());
+  auto *AType =
+  SemaRef.Context.getAsArrayType(Entity.getParent()->getType());
   assert(AType && "expected array type when initializing array");
   ElsCount = Embed->getDataElementCount();
   if (const auto *CAType = dyn_cast(AType))
diff --git a/clang/test/Preprocessor/embed_codegen.cpp 
b/clang/test/Preprocessor/embed_codegen.cpp
index 5baab9b59a9c1..d9624306dc828 100644
--- a/clang/test/Preprocessor/embed_codegen.cpp
+++ b/clang/test/Preprocessor/embed_codegen.cpp
@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 %s -triple x86_64 --embed-dir=%S/Inputs -emit-llvm -o - | 
FileCheck %s
 
+// CHECK: @.compoundliteral = internal global [2 x i8] c"jk"
 // CHECK: @__const._Z3fooi.ca = private unnamed_addr constant [3 x i32] [i32 
0, i32 106, i32 107], align 4
 // CHECK: @__const._Z3fooi.sc = private unnamed_addr constant %struct.S1 { i32 
106, i32 107, i32 0 }, align 4
 // CHECK: @__const._Z3fooi.t = private unnamed_addr constant [3 x %struct.T] 
[%struct.T { [2 x i32] [i32 48, i32 49], %struct.S1 { i32 50, i32 51, i32 52 } 
}, %struct.T { [2 x i32] [i32 53, i32 54], %struct.S1 { i32 55, i32 56, i32 57 
} }, %struct.T { [2 x i32] [i32 10, i32 0], %struct.S1 zeroinitializer }], 
align 16
 // CHECK: @__const._Z3fooi.W = private unnamed_addr constant %struct.Wrapper { 
i32 48, %struct.HasCharArray { [10 x i8] c"123456789\0A" } }, align 4
+
+char *p = (char[]){
+#embed "jk.txt"
+};
+
 void foo(int a) {
 // CHECK: %a.addr = alloca i32, align 4
 // CHECK: store i32 %a, ptr %a.addr, align 4

``




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


[clang] [clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (PR #98138)

2024-08-07 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

ping.

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


[clang] [clang] Fix crash when #embed used in a compound literal (PR #102304)

2024-08-07 Thread via cfe-commits

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


[clang] [clang] Fix crash when #embed used in a compound literal (PR #102304)

2024-08-07 Thread via cfe-commits

https://github.com/cor3ntin commented:

LGTM.
I think it is reasonable to backport that (in which case we don't need the 
changelog entry)

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


[clang] [clang] Fix crash when #embed used in a compound literal (PR #102304)

2024-08-07 Thread via cfe-commits


@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 %s -triple x86_64 --embed-dir=%S/Inputs -emit-llvm -o - | 
FileCheck %s
 
+// CHECK: @.compoundliteral = internal global [2 x i8] c"jk"
 // CHECK: @__const._Z3fooi.ca = private unnamed_addr constant [3 x i32] [i32 
0, i32 106, i32 107], align 4
 // CHECK: @__const._Z3fooi.sc = private unnamed_addr constant %struct.S1 { i32 
106, i32 107, i32 0 }, align 4
 // CHECK: @__const._Z3fooi.t = private unnamed_addr constant [3 x %struct.T] 
[%struct.T { [2 x i32] [i32 48, i32 49], %struct.S1 { i32 50, i32 51, i32 52 } 
}, %struct.T { [2 x i32] [i32 53, i32 54], %struct.S1 { i32 55, i32 56, i32 57 
} }, %struct.T { [2 x i32] [i32 10, i32 0], %struct.S1 zeroinitializer }], 
align 16
 // CHECK: @__const._Z3fooi.W = private unnamed_addr constant %struct.Wrapper { 
i32 48, %struct.HasCharArray { [10 x i8] c"123456789\0A" } }, align 4
+
+char *p = (char[]){
+#embed "jk.txt"
+};
+

cor3ntin wrote:

Can you add tests for `char[N]`, `int[]` ?

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-public-enable-shared-from-this");

PiotrZSL wrote:

name should be more a "non-public", as check should tell whats wrong.
i would call this check bugprone-incorrect-enable-shared-from-this, and then 
you could also check other constructions in future like:
```
class Bad2Example : enable_shared_from_this {};
```

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

I'm fine with idea behind this check. Just few fixes are needed.

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(

PiotrZSL wrote:

`hasAnyBase(cxxBaseSpecifier(...).bind("base"))`, check if this works, maybe 
with that you could avoid having loop in a check method

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s bugprone-public-enable-shared-from-this %t -- --
+
+namespace std {
+
+template  class enable_shared_from_this {};
+

PiotrZSL wrote:

std namespace should end here

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");

PiotrZSL wrote:

what if it already got explicit "private", then it will end up with "private 
public" and thats invalid

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(

PiotrZSL wrote:

consider excluding system headers, to speed things up

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");
+  diag(EnableSharedClassDecl->getLocation(), "class %0 is not 
public even though it's derived from std::enable_shared_from_this", 
DiagnosticIDs::Warning)
+  << EnableSharedClassDecl->getNameAsString()

PiotrZSL wrote:

no need for getNameAsString

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");
+  diag(EnableSharedClassDecl->getLocation(), "class %0 is not 
public even though it's derived from std::enable_shared_from_this", 
DiagnosticIDs::Warning)

PiotrZSL wrote:

this warning message doesn't make sense. there is no such thing like 
public/private class. This public/private inheritance.

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,33 @@
+//===--- PublicEnableSharedFromThisCheck.h - clang-tidy -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PUBLICENABLESHAREDFROMTHISCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PUBLICENABLESHAREDFROMTHISCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::bugprone {
+
+/// Checks if a class deriving from enable_shared_from_this has public access 
specifiers, because otherwise the program will crash when shared_from_this is 
called.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/bugprone/public-enable-shared-from-this.html
+class PublicEnableSharedFromThisCheck : public ClangTidyCheck {
+public:
+  PublicEnableSharedFromThisCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus;

PiotrZSL wrote:

CPlusPlus11

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s bugprone-public-enable-shared-from-this %t -- --
+
+namespace std {
+
+template  class enable_shared_from_this {};
+
+class BadExample : enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class BadExample is not public 
even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public enable_shared_from_this
+
+class Bad2Example : std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class Bad2Example is not 
public even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+

PiotrZSL wrote:

add test:
class Bad3Example : private std::enable_shared_from_this {};

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s bugprone-public-enable-shared-from-this %t -- --
+
+namespace std {
+
+template  class enable_shared_from_this {};
+
+class BadExample : enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class BadExample is not public 
even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public enable_shared_from_this
+
+class Bad2Example : std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class Bad2Example is not 
public even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+
+class GoodExample : public enable_shared_from_this {
+};
+
+struct BaseClass {
+
+void print() {
+(void) State;
+(void) Requester;
+}
+bool State;
+int Requester;
+};
+
+class InheritPrivateBaseClass : BaseClass {
+public:
+void additionalFunction() {
+(void) ID;
+}
+private: 
+int ID;
+};
+
+class InheritPublicBaseClass : public BaseClass {
+public:
+void additionalFunction() {
+(void) ID;
+}
+private: 
+int ID;
+};

PiotrZSL wrote:

Those classes does not add anything, so maybe remove them, or you missing 
something here

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,26 @@
+.. title:: clang-tidy - bugprone-public-enable-shared-from-this
+
+bugprone-public-enable-shared-from-this
+===
+
+Checks that classes/structs inheriting from ``std::enable_shared_from_this`` 
derive it with the ``public`` access specifier. If not, then issue a FixItHint 
that can be applied.
+
+Consider the following code:
+.. code-block:: c++
+#include 
+
+class BadExample : std::enable_shared_from_this {
+// warning: class BadExample is not public even though it's derived 
from std::enable_shared_from_this [bugprone-public-enable-shared-from-this]
+// will insert the public keyword if -fix is applied 
+public:
+BadExample* foo() { return shared_from_this().get(); }
+void bar() { return; }
+};
+
+void using_not_public() {
+auto bad_example = std::make_shared();
+auto* b_ex = bad_example->foo();
+b_ex->bar();
+}
+
+When ``using_not_public()`` is called, this code will crash.

PiotrZSL wrote:

no it won't crash, it will thrown `std::bad_weak_ptr`, if application didin't 
implement proper exception handling then it would crash.

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -98,6 +98,11 @@ Improvements to clang-tidy
 New checks
 ^^
 
+- New :doc:`bugprone-public-enable-shared-from-this
+  ` check.
+
+  Checks if a class deriving from enable_shared_from_this has public access 
specifiers, because otherwise the program will crash when shared_from_this is 
called.

PiotrZSL wrote:

again, wrong. "Check if class publicly derive from std::enable_shared_from_this 
..."
And wrap on 80 column.

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


[clang] [llvm] [mlir] [NFC][IWYU] Update includes in Support lib with IWYU. (PR #102306)

2024-08-07 Thread via cfe-commits

github-actions[bot] wrote:

⚠️ We detected that you are using a GitHub private e-mail address to contribute 
to the repo. Please turn off [Keep my email addresses 
private](https://github.com/settings/emails) setting in your account. See 
[LLVM 
Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
 for more information.

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


[clang] [llvm] [mlir] [NFC][IWYU] Update includes in Support lib with IWYU. (PR #102306)

2024-08-07 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 4745bb3e7db6d9cf5588171a433f534e5b488c70 
7554c5d6fb2bc442fe3d2e00826ea5a0e34e432b --extensions h,inc,cpp -- 
clang/lib/Driver/ToolChains/SPIRV.cpp llvm/include/llvm/ADT/APFixedPoint.h 
llvm/include/llvm/ADT/APFloat.h llvm/include/llvm/ADT/APInt.h 
llvm/include/llvm/ADT/APSInt.h llvm/include/llvm/ADT/DynamicAPInt.h 
llvm/include/llvm/ADT/FloatingPointMode.h llvm/include/llvm/ADT/FoldingSet.h 
llvm/include/llvm/ADT/IntEqClasses.h llvm/include/llvm/ADT/IntervalMap.h 
llvm/include/llvm/ADT/SlowDynamicAPInt.h llvm/include/llvm/ADT/SmallPtrSet.h 
llvm/include/llvm/ADT/SmallVector.h llvm/include/llvm/ADT/Statistic.h 
llvm/include/llvm/ADT/StringExtras.h llvm/include/llvm/ADT/StringMap.h 
llvm/include/llvm/ADT/StringRef.h llvm/include/llvm/ADT/Twine.h 
llvm/include/llvm/Support/ARMAttributeParser.h 
llvm/include/llvm/Support/ARMWinEH.h llvm/include/llvm/Support/Atomic.h 
llvm/include/llvm/Support/BalancedPartitioning.h 
llvm/include/llvm/Support/Base64.h 
llvm/include/llvm/Support/BinaryStreamError.h 
llvm/include/llvm/Support/BinaryStreamReader.h 
llvm/include/llvm/Support/BinaryStreamRef.h 
llvm/include/llvm/Support/BinaryStreamWriter.h 
llvm/include/llvm/Support/BranchProbability.h llvm/include/llvm/Support/CRC.h 
llvm/include/llvm/Support/CSKYAttributeParser.h 
llvm/include/llvm/Support/CachePruning.h llvm/include/llvm/Support/Caching.h 
llvm/include/llvm/Support/Chrono.h llvm/include/llvm/Support/CodeGenCoverage.h 
llvm/include/llvm/Support/CommandLine.h llvm/include/llvm/Support/Compression.h 
llvm/include/llvm/Support/ConvertEBCDIC.h llvm/include/llvm/Support/DJB.h 
llvm/include/llvm/Support/DataExtractor.h 
llvm/include/llvm/Support/DebugCounter.h 
llvm/include/llvm/Support/ELFAttributeParser.h 
llvm/include/llvm/Support/Error.h 
llvm/include/llvm/Support/ExponentialBackoff.h 
llvm/include/llvm/Support/FileCollector.h 
llvm/include/llvm/Support/FileOutputBuffer.h 
llvm/include/llvm/Support/FileUtilities.h 
llvm/include/llvm/Support/FormatVariadic.h 
llvm/include/llvm/Support/FormatVariadicDetails.h 
llvm/include/llvm/Support/FormattedStream.h 
llvm/include/llvm/Support/GlobPattern.h llvm/include/llvm/Support/GraphWriter.h 
llvm/include/llvm/Support/HexagonAttributeParser.h 
llvm/include/llvm/Support/InstructionCost.h llvm/include/llvm/Support/JSON.h 
llvm/include/llvm/Support/KnownBits.h llvm/include/llvm/Support/LEB128.h 
llvm/include/llvm/Support/LineIterator.h 
llvm/include/llvm/Support/LockFileManager.h llvm/include/llvm/Support/MD5.h 
llvm/include/llvm/Support/MSP430AttributeParser.h 
llvm/include/llvm/Support/MathExtras.h llvm/include/llvm/Support/Memory.h 
llvm/include/llvm/Support/MemoryBuffer.h 
llvm/include/llvm/Support/MemoryBufferRef.h 
llvm/include/llvm/Support/NativeFormatting.h 
llvm/include/llvm/Support/OptimizedStructLayout.h 
llvm/include/llvm/Support/PGOOptions.h llvm/include/llvm/Support/Parallel.h 
llvm/include/llvm/Support/Path.h llvm/include/llvm/Support/PrettyStackTrace.h 
llvm/include/llvm/Support/Process.h llvm/include/llvm/Support/Program.h 
llvm/include/llvm/Support/RISCVAttributeParser.h 
llvm/include/llvm/Support/RandomNumberGenerator.h 
llvm/include/llvm/Support/ScaledNumber.h 
llvm/include/llvm/Support/ScopedPrinter.h llvm/include/llvm/Support/SourceMgr.h 
llvm/include/llvm/Support/SpecialCaseList.h 
llvm/include/llvm/Support/StringSaver.h llvm/include/llvm/Support/SuffixTree.h 
llvm/include/llvm/Support/TarWriter.h llvm/include/llvm/Support/ThreadPool.h 
llvm/include/llvm/Support/Threading.h llvm/include/llvm/Support/TimeProfiler.h 
llvm/include/llvm/Support/Timer.h llvm/include/llvm/Support/ToolOutputFile.h 
llvm/include/llvm/Support/TypeSize.h llvm/include/llvm/Support/Unicode.h 
llvm/include/llvm/Support/VersionTuple.h 
llvm/include/llvm/Support/VirtualFileSystem.h 
llvm/include/llvm/Support/Watchdog.h llvm/include/llvm/Support/WithColor.h 
llvm/include/llvm/Support/YAMLParser.h llvm/include/llvm/Support/YAMLTraits.h 
llvm/include/llvm/Support/circular_raw_ostream.h 
llvm/include/llvm/Support/raw_os_ostream.h 
llvm/include/llvm/Support/raw_ostream.h 
llvm/include/llvm/Support/raw_socket_stream.h 
llvm/include/llvm/Support/xxhash.h 
llvm/lib/DebugInfo/DWARF/DWARFLocationExpression.cpp 
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp llvm/lib/FileCheck/FileCheck.cpp 
llvm/lib/Support/AMDGPUMetadata.cpp llvm/lib/Support/APFixedPoint.cpp 
llvm/lib/Support/APFloat.cpp llvm/lib/Support/APInt.cpp 
llvm/lib/Support/APSInt.cpp llvm/lib/Support/ARMAttributeParser.cpp 
llvm/lib/Support/ARMBuildAttrs.cpp llvm/lib/Support/BalancedPartitioning.cpp 
llvm/lib/Support/Base64.cpp llvm/lib/Support/BinaryStreamReader.cpp 
llvm/lib/Support/BinaryStreamRef.cpp llvm/lib/Support/BinaryStreamWriter.cpp 
llvm/lib/Support/BranchProbability.cpp llvm/lib/Support/BuryPointer.cpp 
llvm/lib/Suppor

[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-public-enable-shared-from-this");

PiotrZSL wrote:

Or just call it bugprone-non-public-enable-shared-from-this

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


[clang] [clang] Fix crash when #embed used in a compound literal (PR #102304)

2024-08-07 Thread Aaron Ballman via cfe-commits

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


[clang] [clang] Fix crash when #embed used in a compound literal (PR #102304)

2024-08-07 Thread Aaron Ballman via cfe-commits

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

Changes LGTM as far as they go, but some additional test coverage is requested.

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


[clang] [clang] Fix crash when #embed used in a compound literal (PR #102304)

2024-08-07 Thread Aaron Ballman via cfe-commits


@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 %s -triple x86_64 --embed-dir=%S/Inputs -emit-llvm -o - | 
FileCheck %s
 
+// CHECK: @.compoundliteral = internal global [2 x i8] c"jk"
 // CHECK: @__const._Z3fooi.ca = private unnamed_addr constant [3 x i32] [i32 
0, i32 106, i32 107], align 4
 // CHECK: @__const._Z3fooi.sc = private unnamed_addr constant %struct.S1 { i32 
106, i32 107, i32 0 }, align 4
 // CHECK: @__const._Z3fooi.t = private unnamed_addr constant [3 x %struct.T] 
[%struct.T { [2 x i32] [i32 48, i32 49], %struct.S1 { i32 50, i32 51, i32 52 } 
}, %struct.T { [2 x i32] [i32 53, i32 54], %struct.S1 { i32 55, i32 56, i32 57 
} }, %struct.T { [2 x i32] [i32 10, i32 0], %struct.S1 zeroinitializer }], 
align 16
 // CHECK: @__const._Z3fooi.W = private unnamed_addr constant %struct.Wrapper { 
i32 48, %struct.HasCharArray { [10 x i8] c"123456789\0A" } }, align 4
+
+char *p = (char[]){
+#embed "jk.txt"
+};
+

AaronBallman wrote:

Also, because compound literals in C++ are different from compound literals in 
C, we should have a C-specific test as well. And that test should probably be 
in `Sema` because this is fixing an issue in `SemaInit.cpp`.

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits


@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s bugprone-public-enable-shared-from-this %t -- --
+
+namespace std {
+
+template  class enable_shared_from_this {};
+
+class BadExample : enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class BadExample is not public 
even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public enable_shared_from_this
+
+class Bad2Example : std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class Bad2Example is not 
public even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+
+class GoodExample : public enable_shared_from_this {
+};
+
+struct BaseClass {
+
+void print() {
+(void) State;
+(void) Requester;
+}
+bool State;
+int Requester;
+};
+
+class InheritPrivateBaseClass : BaseClass {
+public:
+void additionalFunction() {
+(void) ID;
+}
+private: 
+int ID;
+};
+
+class InheritPublicBaseClass : public BaseClass {
+public:
+void additionalFunction() {
+(void) ID;
+}
+private: 
+int ID;
+};

MichelleCDjunaidi wrote:

Ah, so I don't need to demonstrate that it doesn't match things with public 
inheritance? Understood, will do

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits


@@ -0,0 +1,26 @@
+.. title:: clang-tidy - bugprone-public-enable-shared-from-this
+
+bugprone-public-enable-shared-from-this
+===
+
+Checks that classes/structs inheriting from ``std::enable_shared_from_this`` 
derive it with the ``public`` access specifier. If not, then issue a FixItHint 
that can be applied.
+
+Consider the following code:
+.. code-block:: c++
+#include 
+
+class BadExample : std::enable_shared_from_this {
+// warning: class BadExample is not public even though it's derived 
from std::enable_shared_from_this [bugprone-public-enable-shared-from-this]
+// will insert the public keyword if -fix is applied 
+public:
+BadExample* foo() { return shared_from_this().get(); }
+void bar() { return; }
+};
+
+void using_not_public() {
+auto bad_example = std::make_shared();
+auto* b_ex = bad_example->foo();
+b_ex->bar();
+}
+
+When ``using_not_public()`` is called, this code will crash.

MichelleCDjunaidi wrote:

Yeah, will fix the desc

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits


@@ -98,6 +98,11 @@ Improvements to clang-tidy
 New checks
 ^^
 
+- New :doc:`bugprone-public-enable-shared-from-this
+  ` check.
+
+  Checks if a class deriving from enable_shared_from_this has public access 
specifiers, because otherwise the program will crash when shared_from_this is 
called.

MichelleCDjunaidi wrote:

Right, will run git clang format, thanks for the reminder and feedback

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");
+  diag(EnableSharedClassDecl->getLocation(), "class %0 is not 
public even though it's derived from std::enable_shared_from_this", 
DiagnosticIDs::Warning)

MichelleCDjunaidi wrote:

Thanks for correcting me, will get on it

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


[clang] f05e818 - [clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) (#102302)

2024-08-07 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-08-07T13:52:00+02:00
New Revision: f05e8186a439cf538f383dfbde68eca364a5acec

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

LOG: [clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) (#102302)

We were not doing the final Neg here.

Added: 


Modified: 
clang/lib/AST/Interp/Compiler.cpp
clang/test/AST/Interp/vectors.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 95f4fe9bd0becf..11fe2acf2d7b95 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -480,19 +480,25 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
   }
 }
 
+auto maybeNegate = [&]() -> bool {
+  if (CE->getCastKind() == CK_BooleanToSignedIntegral)
+return this->emitNeg(*ToT, CE);
+  return true;
+};
+
 if (ToT == PT_IntAP)
-  return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+  return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+ maybeNegate();
 if (ToT == PT_IntAPS)
-  return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+  return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+ maybeNegate();
 
 if (FromT == ToT)
   return true;
 if (!this->emitCast(*FromT, *ToT, CE))
   return false;
 
-if (CE->getCastKind() == CK_BooleanToSignedIntegral)
-  return this->emitNeg(*ToT, CE);
-return true;
+return maybeNegate();
   }
 
   case CK_PointerToBoolean:

diff  --git a/clang/test/AST/Interp/vectors.cpp 
b/clang/test/AST/Interp/vectors.cpp
index b25d4d8a2df9aa..cf10d9416e9567 100644
--- a/clang/test/AST/Interp/vectors.cpp
+++ b/clang/test/AST/Interp/vectors.cpp
@@ -90,3 +90,14 @@ namespace Temporaries {
   };
   int &&s = S().w[1];
 }
+
+#ifdef __SIZEOF_INT128__
+namespace bigint {
+  typedef __attribute__((__ext_vector_type__(4))) __int128 bigint4;
+  constexpr bigint4 A = (bigint4)true;
+  static_assert(A[0] == -1, "");
+  static_assert(A[1] == -1, "");
+  static_assert(A[2] == -1, "");
+  static_assert(A[3] == -1, "");
+}
+#endif



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


[clang] [clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) (PR #102302)

2024-08-07 Thread Timm Baeder via cfe-commits

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(

MichelleCDjunaidi wrote:

Oh, I didn't know that's possible in registerMatchers. Mind pointing me to a 
resource so I can figure that out? 

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(

PiotrZSL wrote:

`unless(isExpansionInSystemHeader())`

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits

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


[clang] [clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) (PR #102302)

2024-08-07 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running 
on `linaro-lldb-arm-ubuntu` while building `clang` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/18/builds/1875

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
PASS: lldb-unit :: Utility/./UtilityTests/96/243 (2751 of 2760)
PASS: lldb-unit :: Utility/./UtilityTests/97/243 (2752 of 2760)
PASS: lldb-unit :: Utility/./UtilityTests/98/243 (2753 of 2760)
PASS: lldb-unit :: Utility/./UtilityTests/99/243 (2754 of 2760)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/2/3 (2755 of 2760)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/1/3 (2756 of 2760)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/0/3 (2757 of 2760)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/1/2 (2758 of 2760)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/0/2 (2759 of 2760)
TIMEOUT: lldb-api :: 
functionalities/single-thread-step/TestSingleThreadStepTimeout.py (2760 of 2760)
 TEST 'lldb-api :: 
functionalities/single-thread-step/TestSingleThreadStepTimeout.py' FAILED 

Script:
--
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py 
-u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env 
LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch 
armv8l --build-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil 
--llvm-tools-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin 
--lldb-obj-root /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb 
--lldb-libs-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/functionalities/single-thread-step
 -p TestSingleThreadStepTimeout.py
--
Exit Code: -9
Timeout: Reached timeout of 600 seconds

Command Output (stdout):
--
lldb version 20.0.0git (https://github.com/llvm/llvm-project.git revision 
f05e8186a439cf538f383dfbde68eca364a5acec)
  clang revision f05e8186a439cf538f383dfbde68eca364a5acec
  llvm revision f05e8186a439cf538f383dfbde68eca364a5acec

--



Timed Out Tests (1):
  lldb-api :: functionalities/single-thread-step/TestSingleThreadStepTimeout.py


Testing Time: 828.26s

Total Discovered Tests: 3003
  Unsupported  :  515 (17.15%)
  Passed   : 2464 (82.05%)
  Expectedly Failed:   23 (0.77%)
  Timed Out:1 (0.03%)
FAILED: tools/lldb/test/CMakeFiles/check-lldb 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/test/CMakeFiles/check-lldb
 
cd /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/test && 
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/llvm-lit -vj 4 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/test
ninja: build stopped: subcommand failed.

```

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


[clang] 0c25f85 - [RISCV] Add sifive-p470 processor (#102022)

2024-08-07 Thread via cfe-commits

Author: Michael Maitland
Date: 2024-08-07T08:30:42-04:00
New Revision: 0c25f85e5b88102363c0cd55e1946053d5827e99

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

LOG: [RISCV] Add sifive-p470 processor (#102022)

This is an OOO core that has a vector unit. For more information see
https://www.sifive.com/cores/performance-p450-470.

Use the existing P400 scheduler model. This model is missing accurate
vector scheduling support, but it will be added in a follow up patch.

Other tunings can come in future patches too.

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 7a885cde76d6ae..750fb637edeb1a 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -304,6 +304,54 @@
 // MCPU-SIFIVE-P450-SAME: "-target-feature" "+zbs"
 // MCPU-SIFIVE-P450-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-p470 | FileCheck 
-check-prefix=MCPU-SIFIVE-P470 %s
+// MCPU-SIFIVE-P470: "-target-cpu" "sifive-p470"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+m"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+a"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+f"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+d"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+c"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+v"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zic64b"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zicbom"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zicbop"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zicboz"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+ziccamoa"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+ziccif"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zicclsm"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+ziccrse"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zicsr"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zifencei"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zihintntl"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zihintpause"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zihpm"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zmmul"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+za64rs"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zfhmin"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zba"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zbb"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zbs"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvbb"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvbc"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zve32f"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zve32x"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zve64d"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zve64f"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zve64x"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvkg"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvkn"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvknc"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvkned"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvkng"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvknhb"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvks"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvksc"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvksed"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvksg"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvksh"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvkt"
+// MCPU-SIFIVE-P470-SAME: "-target-abi" "lp64d"
+
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-p670 | FileCheck 
-check-prefix=MCPU-SIFIVE-P670 %s
 // MCPU-SIFIVE-P670: "-target-cpu" "sifive-p670"
 // MCPU-SIFIVE-P670-SAME: "-target-feature" "+m"

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index b87bced18cb2b4..249bea2311549f 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, 
syntacore-scr4-rv64, veyron-v1, xiangshan-nanhu{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p470, sifive-p670, sifive-s21, sifive-s51, sifive-s54, 
sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-x

[clang] [llvm] [RISCV] Add sifive-p470 processor (PR #102022)

2024-08-07 Thread Michael Maitland via cfe-commits

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


[clang] [Arm][AArch64][Clang] Respect function's branch protection attributes. (PR #101978)

2024-08-07 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss updated 
https://github.com/llvm/llvm-project/pull/101978

>From 4afadb9122c982c63f2b067661548a2c063590a5 Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Mon, 5 Aug 2024 13:01:06 +0200
Subject: [PATCH] [Arm][AArch64][Clang] Respect function's branch protection
 attributes.

Default attributes assigned to all functions according to the command line
parameters. Some functions might have their own attributes and we need to set
or remove attributes accordingly.
---
 clang/lib/CodeGen/TargetInfo.cpp  | 25 ---
 clang/lib/CodeGen/TargetInfo.h|  3 +++
 .../CodeGen/aarch64-branch-protection-attr.c  | 13 +-
 .../CodeGen/arm-branch-protection-attr-1.c|  6 +
 4 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 38faa50cf19cf..ec05db0ecfac5 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -209,9 +209,28 @@ llvm::Value *TargetCodeGenInfo::createEnqueuedBlockKernel(
 
 void TargetCodeGenInfo::setBranchProtectionFnAttributes(
 const TargetInfo::BranchProtectionInfo &BPI, llvm::Function &F) {
-  llvm::AttrBuilder FuncAttrs(F.getContext());
-  setBranchProtectionFnAttributes(BPI, FuncAttrs);
-  F.addFnAttrs(FuncAttrs);
+  if (BPI.SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) {
+F.addFnAttr("sign-return-address", BPI.getSignReturnAddrStr());
+F.addFnAttr("sign-return-address-key", BPI.getSignKeyStr());
+  } else {
+if (F.hasFnAttribute("sign-return-address"))
+  F.removeFnAttr("sign-return-address");
+if (F.hasFnAttribute("sign-return-address-key"))
+  F.removeFnAttr("sign-return-address-key");
+  }
+
+  auto AddRemoveAttributeAsSet = [&](bool Set, const StringRef &ModAttr) {
+if (Set)
+  F.addFnAttr(ModAttr);
+else if (F.hasFnAttribute(ModAttr))
+  F.removeFnAttr(ModAttr);
+  };
+
+  AddRemoveAttributeAsSet(BPI.BranchTargetEnforcement,
+  "branch-target-enforcement");
+  AddRemoveAttributeAsSet(BPI.BranchProtectionPAuthLR,
+  "branch-protection-pauth-lr");
+  AddRemoveAttributeAsSet(BPI.GuardedControlStack, "guarded-control-stack");
 }
 
 void TargetCodeGenInfo::setBranchProtectionFnAttributes(
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index 8f17c053f4783..639717bd9580d 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -418,10 +418,13 @@ class TargetCodeGenInfo {
 return nullptr;
   }
 
+  // Set the Branch Protection Attributes of the Function accordingly to the
+  // BPI. Might remove attributes if contradicts with the pass request.
   static void
   setBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI,
   llvm::Function &F);
 
+  // Add the Branch Protection Attributes of the FuncAttrs.
   static void
   setBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI,
   llvm::AttrBuilder &FuncAttrs);
diff --git a/clang/test/CodeGen/aarch64-branch-protection-attr.c 
b/clang/test/CodeGen/aarch64-branch-protection-attr.c
index e7ae7fb1570c9..c66bce1bee6d3 100644
--- a/clang/test/CodeGen/aarch64-branch-protection-attr.c
+++ b/clang/test/CodeGen/aarch64-branch-protection-attr.c
@@ -1,6 +1,18 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64 -emit-llvm  -target-cpu generic 
-target-feature +v8.5a %s -o - \
 // RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64 -emit-llvm  -target-cpu generic 
-target-feature +v8.5a -mbranch-target-enforce %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64 -emit-llvm  -target-cpu generic 
-target-feature +v8.5a -mguarded-control-stack %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64 -emit-llvm  -target-cpu generic 
-target-feature +v8.5a -msign-return-address=non-leaf 
-msign-return-address-key=a_key %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64 -emit-llvm  -target-cpu generic 
-target-feature +v8.5a -msign-return-address=all 
-msign-return-address-key=b_key %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64 -emit-llvm  -target-cpu generic 
-target-feature +v8.5a -mbranch-protection-pauth-lr -msign-return-address=all 
-msign-return-address-key=a_key %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64 -emit-llvm  -target-cpu generic 
-target-feature +v8.5a -mguarded-control-stack -mbranch-target-enforce 
-mbranch-protection-pauth-lr -msign-return-address=all 
-msig

[clang] [clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) (PR #102302)

2024-08-07 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` 
running on `ppc64le-sanitizer` while building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/72/builds/1984

Here is the relevant piece of the build log for the reference:
```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
PASS: ThreadSanitizer-powerpc64le :: unaligned_norace.cpp (2338 of 2483)
PASS: ThreadSanitizer-powerpc64le :: mutex_double_lock.cpp (2339 of 2483)
PASS: ThreadSanitizer-powerpc64le :: custom_mutex0.cpp (2340 of 2483)
PASS: ThreadSanitizer-powerpc64le :: pthread_atfork_deadlock.c (2341 of 2483)
PASS: ThreadSanitizer-powerpc64le :: inlined_memcpy_race.cpp (2342 of 2483)
PASS: ThreadSanitizer-powerpc64le :: mop_with_offset2.cpp (2343 of 2483)
PASS: ThreadSanitizer-powerpc64le :: dl_iterate_phdr.cpp (2344 of 2483)
PASS: ThreadSanitizer-powerpc64le :: signal_in_mutex_lock.cpp (2345 of 2483)
PASS: ThreadSanitizer-powerpc64le :: mutexset1.cpp (2346 of 2483)
PASS: ThreadSanitizer-powerpc64le :: mutexset3.cpp (2347 of 2483)
FAIL: ThreadSanitizer-powerpc64le :: signal_block.cpp (2348 of 2483)
 TEST 'ThreadSanitizer-powerpc64le :: signal_block.cpp' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/./bin/clang
  -fsanitize=thread -Wall  -m64 -fno-function-sections   -gline-tables-only 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/../
 -O1 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp
 -o 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_block.cpp.tmp
 &&  
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_block.cpp.tmp
 2>&1 | FileCheck 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp
+ 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/./bin/clang
 -fsanitize=thread -Wall -m64 -fno-function-sections -gline-tables-only 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/../
 -O1 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp
 -o 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_block.cpp.tmp
+ 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_block.cpp.tmp
+ FileCheck 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp:59:15:
 error: CHECK-NOT: excluded string found in input
// CHECK-NOT: WARNING: ThreadSanitizer:
  ^
:2:1: note: found here
WARNING: ThreadSanitizer: signal handler spoils errno (pid=3403759)
^

Input file: 
Check file: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp

-dump-input=help explains the following input dump.

Input was:
<<
1: == 
2: WARNING: ThreadSanitizer: signal handler spoils errno (pid=3403759) 
not:59 !
error: no match expected
3:  Signal 10 handler invoked at: 
4:  #0 handler(int) 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp:13
 (signal_block.cpp.tmp+0xff1a0) 
5:  #1 thread(void*) 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp:25:5
 (signal_block.cpp.tmp+0xff2f0) 
6:  
7: SUMMARY: ThreadSanitizer: signal handler spoils errno 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp:13

[clang] [llvm] [AArch64] Add updated FEAT_SVE_B16B16 and begin replacement of 'b16b16' flag (PR #101480)

2024-08-07 Thread via cfe-commits

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


[clang] [llvm] [AArch64] Add updated FEAT_SVE_B16B16 and begin replacement of 'b16b16' flag (PR #101480)

2024-08-07 Thread via cfe-commits

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

Thank you Spencer for the work.
I left some comments about the sve2.1 feature flags being used for the sve2. 
But I dont think you need to change in this patch. Because it is unrelated
Maybe you create another patch a NFC to move all the sve2p1 tests and run lines 
to be only SVE2?
I believe when we changed the feature flag we forgot to move the tests and also 
to fix all run lines. 

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


[clang] [llvm] [AArch64] Add updated FEAT_SVE_B16B16 and begin replacement of 'b16b16' flag (PR #101480)

2024-08-07 Thread via cfe-commits


@@ -1,10 +1,10 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: aarch64-registered-target
-// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +sve2 
-target-feature +sve2p1 -target-feature +b16b16 -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s
-// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +sve2 
-target-feature +sve2p1 -target-feature +b16b16 -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
-// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve 
-target-feature +sve2 -target-feature +sve2p1 -target-feature +b16b16 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s
-// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve 
-target-feature +sve2 -target-feature +sve2p1 -target-feature +b16b16 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
-// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +sve2 
-target-feature +sve2p1 -target-feature +b16b16 -disable-O0-optnone -Werror 
-Wall -o /dev/null %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +sve2 
-target-feature +sve2p1 -target-feature +sve-b16b16 -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +sve2 
-target-feature +sve2p1 -target-feature +sve-b16b16 -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve 
-target-feature +sve2 -target-feature +sve2p1 -target-feature +sve-b16b16 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve 
-target-feature +sve2 -target-feature +sve2p1 -target-feature +sve-b16b16 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +sve2 
-target-feature +sve2p1 -target-feature +sve-b16b16 -disable-O0-optnone -Werror 
-Wall -o /dev/null %s

CarolineConcatto wrote:

Not related to you patch, but the instructions that you changed  now only 
require sve2.
I believe you can change the run line to be only sve2.
The only ones that are sve2.1 are in section
SVE2.1 instruction intrinsics in the ACLE 
https://github.com/ARM-software/acle/blob/main/main/acle.md

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


  1   2   3   4   5   6   >