diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-24 03:33:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-24 03:33:13 +0000 |
commit | 077bf5e2f48acfa9e7d69429b6e4ba86ea14896d (patch) | |
tree | 55c540d3cfe45fb990f27b56635fcec5865bcc16 /lib/Sema/Sema.cpp | |
parent | d0fd3b747c46211c481021ffb9cabd5635f918ed (diff) |
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
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index be21c36073..6b913fb215 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -23,22 +23,33 @@ using namespace clang; /// 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()); } |