Skip to content

Commit

Permalink
Copy and move semantics have been disabled for scope types.
Browse files Browse the repository at this point in the history
These types are only intended for scope-like usage (ctor-dtor pair matters), not the relocation of data.
  • Loading branch information
dbukki committed Mar 7, 2024
1 parent f9bddaa commit e77d2cd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/cpp/parser/src/clangastvisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class ClangASTVisitor : public clang::RecursiveASTVisitor<ClangASTVisitor>

class TypeScope final
{
DECLARE_SCOPED_TYPE(TypeScope)

private:
ClangASTVisitor* _visitor;
model::CppRecordPtr _type;
Expand All @@ -170,6 +172,8 @@ class ClangASTVisitor : public clang::RecursiveASTVisitor<ClangASTVisitor>

class EnumScope final
{
DECLARE_SCOPED_TYPE(EnumScope)

private:
ClangASTVisitor* _visitor;
model::CppEnumPtr _enum;
Expand All @@ -196,6 +200,8 @@ class ClangASTVisitor : public clang::RecursiveASTVisitor<ClangASTVisitor>

class FunctionScope final
{
DECLARE_SCOPED_TYPE(FunctionScope)

private:
ClangASTVisitor* _visitor;
model::CppFunctionPtr _curFun;
Expand Down Expand Up @@ -321,6 +327,8 @@ class ClangASTVisitor : public clang::RecursiveASTVisitor<ClangASTVisitor>

class CtxStmtScope final
{
DECLARE_SCOPED_TYPE(CtxStmtScope)

private:
ClangASTVisitor* _visitor;

Expand Down
6 changes: 6 additions & 0 deletions plugins/cpp/parser/src/nestedscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <clang/AST/Stmt.h>

#include <util/scopedvalue.h>

namespace cc
{
namespace parser
Expand All @@ -12,6 +14,8 @@ namespace parser

class StatementStack final
{
DECLARE_SCOPED_TYPE(StatementStack)

friend class StatementScope;

private:
Expand All @@ -26,6 +30,8 @@ namespace parser

class StatementScope final
{
DECLARE_SCOPED_TYPE(StatementScope)

friend class StatementStack;

private:
Expand Down
10 changes: 10 additions & 0 deletions util/include/util/scopedvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

#include <memory>

#define DECLARE_SCOPED_TYPE(type) \
private: \
type(const type&) = delete; \
type(type&&) = delete; \
type& operator=(const type&) = delete; \
type& operator=(type&&) = delete; \


namespace cc
{
namespace util
Expand All @@ -19,6 +27,8 @@ namespace util
template<typename TValue>
class ScopedValue final
{
DECLARE_SCOPED_TYPE(ScopedValue)

private:
TValue& _storage;
TValue _oldValue;
Expand Down

0 comments on commit e77d2cd

Please sign in to comment.