From: Craig Topper Date: Thu, 12 Jun 2014 05:32:27 +0000 (+0000) Subject: Use ArrayRef in some function parameters instead of a pointer and count. No functiona... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a063bbd479937b8c6ed37ce1b1f8810e1825c7de;p=clang Use ArrayRef in some function parameters instead of a pointer and count. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210750 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ASTDiagnostic.h b/include/clang/AST/ASTDiagnostic.h index 1635511984..efde942d85 100644 --- a/include/clang/AST/ASTDiagnostic.h +++ b/include/clang/AST/ASTDiagnostic.h @@ -40,8 +40,7 @@ namespace clang { unsigned ModLen, const char *Argument, unsigned ArgLen, - const DiagnosticsEngine::ArgumentValue *PrevArgs, - unsigned NumPrevArgs, + ArrayRef PrevArgs, SmallVectorImpl &Output, void *Cookie, ArrayRef QualTypeVals); diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 4270c0f286..aa3947a05a 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -316,17 +316,16 @@ private: /// /// This takes the modifiers and argument that was present in the diagnostic. /// - /// The PrevArgs array (whose length is NumPrevArgs) indicates the previous - /// arguments formatted for this diagnostic. Implementations of this function - /// can use this information to avoid redundancy across arguments. + /// The PrevArgs array indicates the previous arguments formatted for this + /// diagnostic. Implementations of this function can use this information to + /// avoid redundancy across arguments. /// /// This is a hack to avoid a layering violation between libbasic and libsema. typedef void (*ArgToStringFnTy)( ArgumentKind Kind, intptr_t Val, const char *Modifier, unsigned ModifierLen, const char *Argument, unsigned ArgumentLen, - const ArgumentValue *PrevArgs, - unsigned NumPrevArgs, + ArrayRef PrevArgs, SmallVectorImpl &Output, void *Cookie, ArrayRef QualTypeVals); @@ -620,11 +619,11 @@ public: void ConvertArgToString(ArgumentKind Kind, intptr_t Val, const char *Modifier, unsigned ModLen, const char *Argument, unsigned ArgLen, - const ArgumentValue *PrevArgs, unsigned NumPrevArgs, + ArrayRef PrevArgs, SmallVectorImpl &Output, ArrayRef QualTypeVals) const { ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen, - PrevArgs, NumPrevArgs, Output, ArgToStringCookie, + PrevArgs, Output, ArgToStringCookie, QualTypeVals); } diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index 70073ff237..a9d8cbf17d 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -162,9 +162,8 @@ break; \ /// diagnostic message static std::string ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, - const DiagnosticsEngine::ArgumentValue *PrevArgs, - unsigned NumPrevArgs, - ArrayRef QualTypeVals) { + ArrayRef PrevArgs, + ArrayRef QualTypeVals) { // FIXME: Playing with std::string is really slow. bool ForceAKA = false; QualType CanTy = Ty.getCanonicalType(); @@ -202,7 +201,7 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, // Check to see if we already desugared this type in this // diagnostic. If so, don't do it again. bool Repeated = false; - for (unsigned i = 0; i != NumPrevArgs; ++i) { + for (unsigned i = 0, e = PrevArgs.size(); i != e; ++i) { // TODO: Handle ak_declcontext case. if (PrevArgs[i].first == DiagnosticsEngine::ak_qualtype) { void *Ptr = (void*)PrevArgs[i].second; @@ -261,8 +260,7 @@ void clang::FormatASTNodeDiagnosticArgument( unsigned ModLen, const char *Argument, unsigned ArgLen, - const DiagnosticsEngine::ArgumentValue *PrevArgs, - unsigned NumPrevArgs, + ArrayRef PrevArgs, SmallVectorImpl &Output, void *Cookie, ArrayRef QualTypeVals) { @@ -306,8 +304,7 @@ void clang::FormatASTNodeDiagnosticArgument( "Invalid modifier for QualType argument"); QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast(Val))); - OS << ConvertTypeToDiagnosticString(Context, Ty, PrevArgs, NumPrevArgs, - QualTypeVals); + OS << ConvertTypeToDiagnosticString(Context, Ty, PrevArgs, QualTypeVals); NeedQuotes = false; break; } @@ -357,8 +354,7 @@ void clang::FormatASTNodeDiagnosticArgument( } else if (TypeDecl *Type = dyn_cast(DC)) { OS << ConvertTypeToDiagnosticString(Context, Context.getTypeDeclType(Type), - PrevArgs, NumPrevArgs, - QualTypeVals); + PrevArgs, QualTypeVals); } else { // FIXME: Get these strings from some localized place if (isa(DC)) { diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 6cf3c5c2eb..1956133703 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -24,15 +24,14 @@ using namespace clang; static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT, - const char *Modifier, unsigned ML, - const char *Argument, unsigned ArgLen, - const DiagnosticsEngine::ArgumentValue *PrevArgs, - unsigned NumPrevArgs, - SmallVectorImpl &Output, - void *Cookie, - ArrayRef QualTypeVals) { - const char *Str = ""; - Output.append(Str, Str+strlen(Str)); + const char *Modifier, unsigned ML, + const char *Argument, unsigned ArgLen, + ArrayRef PrevArgs, + SmallVectorImpl &Output, + void *Cookie, + ArrayRef QualTypeVals) { + StringRef Str = ""; + Output.append(Str.begin(), Str.end()); } @@ -830,7 +829,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo), Modifier, ModifierLen, Argument, ArgumentLen, - FormattedArgs.data(), FormattedArgs.size(), + FormattedArgs, OutStr, QualTypeVals); break; case DiagnosticsEngine::ak_qualtype_pair: @@ -854,8 +853,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, getDiags()->ConvertArgToString(Kind, val, Modifier, ModifierLen, Argument, ArgumentLen, - FormattedArgs.data(), - FormattedArgs.size(), + FormattedArgs, Tree, QualTypeVals); // If there is no tree information, fall back to regular printing. if (!Tree.empty()) { @@ -878,7 +876,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, getDiags()->ConvertArgToString(Kind, val, Modifier, ModifierLen, Argument, ArgumentLen, - FormattedArgs.data(), FormattedArgs.size(), + FormattedArgs, OutStr, QualTypeVals); if (!TDT.TemplateDiffUsed) FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, @@ -892,7 +890,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, getDiags()->ConvertArgToString(Kind, val, Modifier, ModifierLen, Argument, ArgumentLen, - FormattedArgs.data(), FormattedArgs.size(), + FormattedArgs, OutStr, QualTypeVals); if (!TDT.TemplateDiffUsed) FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 7c2c739cf6..4c3d0f4066 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2101,7 +2101,7 @@ llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor(QualType T) { SmallString<32> Buffer; CGM.getDiags().ConvertArgToString(DiagnosticsEngine::ak_qualtype, (intptr_t)T.getAsOpaquePtr(), - nullptr, 0, nullptr, 0, nullptr, 0, Buffer, + nullptr, 0, nullptr, 0, None, Buffer, ArrayRef()); llvm::Constant *Components[] = {