forked from OSchip/llvm-project
Use StringRef to simplify code. No functional change.
llvm-svn: 210751
This commit is contained in:
parent
e47535041c
commit
3aa4fb3b8b
|
@ -36,10 +36,8 @@ namespace clang {
|
|||
void FormatASTNodeDiagnosticArgument(
|
||||
DiagnosticsEngine::ArgumentKind Kind,
|
||||
intptr_t Val,
|
||||
const char *Modifier,
|
||||
unsigned ModLen,
|
||||
const char *Argument,
|
||||
unsigned ArgLen,
|
||||
StringRef Modifier,
|
||||
StringRef Argument,
|
||||
ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
|
||||
SmallVectorImpl<char> &Output,
|
||||
void *Cookie,
|
||||
|
|
|
@ -323,8 +323,7 @@ private:
|
|||
/// 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,
|
||||
StringRef Modifier, StringRef Argument,
|
||||
ArrayRef<ArgumentValue> PrevArgs,
|
||||
SmallVectorImpl<char> &Output,
|
||||
void *Cookie,
|
||||
|
@ -617,14 +616,12 @@ public:
|
|||
/// \brief Converts a diagnostic argument (as an intptr_t) into the string
|
||||
/// that represents it.
|
||||
void ConvertArgToString(ArgumentKind Kind, intptr_t Val,
|
||||
const char *Modifier, unsigned ModLen,
|
||||
const char *Argument, unsigned ArgLen,
|
||||
StringRef Modifier, StringRef Argument,
|
||||
ArrayRef<ArgumentValue> PrevArgs,
|
||||
SmallVectorImpl<char> &Output,
|
||||
ArrayRef<intptr_t> QualTypeVals) const {
|
||||
ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen,
|
||||
PrevArgs, Output, ArgToStringCookie,
|
||||
QualTypeVals);
|
||||
ArgToStringFn(Kind, Val, Modifier, Argument, PrevArgs, Output,
|
||||
ArgToStringCookie, QualTypeVals);
|
||||
}
|
||||
|
||||
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie) {
|
||||
|
|
|
@ -256,10 +256,8 @@ static bool FormatTemplateTypeDiff(ASTContext &Context, QualType FromType,
|
|||
void clang::FormatASTNodeDiagnosticArgument(
|
||||
DiagnosticsEngine::ArgumentKind Kind,
|
||||
intptr_t Val,
|
||||
const char *Modifier,
|
||||
unsigned ModLen,
|
||||
const char *Argument,
|
||||
unsigned ArgLen,
|
||||
StringRef Modifier,
|
||||
StringRef Argument,
|
||||
ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
|
||||
SmallVectorImpl<char> &Output,
|
||||
void *Cookie,
|
||||
|
@ -295,12 +293,12 @@ void clang::FormatASTNodeDiagnosticArgument(
|
|||
// Attempting to do a template diff on non-templates. Set the variables
|
||||
// and continue with regular type printing of the appropriate type.
|
||||
Val = TDT.PrintFromType ? TDT.FromType : TDT.ToType;
|
||||
ModLen = 0;
|
||||
ArgLen = 0;
|
||||
Modifier = StringRef();
|
||||
Argument = StringRef();
|
||||
// Fall through
|
||||
}
|
||||
case DiagnosticsEngine::ak_qualtype: {
|
||||
assert(ModLen == 0 && ArgLen == 0 &&
|
||||
assert(Modifier.empty() && Argument.empty() &&
|
||||
"Invalid modifier for QualType argument");
|
||||
|
||||
QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast<void*>(Val)));
|
||||
|
@ -309,13 +307,12 @@ void clang::FormatASTNodeDiagnosticArgument(
|
|||
break;
|
||||
}
|
||||
case DiagnosticsEngine::ak_declarationname: {
|
||||
if (ModLen == 9 && !memcmp(Modifier, "objcclass", 9) && ArgLen == 0)
|
||||
if (Modifier == "objcclass" && Argument.empty())
|
||||
OS << '+';
|
||||
else if (ModLen == 12 && !memcmp(Modifier, "objcinstance", 12)
|
||||
&& ArgLen==0)
|
||||
else if (Modifier == "objcinstance" && Argument.empty())
|
||||
OS << '-';
|
||||
else
|
||||
assert(ModLen == 0 && ArgLen == 0 &&
|
||||
assert(Modifier.empty() && Argument.empty() &&
|
||||
"Invalid modifier for DeclarationName argument");
|
||||
|
||||
OS << DeclarationName::getFromOpaqueInteger(Val);
|
||||
|
@ -323,10 +320,10 @@ void clang::FormatASTNodeDiagnosticArgument(
|
|||
}
|
||||
case DiagnosticsEngine::ak_nameddecl: {
|
||||
bool Qualified;
|
||||
if (ModLen == 1 && Modifier[0] == 'q' && ArgLen == 0)
|
||||
if (Modifier == "q" && Argument.empty())
|
||||
Qualified = true;
|
||||
else {
|
||||
assert(ModLen == 0 && ArgLen == 0 &&
|
||||
assert(Modifier.empty() && Argument.empty() &&
|
||||
"Invalid modifier for NamedDecl* argument");
|
||||
Qualified = false;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
using namespace clang;
|
||||
|
||||
static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
|
||||
const char *Modifier, unsigned ML,
|
||||
const char *Argument, unsigned ArgLen,
|
||||
StringRef Modifier, StringRef Argument,
|
||||
ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
|
||||
SmallVectorImpl<char> &Output,
|
||||
void *Cookie,
|
||||
|
@ -827,8 +826,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
|
|||
case DiagnosticsEngine::ak_declcontext:
|
||||
case DiagnosticsEngine::ak_attr:
|
||||
getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo),
|
||||
Modifier, ModifierLen,
|
||||
Argument, ArgumentLen,
|
||||
StringRef(Modifier, ModifierLen),
|
||||
StringRef(Argument, ArgumentLen),
|
||||
FormattedArgs,
|
||||
OutStr, QualTypeVals);
|
||||
break;
|
||||
|
@ -851,8 +850,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
|
|||
TDT.PrintFromType = true;
|
||||
TDT.PrintTree = true;
|
||||
getDiags()->ConvertArgToString(Kind, val,
|
||||
Modifier, ModifierLen,
|
||||
Argument, ArgumentLen,
|
||||
StringRef(Modifier, ModifierLen),
|
||||
StringRef(Argument, ArgumentLen),
|
||||
FormattedArgs,
|
||||
Tree, QualTypeVals);
|
||||
// If there is no tree information, fall back to regular printing.
|
||||
|
@ -874,8 +873,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
|
|||
TDT.PrintTree = false;
|
||||
TDT.PrintFromType = true;
|
||||
getDiags()->ConvertArgToString(Kind, val,
|
||||
Modifier, ModifierLen,
|
||||
Argument, ArgumentLen,
|
||||
StringRef(Modifier, ModifierLen),
|
||||
StringRef(Argument, ArgumentLen),
|
||||
FormattedArgs,
|
||||
OutStr, QualTypeVals);
|
||||
if (!TDT.TemplateDiffUsed)
|
||||
|
@ -888,8 +887,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
|
|||
// Append second type
|
||||
TDT.PrintFromType = false;
|
||||
getDiags()->ConvertArgToString(Kind, val,
|
||||
Modifier, ModifierLen,
|
||||
Argument, ArgumentLen,
|
||||
StringRef(Modifier, ModifierLen),
|
||||
StringRef(Argument, ArgumentLen),
|
||||
FormattedArgs,
|
||||
OutStr, QualTypeVals);
|
||||
if (!TDT.TemplateDiffUsed)
|
||||
|
|
|
@ -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, None, Buffer,
|
||||
StringRef(), StringRef(), None, Buffer,
|
||||
ArrayRef<intptr_t>());
|
||||
|
||||
llvm::Constant *Components[] = {
|
||||
|
|
Loading…
Reference in New Issue