[cfe-commits] r39221 - in /cfe/cfe/trunk: AST/SemaType.cpp Parse/DeclSpec.cpp Parse/MinimalAction.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:41:25 PDT 2007


Author: sabre
Date: Wed Jul 11 11:41:25 2007
New Revision: 39221

URL: http://llvm.org/viewvc/llvm-project?rev=39221&view=rev
Log:
add accessors to DeclSpec, start moving clients over to use them.

Modified:
    cfe/cfe/trunk/AST/SemaType.cpp
    cfe/cfe/trunk/Parse/DeclSpec.cpp
    cfe/cfe/trunk/Parse/MinimalAction.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=39221&r1=39220&r2=39221&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaType.cpp (original)
+++ cfe/cfe/trunk/AST/SemaType.cpp Wed Jul 11 11:41:25 2007
@@ -77,10 +77,10 @@
 //case DeclSpec::TST_union:
 //case DeclSpec::TST_struct:
   case DeclSpec::TST_typedef: {
-    Decl *D = (Decl *)DS.TypenameRep;
+    Decl *D = (Decl *)DS.getTypenameRep();
     assert(D && "Didn't get a decl for a typedef?");
-    assert(DS.TypeSpecWidth == 0 && DS.TypeSpecComplex == 0 &&
-           DS.TypeSpecSign == 0 &&
+    assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
+           DS.getTypeSpecSign() == 0 &&
            "Can't handle qualifiers on typedef names yet!");
     // TypeQuals handled by caller.
     return Ctx.getTypeDeclType(cast<TypedefDecl>(D));

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

==============================================================================
--- cfe/cfe/trunk/Parse/DeclSpec.cpp (original)
+++ cfe/cfe/trunk/Parse/DeclSpec.cpp Wed Jul 11 11:41:25 2007
@@ -28,10 +28,7 @@
   if (TypeQualifiers   != TQ_unspecified)
     Res |= PQ_TypeQualifier;
   
-  if (TypeSpecWidth    != TSW_unspecified ||
-      TypeSpecComplex  != TSC_unspecified ||
-      TypeSpecSign     != TSS_unspecified ||
-      TypeSpecType     != TST_unspecified)
+  if (hasTypeSpecifier())
     Res |= PQ_TypeSpecifier;
   
   if (FS_inline_specified)

Modified: cfe/cfe/trunk/Parse/MinimalAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/MinimalAction.cpp?rev=39221&r1=39220&r2=39221&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/MinimalAction.cpp (original)
+++ cfe/cfe/trunk/Parse/MinimalAction.cpp Wed Jul 11 11:41:25 2007
@@ -25,7 +25,7 @@
   
   TypeNameInfo(bool istypename, TypeNameInfo *prev) {
     isTypeName = istypename;
-	Prev = prev;
+    Prev = prev;
   }
 };
 
@@ -52,7 +52,8 @@
   if (II == 0) return 0;
   
   TypeNameInfo *weCurrentlyHaveTypeInfo = II->getFETokenInfo<TypeNameInfo>();
-  bool isTypeName = D.getDeclSpec().StorageClassSpec == DeclSpec::SCS_typedef;
+  bool isTypeName =
+    D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef;
 
   // this check avoids creating TypeNameInfo objects for the common case.
   // It does need to handle the uncommon case of shadowing a typedef name with a 

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

==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:41:25 2007
@@ -253,10 +253,7 @@
       // This identifier can only be a typedef name if we haven't already seen
       // a type-specifier.  Without this check we misparse:
       //  typedef int X; struct Y { short X; };  as 'short int'.
-      if (DS.TypeSpecType  == DeclSpec::TST_unspecified &&
-          DS.TypeSpecWidth == DeclSpec::TSW_unspecified &&
-          DS.TypeSpecComplex == DeclSpec::TSC_unspecified &&
-          DS.TypeSpecSign == DeclSpec::TSS_unspecified) {
+      if (!DS.hasTypeSpecifier()) {
         // It has to be available as a typedef too!
         if (void *TypeRep = Actions.isTypeName(*Tok.getIdentifierInfo(),
                                                CurScope)) {
@@ -990,7 +987,7 @@
         ParseAttributes();
       
       // Verify C99 6.7.5.3p2: The only SCS allowed is 'register'.
-      switch (DS.StorageClassSpec) {
+      switch (DS.getStorageClassSpec()) {
       case DeclSpec::SCS_unspecified:
       case DeclSpec::SCS_register:
         break;

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

==============================================================================
--- cfe/cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaType.cpp Wed Jul 11 11:41:25 2007
@@ -77,10 +77,10 @@
 //case DeclSpec::TST_union:
 //case DeclSpec::TST_struct:
   case DeclSpec::TST_typedef: {
-    Decl *D = (Decl *)DS.TypenameRep;
+    Decl *D = (Decl *)DS.getTypenameRep();
     assert(D && "Didn't get a decl for a typedef?");
-    assert(DS.TypeSpecWidth == 0 && DS.TypeSpecComplex == 0 &&
-           DS.TypeSpecSign == 0 &&
+    assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
+           DS.getTypeSpecSign() == 0 &&
            "Can't handle qualifiers on typedef names yet!");
     // TypeQuals handled by caller.
     return Ctx.getTypeDeclType(cast<TypedefDecl>(D));

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=39221&r1=39220&r2=39221&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:41:25 2007
@@ -93,8 +93,6 @@
     PQ_FunctionSpecifier     = 8
   };
   
-  
-
   // storage-class-specifier
   SCS StorageClassSpec : 3;
   bool SCS_thread_specified : 1;
@@ -111,6 +109,7 @@
   // function-specifier
   bool FS_inline_specified : 1;
   
+private:  
   
   // TypenameRep - If TypeSpecType == TST_typedef, this contains the
   // representation for the typedef.
@@ -118,6 +117,7 @@
   
   // attributes.
   // FIXME: implement declspec attributes.
+public:  
   
   DeclSpec()
     : StorageClassSpec(SCS_unspecified),
@@ -131,6 +131,34 @@
       TypenameRep(0) {
   }
   
+  // storage-class-specifier
+  SCS getStorageClassSpec() const { return StorageClassSpec; }
+  bool isThreadSpecified() const { return SCS_thread_specified; }
+  
+  // type-specifier
+  TSW getTypeSpecWidth() const { return TypeSpecWidth; }
+  TSC getTypeSpecComplex() const { return TypeSpecComplex; }
+  TSS getTypeSpecSign() const { return TypeSpecSign; }
+  TST getTypeSpecType() const { return TypeSpecType; }
+  void *getTypenameRep() const { return TypenameRep; }
+  
+  // type-qualifiers
+
+  /// getTypeQualifiers - Return a set of TQs.
+  unsigned getTypeQualifiers() const { return TypeQualifiers; }
+  
+  // function-specifier
+  bool isInlineSpecified() const { return FS_inline_specified; }
+  
+  /// hasTypeSpecifier - Return true if any type-specifier has been found.
+  bool hasTypeSpecifier() const {
+    return getTypeSpecType() != DeclSpec::TST_unspecified ||
+           getTypeSpecWidth() != DeclSpec::TSW_unspecified ||
+           getTypeSpecComplex() != DeclSpec::TSC_unspecified ||
+           getTypeSpecSign() != DeclSpec::TSS_unspecified;
+  }
+  
+  
   /// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
   /// DeclSpec includes.
   ///





More information about the cfe-commits mailing list