r210750 - Use ArrayRef in some function parameters instead of a pointer and count. No functional change.
Craig Topper
craig.topper at gmail.com
Wed Jun 11 22:32:28 PDT 2014
Author: ctopper
Date: Thu Jun 12 00:32:27 2014
New Revision: 210750
URL: http://llvm.org/viewvc/llvm-project?rev=210750&view=rev
Log:
Use ArrayRef in some function parameters instead of a pointer and count. No functional change.
Modified:
cfe/trunk/include/clang/AST/ASTDiagnostic.h
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/include/clang/AST/ASTDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDiagnostic.h?rev=210750&r1=210749&r2=210750&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTDiagnostic.h (original)
+++ cfe/trunk/include/clang/AST/ASTDiagnostic.h Thu Jun 12 00:32:27 2014
@@ -40,8 +40,7 @@ namespace clang {
unsigned ModLen,
const char *Argument,
unsigned ArgLen,
- const DiagnosticsEngine::ArgumentValue *PrevArgs,
- unsigned NumPrevArgs,
+ ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
void *Cookie,
ArrayRef<intptr_t> QualTypeVals);
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=210750&r1=210749&r2=210750&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Jun 12 00:32:27 2014
@@ -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<ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
void *Cookie,
ArrayRef<intptr_t> 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<ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
ArrayRef<intptr_t> QualTypeVals) const {
ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen,
- PrevArgs, NumPrevArgs, Output, ArgToStringCookie,
+ PrevArgs, Output, ArgToStringCookie,
QualTypeVals);
}
Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=210750&r1=210749&r2=210750&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Thu Jun 12 00:32:27 2014
@@ -162,9 +162,8 @@ break; \
/// diagnostic message
static std::string
ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
- const DiagnosticsEngine::ArgumentValue *PrevArgs,
- unsigned NumPrevArgs,
- ArrayRef<intptr_t> QualTypeVals) {
+ ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
+ ArrayRef<intptr_t> QualTypeVals) {
// FIXME: Playing with std::string is really slow.
bool ForceAKA = false;
QualType CanTy = Ty.getCanonicalType();
@@ -202,7 +201,7 @@ ConvertTypeToDiagnosticString(ASTContext
// 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::FormatASTNodeDiagnosticArgum
unsigned ModLen,
const char *Argument,
unsigned ArgLen,
- const DiagnosticsEngine::ArgumentValue *PrevArgs,
- unsigned NumPrevArgs,
+ ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
void *Cookie,
ArrayRef<intptr_t> QualTypeVals) {
@@ -306,8 +304,7 @@ void clang::FormatASTNodeDiagnosticArgum
"Invalid modifier for QualType argument");
QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast<void*>(Val)));
- OS << ConvertTypeToDiagnosticString(Context, Ty, PrevArgs, NumPrevArgs,
- QualTypeVals);
+ OS << ConvertTypeToDiagnosticString(Context, Ty, PrevArgs, QualTypeVals);
NeedQuotes = false;
break;
}
@@ -357,8 +354,7 @@ void clang::FormatASTNodeDiagnosticArgum
} else if (TypeDecl *Type = dyn_cast<TypeDecl>(DC)) {
OS << ConvertTypeToDiagnosticString(Context,
Context.getTypeDeclType(Type),
- PrevArgs, NumPrevArgs,
- QualTypeVals);
+ PrevArgs, QualTypeVals);
} else {
// FIXME: Get these strings from some localized place
if (isa<BlockDecl>(DC)) {
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=210750&r1=210749&r2=210750&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Jun 12 00:32:27 2014
@@ -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<char> &Output,
- void *Cookie,
- ArrayRef<intptr_t> QualTypeVals) {
- const char *Str = "<can't format argument>";
- Output.append(Str, Str+strlen(Str));
+ const char *Modifier, unsigned ML,
+ const char *Argument, unsigned ArgLen,
+ ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
+ SmallVectorImpl<char> &Output,
+ void *Cookie,
+ ArrayRef<intptr_t> QualTypeVals) {
+ StringRef Str = "<can't format argument>";
+ Output.append(Str.begin(), Str.end());
}
@@ -830,7 +829,7 @@ FormatDiagnostic(const char *DiagStr, co
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, co
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, co
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, co
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,
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=210750&r1=210749&r2=210750&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun 12 00:32:27 2014
@@ -2101,7 +2101,7 @@ llvm::Constant *CodeGenFunction::EmitChe
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<intptr_t>());
llvm::Constant *Components[] = {
More information about the cfe-commits
mailing list