[clang] [clang] Introduce `SemaPseudoObject` (PR #92646)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/92646 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaPseudoObject` (PR #92646)
https://github.com/AaronBallman approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/92646 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaPseudoObject` (PR #92646)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/92646 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaPseudoObject` (PR #92646)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/92646 >From 81b2c7dbb6fb9cb24d560b6069f60ba3452bbf2a Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Sat, 18 May 2024 14:20:43 +0300 Subject: [PATCH 1/2] [clang] Introduce `SemaPseudoObject` --- clang/include/clang/Sema/Sema.h | 57 +++--- clang/include/clang/Sema/SemaPseudoObject.h | 41 + clang/lib/Sema/Sema.cpp | 2 + clang/lib/Sema/SemaExpr.cpp | 9 +-- clang/lib/Sema/SemaPseudoObject.cpp | 65 +++-- clang/lib/Sema/TreeTransform.h | 7 ++- 6 files changed, 107 insertions(+), 74 deletions(-) create mode 100644 clang/include/clang/Sema/SemaPseudoObject.h diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index d4d4a82525a02..9d26a48dd213a 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -173,6 +173,7 @@ class SemaHLSL; class SemaObjC; class SemaOpenACC; class SemaOpenMP; +class SemaPseudoObject; class SemaSYCL; class StandardConversionSequence; class Stmt; @@ -470,20 +471,19 @@ class Sema final : public SemaBase { // 18. Name Lookup (SemaLookup.cpp) // 19. Modules (SemaModule.cpp) // 20. C++ Overloading (SemaOverload.cpp) - // 21. Pseudo-Object (SemaPseudoObject.cpp) - // 22. Statements (SemaStmt.cpp) - // 23. `inline asm` Statement (SemaStmtAsm.cpp) - // 24. Statement Attribute Handling (SemaStmtAttr.cpp) - // 25. C++ Templates (SemaTemplate.cpp) - // 26. C++ Template Argument Deduction (SemaTemplateDeduction.cpp) - // 27. C++ Template Instantiation (SemaTemplateInstantiate.cpp) - // 28. C++ Template Declaration Instantiation + // 21. Statements (SemaStmt.cpp) + // 22. `inline asm` Statement (SemaStmtAsm.cpp) + // 23. Statement Attribute Handling (SemaStmtAttr.cpp) + // 24. C++ Templates (SemaTemplate.cpp) + // 25. C++ Template Argument Deduction (SemaTemplateDeduction.cpp) + // 26. C++ Template Instantiation (SemaTemplateInstantiate.cpp) + // 27. C++ Template Declaration Instantiation // (SemaTemplateInstantiateDecl.cpp) - // 29. C++ Variadic Templates (SemaTemplateVariadic.cpp) - // 30. Constraints and Concepts (SemaConcept.cpp) - // 31. Types (SemaType.cpp) - // 32. FixIt Helpers (SemaFixItUtils.cpp) - // 33. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp) + // 28. C++ Variadic Templates (SemaTemplateVariadic.cpp) + // 29. Constraints and Concepts (SemaConcept.cpp) + // 30. Types (SemaType.cpp) + // 31. FixIt Helpers (SemaFixItUtils.cpp) + // 32. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp) /// \name Semantic Analysis /// Implementations are in Sema.cpp @@ -1014,6 +1014,11 @@ class Sema final : public SemaBase { return *OpenMPPtr; } + SemaPseudoObject () { +assert(PseudoObjectPtr); +return *PseudoObjectPtr; + } + SemaSYCL () { assert(SYCLPtr); return *SYCLPtr; @@ -1055,6 +1060,7 @@ class Sema final : public SemaBase { std::unique_ptr ObjCPtr; std::unique_ptr OpenACCPtr; std::unique_ptr OpenMPPtr; + std::unique_ptr PseudoObjectPtr; std::unique_ptr SYCLPtr; ///@} @@ -6370,6 +6376,8 @@ class Sema final : public SemaBase { llvm::SmallVector, 1> ImplicitlyRetainedSelfLocs; + void maybeExtendBlockObject(ExprResult ); + private: static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind); @@ -8368,29 +8376,6 @@ class Sema final : public SemaBase { // // - /// \name Pseudo-Object - /// Implementations are in SemaPseudoObject.cpp - ///@{ - -public: - void maybeExtendBlockObject(ExprResult ); - - ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, - UnaryOperatorKind Opcode, Expr *Op); - ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, - BinaryOperatorKind Opcode, Expr *LHS, - Expr *RHS); - ExprResult checkPseudoObjectRValue(Expr *E); - Expr *recreateSyntacticForm(PseudoObjectExpr *E); - - ///@} - - // - // - // - - // - // - /// \name Statements /// Implementations are in SemaStmt.cpp ///@{ diff --git a/clang/include/clang/Sema/SemaPseudoObject.h b/clang/include/clang/Sema/SemaPseudoObject.h new file mode 100644 index 0..f1f4dc07cf1c1 --- /dev/null +++ b/clang/include/clang/Sema/SemaPseudoObject.h @@ -0,0 +1,41 @@ +//===- SemaPseudoObject.h --- Semantic Analysis for Pseudo-Objects ===// +// +// 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 +// +//===--===// +/// \file
[clang] [clang] Introduce `SemaPseudoObject` (PR #92646)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes This patch moves `Sema` functions that handle pseudo-objects into the new `SemaPseudoObject` class. This continues previous efforts to split `Sema` up. Additional context can be found in #84184. As usual, in order to help reviewing this, formatting changes are split into a separate commit. --- Full diff: https://github.com/llvm/llvm-project/pull/92646.diff 6 Files Affected: - (modified) clang/include/clang/Sema/Sema.h (+21-36) - (added) clang/include/clang/Sema/SemaPseudoObject.h (+40) - (modified) clang/lib/Sema/Sema.cpp (+2) - (modified) clang/lib/Sema/SemaExpr.cpp (+5-4) - (modified) clang/lib/Sema/SemaPseudoObject.cpp (+39-36) - (modified) clang/lib/Sema/TreeTransform.h (+5-4) ``diff diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index d4d4a82525a02..9d26a48dd213a 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -173,6 +173,7 @@ class SemaHLSL; class SemaObjC; class SemaOpenACC; class SemaOpenMP; +class SemaPseudoObject; class SemaSYCL; class StandardConversionSequence; class Stmt; @@ -470,20 +471,19 @@ class Sema final : public SemaBase { // 18. Name Lookup (SemaLookup.cpp) // 19. Modules (SemaModule.cpp) // 20. C++ Overloading (SemaOverload.cpp) - // 21. Pseudo-Object (SemaPseudoObject.cpp) - // 22. Statements (SemaStmt.cpp) - // 23. `inline asm` Statement (SemaStmtAsm.cpp) - // 24. Statement Attribute Handling (SemaStmtAttr.cpp) - // 25. C++ Templates (SemaTemplate.cpp) - // 26. C++ Template Argument Deduction (SemaTemplateDeduction.cpp) - // 27. C++ Template Instantiation (SemaTemplateInstantiate.cpp) - // 28. C++ Template Declaration Instantiation + // 21. Statements (SemaStmt.cpp) + // 22. `inline asm` Statement (SemaStmtAsm.cpp) + // 23. Statement Attribute Handling (SemaStmtAttr.cpp) + // 24. C++ Templates (SemaTemplate.cpp) + // 25. C++ Template Argument Deduction (SemaTemplateDeduction.cpp) + // 26. C++ Template Instantiation (SemaTemplateInstantiate.cpp) + // 27. C++ Template Declaration Instantiation // (SemaTemplateInstantiateDecl.cpp) - // 29. C++ Variadic Templates (SemaTemplateVariadic.cpp) - // 30. Constraints and Concepts (SemaConcept.cpp) - // 31. Types (SemaType.cpp) - // 32. FixIt Helpers (SemaFixItUtils.cpp) - // 33. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp) + // 28. C++ Variadic Templates (SemaTemplateVariadic.cpp) + // 29. Constraints and Concepts (SemaConcept.cpp) + // 30. Types (SemaType.cpp) + // 31. FixIt Helpers (SemaFixItUtils.cpp) + // 32. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp) /// \name Semantic Analysis /// Implementations are in Sema.cpp @@ -1014,6 +1014,11 @@ class Sema final : public SemaBase { return *OpenMPPtr; } + SemaPseudoObject () { +assert(PseudoObjectPtr); +return *PseudoObjectPtr; + } + SemaSYCL () { assert(SYCLPtr); return *SYCLPtr; @@ -1055,6 +1060,7 @@ class Sema final : public SemaBase { std::unique_ptr ObjCPtr; std::unique_ptr OpenACCPtr; std::unique_ptr OpenMPPtr; + std::unique_ptr PseudoObjectPtr; std::unique_ptr SYCLPtr; ///@} @@ -6370,6 +6376,8 @@ class Sema final : public SemaBase { llvm::SmallVector, 1> ImplicitlyRetainedSelfLocs; + void maybeExtendBlockObject(ExprResult ); + private: static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind); @@ -8368,29 +8376,6 @@ class Sema final : public SemaBase { // // - /// \name Pseudo-Object - /// Implementations are in SemaPseudoObject.cpp - ///@{ - -public: - void maybeExtendBlockObject(ExprResult ); - - ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, - UnaryOperatorKind Opcode, Expr *Op); - ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, - BinaryOperatorKind Opcode, Expr *LHS, - Expr *RHS); - ExprResult checkPseudoObjectRValue(Expr *E); - Expr *recreateSyntacticForm(PseudoObjectExpr *E); - - ///@} - - // - // - // - - // - // - /// \name Statements /// Implementations are in SemaStmt.cpp ///@{ diff --git a/clang/include/clang/Sema/SemaPseudoObject.h b/clang/include/clang/Sema/SemaPseudoObject.h new file mode 100644 index 0..22d8be2b3726e --- /dev/null +++ b/clang/include/clang/Sema/SemaPseudoObject.h @@ -0,0 +1,40 @@ +//===- SemaPseudoObject.h --- Semantic Analysis for Pseudo-Objects ===// +// +// 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 +//
[clang] [clang] Introduce `SemaPseudoObject` (PR #92646)
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/92646 This patch moves `Sema` functions that handle pseudo-objects into the new `SemaPseudoObject` class. This continues previous efforts to split `Sema` up. Additional context can be found in #84184. As usual, in order to help reviewing this, formatting changes are split into a separate commit. >From 81b2c7dbb6fb9cb24d560b6069f60ba3452bbf2a Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Sat, 18 May 2024 14:20:43 +0300 Subject: [PATCH 1/2] [clang] Introduce `SemaPseudoObject` --- clang/include/clang/Sema/Sema.h | 57 +++--- clang/include/clang/Sema/SemaPseudoObject.h | 41 + clang/lib/Sema/Sema.cpp | 2 + clang/lib/Sema/SemaExpr.cpp | 9 +-- clang/lib/Sema/SemaPseudoObject.cpp | 65 +++-- clang/lib/Sema/TreeTransform.h | 7 ++- 6 files changed, 107 insertions(+), 74 deletions(-) create mode 100644 clang/include/clang/Sema/SemaPseudoObject.h diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index d4d4a82525a02..9d26a48dd213a 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -173,6 +173,7 @@ class SemaHLSL; class SemaObjC; class SemaOpenACC; class SemaOpenMP; +class SemaPseudoObject; class SemaSYCL; class StandardConversionSequence; class Stmt; @@ -470,20 +471,19 @@ class Sema final : public SemaBase { // 18. Name Lookup (SemaLookup.cpp) // 19. Modules (SemaModule.cpp) // 20. C++ Overloading (SemaOverload.cpp) - // 21. Pseudo-Object (SemaPseudoObject.cpp) - // 22. Statements (SemaStmt.cpp) - // 23. `inline asm` Statement (SemaStmtAsm.cpp) - // 24. Statement Attribute Handling (SemaStmtAttr.cpp) - // 25. C++ Templates (SemaTemplate.cpp) - // 26. C++ Template Argument Deduction (SemaTemplateDeduction.cpp) - // 27. C++ Template Instantiation (SemaTemplateInstantiate.cpp) - // 28. C++ Template Declaration Instantiation + // 21. Statements (SemaStmt.cpp) + // 22. `inline asm` Statement (SemaStmtAsm.cpp) + // 23. Statement Attribute Handling (SemaStmtAttr.cpp) + // 24. C++ Templates (SemaTemplate.cpp) + // 25. C++ Template Argument Deduction (SemaTemplateDeduction.cpp) + // 26. C++ Template Instantiation (SemaTemplateInstantiate.cpp) + // 27. C++ Template Declaration Instantiation // (SemaTemplateInstantiateDecl.cpp) - // 29. C++ Variadic Templates (SemaTemplateVariadic.cpp) - // 30. Constraints and Concepts (SemaConcept.cpp) - // 31. Types (SemaType.cpp) - // 32. FixIt Helpers (SemaFixItUtils.cpp) - // 33. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp) + // 28. C++ Variadic Templates (SemaTemplateVariadic.cpp) + // 29. Constraints and Concepts (SemaConcept.cpp) + // 30. Types (SemaType.cpp) + // 31. FixIt Helpers (SemaFixItUtils.cpp) + // 32. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp) /// \name Semantic Analysis /// Implementations are in Sema.cpp @@ -1014,6 +1014,11 @@ class Sema final : public SemaBase { return *OpenMPPtr; } + SemaPseudoObject () { +assert(PseudoObjectPtr); +return *PseudoObjectPtr; + } + SemaSYCL () { assert(SYCLPtr); return *SYCLPtr; @@ -1055,6 +1060,7 @@ class Sema final : public SemaBase { std::unique_ptr ObjCPtr; std::unique_ptr OpenACCPtr; std::unique_ptr OpenMPPtr; + std::unique_ptr PseudoObjectPtr; std::unique_ptr SYCLPtr; ///@} @@ -6370,6 +6376,8 @@ class Sema final : public SemaBase { llvm::SmallVector, 1> ImplicitlyRetainedSelfLocs; + void maybeExtendBlockObject(ExprResult ); + private: static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind); @@ -8368,29 +8376,6 @@ class Sema final : public SemaBase { // // - /// \name Pseudo-Object - /// Implementations are in SemaPseudoObject.cpp - ///@{ - -public: - void maybeExtendBlockObject(ExprResult ); - - ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, - UnaryOperatorKind Opcode, Expr *Op); - ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, - BinaryOperatorKind Opcode, Expr *LHS, - Expr *RHS); - ExprResult checkPseudoObjectRValue(Expr *E); - Expr *recreateSyntacticForm(PseudoObjectExpr *E); - - ///@} - - // - // - // - - // - // - /// \name Statements /// Implementations are in SemaStmt.cpp ///@{ diff --git a/clang/include/clang/Sema/SemaPseudoObject.h b/clang/include/clang/Sema/SemaPseudoObject.h new file mode 100644 index 0..f1f4dc07cf1c1 --- /dev/null +++ b/clang/include/clang/Sema/SemaPseudoObject.h @@ -0,0 +1,41 @@ +//===- SemaPseudoObject.h --- Semantic Analysis for Pseudo-Objects ===// +// +//