[cfe-commits] r66314 - in /cfe/trunk: include/clang/Basic/Diagnostic.h include/clang/Basic/IdentifierTable.h lib/Basic/Diagnostic.cpp lib/Sema/SemaDeclObjC.cpp
Ted Kremenek
kremenek at apple.com
Fri Mar 6 17:36:13 PST 2009
Author: kremenek
Date: Fri Mar 6 19:36:13 2009
New Revision: 66314
URL: http://llvm.org/viewvc/llvm-project?rev=66314&view=rev
Log:
Teach Diagnostic about Selector.
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=66314&r1=66313&r2=66314&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Fri Mar 6 19:36:13 2009
@@ -15,6 +15,7 @@
#define LLVM_CLANG_DIAGNOSTIC_H
#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/IdentifierTable.h"
#include <string>
#include <cassert>
@@ -26,7 +27,6 @@
class DiagnosticClient;
class SourceRange;
class DiagnosticBuilder;
- class IdentifierInfo;
// Import the diagnostic enums themselves.
namespace diag {
@@ -142,7 +142,8 @@
ak_identifierinfo, // IdentifierInfo
ak_qualtype, // QualType
ak_declarationname, // DeclarationName
- ak_nameddecl // NamedDecl *
+ ak_nameddecl, // NamedDecl *
+ ak_selector // Selector
};
private:
@@ -484,6 +485,13 @@
}
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 DB;
@@ -566,6 +574,12 @@
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 &&
Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=66314&r1=66313&r2=66314&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Fri Mar 6 19:36:13 2009
@@ -334,6 +334,8 @@
/// 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,
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=66314&r1=66313&r2=66314&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Fri Mar 6 19:36:13 2009
@@ -657,6 +657,14 @@
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:
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=66314&r1=66313&r2=66314&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Mar 6 19:36:13 2009
@@ -1139,7 +1139,7 @@
Diag(property->getLocation(),
diag::err_accessor_property_type_mismatch)
<< property->getDeclName()
- << GetterMethod->getSelector().getAsString();
+ << GetterMethod->getSelector();
Diag(GetterMethod->getLocation(), diag::note_declared_at);
}
@@ -1152,7 +1152,7 @@
Diag(property->getLocation(),
diag::err_accessor_property_type_mismatch)
<< property->getDeclName()
- << SetterMethod->getSelector().getAsString();
+ << SetterMethod->getSelector();
Diag(SetterMethod->getLocation(), diag::note_declared_at);
}
}
More information about the cfe-commits
mailing list