From: Craig Topper Date: Wed, 21 Oct 2015 02:34:10 +0000 (+0000) Subject: Use ArrayRef and MutableArrayRef instead of a pointer and size. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36f756d3ceecc8c70c1acffce59256d5583b90aa;p=clang Use ArrayRef and MutableArrayRef instead of a pointer and size. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250876 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index 054d55023c..b0c83498c2 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -648,8 +648,7 @@ public: // a constraint is valid and provides information about it. // FIXME: These should return a real error instead of just true/false. bool validateOutputConstraint(ConstraintInfo &Info) const; - bool validateInputConstraint(ConstraintInfo *OutputConstraints, - unsigned NumOutputs, + bool validateInputConstraint(MutableArrayRef OutputConstraints, ConstraintInfo &info) const; virtual bool validateOutputSize(StringRef /*Constraint*/, @@ -673,8 +672,8 @@ public: TargetInfo::ConstraintInfo &info) const = 0; bool resolveSymbolicName(const char *&Name, - ConstraintInfo *OutputConstraints, - unsigned NumOutputs, unsigned &Index) const; + ArrayRef OutputConstraints, + unsigned &Index) const; // Constraint parm will be left pointing at the last character of // the constraint. In practice, it won't be changed unless the diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 21368f8b11..eca3a6f710 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -510,8 +510,7 @@ bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const { } bool TargetInfo::resolveSymbolicName(const char *&Name, - ConstraintInfo *OutputConstraints, - unsigned NumOutputs, + ArrayRef OutputConstraints, unsigned &Index) const { assert(*Name == '[' && "Symbolic name did not start with '['"); Name++; @@ -526,16 +525,16 @@ bool TargetInfo::resolveSymbolicName(const char *&Name, std::string SymbolicName(Start, Name - Start); - for (Index = 0; Index != NumOutputs; ++Index) + for (Index = 0; Index != OutputConstraints.size(); ++Index) if (SymbolicName == OutputConstraints[Index].getName()) return true; return false; } -bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints, - unsigned NumOutputs, - ConstraintInfo &Info) const { +bool TargetInfo::validateInputConstraint( + MutableArrayRef OutputConstraints, + ConstraintInfo &Info) const { const char *Name = Info.ConstraintStr.c_str(); if (!*Name) @@ -556,7 +555,7 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints, return false; // Check if matching constraint is out of bounds. - if (i >= NumOutputs) return false; + if (i >= OutputConstraints.size()) return false; // A number must refer to an output only operand. if (OutputConstraints[i].isReadWrite()) @@ -579,7 +578,7 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints, break; case '[': { unsigned Index = 0; - if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index)) + if (!resolveSymbolicName(Name, OutputConstraints, Index)) return false; // If the constraint is already tied, it must be tied to the diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 1ca119ef98..f915518c26 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1587,9 +1587,7 @@ SimplifyConstraint(const char *Constraint, const TargetInfo &Target, assert(OutCons && "Must pass output names to constraints with a symbolic name"); unsigned Index; - bool result = Target.resolveSymbolicName(Constraint, - &(*OutCons)[0], - OutCons->size(), Index); + bool result = Target.resolveSymbolicName(Constraint, *OutCons, Index); assert(result && "Could not resolve symbolic name"); (void)result; Result += llvm::utostr(Index); break; @@ -1744,8 +1742,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { Name = GAS->getInputName(i); TargetInfo::ConstraintInfo Info(S.getInputConstraint(i), Name); bool IsValid = - getTarget().validateInputConstraint(OutputConstraintInfos.data(), - S.getNumOutputs(), Info); + getTarget().validateInputConstraint(OutputConstraintInfos, Info); assert(IsValid && "Failed to parse input constraint"); (void)IsValid; InputConstraintInfos.push_back(Info); } diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index 79c06367e0..bb6657b803 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -252,8 +252,8 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, InputName = Names[i]->getName(); TargetInfo::ConstraintInfo Info(Literal->getString(), InputName); - if (!Context.getTargetInfo().validateInputConstraint( - OutputConstraintInfos.data(), NumOutputs, Info)) { + if (!Context.getTargetInfo().validateInputConstraint(OutputConstraintInfos, + Info)) { return StmtError(Diag(Literal->getLocStart(), diag::err_asm_invalid_input_constraint) << Info.getConstraintStr());