From: Dmitri Gribenko Date: Thu, 23 May 2019 09:22:43 +0000 (+0000) Subject: Delete default constructors, copy constructors, move constructors, copy assignment... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=50daf71e99bcbf980f7a4ac067f868cafc7cca67;p=clang Delete default constructors, copy constructors, move constructors, copy assignment, move assignment operators on Expr, Stmt and Decl Reviewers: ilya-biryukov, rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62187 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361468 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 674e0f4a59..cebf2973c8 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -368,6 +368,13 @@ private: return ModuleOwnershipKind::Unowned; } +public: + Decl() = delete; + Decl(const Decl&) = delete; + Decl(Decl &&) = delete; + Decl &operator=(const Decl&) = delete; + Decl &operator=(Decl&&) = delete; + protected: Decl(Kind DK, DeclContext *DC, SourceLocation L) : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)), diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 143eaae37b..96cb8e8f1a 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -108,6 +108,13 @@ struct SubobjectAdjustment { class Expr : public ValueStmt { QualType TR; +public: + Expr() = delete; + Expr(const Expr&) = delete; + Expr(Expr &&) = delete; + Expr &operator=(const Expr&) = delete; + Expr &operator=(Expr&&) = delete; + protected: Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack) diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index a6ab1851fe..8834a60cd6 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1040,6 +1040,12 @@ protected: explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {} public: + Stmt() = delete; + Stmt(const Stmt &) = delete; + Stmt(Stmt &&) = delete; + Stmt &operator=(const Stmt &) = delete; + Stmt &operator=(Stmt &&) = delete; + Stmt(StmtClass SC) { static_assert(sizeof(*this) <= 8, "changing bitfields changed sizeof(Stmt)"); @@ -1054,11 +1060,6 @@ public: return static_cast(StmtBits.sClass); } - Stmt(const Stmt &) = delete; - Stmt(Stmt &&) = delete; - Stmt &operator=(const Stmt &) = delete; - Stmt &operator=(Stmt &&) = delete; - const char *getStmtClassName() const; bool isOMPStructuredBlock() const { return StmtBits.IsOMPStructuredBlock; } diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 34537d3f3e..d59e0fc960 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1134,9 +1134,10 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction( return F; llvm::SmallVector ArgTys; - llvm::SmallVector Params; - Params.emplace_back(Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"), - Ctx.VoidPtrTy, ImplicitParamDecl::Other); + FunctionArgList Args; + Args.push_back(ImplicitParamDecl::Create( + Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"), Ctx.VoidPtrTy, + ImplicitParamDecl::Other)); ArgTys.emplace_back(Ctx.VoidPtrTy); for (unsigned int I = 0, E = Layout.Items.size(); I < E; ++I) { @@ -1145,17 +1146,13 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction( continue; QualType ArgTy = getOSLogArgType(Ctx, Size); - Params.emplace_back( + Args.push_back(ImplicitParamDecl::Create( Ctx, nullptr, SourceLocation(), &Ctx.Idents.get(std::string("arg") + llvm::to_string(I)), ArgTy, - ImplicitParamDecl::Other); + ImplicitParamDecl::Other)); ArgTys.emplace_back(ArgTy); } - FunctionArgList Args; - for (auto &P : Params) - Args.push_back(&P); - QualType ReturnTy = Ctx.VoidTy; QualType FuncionTy = Ctx.getFunctionType(ReturnTy, ArgTys, {}); @@ -1188,7 +1185,7 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction( auto AL = ApplyDebugLocation::CreateArtificial(*this); CharUnits Offset; - Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(&Params[0]), "buf"), + Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(Args[0]), "buf"), BufferAlignment); Builder.CreateStore(Builder.getInt8(Layout.getSummaryByte()), Builder.CreateConstByteGEP(BufAddr, Offset++, "summary")); @@ -1208,7 +1205,7 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction( if (!Size.getQuantity()) continue; - Address Arg = GetAddrOfLocalVar(&Params[I]); + Address Arg = GetAddrOfLocalVar(Args[I]); Address Addr = Builder.CreateConstByteGEP(BufAddr, Offset, "argData"); Addr = Builder.CreateBitCast(Addr, Arg.getPointer()->getType(), "argDataCast");