r203461 - Reverting llvm::distance changes to use std::distance with iterators instead, per post-commit review feedback.
Aaron Ballman
aaron at aaronballman.com
Mon Mar 10 06:43:56 PDT 2014
Author: aaronballman
Date: Mon Mar 10 08:43:55 2014
New Revision: 203461
URL: http://llvm.org/viewvc/llvm-project?rev=203461&view=rev
Log:
Reverting llvm::distance changes to use std::distance with iterators instead, per post-commit review feedback.
Replacing llvm::copy changes with SmallVector range-based construction which is a considerably cleaner approach.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=203461&r1=203460&r2=203461&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Mar 10 08:43:55 2014
@@ -3673,7 +3673,7 @@ static bool HandleConstructorCall(Source
// Reserve space for the struct members.
if (!RD->isUnion() && Result.isUninit())
Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
- llvm::distance(RD->fields()));
+ std::distance(RD->field_begin(), RD->field_end()));
if (RD->isInvalidDecl()) return false;
const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
@@ -3733,7 +3733,7 @@ static bool HandleConstructorCall(Source
*Value = APValue(FD);
else
*Value = APValue(APValue::UninitStruct(), CD->getNumBases(),
- llvm::distance(CD->fields()));
+ std::distance(CD->field_begin(), CD->field_end()));
}
if (!HandleLValueMember(Info, (*I)->getInit(), Subobject, FD))
return false;
@@ -4930,7 +4930,7 @@ static bool HandleClassZeroInitializatio
assert(!RD->isUnion() && "Expected non-union class type");
const CXXRecordDecl *CD = dyn_cast<CXXRecordDecl>(RD);
Result = APValue(APValue::UninitStruct(), CD ? CD->getNumBases() : 0,
- llvm::distance(RD->fields()));
+ std::distance(RD->field_begin(), RD->field_end()));
if (RD->isInvalidDecl()) return false;
const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
@@ -5059,7 +5059,8 @@ bool RecordExprEvaluator::VisitInitListE
assert((!isa<CXXRecordDecl>(RD) || !cast<CXXRecordDecl>(RD)->getNumBases()) &&
"initializer list for class with base classes");
- Result = APValue(APValue::UninitStruct(), 0, llvm::distance(RD->fields()));
+ Result = APValue(APValue::UninitStruct(), 0,
+ std::distance(RD->field_begin(), RD->field_end()));
unsigned ElementNo = 0;
bool Success = true;
for (const auto *Field : RD->fields()) {
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=203461&r1=203460&r2=203461&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Mar 10 08:43:55 2014
@@ -2200,8 +2200,7 @@ void CGObjCCommonMac::BuildRCBlockVarRec
bool &HasUnion,
bool ByrefLayout) {
const RecordDecl *RD = RT->getDecl();
- SmallVector<const FieldDecl*, 16> Fields;
- llvm::copy(RD->fields(), std::back_inserter(Fields));
+ SmallVector<const FieldDecl*, 16> Fields(RD->fields());
llvm::Type *Ty = CGM.getTypes().ConvertType(QualType(RT, 0));
const llvm::StructLayout *RecLayout =
CGM.getDataLayout().getStructLayout(cast<llvm::StructType>(Ty));
@@ -4513,8 +4512,7 @@ void CGObjCCommonMac::BuildAggrIvarRecor
bool &HasUnion) {
const RecordDecl *RD = RT->getDecl();
// FIXME - Use iterator.
- SmallVector<const FieldDecl*, 16> Fields;
- llvm::copy(RD->fields(), std::back_inserter(Fields));
+ SmallVector<const FieldDecl*, 16> Fields(RD->fields());
llvm::Type *Ty = CGM.getTypes().ConvertType(QualType(RT, 0));
const llvm::StructLayout *RecLayout =
CGM.getDataLayout().getStructLayout(cast<llvm::StructType>(Ty));
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=203461&r1=203460&r2=203461&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Mar 10 08:43:55 2014
@@ -2286,7 +2286,7 @@ InitListChecker::getStructuredSubobjectI
if (RDecl->isUnion())
NumElements = 1;
else
- NumElements = llvm::distance(RDecl->fields());
+ NumElements = std::distance(RDecl->field_begin(), RDecl->field_end());
}
Result->reserveInits(SemaRef.Context, NumElements);
Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=203461&r1=203460&r2=203461&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Mon Mar 10 08:43:55 2014
@@ -1146,8 +1146,7 @@ void Sema::ActOnLambdaError(SourceLocati
LambdaScopeInfo *LSI = getCurLambda();
CXXRecordDecl *Class = LSI->Lambda;
Class->setInvalidDecl();
- SmallVector<Decl*, 4> Fields;
- llvm::copy(Class->fields(), std::back_inserter(Fields));
+ SmallVector<Decl*, 4> Fields(Class->fields());
ActOnFields(0, Class->getLocation(), Class, Fields, SourceLocation(),
SourceLocation(), 0);
CheckCompletedCXXClass(Class);
@@ -1507,8 +1506,7 @@ ExprResult Sema::ActOnLambdaExpr(SourceL
addBlockPointerConversion(*this, IntroducerRange, Class, CallOperator);
// Finalize the lambda class.
- SmallVector<Decl*, 4> Fields;
- llvm::copy(Class->fields(), std::back_inserter(Fields));
+ SmallVector<Decl*, 4> Fields(Class->fields());
ActOnFields(0, Class->getLocation(), Class, Fields, SourceLocation(),
SourceLocation(), 0);
CheckCompletedCXXClass(Class);
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=203461&r1=203460&r2=203461&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Mar 10 08:43:55 2014
@@ -3349,8 +3349,7 @@ void Sema::ActOnCapturedRegionError() {
RecordDecl *Record = RSI->TheRecordDecl;
Record->setInvalidDecl();
- SmallVector<Decl*, 4> Fields;
- llvm::copy(Record->fields(), std::back_inserter(Fields));
+ SmallVector<Decl*, 4> Fields(Record->fields());
ActOnFields(/*Scope=*/0, Record->getLocation(), Record, Fields,
SourceLocation(), SourceLocation(), /*AttributeList=*/0);
More information about the cfe-commits
mailing list