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

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


Author: sabre
Date: Wed Jul 11 11:41:26 2007
New Revision: 39222

URL: http://llvm.org/viewvc/llvm-project?rev=39222&view=rev
Log:
Convert more code to use DeclSpec accessors

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

==============================================================================
--- cfe/cfe/trunk/AST/SemaType.cpp (original)
+++ cfe/cfe/trunk/AST/SemaType.cpp Wed Jul 11 11:41:26 2007
@@ -97,7 +97,7 @@
   if (T.isNull()) return T;
   
   // Apply const/volatile/restrict qualifiers to T.
-  T = T.getQualifiedType(D.getDeclSpec().TypeQualifiers);
+  T = T.getQualifiedType(D.getDeclSpec().getTypeQualifiers());
   
   // Walk the DeclTypeInfo, building the recursive type as we go.  DeclTypeInfos
   // are ordered from the identifier out, which is opposite of what we want :).

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

==============================================================================
--- cfe/cfe/trunk/Parse/DeclSpec.cpp (original)
+++ cfe/cfe/trunk/Parse/DeclSpec.cpp Wed Jul 11 11:41:26 2007
@@ -166,6 +166,13 @@
   return false;
 }
 
+bool DeclSpec::SetFunctionSpecInline(const char *&PrevSpec) {
+  // 'inline inline' is ok.
+  FS_inline_specified = true;
+  return false;
+}
+
+
 /// Finish - This does final analysis of the declspec, rejecting things like
 /// "_Imaginary" (lacking an FP type).  This returns a diagnostic to issue or
 /// diag::NUM_DIAGNOSTICS if there is no error.  After calling this method,

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

==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:41:26 2007
@@ -187,13 +187,14 @@
   
   if (Specs & DeclSpec::PQ_StorageClassSpecifier) {
     Diag(Loc, diag::err_typename_invalid_storageclass);
+    // FIXME: better loc info for this!
     // Remove storage class.
-    DS.StorageClassSpec     = DeclSpec::SCS_unspecified;
-    DS.SCS_thread_specified = false;
+    DS.ClearStorageClassSpecs();
   }
   if (Specs & DeclSpec::PQ_FunctionSpecifier) {
+    // FIXME: better loc info for this!
     Diag(Loc, diag::err_typename_invalid_functionspec);
-    DS.FS_inline_specified = false;
+    DS.ClearFunctionSpecs();
   }
 }
 
@@ -374,8 +375,7 @@
       
     // function-specifier
     case tok::kw_inline:
-      // 'inline inline' is ok.
-      DS.FS_inline_specified = true;
+      isInvalid = DS.SetFunctionSpecInline(PrevSpec);
       break;
     }
     // If the specifier combination wasn't legal, issue a diagnostic.
@@ -779,7 +779,7 @@
   ParseDeclaratorInternal(D);
 
   // Remember that we parsed a pointer type, and remember the type-quals.
-  D.AddTypeInfo(DeclaratorTypeInfo::getPointer(DS.TypeQualifiers, Loc));
+  D.AddTypeInfo(DeclaratorTypeInfo::getPointer(DS.getTypeQualifiers(), Loc));
 }
 
 
@@ -1105,7 +1105,7 @@
   }
   
   // Remember that we parsed a pointer type, and remember the type-quals.
-  D.AddTypeInfo(DeclaratorTypeInfo::getArray(DS.TypeQualifiers,
+  D.AddTypeInfo(DeclaratorTypeInfo::getArray(DS.getTypeQualifiers(),
                                              StaticLoc.isValid(), isStar,
                                              NumElements.Val, StartLoc));
 }

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

==============================================================================
--- cfe/cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseStmt.cpp Wed Jul 11 11:41:26 2007
@@ -716,9 +716,9 @@
   ParseTypeQualifierListOpt(DS);
   
   // GNU asms accept, but warn, about type-qualifiers other than volatile.
-  if (DS.TypeQualifiers & DeclSpec::TQ_const)
+  if (DS.getTypeQualifiers() & DeclSpec::TQ_const)
     Diag(Loc, diag::w_asm_qualifier_ignored, "const");
-  if (DS.TypeQualifiers & DeclSpec::TQ_restrict)
+  if (DS.getTypeQualifiers() & DeclSpec::TQ_restrict)
     Diag(Loc, diag::w_asm_qualifier_ignored, "restrict");
   
   // Remember if this was a volatile asm.

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

==============================================================================
--- cfe/cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaType.cpp Wed Jul 11 11:41:26 2007
@@ -97,7 +97,7 @@
   if (T.isNull()) return T;
   
   // Apply const/volatile/restrict qualifiers to T.
-  T = T.getQualifiedType(D.getDeclSpec().TypeQualifiers);
+  T = T.getQualifiedType(D.getDeclSpec().getTypeQualifiers());
   
   // Walk the DeclTypeInfo, building the recursive type as we go.  DeclTypeInfos
   // are ordered from the identifier out, which is opposite of what we want :).

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

==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:41:26 2007
@@ -103,14 +103,14 @@
   TSS TypeSpecSign : 2;
   TST TypeSpecType : 4;
   
+private:
+    
   // type-qualifiers
   unsigned TypeQualifiers : 3;  // Bitwise OR of TQ.
   
   // function-specifier
   bool FS_inline_specified : 1;
   
-private:  
-  
   // TypenameRep - If TypeSpecType == TST_typedef, this contains the
   // representation for the typedef.
   void *TypenameRep;  
@@ -135,6 +135,11 @@
   SCS getStorageClassSpec() const { return StorageClassSpec; }
   bool isThreadSpecified() const { return SCS_thread_specified; }
   
+  void ClearStorageClassSpecs() {
+    StorageClassSpec     = DeclSpec::SCS_unspecified;
+    SCS_thread_specified = false;
+  }
+  
   // type-specifier
   TSW getTypeSpecWidth() const { return TypeSpecWidth; }
   TSC getTypeSpecComplex() const { return TypeSpecComplex; }
@@ -149,6 +154,9 @@
   
   // function-specifier
   bool isInlineSpecified() const { return FS_inline_specified; }
+  void ClearFunctionSpecs() {
+    FS_inline_specified = false;
+  }
   
   /// hasTypeSpecifier - Return true if any type-specifier has been found.
   bool hasTypeSpecifier() const {
@@ -175,6 +183,8 @@
   
   bool SetTypeQual(TQ T, const char *&PrevSpec, const LangOptions &Lang);
   
+  bool SetFunctionSpecInline(const char *&PrevSpec);
+  
   /// Finish - This does final analysis of the declspec, issuing diagnostics for
   /// things like "_Imaginary" (lacking an FP type).  After calling this method,
   /// DeclSpec is guaranteed self-consistent, even if an error occurred.





More information about the cfe-commits mailing list