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
This commit is contained in:
Argyrios Kyrtzidis 2008-08-16 09:55:52 +00:00
Родитель b7ec246872
Коммит e1449e5101
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -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<DeclSpec &>(DS); }
TheContext getContext() const { return Context; }