From e47535041c085fba2a8ad11fcb576e3d2c45fe73 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 12 Jun 2014 05:32:27 +0000 Subject: [PATCH] Use ArrayRef in some function parameters instead of a pointer and count. No functional change. llvm-svn: 210750 --- clang/include/clang/AST/ASTDiagnostic.h | 3 +-- clang/include/clang/Basic/Diagnostic.h | 13 ++++++------- clang/lib/AST/ASTDiagnostic.cpp | 16 ++++++---------- clang/lib/Basic/Diagnostic.cpp | 26 ++++++++++++-------------- clang/lib/CodeGen/CGExpr.cpp | 2 +- 5 files changed, 26 insertions(+), 34 deletions(-) diff --git a/clang/include/clang/AST/ASTDiagnostic.h b/clang/include/clang/AST/ASTDiagnostic.h index 1635511..efde942 100644 --- a/clang/include/clang/AST/ASTDiagnostic.h +++ b/clang/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/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index 4270c0f..aa3947a 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/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/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 70073ff..a9d8cbf 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/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/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 6cf3c5c..1956133 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/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/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 7c2c739..4c3d0f4 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/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[] = { -- 2.7.4