#define LLVM_CLANG_DIAGNOSTIC_H
#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/IdentifierTable.h"
#include <string>
#include <cassert>
class DiagnosticClient;
class SourceRange;
class DiagnosticBuilder;
- class IdentifierInfo;
// Import the diagnostic enums themselves.
namespace diag {
ak_identifierinfo, // IdentifierInfo
ak_qualtype, // QualType
ak_declarationname, // DeclarationName
- ak_nameddecl // NamedDecl *
+ ak_nameddecl, // NamedDecl *
+ ak_selector // Selector
};
private:
return DB;
}
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ Selector S) {
+ DB.AddTaggedVal(reinterpret_cast<intptr_t>(S.getAsOpaquePtr()),
+ Diagnostic::ak_selector);
+ return DB;
+}
+
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const SourceRange &R) {
DB.AddSourceRange(R);
return reinterpret_cast<IdentifierInfo*>(DiagObj->DiagArgumentsVal[Idx]);
}
+ /// getArgSelector - Return the specified Selector argument.
+ Selector getArgSelector(unsigned Idx) const {
+ assert(getArgKind(Idx) == Diagnostic::ak_selector &&
+ "invalid argument accessor!");
+ return Selector(DiagObj->DiagArgumentsVal[Idx]);
+ }
/// getRawArg - Return the specified non-string argument in an opaque form.
intptr_t getRawArg(unsigned Idx) const {
assert(getArgKind(Idx) != Diagnostic::ak_std_string &&
/// selectors that take no arguments and selectors that take 1 argument, which
/// accounts for 78% of all selectors in Cocoa.h.
class Selector {
+ friend class DiagnosticInfo;
+
enum IdentifierInfoFlag {
// MultiKeywordSelector = 0.
ZeroArg = 0x1,
OutStr.push_back('\'');
break;
}
+ case Diagnostic::ak_selector: {
+ Selector S = getArgSelector(ArgNo);
+ OutStr.push_back('\'');
+ const std::string &s = S.getAsString();
+ OutStr.append(&s[0], &s[0]+s.length());
+ OutStr.push_back('\'');
+ break;
+ }
case Diagnostic::ak_qualtype:
case Diagnostic::ak_declarationname:
case Diagnostic::ak_nameddecl:
Diag(property->getLocation(),
diag::err_accessor_property_type_mismatch)
<< property->getDeclName()
- << GetterMethod->getSelector().getAsString();
+ << GetterMethod->getSelector();
Diag(GetterMethod->getLocation(), diag::note_declared_at);
}
Diag(property->getLocation(),
diag::err_accessor_property_type_mismatch)
<< property->getDeclName()
- << SetterMethod->getSelector().getAsString();
+ << SetterMethod->getSelector();
Diag(SetterMethod->getLocation(), diag::note_declared_at);
}
}