forked from OSchip/llvm-project
genericize IdentifierInfo interface to make it work more naturally.
llvm-svn: 39076
This commit is contained in:
parent
2abeb12df6
commit
3bc804ed3d
|
@ -23,7 +23,18 @@ using namespace clang;
|
|||
// IdentifierInfo Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void IdentifierInfo::Destroy() {
|
||||
IdentifierInfo::IdentifierInfo() {
|
||||
Macro = 0;
|
||||
TokenID = tok::identifier;
|
||||
PPID = tok::pp_not_keyword;
|
||||
ObjCID = tok::objc_not_keyword;
|
||||
IsExtension = false;
|
||||
IsPoisoned = false;
|
||||
IsOtherTargetMacro = false;
|
||||
FETokenInfo = 0;
|
||||
}
|
||||
|
||||
IdentifierInfo::~IdentifierInfo() {
|
||||
delete Macro;
|
||||
}
|
||||
|
||||
|
@ -146,7 +157,7 @@ IdentifierTable::~IdentifierTable() {
|
|||
for (unsigned i = 0, e = HashTableSize; i != e; ++i) {
|
||||
if (IdentifierInfo *Id = TableArray[i].Info) {
|
||||
// Free memory referenced by the identifier (e.g. macro info).
|
||||
Id->Destroy();
|
||||
Id->~IdentifierInfo();
|
||||
|
||||
#if !USE_ALLOCATOR
|
||||
// Free the memory for the identifier itself.
|
||||
|
@ -214,14 +225,7 @@ IdentifierInfo &IdentifierTable::get(const char *NameStart,
|
|||
#else
|
||||
IdentifierInfo *Identifier = (IdentifierInfo*)malloc(AllocSize);
|
||||
#endif
|
||||
Identifier->Macro = 0;
|
||||
Identifier->TokenID = tok::identifier;
|
||||
Identifier->PPID = tok::pp_not_keyword;
|
||||
Identifier->ObjCID = tok::objc_not_keyword;
|
||||
Identifier->IsExtension = false;
|
||||
Identifier->IsPoisoned = false;
|
||||
Identifier->IsOtherTargetMacro = false;
|
||||
Identifier->FETokenInfo = 0;
|
||||
new (Identifier) IdentifierInfo();
|
||||
++NumIdentifiers;
|
||||
|
||||
// Copy the string information.
|
||||
|
|
|
@ -39,7 +39,11 @@ class IdentifierInfo {
|
|||
bool IsOtherTargetMacro : 1; // True if ident is macro on another target.
|
||||
void *FETokenInfo; // Managed by the language front-end.
|
||||
friend class IdentifierTable;
|
||||
IdentifierInfo(const IdentifierInfo&); // NONCOPYABLE.
|
||||
public:
|
||||
IdentifierInfo();
|
||||
~IdentifierInfo();
|
||||
|
||||
/// getName - Return the actual string for this identifier. The length of
|
||||
/// this string is stored in NameLen, and the returned string is properly null
|
||||
/// terminated.
|
||||
|
@ -94,8 +98,6 @@ public:
|
|||
template<typename T>
|
||||
T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); }
|
||||
void setFETokenInfo(void *T) { FETokenInfo = T; }
|
||||
private:
|
||||
void Destroy();
|
||||
};
|
||||
|
||||
/// IdentifierVisitor - Subclasses of this class may be implemented to walk all
|
||||
|
|
Loading…
Reference in New Issue