[cfe-commits] r39076 - in /cfe/cfe/trunk: Lex/IdentifierTable.cpp include/clang/Lex/IdentifierTable.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:27:20 PDT 2007


Author: sabre
Date: Wed Jul 11 11:27:20 2007
New Revision: 39076

URL: http://llvm.org/viewvc/llvm-project?rev=39076&view=rev
Log:
genericize IdentifierInfo interface to make it work more naturally.

Modified:
    cfe/cfe/trunk/Lex/IdentifierTable.cpp
    cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h

Modified: cfe/cfe/trunk/Lex/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/IdentifierTable.cpp?rev=39076&r1=39075&r2=39076&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/IdentifierTable.cpp (original)
+++ cfe/cfe/trunk/Lex/IdentifierTable.cpp Wed Jul 11 11:27:20 2007
@@ -23,7 +23,18 @@
 // 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 @@
   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 @@
 #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.

Modified: cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h?rev=39076&r1=39075&r2=39076&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/IdentifierTable.h Wed Jul 11 11:27:20 2007
@@ -39,7 +39,11 @@
   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 @@
   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





More information about the cfe-commits mailing list