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

Argiris Kirtzidis akyrtzi at gmail.com
Sat Aug 16 02:55:54 PDT 2008


Author: akirtzidis
Date: Sat Aug 16 04:55:52 2008
New Revision: 54839

URL: http://llvm.org/viewvc/llvm-project?rev=54839&view=rev
Log:
Declarator class considers DeclSpec as immutable; Declarator::getMutableDeclSpec should be used rarely and with care.
Have Declarator accept and use a 'const DeclSpec &', instead of 'DeclSpec &', to make DeclSpec's immutability more explicit.
No functionality change.

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

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

==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Sat Aug 16 04:55:52 2008
@@ -549,7 +549,7 @@
 /// Instances of this class should be a transient object that lives on the
 /// stack, not objects that are allocated in large quantities on the heap.
 class Declarator {
-  DeclSpec &DS;
+  const DeclSpec &DS;
   IdentifierInfo *Identifier;
   SourceLocation IdentifierLoc;
   
@@ -584,7 +584,7 @@
   Action::ExprTy *AsmLabel;
   
 public:
-  Declarator(DeclSpec &ds, TheContext C)
+  Declarator(const DeclSpec &ds, TheContext C)
     : DS(ds), Identifier(0), Context(C), InvalidType(false), AttrList(0),
       AsmLabel(0) {
   }
@@ -602,7 +602,7 @@
   /// multiple declarators, so mutating the DeclSpec affects all of the
   /// Declarators.  This should only be done when the declspec is known to not
   /// be shared or when in error recovery etc.
-  DeclSpec &getMutableDeclSpec() { return DS; }
+  DeclSpec &getMutableDeclSpec() { return const_cast<DeclSpec &>(DS); }
 
   TheContext getContext() const { return Context; }
   





More information about the cfe-commits mailing list