[parsing][cleanup] Using 'using' instead of 'typedef'

Even though both are allowed in the style guide, it recommends to use
'using', as its syntax is more consistent with the rest of C++.
This CL turns all typedefs in parsing code to 'using' declarations.

R=leszeks@chromium.org

Bug: v8:8834
Change-Id: I0c95f83ee6897d294bd002b7a4a6277962397e90
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1545897
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60522}
This commit is contained in:
Clemens Hammacher 2019-03-29 12:05:34 +01:00 committed by Commit Bot
parent 138d2dfcb1
commit 8ab941a087
6 changed files with 118 additions and 118 deletions

View File

@ -41,8 +41,8 @@ class VariableProxy;
template <typename Types> template <typename Types>
class ExpressionScope { class ExpressionScope {
public: public:
typedef typename Types::Impl ParserT; using ParserT = typename Types::Impl;
typedef typename Types::Expression ExpressionT; using ExpressionT = typename Types::Expression;
VariableProxy* NewVariable(const AstRawString* name, VariableProxy* NewVariable(const AstRawString* name,
int pos = kNoSourcePosition) { int pos = kNoSourcePosition) {
@ -281,9 +281,9 @@ class ExpressionScope {
template <typename Types> template <typename Types>
class VariableDeclarationParsingScope : public ExpressionScope<Types> { class VariableDeclarationParsingScope : public ExpressionScope<Types> {
public: public:
typedef typename Types::Impl ParserT; using ParserT = typename Types::Impl;
typedef class ExpressionScope<Types> ExpressionScopeT; using ExpressionScopeT = ExpressionScope<Types>;
typedef typename ExpressionScopeT::ScopeType ScopeType; using ScopeType = typename ExpressionScopeT::ScopeType;
VariableDeclarationParsingScope(ParserT* parser, VariableMode mode, VariableDeclarationParsingScope(ParserT* parser, VariableMode mode,
ZonePtrList<const AstRawString>* names) ZonePtrList<const AstRawString>* names)
@ -351,9 +351,9 @@ class VariableDeclarationParsingScope : public ExpressionScope<Types> {
template <typename Types> template <typename Types>
class ParameterDeclarationParsingScope : public ExpressionScope<Types> { class ParameterDeclarationParsingScope : public ExpressionScope<Types> {
public: public:
typedef typename Types::Impl ParserT; using ParserT = typename Types::Impl;
typedef class ExpressionScope<Types> ExpressionScopeT; using ExpressionScopeT = ExpressionScope<Types>;
typedef typename ExpressionScopeT::ScopeType ScopeType; using ScopeType = typename ExpressionScopeT::ScopeType;
explicit ParameterDeclarationParsingScope(ParserT* parser) explicit ParameterDeclarationParsingScope(ParserT* parser)
: ExpressionScopeT(parser, ExpressionScopeT::kParameterDeclaration) {} : ExpressionScopeT(parser, ExpressionScopeT::kParameterDeclaration) {}
@ -391,10 +391,10 @@ class ParameterDeclarationParsingScope : public ExpressionScope<Types> {
template <typename Types> template <typename Types>
class ExpressionParsingScope : public ExpressionScope<Types> { class ExpressionParsingScope : public ExpressionScope<Types> {
public: public:
typedef typename Types::Impl ParserT; using ParserT = typename Types::Impl;
typedef typename Types::Expression ExpressionT; using ExpressionT = typename Types::Expression;
typedef class ExpressionScope<Types> ExpressionScopeT; using ExpressionScopeT = ExpressionScope<Types>;
typedef typename ExpressionScopeT::ScopeType ScopeType; using ScopeType = typename ExpressionScopeT::ScopeType;
ExpressionParsingScope(ParserT* parser, ExpressionParsingScope(ParserT* parser,
ScopeType type = ExpressionScopeT::kExpression) ScopeType type = ExpressionScopeT::kExpression)
@ -563,7 +563,7 @@ class ExpressionParsingScope : public ExpressionScope<Types> {
template <typename Types> template <typename Types>
class AccumulationScope { class AccumulationScope {
public: public:
typedef typename Types::Impl ParserT; using ParserT = typename Types::Impl;
static const int kNumberOfErrors = static const int kNumberOfErrors =
ExpressionParsingScope<Types>::kNumberOfErrors; ExpressionParsingScope<Types>::kNumberOfErrors;
@ -644,8 +644,8 @@ class AccumulationScope {
template <typename Types> template <typename Types>
class ArrowHeadParsingScope : public ExpressionParsingScope<Types> { class ArrowHeadParsingScope : public ExpressionParsingScope<Types> {
public: public:
typedef typename Types::Impl ParserT; using ParserT = typename Types::Impl;
typedef typename ExpressionScope<Types>::ScopeType ScopeType; using ScopeType = typename ExpressionScope<Types>::ScopeType;
ArrowHeadParsingScope(ParserT* parser, FunctionKind kind) ArrowHeadParsingScope(ParserT* parser, FunctionKind kind)
: ExpressionParsingScope<Types>( : ExpressionParsingScope<Types>(

View File

@ -236,8 +236,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
void Enqueue(ParseInfo* outer_parse_info, const AstRawString* function_name, void Enqueue(ParseInfo* outer_parse_info, const AstRawString* function_name,
FunctionLiteral* literal); FunctionLiteral* literal);
typedef std::forward_list<std::pair<FunctionLiteral*, uintptr_t>>::iterator using EnqueuedJobsIterator =
EnqueuedJobsIterator; std::forward_list<std::pair<FunctionLiteral*, uintptr_t>>::iterator;
EnqueuedJobsIterator begin() { return enqueued_jobs_.begin(); } EnqueuedJobsIterator begin() { return enqueued_jobs_.begin(); }
EnqueuedJobsIterator end() { return enqueued_jobs_.end(); } EnqueuedJobsIterator end() { return enqueued_jobs_.end(); }

View File

@ -49,7 +49,7 @@ enum class ParseFunctionFlag : uint8_t {
kIsAsync = 1 << 1 kIsAsync = 1 << 1
}; };
typedef base::Flags<ParseFunctionFlag> ParseFunctionFlags; using ParseFunctionFlags = base::Flags<ParseFunctionFlag>;
struct FormalParametersBase { struct FormalParametersBase {
explicit FormalParametersBase(DeclarationScope* scope) : scope(scope) {} explicit FormalParametersBase(DeclarationScope* scope) : scope(scope) {}
@ -195,44 +195,44 @@ template <typename Impl>
class ParserBase { class ParserBase {
public: public:
// Shorten type names defined by ParserTypes<Impl>. // Shorten type names defined by ParserTypes<Impl>.
typedef ParserTypes<Impl> Types; using Types = ParserTypes<Impl>;
typedef typename v8::internal::ExpressionScope<Types> ExpressionScope; using ExpressionScope = typename v8::internal::ExpressionScope<Types>;
typedef typename v8::internal::ExpressionParsingScope<Types> using ExpressionParsingScope =
ExpressionParsingScope; typename v8::internal::ExpressionParsingScope<Types>;
typedef typename v8::internal::AccumulationScope<Types> AccumulationScope; using AccumulationScope = typename v8::internal::AccumulationScope<Types>;
typedef typename v8::internal::ArrowHeadParsingScope<Types> using ArrowHeadParsingScope =
ArrowHeadParsingScope; typename v8::internal::ArrowHeadParsingScope<Types>;
typedef typename v8::internal::VariableDeclarationParsingScope<Types> using VariableDeclarationParsingScope =
VariableDeclarationParsingScope; typename v8::internal::VariableDeclarationParsingScope<Types>;
typedef typename v8::internal::ParameterDeclarationParsingScope<Types> using ParameterDeclarationParsingScope =
ParameterDeclarationParsingScope; typename v8::internal::ParameterDeclarationParsingScope<Types>;
// Return types for traversing functions. // Return types for traversing functions.
typedef typename Types::Block BlockT; using BlockT = typename Types::Block;
typedef typename Types::BreakableStatement BreakableStatementT; using BreakableStatementT = typename Types::BreakableStatement;
typedef typename Types::ClassLiteralProperty ClassLiteralPropertyT; using ClassLiteralPropertyT = typename Types::ClassLiteralProperty;
typedef typename Types::ClassPropertyList ClassPropertyListT; using ClassPropertyListT = typename Types::ClassPropertyList;
typedef typename Types::Expression ExpressionT; using ExpressionT = typename Types::Expression;
typedef typename Types::ExpressionList ExpressionListT; using ExpressionListT = typename Types::ExpressionList;
typedef typename Types::FormalParameters FormalParametersT; using FormalParametersT = typename Types::FormalParameters;
typedef typename Types::ForStatement ForStatementT; using ForStatementT = typename Types::ForStatement;
typedef typename Types::FunctionLiteral FunctionLiteralT; using FunctionLiteralT = typename Types::FunctionLiteral;
typedef typename Types::Identifier IdentifierT; using IdentifierT = typename Types::Identifier;
typedef typename Types::IterationStatement IterationStatementT; using IterationStatementT = typename Types::IterationStatement;
typedef typename Types::ObjectLiteralProperty ObjectLiteralPropertyT; using ObjectLiteralPropertyT = typename Types::ObjectLiteralProperty;
typedef typename Types::ObjectPropertyList ObjectPropertyListT; using ObjectPropertyListT = typename Types::ObjectPropertyList;
typedef typename Types::Statement StatementT; using StatementT = typename Types::Statement;
typedef typename Types::StatementList StatementListT; using StatementListT = typename Types::StatementList;
typedef typename Types::Suspend SuspendExpressionT; using SuspendExpressionT = typename Types::Suspend;
// For constructing objects returned by the traversing functions. // For constructing objects returned by the traversing functions.
typedef typename Types::Factory FactoryT; using FactoryT = typename Types::Factory;
// Other implementation-specific tasks. // Other implementation-specific tasks.
typedef typename Types::FuncNameInferrer FuncNameInferrer; using FuncNameInferrer = typename Types::FuncNameInferrer;
typedef typename Types::FuncNameInferrer::State FuncNameInferrerState; using FuncNameInferrerState = typename Types::FuncNameInferrer::State;
typedef typename Types::SourceRange SourceRange; using SourceRange = typename Types::SourceRange;
typedef typename Types::SourceRangeScope SourceRangeScope; using SourceRangeScope = typename Types::SourceRangeScope;
typedef typename Types::Target TargetT; using TargetT = typename Types::Target;
typedef typename Types::TargetScope TargetScopeT; using TargetScopeT = typename Types::TargetScope;
// All implementation-specific methods must be called through this. // All implementation-specific methods must be called through this.
Impl* impl() { return static_cast<Impl*>(this); } Impl* impl() { return static_cast<Impl*>(this); }

View File

@ -137,36 +137,36 @@ struct ParserFormalParameters : FormalParametersBase {
template <> template <>
struct ParserTypes<Parser> { struct ParserTypes<Parser> {
typedef ParserBase<Parser> Base; using Base = ParserBase<Parser>;
typedef Parser Impl; using Impl = Parser;
// Return types for traversing functions. // Return types for traversing functions.
typedef v8::internal::Block* Block; using Block = v8::internal::Block*;
typedef v8::internal::BreakableStatement* BreakableStatement; using BreakableStatement = v8::internal::BreakableStatement*;
typedef ClassLiteral::Property* ClassLiteralProperty; using ClassLiteralProperty = ClassLiteral::Property*;
typedef ZonePtrList<ClassLiteral::Property>* ClassPropertyList; using ClassPropertyList = ZonePtrList<ClassLiteral::Property>*;
typedef v8::internal::Expression* Expression; using Expression = v8::internal::Expression*;
typedef ScopedPtrList<v8::internal::Expression> ExpressionList; using ExpressionList = ScopedPtrList<v8::internal::Expression>;
typedef ParserFormalParameters FormalParameters; using FormalParameters = ParserFormalParameters;
typedef v8::internal::ForStatement* ForStatement; using ForStatement = v8::internal::ForStatement*;
typedef v8::internal::FunctionLiteral* FunctionLiteral; using FunctionLiteral = v8::internal::FunctionLiteral*;
typedef const AstRawString* Identifier; using Identifier = const AstRawString*;
typedef v8::internal::IterationStatement* IterationStatement; using IterationStatement = v8::internal::IterationStatement*;
typedef ObjectLiteral::Property* ObjectLiteralProperty; using ObjectLiteralProperty = ObjectLiteral::Property*;
typedef ScopedPtrList<v8::internal::ObjectLiteralProperty> ObjectPropertyList; using ObjectPropertyList = ScopedPtrList<v8::internal::ObjectLiteralProperty>;
typedef v8::internal::Statement* Statement; using Statement = v8::internal::Statement*;
typedef ScopedPtrList<v8::internal::Statement> StatementList; using StatementList = ScopedPtrList<v8::internal::Statement>;
typedef v8::internal::Suspend* Suspend; using Suspend = v8::internal::Suspend*;
// For constructing objects returned by the traversing functions. // For constructing objects returned by the traversing functions.
typedef AstNodeFactory Factory; using Factory = AstNodeFactory;
// Other implementation-specific functions. // Other implementation-specific functions.
typedef v8::internal::FuncNameInferrer FuncNameInferrer; using FuncNameInferrer = v8::internal::FuncNameInferrer;
typedef v8::internal::SourceRange SourceRange; using SourceRange = v8::internal::SourceRange;
typedef v8::internal::SourceRangeScope SourceRangeScope; using SourceRangeScope = v8::internal::SourceRangeScope;
typedef ParserTarget Target; using Target = ParserTarget;
typedef ParserTargetScope TargetScope; using TargetScope = ParserTargetScope;
}; };
class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
@ -496,7 +496,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
int pos_; int pos_;
}; };
typedef TemplateLiteral* TemplateLiteralState; using TemplateLiteralState = TemplateLiteral*;
TemplateLiteralState OpenTemplateLiteral(int pos); TemplateLiteralState OpenTemplateLiteral(int pos);
// "should_cook" means that the span can be "cooked": in tagged template // "should_cook" means that the span can be "cooked": in tagged template

View File

@ -346,23 +346,23 @@ class PreParserExpression {
: code_(expression_code) {} : code_(expression_code) {}
// The first three bits are for the Type. // The first three bits are for the Type.
typedef BitField<Type, 0, 3> TypeField; using TypeField = BitField<Type, 0, 3>;
// The high order bit applies only to nodes which would inherit from the // The high order bit applies only to nodes which would inherit from the
// Expression ASTNode --- This is by necessity, due to the fact that // Expression ASTNode --- This is by necessity, due to the fact that
// Expression nodes may be represented as multiple Types, not exclusively // Expression nodes may be represented as multiple Types, not exclusively
// through kExpression. // through kExpression.
// TODO(caitp, adamk): clean up PreParserExpression bitfields. // TODO(caitp, adamk): clean up PreParserExpression bitfields.
typedef BitField<bool, TypeField::kNext, 1> IsParenthesizedField; using IsParenthesizedField = BitField<bool, TypeField::kNext, 1>;
// The rest of the bits are interpreted depending on the value // The rest of the bits are interpreted depending on the value
// of the Type field, so they can share the storage. // of the Type field, so they can share the storage.
typedef BitField<ExpressionType, IsParenthesizedField::kNext, 4> using ExpressionTypeField =
ExpressionTypeField; BitField<ExpressionType, IsParenthesizedField::kNext, 4>;
typedef BitField<PreParserIdentifier::Type, IsParenthesizedField::kNext, 8> using IdentifierTypeField =
IdentifierTypeField; BitField<PreParserIdentifier::Type, IsParenthesizedField::kNext, 8>;
typedef BitField<bool, IsParenthesizedField::kNext, 1> using HasCoverInitializedNameField =
HasCoverInitializedNameField; BitField<bool, IsParenthesizedField::kNext, 1>;
uint32_t code_; uint32_t code_;
friend class PreParser; friend class PreParser;
@ -873,36 +873,36 @@ class PreParserPropertyList {};
template <> template <>
struct ParserTypes<PreParser> { struct ParserTypes<PreParser> {
typedef ParserBase<PreParser> Base; using Base = ParserBase<PreParser>;
typedef PreParser Impl; using Impl = PreParser;
// Return types for traversing functions. // Return types for traversing functions.
typedef PreParserExpression ClassLiteralProperty; using ClassLiteralProperty = PreParserExpression;
typedef PreParserExpression Expression; using Expression = PreParserExpression;
typedef PreParserExpression FunctionLiteral; using FunctionLiteral = PreParserExpression;
typedef PreParserExpression ObjectLiteralProperty; using ObjectLiteralProperty = PreParserExpression;
typedef PreParserExpression Suspend; using Suspend = PreParserExpression;
typedef PreParserExpressionList ExpressionList; using ExpressionList = PreParserExpressionList;
typedef PreParserExpressionList ObjectPropertyList; using ObjectPropertyList = PreParserExpressionList;
typedef PreParserFormalParameters FormalParameters; using FormalParameters = PreParserFormalParameters;
typedef PreParserIdentifier Identifier; using Identifier = PreParserIdentifier;
typedef PreParserPropertyList ClassPropertyList; using ClassPropertyList = PreParserPropertyList;
typedef PreParserScopedStatementList StatementList; using StatementList = PreParserScopedStatementList;
typedef PreParserBlock Block; using Block = PreParserBlock;
typedef PreParserStatement BreakableStatement; using BreakableStatement = PreParserStatement;
typedef PreParserStatement ForStatement; using ForStatement = PreParserStatement;
typedef PreParserStatement IterationStatement; using IterationStatement = PreParserStatement;
typedef PreParserStatement Statement; using Statement = PreParserStatement;
// For constructing objects returned by the traversing functions. // For constructing objects returned by the traversing functions.
typedef PreParserFactory Factory; using Factory = PreParserFactory;
// Other implementation-specific tasks. // Other implementation-specific tasks.
typedef PreParserFuncNameInferrer FuncNameInferrer; using FuncNameInferrer = PreParserFuncNameInferrer;
typedef PreParserSourceRange SourceRange; using SourceRange = PreParserSourceRange;
typedef PreParserSourceRangeScope SourceRangeScope; using SourceRangeScope = PreParserSourceRangeScope;
typedef PreParserTarget Target; using Target = PreParserTarget;
typedef PreParserTargetScope TargetScope; using TargetScope = PreParserTargetScope;
}; };
@ -922,9 +922,9 @@ class PreParser : public ParserBase<PreParser> {
friend class ParserBase<PreParser>; friend class ParserBase<PreParser>;
public: public:
typedef PreParserIdentifier Identifier; using Identifier = PreParserIdentifier;
typedef PreParserExpression Expression; using Expression = PreParserExpression;
typedef PreParserStatement Statement; using Statement = PreParserStatement;
enum PreParseResult { enum PreParseResult {
kPreParseStackOverflow, kPreParseStackOverflow,

View File

@ -54,14 +54,14 @@ struct CharTraits;
template <> template <>
struct CharTraits<uint8_t> { struct CharTraits<uint8_t> {
typedef SeqOneByteString String; using String = SeqOneByteString;
typedef ExternalOneByteString ExternalString; using ExternalString = ExternalOneByteString;
}; };
template <> template <>
struct CharTraits<uint16_t> { struct CharTraits<uint16_t> {
typedef SeqTwoByteString String; using String = SeqTwoByteString;
typedef ExternalTwoByteString ExternalString; using ExternalString = ExternalTwoByteString;
}; };
template <typename Char> template <typename Char>
@ -79,7 +79,7 @@ struct Range {
template <typename Char> template <typename Char>
class OnHeapStream { class OnHeapStream {
public: public:
typedef typename CharTraits<Char>::String String; using String = typename CharTraits<Char>::String;
OnHeapStream(Handle<String> string, size_t start_offset, size_t end) OnHeapStream(Handle<String> string, size_t start_offset, size_t end)
: string_(string), start_offset_(start_offset), length_(end) {} : string_(string), start_offset_(start_offset), length_(end) {}
@ -109,7 +109,7 @@ class OnHeapStream {
// ExternalTwoByteString. // ExternalTwoByteString.
template <typename Char> template <typename Char>
class ExternalStringStream { class ExternalStringStream {
typedef typename CharTraits<Char>::ExternalString ExternalString; using ExternalString = typename CharTraits<Char>::ExternalString;
public: public:
ExternalStringStream(ExternalString string, size_t start_offset, ExternalStringStream(ExternalString string, size_t start_offset,