summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/Lex/IdentifierTable.cpp8
-rw-r--r--clang/Sema/Sema.h6
-rw-r--r--clang/Sema/SemaDecl.cpp23
-rw-r--r--clang/include/clang/Lex/IdentifierTable.h34
4 files changed, 55 insertions, 16 deletions
diff --git a/clang/Lex/IdentifierTable.cpp b/clang/Lex/IdentifierTable.cpp
index 2ca1225b176..f3a6cf7175f 100644
--- a/clang/Lex/IdentifierTable.cpp
+++ b/clang/Lex/IdentifierTable.cpp
@@ -16,6 +16,7 @@
#include "clang/Lex/MacroInfo.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/DenseMap.h"
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -215,10 +216,16 @@ void IdentifierTable::PrintStats() const {
// SelectorTable Implementation
//===----------------------------------------------------------------------===//
+unsigned llvm::DenseMapInfo<clang::Selector>::getHashValue(clang::Selector S) {
+ return DenseMapInfo<void*>::getHashValue(S.getAsOpaquePtr());
+}
+
+
/// MultiKeywordSelector - One of these variable length records is kept for each
/// selector containing more than one keyword. We use a folding set
/// to unique aggregate names (keyword selectors in ObjC parlance). Access to
/// this class is provided strictly through Selector.
+namespace clang {
class MultiKeywordSelector : public llvm::FoldingSetNode {
public:
unsigned NumArgs;
@@ -263,6 +270,7 @@ public:
Profile(ID, keyword_begin(), NumArgs);
}
};
+} // end namespace clang.
unsigned Selector::getNumArgs() const {
unsigned IIF = getIdentifierInfoFlag();
diff --git a/clang/Sema/Sema.h b/clang/Sema/Sema.h
index b497f5e0ffe..7a6d62fac25 100644
--- a/clang/Sema/Sema.h
+++ b/clang/Sema/Sema.h
@@ -217,7 +217,7 @@ private:
void CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
bool& IncompleteImpl,
const llvm::DenseSet<void *>& InsMap,
- const llvm::DenseSet<void *>& ClsMap);
+ const llvm::DenseSet<Selector> &ClsMap);
/// CheckImplementationIvars - This routine checks if the instance variables
/// listed in the implelementation match those listed in the interface.
@@ -260,8 +260,8 @@ public:
StmtTy *ThenVal, SourceLocation ElseLoc,
StmtTy *ElseVal);
virtual StmtResult ActOnStartOfSwitchStmt(ExprTy *Cond);
- virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch,
- ExprTy *Body);
+ virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
+ StmtTy *Switch, ExprTy *Body);
virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
StmtTy *Body);
virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
diff --git a/clang/Sema/SemaDecl.cpp b/clang/Sema/SemaDecl.cpp
index f7d8dd8493b..b827732b872 100644
--- a/clang/Sema/SemaDecl.cpp
+++ b/clang/Sema/SemaDecl.cpp
@@ -1221,7 +1221,7 @@ void Sema::CheckImplementationIvars(ObjcImplementationDecl *ImpDecl,
void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
bool& IncompleteImpl,
const llvm::DenseSet<void *>& InsMap,
- const llvm::DenseSet<void *>& ClsMap) {
+ const llvm::DenseSet<Selector> &ClsMap) {
// check unimplemented instance methods.
ObjcMethodDecl** methods = PDecl->getInstanceMethods();
for (int j = 0; j < PDecl->getNumInstanceMethods(); j++) {
@@ -1236,7 +1236,7 @@ void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
// check unimplemented class methods
methods = PDecl->getClassMethods();
for (int j = 0; j < PDecl->getNumClassMethods(); j++)
- if (!ClsMap.count(methods[j]->getSelector().getAsOpaquePtr())) {
+ if (!ClsMap.count(methods[j]->getSelector())) {
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
@@ -1267,16 +1267,16 @@ void Sema::ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl,
methods[j]->getSelector().getName(buf));
IncompleteImpl = true;
}
- llvm::DenseSet<void *> ClsMap;
+ llvm::DenseSet<Selector> ClsMap;
// Check and see if class methods in class interface have been
// implemented in the implementation class.
methods = IMPDecl->getClassMethods();
for (int i=0; i < IMPDecl->getNumClassMethods(); i++)
- ClsMap.insert(methods[i]->getSelector().getAsOpaquePtr());
+ ClsMap.insert(methods[i]->getSelector());
methods = IDecl->getClassMethods();
for (int j = 0; j < IDecl->getNumClassMethods(); j++)
- if (!ClsMap.count(methods[j]->getSelector().getAsOpaquePtr())) {
+ if (!ClsMap.count(methods[j]->getSelector())) {
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
@@ -1286,10 +1286,9 @@ void Sema::ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl,
// Check the protocol list for unimplemented methods in the @implementation
// class.
ObjcProtocolDecl** protocols = IDecl->getReferencedProtocols();
- for (int i = 0; i < IDecl->getNumIntfRefProtocols(); i++) {
- ObjcProtocolDecl* PDecl = protocols[i];
- CheckProtocolMethodDefs(PDecl, IncompleteImpl, InsMap, ClsMap);
- }
+ for (int i = 0; i < IDecl->getNumIntfRefProtocols(); i++)
+ CheckProtocolMethodDefs(protocols[i], IncompleteImpl, InsMap, ClsMap);
+
if (IncompleteImpl)
Diag(IMPDecl->getLocation(), diag::warn_incomplete_impl_class,
IMPDecl->getName());
@@ -1315,16 +1314,16 @@ void Sema::ImplCategoryMethodsVsIntfMethods(ObjcCategoryImplDecl *CatImplDecl,
methods[j]->getSelector().getName(buf));
IncompleteImpl = true;
}
- llvm::DenseSet<void *> ClsMap;
+ llvm::DenseSet<Selector> ClsMap;
// Check and see if class methods in category interface have been
// implemented in its implementation class.
methods = CatImplDecl->getClassMethods();
for (int i=0; i < CatImplDecl->getNumClassMethods(); i++)
- ClsMap.insert(methods[i]->getSelector().getAsOpaquePtr());
+ ClsMap.insert(methods[i]->getSelector());
methods = CatClassDecl->getClassMethods();
for (int j = 0; j < CatClassDecl->getNumClassMethods(); j++)
- if (!ClsMap.count(methods[j]->getSelector().getAsOpaquePtr())) {
+ if (!ClsMap.count(methods[j]->getSelector())) {
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
diff --git a/clang/include/clang/Lex/IdentifierTable.h b/clang/include/clang/Lex/IdentifierTable.h
index c820e86fa75..9bb6d83cc56 100644
--- a/clang/include/clang/Lex/IdentifierTable.h
+++ b/clang/include/clang/Lex/IdentifierTable.h
@@ -22,11 +22,14 @@
#include <string>
#include <cassert>
-class MultiKeywordSelector; // a private class used by Selector.
+namespace llvm {
+ template <typename T> struct DenseMapInfo;
+}
namespace clang {
class MacroInfo;
struct LangOptions;
+ class MultiKeywordSelector; // a private class used by Selector.
/// IdentifierInfo - One of these records is kept for each identifier that
/// is lexed. This contains information about whether the token was #define'd,
@@ -202,6 +205,7 @@ class Selector {
InfoPtr = reinterpret_cast<uintptr_t>(SI);
assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
}
+ Selector(intptr_t V) : InfoPtr(V) {}
public:
friend class SelectorTable; // only the SelectorTable can create these.
@@ -237,6 +241,13 @@ public:
// As a convenience, a pointer to the first character is returned.
// Example usage: llvm::SmallString<128> mbuf; Selector->getName(mbuf);
char *getName(llvm::SmallVectorImpl<char> &methodBuffer);
+
+ static Selector getEmptyMarker() {
+ return Selector(uintptr_t(-1));
+ }
+ static Selector getTombstoneMarker() {
+ return Selector(uintptr_t(-2));
+ }
};
/// SelectorTable - This table allows us to fully hide how we implement
@@ -256,4 +267,25 @@ public:
} // end namespace clang
+namespace llvm {
+template <>
+struct DenseMapInfo<clang::Selector> {
+ static inline clang::Selector getEmptyKey() {
+ return clang::Selector::getEmptyMarker();
+ }
+ static inline clang::Selector getTombstoneKey() {
+ return clang::Selector::getTombstoneMarker();
+ }
+
+ static unsigned getHashValue(clang::Selector S);
+
+ static bool isEqual(clang::Selector LHS, clang::Selector RHS) {
+ return LHS == RHS;
+ }
+
+ static bool isPod() { return true; }
+};
+
+} // end namespace llvm
+
#endif
OpenPOWER on IntegriCloud