Deleted Added
full compact
IdentifierTable.h (198092) IdentifierTable.h (198398)
1//===--- IdentifierTable.h - Hash table for identifier lookup ---*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 61 unchanged lines hidden (view full) ---

70public:
71 IdentifierInfo();
72
73
74 /// isStr - Return true if this is the identifier for the specified string.
75 /// This is intended to be used for string literals only: II->isStr("foo").
76 template <std::size_t StrLen>
77 bool isStr(const char (&Str)[StrLen]) const {
1//===--- IdentifierTable.h - Hash table for identifier lookup ---*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 61 unchanged lines hidden (view full) ---

70public:
71 IdentifierInfo();
72
73
74 /// isStr - Return true if this is the identifier for the specified string.
75 /// This is intended to be used for string literals only: II->isStr("foo").
76 template <std::size_t StrLen>
77 bool isStr(const char (&Str)[StrLen]) const {
78 return getLength() == StrLen-1 && !memcmp(getName(), Str, StrLen-1);
78 return getLength() == StrLen-1 && !memcmp(getNameStart(), Str, StrLen-1);
79 }
80
79 }
80
81 /// getName - Return the actual string for this identifier. The returned
82 /// string is properly null terminated.
81 /// getNameStart - Return the beginning of the actual string for this
82 /// identifier. The returned string is properly null terminated.
83 ///
83 ///
84 const char *getName() const {
84 const char *getNameStart() const {
85 if (Entry) return Entry->getKeyData();
86 // FIXME: This is gross. It would be best not to embed specific details
87 // of the PTH file format here.
88 // The 'this' pointer really points to a
89 // std::pair<IdentifierInfo, const char*>, where internal pointer
90 // points to the external string data.
91 return ((std::pair<IdentifierInfo, const char*>*) this)->second;
92 }
93
94 /// getLength - Efficiently return the length of this identifier info.
95 ///
96 unsigned getLength() const {
97 if (Entry) return Entry->getKeyLength();
98 // FIXME: This is gross. It would be best not to embed specific details
99 // of the PTH file format here.
100 // The 'this' pointer really points to a
101 // std::pair<IdentifierInfo, const char*>, where internal pointer
102 // points to the external string data.
103 const char* p = ((std::pair<IdentifierInfo, const char*>*) this)->second-2;
85 if (Entry) return Entry->getKeyData();
86 // FIXME: This is gross. It would be best not to embed specific details
87 // of the PTH file format here.
88 // The 'this' pointer really points to a
89 // std::pair<IdentifierInfo, const char*>, where internal pointer
90 // points to the external string data.
91 return ((std::pair<IdentifierInfo, const char*>*) this)->second;
92 }
93
94 /// getLength - Efficiently return the length of this identifier info.
95 ///
96 unsigned getLength() const {
97 if (Entry) return Entry->getKeyLength();
98 // FIXME: This is gross. It would be best not to embed specific details
99 // of the PTH file format here.
100 // The 'this' pointer really points to a
101 // std::pair<IdentifierInfo, const char*>, where internal pointer
102 // points to the external string data.
103 const char* p = ((std::pair<IdentifierInfo, const char*>*) this)->second-2;
104 return (((unsigned) p[0])
105 | (((unsigned) p[1]) << 8)) - 1;
104 return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
106 }
107
105 }
106
107 /// getName - Return the actual identifier string.
108 llvm::StringRef getName() const {
109 return llvm::StringRef(getNameStart(), getLength());
110 }
111
108 /// hasMacroDefinition - Return true if this identifier is #defined to some
109 /// other value.
110 bool hasMacroDefinition() const {
111 return HasMacro;
112 }
113 void setHasMacroDefinition(bool Val) {
114 if (HasMacro == Val) return;
115

--- 111 unchanged lines hidden (view full) ---

227class IdentifierInfoLookup {
228public:
229 virtual ~IdentifierInfoLookup();
230
231 /// get - Return the identifier token info for the specified named identifier.
232 /// Unlike the version in IdentifierTable, this returns a pointer instead
233 /// of a reference. If the pointer is NULL then the IdentifierInfo cannot
234 /// be found.
112 /// hasMacroDefinition - Return true if this identifier is #defined to some
113 /// other value.
114 bool hasMacroDefinition() const {
115 return HasMacro;
116 }
117 void setHasMacroDefinition(bool Val) {
118 if (HasMacro == Val) return;
119

--- 111 unchanged lines hidden (view full) ---

231class IdentifierInfoLookup {
232public:
233 virtual ~IdentifierInfoLookup();
234
235 /// get - Return the identifier token info for the specified named identifier.
236 /// Unlike the version in IdentifierTable, this returns a pointer instead
237 /// of a reference. If the pointer is NULL then the IdentifierInfo cannot
238 /// be found.
239 //
240 // FIXME: Move to StringRef API.
235 virtual IdentifierInfo* get(const char *NameStart, const char *NameEnd) = 0;
236};
237
238/// \brief An abstract class used to resolve numerical identifier
239/// references (meaningful only to some external source) into
240/// IdentifierInfo pointers.
241class ExternalIdentifierLookup {
242public:

--- 85 unchanged lines hidden (view full) ---

328 Entry.setValue(II);
329
330 // Make sure getName() knows how to find the IdentifierInfo
331 // contents.
332 II->Entry = &Entry;
333
334 return *II;
335 }
241 virtual IdentifierInfo* get(const char *NameStart, const char *NameEnd) = 0;
242};
243
244/// \brief An abstract class used to resolve numerical identifier
245/// references (meaningful only to some external source) into
246/// IdentifierInfo pointers.
247class ExternalIdentifierLookup {
248public:

--- 85 unchanged lines hidden (view full) ---

334 Entry.setValue(II);
335
336 // Make sure getName() knows how to find the IdentifierInfo
337 // contents.
338 II->Entry = &Entry;
339
340 return *II;
341 }
342 IdentifierInfo &CreateIdentifierInfo(llvm::StringRef Name) {
343 return CreateIdentifierInfo(Name.begin(), Name.end());
344 }
336
345
337 IdentifierInfo &get(const llvm::StringRef& Name) {
346 IdentifierInfo &get(llvm::StringRef Name) {
338 return get(Name.begin(), Name.end());
339 }
340
341 typedef HashTableTy::const_iterator iterator;
342 typedef HashTableTy::const_iterator const_iterator;
343
344 iterator begin() const { return HashTable.begin(); }
345 iterator end() const { return HashTable.end(); }

--- 112 unchanged lines hidden (view full) ---

458 /// constructSetterName - Return the setter name for the given
459 /// identifier, i.e. "set" + Name where the initial character of Name
460 /// has been capitalized.
461 static Selector constructSetterName(IdentifierTable &Idents,
462 SelectorTable &SelTable,
463 const IdentifierInfo *Name) {
464 llvm::SmallString<100> SelectorName;
465 SelectorName = "set";
347 return get(Name.begin(), Name.end());
348 }
349
350 typedef HashTableTy::const_iterator iterator;
351 typedef HashTableTy::const_iterator const_iterator;
352
353 iterator begin() const { return HashTable.begin(); }
354 iterator end() const { return HashTable.end(); }

--- 112 unchanged lines hidden (view full) ---

467 /// constructSetterName - Return the setter name for the given
468 /// identifier, i.e. "set" + Name where the initial character of Name
469 /// has been capitalized.
470 static Selector constructSetterName(IdentifierTable &Idents,
471 SelectorTable &SelTable,
472 const IdentifierInfo *Name) {
473 llvm::SmallString<100> SelectorName;
474 SelectorName = "set";
466 SelectorName.append(Name->getName(), Name->getName()+Name->getLength());
475 SelectorName += Name->getName();
467 SelectorName[3] = toupper(SelectorName[3]);
468 IdentifierInfo *SetterName =
469 &Idents.get(SelectorName.data(),
470 SelectorName.data() + SelectorName.size());
471 return SelTable.getUnarySelector(SetterName);
472 }
473};
474

--- 82 unchanged lines hidden ---
476 SelectorName[3] = toupper(SelectorName[3]);
477 IdentifierInfo *SetterName =
478 &Idents.get(SelectorName.data(),
479 SelectorName.data() + SelectorName.size());
480 return SelTable.getUnarySelector(SetterName);
481 }
482};
483

--- 82 unchanged lines hidden ---