diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-10-22 04:59:59 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-10-22 04:59:59 +0000 |
commit | b5518246b25cf6f3fd8ccc2aaef8b943ae292f9c (patch) | |
tree | 6320f2e7e8d21f543ca5b6225b69c92feac98c47 /clang/lib/Sema/SemaExpr.cpp | |
parent | a9247eb2b14198d6a87265fa824810fbb89b3589 (diff) | |
download | bcm5719-llvm-b5518246b25cf6f3fd8ccc2aaef8b943ae292f9c.tar.gz bcm5719-llvm-b5518246b25cf6f3fd8ccc2aaef8b943ae292f9c.zip |
Use an ArrayRef<OffsetOfComponent> instead of pointer and size throughout offsetof handling code. Also use a range-based for loop. NFC
llvm-svn: 250989
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f3262852855..1b43f92128e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -11137,8 +11137,7 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, - OffsetOfComponent *CompPtr, - unsigned NumComponents, + ArrayRef<OffsetOfComponent> Components, SourceLocation RParenLoc) { QualType ArgTy = TInfo->getType(); bool Dependent = ArgTy->isDependentType(); @@ -11162,17 +11161,16 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, // GCC extension, diagnose them. // FIXME: This diagnostic isn't actually visible because the location is in // a system header! - if (NumComponents != 1) + if (Components.size() != 1) Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator) - << SourceRange(CompPtr[1].LocStart, CompPtr[NumComponents-1].LocEnd); + << SourceRange(Components[1].LocStart, Components.back().LocEnd); bool DidWarnAboutNonPOD = false; QualType CurrentType = ArgTy; typedef OffsetOfExpr::OffsetOfNode OffsetOfNode; SmallVector<OffsetOfNode, 4> Comps; SmallVector<Expr*, 4> Exprs; - for (unsigned i = 0; i != NumComponents; ++i) { - const OffsetOfComponent &OC = CompPtr[i]; + for (const OffsetOfComponent &OC : Components) { if (OC.isBrackets) { // Offset of an array sub-field. TODO: Should we allow vector elements? if (!CurrentType->isDependentType()) { @@ -11240,7 +11238,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, if (!IsSafe && !DidWarnAboutNonPOD && DiagRuntimeBehavior(BuiltinLoc, nullptr, PDiag(DiagID) - << SourceRange(CompPtr[0].LocStart, OC.LocEnd) + << SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType)) DidWarnAboutNonPOD = true; } @@ -11313,8 +11311,7 @@ ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, - OffsetOfComponent *CompPtr, - unsigned NumComponents, + ArrayRef<OffsetOfComponent> Components, SourceLocation RParenLoc) { TypeSourceInfo *ArgTInfo; @@ -11325,8 +11322,7 @@ ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, if (!ArgTInfo) ArgTInfo = Context.getTrivialTypeSourceInfo(ArgTy, TypeLoc); - return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, CompPtr, NumComponents, - RParenLoc); + return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc); } |