Rename Selector::getName() to Selector::getAsString(), and add
a new NamedDecl::getAsString() method.
Change uses of Selector::getName() to just pass in a Selector
where possible (e.g. to diagnostics) instead of going through
an std::string.
This also adds new formatters for objcinstance and objcclass
as described in the dox.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59933 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index be21c36..6b913fb 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -23,22 +23,33 @@
/// ConvertQualTypeToStringFn - This function is used to pretty print the
/// specified QualType as a string in diagnostics.
static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
- const char *Modifier, unsigned ML,
+ const char *Modifier, unsigned ModLen,
const char *Argument, unsigned ArgLen,
llvm::SmallVectorImpl<char> &Output) {
- assert(ML == 0 && ArgLen == 0 && "Invalid modifier for QualType argument");
std::string S;
if (Kind == Diagnostic::ak_qualtype) {
QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast<void*>(Val)));
-
+
// FIXME: Playing with std::string is really slow.
S = Ty.getAsString();
+
+ assert(ModLen == 0 && ArgLen == 0 &&
+ "Invalid modifier for QualType argument");
+
} else {
assert(Kind == Diagnostic::ak_declarationname);
DeclarationName N = DeclarationName::getFromOpaqueInteger(Val);
S = N.getAsString();
+
+ if (ModLen == 9 && !memcmp(Modifier, "objcclass", 9) && ArgLen == 0)
+ S = '+' + S;
+ else if (ModLen == 12 && !memcmp(Modifier, "objcinstance", 12) && ArgLen==0)
+ S = '-' + S;
+ else
+ assert(ModLen == 0 && ArgLen == 0 &&
+ "Invalid modifier for DeclarationName argument");
}
Output.append(S.begin(), S.end());
}