diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -118,7 +118,7 @@ /// Determines the semantic type of a syntactic token, e.g. whether "<" is a /// template opener or binary operator. -enum TokenType { +enum TokenType : uint8_t { #define TYPE(X) TT_##X, LIST_TOKEN_TYPES #undef TYPE @@ -149,8 +149,8 @@ ClosesTemplateDeclaration(false), StartsBinaryExpression(false), EndsBinaryExpression(false), PartOfMultiVariableDeclStmt(false), ContinuesLineCommentSection(false), Finalized(false), - BlockKind(BK_Unknown), Type(TT_Unknown), Decision(FD_Unformatted), - PackingKind(PPK_Inconclusive) {} + BlockKind(BK_Unknown), Decision(FD_Unformatted), + PackingKind(PPK_Inconclusive), Type(TT_Unknown) {} /// The \c Token. Token Tok; @@ -233,18 +233,6 @@ assert(getBlockKind() == BBK && "BraceBlockKind overflow!"); } -private: - unsigned Type : 8; - -public: - /// Returns the token's type, e.g. whether "<" is a template opener or - /// binary operator. - TokenType getType() const { return static_cast(Type); } - void setType(TokenType T) { - Type = T; - assert(getType() == T && "TokenType overflow!"); - } - private: /// Stores the formatting decision for the token once it was made. unsigned Decision : 2; @@ -271,6 +259,18 @@ assert(getPackingKind() == K && "ParameterPackingKind overflow!"); } +private: + TokenType Type; + +public: + /// Returns the token's type, e.g. whether "<" is a template opener or + /// binary operator. + TokenType getType() const { return static_cast(Type); } + void setType(TokenType T) { + Type = T; + assert(getType() == T && "TokenType overflow!"); + } + /// The number of newlines immediately before the \c Token. /// /// This can be used to determine what the user wrote in the original code diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2753,7 +2753,7 @@ E = Line.Tokens.end(); I != E; ++I) { llvm::dbgs() << I->Tok->Tok.getName() << "[" - << "T=" << I->Tok->getType() + << "T=" << (unsigned)I->Tok->getType() << ", OC=" << I->Tok->OriginalColumn << "] "; } for (std::list::const_iterator I = Line.Tokens.begin(),