[clang] adece4e - [clang-format][NFC] Remove superfluous code in UnwrappedLineParser

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 1 13:31:32 PDT 2023


Author: Owen Pan
Date: 2023-08-01T13:31:24-07:00
New Revision: adece4e452e88f47e1b2b7971286906ae5246fb8

URL: https://github.com/llvm/llvm-project/commit/adece4e452e88f47e1b2b7971286906ae5246fb8
DIFF: https://github.com/llvm/llvm-project/commit/adece4e452e88f47e1b2b7971286906ae5246fb8.diff

LOG: [clang-format][NFC] Remove superfluous code in UnwrappedLineParser

Differential Revision: https://reviews.llvm.org/D156643

Added: 
    

Modified: 
    clang/lib/Format/UnwrappedLineParser.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 32619bc56f7a3f..febe43e1ba65f4 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1188,8 +1188,8 @@ void UnwrappedLineParser::parsePPUnknown() {
 static bool tokenCanStartNewLine(const FormatToken &Tok) {
   // Semicolon can be a null-statement, l_square can be a start of a macro or
   // a C++11 attribute, but this doesn't seem to be common.
+  assert(Tok.isNot(TT_AttributeSquare));
   return Tok.isNot(tok::semi) && Tok.isNot(tok::l_brace) &&
-         Tok.isNot(TT_AttributeSquare) &&
          // Tokens that can only be used as binary operators and a part of
          // overloaded operator names.
          Tok.isNot(tok::period) && Tok.isNot(tok::periodstar) &&
@@ -3646,12 +3646,7 @@ bool UnwrappedLineParser::parseEnum() {
     // We can have macros or attributes in between 'enum' and the enum name.
     if (FormatTok->is(tok::l_paren))
       parseParens();
-    if (FormatTok->is(TT_AttributeSquare)) {
-      parseSquare();
-      // Consume the closing TT_AttributeSquare.
-      if (FormatTok->Next && FormatTok->is(TT_AttributeSquare))
-        nextToken();
-    }
+    assert(FormatTok->isNot(TT_AttributeSquare));
     if (FormatTok->is(tok::identifier)) {
       nextToken();
       // If there are two identifiers in a row, this is likely an elaborate


        


More information about the cfe-commits mailing list