[cfe-commits] r39282 - in /cfe/cfe/trunk: AST/SemaType.cpp Parse/DeclSpec.cpp Parse/ParseDecl.cpp Sema/SemaType.cpp include/clang/Parse/DeclSpec.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:42:26 PDT 2007


Author: sabre
Date: Wed Jul 11 11:42:26 2007
New Revision: 39282

URL: http://llvm.org/viewvc/llvm-project?rev=39282&view=rev
Log:
Generalize DeclSpec::TypedefRep to allow it to hold any type representation.
Use it to hold the declaration object for a struct/union.

Modified:
    cfe/cfe/trunk/AST/SemaType.cpp
    cfe/cfe/trunk/Parse/DeclSpec.cpp
    cfe/cfe/trunk/Parse/ParseDecl.cpp
    cfe/cfe/trunk/Sema/SemaType.cpp
    cfe/cfe/trunk/include/clang/Parse/DeclSpec.h

Modified: cfe/cfe/trunk/AST/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaType.cpp?rev=39282&r1=39281&r2=39282&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaType.cpp (original)
+++ cfe/cfe/trunk/AST/SemaType.cpp Wed Jul 11 11:42:26 2007
@@ -78,7 +78,7 @@
 //case DeclSpec::TST_union:
 //case DeclSpec::TST_struct:
   case DeclSpec::TST_typedef: {
-    Decl *D = (Decl *)DS.getTypenameRep();
+    Decl *D = static_cast<Decl *>(DS.getTypeRep());
     assert(D && "Didn't get a decl for a typedef?");
     assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
            DS.getTypeSpecSign() == 0 &&

Modified: cfe/cfe/trunk/Parse/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/DeclSpec.cpp?rev=39282&r1=39281&r2=39282&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/DeclSpec.cpp (original)
+++ cfe/cfe/trunk/Parse/DeclSpec.cpp Wed Jul 11 11:42:26 2007
@@ -171,11 +171,11 @@
 }
 
 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
-                               const char *&PrevSpec, void *TypeRep) {
+                               const char *&PrevSpec, void *Rep) {
   if (TypeSpecType != TST_unspecified)
     return BadSpecifier(TypeSpecType, PrevSpec);
   TypeSpecType = T;
-  TypenameRep = TypeRep;
+  TypeRep = Rep;
   TSTLoc = Loc;
   return false;
 }

Modified: cfe/cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseDecl.cpp?rev=39282&r1=39281&r2=39282&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:42:26 2007
@@ -451,7 +451,7 @@
     ParseStructUnionBody(TagType, TagDecl);
 
   const char *PrevSpec = 0;
-  if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec))
+  if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, TagDecl))
     Diag(StartLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
 }
 

Modified: cfe/cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaType.cpp?rev=39282&r1=39281&r2=39282&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaType.cpp Wed Jul 11 11:42:26 2007
@@ -78,7 +78,7 @@
 //case DeclSpec::TST_union:
 //case DeclSpec::TST_struct:
   case DeclSpec::TST_typedef: {
-    Decl *D = (Decl *)DS.getTypenameRep();
+    Decl *D = static_cast<Decl *>(DS.getTypeRep());
     assert(D && "Didn't get a decl for a typedef?");
     assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
            DS.getTypeSpecSign() == 0 &&

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=39282&r1=39281&r2=39282&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:42:26 2007
@@ -111,9 +111,10 @@
   // function-specifier
   bool FS_inline_specified : 1;
   
-  // TypenameRep - If TypeSpecType == TST_typedef, this contains the
-  // representation for the typedef.
-  void *TypenameRep;  
+  /// TypeRep - This contains action-specific information about a specific TST.
+  /// For example, for a typedef or struct, it might contain the declaration for
+  /// these.
+  void *TypeRep;  
   
   // attributes.
   // FIXME: implement declspec attributes.
@@ -135,7 +136,7 @@
       TypeSpecType(TST_unspecified),
       TypeQualifiers(TSS_unspecified),
       FS_inline_specified(false),
-      TypenameRep(0) {
+      TypeRep(0) {
   }
   
   // storage-class-specifier
@@ -158,7 +159,7 @@
   TSC getTypeSpecComplex() const { return TypeSpecComplex; }
   TSS getTypeSpecSign() const { return TypeSpecSign; }
   TST getTypeSpecType() const { return TypeSpecType; }
-  void *getTypenameRep() const { return TypenameRep; }
+  void *getTypeRep() const { return TypeRep; }
   
   SourceLocation getTypeSpecWidthLoc() const { return TSWLoc; }
   SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; }
@@ -210,7 +211,7 @@
   bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec);
   bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec);
   bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
-                       void *TypenameRep = 0);
+                       void *TypeRep = 0);
   
   bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
                    const LangOptions &Lang);





More information about the cfe-commits mailing list