Skip to content

Commit 03ff259

Browse files
committedMay 29, 2014
Refactoring. Remove Owned method from Sema.
llvm-svn: 209812
1 parent ef5f26b commit 03ff259

21 files changed

+585
-724
lines changed
 

‎clang/include/clang/Sema/Sema.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -1036,10 +1036,6 @@ class Sema {
10361036
/// \brief Retrieve the module loader associated with the preprocessor.
10371037
ModuleLoader &getModuleLoader() const;
10381038

1039-
ExprResult Owned(Expr* E) { return E; }
1040-
ExprResult Owned(ExprResult R) { return R; }
1041-
StmtResult Owned(Stmt* S) { return S; }
1042-
10431039
void ActOnEndOfTranslationUnit();
10441040

10451041
void CheckDelegatingCtorCycles();
@@ -7699,8 +7695,8 @@ class Sema {
76997695
Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
77007696
QualType Composite = FindCompositePointerType(Loc, E1Tmp, E2Tmp,
77017697
NonStandardCompositeType);
7702-
E1 = Owned(E1Tmp);
7703-
E2 = Owned(E2Tmp);
7698+
E1 = E1Tmp;
7699+
E2 = E2Tmp;
77047700
return Composite;
77057701
}
77067702

‎clang/lib/Sema/Sema.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
328328
QualType TypeTy = Context.getCanonicalType(Ty);
329329

330330
if (ExprTy == TypeTy)
331-
return Owned(E);
331+
return E;
332332

333333
// If this is a derived-to-base cast to a through a virtual base, we
334334
// need a vtable.
@@ -346,11 +346,11 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
346346
if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
347347
ImpCast->setType(Ty);
348348
ImpCast->setValueKind(VK);
349-
return Owned(E);
349+
return E;
350350
}
351351
}
352352

353-
return Owned(ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK));
353+
return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK);
354354
}
355355

356356
/// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding

‎clang/lib/Sema/SemaCast.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace {
9393
CK_Dependent, castExpr, nullptr,
9494
castExpr->getValueKind());
9595
}
96-
return Self.Owned(castExpr);
96+
return castExpr;
9797
}
9898

9999
// Internal convenience methods.
@@ -239,7 +239,7 @@ ExprResult
239239
Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
240240
TypeSourceInfo *DestTInfo, Expr *E,
241241
SourceRange AngleBrackets, SourceRange Parens) {
242-
ExprResult Ex = Owned(E);
242+
ExprResult Ex = E;
243243
QualType DestType = DestTInfo->getType();
244244

245245
// If the type is dependent, we won't do the semantic analysis now.

‎clang/lib/Sema/SemaChecking.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) {
101101
if (checkArgCount(S, TheCall, 1))
102102
return true;
103103

104-
ExprResult Arg(S.Owned(TheCall->getArg(0)));
104+
ExprResult Arg(TheCall->getArg(0));
105105
QualType ResultType = S.CheckAddressOfOperand(Arg, TheCall->getLocStart());
106106
if (ResultType.isNull())
107107
return true;
@@ -113,7 +113,7 @@ static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) {
113113

114114
ExprResult
115115
Sema::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
116-
ExprResult TheCallResult(Owned(TheCall));
116+
ExprResult TheCallResult(TheCall);
117117

118118
// Find out if any arguments are required to be integer constant expressions.
119119
unsigned ICEArguments = 0;
@@ -1219,7 +1219,7 @@ ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult,
12191219
Diag(AE->getLocStart(), diag::err_atomic_load_store_uses_lib) <<
12201220
((Op == AtomicExpr::AO__c11_atomic_load) ? 0 : 1);
12211221

1222-
return Owned(AE);
1222+
return AE;
12231223
}
12241224

12251225

@@ -1861,9 +1861,9 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
18611861
TheCall->setArg(i, nullptr);
18621862
}
18631863

1864-
return Owned(new (Context) ShuffleVectorExpr(Context, exprs, resType,
1865-
TheCall->getCallee()->getLocStart(),
1866-
TheCall->getRParenLoc()));
1864+
return new (Context) ShuffleVectorExpr(Context, exprs, resType,
1865+
TheCall->getCallee()->getLocStart(),
1866+
TheCall->getRParenLoc());
18671867
}
18681868

18691869
/// SemaConvertVectorExpr - Handle __builtin_convertvector
@@ -1892,9 +1892,8 @@ ExprResult Sema::SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
18921892
<< E->getSourceRange());
18931893
}
18941894

1895-
return Owned(new (Context) ConvertVectorExpr(E, TInfo, DstTy, VK, OK,
1896-
BuiltinLoc, RParenLoc));
1897-
1895+
return new (Context)
1896+
ConvertVectorExpr(E, TInfo, DstTy, VK, OK, BuiltinLoc, RParenLoc);
18981897
}
18991898

19001899
/// SemaBuiltinPrefetch - Handle __builtin_prefetch.

‎clang/lib/Sema/SemaDecl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11453,7 +11453,7 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc,
1145311453
// If the bit-width is type- or value-dependent, don't try to check
1145411454
// it now.
1145511455
if (BitWidth->isValueDependent() || BitWidth->isTypeDependent())
11456-
return Owned(BitWidth);
11456+
return BitWidth;
1145711457

1145811458
llvm::APSInt Value;
1145911459
ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value);
@@ -11500,7 +11500,7 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc,
1150011500
}
1150111501
}
1150211502

11503-
return Owned(BitWidth);
11503+
return BitWidth;
1150411504
}
1150511505

1150611506
/// ActOnField - Each field of a C struct/union is passed into this in order

‎clang/lib/Sema/SemaDeclCXX.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init,
28332833
// initializer. However, deconstructing the ASTs is a dicey process,
28342834
// and this approach is far more likely to get the corner cases right.
28352835
if (CurContext->isDependentContext())
2836-
DelegationInit = Owned(Init);
2836+
DelegationInit = Init;
28372837

28382838
return new (Context) CXXCtorInitializer(Context, TInfo, InitRange.getBegin(),
28392839
DelegationInit.getAs<Expr>(),
@@ -2962,7 +2962,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo,
29622962
// initializer. However, deconstructing the ASTs is a dicey process,
29632963
// and this approach is far more likely to get the corner cases right.
29642964
if (CurContext->isDependentContext())
2965-
BaseInit = Owned(Init);
2965+
BaseInit = Init;
29662966

29672967
return new (Context) CXXCtorInitializer(Context, BaseTInfo,
29682968
BaseSpec->isVirtual(),
@@ -9030,7 +9030,7 @@ buildMemcpyForAssignmentOp(Sema &S, SourceLocation Loc, QualType T,
90309030
Loc, CallArgs, Loc);
90319031

90329032
assert(!Call.isInvalid() && "Call to __builtin_memcpy cannot fail!");
9033-
return S.Owned(Call.getAs<Stmt>());
9033+
return Call.getAs<Stmt>();
90349034
}
90359035

90369036
/// \brief Builds a statement that copies/moves the given entity from \p From to
@@ -10585,12 +10585,11 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
1058510585
unsigned ConstructKind,
1058610586
SourceRange ParenRange) {
1058710587
MarkFunctionReferenced(ConstructLoc, Constructor);
10588-
return Owned(CXXConstructExpr::Create(Context, DeclInitType, ConstructLoc,
10589-
Constructor, Elidable, ExprArgs,
10590-
HadMultipleCandidates,
10591-
IsListInitialization, RequiresZeroInit,
10592-
static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
10593-
ParenRange));
10588+
return CXXConstructExpr::Create(
10589+
Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs,
10590+
HadMultipleCandidates, IsListInitialization, RequiresZeroInit,
10591+
static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
10592+
ParenRange);
1059410593
}
1059510594

1059610595
void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) {

0 commit comments

Comments
 (0)
Please sign in to comment.