[cfe-commits] r39250 - /cfe/cfe/trunk/include/clang/Parse/DeclSpec.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:41:56 PDT 2007


Author: sabre
Date: Wed Jul 11 11:41:55 2007
New Revision: 39250

URL: http://llvm.org/viewvc/llvm-project?rev=39250&view=rev
Log:
cleanup code to make it more obvious and extensible

Modified:
    cfe/cfe/trunk/include/clang/Parse/DeclSpec.h

Modified: cfe/cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=39250&r1=39249&r2=39250&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:41:55 2007
@@ -234,6 +234,7 @@
   struct PointerTypeInfo {
     /// The type qualifiers: const/volatile/restrict.
     unsigned TypeQuals : 3;
+    void destroy() {}
   };
   struct ArrayTypeInfo {
     /// The type qualifiers for the array: const/volatile/restrict.
@@ -248,6 +249,7 @@
     /// This is the size of the array, or null if [] or [*] was specified.
     /// FIXME: make this be an expression* when we have expressions.
     void *NumElts;
+    void destroy() {}
   };
   
   /// ParamInfo - An array of paraminfo objects is allocated whenever a function
@@ -286,6 +288,10 @@
     /// describe the arguments for this function declarator.  This is null if
     /// there are no arguments specified.
     ParamInfo *ArgInfo;
+    
+    void destroy() {
+      delete[] ArgInfo;
+    }
   };
   
   union {
@@ -398,10 +404,16 @@
     Identifier = 0;
     IdentifierLoc = SourceLocation();
     
-    for (unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i)
+    for (unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i) {
       if (DeclTypeInfo[i].Kind == DeclaratorChunk::Function)
-        delete [] DeclTypeInfo[i].Fun.ArgInfo;
-        
+        DeclTypeInfo[i].Fun.destroy();
+      else if (DeclTypeInfo[i].Kind == DeclaratorChunk::Pointer)
+        DeclTypeInfo[i].Ptr.destroy();
+      else if (DeclTypeInfo[i].Kind == DeclaratorChunk::Array)
+        DeclTypeInfo[i].Arr.destroy();
+      else
+        assert(0 && "Unknown decl type!");
+    }
     DeclTypeInfo.clear();
   }
   





More information about the cfe-commits mailing list