From e1449e51016fa7868d241c9e451253929d188bb9 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 16 Aug 2008 09:55:52 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54839 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Parse/DeclSpec.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h index 4f53de9462..f4690f8012 100644 --- a/include/clang/Parse/DeclSpec.h +++ b/include/clang/Parse/DeclSpec.h @@ -549,7 +549,7 @@ struct DeclaratorChunk { /// 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 @@ private: 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 @@ public: /// 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(DS); } TheContext getContext() const { return Context; } -- 2.40.0