[clang] 659e401 - [clang-format][NFC] Improve an `if` conditional in the annotator

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 26 22:59:51 PST 2023


Author: Owen Pan
Date: 2023-11-26T22:54:44-08:00
New Revision: 659e4017b7371efa8ce97da2d87270c60a93d03d

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

LOG: [clang-format][NFC] Improve an `if` conditional in the annotator

Added: 
    

Modified: 
    clang/lib/Format/TokenAnnotator.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index cfca7c00312aab3..6ae83de40113126 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2391,9 +2391,8 @@ class AnnotatingParser {
       return true;
 
     // If a (non-string) literal follows, this is likely a cast.
-    if (Tok.Next->isNot(tok::string_literal) &&
-        (Tok.Next->Tok.isLiteral() ||
-         Tok.Next->isOneOf(tok::kw_sizeof, tok::kw_alignof))) {
+    if (Tok.Next->isOneOf(tok::kw_sizeof, tok::kw_alignof) ||
+        (Tok.Next->Tok.isLiteral() && Tok.Next->isNot(tok::string_literal))) {
       return true;
     }
 


        


More information about the cfe-commits mailing list