[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik updated 
https://github.com/llvm/llvm-project/pull/66643

>From 88028509d7e5b5eaf38075c18abba498cb00087a Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Mon, 18 Sep 2023 18:07:44 +0200
Subject: [PATCH] [clang] Fix null dereference on return in lambda attribute
 statement expr

clang was crashing on a lambda attribute with a statement expression
that contained a `return`.
It attempted to access the lambda type which was unknown at that point.

Fixes https://github.com/llvm/llvm-project/issues/48527
---
 clang/docs/ReleaseNotes.rst  |  4 
 clang/lib/Sema/SemaStmt.cpp  |  2 ++
 clang/test/SemaCXX/gh48527-2.cpp |  6 ++
 clang/test/SemaCXX/gh48527.cpp   | 10 ++
 4 files changed, 22 insertions(+)
 create mode 100644 clang/test/SemaCXX/gh48527-2.cpp
 create mode 100644 clang/test/SemaCXX/gh48527.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 500f9c9a0cda741..c6f258991c85a79 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -291,6 +291,10 @@ Bug Fixes to C++ Support
   pointers on win32.
   (`#62594 `_)
 
+- Fix crash for a lambda attribute with a statement expression
+  that contains a `return`.
+  (`#48527 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7cc509542d5381d..10adfbc406dfbb5 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3577,6 +3577,8 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation 
ReturnLoc,
   CapturingScopeInfo *CurCap = cast(getCurFunction());
   QualType FnRetType = CurCap->ReturnType;
   LambdaScopeInfo *CurLambda = dyn_cast(CurCap);
+  if (CurLambda && CurLambda->CallOperator->getType().isNull())
+return StmtError();
   bool HasDeducedReturnType =
   CurLambda && hasDeducedReturnType(CurLambda->CallOperator);
 
diff --git a/clang/test/SemaCXX/gh48527-2.cpp b/clang/test/SemaCXX/gh48527-2.cpp
new file mode 100644
index 000..c5d45f29252ca6b
--- /dev/null
+++ b/clang/test/SemaCXX/gh48527-2.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() {
+auto a = []()__attribute__((b(({ return 0; }{}; // expected-warning 
{{unknown attribute 'b' ignored}}
+return 0;
+}
diff --git a/clang/test/SemaCXX/gh48527.cpp b/clang/test/SemaCXX/gh48527.cpp
new file mode 100644
index 000..420c35be37f5191
--- /dev/null
+++ b/clang/test/SemaCXX/gh48527.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() { // expected-note {{to match this '{'}}
+auto a = [](void)__attribute__((b(({ // expected-note {{to match this '('}}
+return 0;
+} // expected-error 3 {{expected ')'}} \
+  // expected-error {{expected ';' at end of declaration}}
+// expected-error@+2 {{expected ')'}}
+// expected-error@+1 {{expected body of lambda expression}}
+// expected-error {{expected '}'}}

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

pfusik wrote:

@cor3ntin to `test/CXX/what` or `test/Parser` ?

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik updated 
https://github.com/llvm/llvm-project/pull/66643

>From 33c94d5bedf8889ab7b7fe2442fa0a3196223c91 Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Mon, 18 Sep 2023 18:41:54 +0200
Subject: [PATCH] [clang] Fix null dereference on return in lambda attribute
 statement expr

clang was crashing on a lambda attribute with a statement expression
that contained a `return`.
It attempted to access the lambda type which was unknown at that point.

Fixes https://github.com/llvm/llvm-project/issues/48527
---
 clang/docs/ReleaseNotes.rst  |  4 
 clang/lib/Sema/SemaStmt.cpp  |  2 ++
 clang/test/Parser/gh48527.cpp| 10 ++
 clang/test/SemaCXX/gh48527-2.cpp |  6 ++
 4 files changed, 22 insertions(+)
 create mode 100644 clang/test/Parser/gh48527.cpp
 create mode 100644 clang/test/SemaCXX/gh48527-2.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 500f9c9a0cda741..c6f258991c85a79 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -291,6 +291,10 @@ Bug Fixes to C++ Support
   pointers on win32.
   (`#62594 `_)
 
+- Fix crash for a lambda attribute with a statement expression
+  that contains a `return`.
+  (`#48527 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7cc509542d5381d..10adfbc406dfbb5 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3577,6 +3577,8 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation 
ReturnLoc,
   CapturingScopeInfo *CurCap = cast(getCurFunction());
   QualType FnRetType = CurCap->ReturnType;
   LambdaScopeInfo *CurLambda = dyn_cast(CurCap);
+  if (CurLambda && CurLambda->CallOperator->getType().isNull())
+return StmtError();
   bool HasDeducedReturnType =
   CurLambda && hasDeducedReturnType(CurLambda->CallOperator);
 
diff --git a/clang/test/Parser/gh48527.cpp b/clang/test/Parser/gh48527.cpp
new file mode 100644
index 000..420c35be37f5191
--- /dev/null
+++ b/clang/test/Parser/gh48527.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() { // expected-note {{to match this '{'}}
+auto a = [](void)__attribute__((b(({ // expected-note {{to match this '('}}
+return 0;
+} // expected-error 3 {{expected ')'}} \
+  // expected-error {{expected ';' at end of declaration}}
+// expected-error@+2 {{expected ')'}}
+// expected-error@+1 {{expected body of lambda expression}}
+// expected-error {{expected '}'}}
diff --git a/clang/test/SemaCXX/gh48527-2.cpp b/clang/test/SemaCXX/gh48527-2.cpp
new file mode 100644
index 000..c5d45f29252ca6b
--- /dev/null
+++ b/clang/test/SemaCXX/gh48527-2.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() {
+auto a = []()__attribute__((b(({ return 0; }{}; // expected-warning 
{{unknown attribute 'b' ignored}}
+return 0;
+}

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik updated 
https://github.com/llvm/llvm-project/pull/66643

>From 81281e52ac76d0c10ddadaf7d75a544eccce39a5 Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Mon, 18 Sep 2023 19:54:16 +0200
Subject: [PATCH] [clang] Fix null dereference on return in lambda attribute
 statement expr

clang was crashing on a lambda attribute with a statement expression
that contained a `return`.
It attempted to access the lambda type which was unknown at that point.

Fixes https://github.com/llvm/llvm-project/issues/48527
---
 clang/docs/ReleaseNotes.rst   |  4 
 clang/lib/Sema/SemaStmt.cpp   |  2 ++
 clang/test/Parser/gh48527.cpp | 10 ++
 clang/test/SemaCXX/lambda-expressions.cpp |  4 
 4 files changed, 20 insertions(+)
 create mode 100644 clang/test/Parser/gh48527.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 500f9c9a0cda741..c6f258991c85a79 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -291,6 +291,10 @@ Bug Fixes to C++ Support
   pointers on win32.
   (`#62594 `_)
 
+- Fix crash for a lambda attribute with a statement expression
+  that contains a `return`.
+  (`#48527 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7cc509542d5381d..10adfbc406dfbb5 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3577,6 +3577,8 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation 
ReturnLoc,
   CapturingScopeInfo *CurCap = cast(getCurFunction());
   QualType FnRetType = CurCap->ReturnType;
   LambdaScopeInfo *CurLambda = dyn_cast(CurCap);
+  if (CurLambda && CurLambda->CallOperator->getType().isNull())
+return StmtError();
   bool HasDeducedReturnType =
   CurLambda && hasDeducedReturnType(CurLambda->CallOperator);
 
diff --git a/clang/test/Parser/gh48527.cpp b/clang/test/Parser/gh48527.cpp
new file mode 100644
index 000..420c35be37f5191
--- /dev/null
+++ b/clang/test/Parser/gh48527.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() { // expected-note {{to match this '{'}}
+auto a = [](void)__attribute__((b(({ // expected-note {{to match this '('}}
+return 0;
+} // expected-error 3 {{expected ')'}} \
+  // expected-error {{expected ';' at end of declaration}}
+// expected-error@+2 {{expected ')'}}
+// expected-error@+1 {{expected body of lambda expression}}
+// expected-error {{expected '}'}}
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 23745dc14154747..269a1e1040ee96f 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -714,3 +714,7 @@ void foo() {
   // CHECK-NEXT: ConstantExpr
   // CHECK-NEXT: value: Int 2
 }
+
+void GH48527() {
+auto a = []()__attribute__((b(({ return 0; }{}; // expected-warning 
{{unknown attribute 'b' ignored}}
+}

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik updated 
https://github.com/llvm/llvm-project/pull/66643

>From b84e2a821a3121fa3597e710da341de66746bb46 Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Mon, 18 Sep 2023 19:56:10 +0200
Subject: [PATCH] [clang] Fix null dereference on return in lambda attribute
 statement expr

clang was crashing on a lambda attribute with a statement expression
that contained a `return`.
It attempted to access the lambda type which was unknown at that point.

Fixes https://github.com/llvm/llvm-project/issues/48527
---
 clang/docs/ReleaseNotes.rst   |  4 
 clang/lib/Sema/SemaStmt.cpp   |  2 ++
 clang/test/Parser/gh48527.cpp | 10 ++
 clang/test/SemaCXX/lambda-expressions.cpp |  4 
 4 files changed, 20 insertions(+)
 create mode 100644 clang/test/Parser/gh48527.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 500f9c9a0cda741..c6f258991c85a79 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -291,6 +291,10 @@ Bug Fixes to C++ Support
   pointers on win32.
   (`#62594 `_)
 
+- Fix crash for a lambda attribute with a statement expression
+  that contains a `return`.
+  (`#48527 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7cc509542d5381d..10adfbc406dfbb5 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3577,6 +3577,8 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation 
ReturnLoc,
   CapturingScopeInfo *CurCap = cast(getCurFunction());
   QualType FnRetType = CurCap->ReturnType;
   LambdaScopeInfo *CurLambda = dyn_cast(CurCap);
+  if (CurLambda && CurLambda->CallOperator->getType().isNull())
+return StmtError();
   bool HasDeducedReturnType =
   CurLambda && hasDeducedReturnType(CurLambda->CallOperator);
 
diff --git a/clang/test/Parser/gh48527.cpp b/clang/test/Parser/gh48527.cpp
new file mode 100644
index 000..420c35be37f5191
--- /dev/null
+++ b/clang/test/Parser/gh48527.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() { // expected-note {{to match this '{'}}
+auto a = [](void)__attribute__((b(({ // expected-note {{to match this '('}}
+return 0;
+} // expected-error 3 {{expected ')'}} \
+  // expected-error {{expected ';' at end of declaration}}
+// expected-error@+2 {{expected ')'}}
+// expected-error@+1 {{expected body of lambda expression}}
+// expected-error {{expected '}'}}
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 23745dc14154747..0c9e8584e653473 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -714,3 +714,7 @@ void foo() {
   // CHECK-NEXT: ConstantExpr
   // CHECK-NEXT: value: Int 2
 }
+
+void GH48527() {
+  auto a = []()__attribute__((b(({ return 0; }{}; // expected-warning 
{{unknown attribute 'b' ignored}}
+}

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik updated 
https://github.com/llvm/llvm-project/pull/66643

>From c313074ca50cae80698154991273717e5a8cc13a Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Mon, 18 Sep 2023 19:56:10 +0200
Subject: [PATCH] [clang] Fix null dereference on return in lambda attribute
 statement expr

clang was crashing on a lambda attribute with a statement expression
that contained a `return`.
It attempted to access the lambda type which was unknown at that point.

Fixes https://github.com/llvm/llvm-project/issues/48527
---
 clang/docs/ReleaseNotes.rst   |  4 
 clang/lib/Sema/SemaStmt.cpp   |  2 ++
 clang/test/Parser/gh48527.cpp | 10 ++
 clang/test/SemaCXX/lambda-expressions.cpp |  4 
 4 files changed, 20 insertions(+)
 create mode 100644 clang/test/Parser/gh48527.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7e964f6eb435bb0..ef4e9c792bec05c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -297,6 +297,10 @@ Bug Fixes to C++ Support
   definition the specialization was instantiated from.
   (`#26057 `_`)
 
+- Fix crash for a lambda attribute with a statement expression
+  that contains a `return`.
+  (`#48527 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7cc509542d5381d..10adfbc406dfbb5 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3577,6 +3577,8 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation 
ReturnLoc,
   CapturingScopeInfo *CurCap = cast(getCurFunction());
   QualType FnRetType = CurCap->ReturnType;
   LambdaScopeInfo *CurLambda = dyn_cast(CurCap);
+  if (CurLambda && CurLambda->CallOperator->getType().isNull())
+return StmtError();
   bool HasDeducedReturnType =
   CurLambda && hasDeducedReturnType(CurLambda->CallOperator);
 
diff --git a/clang/test/Parser/gh48527.cpp b/clang/test/Parser/gh48527.cpp
new file mode 100644
index 000..420c35be37f5191
--- /dev/null
+++ b/clang/test/Parser/gh48527.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() { // expected-note {{to match this '{'}}
+auto a = [](void)__attribute__((b(({ // expected-note {{to match this '('}}
+return 0;
+} // expected-error 3 {{expected ')'}} \
+  // expected-error {{expected ';' at end of declaration}}
+// expected-error@+2 {{expected ')'}}
+// expected-error@+1 {{expected body of lambda expression}}
+// expected-error {{expected '}'}}
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 23745dc14154747..0c9e8584e653473 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -714,3 +714,7 @@ void foo() {
   // CHECK-NEXT: ConstantExpr
   // CHECK-NEXT: value: Int 2
 }
+
+void GH48527() {
+  auto a = []()__attribute__((b(({ return 0; }{}; // expected-warning 
{{unknown attribute 'b' ignored}}
+}

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

pfusik wrote:

Rebased resolving the conflict in release notes.

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik updated 
https://github.com/llvm/llvm-project/pull/66643

>From 4545c9c691a7affcab6cfe4e1b9b2a7715ab3f8b Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Mon, 18 Sep 2023 19:56:10 +0200
Subject: [PATCH] [clang] Fix null dereference on return in lambda attribute
 statement expr

clang was crashing on a lambda attribute with a statement expression
that contained a `return`.
It attempted to access the lambda type which was unknown at that point.

Fixes https://github.com/llvm/llvm-project/issues/48527
---
 clang/docs/ReleaseNotes.rst   |  4 
 clang/lib/Sema/SemaStmt.cpp   |  2 ++
 clang/test/Parser/gh48527.cpp | 10 ++
 clang/test/SemaCXX/lambda-expressions.cpp |  4 
 4 files changed, 20 insertions(+)
 create mode 100644 clang/test/Parser/gh48527.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9b1578762e301f6..172818114c3b92b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -301,6 +301,10 @@ Bug Fixes to C++ Support
   makes an invalid call to an immediate function.
   (`#66324 `_)
 
+- Fix crash for a lambda attribute with a statement expression
+  that contains a `return`.
+  (`#48527 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7cc509542d5381d..10adfbc406dfbb5 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3577,6 +3577,8 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation 
ReturnLoc,
   CapturingScopeInfo *CurCap = cast(getCurFunction());
   QualType FnRetType = CurCap->ReturnType;
   LambdaScopeInfo *CurLambda = dyn_cast(CurCap);
+  if (CurLambda && CurLambda->CallOperator->getType().isNull())
+return StmtError();
   bool HasDeducedReturnType =
   CurLambda && hasDeducedReturnType(CurLambda->CallOperator);
 
diff --git a/clang/test/Parser/gh48527.cpp b/clang/test/Parser/gh48527.cpp
new file mode 100644
index 000..420c35be37f5191
--- /dev/null
+++ b/clang/test/Parser/gh48527.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() { // expected-note {{to match this '{'}}
+auto a = [](void)__attribute__((b(({ // expected-note {{to match this '('}}
+return 0;
+} // expected-error 3 {{expected ')'}} \
+  // expected-error {{expected ';' at end of declaration}}
+// expected-error@+2 {{expected ')'}}
+// expected-error@+1 {{expected body of lambda expression}}
+// expected-error {{expected '}'}}
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 23745dc14154747..0c9e8584e653473 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -714,3 +714,7 @@ void foo() {
   // CHECK-NEXT: ConstantExpr
   // CHECK-NEXT: value: Int 2
 }
+
+void GH48527() {
+  auto a = []()__attribute__((b(({ return 0; }{}; // expected-warning 
{{unknown attribute 'b' ignored}}
+}

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik created 
https://github.com/llvm/llvm-project/pull/66643

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

>From ea731b4d3d553f42cbaaec2079adeec3927b4150 Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Mon, 18 Sep 2023 15:10:58 +0200
Subject: [PATCH] [clang] Fix null dereference on return in lambda attribute
 statement expr

Fixes https://github.com/llvm/llvm-project/issues/48527
---
 clang/lib/Sema/SemaStmt.cpp|  2 ++
 clang/test/SemaCXX/gh48527.cpp | 10 ++
 2 files changed, 12 insertions(+)
 create mode 100644 clang/test/SemaCXX/gh48527.cpp

diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7cc509542d5381d..10adfbc406dfbb5 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3577,6 +3577,8 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation 
ReturnLoc,
   CapturingScopeInfo *CurCap = cast(getCurFunction());
   QualType FnRetType = CurCap->ReturnType;
   LambdaScopeInfo *CurLambda = dyn_cast(CurCap);
+  if (CurLambda && CurLambda->CallOperator->getType().isNull())
+return StmtError();
   bool HasDeducedReturnType =
   CurLambda && hasDeducedReturnType(CurLambda->CallOperator);
 
diff --git a/clang/test/SemaCXX/gh48527.cpp b/clang/test/SemaCXX/gh48527.cpp
new file mode 100644
index 000..420c35be37f5191
--- /dev/null
+++ b/clang/test/SemaCXX/gh48527.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() { // expected-note {{to match this '{'}}
+auto a = [](void)__attribute__((b(({ // expected-note {{to match this '('}}
+return 0;
+} // expected-error 3 {{expected ')'}} \
+  // expected-error {{expected ';' at end of declaration}}
+// expected-error@+2 {{expected ')'}}
+// expected-error@+1 {{expected body of lambda expression}}
+// expected-error {{expected '}'}}

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


[clang] [clang] Fix null dereference on return in lambda attribute statement expr (PR #66643)

2023-09-18 Thread Piotr Fusik via cfe-commits

pfusik wrote:

> I'd be inclined to move the test to clang/test/Parser/ because even though 
> the fix is in Sema, it's testing a wrong parse.

It's an ICE in Sema. The test is identical to the bug report, but it doesn't 
mean the issue is limited to syntax errors.

```cpp
int main() {
[]()__attribute__((b(({ return 0; }{};
}
```

g++ accepts the above while Clang crashes. I'll add this as a second test.

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


[clang] [clang][NFC] Fix a warning (PR #98611)

2024-07-12 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik created 
https://github.com/llvm/llvm-project/pull/98611

enumerated and non-enumerated type in conditional expression

>From d8d44d1eff37bc7e2632fb64b087aac270742ac6 Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Fri, 12 Jul 2024 11:34:26 +0200
Subject: [PATCH] [clang][NFC] Fix a warning

enumerated and non-enumerated type in conditional expression
---
 clang/lib/CodeGen/CGExpr.cpp | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 039f60c774591..ddb82571f53d7 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3842,9 +3842,10 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
 
 llvm::CallInst *TrapCall = Builder.CreateCall(
 CGM.getIntrinsic(llvm::Intrinsic::ubsantrap),
-llvm::ConstantInt::get(CGM.Int8Ty, ClSanitizeDebugDeoptimization
-   ? TrapBB->getParent()->size()
-   : CheckHandlerID));
+llvm::ConstantInt::get(CGM.Int8Ty,
+   ClSanitizeDebugDeoptimization
+   ? TrapBB->getParent()->size()
+   : static_cast(CheckHandlerID)));
 
 if (!CGM.getCodeGenOpts().TrapFuncName.empty()) {
   auto A = llvm::Attribute::get(getLLVMContext(), "trap-func-name",

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


[clang] [clang][NFC] Fix a warning (PR #98611)

2024-07-12 Thread Piotr Fusik via cfe-commits

pfusik wrote:

This fixes one of the very few warnings when building clang with Ubuntu 22.04's 
gcc.

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


[clang] [clang][NFC] Fix a warning (PR #98611)

2024-07-14 Thread Piotr Fusik via cfe-commits

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


[clang] [BoundsSafety][doc] Fix formatting (PR #126245)

2025-02-07 Thread Piotr Fusik via cfe-commits

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


[clang] [BoundsSafety][doc] Add a missing newline in C snippet (PR #126245)

2025-02-07 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik updated 
https://github.com/llvm/llvm-project/pull/126245

>From 666c1d15556579707c1ebce07ed2774fe13437ec Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Fri, 7 Feb 2025 14:58:34 +0100
Subject: [PATCH 1/2] [BoundsSafety][doc] Add a missing newline in C snippet

---
 clang/docs/BoundsSafety.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/docs/BoundsSafety.rst b/clang/docs/BoundsSafety.rst
index e24c69d8c7855f3..f867c7ba07b48b3 100644
--- a/clang/docs/BoundsSafety.rst
+++ b/clang/docs/BoundsSafety.rst
@@ -959,7 +959,8 @@ that has the define.
#if defined(__has_feature) && __has_feature(bounds_safety)
#define __counted_by(T) __attribute__((__counted_by__(T)))
// ... other bounds annotations
-   #else #define __counted_by(T) // defined as nothing
+   #else
+   #define __counted_by(T) // defined as nothing
// ... other bounds annotations
#endif
 
@@ -1003,4 +1004,4 @@ Try it out
 
 Your feedback on the programming model is valuable. You may want to follow the
 instruction in :doc:`BoundsSafetyAdoptionGuide` to play with 
``-fbounds-safety``
-and please send your feedback to `Yeoul Na `_.
\ No newline at end of file
+and please send your feedback to `Yeoul Na `_.

>From 6696886dbf074e814e06e7307cc5cd247ea64145 Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Fri, 7 Feb 2025 15:06:37 +0100
Subject: [PATCH 2/2] [BoundsSafety][doc] Add a missing quote

---
 clang/docs/BoundsSafety.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/BoundsSafety.rst b/clang/docs/BoundsSafety.rst
index f867c7ba07b48b3..8635bec6e17c73a 100644
--- a/clang/docs/BoundsSafety.rst
+++ b/clang/docs/BoundsSafety.rst
@@ -988,7 +988,7 @@ and it does not guarantee other types of memory safety 
properties. Consequently,
 it may not prevent some of the secondary bounds safety violations caused by
 other types of safety violations such as type confusion. For instance,
 ``-fbounds-safety`` does not perform type-safety checks on conversions between
-`__single`` pointers of different pointee types (e.g., ``char *__single`` →
+``__single`` pointers of different pointee types (e.g., ``char *__single`` →
 ``void *__single`` → ``int *__single``) beyond what the foundation languages
 (C/C++) already offer.
 

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


[clang] [BoundsSafety][doc] Fix a typo (PR #126247)

2025-02-07 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik created 
https://github.com/llvm/llvm-project/pull/126247

None

>From 7aa0008aafc776941151dec16f52725b8958e730 Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Fri, 7 Feb 2025 15:19:11 +0100
Subject: [PATCH] [BoundsSafety][doc] Fix a typo

---
 clang/docs/BoundsSafety.rst  | 6 +++---
 clang/docs/BoundsSafetyImplPlans.rst | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/docs/BoundsSafety.rst b/clang/docs/BoundsSafety.rst
index e24c69d8c7855f3..3d3d7ea3eb41be9 100644
--- a/clang/docs/BoundsSafety.rst
+++ b/clang/docs/BoundsSafety.rst
@@ -777,13 +777,13 @@ the transformed pseudo code of function ``alloc_buf()`` 
in the example below.
   size_t count;
} sized_buf_t;
 
-   void alloc_buf(sized_buf_t *sbuf, sized_t nelems) {
+   void alloc_buf(sized_buf_t *sbuf, size_t nelems) {
   sbuf->buf = (int *)malloc(sizeof(int) * nelems);
   sbuf->count = nelems;
}
 
// Transformed pseudo code:
-   void alloc_buf(sized_buf_t *sbuf, sized_t nelems) {
+   void alloc_buf(sized_buf_t *sbuf, size_t nelems) {
   // Materialize RHS values:
   int *tmp_ptr = (int *)malloc(sizeof(int) * nelems);
   int tmp_count = nelems;
@@ -1003,4 +1003,4 @@ Try it out
 
 Your feedback on the programming model is valuable. You may want to follow the
 instruction in :doc:`BoundsSafetyAdoptionGuide` to play with 
``-fbounds-safety``
-and please send your feedback to `Yeoul Na `_.
\ No newline at end of file
+and please send your feedback to `Yeoul Na `_.
diff --git a/clang/docs/BoundsSafetyImplPlans.rst 
b/clang/docs/BoundsSafetyImplPlans.rst
index 93c2ed7b4340295..34276c920f31e2a 100644
--- a/clang/docs/BoundsSafetyImplPlans.rst
+++ b/clang/docs/BoundsSafetyImplPlans.rst
@@ -134,7 +134,7 @@ same basic block and without side effect in between.
   int *__counted_by(count) buf; size_t count;
} sized_buf_t;
 
-   void alloc_buf(sized_buf_t *sbuf, sized_t nelems) {
+   void alloc_buf(sized_buf_t *sbuf, size_t nelems) {
   sbuf->buf = (int *)malloc(sizeof(int) * nelems);
   sbuf->count = nelems;
}

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


[clang] [BoundsSafety][doc] Add a missing newline in C snippet (PR #126245)

2025-02-07 Thread Piotr Fusik via cfe-commits

https://github.com/pfusik created 
https://github.com/llvm/llvm-project/pull/126245

None

>From 666c1d15556579707c1ebce07ed2774fe13437ec Mon Sep 17 00:00:00 2001
From: Piotr Fusik 
Date: Fri, 7 Feb 2025 14:58:34 +0100
Subject: [PATCH] [BoundsSafety][doc] Add a missing newline in C snippet

---
 clang/docs/BoundsSafety.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/docs/BoundsSafety.rst b/clang/docs/BoundsSafety.rst
index e24c69d8c7855f3..f867c7ba07b48b3 100644
--- a/clang/docs/BoundsSafety.rst
+++ b/clang/docs/BoundsSafety.rst
@@ -959,7 +959,8 @@ that has the define.
#if defined(__has_feature) && __has_feature(bounds_safety)
#define __counted_by(T) __attribute__((__counted_by__(T)))
// ... other bounds annotations
-   #else #define __counted_by(T) // defined as nothing
+   #else
+   #define __counted_by(T) // defined as nothing
// ... other bounds annotations
#endif
 
@@ -1003,4 +1004,4 @@ Try it out
 
 Your feedback on the programming model is valuable. You may want to follow the
 instruction in :doc:`BoundsSafetyAdoptionGuide` to play with 
``-fbounds-safety``
-and please send your feedback to `Yeoul Na `_.
\ No newline at end of file
+and please send your feedback to `Yeoul Na `_.

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


[clang] [BoundsSafety][doc] Fix formatting (PR #126245)

2025-02-07 Thread Piotr Fusik via cfe-commits

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