[clang] b698ad0 - [clang][NFC] Rearrange Comment Token and Lexer fields to reduce padding
Nathan James via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 26 17:03:50 PDT 2020
Author: Nathan James
Date: 2020-10-27T00:03:43Z
New Revision: b698ad00cbc76f34f48bb639ffb1cfee47a9737e
URL: https://github.com/llvm/llvm-project/commit/b698ad00cbc76f34f48bb639ffb1cfee47a9737e
DIFF: https://github.com/llvm/llvm-project/commit/b698ad00cbc76f34f48bb639ffb1cfee47a9737e.diff
LOG: [clang][NFC] Rearrange Comment Token and Lexer fields to reduce padding
Rearrange the fields to reduce the size of the classes
Reviewed By: gribozavr2
Differential Revision: https://reviews.llvm.org/D90127
Added:
Modified:
clang/include/clang/AST/CommentLexer.h
clang/lib/AST/CommentLexer.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/CommentLexer.h b/clang/include/clang/AST/CommentLexer.h
index 138fdaca0ff6..94f778501e75 100644
--- a/clang/include/clang/AST/CommentLexer.h
+++ b/clang/include/clang/AST/CommentLexer.h
@@ -62,13 +62,6 @@ class Token {
/// The actual kind of the token.
tok::TokenKind Kind;
- /// Length of the token spelling in comment. Can be 0 for synthenized
- /// tokens.
- unsigned Length;
-
- /// Contains text value associated with a token.
- const char *TextPtr;
-
/// Integer value associated with a token.
///
/// If the token is a known command, contains command ID and TextPtr is
@@ -76,6 +69,13 @@ class Token {
/// contains the length of the string that starts at TextPtr.
unsigned IntVal;
+ /// Length of the token spelling in comment. Can be 0 for synthenized
+ /// tokens.
+ unsigned Length;
+
+ /// Contains text value associated with a token.
+ const char *TextPtr;
+
public:
SourceLocation getLocation() const LLVM_READONLY { return Loc; }
void setLocation(SourceLocation SL) { Loc = SL; }
@@ -232,7 +232,6 @@ class Lexer {
const char *const BufferStart;
const char *const BufferEnd;
- SourceLocation FileLoc;
const char *BufferPtr;
@@ -240,7 +239,14 @@ class Lexer {
/// to newline or BufferEnd, for C comments points to star in '*/'.
const char *CommentEnd;
- enum LexerCommentState {
+ SourceLocation FileLoc;
+
+ /// If true, the commands, html tags, etc will be parsed and reported as
+ /// separate tokens inside the comment body. If false, the comment text will
+ /// be parsed into text and newline tokens.
+ bool ParseCommands;
+
+ enum LexerCommentState : uint8_t {
LCS_BeforeComment,
LCS_InsideBCPLComment,
LCS_InsideCComment,
@@ -250,7 +256,7 @@ class Lexer {
/// Low-level lexer state, track if we are inside or outside of comment.
LexerCommentState CommentState;
- enum LexerState {
+ enum LexerState : uint8_t {
/// Lexing normal comment text
LS_Normal,
@@ -280,11 +286,6 @@ class Lexer {
/// command, including command marker.
SmallString<16> VerbatimBlockEndCommandName;
- /// If true, the commands, html tags, etc will be parsed and reported as
- /// separate tokens inside the comment body. If false, the comment text will
- /// be parsed into text and newline tokens.
- bool ParseCommands;
-
/// Given a character reference name (e.g., "lt"), return the character that
/// it stands for (e.g., "<").
StringRef resolveHTMLNamedCharacterReference(StringRef Name) const;
diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp
index c1ea3eab075e..4bebd41e15ee 100644
--- a/clang/lib/AST/CommentLexer.cpp
+++ b/clang/lib/AST/CommentLexer.cpp
@@ -740,12 +740,11 @@ void Lexer::lexHTMLEndTag(Token &T) {
Lexer::Lexer(llvm::BumpPtrAllocator &Allocator, DiagnosticsEngine &Diags,
const CommandTraits &Traits, SourceLocation FileLoc,
- const char *BufferStart, const char *BufferEnd,
- bool ParseCommands)
+ const char *BufferStart, const char *BufferEnd, bool ParseCommands)
: Allocator(Allocator), Diags(Diags), Traits(Traits),
- BufferStart(BufferStart), BufferEnd(BufferEnd), FileLoc(FileLoc),
- BufferPtr(BufferStart), CommentState(LCS_BeforeComment), State(LS_Normal),
- ParseCommands(ParseCommands) {}
+ BufferStart(BufferStart), BufferEnd(BufferEnd), BufferPtr(BufferStart),
+ FileLoc(FileLoc), ParseCommands(ParseCommands),
+ CommentState(LCS_BeforeComment), State(LS_Normal) {}
void Lexer::lex(Token &T) {
again:
More information about the cfe-commits
mailing list