Skip to content

Commit 3919204

Browse files
committed
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 llvm-svn: 361468
1 parent 50434e8 commit 3919204

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

clang/include/clang/AST/DeclBase.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,13 @@ class alignas(8) Decl {
368368
return ModuleOwnershipKind::Unowned;
369369
}
370370

371+
public:
372+
Decl() = delete;
373+
Decl(const Decl&) = delete;
374+
Decl(Decl &&) = delete;
375+
Decl &operator=(const Decl&) = delete;
376+
Decl &operator=(Decl&&) = delete;
377+
371378
protected:
372379
Decl(Kind DK, DeclContext *DC, SourceLocation L)
373380
: NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),

clang/include/clang/AST/Expr.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ struct SubobjectAdjustment {
108108
class Expr : public ValueStmt {
109109
QualType TR;
110110

111+
public:
112+
Expr() = delete;
113+
Expr(const Expr&) = delete;
114+
Expr(Expr &&) = delete;
115+
Expr &operator=(const Expr&) = delete;
116+
Expr &operator=(Expr&&) = delete;
117+
111118
protected:
112119
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK,
113120
bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)

clang/include/clang/AST/Stmt.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,12 @@ class alignas(void *) Stmt {
10401040
explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {}
10411041

10421042
public:
1043+
Stmt() = delete;
1044+
Stmt(const Stmt &) = delete;
1045+
Stmt(Stmt &&) = delete;
1046+
Stmt &operator=(const Stmt &) = delete;
1047+
Stmt &operator=(Stmt &&) = delete;
1048+
10431049
Stmt(StmtClass SC) {
10441050
static_assert(sizeof(*this) <= 8,
10451051
"changing bitfields changed sizeof(Stmt)");
@@ -1054,11 +1060,6 @@ class alignas(void *) Stmt {
10541060
return static_cast<StmtClass>(StmtBits.sClass);
10551061
}
10561062

1057-
Stmt(const Stmt &) = delete;
1058-
Stmt(Stmt &&) = delete;
1059-
Stmt &operator=(const Stmt &) = delete;
1060-
Stmt &operator=(Stmt &&) = delete;
1061-
10621063
const char *getStmtClassName() const;
10631064

10641065
bool isOMPStructuredBlock() const { return StmtBits.IsOMPStructuredBlock; }

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,9 +1134,10 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction(
11341134
return F;
11351135

11361136
llvm::SmallVector<QualType, 4> ArgTys;
1137-
llvm::SmallVector<ImplicitParamDecl, 4> Params;
1138-
Params.emplace_back(Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"),
1139-
Ctx.VoidPtrTy, ImplicitParamDecl::Other);
1137+
FunctionArgList Args;
1138+
Args.push_back(ImplicitParamDecl::Create(
1139+
Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"), Ctx.VoidPtrTy,
1140+
ImplicitParamDecl::Other));
11401141
ArgTys.emplace_back(Ctx.VoidPtrTy);
11411142

11421143
for (unsigned int I = 0, E = Layout.Items.size(); I < E; ++I) {
@@ -1145,17 +1146,13 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction(
11451146
continue;
11461147

11471148
QualType ArgTy = getOSLogArgType(Ctx, Size);
1148-
Params.emplace_back(
1149+
Args.push_back(ImplicitParamDecl::Create(
11491150
Ctx, nullptr, SourceLocation(),
11501151
&Ctx.Idents.get(std::string("arg") + llvm::to_string(I)), ArgTy,
1151-
ImplicitParamDecl::Other);
1152+
ImplicitParamDecl::Other));
11521153
ArgTys.emplace_back(ArgTy);
11531154
}
11541155

1155-
FunctionArgList Args;
1156-
for (auto &P : Params)
1157-
Args.push_back(&P);
1158-
11591156
QualType ReturnTy = Ctx.VoidTy;
11601157
QualType FuncionTy = Ctx.getFunctionType(ReturnTy, ArgTys, {});
11611158

@@ -1188,7 +1185,7 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction(
11881185
auto AL = ApplyDebugLocation::CreateArtificial(*this);
11891186

11901187
CharUnits Offset;
1191-
Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(&Params[0]), "buf"),
1188+
Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(Args[0]), "buf"),
11921189
BufferAlignment);
11931190
Builder.CreateStore(Builder.getInt8(Layout.getSummaryByte()),
11941191
Builder.CreateConstByteGEP(BufAddr, Offset++, "summary"));
@@ -1208,7 +1205,7 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction(
12081205
if (!Size.getQuantity())
12091206
continue;
12101207

1211-
Address Arg = GetAddrOfLocalVar(&Params[I]);
1208+
Address Arg = GetAddrOfLocalVar(Args[I]);
12121209
Address Addr = Builder.CreateConstByteGEP(BufAddr, Offset, "argData");
12131210
Addr = Builder.CreateBitCast(Addr, Arg.getPointer()->getType(),
12141211
"argDataCast");

0 commit comments

Comments
 (0)